Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unplugging a serial-over-USB steno machine leaves Plover in an undefined state #1559

Closed
sol opened this issue Sep 1, 2022 · 0 comments · Fixed by #1560
Closed

Unplugging a serial-over-USB steno machine leaves Plover in an undefined state #1559

sol opened this issue Sep 1, 2022 · 0 comments · Fixed by #1560
Labels

Comments

@sol
Copy link
Contributor

sol commented Sep 1, 2022

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

  1. Plug a GeminiPR serial-over-USB machine into a free USB port of your computer (e.g. a USB keyboard running QMK).
  2. In Plover, configure and connect the machine.
  3. Unplug the machine from your computer.

Expected behavior

Tray icon and mouseover text should indicate that the machine is disconnected:

expected

Actual behavior

Tray icon and mouse overtext wrongly indicate that the machine is connected:

actual

Operating system

  • OS: Linux 5.19.4 (zen patches)
  • Plover Version: 3066a9a (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:

  1. Reading through all the related discussions gets unwieldy quickly. To address this I hope that this issue provides a more compact summary.
  2. The exciting PR is technically a breaking change. To address this I opened Update machine state on unhandled exceptions #1560, an alternative approach that does not introduce any breaking changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant