|
From: | Bhavna Harani |
Subject: | Re: Getting timeout error while reading data. |
Date: | Sun, 17 Jul 2022 09:59:51 +0530 |
Hi Gary,> I am giving data dynamically to gpsd over udp by the below command.
> gpsd -D 1 -n udp://127.0.0.1:8080
You skipped over some important lot of details. What version of gpsd? What is
the source for "udp://127.0.0.1:8080"version: 3.24.1source : created client application which write raw NEMA packet at 127.0.0.1:8080
> every 1 second I am feeding data to udp socket.
How? What sort of data?1083 NEMA string ,there is some utility which generates sample data.
> When I tried to read
> the data
> using gpslib I got a timeout error.
Getting way ahead of yourself. Don't bother to touch libgps until
the "-D 4" log from gpsd looks good. Then move on to cgps, befoure
looking at libgps.ok
> Below is a snippet to feed data at 1 second frequency.
> while(fgets(buffer, bufferLength, filePointer))
> {
> printf("%s\n", buffer);
> sleep(1);
> sendto(sockfd, buffer, strlen(buffer),MSG_CONFIRM, (const struct
> sockaddr *) &servaddr,sizeof(servaddr));
> }
Way too small a snippet. Also, never use strlen(), use strnlen()
instead.
> Below is a snippet for reading the data.
Way to small a snippet, and very premature. Look at the -D4" first,
then cgps, then libgps.
> if (0 != gps_open("localhost", "2947", &gpsd_gps_data))
> {
> printf( "LC79D_GNSS open error");
> exit(-1);
> }
> /*enable watch enable from gpsd demon*/
> (void)gps_stream(&gpsd_gps_data, WATCH_ENABLE | WATCH_JSON, NULL);
Failed to check the return code.
> // Wait for data available.
> #define GNSS_DATA_TIME_OUT 5000000
> while (gps_waiting(&gpsd_gps_data, GNSS_DATA_TIME_OUT))
> {
> if (-1 == gps_read(&gpsd_gps_data, NULL, 0))
> {printf ( "GNSS Read ERROR");
> ....
> }
> printf ( "timeout");
> }
Might work, can;t tell without working code. No ouput that ever says
you got data...
> I have tried with "gpspipe -r" ,I was able to get a raw string which
> I parsed dynamically.
Your C code asks for JSON, but you compare to psuedo NMEA. Apples and
oranges.- I was checking the gpspipe client and my client application. gpspipe clientwas getting data (in both options -w -r) ,my client application got timeout.Thanks & Regards,BhavnaOn Fri, Jul 15, 2022 at 10:37 PM Gary E. Miller <gem@rellim.com> wrote:Yo Bhavna!
On Fri, 15 Jul 2022 11:50:31 +0530
Bhavna Harani <haranibhavna111@gmail.com> wrote:
> I am giving data dynamically to gpsd over udp by the below command.
> gpsd -D 1 -n udp://127.0.0.1:8080
You skipped over some important lot of details. What version of gpsd? What is
the source for "udp://127.0.0.1:8080"
> every 1 second I am feeding data to udp socket.
How? What sort of data?
> When I tried to read
> the data
> using gpslib I got a timeout error.
Getting way ahead of yourself. Don't bother to touch libgps until
the "-D 4" log from gpsd looks good. Then move on to cgps, befoure
looking at libgps.
> Below is a snippet to feed data at 1 second frequency.
> while(fgets(buffer, bufferLength, filePointer))
> {
> printf("%s\n", buffer);
> sleep(1);
> sendto(sockfd, buffer, strlen(buffer),MSG_CONFIRM, (const struct
> sockaddr *) &servaddr,sizeof(servaddr));
> }
Way too small a snippet. Also, never use strlen(), use strnlen()
instead.
> Below is a snippet for reading the data.
Way to small a snippet, and very premature. Look at the -D4" first,
then cgps, then libgps.
> if (0 != gps_open("localhost", "2947", &gpsd_gps_data))
> {
> printf( "LC79D_GNSS open error");
> exit(-1);
> }
> /*enable watch enable from gpsd demon*/
> (void)gps_stream(&gpsd_gps_data, WATCH_ENABLE | WATCH_JSON, NULL);
Failed to check the return code.
> // Wait for data available.
> #define GNSS_DATA_TIME_OUT 5000000
> while (gps_waiting(&gpsd_gps_data, GNSS_DATA_TIME_OUT))
> {
> if (-1 == gps_read(&gpsd_gps_data, NULL, 0))
> {printf ( "GNSS Read ERROR");
> ....
> }
> printf ( "timeout");
> }
Might work, can;t tell without working code. No ouput that ever says
you got data...
> I have tried with "gpspipe -r" ,I was able to get a raw string which
> I parsed dynamically.
Your C code asks for JSON, but you compare to psuedo NMEA. Apples and
oranges.
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
gem@rellim.com Tel:+1 541 382 8588
Veritas liberabit vos. -- Quid est veritas?
"If you can't measure it, you can't improve it." - Lord Kelvin
[Prev in Thread] | Current Thread | [Next in Thread] |