Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 0.78 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How can I get a byte that represents an unsigned int in Java?
  2. OutputStream out;
  3. public void writeToStream(int i) throws Exception {
  4.     out.write(((byte)(i & 0xff)));
  5. }
  6.        
  7. uint8_t nextByte() {
  8.     while(1) {
  9.     if(Serial.available() > 0) {
  10.         uint8_t b =  Serial.read();
  11.       return b;
  12.      }
  13.     }
  14. }
  15.        
  16. class writerThread(threading.Thread):
  17.     def __init__(self, threadID, name):
  18.         threading.Thread.__init__(self)
  19.         self.threadID = threadID
  20.         self.name = name
  21.     def run(self):
  22.         while True:
  23.             input = raw_input("[W}Give Me Input!")
  24.             if (input == "exit"):
  25.                exit("Goodbye");
  26.             print ("[W]You input %sn" % input.strip())
  27.             fval = [ int(input.strip()) ]
  28.             ser.write("".join([chr(x) for x in fval]))