Skip to content

close() fails with rtscts=True #5

@davegravy

Description

@davegravy
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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions