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, write #52

Closed
antsmo opened this issue Jul 23, 2016 · 5 comments
Closed

EPERM: operation not permitted, write #52

antsmo opened this issue Jul 23, 2016 · 5 comments

Comments

@antsmo
Copy link

antsmo commented Jul 23, 2016

Hi, I'm just trying the functions out and I'm currently trying to write to pin 4, but getting the above error message. Here's the code, it's pretty basic..

`var Gpio = require('onoff').Gpio,
led = new Gpio(4, 'out');

led.write(1);`

Has anyone come across this before?

@antsmo
Copy link
Author

antsmo commented Jul 23, 2016

My apologies for the double submit, please delete the other issue.

This was solved by running the script with SUDO

@antsmo antsmo closed this as completed Jul 23, 2016
@fivdi
Copy link
Owner

fivdi commented Jul 23, 2016

@SimonTheEngineer if Raspbian Jessie is being used as mentioned here then it should not be necessary to run the script with sudo if logged on as user pi. Were you logged on as user pi?

@antsmo
Copy link
Author

antsmo commented Jul 23, 2016

I was yes, fresh install too so all permissions should be default

@fivdi
Copy link
Owner

fivdi commented Jul 23, 2016

I just gave it a try with Raspbian Jessie and don't have the issue. i.e., it's not necessary to run the script with sudo.

What happens if you run the following commands from the command line? They should turn the LED connected to gpio4 on. Do the commands turn the LED on or is there an EPERM error?

pi@raspberrypi:~ $ cd /sys/class/gpio/
pi@raspberrypi:/sys/class/gpio $ echo 4 > export 
pi@raspberrypi:/sys/class/gpio $ echo out > gpio4/direction 
pi@raspberrypi:/sys/class/gpio $ echo 1 > gpio4/value 
pi@raspberrypi:/sys/class/gpio $ 

@fivdi
Copy link
Owner

fivdi commented Jul 23, 2016

Note that EPERM: operation not permitted, write isn't actually related to permissions. An EPERM error occurs when an operation is not permitted because it doesn't make sense. In this case it looks like the EPERM error occurred because an an attempt was made to write data to an input. Here's an example:

pi@raspberrypi:~ $ cd /sys/class/gpio/
pi@raspberrypi:/sys/class/gpio $ echo 17 > export 
pi@raspberrypi:/sys/class/gpio $ cd gpio17
pi@raspberrypi:/sys/class/gpio/gpio17 $ echo in > direction 
pi@raspberrypi:/sys/class/gpio/gpio17 $ echo 1 > value 
-bash: echo: write error: Operation not permitted
pi@raspberrypi:/sys/class/gpio/gpio17 $ 

Errors related to permissions are usually EACCES errors.

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