[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting timeout error while reading data.
From: |
Gary E. Miller |
Subject: |
Re: Getting timeout error while reading data. |
Date: |
Fri, 15 Jul 2022 10:06:59 -0700 |
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
pgpB4BHJzNJnj.pgp
Description: OpenPGP digital signature