Thu 30 May 2013 07:04:32 AM UTC, original submission:
If two or more messages are sent to gpsd's JSON interface right after another then gpsd might not recognize the latter command. For example, perl's Net::GPSD3 client (http://cpansearch.perl.org/src/MRDVT/Net-GPSD3-0.18/lib/Net/GPSD3.pm) sends messages ?DEVICES; and ?POLL; to gpsd and then reads responses from socket. Mostly gpsd can recognize both commands but every once in a while POLL is not recognized. If that is a case Net::GPSD3 ends up in a infinite loop and the responses are:
{"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttyUSB6","activated":"2013-05-30T05:27:12.926Z","flags":1,"driver":"Generic NMEA","native":0,"bps":9600,"parity":"N","stopbits":1,"cycle":1.00}]}
{"class":"ERROR","message":"Unrecognized request '?POLL'"}
Because this bug happens only now and then I tried to solve how to repeat this bug easily. I end up replacing these two lines in GPSD3.pm
$self->socket->send(qq(?DEVICES;\n)) unless $self->cache->DEVICES;
$self->socket->send(qq(?POLL;\n));
with line
$self->socket->send(qq(?DEVICES;\n?POLL;\n)) unless $self->cache->DEVICES;
In my tests this change will always result in above error message. Naturally this bug could be avoided by reading the response to ?DEVICES; command and sending the ?POLL; command only after that. Anyhow, I would like to get this fixed. Shouldn't be too hard because it seems that it is only matter of not having ; char after the ?POLL command.
|