Hi Everyone,
I am attempting to run a node.js script that uses gpio_helper. I am using the following code (it also uses pushbullet).
//on Garage state change send notification
helper.onPinChange(6, function(value) {
if (startingvar != 0){
if(value == 1) {
console.log("The garage is open - " + value + " as of " + getDateNow());
pusher.note(null, "GarageFi", "The garage was opened.", function(error, response) {
//process.exit(); // kill the script once push is sent
});
} else if(value == 0){
console.log("The garage is closed - " + value + " as of " + getDateNow());
pusher.note(null, "GarageFi", "The garage was closed.", function(error, response) {
//process.exit(); // kill the script once push is sent
});
}
}
});
Now the problem comes when I poll this same GPIO pin via the Onion Cloud API. If I poll the same GPIO pin it either hangs (using the web UI), or it crashes as follows:
fs.js:603
var r = binding.read(fd, buffer, offset, length, position);
^
Error: ENODEV: no such device, read
at Error (native)
at Object.fs.readSync (fs.js:603:19)
at Object.fs.readFileSync (fs.js:433:24)
at GPIOHelper.getPinSync (/root/gpiohelper.js:77:15)
at GPIOHelper._poll (/root/gpiohelper.js:110:20)
at null._repeat (/root/gpiohelper.js:100:8)
at wrapper [as _onTimeout] (timers.js:275:11)
at Timer.listOnTimeout (timers.js:92:15)
Is it not possible to watch for the GPIO state with the JS code and at the same time have the API read the state as well?