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

An OSError when the device is unplugged on RaspberrypiOS #639

Open
H3LL0U opened this issue Mar 13, 2024 · 2 comments
Open

An OSError when the device is unplugged on RaspberrypiOS #639

H3LL0U opened this issue Mar 13, 2024 · 2 comments

Comments

@H3LL0U
Copy link

H3LL0U commented Mar 13, 2024

When the device is unplugged during the execution of the following code:

import keyboard

if __name__ == "__main__":
    keyboard.wait('esc')

The following error acures which breaks the program:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
  File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 106, in start_reading
    self.event_queue.put(device.read_event())
  File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 83, in read_event
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 106, in start_reading
    self.event_queue.put(device.read_event())
  File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 83, in read_event
    data = self.input_file.read(struct.calcsize(event_bin_format))
OSError: [Errno 19] No such device
    data = self.input_file.read(struct.calcsize(event_bin_format))
OSError: [Errno 19] No such device
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 106, in start_reading
    self.event_queue.put(device.read_event())
  File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 83, in read_event
    data = self.input_file.read(struct.calcsize(event_bin_format))
OSError: [Errno 19] No such device

Note: I'm starting the Script through SSH with sudo python3 Log.py and the Script executes normally when the keyboard is innitially plugged in

@H3LL0U
Copy link
Author

H3LL0U commented Mar 13, 2024

#531 Similar Issue

@H3LL0U
Copy link
Author

H3LL0U commented Mar 13, 2024

Partial solution found. Now the keyboard doesn't raise an OSError when disconected. However upon disconecting it reinitializes everything which automatically sets a fake keyboard. The system should be implomented which checks if there are any changes in the usb devices 5d518fa (Will work on it later)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant