Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CheckGPS(void *param) {
- static char line[1024];
- Nubot *temp = malloc(sizeof(Nubot));
- temp = (Nubot *) param;
- memset(line, 0, sizeof(line));
- char *dtmp = line;
- while (1) {
- dtmp = readLine(UART_NUM_2);
- if (!strncmp(dtmp, "$GPRMC,", 7)) {
- ESP_LOGW(TAG, "%s", (char* ) dtmp);
- bzero(temp->RawGPS, sizeof(temp->RawGPS));
- sprintf(temp->RawGPS, "%s", dtmp);
- DecomposeGPS(temp, 0);
- ESP_LOGE(TAG , "Flushing UART2");
- uart_flush(UART_NUM_2);
- }
- memset(dtmp, 0, sizeof(line));
- vTaskDelay(10 / portTICK_PERIOD_MS);
- }
- }
- char *readLine(uart_port_t uart) {
- static char line[1024];
- int size;
- memset(line , 0 , sizeof(line));
- char *ptr = line;
- while (1) {
- size = uart_read_bytes(uart, (unsigned char *) ptr, 1, 1000/portMAX_DELAY);
- if (size == 1) {
- printf("%c" , ptr[0]);
- if (*ptr == '\n') {
- ptr++;
- *ptr = 0;
- return line;
- }
- ptr++;
- } // End of read a character
- } // End of loop
- } // End of readLine
Add Comment
Please, Sign In to add comment