# GPS application unable to get a fix

**URL:** <https://forum.legato.io/t/gps-application-unable-to-get-a-fix/2845>\
**Category:** Legato Application Framework\
**Created:** [December 8, 2017, 6:05am UTC](https://forum.legato.io/t/gps-application-unable-to-get-a-fix/2845 "2017-12-08T06:05:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![codegit001](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@codegit001](https://forum.legato.io/u/codegit001)\
**Post date:** [December 8, 2017, 6:05am UTC](https://forum.legato.io/t/gps-application-unable-to-get-a-fix/2845/1 "2017-12-08T06:05:47Z")

</div>

Hi I am working with the GNSS module of Legato; it seems my application is unable to get a position fix.

If I use “gnss get posInfo” command on the terminal while my app is running, the app also gets the info and subsequently gets the information.

It also works if I run the whole process, from enable to getdata in a single sequence, without letting anything but getData happen in a sequence ie if I put getData sequence in a while 1 loop after setting parameters and le\_gnss\_Start().

I am not using le\_gnss\_AddpositionHandler() and is relying on le\_gnss\_GetLastSampleRef().

---

<div class="post-metadata">

**Author:** ![wdev](https://avatars.discourse-cdn.com/v4/letter/w/d9b06d/32.png) [@wdev](https://forum.legato.io/u/wdev)\
**Post date:** [July 9, 2018, 10:07am UTC](https://forum.legato.io/t/gps-application-unable-to-get-a-fix/2845/2 "2018-07-09T10:07:01Z")

</div>

Hi,

Using gnss target tool is a good way to check that GNSS works and you can get a position fix:  
_# gnss start_  
_# gnss watch 60_  
You can also check position information from NMEA flow:  
_# cat /dev/nmea_

For GNSS app implementation, you can use gnss target tool source code (apps/tools/gnss/gnss.c) or gnssTest app (legato/apps/test/positioning/gnssTest/gnssTest/gnssTest.c) as sample code to develop your app. “while 1 loop” is really not recommended.  
In COMPONENT\_INIT (main thread), you should create a thread to add a position handler:  
_positionThreadRef = le\_thread\_Create(“PositionThread”,PositionThread,NULL);_  
_le\_thread\_Start(positionThreadRef);_  
A position handler should be added from that “PositionThread”, and then runs the event loop for the calling thread:  
_le\_gnss\_Start();_  
_PositionHandlerRef = le\_gnss\_AddPositionHandler(PositionHandlerFunction, NULL);_  
_le\_event\_RunLoop();_  
referring to [Event-driven Programming](https://docs.legato.io/latest/conceptsEvents.html).  
Then you will be notified for position information at 1Hz (default update rate).  
From “PositionHandlerFunction”, you can check position state using the le\_gnss\_GetPositionState function. When the position is fixed (2D/3D), you can get position information using le\_gnss\_getXXXX functions.

Hope it helps!

---

<div class="post-metadata">

**Author:** ![TheGod](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/thegod/32/252_2.png) [@TheGod](https://forum.legato.io/u/TheGod)\
**Post date:** [September 7, 2018, 4:10pm UTC](https://forum.legato.io/t/gps-application-unable-to-get-a-fix/2845/3 "2018-09-07T16:10:02Z")

</div>

No, I had to disconnect WiFi to make it work.

---

<div class="post-metadata">

**Author:** ![Vasantha\_lax](https://avatars.discourse-cdn.com/v4/letter/v/5f9b8f/32.png) [@Vasantha\_lax](https://forum.legato.io/u/Vasantha_lax)\
**Post date:** [October 4, 2018, 10:49am UTC](https://forum.legato.io/t/gps-application-unable-to-get-a-fix/2845/4 "2018-10-04T10:49:23Z")

</div>

Can you let us know if this issue is fixed?

---

<div class="post-metadata">

**Author:** ![mrjoso](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mrjoso](https://forum.legato.io/u/mrjoso)\
**Post date:** [January 8, 2020, 1:14pm UTC](https://forum.legato.io/t/gps-application-unable-to-get-a-fix/2845/5 "2020-01-08T13:14:47Z")

</div>

I have the same issue with le\_gnss\_GetLastSampleRef(). The problem happens when several conditions are met (le\_gnss\_Stop and after that le\_gnss\_Start), but “gnss get satStat” or similar help the application to receive the position fix again. I’m using WP7702 module with Legato 19.07.0.

---

<div class="post-metadata">

**Author:** ![gi1](https://avatars.discourse-cdn.com/v4/letter/g/e79b87/32.png) [@gi1](https://forum.legato.io/u/gi1)\
**Post date:** [December 5, 2023, 2:07pm UTC](https://forum.legato.io/t/gps-application-unable-to-get-a-fix/2845/6 "2023-12-05T14:07:59Z")

</div>

Hello,  
sometimes we fall in same situation… how do you handle in code?

Regards

---

<div class="post-metadata">

**Author:** ![mrjoso](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mrjoso](https://forum.legato.io/u/mrjoso)\
**Post date:** [December 6, 2023, 1:54pm UTC](https://forum.legato.io/t/gps-application-unable-to-get-a-fix/2845/7 "2023-12-06T13:54:14Z")

</div>

It is several years back, but I have rewritten the code to use position handler instead.
