I want to get time and count of input pulse in microseconds using pigpio. How can i Listen to gpio pin in spreate thread.
By default pigpio samples GPIO 0-31 at a rate of 200 thousand times per second (once every 5µs).
You can register to be alerted when
- one or more of GPIO 0-31 change level
- one or more of GPIO 0-31 have not changed level for a timeout period
The pigpio daemon provides a socket interface to this information. Each report contains an incrementing sequence number, flags to indicate a timeout, the event tick, and a bit mask giving the levels of GPIO 0-31 at that event tick.
The event tick is a 32 bit microsecond counter which starts at boot and wraps around every 1 hour 12 minutes.
piscope is written in C and uses alerts via the socket inerface.
x_pigpiod_if2.c (part of the pigpio archive) is written in C gives examples of using alerts via the socket interface.
monitor.py is written in Python and uses alerts via the socket interface.