After having opened my serial port /dev/tty/USB0
with pyserial
:
>>> ser = serial.Serial("/dev/ttyUSB0", 57600)
>>> ser.isOpen()
True
>>> ser.close()
>>> ser.isOpen()
False
I can no longer read /dev/ttyUSB0
with the command cat /dev/ttyUSB0
usually cat /dev/ttyUSB0
is a blocking command like read
, but after the serial port is opened/closed with pyserial, the cat
command become non blocking, seems like busy ...
Does anybody knows what causes this?
when pyserial opens the tty, it implicitly reconfigure some parameters of the tty for example: time=0
which set the timeout to 0 second, and min=0
, which set the minimum characters to read, etc.
And to restore the default behavior, use the linux command stty
stty -F /dev/ttyUSB0 icanon