This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Acquiring GPS data through UART on a polling basis.

I'm able to successfully use peripheral/uart example to read the data from GPS module. I achieved the same by setting baud rate to 4800, and connecting rx and tx of GPS to pins 6 and 8 respectively. Currently I have the GPS data printed on my console(CoolTerm). 

While the GPS module is continuously throwing data out of UART, how can I read this GPS data from UART only at specific intervals?

Is there a way where I can perform something like this? Enable UART, Collect data, Disable Uart. Again when I need GPS data, repeat the same procedure.

I also tried to incorporate a delay in my code to check if I can finish all my other tasks and then come back to read the data. But my console shows nothing!

while (true) {
    uint8_t cr[250];
    while (app_uart_get(&cr[gps_idx]) != NRF_SUCCESS);
    while (cr[gps_idx] != '\r') {
        gps_idx++ ;
        while (app_uart_get(&cr[gps_idx]) != NRF_SUCCESS);
    }

    printf("GPS Data One line end\r");
    for (int j=0; j<=gps_idx; j++) {
        printf("%c", cr[j]);
    }
    printf("GPS Data One Line printed\r\r");
      
    gps_idx = 0;
    
    // Works fine without this delay
    nrf_delay_ms(1000);
}

Parents
  • Hello Sharada,

     

      What type GPS are you using? 

    Usually you can send a command to to the GPS module and get the data when you ask for it. 

  • Hello Martin,

    I'm using GPS Module EM - 506. 

    For my application, I only need the latitude and longitude information. So, sending AT commands and receiving the data would make it complicated. Anyhow, upon connection, GPS module sends out the data as strings with a specific format. All I have to do is parse those strings and extract Latitude/ Longitude information from them.

    I just want to be able to read the rx buffer of uart at will and parse the data when needed. During other times, I don't care what data in arriving on the UART port.

    I would like to perform something like this

     

    // Other functions running
    // Like saadc, ble advertising
    
    if (trigger_condition) 
    {
        string = read_data_coming_from_GPS_module();
        parse_string();
    }
    

    Basically. I want to poll the UART module for data take whatever GPS module has transmitted.

    I'm also curious as to why would the data transmission stop on adding that nrf_delay_ms(1000) !!

Reply
  • Hello Martin,

    I'm using GPS Module EM - 506. 

    For my application, I only need the latitude and longitude information. So, sending AT commands and receiving the data would make it complicated. Anyhow, upon connection, GPS module sends out the data as strings with a specific format. All I have to do is parse those strings and extract Latitude/ Longitude information from them.

    I just want to be able to read the rx buffer of uart at will and parse the data when needed. During other times, I don't care what data in arriving on the UART port.

    I would like to perform something like this

     

    // Other functions running
    // Like saadc, ble advertising
    
    if (trigger_condition) 
    {
        string = read_data_coming_from_GPS_module();
        parse_string();
    }
    

    Basically. I want to poll the UART module for data take whatever GPS module has transmitted.

    I'm also curious as to why would the data transmission stop on adding that nrf_delay_ms(1000) !!

Children
No Data
Related