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

EPERM, operation not permitted while pin.value(true); #3

Open
kiddyfurby opened this issue Jan 26, 2015 · 4 comments
Open

EPERM, operation not permitted while pin.value(true); #3

kiddyfurby opened this issue Jan 26, 2015 · 4 comments

Comments

@kiddyfurby
Copy link

On both a raspberry pi (arch linux arm) and a beaglebone black (debian) I get a permission denied running test.js that came with npm install pi-pins
If I change index.js:46 to use a write() instead of writeSync() there will be no error, however I do want to make sure my write are not just buffered.

trace from node test.js

fs.js:540
return binding.write(fd, buffer, offset, length, position);
^
Error: EPERM, operation not permitted
at Object.fs.writeSync (fs.js:540:18)
at EventEmitter.gpio.value (/root/nrf/node_modules/nrf/node_modules/pi-pins/index.js:46:16)
at Object. (/root/nrf/node_modules/nrf/node_modules/pi-pins/test.js:9:6)

@natevw
Copy link
Owner

natevw commented Jan 30, 2015

The Raspberry Pi GPIO device files are not available to users by default. You'll need to either start your script via sudo, or, setup your permissions so that your desired user can access. See Raspberry Pi – using GPIO / WiringPi without root (sudo) access or Stack Overflow: Accessing the GPIO (of a raspberry pi) without sudo for potential advice on the latter.

@natevw natevw closed this as completed Jan 30, 2015
@natevw
Copy link
Owner

natevw commented Jan 30, 2015

Actually, I'm reopening this issue as I review the non-sudo solutions. The device files themselves are "exported" (i.e. created) by this library during normal course of operations:

fs.writeFileSync("/sys/class/gpio/export", ''+pin);

So I'd like to add a CLI script to this package that can be used once (via sudo) to make the pins available, so that the script actually using them can be run non-privileged.

In the meantime the workaround would be to use the existing Python/C/whatever utilities that do this first. Thanks for the bug report, @kiddyfurby!

@natevw natevw reopened this Jan 30, 2015
@kiddyfurby
Copy link
Author

Thank you for your great library!

manually export the GPIO and chmod didn't help, actually, not even running as root helps.
chmod -R 777 /sys/class/gpio/gpio20
chmod -R 777 /sys/class/gpio/gpio21

[root@alarmpi pi-pins]# node test.js
Should be true: false
Should be false: false

fs.js:540
return binding.write(fd, buffer, offset, length, position);
^
Error: EPERM, operation not permitted
at Object.fs.writeSync (fs.js:540:18)
at EventEmitter.gpio.value (/root/pi-pins/node_modules/pi-pins/index.js:46:16)

@kiddyfurby
Copy link
Author

I needed one line of change in pi-pins index.js

gpio.mode = function (mode) {       // 'in','out','low','high'
    fs.writeFileSync(pinPath+"/direction", mode);
    if (mode == 'high' || mode == 'low') this.value( mode == 'high' ); // add this line!
};

screen shot 2015-02-05 at 1 15 00 pm
I do however still have problems with nrf (not sure if I should post here or there).
My logic analyzer suggest that the CE pin was set high too early, more precisely, before even W_TX_PAYLOAD is shifted out via SPI

Could it be that the GPIO and SPI handling of Linux has different timing?

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