bansari18
Posts: 21
Joined: Tue Mar 07, 2017 1:04 pm

Unable to access pigpio without sudo.

Mon Apr 17, 2017 9:48 am

Hi.. I am using pigpio module for LED pwm in RGB led strip. But I am unable to run it without sudo i.e. as root.. so if there is any way i can use it without root permission. as it give me try running as root . precede the command with 'sudo' error.
I have also tried running 'sudo pigpiod' to start the daemon. but got the same result.
Thanks in advance.
-Bansari

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

Re: Unable to access pigpio without sudo.

Mon Apr 17, 2017 10:34 am

You need to use sudo to start the pigpio daemon (sudo pigpiod) or run a program linked against the pigpio library.

You do not need sudo to run a pigpio Python script or to run a program linked against the pigpiod_if library (both of which use the services of the running pigpio daemon).

User avatar
bitbank
Posts: 253
Joined: Sat Nov 07, 2015 8:01 am
Location: Sarasota, Florida
Contact: Website

Re: Unable to access pigpio without sudo.

Tue Jul 11, 2017 3:25 pm

joan - I'm in need of your advice. My C application uses PIGPIO to access GPIO pins and the SPI bus. It also uses SDL2 to output audio. When running as root, USB audio devices fail to open, but the bcm2835 PWM audio driver still works. Is there any way to use your library for GPIO/SPI without having to have my program run as root?
The fastest code is none at all :)

User avatar
bitbank
Posts: 253
Joined: Sat Nov 07, 2015 8:01 am
Location: Sarasota, Florida
Contact: Website

Re: Unable to access pigpio without sudo.

Wed Jul 26, 2017 7:39 pm

As a follow-up to my own post, I discovered a way to make it work. The USB audio adapter I'm using doesn't work when the calling program has root privilege. The way around this is to give the executable root privilege, but run it as user. To give an executable root privilege:

sudo chown root:root my_program
sudo chmod 4755 my_program

This allows PIGPIO to run as root, but creating threads with pthread that run as user.
The fastest code is none at all :)

Return to “Beginners”