[Top][All Lists]

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

[gpsd-users] Python client library modification.

From: Cuningan Re Set
Subject: [gpsd-users] Python client library modification.
Date: Thu, 1 Oct 2015 10:43:18 +0200

Hello all, today i am not going to call for help, today i want to share with you a little modification i have done on the Python Library for gpsd.
The default library, if you call or it will block until any data arrive from the daemon, it will lock waiting for any data to come from the socket on the method read() of the class gpscommon on the file (around line 86 ), the call to this method is produced from the method next() or read() of the class gps on the file (around line 310 to 330 ).

I found that if GPSd does not have any valid data from the physical GPS it will not transmit any data to the client more than what device it have connected and nothing more, you can see that connecting with #cgps, you can see that there is no more JSON data after the device information, but with #gpsmon you can see that the gps is throwing NMEA data.

What i have done is avoiding the socket locking in method read of the class gpscommon, to do this i have modified the gps.__init__() method to add a timeout argument with default to 30 seconds, this argument is passed to gpscommon.__init__() that passed it to gpscommon.connect() and create a socket with the timeout we selected or 30 seconds by default.

Now, when you call to fill the gpsd object with data it will block for a maximun of the timeout you especified or 30 seconds by default, if failed it will return -1 that will raise and exception on the method on file (around line 310)

To avoid crashing your program you can do something like:


if gpsd.waiting:
   #If there is valid data do ...
   #If there is not valid data do...

In attached file is the complete Python library, make full copy of your gps/ folder first!!.
Untar it into /usr/lib/python2.7/dist-packages#tar -zxvf gps_modificado_3.14.tgz

If you can not download it from the email you can download it from my Box Cloud here:

Thanks, maybe this can help someone more.

Attachment: gps_modificado_3.14.tgz
Description: GNU Zip compressed data

reply via email to

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