some work done, but i need to test it in a regular C program..
This commit is contained in:
@@ -5,14 +5,49 @@
|
|||||||
* Author: Christian Lind Vie Madsen
|
* Author: Christian Lind Vie Madsen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "cm_nmea_decoder.h"
|
||||||
|
#include <string.h>
|
||||||
|
#define MAX_NMEA_MSG_TYPES 2
|
||||||
|
const char *nmea_msg_types[MAX_NMEA_MSG_TYPES] = {"$GPGLL", "$GPGFF"};
|
||||||
|
typedef int (*nmeaDecoder_Evt_fpt)(cm_nmea_msg_t *inst, char *str);
|
||||||
|
|
||||||
|
static int sGPGLL_decode(char *str){
|
||||||
|
|
||||||
|
//Move pointer until we meet a "," or NULL!
|
||||||
|
while((*str != ",") && (*str != NULL)) str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nmeaDecoder_Evt_fpt nmea_decodeFuncs[1] = {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static int sNMEA_getMsgType(char *str){
|
||||||
|
|
||||||
|
for(int i = 0; i < (MAX_NMEA_MSG_TYPES-1); i++){
|
||||||
|
|
||||||
|
if(strcmp(nmea_msg_types[i], str)) return i;
|
||||||
|
};
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int cm_nmea_characterDecode(char in){
|
int cm_nmea_characterDecode(char in){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function returns the message type, so the user knows which message has been decoded!
|
||||||
int cm_nmea_stringDecode(char *str){
|
int cm_nmea_stringDecode(char *str){
|
||||||
|
|
||||||
|
// Find which type of message we need to decode.
|
||||||
|
int nmea_msg_idx = sNMEA_getMsgType(str);
|
||||||
|
|
||||||
|
// Check if we found a valid NMEA message.
|
||||||
|
if(nmea_msg_idx == -1) return nmea_msg_idx;
|
||||||
|
|
||||||
|
// Use the correct function to decode!
|
||||||
|
if(nmea_msg_idx >= 0) nmea_msg_types[nmea_msg](str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
|
||||||
|
NMEA_MSG_GPGLL = 0,
|
||||||
|
|
||||||
|
}nmea_msg_type;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
uint8_t deg; // Degrees: 0–90 (latitude) or 0–180 (longitude)
|
uint8_t deg; // Degrees: 0–90 (latitude) or 0–180 (longitude)
|
||||||
@@ -38,7 +43,7 @@ typedef struct {
|
|||||||
cm_nmea_gpgll_msg gpgll_msg;
|
cm_nmea_gpgll_msg gpgll_msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
}cm_nmea_msg;
|
}cm_nmea_msg_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user