[Firebug-cvs] fireboard/beta/tools/gps/SiRF sirftest_util.c,NONE,1.1 sirftest_util.h,NONE,1.1 Makefi
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2005-08-19 00:24:47
|
Update of /cvsroot/firebug/fireboard/beta/tools/gps/SiRF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14310/tools/gps/SiRF Modified Files: Makefile sirf_id2.c sirf_id28.c sirf_id28_1.c sirf_id28_2.c sirf_id28_3.c sirf_id2_1.c sirf_id2_2.c sirftest.c Added Files: sirftest_util.c sirftest_util.h Log Message: sirf id 28 messages can now be handled. Index: sirftest.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/sirftest.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sirftest.c 17 Aug 2005 01:56:47 -0000 1.6 --- sirftest.c 17 Aug 2005 21:46:00 -0000 1.7 *************** *** 559,563 **** //print_message_sizes(); print_struct_sizes(); ! //test_sirf_id2_parsing(); --- 559,563 ---- //print_message_sizes(); print_struct_sizes(); ! *************** *** 573,584 **** sid2 = (SiRF_ID2_t*)calloc(1,sizeof(SiRF_ID2_t)); sid2->xpos = convert_4_bytes_to_int(&msg[1]); sid2->ypos = convert_4_bytes_to_int(&msg[5]); sid2->zpos = convert_4_bytes_to_int(&msg[9]); ! sid2->xvel = convert_2_bytes_to_float(&msg[13]); ! sid2->yvel = convert_2_bytes_to_float(&msg[15])/8.0; ! sid2->zvel = convert_2_bytes_to_float(&msg[17])/8.0; sid2->mode1 = msg[19]; ! sid2->dop = (float)msg[20]/5.0; sid2->mode2 = msg[21]; sid2->gps_week = convert_2_bytes_to_uint16(&msg[22]); --- 573,586 ---- sid2 = (SiRF_ID2_t*)calloc(1,sizeof(SiRF_ID2_t)); + printf("zpos: %i\n",convert_4_bytes_to_int(&msg[9])); + sid2->xpos = convert_4_bytes_to_int(&msg[1]); sid2->ypos = convert_4_bytes_to_int(&msg[5]); sid2->zpos = convert_4_bytes_to_int(&msg[9]); ! sid2->xvel = convert_2_bytes_to_uint16(&msg[13]); ! sid2->yvel = convert_2_bytes_to_uint16(&msg[15]); ! sid2->zvel = convert_2_bytes_to_uint16(&msg[17]); sid2->mode1 = msg[19]; ! sid2->dop = msg[20]; sid2->mode2 = msg[21]; sid2->gps_week = convert_2_bytes_to_uint16(&msg[22]); *************** *** 660,665 **** uint8_t mid = get_message_id(sirfmsg); - printf("sirf id: %d\n",sirfmsg[2]); - switch (mid) { case 2: --- 662,665 ---- *************** *** 681,690 **** pack_struct(msg_packer_t * mp, uint8_t * raw_msg) { ! printf("Block Number:%d\n",mp->blocknumber); ! printf("msg[0]: %d\n",raw_msg[0]); ! ! strncpy(&mp->msg[mp->blocknumber*FRAGMENT_PAYLOAD_LENGTH],raw_msg,FRAGMENT_PAYLOAD_LENGTH); ! printf("ID: %d\n",mp->msg[0]); } --- 681,691 ---- pack_struct(msg_packer_t * mp, uint8_t * raw_msg) { ! int offset; ! offset = mp->blocknumber*FRAGMENT_PAYLOAD_LENGTH; ! //printf("offset: %d\n",offset); ! //printf("zpos: %i\n",convert_4_bytes_to_int(&raw_msg[9])); ! memcpy(&mp->msg[offset],raw_msg,FRAGMENT_PAYLOAD_LENGTH); ! //printf("zpos: %i\n",convert_4_bytes_to_int(&mp->msg[9])); } *************** *** 713,720 **** msg_packer_t * mp; ! printf("mf->blockcount: %d\n", mf->h.blockCount); ! printf("mf->mote_id: %d\n", mf->h.mote_id); ! printf("mf->seqno: %d\n", mf->h.sequenceNumber); printf("mf->blocknumber: %d\n", mf->h.blockNumber); mp = mp_array[mote_id]; --- 714,723 ---- msg_packer_t * mp; ! ! //printf("mf->blockcount: %d\n", mf->h.blockCount); ! //printf("mf->mote_id: %d\n", mf->h.mote_id); ! //printf("mf->seqno: %d\n", mf->h.sequenceNumber); printf("mf->blocknumber: %d\n", mf->h.blockNumber); + mp = mp_array[mote_id]; *************** *** 739,747 **** } ! printf("IDID: %d\n",mp->msg[0]); mp->blocks_received_flags |= 1 << blocknumber; ! printf("Blocks received: %d\n",mp->blocks_received_flags); if ((number_of_blocks == 1 && mp->blocks_received_flags == 1) || --- 742,750 ---- } ! //printf("IDID: %d\n",mp->msg[0]); mp->blocks_received_flags |= 1 << blocknumber; ! //printf("Blocks received: %d\n",mp->blocks_received_flags); if ((number_of_blocks == 1 && mp->blocks_received_flags == 1) || *************** *** 750,754 **** (number_of_blocks == 4 && mp->blocks_received_flags == 15)) { parse_msg(mp->msg); ! memset(mp, 0x0, sizeof(msg_packer_t)); } --- 753,757 ---- (number_of_blocks == 4 && mp->blocks_received_flags == 15)) { parse_msg(mp->msg); ! //memset(mp, 0x0, sizeof(msg_packer_t)); } *************** *** 784,792 **** //printf("%d\n",sirf_id2[0]); ! memcpy(mf1->data,(uint8_t*)sirf_id2,FRAGMENT_PAYLOAD_LENGTH); ! memcpy(&mf2->data[FRAGMENT_PAYLOAD_LENGTH],sirf_id2,FRAGMENT_PAYLOAD_LENGTH); - unpack_message((void*)mf1); unpack_message((void*)mf2); } --- 787,802 ---- //printf("%d\n",sirf_id2[0]); ! printf("zvel: %d:\n",convert_2_bytes_to_uint16(&sirf_id2[17])); ! ! ! memcpy(mf1->data,sirf_id2,FRAGMENT_PAYLOAD_LENGTH); ! memcpy(mf2->data,sirf_id2+FRAGMENT_PAYLOAD_LENGTH,FRAGMENT_PAYLOAD_LENGTH); ! ! ! printf("yvel: %d:\n",convert_2_bytes_to_uint16(&mf1->data[15])); ! unpack_message((void*)mf2); + unpack_message((void*)mf1); } *************** *** 805,810 **** //printf("Foo: %f\n", foo); - test_packer(); return 0; } --- 815,822 ---- //printf("Foo: %f\n", foo); + test_sirf_id2_parsing(); + test_packer(); + print_sirf2_message(); return 0; } Index: sirf_id28.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/sirf_id28.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sirf_id28.c 11 Jul 2005 22:33:01 -0000 1.1 --- sirf_id28.c 17 Aug 2005 21:46:00 -0000 1.2 *************** *** 1,3 **** ! #include "sirf.h" --- 1,805 ---- + /** + * This class is automatically generated by mig. DO NOT EDIT THIS FILE. + * This code implements C interface to the 'SiRF_ID28P' + * message type. + */ + #include <stdio.h> + #include <stdlib.h> + #include <memory.h> ! ! ! ! /** Private header is programmer specified for handling ! * conversion functions, etc. ! */ ! //#include "SiRF_ID28P_private.h" ! /** Not the best way to handle xbow dependencies. */ ! #ifdef TELOS_MOTE ! #include "../xdb.h" ! #include "../xsensors.h" ! #endif ! ! ! ! ! /** These need to be moved to a header file. */ ! typedef struct _SiRF_ID28P SiRF_ID28P; ! #ifndef TELOS_MOTE ! typedef struct _XbowSensorboardPacket XbowSensorboardPacket; ! #endif ! /** The Active Message type associated with this message. */ ! //static const int AM_TYPE = 156; ! ! //#define AM_TYPE 156 ! ! ! ! // This struct is defined to keep gcc happy while the module ! // is under development. At some point in the near future, a ! // a convention for passing arguments into the functions will ! // have to be defined. ! struct _XbowSensorboardPacket { ! unsigned char data[29]; ! }; ! ! ! ! ! ! ! ! ! struct _SiRF_ID28P { ! uint8_t header_mote_id; ! uint8_t header_seqno; ! uint8_t header_am_type; ! uint8_t header_blockcount; ! uint8_t channel; ! uint32_t time_tag; ! uint8_t sat_id; ! uint64_t gps_sw_time; ! uint64_t pseudo_range; ! uint32_t carrier_freq; ! uint64_t carrier_phase; ! uint16_t time_in_track; ! uint8_t sync_flags; ! uint8_t cno1; ! uint8_t cno2; ! uint8_t cno3; ! uint8_t cno4; ! uint8_t cno5; ! uint8_t cno6; ! uint8_t cno7; ! uint8_t cno8; ! uint8_t cno9; ! uint8_t cno10; ! uint16_t delta_range_interval; ! uint16_t mean_delta_range_time; ! uint16_t extrapolation_time; ! uint8_t phase_error_count; ! uint8_t low_power_count; ! }; ! ! ! ! void ! SiRF_ID28P_set_header_mote_id(SiRF_ID28P * userdata, uint8_t header_mote_id) { ! userdata->header_mote_id = header_mote_id; ! } ! ! uint8_t ! SiRF_ID28P_get_header_mote_id(SiRF_ID28P * userdata) { ! return userdata->header_mote_id; ! } ! ! void ! SiRF_ID28P_set_header_seqno(SiRF_ID28P * userdata, uint8_t header_seqno) { ! userdata->header_seqno = header_seqno; ! } ! ! uint8_t ! SiRF_ID28P_get_header_seqno(SiRF_ID28P * userdata) { ! return userdata->header_seqno; ! } ! ! void ! SiRF_ID28P_set_header_am_type(SiRF_ID28P * userdata, uint8_t header_am_type) { ! userdata->header_am_type = header_am_type; ! } ! ! uint8_t ! SiRF_ID28P_get_header_am_type(SiRF_ID28P * userdata) { ! return userdata->header_am_type; ! } ! ! void ! SiRF_ID28P_set_header_blockcount(SiRF_ID28P * userdata, uint8_t header_blockcount) { ! userdata->header_blockcount = header_blockcount; ! } ! ! uint8_t ! SiRF_ID28P_get_header_blockcount(SiRF_ID28P * userdata) { ! return userdata->header_blockcount; ! } ! ! void ! SiRF_ID28P_set_channel(SiRF_ID28P * userdata, uint8_t channel) { ! userdata->channel = channel; ! } ! ! uint8_t ! SiRF_ID28P_get_channel(SiRF_ID28P * userdata) { ! return userdata->channel; ! } ! ! void ! SiRF_ID28P_set_time_tag(SiRF_ID28P * userdata, uint32_t time_tag) { ! userdata->time_tag = time_tag; ! } ! ! uint32_t ! SiRF_ID28P_get_time_tag(SiRF_ID28P * userdata) { ! return userdata->time_tag; ! } ! ! void ! SiRF_ID28P_set_sat_id(SiRF_ID28P * userdata, uint8_t sat_id) { ! userdata->sat_id = sat_id; ! } ! ! uint8_t ! SiRF_ID28P_get_sat_id(SiRF_ID28P * userdata) { ! return userdata->sat_id; ! } ! ! void ! SiRF_ID28P_set_gps_sw_time(SiRF_ID28P * userdata, uint64_t gps_sw_time) { ! userdata->gps_sw_time = gps_sw_time; ! } ! ! uint64_t ! SiRF_ID28P_get_gps_sw_time(SiRF_ID28P * userdata) { ! return userdata->gps_sw_time; ! } ! ! void ! SiRF_ID28P_set_pseudo_range(SiRF_ID28P * userdata, uint64_t pseudo_range) { ! userdata->pseudo_range = pseudo_range; ! } ! ! uint64_t ! SiRF_ID28P_get_pseudo_range(SiRF_ID28P * userdata) { ! return userdata->pseudo_range; ! } ! ! void ! SiRF_ID28P_set_carrier_freq(SiRF_ID28P * userdata, uint32_t carrier_freq) { ! userdata->carrier_freq = carrier_freq; ! } ! ! uint32_t ! SiRF_ID28P_get_carrier_freq(SiRF_ID28P * userdata) { ! return userdata->carrier_freq; ! } ! ! void ! SiRF_ID28P_set_carrier_phase(SiRF_ID28P * userdata, uint64_t carrier_phase) { ! userdata->carrier_phase = carrier_phase; ! } ! ! uint64_t ! SiRF_ID28P_get_carrier_phase(SiRF_ID28P * userdata) { ! return userdata->carrier_phase; ! } ! ! void ! SiRF_ID28P_set_time_in_track(SiRF_ID28P * userdata, uint16_t time_in_track) { ! userdata->time_in_track = time_in_track; ! } ! ! uint16_t ! SiRF_ID28P_get_time_in_track(SiRF_ID28P * userdata) { ! return userdata->time_in_track; ! } ! ! void ! SiRF_ID28P_set_sync_flags(SiRF_ID28P * userdata, uint8_t sync_flags) { ! userdata->sync_flags = sync_flags; ! } ! ! uint8_t ! SiRF_ID28P_get_sync_flags(SiRF_ID28P * userdata) { ! return userdata->sync_flags; ! } ! ! void ! SiRF_ID28P_set_cno1(SiRF_ID28P * userdata, uint8_t cno1) { ! userdata->cno1 = cno1; ! } ! ! uint8_t ! SiRF_ID28P_get_cno1(SiRF_ID28P * userdata) { ! return userdata->cno1; ! } ! ! void ! SiRF_ID28P_set_cno2(SiRF_ID28P * userdata, uint8_t cno2) { ! userdata->cno2 = cno2; ! } ! ! uint8_t ! SiRF_ID28P_get_cno2(SiRF_ID28P * userdata) { ! return userdata->cno2; ! } ! ! void ! SiRF_ID28P_set_cno3(SiRF_ID28P * userdata, uint8_t cno3) { ! userdata->cno3 = cno3; ! } ! ! uint8_t ! SiRF_ID28P_get_cno3(SiRF_ID28P * userdata) { ! return userdata->cno3; ! } ! ! void ! SiRF_ID28P_set_cno4(SiRF_ID28P * userdata, uint8_t cno4) { ! userdata->cno4 = cno4; ! } ! ! uint8_t ! SiRF_ID28P_get_cno4(SiRF_ID28P * userdata) { ! return userdata->cno4; ! } ! ! void ! SiRF_ID28P_set_cno5(SiRF_ID28P * userdata, uint8_t cno5) { ! userdata->cno5 = cno5; ! } ! ! uint8_t ! SiRF_ID28P_get_cno5(SiRF_ID28P * userdata) { ! return userdata->cno5; ! } ! ! void ! SiRF_ID28P_set_cno6(SiRF_ID28P * userdata, uint8_t cno6) { ! userdata->cno6 = cno6; ! } ! ! uint8_t ! SiRF_ID28P_get_cno6(SiRF_ID28P * userdata) { ! return userdata->cno6; ! } ! ! void ! SiRF_ID28P_set_cno7(SiRF_ID28P * userdata, uint8_t cno7) { ! userdata->cno7 = cno7; ! } ! ! uint8_t ! SiRF_ID28P_get_cno7(SiRF_ID28P * userdata) { ! return userdata->cno7; ! } ! ! void ! SiRF_ID28P_set_cno8(SiRF_ID28P * userdata, uint8_t cno8) { ! userdata->cno8 = cno8; ! } ! ! uint8_t ! SiRF_ID28P_get_cno8(SiRF_ID28P * userdata) { ! return userdata->cno8; ! } ! ! void ! SiRF_ID28P_set_cno9(SiRF_ID28P * userdata, uint8_t cno9) { ! userdata->cno9 = cno9; ! } ! ! uint8_t ! SiRF_ID28P_get_cno9(SiRF_ID28P * userdata) { ! return userdata->cno9; ! } ! ! void ! SiRF_ID28P_set_cno10(SiRF_ID28P * userdata, uint8_t cno10) { ! userdata->cno10 = cno10; ! } ! ! uint8_t ! SiRF_ID28P_get_cno10(SiRF_ID28P * userdata) { ! return userdata->cno10; ! } ! ! void ! SiRF_ID28P_set_delta_range_interval(SiRF_ID28P * userdata, uint16_t delta_range_interval) { ! userdata->delta_range_interval = delta_range_interval; ! } ! ! uint16_t ! SiRF_ID28P_get_delta_range_interval(SiRF_ID28P * userdata) { ! return userdata->delta_range_interval; ! } ! ! void ! SiRF_ID28P_set_mean_delta_range_time(SiRF_ID28P * userdata, uint16_t mean_delta_range_time) { ! userdata->mean_delta_range_time = mean_delta_range_time; ! } ! ! uint16_t ! SiRF_ID28P_get_mean_delta_range_time(SiRF_ID28P * userdata) { ! return userdata->mean_delta_range_time; ! } ! ! void ! SiRF_ID28P_set_extrapolation_time(SiRF_ID28P * userdata, uint16_t extrapolation_time) { ! userdata->extrapolation_time = extrapolation_time; ! } ! ! uint16_t ! SiRF_ID28P_get_extrapolation_time(SiRF_ID28P * userdata) { ! return userdata->extrapolation_time; ! } ! ! void ! SiRF_ID28P_set_phase_error_count(SiRF_ID28P * userdata, uint8_t phase_error_count) { ! userdata->phase_error_count = phase_error_count; ! } ! ! uint8_t ! SiRF_ID28P_get_phase_error_count(SiRF_ID28P * userdata) { ! return userdata->phase_error_count; ! } ! ! void ! SiRF_ID28P_set_low_power_count(SiRF_ID28P * userdata, uint8_t low_power_count) { ! userdata->low_power_count = low_power_count; ! } ! ! uint8_t ! SiRF_ID28P_get_low_power_count(SiRF_ID28P * userdata) { ! return userdata->low_power_count; ! } ! ! ! ! ! ! //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, %i, %i, %i, %i, %i, %i, %i, %i"; ! ! ! //static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i"; ! ! ! static char insert_stmt[] = "INSERT into SiRF_ID28P (" ! "result_time," ! "header_mote_id," ! "header_seqno," ! "header_am_type," ! "header_blockcount," ! "channel," ! "time_tag," ! "sat_id," ! "gps_sw_time," ! "pseudo_range," ! "carrier_freq," ! "carrier_phase," ! "time_in_track," ! "sync_flags," ! "cno1," ! "cno2," ! "cno3," ! "cno4," ! "cno5," ! "cno6," ! "cno7," ! "cno8," ! "cno9," ! "cno10," ! "delta_range_interval," ! "mean_delta_range_time," ! "extrapolation_time," ! "phase_error_count," ! "low_power_count) values (now(), %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"; ! ! ! void ! SiRF_ID28P_pg_log(XbowSensorboardPacket * userdata) { ! char pg_command[255]; ! SiRF_ID28P * data = (SiRF_ID28P*)userdata; ! sprintf(pg_command,insert_stmt, ! data->header_mote_id, ! data->header_seqno, ! data->header_am_type, ! data->header_blockcount, ! data->channel, ! data->time_tag, ! data->sat_id, ! data->gps_sw_time, ! data->pseudo_range, ! data->carrier_freq, ! data->carrier_phase, ! data->time_in_track, ! data->sync_flags, ! data->cno1, ! data->cno2, ! data->cno3, ! data->cno4, ! data->cno5, ! data->cno6, ! data->cno7, ! data->cno8, ! data->cno9, ! data->cno10, ! data->delta_range_interval, ! data->mean_delta_range_time, ! data->extrapolation_time, ! data->phase_error_count, ! data->low_power_count); ! #ifdef TELOS_MOTE ! xdb_execute(pg_command); ! #endif ! } ! ! ! ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! header_mote_id_convert(uint8_t header_mote_id) { ! return header_mote_id; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! header_seqno_convert(uint8_t header_seqno) { ! return header_seqno; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! header_am_type_convert(uint8_t header_am_type) { ! return header_am_type; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! header_blockcount_convert(uint8_t header_blockcount) { ! return header_blockcount; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! channel_convert(uint8_t channel) { ! return channel; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint32_t ! time_tag_convert(uint32_t time_tag) { ! return time_tag; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! sat_id_convert(uint8_t sat_id) { ! return sat_id; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint64_t ! gps_sw_time_convert(uint64_t gps_sw_time) { ! return gps_sw_time; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint64_t ! pseudo_range_convert(uint64_t pseudo_range) { ! return pseudo_range; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint32_t ! carrier_freq_convert(uint32_t carrier_freq) { ! return carrier_freq; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint64_t ! carrier_phase_convert(uint64_t carrier_phase) { ! return carrier_phase; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint16_t ! time_in_track_convert(uint16_t time_in_track) { ! return time_in_track; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! sync_flags_convert(uint8_t sync_flags) { ! return sync_flags; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno1_convert(uint8_t cno1) { ! return cno1; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno2_convert(uint8_t cno2) { ! return cno2; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno3_convert(uint8_t cno3) { ! return cno3; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno4_convert(uint8_t cno4) { ! return cno4; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno5_convert(uint8_t cno5) { ! return cno5; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno6_convert(uint8_t cno6) { ! return cno6; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno7_convert(uint8_t cno7) { ! return cno7; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno8_convert(uint8_t cno8) { ! return cno8; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno9_convert(uint8_t cno9) { ! return cno9; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! cno10_convert(uint8_t cno10) { ! return cno10; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint16_t ! delta_range_interval_convert(uint16_t delta_range_interval) { ! return delta_range_interval; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint16_t ! mean_delta_range_time_convert(uint16_t mean_delta_range_time) { ! return mean_delta_range_time; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint16_t ! extrapolation_time_convert(uint16_t extrapolation_time) { ! return extrapolation_time; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! phase_error_count_convert(uint8_t phase_error_count) { ! return phase_error_count; ! } ! ! /** @brief Default behavior is to return the input as output. ! * User is responsible for "cooking" the data. ! */ ! static uint8_t ! low_power_count_convert(uint8_t low_power_count) { ! return low_power_count; ! } ! ! void ! SiRF_ID28P_cook_packet(SiRF_ID28P * userdata) { ! userdata->header_mote_id = header_mote_id_convert(userdata->header_mote_id); ! userdata->header_seqno = header_seqno_convert(userdata->header_seqno); ! userdata->header_am_type = header_am_type_convert(userdata->header_am_type); ! userdata->header_blockcount = header_blockcount_convert(userdata->header_blockcount); ! userdata->channel = channel_convert(userdata->channel); ! userdata->time_tag = time_tag_convert(userdata->time_tag); ! userdata->sat_id = sat_id_convert(userdata->sat_id); ! userdata->gps_sw_time = gps_sw_time_convert(userdata->gps_sw_time); ! userdata->pseudo_range = pseudo_range_convert(userdata->pseudo_range); ! userdata->carrier_freq = carrier_freq_convert(userdata->carrier_freq); ! userdata->carrier_phase = carrier_phase_convert(userdata->carrier_phase); ! userdata->time_in_track = time_in_track_convert(userdata->time_in_track); ! userdata->sync_flags = sync_flags_convert(userdata->sync_flags); ! userdata->cno1 = cno1_convert(userdata->cno1); ! userdata->cno2 = cno2_convert(userdata->cno2); ! userdata->cno3 = cno3_convert(userdata->cno3); ! userdata->cno4 = cno4_convert(userdata->cno4); ! userdata->cno5 = cno5_convert(userdata->cno5); ! userdata->cno6 = cno6_convert(userdata->cno6); ! userdata->cno7 = cno7_convert(userdata->cno7); ! userdata->cno8 = cno8_convert(userdata->cno8); ! userdata->cno9 = cno9_convert(userdata->cno9); ! userdata->cno10 = cno10_convert(userdata->cno10); ! userdata->delta_range_interval = delta_range_interval_convert(userdata->delta_range_interval); ! userdata->mean_delta_range_time = mean_delta_range_time_convert(userdata->mean_delta_range_time); ! userdata->extrapolation_time = extrapolation_time_convert(userdata->extrapolation_time); ! userdata->phase_error_count = phase_error_count_convert(userdata->phase_error_count); ! userdata->low_power_count = low_power_count_convert(userdata->low_power_count); ! } ! ! ! ! ! ! /** User has to fill in any conversion code ! * necessary for processing. ! */ ! SiRF_ID28P * ! SiRF_ID28P_convert(char * data) { ! // Just to keep gcc happy. ! return (SiRF_ID28P*)data; ! } ! ! ! ! ! /** Print the bytes of the packet. */ ! void ! SiRF_ID28P_print_raw (XbowSensorboardPacket *packet) { ! ! printf("SiRF_ID28P print raw.\n"); ! } ! ! /** Print cooked output. */ ! void ! SiRF_ID28P_print_cooked (XbowSensorboardPacket * userdata) { ! ! SiRF_ID28P * data = (SiRF_ID28P*)userdata; ! printf("SiRF_ID28P print cooked:\n"); ! printf(" header_mote_id: %i,\n",data->header_mote_id); ! printf(" header_seqno: %i,\n",data->header_seqno); ! printf(" header_am_type: %i,\n",data->header_am_type); ! printf(" header_blockcount: %i,\n",data->header_blockcount); ! 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); ! 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); ! 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); ! } ! ! #ifdef TELOS_MOTE ! XPacketHandler SiRF_ID28P_packet_handler = { ! // This should be replaced with the AM_TYPE ! 156, ! "$Id$", ! SiRF_ID28P_print_raw, ! SiRF_ID28P_print_cooked, ! SiRF_ID28P_print_raw, ! SiRF_ID28P_print_cooked, ! SiRF_ID28P_pg_log, ! {0} ! }; ! ! ! void ! SiRF_ID28P_initialize() { ! xpacket_add_type(&SiRF_ID28P_packet_handler); ! } ! #endif ! /** The default size of this message type in bytes. */ ! //static int DEFAULT_MESSAGE_SIZE = 59; ! ! /** If incomplete types are used, we need to provide a way ! * to manage memory. ! */ ! SiRF_ID28P * ! SiRF_ID28P_new() { ! SiRF_ID28P * userdata = (SiRF_ID28P*)malloc(sizeof(SiRF_ID28P)); ! memset((void*)userdata,0xda,sizeof(SiRF_ID28P)); ! return userdata; ! } ! ! ! ! ! void ! SiRF_ID28P_delete(SiRF_ID28P * userdata) { ! memset((void*)userdata,0xdd,sizeof(SiRF_ID28P)); ! free(userdata); ! } Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/gps/SiRF/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 17 Aug 2005 01:56:47 -0000 1.5 --- Makefile 17 Aug 2005 21:46:00 -0000 1.6 *************** *** 1,8 **** SRC = sirf_id2_1.c sirf_id2_2.c sirf_id28_1.c sirf_id28_2.c sirf_id28_3.c ! SRC += sirf_id2.c INCLUDES = ../../../tos/lib/SiRF # uint32_t -> int format produces annoying warning messages, # disable it for now. --- 1,11 ---- SRC = sirf_id2_1.c sirf_id2_2.c sirf_id28_1.c sirf_id28_2.c sirf_id28_3.c ! SRC += sirf_id2.c sirf_id28.c ! SRC += sirftest_util.c INCLUDES = ../../../tos/lib/SiRF + all: test sirftest2 sirftest28 + # uint32_t -> int format produces annoying warning messages, # disable it for now. *************** *** 10,13 **** --- 13,22 ---- gcc -Wall -Wno-format -o sirftest -I$(INCLUDES) sirftest.c $(SRC) + sirftest2: + gcc -Wall -Wno-format -o sirftest2 -I$(INCLUDES) sirftest2.c $(SRC) + + sirftest28: + gcc -Wall -Wno-format -o sirftest28 -I$(INCLUDES) sirftest28.c $(SRC) -lm + clean: --- NEW FILE: sirftest_util.c --- #include <stdio.h> #include <string.h> #include <stdlib.h> // TODO: Make a macro for this. 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; } /* static int convert_4_bytes_to_uint32(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. 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. 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. 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. 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; } --- NEW FILE: sirftest_util.h --- int convert_4_bytes_to_int (char * bytes); /* int convert_4_bytes_to_uint32 (char * bytes); */ // TODO: Make a macro for this. float convert_2_bytes_to_float (char * bytes); // TODO: Make a macro for this. float convert_4_bytes_to_float (char * bytes); // FIXME: Get rid of locally defined variable // so that this can be turned into a macro. double convert_8_bytes_to_double (char * bytes); // TODO: Make a macro for this. uint16_t convert_2_bytes_to_uint16 (char * bytes); |