code_junkie

Programmatically talking to a Serial Port in OS X or Linux

Nov 10th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. stty -f /dev/cu.usbserial
  2. speed 9600 baud;
  3. lflags: -icanon -isig -iexten -echo
  4. iflags: -icrnl -ixon -ixany -imaxbel -brkint
  5. oflags: -opost -onlcr -oxtabs
  6. cflags: cs8 -parenb
  7.  
  8. #!/usr/bin/python
  9.  
  10. import serial
  11.  
  12. ser = serial.Serial('/dev/cu.usbserial', 9600, timeout=10)
  13. ser.write("<ID01><PA> rn")
  14. read_chars = ser.read(20)
  15. print read_chars
  16.  
  17. ser.close()
  18.  
  19. /dev/cu.usbserial-xxxxxxxxA/dev/tty.usbserial-xxxxxxxxA/dev/cu.usbserial-xxxxxxxxB/dev/tty.usbserial-xxxxxxxxB
Add Comment
Please, Sign In to add comment