Page 1 of 1

How to give permissions to a file that works with dev/mem??

Posted: Mon Nov 02, 2015 10:52 pm
by Max314
Hi! I'm working in a project that use GPIO. But in this project, the program cant be execute as super user, because it need run automatically, when the RPi starts . So I dont know how can I give permissions to this file. I tried to use chmod, but the program doesn't run.
Thanks

Re: How to give permissions to a file that works with dev/me

Posted: Mon Nov 02, 2015 11:00 pm
by AndyD
It makes sense that /dev/mem is only readable/writable by root. Don't try to change the permissions of /dev/mem.

If you are running your program at startup, you can run it as root. How are you running your program at startup?

There are ways to access the GPIO without running your program as root. What language is your program written in?

Re: How to give permissions to a file that works with dev/me

Posted: Mon Nov 02, 2015 11:51 pm
by DougieLawson
http://raspi.tv/2015/gpio-zero-introduction

There's also some words in MagPi #39 about GPIO Zero which doesn't need sudo access or any fiddling with permissions for /dev/mem/.

Re: How to give permissions to a file that works with dev/me

Posted: Tue Nov 03, 2015 12:08 am
by AndyD
My understanding it that GPIO Zero is a Python library.

You could also look at Joan's pigpio C library.

Re: How to give permissions to a file that works with dev/me

Posted: Tue Nov 03, 2015 1:11 am
by Max314
Python.
Now I'm testing the GPIO Zero library to see how can I use it.
The true is that I dont really know how I can start this program when de RPi starts. If you have any idea how I can do it, I offer my thanks. :)

Re: How to give permissions to a file that works with dev/me

Posted: Tue Nov 03, 2015 1:52 am
by AndyD
Max314 wrote:The true is that I dont really know how I can start this program when de RPi starts. If you have any idea how I can do it, I offer my thanks. :)
You could have a look at starting your script using rc.local or crontab

Re: How to give permissions to a file that works with dev/me

Posted: Tue Nov 03, 2015 2:06 am
by Max314
Ok, thanks. I will check it out. But first..
I already tested the gpio zero, using

Code: Select all

from gpiozero import Button
(to use as output), and it has the same problem. :( Any idea?
(ps: I prefer use Python, because C would change all my program)

Re: How to give permissions to a file that works with dev/me

Posted: Tue Nov 03, 2015 3:18 am
by AndyD
Max314 wrote:Ok, thanks. I will check it out. But first..
I already tested the gpio zero, using

Code: Select all

from gpiozero import Button
(to use as output), and it has the same problem. :( Any idea?
Are you saying that using gpio zero you still get permission problems with /dev/mem?

Can you post your code?

PS. If you post your code please post in a code block to preserve the formatting.

Code: Select all

[code]
[/code]
The example on the GPIO Zero home page work for me.

Code: Select all

from gpiozero import LED, Button

led = LED(2)
button = Button(3)

button.when_pressed = led.on
button.when_released = led.off

Re: How to give permissions to a file that works with dev/me

Posted: Tue Nov 03, 2015 12:49 pm
by Max314
okay here are the code:
Image
URL: https://mail.google.com/mail/u/0/?ui=2& ... w1335-h448

and here are de error:
Image
URL:https://mail.google.com/mail/u/0/?ui=2& ... w1335-h448

The variables are in portuguese, because I speak portuguese :? :P ...Well, whatever, the code doesnt work.

Re: How to give permissions to a file that works with dev/me

Posted: Tue Nov 03, 2015 12:51 pm
by DirkS
Max314 wrote:okay here are the code:
Nothing showing; the images don't show up and the links result in a 403 error (forbidden)...

Re: How to give permissions to a file that works with dev/me

Posted: Thu Dec 03, 2015 3:47 pm
by with ice cream
DougieLawson wrote:GPIO Zero which doesn't need sudo access or any fiddling with permissions for /dev/mem/.
I am in a similar situation. I user a cgi-bin python script and gpiozero but the error output mentions denied access to /dev/mem (for www-data).

Re: How to give permissions to a file that works with dev/me

Posted: Thu Dec 03, 2015 3:58 pm
by joan
with ice cream wrote:
DougieLawson wrote:GPIO Zero which doesn't need sudo access or any fiddling with permissions for /dev/mem/.
I am in a similar situation. I user a cgi-bin python script and gpiozero but the error output mentions denied access to /dev/mem (for www-data).
Details of the cgi-bin script and the error message would be useful.

Re: How to give permissions to a file that works with dev/me

Posted: Thu Dec 03, 2015 4:17 pm
by DougieLawson
with ice cream wrote: I am in a similar situation. I user a cgi-bin python script and gpiozero but the error output mentions denied access to /dev/mem (for www-data).
Have you added userid www-data to group gpio?