I have a Python program that does the following:
- Spawns a process via multiprocessing that runs in a tight loop reading TPV reports and saves the latest reading to a buffer. I'm using the stream() API.
- I have two other threads that pick up this buffer periodically (it's actually threads that are timestamping two video streams via GStreamer at ~30fps).
- The GPS NMEA strings are emitted at 10Hz
What I'm finding is that my GPS reader process sometimes lags behind the frames. Basically, I will see at times a second go by before my process drains all the reports to the current one. This means I see several frames with the same latitude/longitude before the next frame gets updated. Obviously if the frames are emitted at 30Hz and the GPS strings are at 10Hz I would expect three or four duplicate coordinates every second. But it varies wildly.
I suspect this is a scheduling issue. My process just simply isn't real-time and the scheduler doesn't allow my process to drain the reports fast enough (or recv is too slow?).
However, one "fix" for this would be if I could get the last valid TPV report from gpsd without having to manually drain the stream myself. Is this possible outside of opening up a raw socket to my device and parsing the NMEA strings myself (something I really don't want to do).