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

Add error messages when /dev/input fails to open #1005

Open
5 tasks done
pacohope opened this issue Jun 1, 2023 · 1 comment
Open
5 tasks done

Add error messages when /dev/input fails to open #1005

pacohope opened this issue Jun 1, 2023 · 1 comment

Comments

@pacohope
Copy link

pacohope commented Jun 1, 2023

Which node are you reporting an issue on?

node-red-node-pi-gpio

What are the steps to reproduce?

  1. Install node-red on a raspberry pi running raspberry pi OS (Debian 11)
  2. Make sure the user running node-red is NOT a member of the input group in /etc/group
  3. Create a flow with an rpi-keyboard node
  4. Deploy the flow. Note that the rpi-keyboard node will vascillate between "OK" and "Stopped"
  5. Look in the node red logs (e.g., run node-red-log) and look for information about what is wrong
  6. Find none. :)

What happens?

There is no error logged that I could find in this circumstance. For background, you can see my discord post about it, too.

What do you expect to happen?

It would be nice if there was a "Failed to open keyboard: permission denied" or similar log message.

I looked at the code, and it seems like lines 185 and 208 of nrgpio.py might be the right place. I'd be happy to submit a PR with a few except calls in there to handle the failed permissions and post error messages. It would be my first contribution, so I wanted to ask about whether (a) this is the right place, and (b) won't this flood the logs with messages over and over, every time it tries to initialise the keyboard or mouse? So is there something I should do to throttle it or limit the amount of logging it does?

If someone wants to answer the questions to make sure I have the problem correctly scoped and whether I'm right about the solution, I will gladly work up and contribute a PR to fix it.

Please tell us about your environment:

  • Node-RED version: 3.0.2
  • node.js version: v16.20.0
  • npm version: 9.6.7
  • Platform/OS: Linux raspberrypi 6.1.21-v8+
  • Browser: Firefox usually
@dceejay
Copy link
Member

dceejay commented Jun 1, 2023

Hi yes - a pull request would be most welcome !
so
a) yes - this is fine !
b) possibly yes - you could add a delay so it only retries every 10-15 secs - which would off course still flood the log - but more slowly... or you could hold the error in a flag variable - and if you see it again then don't report it. (and clear the variable on success of course) - that way it would only be reported once which would cleaner.

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