[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gpsd-users] GPSD Polling Frequency
From: |
Natal Rivadeneyra |
Subject: |
[gpsd-users] GPSD Polling Frequency |
Date: |
Wed, 29 Aug 2018 16:56:26 -0400 |
Hi,
I am writing a python utility that receives data from a usb-serial port and every packet received needs to be timestamped with GPS time.
I am working with Ubuntu 16.04, GPSD 3.15 and the hardware is Garmin GPS18x LVC receiver with 1 pps.
The frequency at which the data stream is arriving to the usb-serial is ~3000 Hz.
When the utility is started I send a ?WATCH={"enable":true} command to the gpsd daemon and then I use ?POLL; every time I read a packet from the usb-serial port (~3000 times per second)
The problem I am having is that at some point the GPSD daemon throws an error and shuts down the socket:
gpsd:CLIENT: <= client(0): ?POLL;?POLL;?POLL;?POLL;?POLL;\x0a
gpsd: gpsd_json.c:130: json_tpv_dump: Assertion 'replylen > sizeof(char *)' failed.
Aborted (core dumped)
I have read in the documentation that this can happen if I don't read the buffer fast enough, but there was no mention of this happening if I poll it too fast. I have noticed that if I sleep the polling by at least 0.01 seconds then the problem goes away. Unfortunately, I don't have the luxury to sleep that long as I am receiving a new sample every 0.000333. If I sleep for 0.01 I will be losing 30 packets in a row and that is not acceptable.
I have also noticed that if I don't send the ?WATCH={"enable":true} command and just start polling right away I get the following response:
{"class":"POLL","time":"2018-08-29T01:12:52.716Z","active":0,"tpv":[],"gst":[],"sky":[]}
All I am concerned is time, I don't need tpv, gst or sky, so that would be acceptable. However, since there is an "active":0 I don't believe that the time reported is accurate. Is this an accurate assumption? I can run that same routine without the GPS receiver connected to my machine and would still get a time response.
Has anyone experienced this before? Is there a maximum polling frequency?
This is a sample code of what I am attempting to do
import socket
import json
import time
TCP_IP = '127.0.0.1'
TCP_PORT = 2947
BUFFER_SIZE = 1024
MESSAGE = '?WATCH={"enable":true}'
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
gps_data = s.recv(BUFFER_SIZE)
MESSAGE = '?POLL;'
s.send(MESSAGE)
gps_data = s.recv(BUFFER_SIZE)
while True:
#Here I would receive the serial/usb data
s.send(MESSAGE)
gps_data = s.recv(BUFFER_SIZE)
#Here I would extract the time from the received gps_data
print(len(gps_data))#This was to try and figure out the buffer size of the data that was being polled
print(gps_data) #I want to see what is it that I am receiving
#time.sleep(.01)#If I sleep the process at least .01 sec then I don't seem to get the error and the daemon doesn't shut down.
Thank you for your help and l'm looking forward to see if any of you had experienced this and if there is a workaround.
Best Regards,
- [gpsd-users] GPSD Polling Frequency,
Natal Rivadeneyra <=