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

Switch to Wiring Pi GPIO utility #27

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

tjanson
Copy link
Collaborator

@tjanson tjanson commented Oct 31, 2014

Let me know if any changes are required. Also: This passes all tests and works for me, but should still be tested manually.

Uses pi-gpioutil, a wrapper for Wiring Pi's gpio utility, rather than
quick2wire's gpio-admin.
Benefits include more robust pin exports.

Further improvement option: Speed up read/writes by using native code bindings,
such as: https://github.com/eugeneware/wiring-pi
deduplicated auto-exporting code
test for board revision
README: inital example adapted

README: linebreaks

README: export example
@pierreprinetti
Copy link
Contributor

Hello. I'm using this branch with my RPi A+. It seems to work so far. Is there something I could do to test it further and let it eventually merge into master?

@tjanson
Copy link
Collaborator Author

tjanson commented May 4, 2015

@qrawl, @gausie Have you been using it so far without errors? Maybe we could get this merged after all.

@rakeshpai
Copy link
Owner

Waiting for confirmation that someone has tested this. I don't have a Pi handy to test this on. Just one other person's confirmation would be good enough.

@pierreprinetti
Copy link
Contributor

I've been using this branch with my A+ and although I haven't performed programmatic tests, I can say I haven't had any problems so far.

@rakeshpai
Copy link
Owner

Awesome.

@tjanson Just looking through the code. Any reason you've used pi-gpioutil for some functions (like export, unexport), but not for others (read, write, etc.)? I don't have a problem with adding pi-gpioutil as a dep, but I'd rather the code be consistent with using pi-gpioutil or fs, but not both. And given the choice, I'd rather reduce deps than adding them.

@tjanson
Copy link
Collaborator Author

tjanson commented May 6, 2015

It’s been a long time, let me try to remember.

@risingtiger
Copy link

seems to be working fine on Model B+, Revision: 1.2...

@risingtiger
Copy link

Great work tjanson on this branch. One suggestion on overloading the write and read method. Instead of passing a string type argument for 'force', why not pass an object. Something like:

write(23, 1, {exportMode: force}, callback);

This opens up flexibility for future additions and is more of a standard approach (at least in my experiences).

Just a thought. Looking forward to getting this merged in.

@tjanson
Copy link
Collaborator Author

tjanson commented May 7, 2015

Yes, good point @risingtiger. I wasn’t very familiar with JS when I wrote that. There are probably other possible improvements too. I won’t implement that since I don’t have a Pi for testing at the moment (and other things on my mind). If you’re interested, feel free :)

@risingtiger
Copy link

Sure thing. I'll have a bit of time later today to jump in on it.

@risingtiger
Copy link

@tjanson I've pulled the gpioutil-fs-hybrid branch, overloaded the write/read methods with option objects and pushed back to my fork of pi-gpio here #37.

Hopefully we can get this all merged back to rakeshpai/pi-gpio soon.

@ccarterc
Copy link

Would love to see this merge. :) Anyone still working on it?

@rally25rs
Copy link

I just tried this branch on a Pi2 B+ and get the error:

ERROR [gpioUtil] exec failed: 'gpio export 26 out':
/bin/sh: 1: gpio: not found

ERROR [pi-gpio] failed to export pin 37

Edit:

Nevermind, I had to install WiringPI first, following the directions here: http://wiringpi.com/download-and-install/.


Edit 2:

OK, this runs without errors, but does not actually write values to the pins.

The node code:

gpio.write(37, 1);

opens gpio26 in "output" mode, but does not set the value to 1.

from a 2nd console:

> cat /sys/class/gpio/gpio26/direction
out

> cat /sys/class/gpio/gpio26/value
0

Also tested with a voltmeter. If I manually echo "1" > /sys/class/gpio/gpio26/value then I get voltage, but the JS call to .write(37, 1) does not have voltage.

Any ideas?

@tjanson
Copy link
Collaborator Author

tjanson commented Feb 28, 2016

If varSysPath in line 15 of pi-gpio.js is "/sys/devices/virtual/gpio", then try changing that to the path you used: "/sys/class/gpio". I don’t have a Pi 2 (nor have I used this project in a while), but I guess this is the new location of the GPIO device.

Oh, this was in fact already filed as issue #45 by @alex-dacosta, and fixed (?) by 82ef7bd on master.

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

Successfully merging this pull request may close these issues.

6 participants