Improve serial connection logging

27 views
Skip to first unread message

Marc Rechté

unread,
Aug 15, 2025, 12:30:26 PMAug 15
to MPF Users
Hello. Some time to time, I experiment serial port disconnection, due to some kind of USB hub failure. The message I get when this happens is:

"SerialException( 'device reports readiness to read but returned no data (device  isconnected or multiple access on port?)')"

from serial.serialposix.Serial.read().

The stack trace (regarding mpf) is
machine.py: 770
machine.py: 820
opp/opp.py: 197
base_serial_communicator.py:149

The problem is that I have 7 serial ports (2 hubs), and as the message does not state the port, it is not easy to find the culprit.

May be this exception should be caught and a better message reported with the port name.

Some help to improve the code is appreciated !

Alex L

unread,
Aug 15, 2025, 6:52:10 PMAug 15
to MPF Users
I suspect you're hitting the catch and reraise here (and the stacktrace you're seeing is the cleanup process, not the connection attempt itself failing):

Is the info log line (50) from before the connection attempt showing up? Maybe you can add another log line before the reraise (if you confirm this is the right spot), since the debug log on 63 only happens in production mode.

Marc Rechté

unread,
Aug 16, 2025, 6:45:21 AMAug 16
to MPF Users
Yes that's correct, except that this occurs during the game, not at startup (see attach log when reproducing the problem on a single port config). The idea would be to catch the triggering exception (log line 8) and raise a more explicit connection, showing the port name and, ideally the chain_serial (OPP case).
trace_when_disconnection_serial.log
Reply all
Reply to author
Forward
0 new messages