1

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.

Neppomuk
  • 452
  • 4
  • 16

1 Answers1

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.

joan
  • 71,024
  • 5
  • 73
  • 106
  • 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 '18 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: https://stackoverflow.com/questions/52132421/how-can-i-use-a-static-c-method-as-a-callback-for-a-poco-timer – Neppomuk Nov 23 '18 at 15:48