Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

gpio input not working #101

Open
kratostav opened this issue Oct 15, 2014 · 7 comments
Open

gpio input not working #101

kratostav opened this issue Oct 15, 2014 · 7 comments

Comments

@kratostav
Copy link

Gpio input shows as down.
It doesnt go up.
raspberry pi revision 0000d

@tjanson
Copy link
Contributor

tjanson commented Oct 15, 2014

What’s the output of ls /sys/devices/virtual/gpio? Without more info I’d suspect that the Pin isn’t exported, because, well, apparently the GPIO plugin doesn’t do that.
So a manual gpio export [pin] in (where [pin] is the BCM pin number [why!?]) should fix it.
Of course this really should be done by the plugin, or at least documented better.

@kratostav
Copy link
Author

ls gives:
pi@schretterpi ~ $ ls /sys/devices/virtual/gpio
gpiochip0
pi@schretterpi ~ $

gpio export (command not found??
pi@schretterpi ~ $ gpio export pin 17 in
-bash: gpio: command not found

Why is there a gpiochip0 only?
Output is working properly

@kratostav
Copy link
Author

got it working with
pi@schretterpi ~ $ echo 17 > /sys/class/gpio/export
pi@schretterpi ~ $ echo in > /sys/class/gpio/gpio17/direction

gpio

but why i have to do this manually?

@tjanson
Copy link
Contributor

tjanson commented Oct 15, 2014

I’m not familiar with this part of the code. Looks like it was simply forgotten. I’ll look into it.

@ni-c
Copy link
Owner

ni-c commented Oct 16, 2014

Maybe it works if you change line 80 in plugins/gpio/index.js (https://github.com/ni-c/heimcontrol.js/blob/master/plugins/gpio/index.js#L80) from

gpio.setDirection(parseInt(item.pin), "input", function(err) {

to

gpio.open(parseInt(item.pin), "input", function(err) {

I have no time to test it now, but i think this could be the problem.

@tjanson
Copy link
Contributor

tjanson commented Oct 16, 2014

I'm working on a fix. I'll rewrite the pi-gpio library.

Seems drastic, but it's overdue. Switching the underlying export mechanism
from quick2wire's gpio-admin to Wiring Pi's gpio should improve lots of
things including this issue, because its export can be called multiple
times, whereas gpio-admin export errors if called on an open pin. (See
rakeshpai/pi-gpio#24.)

@tjanson
Copy link
Contributor

tjanson commented Oct 19, 2014

Here’s what I’ve been working on: tjanson/heimcontrol.js@ad79484 (which uses a rewritten version of pi-gpio, which uses a wrapper of Wiring Pi gpio util).

Feel free to give it a try. I’ll write a PR once I have some feedback here: rakeshpai/pi-gpio#25.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants