[Firebug-cvs] fireboard/beta/tools/gps/SiRF Makefile,1.2,1.3 sirf.h,1.2,1.3 sirf_id28_1.c,1.1,1.2 si
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2005-07-29 19:12:37
|
Update of /cvsroot/firebug/fireboard/beta/tools/gps/SiRF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7305 Modified Files: Makefile sirf.h sirf_id28_1.c sirf_id28_2.c sirf_id28_3.c sirf_id2_1.c sirf_id2_2.c sirftest.c Log Message: Added more test code for sirf parsing. Index: sirf_id28_3.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/sirf_id28_3.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sirf_id28_3.c 15 Jul 2005 16:23:37 -0000 1.1 --- sirf_id28_3.c 29 Jul 2005 19:12:26 -0000 1.2 *************** *** 66,70 **** //Format string generated automatically, ! static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i"; --- 66,70 ---- //Format string generated automatically, ! //static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i"; *************** *** 273,276 **** --- 273,278 ---- + // Not yet used. + #if 0 static char insert_stmt[] = "INSERT into SiRF_ID28_3 (" "header_seqno," *************** *** 295,298 **** --- 297,301 ---- "low_power_count) values (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"; + #endif #if 0 void *************** *** 528,553 **** /** Print the bytes of the packet. */ ! void SiRF_ID28_3_print_raw (XbowSensorboardPacket *packet) { ! ! SiRF_ID28_3 * userdata = (SiRF_ID28_3*)packet->data; ! } ! ! /** Print typed output. */ ! void SiRF_ID28_3_print_cooked (XbowSensorboardPacket *packet) { - SiRF_ID28_3 * userdata = (SiRF_ID28_3*)packet->data; } ! /** Print cooked with tabs. */ ! void SiRF_ID28_3_print_tabbed (XbowSensorboardPacket *packet) { ! SiRF_ID28_3 * userdata = (SiRF_ID28_3*)packet->data; } /** The default size of this message type in bytes. */ ! static int DEFAULT_MESSAGE_SIZE = 23; /** The Active Message type associated with this message. */ ! static int AM_TYPE = 154; /** If incomplete types are used, we need to provide a way --- 531,571 ---- /** Print the bytes of the packet. */ ! void ! SiRF_ID28_3_print_raw (XbowSensorboardPacket *packet) { } ! /** Print cooked output. */ ! void ! SiRF_ID28_3_print_cooked (void * userdata) { ! SiRF_ID28_3 * data = (SiRF_ID28_3*)userdata; ! printf("header_seqno: %i,\n",data->header_seqno); ! printf("header_am_type: %i,\n",data->header_am_type); ! printf("header_rsrvd1: %i,\n",data->header_rsrvd1); ! printf("header_rsrvd2: %i,\n",data->header_rsrvd2); ! printf("sync_flags: %i,\n",data->sync_flags); ! printf("cno1: %i,\n",data->cno1); ! printf("cno2: %i,\n",data->cno2); ! printf("cno3: %i,\n",data->cno3); ! printf("cno4: %i,\n",data->cno4); ! printf("cno5: %i,\n",data->cno5); ! printf("cno6: %i,\n",data->cno6); ! printf("cno7: %i,\n",data->cno7); ! printf("cno8: %i,\n",data->cno8); ! printf("cno9: %i,\n",data->cno9); ! printf("cno10: %i,\n",data->cno10); ! printf("delta_range_interval: %i,\n",data->delta_range_interval); ! printf("mean_delta_range_time: %i,\n",data->mean_delta_range_time); ! printf("extrapolation_time: %i,\n",data->extrapolation_time); ! printf("phase_error_count: %i,\n",data->phase_error_count); ! printf("low_power_count: %i,\n",data->low_power_count); } /** The default size of this message type in bytes. */ ! //static int DEFAULT_MESSAGE_SIZE = 23; /** The Active Message type associated with this message. */ ! //static int AM_TYPE = 154; /** If incomplete types are used, we need to provide a way Index: sirf.h =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/sirf.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sirf.h 15 Jul 2005 16:23:37 -0000 1.2 --- sirf.h 29 Jul 2005 19:12:26 -0000 1.3 *************** *** 30,36 **** fb_header header; ! uint32_t xpos; ! uint32_t ypos; ! uint32_t zpos; uint16_t xvel; --- 30,36 ---- fb_header header; ! int32_t xpos; ! int32_t ypos; ! int32_t zpos; uint16_t xvel; *************** *** 39,42 **** --- 39,44 ---- uint8_t mode1; + uint8_t dop; + uint8_t mode2; uint16_t gps_week; Index: sirf_id2_1.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/sirf_id2_1.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sirf_id2_1.c 15 Jul 2005 16:23:37 -0000 1.1 --- sirf_id2_1.c 29 Jul 2005 19:12:26 -0000 1.2 *************** *** 45,55 **** uint8_t header_rsrvd1; uint8_t header_rsrvd2; ! uint32_t xpos; ! uint32_t ypos; ! uint32_t zpos; uint16_t xvel; uint16_t yvel; uint16_t zvel; uint8_t mode1; uint16_t gps_week; }; --- 45,57 ---- uint8_t header_rsrvd1; uint8_t header_rsrvd2; ! int xpos; ! int ypos; ! int zpos; uint16_t xvel; uint16_t yvel; uint16_t zvel; uint8_t mode1; + uint8_t dop; + uint8_t mode2; uint16_t gps_week; }; *************** *** 58,62 **** //Format string generated automatically, ! static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i"; --- 60,64 ---- //Format string generated automatically, ! //static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i"; *************** *** 102,110 **** void ! SiRF_ID2_1_set_xpos(SiRF_ID2_1 * userdata, uint32_t xpos) { userdata->xpos = xpos; } ! uint32_t SiRF_ID2_1_get_xpos(SiRF_ID2_1 * userdata) { return userdata->xpos; --- 104,112 ---- void ! SiRF_ID2_1_set_xpos(SiRF_ID2_1 * userdata, int xpos) { userdata->xpos = xpos; } ! int SiRF_ID2_1_get_xpos(SiRF_ID2_1 * userdata) { return userdata->xpos; *************** *** 112,120 **** void ! SiRF_ID2_1_set_ypos(SiRF_ID2_1 * userdata, uint32_t ypos) { userdata->ypos = ypos; } ! uint32_t SiRF_ID2_1_get_ypos(SiRF_ID2_1 * userdata) { return userdata->ypos; --- 114,122 ---- void ! SiRF_ID2_1_set_ypos(SiRF_ID2_1 * userdata, int ypos) { userdata->ypos = ypos; } ! int SiRF_ID2_1_get_ypos(SiRF_ID2_1 * userdata) { return userdata->ypos; *************** *** 122,130 **** void ! SiRF_ID2_1_set_zpos(SiRF_ID2_1 * userdata, uint32_t zpos) { userdata->zpos = zpos; } ! uint32_t SiRF_ID2_1_get_zpos(SiRF_ID2_1 * userdata) { return userdata->zpos; --- 124,132 ---- void ! SiRF_ID2_1_set_zpos(SiRF_ID2_1 * userdata, int zpos) { userdata->zpos = zpos; } ! int SiRF_ID2_1_get_zpos(SiRF_ID2_1 * userdata) { return userdata->zpos; *************** *** 172,175 **** --- 174,197 ---- void + SiRF_ID2_1_set_dop(SiRF_ID2_1 * userdata, uint8_t dop) { + userdata->dop = dop; + } + + uint8_t + SiRF_ID2_1_get_dop(SiRF_ID2_1 * userdata) { + return userdata->dop; + } + + void + SiRF_ID2_1_set_mode2(SiRF_ID2_1 * userdata, uint8_t mode2) { + userdata->mode2 = mode2; + } + + uint8_t + SiRF_ID2_1_get_mode2(SiRF_ID2_1 * userdata) { + return userdata->mode2; + } + + void SiRF_ID2_1_set_gps_week(SiRF_ID2_1 * userdata, uint16_t gps_week) { userdata->gps_week = gps_week; *************** *** 185,188 **** --- 207,212 ---- + // Not yet used. + #if 0 static char insert_stmt[] = "INSERT into SiRF_ID2_1 (" "header_seqno," *************** *** 197,202 **** "zvel," "mode1," ! "gps_week) values (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"; #if 0 void --- 221,229 ---- "zvel," "mode1," ! "dop," ! "mode2," ! "gps_week) values (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"; + #endif #if 0 void *************** *** 206,209 **** --- 233,237 ---- sprintf(pg_command,formatstring, data->mode1, + data->dop, data->header_rsrvd2, data->yvel, *************** *** 213,216 **** --- 241,245 ---- data->xpos, data->xvel, + data->mode2, data->header_seqno, data->ypos, *************** *** 258,263 **** * User is responsible for "cooking" the data. */ ! static uint32_t ! xpos_convert(uint32_t xpos) { return xpos; } --- 287,292 ---- * User is responsible for "cooking" the data. */ ! static int ! xpos_convert(int xpos) { return xpos; } *************** *** 266,271 **** * User is responsible for "cooking" the data. */ ! static uint32_t ! ypos_convert(uint32_t ypos) { return ypos; } --- 295,300 ---- * User is responsible for "cooking" the data. */ ! static int ! ypos_convert(int ypos) { return ypos; } *************** *** 274,279 **** * User is responsible for "cooking" the data. */ ! static uint32_t ! zpos_convert(uint32_t zpos) { return zpos; } --- 303,308 ---- * User is responsible for "cooking" the data. */ ! static int ! zpos_convert(int zpos) { return zpos; } *************** *** 314,317 **** --- 343,362 ---- * User is responsible for "cooking" the data. */ + static uint8_t + dop_convert(uint8_t dop) { + return dop; + } + + /** @brief Default behavior is to return the input as output. + * User is responsible for "cooking" the data. + */ + static uint8_t + mode2_convert(uint8_t mode2) { + return mode2; + } + + /** @brief Default behavior is to return the input as output. + * User is responsible for "cooking" the data. + */ static uint16_t gps_week_convert(uint16_t gps_week) { *************** *** 332,335 **** --- 377,382 ---- userdata->zvel = zvel_convert(userdata->zvel); userdata->mode1 = mode1_convert(userdata->mode1); + userdata->dop = dop_convert(userdata->dop); + userdata->mode2 = mode2_convert(userdata->mode2); userdata->gps_week = gps_week_convert(userdata->gps_week); } *************** *** 352,377 **** /** Print the bytes of the packet. */ ! void SiRF_ID2_1_print_raw (XbowSensorboardPacket *packet) { ! ! SiRF_ID2_1 * userdata = (SiRF_ID2_1*)packet->data; ! } ! ! /** Print typed output. */ ! void SiRF_ID2_1_print_cooked (XbowSensorboardPacket *packet) { - SiRF_ID2_1 * userdata = (SiRF_ID2_1*)packet->data; } ! /** Print cooked with tabs. */ ! void SiRF_ID2_1_print_tabbed (XbowSensorboardPacket *packet) { ! SiRF_ID2_1 * userdata = (SiRF_ID2_1*)packet->data; } /** The default size of this message type in bytes. */ ! static int DEFAULT_MESSAGE_SIZE = 25; /** The Active Message type associated with this message. */ ! static int AM_TYPE = 150; /** If incomplete types are used, we need to provide a way --- 399,433 ---- /** Print the bytes of the packet. */ ! void ! SiRF_ID2_1_print_raw (XbowSensorboardPacket *packet) { } ! /** Print cooked output. */ ! void ! SiRF_ID2_1_print_cooked (void * userdata) { ! SiRF_ID2_1 * data = (SiRF_ID2_1*)userdata; ! printf("header_seqno: %i,\n",data->header_seqno); ! printf("header_am_type: %i,\n",data->header_am_type); ! printf("header_rsrvd1: %i,\n",data->header_rsrvd1); ! printf("header_rsrvd2: %i,\n",data->header_rsrvd2); ! printf("xpos: %i,\n",data->xpos); ! printf("ypos: %i,\n",data->ypos); ! printf("zpos: %i,\n",data->zpos); ! printf("xvel: %i,\n",data->xvel); ! printf("yvel: %i,\n",data->yvel); ! printf("zvel: %i,\n",data->zvel); ! printf("mode1: %i,\n",data->mode1); ! printf("dop: %i,\n",data->dop); ! printf("mode2: %i,\n",data->mode2); ! printf("gps_week: %i,\n",data->gps_week); } /** The default size of this message type in bytes. */ ! //static int DEFAULT_MESSAGE_SIZE = 27; /** The Active Message type associated with this message. */ ! //static int AM_TYPE = 150; /** If incomplete types are used, we need to provide a way Index: sirf_id2_2.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/sirf_id2_2.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sirf_id2_2.c 15 Jul 2005 16:23:37 -0000 1.1 --- sirf_id2_2.c 29 Jul 2005 19:12:26 -0000 1.2 *************** *** 64,68 **** //Format string generated automatically, ! static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i"; --- 64,68 ---- //Format string generated automatically, ! //static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i"; *************** *** 251,254 **** --- 251,256 ---- + // Not yet used. + #if 0 static char insert_stmt[] = "INSERT into SiRF_ID2_2 (" "header_seqno," *************** *** 271,274 **** --- 273,277 ---- "ch12) values (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"; + #endif #if 0 void *************** *** 484,509 **** /** Print the bytes of the packet. */ ! void SiRF_ID2_2_print_raw (XbowSensorboardPacket *packet) { ! ! SiRF_ID2_2 * userdata = (SiRF_ID2_2*)packet->data; ! } ! ! /** Print typed output. */ ! void SiRF_ID2_2_print_cooked (XbowSensorboardPacket *packet) { - SiRF_ID2_2 * userdata = (SiRF_ID2_2*)packet->data; } ! /** Print cooked with tabs. */ ! void SiRF_ID2_2_print_tabbed (XbowSensorboardPacket *packet) { ! SiRF_ID2_2 * userdata = (SiRF_ID2_2*)packet->data; } /** The default size of this message type in bytes. */ ! static int DEFAULT_MESSAGE_SIZE = 21; /** The Active Message type associated with this message. */ ! static int AM_TYPE = 151; /** If incomplete types are used, we need to provide a way --- 487,525 ---- /** Print the bytes of the packet. */ ! void ! SiRF_ID2_2_print_raw (XbowSensorboardPacket *packet) { } ! /** Print cooked output. */ ! void ! SiRF_ID2_2_print_cooked (void * userdata) { ! SiRF_ID2_2 * data = (SiRF_ID2_2*)userdata; ! printf("header_seqno: %i,\n",data->header_seqno); ! printf("header_am_type: %i,\n",data->header_am_type); ! printf("header_rsrvd1: %i,\n",data->header_rsrvd1); ! printf("header_rsrvd2: %i,\n",data->header_rsrvd2); ! printf("gps_tow: %d,\n",data->gps_tow); ! printf("sv_in_fix: %i,\n",data->sv_in_fix); ! printf("ch1: %i,\n",data->ch1); ! printf("ch2: %i,\n",data->ch2); ! printf("ch3: %i,\n",data->ch3); ! printf("ch4: %i,\n",data->ch4); ! printf("ch5: %i,\n",data->ch5); ! printf("ch6: %i,\n",data->ch6); ! printf("ch7: %i,\n",data->ch7); ! printf("ch8: %i,\n",data->ch8); ! printf("ch9: %i,\n",data->ch9); ! printf("ch10: %i,\n",data->ch10); ! printf("ch11: %i,\n",data->ch11); ! printf("ch12: %i,\n",data->ch12); } /** The default size of this message type in bytes. */ ! //static int DEFAULT_MESSAGE_SIZE = 21; /** The Active Message type associated with this message. */ ! //static int AM_TYPE = 151; /** If incomplete types are used, we need to provide a way Index: sirf_id28_1.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/sirf_id28_1.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sirf_id28_1.c 15 Jul 2005 16:23:37 -0000 1.1 --- sirf_id28_1.c 29 Jul 2005 19:12:26 -0000 1.2 *************** *** 54,58 **** //Format string generated automatically, ! static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i"; --- 54,58 ---- //Format string generated automatically, ! //static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i"; *************** *** 141,144 **** --- 141,146 ---- + // Not yet used. + #if 0 static char insert_stmt[] = "INSERT into SiRF_ID28_1 (" "header_seqno," *************** *** 151,154 **** --- 153,157 ---- "gps_sw_time) values (0, 0, 0, 0, 0, 0, 0, 0)"; + #endif #if 0 void *************** *** 264,289 **** /** Print the bytes of the packet. */ ! void SiRF_ID28_1_print_raw (XbowSensorboardPacket *packet) { ! ! SiRF_ID28_1 * userdata = (SiRF_ID28_1*)packet->data; ! } ! ! /** Print typed output. */ ! void SiRF_ID28_1_print_cooked (XbowSensorboardPacket *packet) { - SiRF_ID28_1 * userdata = (SiRF_ID28_1*)packet->data; } ! /** Print cooked with tabs. */ ! void SiRF_ID28_1_print_tabbed (XbowSensorboardPacket *packet) { ! SiRF_ID28_1 * userdata = (SiRF_ID28_1*)packet->data; } /** The default size of this message type in bytes. */ ! static int DEFAULT_MESSAGE_SIZE = 18; /** The Active Message type associated with this message. */ ! static int AM_TYPE = 152; /** If incomplete types are used, we need to provide a way --- 267,295 ---- /** Print the bytes of the packet. */ ! void ! SiRF_ID28_1_print_raw (XbowSensorboardPacket *packet) { } ! /** Print cooked output. */ ! void ! SiRF_ID28_1_print_cooked (void * userdata) { ! SiRF_ID28_1 * data = (SiRF_ID28_1*)userdata; ! printf("header_seqno: %i,\n",data->header_seqno); ! printf("header_am_type: %i,\n",data->header_am_type); ! printf("header_rsrvd1: %i,\n",data->header_rsrvd1); ! printf("header_rsrvd2: %i,\n",data->header_rsrvd2); ! printf("channel: %i,\n",data->channel); ! printf("time_tag: %i,\n",data->time_tag); ! printf("sat_id: %i,\n",data->sat_id); ! printf("gps_sw_time: %i,\n",data->gps_sw_time); } /** The default size of this message type in bytes. */ ! //static int DEFAULT_MESSAGE_SIZE = 18; /** The Active Message type associated with this message. */ ! //static int AM_TYPE = 152; /** If incomplete types are used, we need to provide a way Index: sirftest.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/sirftest.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sirftest.c 15 Jul 2005 17:34:36 -0000 1.3 --- sirftest.c 29 Jul 2005 19:12:26 -0000 1.4 *************** *** 2,18 **** #include <stdio.h> #include "sirf.h" static char sirf_id2[] = { ! 0x02, ! 0xff, 0xd6, 0xf7, 0x8c, ! 0xff, 0xbe, 0x53, 0x6e}; ! int ! main(int argc, char ** argv) { ! int32_t xpos = 0; ! int32_t ypos = 0; ! uint8_t message_id; printf("sirf id 2,1: %d\n",sizeof(SiRF_ID2_1)); --- 2,188 ---- #include <stdio.h> + #ifndef FALSE + #define FALSE 0 + #endif + #ifndef TRUE + #define TRUE !FALSE + #endif + #include "sirf.h" + static FILE * outstream; + + + + // See page 40 of the LeadTek Protocol manual for + // example sirf id 2 string. static char sirf_id2[] = { ! 0x02, // message id ! 0xff, 0xd6, 0xf7, 0x8c, // x position ! 0xff, 0xbe, 0x53, 0x6e, // y position ! 0x00, 0x3a, 0xc0, 0x04, // z position ! 0x00, 0x00, // x velocity ! 0x00, 0x03, // y velocity ! 0x00, 0x01, // z velocity ! 0x04, // mode 1 ! 0x0a, // (H)DOP ! 0x00, // mode 2 ! 0x03, 0x6b, // GPS Week ! 0x03, 0x97, 0x80, 0xe3, // GPS TOW ! 0x06, // Sats in fix ! 0x12, // ch 1 ! 0x19, // ch 2 ! 0x0e, // ch 3 ! 0x16, // ch 4 ! 0x0f, // ch 5 ! 0x04, // ch 6 ! 0x00, // ch 7 ! 0x00, // ch 8 ! 0x00, // ch 9 ! 0x00, // ch 10 ! 0x00, // ch 11 ! 0x00 // ch 12 ! }; ! // See page 67 of the LeadTek Protocol manual for ! // example sirf id 2 string. ! static char sirf_id28[] = { ! 0x1c, // message id ! 0x00, // channel ! 0x00, 0x06, 0x60, 0xd0, // time tag ! 0x15, // satellite id ! 0xf1, 0x43, 0xf6, 0x2c, // GPS Software time, 1st 4 bytes ! 0x41, 0x13, 0xf4, 0x2f, // GPS Software time, 2d 4 bytes ! 0x41, 0x7b, 0x23, 0x5c, // Pseudo-range, 1st 4 bytes ! 0xf3, 0xfb, 0xe9, 0x5e, // Pseudo-range, 2d 4 bytes ! 0x46, 0x8c, 0x69, 0x64, // Carrier freq. ! 0xb8, 0xfb, 0xc5, 0x82, // Carrier phase, 1st 4 bytes ! 0x41, 0x5c, 0xf1, 0x5e, // Carrier phase, 2d 4 bytes ! 0x75, 0x30, // Time in track ! 0x17, // Sync flags ! 0x34, // C/No 1 ! 0x34, // C/No 2 ! 0x34, // C/No 3 ! 0x34, // C/No 4 ! 0x34, // C/No 5 ! 0x34, // C/No 6 ! 0x34, // C/No 7 ! 0x34, // C/No 8 ! 0x34, // C/No 9 ! 0x34, // C/No 10 ! 0x03, 0xe8, // Delta Range interval ! 0x01, 0xf4, // Mean Delta Range Time ! 0x00, 0x00, // Extrapolation time ! 0x00, // Phase error count ! 0x00 // Low Power Count ! }; ! ! // TODO: Make a macro for this. ! static int ! convert_4_bytes_to_int(char * bytes) { ! ! int val = 0; ! val |= bytes[0] & 0xFF; ! val <<= 8; ! val |= bytes[1] & 0xFF; ! val <<= 8; ! val |= bytes[2] & 0xFF; ! val <<= 8; ! val |= bytes[3] & 0xFF; ! return val; ! } ! ! // TODO: Make a macro for this. ! static float ! convert_2_bytes_to_float(char * bytes) { ! ! int16_t val = 0; ! val |= bytes[0] & 0xFF; ! val <<= 8; ! val |= bytes[1] & 0xFF; ! return (float)val; ! } ! ! ! // TODO: Make a macro for this. ! static float ! convert_4_bytes_to_float(char * bytes) { ! ! int32_t val = 0; ! val |= bytes[0] & 0xFF; ! val <<= 8; ! val |= bytes[1] & 0xFF; ! val <<= 8; ! val |= bytes[2] & 0xFF; ! val <<= 8; ! val |= bytes[3] & 0xFF; ! return (float)val; ! } ! ! ! // FIXME: Get rid of locally defined variable ! // so that this can be turned into a macro. ! static double ! convert_8_bytes_to_double(char * bytes) { ! ! int64_t val = 0; ! val |= bytes[0] & 0xFF; ! val <<= 8; ! val |= bytes[1] & 0xFF; ! val <<= 8; ! val |= bytes[2] & 0xFF; ! val <<= 8; ! val |= bytes[3] & 0xFF; ! val <<= 8; ! val |= bytes[4] & 0xFF; ! val <<= 8; ! val |= bytes[5] & 0xFF; ! val <<= 8; ! val |= bytes[6] & 0xFF; ! val <<= 8; ! val |= bytes[7] & 0xFF; ! return (double)val; ! } ! ! // TODO: Make a macro for this. ! static uint16_t ! convert_2_bytes_to_uint16(char * bytes) { ! ! uint16_t val = 0; ! val |= bytes[0] & 0xFF; ! val <<= 8; ! val |= bytes[1] & 0xFF; ! return val; ! } ! ! ! int ! test_sirf_id2_parsing(void) { ! ! SiRF_ID2_1 sid2_1 = {{0}}; ! ! sid2_1.header.seqno = 13; ! sid2_1.header.am_type = 150; ! sid2_1.xpos = convert_4_bytes_to_int(&sirf_id2[1]); ! sid2_1.ypos = convert_4_bytes_to_int(&sirf_id2[4]); ! sid2_1.zpos = convert_4_bytes_to_int(&sirf_id2[9]); ! sid2_1.xvel = convert_2_bytes_to_float(&sirf_id2[13]); ! sid2_1.yvel = convert_2_bytes_to_float(&sirf_id2[15]); ! sid2_1.zvel = convert_2_bytes_to_float(&sirf_id2[17]); ! sid2_1.mode1 = sirf_id2[19]; ! sid2_1.dop = sirf_id2[20]; ! sid2_1.mode2 = sirf_id2[21]; ! ! // memcpy(&sid2_1 + 4,&sirf_id2[1],23); ! ! //SiRF_ID2_1_print_cooked (&sid2_1); ! ! return 0; ! } ! ! ! void ! print_struct_sizes(void) { printf("sirf id 2,1: %d\n",sizeof(SiRF_ID2_1)); *************** *** 22,51 **** printf("sirf id 28,3: %d\n",sizeof(SiRF_ID28_3)); ! printf("sirf_id2 string: %x\n",sirf_id2); ! message_id = sirf_id2[0]; ! printf("message_id: %d\n", message_id); - /** This works, needs to be moved to a macro. */ - xpos |= sirf_id2[1] & 0xFF; - xpos <<= 8; - xpos |= sirf_id2[2] & 0xFF; - xpos <<= 8; - xpos |= sirf_id2[3] & 0xFF; - xpos <<= 8; - xpos |= sirf_id2[4] & 0xFF; ! ypos |= sirf_id2[5] & 0xFF; ! ypos <<= 8; ! ypos |= sirf_id2[6] & 0xFF; ! ypos <<= 8; ! ypos |= sirf_id2[7] & 0xFF; ! ypos <<= 8; ! ypos |= sirf_id2[8] & 0xFF; ! printf("X Pos: %i\n", xpos); ! printf("Y Pos: %i\n", ypos); return 0; --- 192,448 ---- printf("sirf id 28,3: %d\n",sizeof(SiRF_ID28_3)); ! } ! void ! print_message_sizes(void) { ! printf("Size of sirf id 2 string: %d\n", sizeof(sirf_id2)); ! printf("Size of sirf id 28 string: %d\n", sizeof(sirf_id28)); ! } ! uint8_t ! get_message_id(char * msg) { ! ! return msg[0]; ! } + void + print_sirf2_message(void) { ! uint8_t msgid = 0; ! int32_t xpos = 0; ! int32_t ypos = 0; ! int32_t zpos = 0; ! ! float xvel = 0; ! float yvel = 0; ! float zvel = 0; ! ! ! msgid = get_message_id(sirf_id2); ! ! xpos = convert_4_bytes_to_int(&sirf_id2[1]); ! ypos = convert_4_bytes_to_int(&sirf_id2[5]); ! zpos = convert_4_bytes_to_int(&sirf_id2[9]); ! ! printf("Message ID: %d:\n",msgid); ! printf("X Pos: %ld\n", xpos); ! printf("Y Pos: %ld\n", ypos); ! printf("Z Pos: %ld\n", zpos); ! ! xvel = convert_2_bytes_to_float(&sirf_id2[13]); ! yvel = convert_2_bytes_to_float(&sirf_id2[15]); ! zvel = convert_2_bytes_to_float(&sirf_id2[17]); ! ! printf("X Vel: %f\n", xvel/8.0); ! printf("Y Vel: %f\n", yvel/8.0); ! printf("Z Vel: %f\n", zvel/8.0); ! ! printf("Mode 1: %d\n",sirf_id2[19]); ! printf("(H)DOP: %f\n",(float)sirf_id2[20]/5.0); ! printf("Mode 2: %d\n",sirf_id2[21]); ! ! printf("GPS Week: %d\n",convert_2_bytes_to_uint16(&sirf_id2[22])); ! //printf("GPS TOW: %f\n",(float)convert_4_bytes_to_int(&sirf_id2[24])/100.0); ! } ! ! unsigned char ! leadtek_crc(char * message, int size) { ! ! unsigned char cs = 0; ! int index = 1; ! ! while (message[index] != '*') { ! ! cs ^= message[index++]; ! } ! ! return cs; ! } ! ! unsigned char ! sirf_crc(char * msg, uint8_t size) { ! ! unsigned char cs = 0; ! uint8_t i; ! ! for (i=0; i<size; i++) { ! cs = cs ^ msg[i]; ! } ! return cs; ! } ! ! ! int ! fb_sirfid28_test() { ! ! return FALSE; ! } ! ! ! ! int ! fb_sirfid2_test() { ! ! int passed = FALSE; ! ! uint8_t msgid = 0; ! int32_t xpos = 0; ! int32_t ypos = 0; ! int32_t zpos = 0; ! ! float xvel = 0; ! float yvel = 0; ! float zvel = 0; ! ! uint8_t mode1, mode2; ! float dop; ! uint16_t gps_week; ! uint32_t gps_tow; ! uint8_t sats_in_fix; ! uint8_t ch1, ch2, ch3, ch4, ch5, ch6, ! ch7, ch8, ch9, ch10, ch11, ch12; ! ! ! msgid = get_message_id(sirf_id2); ! passed = (msgid == 2); ! ! xpos = convert_4_bytes_to_int(&sirf_id2[1]); ! passed &= (xpos == -2689140); ! ! ypos = convert_4_bytes_to_int(&sirf_id2[5]); ! passed &= (ypos == -4304018); ! ! zpos = convert_4_bytes_to_int(&sirf_id2[9]); ! passed &= (zpos == 3850244); ! ! xvel = convert_2_bytes_to_float(&sirf_id2[13]); ! passed &= (xvel == 0.0); ! ! yvel = convert_2_bytes_to_float(&sirf_id2[15])/8.0; ! passed &= (yvel == 0.375); ! ! zvel = convert_2_bytes_to_float(&sirf_id2[17])/8.0; ! passed &= (zvel == 0.125); ! ! mode1 = sirf_id2[19]; ! passed &= (mode1 == 4); ! ! dop = (float)sirf_id2[20]/5.0; ! passed &= (dop == 2.0); ! ! mode2 = sirf_id2[21]; ! passed &= (mode2 == 0); ! ! gps_week = convert_2_bytes_to_uint16(&sirf_id2[22]); ! passed &= (gps_week == 875); ! ! gps_tow = convert_4_bytes_to_int(&sirf_id2[24]); ! passed &= (gps_tow == 60260579); ! ! sats_in_fix = sirf_id2[28]; ! passed &= (sats_in_fix == 6); ! ! ch1 = sirf_id2[29]; ! passed &= (ch1 == 18); ! ! ch2 = sirf_id2[30]; ! passed &= (ch2 == 25); ! ! ch3 = sirf_id2[31]; ! passed &= (ch3 == 14); ! ! ch4 = sirf_id2[32]; ! passed &= (ch4 == 22); ! ! ch5 = sirf_id2[33]; ! passed &= (ch5 == 15); ! ! ch6 = sirf_id2[34]; ! passed &= (ch6 == 4); ! ! ch7 = sirf_id2[35]; ! passed &= (ch7 == 0); ! ! ch8 = sirf_id2[36]; ! passed &= (ch8 == 0); ! ! ch9 = sirf_id2[37]; ! passed &= (ch9 == 0); ! ! ch10 = sirf_id2[38]; ! passed &= (ch10 == 0); ! ! ch11 = sirf_id2[39]; ! passed &= (ch11 == 0); ! ! ch12 = sirf_id2[40]; ! passed &= (ch12 == 0); ! ! /* ! fprintf(outstream,"GPS Week: %d\n",gps_week); ! fprintf(outstream,"GPS TOW: %d\n", gps_tow); ! fprintf(outstream,"SVs in fix: %d\n", sats_in_fix); ! ! ! fprintf(outstream, ! "Channels 1-6: %d %d %d %d %d %d\n" ! "Channels 7-12: %d %d %d %d %d %d\n", ! ch1, ch2, ch3, ch4, ch5, ch6, ! ch7, ch8, ch9, ch10, ch11, ch12); ! ! */ ! ! return passed; ! ! } ! ! ! int ! fb_sirf_test(void) { ! ! if (fb_sirfid2_test()) { ! fprintf(outstream, "SiRF ID 2 parsing passed.\n"); ! } else { ! fprintf(outstream, "SiRF ID 2 parsing failed.\n"); ! } ! ! if (fb_sirfid28_test()) { ! fprintf(outstream, "SiRF ID 28 parsing passed.\n"); ! } else { ! fprintf(outstream, "SiRF ID 28 parsing failed.\n"); ! } ! ! return FALSE; ! } ! ! ! void ! temporary(void) { ! ! double tmp = 0; ! tmp = convert_8_bytes_to_double(&sirf_id28[7]); ! tmp = convert_4_bytes_to_float(&sirf_id28[23]); ! ! printf("CRC 2: %x\n",sirf_crc(sirf_id2,41)); ! ! printf("tmp: %lf\n", tmp); ! ! //print_message_sizes(); ! //print_struct_sizes(); ! //test_sirf_id2_parsing(); ! ! ! } ! ! ! int ! main(int argc, char ** argv) { ! ! outstream = stdout; ! fb_sirf_test(); ! ! print_sirf2_message(); return 0; Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 15 Jul 2005 16:23:36 -0000 1.2 --- Makefile 29 Jul 2005 19:12:26 -0000 1.3 *************** *** 2,7 **** SRC = sirf_id2_1.c sirf_id2_2.c sirf_id28_1.c sirf_id28_2.c sirf_id28_3.c ! test: sirftest ! gcc -o sirftest sirftest.c $(SRC) --- 2,10 ---- SRC = sirf_id2_1.c sirf_id2_2.c sirf_id28_1.c sirf_id28_2.c sirf_id28_3.c ! ! # uint32_t -> int format produces annoying warning messages, ! # disable it for now. ! test: ! gcc -Wall -Wno-format -o sirftest sirftest.c $(SRC) Index: sirf_id28_2.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/sirf_id28_2.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sirf_id28_2.c 15 Jul 2005 16:23:37 -0000 1.1 --- sirf_id28_2.c 29 Jul 2005 19:12:26 -0000 1.2 *************** *** 54,58 **** //Format string generated automatically, ! static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i"; --- 54,58 ---- //Format string generated automatically, ! //static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i"; *************** *** 141,144 **** --- 141,146 ---- + // Not yet used. + #if 0 static char insert_stmt[] = "INSERT into SiRF_ID28_2 (" "header_seqno," *************** *** 151,154 **** --- 153,157 ---- "time_in_track) values (0, 0, 0, 0, 0, 0, 0, 0)"; + #endif #if 0 void *************** *** 264,289 **** /** Print the bytes of the packet. */ ! void SiRF_ID28_2_print_raw (XbowSensorboardPacket *packet) { ! ! SiRF_ID28_2 * userdata = (SiRF_ID28_2*)packet->data; ! } ! ! /** Print typed output. */ ! void SiRF_ID28_2_print_cooked (XbowSensorboardPacket *packet) { - SiRF_ID28_2 * userdata = (SiRF_ID28_2*)packet->data; } ! /** Print cooked with tabs. */ ! void SiRF_ID28_2_print_tabbed (XbowSensorboardPacket *packet) { ! SiRF_ID28_2 * userdata = (SiRF_ID28_2*)packet->data; } /** The default size of this message type in bytes. */ ! static int DEFAULT_MESSAGE_SIZE = 26; /** The Active Message type associated with this message. */ ! static int AM_TYPE = 153; /** If incomplete types are used, we need to provide a way --- 267,295 ---- /** Print the bytes of the packet. */ ! void ! SiRF_ID28_2_print_raw (XbowSensorboardPacket *packet) { } ! /** Print cooked output. */ ! void ! SiRF_ID28_2_print_cooked (void * userdata) { ! SiRF_ID28_2 * data = (SiRF_ID28_2*)userdata; ! printf("header_seqno: %i,\n",data->header_seqno); ! printf("header_am_type: %i,\n",data->header_am_type); ! printf("header_rsrvd1: %i,\n",data->header_rsrvd1); ! printf("header_rsrvd2: %i,\n",data->header_rsrvd2); ! printf("pseudo_range: %i,\n",data->pseudo_range); ! printf("carrier_freq: %i,\n",data->carrier_freq); ! printf("carrier_phase: %i,\n",data->carrier_phase); ! printf("time_in_track: %i,\n",data->time_in_track); } /** The default size of this message type in bytes. */ ! //static int DEFAULT_MESSAGE_SIZE = 26; /** The Active Message type associated with this message. */ ! //static int AM_TYPE = 153; /** If incomplete types are used, we need to provide a way |