Open kratostav opened 9 years ago
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.
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
got it working with pi@schretterpi ~ $ echo 17 > /sys/class/gpio/export pi@schretterpi ~ $ echo in > /sys/class/gpio/gpio17/direction
but why i have to do this manually?
I’m not familiar with this part of the code. Looks like it was simply forgotten. I’ll look into it.
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.
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.)
Here’s what I’ve been working on: tjanson/heimcontrol.js@ad79484f1ccd8cb130512be2df0e9868bbae7cb6 (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.
Gpio input shows as down. It doesnt go up. raspberry pi revision 0000d