Comments (5)
Only one copy of the pigpio library is allowed to run at a time.
The reason is that the library opens a rare resource, a DMA channel, and then starts sampling the GPIO at a high rate using that channel.
It is possible to start pigpio and tell it to use a different DMA channel, but this use is prevented by the lock on /var/run/pigpio.pid. In extremis you could remove the lock code to allow multiple copies.
In fact there are very few DMA channels left. Originally pigpio had about 13 channels (from 15) to select from, now its sometimes hard to find a free channel.
There is very little you can do when directly linked with the library that you can't do just as well by using the daemon.
If you do have such a need then I suggest you put all the time-critical code in one process and launch that instead of pigpiod. Your process then in effect becomes the pigpiod and will automatically service daemon requests via its socket and pipe interface (unless you disable those interfaces with gpioCfg* options at process start).
from pigpio.
Thanks for your detailed explanation! In fact, it is what I did yesterday. I moved any critical code into one process. I just wanted to ask and it makes totally sense.
I must spread another thank-you for the great work you did on pigpio!
from pigpio.
BTW If you do run your program as a replacement for pigpiod
you ought to use the same lock/runfile /var/run/pigpio.pid
in the same way as pigpiod
. I'm doing that for my UPiS daemon which uses the I2C bus and reserves a dedicated GPIO pin for a "shut-down NOW" "hardware" interrupt and it runs on startup as root - so it makes sense to run it as the daemon so it can prevent other processes from touching/hogging resources that it wants.
from pigpio.
That should be automatic as the locking is actually handled by the library during initialisation. The code is initGrabLockFile in pigpio.c.
from pigpio.
Ah, I got that slightly wrong - my code is linked against libpigpio
and using pigpio.h
the header _not libpigpiod
and pigpiod.h
- as I need to have different signal handling behaviour (my daemon needs to catch and handle SIGPIPE (and posibbly SIGPWR) and I do not want it to terminate if it gets SIGSTOP/SIGTSTP/SIGTTOUT/SIGTTIN/SIGCONT) - FWIIW I've clobbered the code base as per (my) PR #58...
from pigpio.
Related Issues (20)
- How to access MCP23008 expander GPIOs?
- CM4 HDMI Audio + pigpio conflict? HOT 9
- general on pigpiod daemon HOT 4
- pigpio callback issue with threads
- Can create SPI wave in nano seconds resolution? HOT 10
- Initialization issue on debian 12 bookworm HOT 2
- `git pull` or `git clone` actions return 'https://github.com/joan2937/pigpio/': SSL certificate problem: certificate is not yet valid HOT 1
- Possible issue with wave function on PI 4 8GB bullseye 64bit HOT 39
- pigpio probably won't work on Pi5 (or later Pi's) HOT 4
- Allow get/set of slew rate and hyst bits for gpio HOT 3
- Uninstalling pigpiod attempted to remove /opt
- pigpio will not run on a Pi 5 HOT 16
- Failed on Rpi2 and AlpineLinux HOT 2
- Unclean PWM at certain frequencies. HOT 1
- i2c (am2320) works with pigpio and not pigpiod - could definition of i2c_open() be wrong?
- C pigpio timer inaccuracy on raspbery pi 4 with raspian
- Pigpio BB Serial Read CPU Resource vs. RPI version HOT 4
- Is there a way to flush an open gpioSerialRead buffer? HOT 9
- event_callback with 0 bytes
- Issue with pigpio Initialization on Raspberry Pi 5 Model B HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pigpio.