ola icon indicating copy to clipboard operation
ola copied to clipboard

Have gpio plugin handle exporting of gpio.

Open robotkid450 opened this issue 7 years ago • 6 comments

Make the gpio plug in handle the exporting and permissions involved with outputting from gpio. OLAD currently has to be restarted once gpio is exported and has is permissions fixed.

robotkid450 avatar Feb 27 '18 06:02 robotkid450

Hi @robotkid450 ,

I don't think its likely. If you take a look here: https://wiki.openlighting.org/index.php/OLA_Device_Specific_Configuration#General_Purpose_I.2FO

You have to run these commands as root; in OLA we do our best to stop you running it as root: https://github.com/OpenLightingProject/ola/blob/9fbd4e4782223135bdf4b75098c0dbf1e3cb65ed/olad/Olad.cpp#L99

Essentially because if we do, bad things can happen to your machine which can be our fault. If we're not root, you can only generally break olad.

I don't think the commands will work as non-root, unless you've done something quite global already, so there's probably not much point in doing so.

I guess the compromise we could do would be to ship a script that reads the relevant olad config file, and does the leg work for you, so you just configure it in OLA and then run the script, rather than needing to tweak all the 23's in that example to the GPIO pins you're using.

peternewman avatar Feb 28 '18 14:02 peternewman

As discussed in #1188, pigpiod ( http://abyz.me.uk/rpi/pigpio/pigpiod.html ) may also be of use for this as a workaround for the root issue.

peternewman avatar Mar 04 '18 10:03 peternewman

OLAD currently has to be restarted once gpio is exported and has is permissions fixed.

if you are referring to raspberry, then just create a initscript that runs before ola on boot.

arielmol avatar May 29 '18 18:05 arielmol

@peternewman

in OLA we do our best to stop you running it as root:

And I think that's a good thing

arielmol avatar May 29 '18 18:05 arielmol

Just to put in a tidbit of information, maybe using the GPIO character device could be good? No more creating / destroying files to export / unexport GPIO pins, and automatic cleanup of reserved pins in case olad crashes. Upstream wants to deprecate the sysfs interface, anyway - see https://www.kernel.org/doc/Documentation/ABI/obsolete/sysfs-gpio . There's a nice C++ library available for this, too - https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/ . Permissions can also be managed much easier, in a sense it's like spidev - but for simple GPIO. It's pretty quick too, you can manage around 400kbit/s while bitbanging SPI on a Rapsberry Pi.

shenghaoyang avatar Jun 10 '18 14:06 shenghaoyang

Do you have any reference for the bitbanging SPI using the libgpiod library?

kripton avatar Feb 12 '21 21:02 kripton