Comments (8)
What type of ARM machine is being used?
Did the same code work in the past?
from onoff.
yes, its a armv7, i just updated node from v4.4.x to v4.5.0
from onoff.
I can't reproduce the error with the sample program posted above using Node.js 4.5.0 and GPIO4 on an ARMv7 Raspberry Pi 2:
pi@raspberrypi:~/onoff $ node -v
v4.5.0
pi@raspberrypi:~/onoff $ cat t.js
const GpioOnOff = require('onoff').Gpio;
const button = new GpioOnOff(4, 'in', 'both');
button.watch(function(err, value) {
console.log('jo');
console.log(err, value);
});
pi@raspberrypi:~/onoff $ node t.js
jo
null 1
jo
null 0
jo
null 1
jo
null 0
jo
null 1
jo
null 0
i just updated node from v4.4.x to v4.5.0
Is Node.js the only thing that was updated or were other things updated, for example, the operating system? If the operating system was updated, is it possible that the GPIO driver was updated and that the old driver supported interrupt detection on GPIO239 but the new driver doesn't?
from onoff.
What type of computer is being used? As in Raspberry Pi, BeagleBone, CHIP, ...
from onoff.
I use an ARM A20 CPU, like the CHIP uses. its very strange, because it seems that the watch
function is not called always. sometimes it works, but not really deterministic. when I run button.readSync();
it works aswell:
> button
Gpio {
gpio: 239,
gpioPath: '/sys/class/gpio/gpio239/',
opts: { debounceTimeout: 0 },
readBuffer: <Buffer 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
listeners: [ [Function] ],
valueFd: 15,
poller: Epoll { closed: false } }
> button.readSync();
0
> button.readSync();
1
.. any hints?
from onoff.
OK - I know what triggers the problem. I did already export the gpio in my application - now when I start my test above, the watch function almost never works. however if I run echo 239 > /sys/class/gpio/unexport
I let onoff export the GPIO port, and THEN the watch function works.
Maybe it make sense to add an option that onoff should not touch the gpio config?
Update:
It seems the actual GPIO config seems not related to this issue, when I start the test tools the first time after an unexport it works, then I quit node, restart node with the test app above - watch does not work anymore.
So I see this solution:
- add option that the current gpio port gets unexported before the pin gets used. this would resolve the current issue and might eliminate the "The pin has already been exported," branch. The unexport call can also made optional, so that it gets only executed when the current pin is exported. what do you think?
from onoff.
I can't reproduce the error by running an app that exports the GPIO and a second app that uses the GPIO.
Here's the app that exports the GPIO:
const GpioOnOff = require('onoff').Gpio;
const button = new GpioOnOff(4, 'in', 'both');
setInterval(function () {
console.log('Hello, World!');
}, 1000);
Here's the test app that uses the GPIO:
const GpioOnOff = require('onoff').Gpio;
const button = new GpioOnOff(4, 'in', 'both');
button.watch(function(err, value) {
console.log('jo');
console.log(err, value);
});
Some questions posted above haven't been answered:
- Did the same code work in the past?
- Is Node.js the only thing that was updated or were other things updated, for example, the operating system?
The title of this issue is "Does not work anymore on Node v4.5.0 (ARM)". This title implies that it did work in the past. I'm almost certain that the update from Node.js v4.4.x to Node V4.5.0 didn't cause the issue and that something else was also modified but not mentioned yet.
In order to move forward sample code to reproduce the error is needed.
from onoff.
Yes you're right, this bug report is completely borked. I create a new one.
from onoff.
Related Issues (20)
- Problem using watch function with relay HOT 10
- Initialize GPIO without change pin status. HOT 6
- GPIO not working in a worker_thread - nodejs 14.15 HOT 2
- EACCES: permission denied, open '/sys/class/gpio/export' as superuser HOT 2
- Cannot run on non Rpi system HOT 1
- TypeError: writeSync is not a function HOT 4
- Raspberry Pi GPIO control in electron App HOT 8
- My computer does not have a /sys/class/gpio directory, but has /dev/gpiochip* HOT 1
- Interrupt misfire HOT 3
- Raspberry 4 - malloc(): corrupted top size HOT 3
- Error: EPERM: operation not permitted, write HOT 4
- Does not work with Compute Module 4. HOT 2
- Event is fired multiple times
- Superb library - I am running on Node v20 HOT 2
- Pi 5 Compatibility issues HOT 9
- Compatibility with ppp asked?
- RPI 5 gpio numbers HOT 2
- fs error HOT 8
- Newer version of epoll
- Button.watch spams endlessly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onoff.