Git Product home page Git Product logo

Comments (8)

fivdi avatar fivdi commented on July 22, 2024

What type of ARM machine is being used?
Did the same code work in the past?

from onoff.

neophob avatar neophob commented on July 22, 2024

yes, its a armv7, i just updated node from v4.4.x to v4.5.0

from onoff.

fivdi avatar fivdi commented on July 22, 2024

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.

fivdi avatar fivdi commented on July 22, 2024

What type of computer is being used? As in Raspberry Pi, BeagleBone, CHIP, ...

from onoff.

neophob avatar neophob commented on July 22, 2024

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.

neophob avatar neophob commented on July 22, 2024

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.

fivdi avatar fivdi commented on July 22, 2024

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.

neophob avatar neophob commented on July 22, 2024

Yes you're right, this bug report is completely borked. I create a new one.

from onoff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.