Git Product home page Git Product logo

Comments (5)

joan2937 avatar joan2937 commented on June 24, 2024

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.

infusion avatar infusion commented on June 24, 2024

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.

SlySven avatar SlySven commented on June 24, 2024

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.

joan2937 avatar joan2937 commented on June 24, 2024

That should be automatic as the locking is actually handled by the library during initialisation. The code is initGrabLockFile in pigpio.c.

from pigpio.

SlySven avatar SlySven commented on June 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.