last commit before gitea mirror
This commit is contained in:
@@ -9,20 +9,47 @@
|
||||
#define MAIN_CM_NMEA_DECODER_CM_NMEA_DECODER_H_
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "GPGxx_defines.h"
|
||||
|
||||
typedef enum {
|
||||
typedef struct {
|
||||
|
||||
NMEA_MSG_GPGLL = 0,
|
||||
nmea_msg_t msg;
|
||||
|
||||
}nmea_msg_type;
|
||||
}cm_nmea_msg_t;
|
||||
|
||||
typedef struct{
|
||||
uint8_t lat_deg; // Degrees: 0–90 (latitude) or 0–180 (longitude)
|
||||
uint32_t lat_min_x10000; // Minutes × 10,000 (e.g., 16.4512 → 164512)
|
||||
|
||||
uint8_t lon_deg; // Degrees: 0–90 (latitude) or 0–180 (longitude)
|
||||
uint32_t lon_min_x10000; // Minutes × 10,000 (e.g., 16.4512 → 164512)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int cm_nmea_stringDecode(cm_nmea_msg_t *inst, char *str);
|
||||
|
||||
/*
|
||||
#define OFFSET(struct_type, field) ((size_t)&(((struct_type *)0)->field))
|
||||
|
||||
FieldDesc gpgll_fields[] = {
|
||||
{ "latitude", FIELD_INT32, OFFSET(GPGLL_t, latitude), 1 },
|
||||
{ "lat_dir", FIELD_CHAR, OFFSET(GPGLL_t, lat_dir), 0 },
|
||||
{ "longitude", FIELD_INT32, OFFSET(GPGLL_t, longitude), 1 },
|
||||
{ "lon_dir", FIELD_CHAR, OFFSET(GPGLL_t, lon_dir), 0 },
|
||||
{ "utc_time", FIELD_UINT32, OFFSET(GPGLL_t, utc_time), 0 }
|
||||
};
|
||||
|
||||
const char *nmea = "$GPGLL,5606.2719,N,01007.2199,E,130808,A,A*56";
|
||||
GPGLL_t gpgll = {0};
|
||||
|
||||
parse_nmea_generic(nmea, &gpgll, gpgll_fields, sizeof(gpgll_fields)/sizeof(gpgll_fields[0]));
|
||||
|
||||
printf("Latitude: %d\n", gpgll.latitude);
|
||||
printf("Longitude: %d\n", gpgll.longitude);
|
||||
printf("Time: %u\n", gpgll.utc_time);
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
uint8_t deg; // Degrees: 0–90 (latitude) or 0–180 (longitude)
|
||||
uint32_t min_x10000; // Minutes × 10,000 (e.g., 16.4512 → 164512)
|
||||
char dir; // 'N', 'S', 'E', or 'W'
|
||||
}cm_nmea_coord;
|
||||
|
||||
@@ -40,15 +67,6 @@ typedef struct {
|
||||
|
||||
}cm_nmea_gpgll_msg;
|
||||
|
||||
typedef struct {
|
||||
|
||||
union{
|
||||
|
||||
cm_nmea_gpgll_msg gpgll_msg;
|
||||
};
|
||||
|
||||
}cm_nmea_msg_t;
|
||||
|
||||
int cm_nmea_stringDecode(cm_nmea_msg_t *inst, char *str);
|
||||
* */
|
||||
|
||||
#endif /* MAIN_CM_NMEA_DECODER_CM_NMEA_DECODER_H_ */
|
||||
|
||||
Reference in New Issue
Block a user