Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I/O errors on first launch #31

Closed
joraff opened this issue Apr 9, 2015 · 4 comments
Closed

I/O errors on first launch #31

joraff opened this issue Apr 9, 2015 · 4 comments

Comments

@joraff
Copy link

joraff commented Apr 9, 2015

The first time I launch a node application (as sudo) that uses onoff.js, I get this error:

fs.js:540
  return binding.write(fd, buffer, offset, length, position);
                 ^
Error: EIO, i/o error
    at Object.fs.writeSync (fs.js:540:18)
    at Object.fs.writeFileSync (fs.js:987:21)
    at new Gpio (/home/pi/nodeplay/node_modules/onoff/onoff.js:103:10)
    at Object.<anonymous> (/home/pi/nodeplay/process.js:15:16)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)

Subsequent launches are fine, until the next reboot.
Any ideas?

@fivdi
Copy link
Owner

fivdi commented Apr 10, 2015

Is the following the case:

  • The program is creating a Gpio object where the direction is "output" and the edge is "rising", "falling", or "both".
  • Linux kernel > 3.13 is being used.

dmesg may also be displaying messages similar to these:

[ 1180.184658] GPIO chip pinctrl-bcm2835: gpio_lock_as_irq: tried to flag a GPIO set as output for IRQ
[ 1180.184688] gpio-17 (sysfs): failed to flag the GPIO for IRQ

If this is the case, then the error is explained by the fact that the Linux 3.13 kernel dropped support for detecting changes on GPIO output pins per hardware interrupt. It can still detect interrupts on input pins.

This is documented in the onoff readme here :).

See also raspberrypi/linux#808 and torvalds/linux@d468bf9

@joraff
Copy link
Author

joraff commented Apr 13, 2015

That's precisely it: new Gpio(4, 'out', 'falling'); What a bummer. Would an acceptable workaround be to initialize as an input, then switch to an output if I need to drive it?

@fivdi
Copy link
Owner

fivdi commented Apr 13, 2015

Given that I have no information about the circuit you're building, I don't know. If everything is electrically ok, the setEdge and setDirection methods could probably be used to handle the software side of things.

@joraff
Copy link
Author

joraff commented Apr 13, 2015

Electrically everything is fine - it was working on a RPi model B+ before I upgraded to RPi 2. I was most likely using an older version of raspbian.

@joraff joraff closed this as completed Apr 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants