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);
}