jperkin / node-rpio

Raspberry Pi GPIO library for node.js
858 stars 124 forks source link

Thrown: GPIO12 is currently in use by /sys/class/gpio #54

Closed japita-se closed 6 years ago

japita-se commented 6 years ago

I think this function is not necessary in rpio.js

function check_sys_gpio(pin)

In fact, in RPI3 + nodejs 8 we can't use rpio. If I comment that function all is fine.

jperkin commented 6 years ago

It's required so that the module does not conflict with any process that might be using the /sys interface. You need to unexport the pins via /sys first, so that the gpio state cannot be corrupted.

japita-se commented 6 years ago

Uhm... can you tell me how to unexport? Because, if I comment that function everything works. g

jperkin commented 6 years ago

You echo the pin number to the /sys/class/gpio/unexport control file. Pins are not exported by default, so something on your system has enabled them without disabling them again afterwards, hence the conflict. You can read more about the sysfs interface here https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

This module uses a different interface to control the pins, which is why we bail out if the sysfs interface is in use. While it may happen to work ok by commenting out the check, it's only due to pure luck. You can't use both interfaces simultaneously and expect things to work correctly.

japita-se commented 6 years ago

Ok, thank you very much for your help