openstenoproject / plover

Open source stenotype engine
http://opensteno.org/plover
GNU General Public License v2.0
2.35k stars 281 forks source link

Serial port stopped working after suspend (sleep) and resume (wake up) #1273

Open user202729 opened 3 years ago

user202729 commented 3 years ago

I think this is an issue with the cdc_acm kernel module rather than pyserial or Plover.

dmesg have this:

[] cdc_acm 2-1:1.2: resume error -1

(on wake up), and

[] cdc_acm 2-1:1.1: acm_port_activate - usb_submit_urb(ctrl irq) failed

on reconnect.


Apart from unplugging and plugging the USB device, the only way I found out to fix the issue is to run sudo modprobe -r cdc_acm; sudo modprobe cdc_acm (requires root permission).

As a workaround, I set the machine to remove the module on sleep and reload it on wake up (search for "execute script on wake up", and optionally, "sudo without password").


Describe the bug

Title.

To Reproduce

Steps to reproduce the behavior:

  1. Open Plover
  2. Connect a Gemini PR machine
  3. Put the computer to sleep
  4. Wake it up
  5. The serial port stopped working

Expected behavior

It keeps working.

Operating system

Hardware

Georgi with Gemini PR protocol.

user202729 commented 3 years ago

Now there is a new type of error... (although I think this is still a kernel bug rather than Plover's)

  File ".../site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 6] could not open port /dev/ttyACM0: [Errno 6] No such device or address: '/dev/ttyACM0'

This one unfortunately cannot be fixed by replugging the USB port, or restarting Plover. rmmod cdc_acm works normally, rmmod -f cdc_acm hangs, lsmod hangs (disk sleep?).

user202729 commented 3 years ago

It might also freeze (and consequently freeze the whole GUI, because of the engine lock) (I should upgrade the operating system already)

  File ".../threading.py", line 912, in _bootstrap
    self._bootstrap_inner()
  File ".../threading.py", line 954, in _bootstrap_inner
    self.run()
  File ".../base.py", line 169, in run
    self.machine._error()
  File ".../base.py", line 233, in _error
    self._close_port()
  File ".../base.py", line 239, in _close_port
    self.serial_port.close()
  File ".../serialposix.py", line 451, in close
    os.close(self.fd)