/**************************************************************************
Name            - parse_tracking_data
Parameters      - Nothing
Responsibility  - Select a parser and extract the satellite tracking info.
                
                 
Returns         - TRUE if data was parsed
                - FALSE if data could not be parsed with any of the avialable
                  parsers.
Author          - Bill (N9CX)
**************************************************************************/
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>


#include "uart_getchar.h"
#include "main.h"
static enum {MAC_DOPPLER, NOVACOMM1, PARSER_UNKNOWN} parser = PARSER_UNKNOWN;

char novacomm1_parser(char *cptr, int);
char Mac_Doppler_parser(char *cptr, int);

char parse_tracking_data(void) {

    char result = FALSE;
    char parse_result = FALSE;
    char tmp_rx_buffer[RX_BUFFER_SZ];

    strncpy(tmp_rx_buffer, rx_buffer, sizeof tmp_rx_buffer);


    if(parser == MAC_DOPPLER || parser == PARSER_UNKNOWN){
       parse_result = Mac_Doppler_parser(tmp_rx_buffer, sizeof(tmp_rx_buffer));
       if(parse_result == TRUE){
           parser = MAC_DOPPLER;
           result = TRUE;
       }
       else parser = PARSER_UNKNOWN;
    }

    if(parser == NOVACOMM1 || parser == PARSER_UNKNOWN){
       parse_result = novacomm1_parser(rx_buffer, sizeof(rx_buffer));
       if(parse_result == TRUE){
           parser = NOVACOMM1;
           result = TRUE;
       }
       else parser = PARSER_UNKNOWN;
    }
return (result);       
}
