Max314
Posts: 9
Joined: Tue Oct 20, 2015 10:45 pm

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

Mon Nov 02, 2015 10:52 pm

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

User avatar
AndyD
Posts: 2331
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

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

Mon Nov 02, 2015 11:00 pm

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?
Last edited by AndyD on Tue Nov 03, 2015 12:00 am, edited 1 time in total.

User avatar
DougieLawson
Posts: 35815
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

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

Mon Nov 02, 2015 11:51 pm

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/.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
AndyD
Posts: 2331
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

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

Tue Nov 03, 2015 12:08 am

My understanding it that GPIO Zero is a Python library.

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

Max314
Posts: 9
Joined: Tue Oct 20, 2015 10:45 pm

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

Tue Nov 03, 2015 1:11 am

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. :)
Last edited by Max314 on Tue Nov 03, 2015 2:03 am, edited 2 times in total.

User avatar
AndyD
Posts: 2331
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

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

Tue Nov 03, 2015 1:52 am

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

Max314
Posts: 9
Joined: Tue Oct 20, 2015 10:45 pm

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

Tue Nov 03, 2015 2:06 am

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)

User avatar
AndyD
Posts: 2331
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

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

Tue Nov 03, 2015 3:18 am

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

Max314
Posts: 9
Joined: Tue Oct 20, 2015 10:45 pm

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

Tue Nov 03, 2015 12:49 pm

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.

DirkS
Posts: 9902
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

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

Tue Nov 03, 2015 12:51 pm

Max314 wrote:okay here are the code:
Nothing showing; the images don't show up and the links result in a 403 error (forbidden)...

User avatar
with ice cream
Posts: 161
Joined: Mon Jul 30, 2012 7:25 am

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

Thu Dec 03, 2015 3:47 pm

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).

User avatar
joan
Posts: 14196
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

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

Thu Dec 03, 2015 3:58 pm

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.

User avatar
DougieLawson
Posts: 35815
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

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

Thu Dec 03, 2015 4:17 pm

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?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Beginners”