bchanudet / OctoPrint-Octorant

Discord plugin for OctoPrint
MIT License
26 stars 14 forks source link

before and after scripts root /dev/mem access #36

Open wmhunter96 opened 5 years ago

wmhunter96 commented 5 years ago

I'm trying to turn on a couple of NeoPixels before and after using the scripts but I believe the only way to interact with GPIO pins is with root access. Any help?

without sudo before my script I get a Can't open /dev/mem: Operation not permitted

bchanudet commented 5 years ago

Hello there!

If I recal correctly, since a few years it's not necessary anymore to have root access to use the GPIO. Are you using an old library or distribution?

As Octoprint itself is not running as root, I don't know if I can make it execute a script requiring root. Maybe by creating a bash file that calls your script with sudo? And then you'd call this script in OctoRant.

I finally have a Octoprint instance running on a Raspberry Pi (I had a real computer for it before), I will do a few tests in the upcoming weeks if you want.

Cheers!

wmhunter96 commented 5 years ago

learn.adafruit.com/neopixels-on-raspberry-pi?view=all

"For NeoPixels to work on Raspberry Pi, you must run the code as root! Root access is required to access the RPi peripherals."

I had the idea of creating a bash file as well however when you run sudo in a bash file wouldn't it be waiting for a password?