Closed farzadpanahi closed 3 months ago
Pyserial is sadly enough no longer maintained and the termios exception is not documented.
I will take a look and see if we easily can add a try/expect.
Just as a sidetone, bytesize=6 is legal for serial communication (not for modbus though), so it might be you have a hardware problem on top of this problem.
Versions
pymodbus==3.6.6
,pyserial==3.5
Pymodbus Specific
Description
I am trying to open a serial port using
ModbusSerialClient
, using invalid connection settings (provided by the user) for instancebytesize=6
. In this case,connect
method inserial.py
fails because the following exception is raised frompyserial
:The problem is that unlike
serial.SerialException
,termios.error
is not handled in theconnect
method.Because of this, the connection will not be closed properly and when I try to open the serial port again (with correct connection settings), I will get the following error:
Expected Behavior
I think
ModbusSerialClient
should also handletermios.error
onconnect
and close the connection properly.Code
The following code does the following:
ModbusSerialClient
in try-catch and will explicitly close the connection whentermios.error
is caughtwith
without explicit try-catch).Notes:
x86
. The error can be reproduced consistently on Raspberry Pi 4.Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 4 bytes (0 received)
. The intention is to just test the serial port not to actually read from a device.Logs