# Can't get location data from GNSS control API

**URL:** <https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144>\
**Category:** Legato Application Framework\
**Created:** [February 26, 2019, 5:35am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144 "2019-02-26T05:35:05Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![kndu\_t](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kndu\_t](https://forum.legato.io/u/kndu_t)\
**Post date:** [February 26, 2019, 5:35am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/1 "2019-02-26T05:35:05Z")

</div>

Hello,

I am using WP8548 and trying to get location data with GNSS control API’s le\_gnss\_GetLocation().  
But it always fails with -3(LE\_OUT\_OF\_RANGE).  
(Before executing le\_gnss\_GetLocation(), le\_gnss\_Start() is executed and no error is occured.)

I also tried it using the following target tool command and it could get correct location data.  
gnss start  
gnss get posInfo

Why can’t it get location data with le\_gnss\_GetLocation()?

Legato version : 18.10.2  
Firmware Version : SWI9X15Y\_07.13.07.00

---

<div class="post-metadata">

**Author:** ![Andy\_5](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Andy\_5](https://forum.legato.io/u/Andy_5)\
**Post date:** [February 26, 2019, 7:30am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/2 "2019-02-26T07:30:41Z")

</div>

Don’t forget to connect antenna to your module and try move on outside !

---

<div class="post-metadata">

**Author:** ![kndu\_t](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kndu\_t](https://forum.legato.io/u/kndu_t)\
**Post date:** [February 26, 2019, 8:03am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/3 "2019-02-26T08:03:03Z")

</div>

Hi Andy\_5,

I tried them with a GPS antenna and I did them at same place in both case of using API and using tool commands.

Thx

---

<div class="post-metadata">

**Author:** ![Andy\_5](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Andy\_5](https://forum.legato.io/u/Andy_5)\
**Post date:** [February 26, 2019, 9:04am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/4 "2019-02-26T09:04:06Z")

</div>

Hi kndu\_t,  
I used to use le\_pos\_Get2DLocation () API instead of le\_gnss\_GetLocation(), flow this link [Sample code for Navigation - Legato Docs](https://docs.legato.io/latest/c_posSampleCodeNavigation.html) to get location, it worked fine or you can install Developer studio and try with a example code, It called Texloc.

---

<div class="post-metadata">

**Author:** ![kndu\_t](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kndu\_t](https://forum.legato.io/u/kndu_t)\
**Post date:** [February 27, 2019, 5:57am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/5 "2019-02-27T05:57:18Z")

</div>

Hi Andy\_5,  
Is the program Texloc the same as textLoc on this link [https://github.com/legatoproject/legato-af/tree/master/apps/sample/textLoc](https://github.com/legatoproject/legato-af/tree/master/apps/sample/textLoc) ?  
If so, I made the program with reference to it.  
And I first used le\_pos\_Get2DLocation() API but it was failed, then I used le\_gnss\_GetLocation() API and it was failed too.

I’m sorry that information I wrote was insufficient.  
I put the code below.

```auto
#define GPS_TIMEOUT_SEC 120

static le_result_t GetCurrentLocation(
    int32_t *latitudePtr,
    int32_t *longitudePtr,
    int32_t *horizontalAccuracyPtr,
    uint32_t timeoutInSeconds
);

void gps_Receiver(void)
{
    le_result_t res;
    int32_t gps_latitude;
    int32_t gps_longitude;
    int32_t gps_horizontalAccuracy;

    res = GetCurrentLocation(&gps_latitude, &gps_longitude, &gps_horizontalAccuracy, GPS_TIMEOUT_SEC);

    if(res == LE_OK){
        LE_INFO("GPS_Loc:latitude -> %d, longitude -> %d", gps_latitude, gps_longitude); 
    }else{
        LE_INFO("GPS_Loc:unknown");
    }

}

static le_result_t GetCurrentLocation(
    int32_t *latitudePtr,
    int32_t *longitudePtr,
    int32_t *horizontalAccuracyPtr,
    uint32_t timeoutInSeconds )
{
    le_result_t result;
    le_gnss_State_t gnss_state_result;
    const time_t startTime = time(NULL);
    le_gnss_SampleRef_t gnss_sampleRef;
    uint32_t ttff;
    le_gnss_FixState_t gnss_fixState;

    gnss_state_result = le_gnss_GetState();
    if(LE_GNSS_STATE_ACTIVE == gnss_state_result){
         le_gnss_Stop();
    }
    

    result = le_gnss_Start();
    if(result != LE_OK){
        LE_ERROR("Can't activate the Positioning service : %d", result);
        return LE_UNAVAILABLE;
    }

    gnss_sampleRef = le_gnss_GetLastSampleRef();
    //gnss_sampleRef= NULL;

    LE_INFO("Checking 2D position");
    while(true){

        result = le_gnss_GetTtff(&ttff);
        LE_INFO("result = %d, TTFF = %d", result, ttff);
        result = le_gnss_GetPositionState(gnss_sampleRef, &gnss_fixState);
        LE_INFO("result = %d, Position state: %d", result, gnss_state_result);
        
        result = le_gnss_GetLocation(gnss_sampleRef, latitudePtr, longitudePtr, horizontalAccuracyPtr);
        if(result == LE_OK){
            break;
        }else if(
            (timeoutInSeconds != 0) &&
            (difftime(time(NULL), startTime) > (double)timeoutInSeconds))
        {
            result = LE_TIMEOUT;
            break;
        }else{
            LE_ERROR("GPS position getting error:%d", result);
            LE_INFO("GPS_Loc:latitude -> %d, longitude -> %d", *latitudePtr, *longitudePtr); 

            // Sleep for one second before requesting the location again.
            sleep(1);
        }

    }

    le_gnss_Stop();

    return result;
}

```

Thx

---

<div class="post-metadata">

**Author:** ![Andy\_5](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Andy\_5](https://forum.legato.io/u/Andy_5)\
**Post date:** [February 27, 2019, 6:58am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/6 "2019-02-27T06:58:11Z")

</div>

Yes, this link [legato-af/textLoc.c at master · legatoproject/legato-af · GitHub](https://github.com/legatoproject/legato-af/blob/master/apps/sample/textLoc/textLocComponent/textLoc.c) is right and **you should flow this code** and I think that you should modify several things like below :

- declare 3 **global variable** like that  
int32\_t lat  
int32\_t long;  
int32\_t horiz;

- In COMPONENT\_INIT  
{ le\_result\_t res ;  
res = GetCurrentLocation (&lat, &long, &horiz, GPSTIMEOUT);  
if ( res == LE\_FAULT)  
LE\_INFO (" FAILED \n") ;

}

---

<div class="post-metadata">

**Author:** ![kndu\_t](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kndu\_t](https://forum.legato.io/u/kndu_t)\
**Post date:** [February 27, 2019, 7:58am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/7 "2019-02-27T07:58:05Z")

</div>

Hi Andy\_5,

I omitted COMPONENT\_INIT part in previous reply.  
OK, I put all code and project files below.

**gpsComponent/helloGps.c**

```auto
#include "legato.h"
#include "interfaces.h"
#include "helloGps.h"

#define GPS_TIMEOUT_SEC 120

static le_result_t GetCurrentLocation(
    int32_t *latitudePtr,
    int32_t *longitudePtr,
    int32_t *horizontalAccuracyPtr,
    uint32_t timeoutInSeconds
);

void gps_Receiver(void)
{
    le_result_t res;
    int32_t gps_latitude;
    int32_t gps_longitude;
    int32_t gps_horizontalAccuracy;

    res = GetCurrentLocation(&gps_latitude, &gps_longitude, &gps_horizontalAccuracy, GPS_TIMEOUT_SEC);

    if(res == LE_OK){
        LE_INFO("GPS_Loc:latitude -> %d, longitude -> %d", gps_latitude, gps_longitude); 
    }else{
        LE_INFO("GPS_Loc:unknown");
    }

}

static le_result_t GetCurrentLocation(
    int32_t *latitudePtr,
    int32_t *longitudePtr,
    int32_t *horizontalAccuracyPtr,
    uint32_t timeoutInSeconds )
{
    le_result_t result;
    le_gnss_State_t gnss_state_result;
    const time_t startTime = time(NULL);
    le_gnss_SampleRef_t gnss_sampleRef;
    uint32_t ttff;
    le_gnss_FixState_t gnss_fixState;

    gnss_state_result = le_gnss_GetState();
    if(LE_GNSS_STATE_ACTIVE == gnss_state_result){
         le_gnss_Stop();
    }
    

    result = le_gnss_Start();
    if(result != LE_OK){
        LE_ERROR("Can't activate the Positioning service : %d", result);
        return LE_UNAVAILABLE;
    }

    gnss_sampleRef = le_gnss_GetLastSampleRef();
    //gnss_sampleRef= NULL;

    LE_INFO("Checking 2D position");
    while(true){

        result = le_gnss_GetTtff(&ttff);
        LE_INFO("result = %d, TTFF = %d", result, ttff);
        result = le_gnss_GetPositionState(gnss_sampleRef, &gnss_fixState);
        LE_INFO("result = %d, Position state: %d", result, gnss_state_result);
        
        result = le_gnss_GetLocation(gnss_sampleRef, latitudePtr, longitudePtr, horizontalAccuracyPtr);
        if(result == LE_OK){
            break;
        }else if(
            (timeoutInSeconds != 0) &&
            (difftime(time(NULL), startTime) > (double)timeoutInSeconds))
        {
            result = LE_TIMEOUT;
            break;
        }else{
            LE_ERROR("GPS position getting error:%d", result);
            LE_INFO("GPS_Loc:latitude -> %d, longitude -> %d", *latitudePtr, *longitudePtr); 

            // Sleep for one second before requesting the location again.
            sleep(1);
        }

    }

    le_gnss_Stop();

    return result;
}

COMPONENT_INIT
{
    LE_INFO("Start GPS Sample!");

    gps_Receiver();
}

```

**helloGps.adef**

```auto
executables:
{
    helloGps = ( gpsComponent )
}

processes:
{
    run:
    {
        ( helloGps )
    }
}

start:manual

bindings:
{
    helloGps.gpsComponent.le_gnss -> positioningService.le_gnss
    helloGps.gpsComponent.le_pos -> positioningService.le_pos
    helloGps.gpsComponent.le_posCtrl -> positioningService.le_posCtrl
}

```

**gpsComponent/Component.cdef**

```auto
requires:
{
    api:
    {
        positioning/le_gnss.api
        positioning/le_pos.api
        positioning/le_posCtrl.api
    }
}

sources:
{
    helloGps.c
}

```

Please point out if something is wrong.

Thx.

---

<div class="post-metadata">

**Author:** ![Andy\_5](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Andy\_5](https://forum.legato.io/u/Andy_5)\
**Post date:** [February 27, 2019, 8:12am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/8 "2019-02-27T08:12:00Z")

</div>

Can you give me the log ?

---

<div class="post-metadata">

**Author:** ![kndu\_t](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kndu\_t](https://forum.legato.io/u/kndu_t)\
**Post date:** [February 27, 2019, 8:31am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/9 "2019-02-27T08:31:11Z")

</div>

Yes, the result of “logread -f” is below.

```auto
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c app_Start() 3385 | Starting app 'helloGps'
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/dev/log' to '/legato/systems/current/appsWriteable/helloGps/dev/log'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/dev/null' to '/legato/systems/current/appsWriteable/helloGps/dev/null'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/dev/zero' to '/legato/systems/current/appsWriteable/helloGps/dev/zero'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/legato/systems/current/lib/liblegato.so' to '/legato/systems/current/appsWriteable/helloGps/lib/liblegato.so'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/lib/ld-linux.so.3' to '/legato/systems/current/appsWriteable/helloGps/lib/ld-linux.so.3'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/lib/libc.so.6' to '/legato/systems/current/appsWriteable/helloGps/lib/libc.so.6'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/lib/libpthread.so.0' to '/legato/systems/current/appsWriteable/helloGps/lib/libpthread.so.0'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/lib/librt.so.1' to '/legato/systems/current/appsWriteable/helloGps/lib/librt.so.1'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/lib/libdl.so.2' to '/legato/systems/current/appsWriteable/helloGps/lib/libdl.so.2'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/lib/libgcc_s.so.1' to '/legato/systems/current/appsWriteable/helloGps/lib/libgcc_s.so.1'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/lib/libm.so.6' to '/legato/systems/current/appsWriteable/helloGps/lib/libm.so.6'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/usr/lib/libstdc++.so.6' to '/legato/systems/current/appsWriteable/helloGps/lib/libstdc++.so.6'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/legato/systems/current/apps/helloGps/read-only/lib/libComponent_gpsComponent.so' to '/legato/systems/current/appsWriteable/helloGps/l
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/legato/systems/current/apps/helloGps/read-only/bin/helloGps' to '/legato/systems/current/appsWriteable/helloGps/bin/helloGps'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateTmpFs() 1703 | Mounted tmpfs at /legato/systems/current/appsWriteable/helloGps/tmp.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/tmp/legato/serviceDirectoryServer' to '/legato/systems/current/appsWriteable/helloGps/tmp/legato/serviceDirectoryServer'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | app.c CreateFileLink() 2069 | Created file link '/tmp/legato/serviceDirectoryClient' to '/legato/systems/current/appsWriteable/helloGps/tmp/legato/serviceDirectoryClient'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | proc.c proc_Start() 1389 | Starting process 'helloGps' with pid 13653
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[645]/supervisor T=main | supervisor.c SigChildHandler() 784 | Reaping unconfigured child process 13652.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | supervisor[13653]/supervisor T=main | proc.c proc_Start() 1354 | Execing 'helloGps'
Feb 5 06:45:48 swi-mdm9x15 user.warn Legato: -WRN- | _UNKNOWN_[13653]/framework T=main | LE_FILENAME le_fdMonitor_Create() 672 | FD Monitor object name 'helloGps.gpsComponent.le_posCtrl' truncated to 'helloGps.gpsComponent.le_posCtr'.
Feb 5 06:45:48 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | helloGps.c _gpsComponent_COMPONENT_INIT() 7 | Start GPS Sample!
Feb 5 06:45:49 swi-mdm9x15 authpriv.info dropbear[13645]: Exit (root): Disconnect received
Feb 5 06:45:49 swi-mdm9x15 user.info Legato: INFO | posDaemon[1046]/le_pa_gnss T=main | pa_gnss_qmi.c pa_gnss_Start() 3445 | EngineState ON
Feb 5 06:45:49 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 62 | Checking 2D position
Feb 5 06:45:49 swi-mdm9x15 user.warn Legato: -WRN- | posDaemon[1046]/le_pa_gnss T=main | pa_gnss_qmi.c pa_gnss_GetTtff() 4036 | TTFF not available
Feb 5 06:45:49 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 66 | result = -17, TTFF = 0
Feb 5 06:45:49 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 68 | result = 0, Position state: 1
Feb 5 06:45:49 swi-mdm9x15 user.err Legato: =ERR= | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 80 | GPS position getting error:-3
Feb 5 06:45:49 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 81 | GPS_Loc:latitude -> 34770001, longitude -> 138460007
Feb 5 06:45:50 swi-mdm9x15 user.warn Legato: -WRN- | posDaemon[1046]/le_pa_gnss T=main | pa_gnss_qmi.c pa_gnss_GetTtff() 4036 | TTFF not available
Feb 5 06:45:50 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 66 | result = -17, TTFF = 0
Feb 5 06:45:50 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 68 | result = 0, Position state: 1
Feb 5 06:45:50 swi-mdm9x15 user.err Legato: =ERR= | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 80 | GPS position getting error:-3
Feb 5 06:45:50 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 81 | GPS_Loc:latitude -> 34770001, longitude -> 138460007
Feb 5 06:45:51 swi-mdm9x15 user.warn Legato: -WRN- | posDaemon[1046]/le_pa_gnss T=main | pa_gnss_qmi.c pa_gnss_GetTtff() 4036 | TTFF not available
Feb 5 06:45:51 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 66 | result = -17, TTFF = 0
Feb 5 06:45:51 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 68 | result = 0, Position state: 1
Feb 5 06:45:51 swi-mdm9x15 user.err Legato: =ERR= | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 80 | GPS position getting error:-3
Feb 5 06:45:51 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 81 | GPS_Loc:latitude -> 34770001, longitude -> 138460007
Feb 5 06:45:52 swi-mdm9x15 user.warn Legato: -WRN- | posDaemon[1046]/le_pa_gnss T=main | pa_gnss_qmi.c pa_gnss_GetTtff() 4036 | TTFF not available
Feb 5 06:45:52 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 66 | result = -17, TTFF = 0
Feb 5 06:45:52 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 68 | result = 0, Position state: 1
Feb 5 06:45:52 swi-mdm9x15 user.err Legato: =ERR= | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 80 | GPS position getting error:-3
Feb 5 06:45:52 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 81 | GPS_Loc:latitude -> 34770001, longitude -> 138460007
Feb 5 06:45:53 swi-mdm9x15 user.warn Legato: -WRN- | posDaemon[1046]/le_pa_gnss T=main | pa_gnss_qmi.c pa_gnss_GetTtff() 4036 | TTFF not available
Feb 5 06:45:53 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 66 | result = -17, TTFF = 0
Feb 5 06:45:53 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 68 | result = 0, Position state: 1
Feb 5 06:45:53 swi-mdm9x15 user.err Legato: =ERR= | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 80 | GPS position getting error:-3
Feb 5 06:45:53 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 81 | GPS_Loc:latitude -> 34770001, longitude -> 138460007
Feb 5 06:45:54 swi-mdm9x15 user.debug kernel: [6770.876757] NMEA read driver miss interrupt, abandon current buff
    .
    . (Repeat)
    .
Feb 5 06:47:48 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 81 | GPS_Loc:latitude -> 34770001, longitude -> 138460007
Feb 5 06:47:49 swi-mdm9x15 user.warn Legato: -WRN- | posDaemon[1046]/le_pa_gnss T=main | pa_gnss_qmi.c pa_gnss_GetTtff() 4036 | TTFF not available
Feb 5 06:47:49 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 66 | result = -17, TTFF = 0
Feb 5 06:47:49 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c GetCurrentLocation() 68 | result = 0, Position state: 1
Feb 5 06:47:49 swi-mdm9x15 user.warn Legato: -WRN- | posDaemon[1046]/le_pa_gnss T=unknown | pa_gnss_qmi.c PositionHandler() 1441 | Bad position indication
Feb 5 06:47:49 swi-mdm9x15 user.info Legato: INFO | helloGps[13653]/gpsComponent T=main | gpsRcv.c gps_Receiver() 27 | GPS_Loc:unknown

```

---

<div class="post-metadata">

**Author:** ![Andy\_5](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Andy\_5](https://forum.legato.io/u/Andy_5)\
**Post date:** [February 28, 2019, 4:39am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/10 "2019-02-28T04:39:39Z")

</div>

I think that you got location data  
GPS\_Loc:latitude -\> 34770001, longitude -\> 138460007

---

<div class="post-metadata">

**Author:** ![kndu\_t](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kndu\_t](https://forum.legato.io/u/kndu_t)\
**Post date:** [February 28, 2019, 5:31am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/11 "2019-02-28T05:31:42Z")

</div>

Hi Andy\_5,

Its location data is invalid data.  
For confirmation, the program also displays the variable value even if an error is returned.  
In case of LE\_OK, it leaves from the while loop and displays valid values.

Certainly it was a confusing log.

Thx

---

<div class="post-metadata">

**Author:** ![kndu\_t](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kndu\_t](https://forum.legato.io/u/kndu_t)\
**Post date:** [March 6, 2019, 5:07am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/12 "2019-03-06T05:07:01Z")

</div>

Supplementally, the latitude and longitude in the log points to the sea. By the way, I am trying it in Tokyo, Japan.

---

<div class="post-metadata">

**Author:** ![kndu\_t](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kndu\_t](https://forum.legato.io/u/kndu_t)\
**Post date:** [March 8, 2019, 9:01am UTC](https://forum.legato.io/t/cant-get-location-data-from-gnss-control-api/4144/13 "2019-03-08T09:01:42Z")

</div>

I could get location data using handler function for EVENT ‘le\_gnss\_Position’ and executing le\_gnss\_GetPositionState() in the handler instead of polling.  
In case of using handler, it seems to be called per one second and it looks same as doing in case of polling.

The GNSS data could be got in up to 3 minutes using handler.  
But in case of polling, it could’t be got even in 5 minutes.

It’s good that the data can be got but I could’t understand why it can’t get them in case of polling.

Thx.
