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

Error reading from event1: read /dev/input/event1: invalid argument #3

Open
queez0405 opened this issue Nov 4, 2024 · 6 comments
Open
Assignees

Comments

@queez0405
Copy link

image

Thank you for this wonderful project. I am currently using a Raspberry Pi Zero 2W running Bullseye Raspberry Pi OS 32-bit. I installed the code using Golang and Task, and connected a Bluetooth keyboard to the RPi. However, after running task run, whenever I press any key on the Bluetooth keyboard, I get an "invalid argument" error as shown in the image above. Any hints or pointers regarding this issue would be greatly appreciated.

Environment:

  • Hardware: Raspberry Pi Zero 2W
  • OS: Raspberry Pi OS Bullseye (32-bit)
  • Tools: Golang, Task
  • Peripheral: Bluetooth keyboard
@bahaaador
Copy link
Owner

bahaaador commented Nov 4, 2024

Hi @queez0405, my pleasure! I'm glad you are finding this useful 😊

This might be related to input event size and structure on 32-bit systems. So far I've only tried it on 64-bit.

I'll try to add some better debugging controls here. In the meantime, could you share the output for these commands?

cat /proc/bus/input/devices
sudo dd if=/dev/input/event1 bs=24 count=1 2>/dev/null | hexdump -C

The second command will wait for the input and then pipe the result to hexdump (part of bsdmainutils package)

-Bahador

@bahaaador bahaaador self-assigned this Nov 4, 2024
@bahaaador
Copy link
Owner

I just pushed a new changeset

This includes a potential fix (use 32bit int for event time instead of 64bit) for the issue you encountered, and a few other cleanup and improvements.

Please give it a shot when you have a chance and let me know how it goes and if you'd need further assistance.

Cheers

@queez0405
Copy link
Author

queez0405 commented Nov 5, 2024

Thank you for your quick response @bahaaador! I've reinstalled the software for 32-bit OS, but I'm still experiencing issues.
The program now crashes whenever I press a keyboard key. I've attached screenshots showing:
image

The output of cat /proc/bus/input/devices
image
The result of running sudo dd if=/dev/input/event1 bs=24 count=1 2>/dev/null | hexdump -C (which doesn't produce any output)
image

I've included screenshots for reference. Thanks again for your help!

@bahaaador
Copy link
Owner

bahaaador commented Nov 5, 2024

Thanks for sharing the screenshots, @queez0405. Based on the first one, it seems like the event is being correctly mapped now (16 bytes with 32-bit architecture), which is great. A quick heads-up that I'm planning to update the code so that the even size is set dynamically depending on the Architecture, so keep an eye on this and let me know if the invalid argument error resurfaces.

Regarding the other issue you mentioned, from the logs that you shared, I don't see any error or crash report. Could you share more details about what you are encountering? I've also added two new tools to help with troubleshooting and testing, with the latest code you should be able to run them through task doctor and task simulate

@queez0405
Copy link
Author

The invalid argument error seems to be working perfectly now! Thank you for the quick feedback.
Let me explain more about the subsequent issue. As mentioned before, when pressing any key on the keyboard (alphabet or numpad), misc event received and read event from event1 appear once, but there's no response on the desktop computer. Even pressing other keys doesn't trigger any response. Therefore, I had to terminate the process using Ctrl+C.

image

Thank you for the update! Here are the results after running the updated task doctor and task simulate:
image
image

While task doctor seems to be detecting the devices correctly, when running task simulate, neither mouse example 1 nor keyboard example 2 worked on the desktop computer.

@bahaaador
Copy link
Owner

bahaaador commented Nov 6, 2024

Thanks for sharing the all of this @queez0405 . The good news is that alsmost everything on the HID seems to be working as expected. We just have to figure out what's going on in the host machine that the USB port is connected to.

I don't think you've mentioned what machine you're trying it on I've tested with Mac and Windows machines. In macOS and linux you can run ls USB -v (and this would be a different machine than the one you ran the initial commands on) on Windows, you should be able to gather more information using Device Manager there might be some similar powershell commands as well.

Try to gather some more information using those and share it to see if that would give us any clue.

If you can access other machines, try it with those as well. To make this easier, you can run task service:install to install the relay as a service that will be persistent after reboot. Good Luck!

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

2 participants