I hope i'm not going to be too much off topic (is there a dedicated topic to pigpio? this is only for python module? DAMN WE HAVE TO CREATE ONE!
), but i have a question for joan.
I'd like to start some testing on the c side of the moon, but as far as i can remember you said (somewhere..) that if pigpiod is running, there can be some problems running c code using pigpio.
Since i have many python script running and using pigpiod, what have i to do to have also c programs running and using pigpio?
(this c part will be much pain LOL)
There can only be one copy of the library running at a time.
sudo pigpiod starts the library and makes its services available via the socket and pipe interfaces.
The Python module, pigs, and piscope use the socket interface to talk to the library. It's preferable to use the socket interface rather than the pipe interface if you want to run your program on a remote machine. The pipe interface is only accessible on the Pi itself.
If possible I recommend you use the socket interface from C. There is a C library pigpiod_if
to help in doing so. It has a very similar interface to the Python module. The only functional difference is that the C version (currently) only allows control of one Pi at a time (you can connect to many simultaneously from the Python module).
If you really need to squeeze the last ounce of performance out of the system you will need to use the C library directly.
In this mode pigpiod becomes redundant. Your C linked program (foobar say) in effect becomes pigpiod. While foobar is running anything which normally connects via the socket or pipe interface won't see any difference. They will transparently connect to foobar rather than pigpiod. You don't have to do anything special in foobar. Once you call gpioInitialise
within foobar the socket and pipe interfaces are automatically started (unless you explicitly say not to with gpioCfgInterfaces
before calling gpioInitialise).
My own take would be try Python first. If the performance isn't there convert to C using pigpiod_if. Only if that is still not good enough go to the raw C I/F.