Guest User

Untitled

a guest
Jun 26th, 2012
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  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]))
Advertisement
Add Comment
Please, Sign In to add comment