gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-users] Flush unconsumed GPS reports in Python


From: Alex
Subject: [gpsd-users] Flush unconsumed GPS reports in Python
Date: Mon, 18 Dec 2017 14:51:21 +0000

Hi,

I am using the Python API for gpsd and I am struggling with the fact that after a while the fixes I get are not fresh. The docĀ  warns about this: "You must poll the socket more often that that", explaining that there is a socket buffer that we should read with a certain frequency.

After setting a poll frequency to "once every 0.3s" the problem goes away, initially. After a period that can vary between several minutes to several hours - the buffering starts again, and even though I read every 0.3s, I end up getting fixes that are 5min old.

What is the recommended way of getting a fresh TPV report once a minute?


For example, perhaps one could call fflush on the underlying unix socket and then issue a `next()` call? The idea is to discard whatever is in the buffer and use the result of the next read operation. However, I found that Python does not expose `fflush()` in the sockets API; and besides that - it feels like I'm breaking the abstraction by fiddling with the internals of the Python library for gpsd.


My guess is that it is a typical use case, so there ought to be a nicer way of accomplishing this.


I count on your help,
Alex

reply via email to

[Prev in Thread] Current Thread [Next in Thread]