Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close() fails with rtscts=True #5

Open
davegravy opened this issue Mar 10, 2024 · 0 comments
Open

close() fails with rtscts=True #5

davegravy opened this issue Mar 10, 2024 · 0 comments
Assignees

Comments

@davegravy
Copy link

davegravy commented Mar 10, 2024

from mpio import Serial

ser = Serial("/dev/ttyS1", 115200, rtscts=True)

ser.write(b"AT\r")
ser.close()

CTS is high preventing the data from being written, and so ser.close() is hanging indefinitely.

Traceback (most recent call last):
  File "mpio-serial-test.py", line 11, in <module>
    ser.close()
  File "/usr/local/lib/python3.8/dist-packages/mpio/serial.py", line 306, in close
    os.close(self._fd)
KeyboardInterrupt
Exception ignored in: <function Serial.__del__ at 0xb6b371d8>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/mpio/serial.py", line 87, in __del__
  File "/usr/local/lib/python3.8/dist-packages/mpio/serial.py", line 306, in close
OSError: [Errno 9] Bad file descriptor

(doesn't happen with rtscts=False)

Consider adding termios.tcflush(fd, termios.TCOFLUSH) to the close() function

@noglitch noglitch self-assigned this Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants