Comments (13)
Thanks for the report and for the solution.
I think there are two issues here:
- the README examples are not very good as they don't catch the errors on pin setup, and people are following their bad example.
- the API is perhaps a bit too granular for how people want to use the module. Setting up and writing to a pin must be the most common use-case, yet it requires two method calls and error handling at each level. Perhaps there should be a simpler API that combines the step and provides a single place where error-handling is required.
from rpi-gpio.js.
It turns out it was a "permission denied" error comming from the method setEdge.
Since the error wasn't being handled on the "setup" function the next block wasn't being executed and i also didn't realise the problem.
Actually the library just failed silently, when logging the error i got
{ [Error: EACCES: permission denied, open '/sys/class/gpio/gpio11/edge']
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/sys/class/gpio/gpio11/edge' }
the solution was to run my script with "sudo" or give the right permissions to my user
from rpi-gpio.js.
@JamesBarwell thanks a lot for your library and for your input. i wish i had done a pull request instead of simply opening a issue. the problem is that i'm quite new to dealing with gpio so i'm backtracked on my project trying to figure out some of my application problems first - apologises about that.
Also, on a similar subject, if you don't mind me asking here:
I'm trying to figure out is how to read encoders, i have seem some examples using C and it seems they read a "stream" that comes from the encoder..
I'm not sure how we could make this happen using the "read" function here?
I tried to read as fast as possible, but it didn't seem to be right way of doing?
Perhaps for encoders and other sort of inputs we could somehow integrate with node.js streams making some sort of "socket connection" to the gpio ?
And last but not least, i believe perhaps we should replace using async for something like bluebird Promises ?
I believe it would make it easier to handle the errors and also to read the source code.
Again, thank you very very much for putting this together.
Hopefully i'll figure my stuff out soon and get back with some pull requests instead of feature requests!
from rpi-gpio.js.
I'd be interested in streaming input, but I'm afraid it's not something I have much knowledge of at the moment, nor will I have any time to look at. This module really just wraps the existing GPIO filesystem functions, so it may be a bit out of scope.
There was a request to use promises in: #34. I'm not ruling it out but it's not the route I want to go down at the moment. The API could definitely be improved, but I am still keen to stick to the style of the node.js API at present.
from rpi-gpio.js.
Hi. Is there any update on this topic?
I am facing the same issue with setting up the edge. And for me it is quite confusing. I am running script on Raspbian Jessie with pi user, which already added to gpio group, but no success dealing with npm module.
I don't want run script with root permissions.
from rpi-gpio.js.
I've only done a little reading on this so I'm prepared to be convinced otherwise, but from what I can see root permissions are required to write to the filesystem for these pins. This module is really just a wrapper for those filesystem operations so it's not within scope of this module to try and work around it. I don't think this module should be involved in messing around with file permissions or user groups, etc.
So at the moment my thinking is that it's up to the user of this module to either compartmentalise their application appropriately, so that only some of it is running with root permissions, and/or do something with the sudoers file to restrict what can get run. There's a blog post along similar lines here: http://www.mobilewill.us/2012/07/raspberry-pi-and-gpio-permissions.html
from rpi-gpio.js.
@JamesBarwell thank you for the reply. I was just wondering if you have solution for that.
Now I launched my app with service with root user and it works properly.
Good luck in research.
from rpi-gpio.js.
@JamesBarwell / @alexandrbig i'm pretty sure you don't need to be root, just google it and you will find! unfortunately i don't have the link as reference right now
from rpi-gpio.js.
I think I found the root cause for this. Wrote it up in #48 .
from rpi-gpio.js.
There's a new version 0.8.1
which should no longer require root permissions.
from rpi-gpio.js.
I am using 0.8.1 and still having this issue on my Pi 3B. I am doing something wrong?
from rpi-gpio.js.
@PiyushRamuka Could you raise a new issue and include the code you're using + all the details of the error please.
from rpi-gpio.js.
@JamesBarwell - created one. Thanks!
Issue 59
from rpi-gpio.js.
Related Issues (20)
- Hint: epoll Update regarding Windows. HOT 6
- Broken on 64-bit Linux HOT 1
- when to support model 4? HOT 2
- This library supported raspberry pi 4? HOT 4
- Convert library to typescript HOT 4
- Read only seems to work with pin 7 (GPIO 4)
- EACCES error on fresh installation
- Getting undefined when using promises HOT 1
- npm on-off module HOT 1
- .setMode() doesn't work in Promises interface HOT 1
- gpio.accessible() method HOT 3
- Only pin 31 seems to work as in input HOT 1
- EACCES in setup() caused by race
- Could not locate the bindings file HOT 1
- False not working HOT 1
- destroy does not unexport
- Segmentation Error on instantiation (v2.1.7) on Pi OS HOT 2
- COMPUTE MODULE 4 generates error
- Support GPIO on Raspberry Pi 5 HOT 2
- Move to libgpiod
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rpi-gpio.js.