From The Compiler, 5 Years ago, written in Plain Text.
Embed
  1. #!/usr/bin/python
  2. import serial
  3. import binascii
  4. import time
  5. import sys
  6.  
  7. if len(sys.argv) <= 1:
  8.     print("Usage: ser.py /dev/ttyXXX")
  9.     sys.exit(1)
  10.  
  11. s = serial.Serial(sys.argv[1], 1200, timeout=0.1)
  12. s.setDTR(True)
  13. s.setRTS(False)
  14.  
  15. for x in range(5):
  16.     s.write(b'\x01')
  17.     re = s.read(16)
  18.     print(binascii.hexlify(re).decode('ASCII'))
  19.     time.sleep(1)