fork download
  1. import serial
  2. bytearray = [ 0o10010000, 0o10111000, 0o00000000, 0o00000000, 0o00000111, 0o01010101, 0o10100100, 0o01111011, 0o00000000, 0o11011010,0o00000011,
  3. 0o00000010,0o00000101,0o00000001 ]
  4.  
  5. try:
  6. ser = serial.Serial('COM3')
  7. ser.baudrate = 57600
  8. ser.timeout = 0.1
  9. ser.open()
  10. except Exception as e:
  11. print('Error opening port - ' + str(e))
  12.  
  13. while ser.isOpen():
  14. try:
  15. #arr = ['\x90','\xB8','\0','\0','\a', '\x55','\xA4','\x7B','\0','\xDA','\x03', '\x02','\x05','\x01']
  16. ser.write(bytearray)
  17. ser.read()
  18. print(ser.read())
  19. finally:
  20. ser.read()
  21. print(ser.read())
Runtime error #stdin #stdout #stderr 0.02s 27712KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named 'serial'