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 Reply
  • Hey Marthin, Thank you for your inputs. Here is my problem,

    1) I don't have to rely on directive line on the GPS module because I don't want to know when the data ready, all I want to do is to read the data when I'm ready (assuming that GPS has a valid data).

    2) I also do not want to receive the data at specific intervals. Again, as mentioned, I just want to read the GPS data when I need it. 

    So, my thought is as follows, let the GPS continuously transmit data over UART. When I want the data, I would like to just go read the UART buffer and interpret the location. Isn't something like that possible at all?

Children
No Data
Related