<commit_before>///
/// @file        tasks/gnss.c
/// @brief       FCORE - Task used for polling GNSS status regularly
/// @author      <NAME>
/// @copyright   2017 <NAME>
///
#include <stdio.h>
#include <fcore/fcore.h>
#include <fcore/tasks/gnss.h>
#include <fcore/gnss/gnss_parser.h>
#include <fcore/buses/uart.h>
#include <stdbool.h>
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"

void fcore_gnssTask(void* parameters) {
    
    fcore_uartInit(9600);
    fcore_rtxWrite((uint8_t*)"FCORE//GNSS TASK INIT\r\n", strlen("FCORE//GNSS TASK INIT\r\n"));
    vTaskDelay(3000 / portTICK_PERIOD_MS);
    
    while(true) {
        fcore_uartClear();
        fcore_gnssReset();
        vTaskDelay(3000 / portTICK_PERIOD_MS);
        
        GNSSStatus state = GNSS_PARSING;
        while(fcore_uartAvailable() > 0 && state == GNSS_PARSING) {
            state = fcore_gnssFeed(fcore_uartReadChar());
        }
        static char info[64];
        uint32_t len = 0;
        switch(state) {
        case GNSS_VALID:
            len = snprintf(info, 64, "valid NMEA packet {%d, %d, %d} (%d sats, %d)\r\n",
                           FCORE.latitude, FCORE.longitude, FCORE.altitude, FCORE.satellites, FCORE.fixQuality);
            fcore_rtxWrite((uint8_t*)info, len);
            break;
        case GNSS_NOTGGA:
            fcore_rtxWrite((uint8_t*)"Not a GGA packet\r\n", strlen("Not a GGA packet\r\n"));
            break;
        default:
            fcore_rtxWrite((uint8_t*)"Invalid NMEA packet\r\n", strlen("Invalid NMEA packet\r\n"));
            break;
        }

        vTaskDelay(10000 / portTICK_PERIOD_MS);
    }
}

extern void fcore_startGNSSTask() {
    xTaskCreate(&fcore_gnssTask, "fcore_gnss", 256, NULL, 2, NULL);
}
<commit_msg>Improve GNSS parsing to ensure GGA parsing<commit_after>///
/// @file        tasks/gnss.c
/// @brief       FCORE - Task used for polling GNSS status regularly
/// @author      <NAME>
/// @copyright   2017 <NAME>
///
#include <stdio.h>
#include <fcore/fcore.h>
#include <fcore/tasks/gnss.h>
#include <fcore/gnss/gnss_parser.h>
#include <fcore/buses/uart.h>
#include <stdbool.h>
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"

#define GNSS_MAX_ATTEMPTS 4

void fcore_gnssTask(void* parameters) {
    
    fcore_uartInit(9600);
    fcore_rtxWrite((uint8_t*)"FCORE//GNSS TASK INIT\r\n", strlen("FCORE//GNSS TASK INIT\r\n"));
    vTaskDelay(3000 / portTICK_PERIOD_MS);
    
    while(true) {
        fcore_uartClear();
        vTaskDelay(3000 / portTICK_PERIOD_MS);
        
        
        for(int i = 0; i < GNSS_MAX_ATTEMPTS; ++i) {
            
            // Reset the GNSS NMEA parser
            GNSSStatus state = GNSS_PARSING;
            fcore_gnssReset();
            
            // Get the next sentence from UART0
            while(fcore_uartAvailable() > 0 && state == GNSS_PARSING) {
                state = fcore_gnssFeed(fcore_uartReadChar());
            }
            
            if(state == GNSS_VALID) {
                char info[64];
                uint32_t len = snprintf(info, 64, "valid NMEA packet {%d, %d, %d} (%d sats, %d)\r\n",
                                        FCORE.latitude, FCORE.longitude, FCORE.altitude, FCORE.satellites, FCORE.fixQuality);
                fcore_rtxWrite((uint8_t*)info, len);
                break;
            }
        }

        vTaskDelay(10000 / portTICK_PERIOD_MS);
    }
}

extern void fcore_startGNSSTask() {
    xTaskCreate(&fcore_gnssTask, "fcore_gnss", 256, NULL, 2, NULL);
}

{'fraction_non_alphanumeric': 0.13439635535307518, 'fraction_numerical': 0.021070615034168565, 'mean_word_length': 2.2052919708029197, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4475266', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1257, 'n_words': 243}