
Untitled
By: a guest on
Jun 26th, 2012 | syntax:
None | size: 0.78 KB | hits: 9 | expires: Never
How can I get a byte that represents an unsigned int in Java?
OutputStream out;
public void writeToStream(int i) throws Exception {
out.write(((byte)(i & 0xff)));
}
uint8_t nextByte() {
while(1) {
if(Serial.available() > 0) {
uint8_t b = Serial.read();
return b;
}
}
}
class writerThread(threading.Thread):
def __init__(self, threadID, name):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
def run(self):
while True:
input = raw_input("[W}Give Me Input!")
if (input == "exit"):
exit("Goodbye");
print ("[W]You input %sn" % input.strip())
fval = [ int(input.strip()) ]
ser.write("".join([chr(x) for x in fval]))