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

write errno: -22 #79

Open
xyboox opened this issue Feb 10, 2018 · 3 comments
Open

write errno: -22 #79

xyboox opened this issue Feb 10, 2018 · 3 comments

Comments

@xyboox
Copy link

xyboox commented Feb 10, 2018

Hi,
I was trying to test the examples and seems like I'm stuck with this error:
GPIO Setup ERROR: { Error: EINVAL: invalid argument, write errno: -22, code: 'EINVAL', syscall: 'write' }

Here's my code:
`// GPIO
var gpio = require('rpi-gpio');

var pin     = 4;
var delay   = 2000;
var countIO = 0;
var max     = 3;

gpio.setup(pin, 'out', on);

function on (err) {
    if (err) {
        logger.info('GPIO Setup ERROR: %O', err);
        return;
    }
    if (countIO >= max) {
        gpio.destroy(function() {
            logger.info('Closed pins, now exit');
        });
        return;
    }

    setTimeout(function() {
        gpio.write(pin, 1, off);
        countIO += 1;
    }, delay);
}

function off() {
    setTimeout(function() {
        gpio.write(pin, 0, on);
    }, delay);
}`

I'm using node v8.9.0 on a Raspberry Pi Zero
User is added to gpio group.

Any idea about what's wrong?
Thanks!

LE: I just saw that actually pin 4 ( one I'm trying to use ) is mapped to 7. So I change it in my code to 7. No I have another error:
GPIO Setup ERROR: %O { Error: EBUSY: resource busy or locked, write errno: -16, code: 'EBUSY', syscall: 'write' }

@thecodershome
Copy link
Contributor

Can you upload your debug log? Try adding DEBUG=rpi-gpio before your command

@filiptc
Copy link

filiptc commented Jan 6, 2019

Same thing happening here. GPIO (pin 2) interaction is fine via BASH. Debug output:

> var pomise = gpiop.setup(2, gpio.DIR_OUT)
      .then(() => gpiop.write(2, false))
      .catch(e => { console.log(e); });
undefined
>   rpi-gpio seen hardware revision 8322; using pin mode v2 +0ms
  rpi-gpio set up pin NaN +8ms
  rpi-gpio export pin NaN +5ms
{ [Error: EINVAL: invalid argument, write] errno: -22, code: 'EINVAL', syscall: 'write' }

@filiptc
Copy link

filiptc commented Jan 6, 2019

I switched to PIN 7 (GPIO4), which works fine. I guess SDA0 GPIO2, is not usable for some reason.

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

3 participants