AbstractBeliefs

Untitled

Oct 25th, 2011
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. import sys
  2. import serial
  3.  
  4. port = raw_input("Which port? > ")
  5. baud = int(raw_input("What baud? > "))
  6.  
  7. try:
  8.     port = serial.Serial(port, baud, timeout=0)
  9. except SerialException:
  10.     print "Couldn't open port, quitting."
  11.     sys.exit(1)
  12. except:
  13.     print "An error occurred, quitting."
  14.     sys.exit(2)
  15.  
  16. while True:
  17.     if port.inWaiting() > 0:
  18.         sys.stdout.write( str(ord( port.read(1) )) )
  19.  
  20.  
Advertisement
Add Comment
Please, Sign In to add comment