Code Monkey home page Code Monkey logo

Comments (13)

JamesBarwell avatar JamesBarwell commented on August 24, 2024 1

Thanks for the report and for the solution.

I think there are two issues here:

  1. the README examples are not very good as they don't catch the errors on pin setup, and people are following their bad example.
  2. 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.

hems avatar hems commented on August 24, 2024

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.

hems avatar hems commented on August 24, 2024

@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.

JamesBarwell avatar JamesBarwell commented on August 24, 2024

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.

alexandrbig avatar alexandrbig commented on August 24, 2024

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.

JamesBarwell avatar JamesBarwell commented on August 24, 2024

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.

alexandrbig avatar alexandrbig commented on August 24, 2024

@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.

hems avatar hems commented on August 24, 2024

@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.

awong-dev avatar awong-dev commented on August 24, 2024

I think I found the root cause for this. Wrote it up in #48 .

from rpi-gpio.js.

JamesBarwell avatar JamesBarwell commented on August 24, 2024

There's a new version 0.8.1 which should no longer require root permissions.

from rpi-gpio.js.

PiyushRamuka avatar PiyushRamuka commented on August 24, 2024

I am using 0.8.1 and still having this issue on my Pi 3B. I am doing something wrong?

from rpi-gpio.js.

JamesBarwell avatar JamesBarwell commented on August 24, 2024

@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.

PiyushRamuka avatar PiyushRamuka commented on August 24, 2024

@JamesBarwell - created one. Thanks!
Issue 59

from rpi-gpio.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.