plover
plover copied to clipboard
Unplugging a serial-over-USB steno machine leaves Plover in an undefined state
Description
When you unplug a serial-over-USB steno machine then:
- The thread that handles the serial connection dies silently.
- Other parts of the system never learn about this.
- The tray icon is never updated, the disconnect is never indicated to the user.
Steps to reproduce
- Plug a GeminiPR serial-over-USB machine into a free USB port of your computer (e.g. a USB keyboard running QMK).
- In Plover, configure and connect the machine.
- Unplug the machine from your computer.
Expected behavior
Tray icon and mouseover text should indicate that the machine is disconnected:
Actual behavior
Tray icon and mouse overtext wrongly indicate that the machine is connected:
Operating system
- OS: Linux 5.19.4 (zen patches)
- Plover Version: https://github.com/openstenoproject/plover/commit/3066a9a47269861ac1d66f8f05cdb26f7251b98d (master)
Discussion
Plover handles serial connections in a dedicated machine thread. The machine thread communicates events to other parts of the system via callbacks.
When you unplug a serial-over-USB device then pyserial
indicates the disconnect by throwing an exception:
serial.serialutil.SerialException: device reports readiness to read but returned no data
(device disconnected or multiple access on port?)
Plover does not handle these exceptions. Instead the machine thread dies silently.
This has been discussed before in #596 and more recently in #1273. There is also a related PR that address the issue #1054.
From what I can tell, this is straightforward to fix. I’m not sure what exactly is holding a fix back. Two things I noticed:
- Reading through all the related discussions gets unwieldy quickly. To address this I hope that this issue provides a more compact summary.
- The exciting PR is technically a breaking change. To address this I opened #1560, an alternative approach that does not introduce any breaking changes.