-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support for GPIO monitoring callbacks #23
Comments
Hi @varadero i am doing some cleanup and after that will work on that for 1.x branch first. At some point we can discuss proper api design/ergonomics here, ;-) |
I would be truly interested in that as well. Did you make any progress? |
Hello @Garfonso indeed this feature is one will be a big improvement, i just need testcases / gpiosim up and running so i can handle the missing bits of 1.x API. staty tuned! |
Given that javascript was designed as an event-driven language, I would rank this with high priority. It seems you have much on your plate with this project, so patience is definitely worth the reward here. |
I don't understand how anybody is using GPIO with nodejs nowadays. Since Bookworm gpiod is the norm to use GPIO, but there is no way to use it properly in nodejs. This library can set and get values, but a very important part of GPIO is event monitoring. I have a reset button attached to a GPIO pin of which I need an event on the rising and falling edge. This was no problem with the old |
Actually, there were problems with the sys FS interface. Most notably, nothing in sys FS interface prevented other threads from appropriating occupied resources (a GPIO chips' exposed pins). Many of the C/C++ offerings (PiGPIO, MRAA, wiringPi) wrapped the sys FS interface into something that can only be described as "a best effort to shield end-users from the pitfalls of the sys FS interface." But, the limited design of the sys FS interface often required wrappers to have root access... This didn't bode well for environments (a python venv for example) that were designed to avoid messing with system-scoped resources. The newer (ioctl-based) char dev interface does not require root privileges. FYI, the GPIO API is the latest of Linux kernel's peripheral APIs to switch to a char dev API. The Linux kernel's I2C and SPI interfaces have been using a (ioctl-based) char dev paradigm for years. You might find Linux kernel examples for I2C still using the older sys FS interface (like the undead wiringPi library does).
I landed on this repo because npmjs.com showed search results that haven't been updated in years. It would seem that embedded Linux isn't a popular use case for node.js (despite the node-red project which used to ship with RPi OS). The char dev API depends on using the Linux kernel's Alternative IdeaThe authors of libgpiod (which is a convenience wrapper for the Linux kernel's char dev API) also ship a rust binding. I thought about wrapping that binding in a napi-rs project, but (like this node-gpiod project) it is not a simple undertaking. The only benefit is that a napi-rs project can ship compiled binaries/modules ( |
I know that GPIO monitoring callbacks is in the roadmap but it would be really great addition. I have tried node-libgpiod with Raspberry Pi 5 4GB (I just needed to change
new Chip(0)
tonew Chip(4)
) and it works great for setting the outputs but don't know how to do the "monitoring" (like detecting push buttons connected to some GPIO). I am willing to sponsor the addition of the callbacks to the library.The text was updated successfully, but these errors were encountered: