[Firebug-cvs] fireboard/apps/TestNMEA NMEAM.nc,1.1,1.2 TestNMEAM.nc,1.1,1.2
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2004-08-30 21:40:20
|
Update of /cvsroot/firebug/fireboard/apps/TestNMEA In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv884 Modified Files: NMEAM.nc TestNMEAM.nc Log Message: NMEA parsing and testing framework defined, some of the code implemented. The GGA code is useful right now. Index: TestNMEAM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/apps/TestNMEA/TestNMEAM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestNMEAM.nc 30 Aug 2004 20:39:20 -0000 1.1 --- TestNMEAM.nc 30 Aug 2004 21:40:11 -0000 1.2 *************** *** 8,11 **** --- 8,16 ---- provides interface StdControl; + provides { + command result_t test_gga_parse(const char * gga_string); + command result_t test_gll_parse(const char * gll_string); + } + uses { interface NMEA as nmea; *************** *** 20,25 **** ! const char gga_string[] = {"$GPGGA,231622.994,3751.3086,N,12216.5235,W,1,09,1.1,-4.5,M,,,,0000*30"}; ! const char gll_string[] = {"$GPGLL,3723.2475,N,12158.3416,W,161229.487,A*2C"}; const char gsa_string[] = {"$GPGSA,A,3,07,02,26,27,09,04,15,,,,,,1.8,1.0,1.5*33"}; const char gsv_string1[] = {"$GPGSV,2,1,07,07,79,048,42,02,51,062,43,26,36,256,42,27,27,138,42,*71"}; --- 25,30 ---- ! const char gga_string1[] = {"$GPGGA,231622.994,3751.3086,N,12216.5235,W,1,09,1.1,-4.5,M,,,,0000*30"}; ! const char gll_string1[] = {"$GPGLL,3723.2475,N,12158.3416,W,161229.487,A*2C"}; const char gsa_string[] = {"$GPGSA,A,3,07,02,26,27,09,04,15,,,,,,1.8,1.0,1.5*33"}; const char gsv_string1[] = {"$GPGSV,2,1,07,07,79,048,42,02,51,062,43,26,36,256,42,27,27,138,42,*71"}; *************** *** 35,39 **** command result_t StdControl.start() { ! // Default test passes. uint8_t result = 1; GGA_Data gga_data; --- 40,57 ---- command result_t StdControl.start() { ! result_t result; ! result = call test_gga_parse(gga_string1); ! result *= call test_gll_parse(gll_string1); ! return result; ! } ! ! command result_t StdControl.stop() { ! return SUCCESS; ! } ! ! ! command result_t test_gga_parse(const char * gga_string) { ! ! // Default: test passes. uint8_t result = 1; GGA_Data gga_data; *************** *** 55,60 **** } ! command result_t StdControl.stop() { ! return SUCCESS; } --- 73,82 ---- } ! /** @todo Implement the test code here. */ ! command result_t test_gll_parse(const char * gll_string) { ! ! GLL_Data gll_data; ! //call nmea.gll_parse(&gll_data, gll_string); ! return FAIL; } Index: NMEAM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/apps/TestNMEA/NMEAM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NMEAM.nc 30 Aug 2004 20:39:20 -0000 1.1 --- NMEAM.nc 30 Aug 2004 21:40:11 -0000 1.2 *************** *** 5,8 **** --- 5,10 ---- * * @author David M. Doolin + * + * $Id$ */ *************** *** 19,25 **** #define extract_Long_dec_min_m(data) (10*(data[3]-'0') + (data[4]-'0') + 0.1*(data[6]-'0') \ + 0.01*(data[7]-'0') + 0.001*(data[8]-'0') + 0.0001*(data[9]-'0')) ! #define NS_m(foo) ((foo[28]=='N') ? 1 : 0) ! #define EW_m(foo) ((foo[41]=='W') ? 1 : 0) ! #define extract_NSEWind_m(foo) ((EW_m(foo)) | ((NS_m(foo))<<4)) --- 21,27 ---- #define extract_Long_dec_min_m(data) (10*(data[3]-'0') + (data[4]-'0') + 0.1*(data[6]-'0') \ + 0.01*(data[7]-'0') + 0.001*(data[8]-'0') + 0.0001*(data[9]-'0')) ! #define GGA_NS_m(foo) ((foo[28]=='N') ? 1 : 0) ! #define GGA_EW_m(foo) ((foo[41]=='W') ? 1 : 0) ! #define extract_GGA_NSEWind_m(foo) ((GGA_EW_m(foo)) | ((GGA_NS_m(foo))<<4)) *************** *** 38,41 **** --- 40,54 ---- } + /** Uses hard-wired offsets because the LeadTek will return two sizes of + * strings. The first size is when there not enough satellites, so we can + * return directly. The second is when there are enough satellites, in + * which case the fields are fixed. + * + * If this turns out to be "broken", it would not be much more + * complicated to find the offset for each by counting commas, + * because the number of fields is fixed. In any case, this is + * much faster than stuffing everything into an array as it is + * done now in the MTS420 driver code. + */ command result_t NMEA.gga_parse (GGA_Data * ggad, const char * gga_string) { *************** *** 71,81 **** ggad->Long_dec_min = extract_Long_dec_min_m(data); ! ggad->NSEWind = extract_NSEWind_m(gga_string); return SUCCESS; } command result_t NMEA.gll_parse (GLL_Data * gll_data, const char * gll_string) { ! return FAIL; } --- 84,126 ---- ggad->Long_dec_min = extract_Long_dec_min_m(data); ! ggad->NSEWind = extract_GGA_NSEWind_m(gga_string); return SUCCESS; } + command result_t NMEA.gll_parse (GLL_Data * gll_data, const char * gll_string) { ! ! const char * data; ! enum {GLL_LAT_DEG = 7, ! GLL_NS_IND = 17, ! GLL_LONG_DEG = 19, ! GLL_EW_IND = 30, ! GLL_HOURS = 32, ! GLL_STATUS = 43}; ! ! #define GLL_NS_m(foo) ((foo[GLL_NS_IND]=='N') ? 1 : 0) ! #define GLL_EW_m(foo) ((foo[GLL_EW_IND]=='W') ? 1 : 0) ! #define extract_GLL_NSEWind_m(foo) ((GLL_EW_m(foo)) | ((GLL_NS_m(foo))<<4)) ! ! data = &gll_string[GLL_LAT_DEG]; ! gll_data->Lat_deg = extract_Lat_deg_m(data); ! gll_data->Lat_dec_min = extract_Lat_dec_min_m(data); ! ! data = &gll_string[GLL_LONG_DEG]; ! gll_data->Long_deg = extract_Long_deg_m(data); ! gll_data->Long_dec_min = extract_Long_dec_min_m(data); ! ! data = &gll_string[GLL_HOURS]; ! gll_data->hours = extract_hours_m(data); ! gll_data->minutes = extract_minutes_m(data); ! gll_data->dec_sec = extract_dec_sec_m(data); ! ! ! gll_data->status = gll_string[GLL_STATUS]; ! ! gll_data->NSEWind = extract_GLL_NSEWind_m(gll_string); ! ! return SUCCESS; } |