gpsd-dev
[Top][All Lists]
Advanced

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

Re: [gpsd-dev] Minimum working example for libgps


From: David Huichen Dai
Subject: Re: [gpsd-dev] Minimum working example for libgps
Date: Sun, 5 Nov 2017 13:38:39 +0800



On Sun, Nov 5, 2017 at 4:01 AM, Gary E. Miller <address@hidden> wrote:
Yo David!

On Sat, 4 Nov 2017 15:13:31 +0800
David Huichen Dai <address@hidden> wrote:

> Thanks for your reply. Why do you say that my sensor reports at
> 1-second interval? I set the gps_waiting time to 2 seconds, which
> means I wait for up to 2 seconds to get the coordinates, not sampling
> every 2 seconds, right?

gps_waiting is client side.  But your GPS just sends data when it wants to,
usualy PVT once a second, and gpsd passes it on when it sees it.  Thus you
should get PVT once a second.
​So how do I get the coordinate once a second? Put a sleep(1) in the loop?​
 
​And for ​the problem that gpsd starts automatically, I think I will kill the gpsd process, and restart it with the -n option. Is this OK?


> Do I need a separate thread to sample the coordinates, store them in a
> variable, and access it from other thread when I need the
> coordinates? Is this the common way to use the libgps?

Nah, the OS buffers the socket for you.  Just poll the gpsd interface in
you main loop.
​Here is the question, I dont have a main loop in my code, and I dont need to have it. Think of the case that a function accepts a coordinate as a parameter, and computes the distance between this coordinate and my current location get from gpsd​ (assume that I already have the algorithm to compute the distance between two coordinates). The logic requires no loop, but I cannot get the coordinate without a loop. How can I implement this function?

Again, some example code from a real project is very much appreciated. 


Thank you!

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        address@hidden  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can’t measure it, you can’t improve it." - Lord Kelvin



--
==================================================
David Huichen Dai, PhD
Research assistant
Lab of Broadband Network Switching Technology and Communication
Dept. of Computer Science and Technology
Tsinghua University, Beijing, P.R. China, 100084
Tel: 86-010-6277-3441
Email: address@hidden; address@hidden
==================================================


reply via email to

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