Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. [serial_test.py]
  2.  
  3. from periphery import Serial
  4.  
  5. serial = Serial("/dev/ttyS0", 115200)
  6.  
  7. serial.write(b"Hello World!")
  8.  
  9. buf = serial.read(128, 0.5)
  10. print("read %d bytes: _%s_" % (len(buf), buf))
  11. serial.close()
  12.  
  13. $ python3 serial_test.py
  14. Traceback (most recent call last):
  15. File "/usr/local/lib/python3.5/dist-packages/periphery/serial.py", line 166, in _open
  16. termios.tcsetattr(self._fd, termios.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
  17. termios.error: (5, 'Input/output error')
  18.  
  19. Traceback (most recent call last):
  20. File "serial.py", line 5, in <module>
  21. serial = Serial("/dev/ttyS0", 115200)
  22. File "/usr/local/lib/python3.5/dist-packages/periphery/serial.py", line 60, in __init__
  23. self._open(devpath, baudrate, databits, parity, stopbits, xonxoff, rtscts)
  24. File "/usr/local/lib/python3.5/dist-packages/periphery/serial.py", line 168, in _open
  25. raise SerialError(e.errno, "Setting serial port attributes: " + e.strerror)
  26. AttributeError: 'error' object has no attribute 'errno'
  27.  
  28. $ stty -F /dev/ttyS0
  29. stty: /dev/ttyS0: Input/output error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement