When still using the pigpio API "directly", I made extensive use of the gpioSetTimerFunc function, just like this:

gpioSetTimerFunc (4, 500, OnRDSDataTimerElapsed);

After making pigpiod do all the GPIO-related work, I have to replace all pigpio calls with pigpiod ones. However, I can't find a viable replacement for the timed callback in the pigpiod API.

Can anybody plase give me a hint? Thank you.

1 Answer 1


gpioSetTimerFunc calls a function at regular intervals.

There is no equivalent in pdif2 so you will have to implement another solution.

I suggest you create a new thread using start_thread and use time_sleep within the thread to delay for the regular interval.

For an example see http://abyz.me.uk/rpi/pigpio/examples.html#pdif2_DHTXXD and in particular pthTriggerThread.

  • Well OK, thank you for your quick and competent answer (despite the fact that it's a pity that this method is not part of pdif2 whereas most other pigpio utility methods are), but I will look into the sourcecode you recommended and watch out for another C/C++ library, which supports timer-driven callbacks.
    – Neppomuk
    Aug 25, 2018 at 21:01
  • OK, I've accomplished my goal by using the Poco library. It contains the TimerTask class, which does almost exactly the same as your gpioSetTimerFunc, but I had to write a wrapper for it. See here: stackoverflow.com/questions/52132421/…
    – Neppomuk
    Nov 23, 2018 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.