hariprasad
Posts: 3
Joined: Wed Apr 02, 2014 2:29 pm

Getting problem when using wiringPiSetup()

Thu Apr 17, 2014 7:27 am

Hai to all,
I am writing code to access the gpio from the Qt, and i was included the wiringPi library to Qt also..
Now my problem is when i write the setup function i.e wiringPiSetup() in mainwindow.cpp file and run, it is saying..

"Starting /home/pi/Desktop/Qtprojects/pi_lcd/....
wiringPiSetup: Must be root. (Did you forget sudo?)
/home/pi/Desktop/Qtprojects/pi_lcd/pi_lcd exited with code 1"

How to set the root permissions for the function or for wiringPi..
Please help me...
Thanks in advance..

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Getting problem when using wiringPiSetup()

Thu Apr 17, 2014 5:10 pm

Call it with sudo. You need to execute your Python script as sudo python myscrypt.py
Sudo means "I want the root user to execute the following command." Think of it as meaning SuperUser (aka root) DO this.

hariprasad
Posts: 3
Joined: Wed Apr 02, 2014 2:29 pm

Re: Getting problem when using wiringPiSetup()

Fri Apr 18, 2014 6:47 am

Thank you for the reply..

I am writing code in Qt and i want to know how to set the root permissions for it to access..

Thanks in advance..

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Getting problem when using wiringPiSetup()

Sat Apr 19, 2014 5:01 am

I don't know QT, but with other languages I've used, if you execute your program as root (using sudo in front of whatever command you normally use to execute it) the whole program gets root permissions, and can therefore use the GPIO functions.

So if your normal command is:
qt program
you would run it as root by executing:
sudo qt program

Return to “Beginners”