[Firebug-cvs] fireboard/tools/src/xlisten/ucb Makefile, NONE, 1.1 linkmsg.c, NONE, 1.1 sirf_id2.c,
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2006-07-10 17:17:21
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/ucb In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv19795 Added Files: Makefile linkmsg.c 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 sirf_id7.c ucb.c ucbtest.c Log Message: updating from beta. --- NEW FILE: ucb.c --- /** Code in this file represents "plugins" * to the xlisten code produced by xbow. */ #include <stdio.h> #include "../xsensors.h" #include "ucb.h" #define AM_SURGEMSG 17 #define AM_LINKESTIMATORMSG 20 #define AM_PINGMSG 21 static PacketHandler * dispatch_table[256]; void ucb_initialize() { /** TODO: Change this code such that the * each message handling module is queried for * the appropriate handler, which is added to the * xpacket type here. This redudes the dependency * on xbow code in the modules. * Example: * handler = sirfid2_get_handlers(); * xpacket_add_type(handler); */ //fireboard_initialize(); //LinkMsgP_initialize(); //SurgeMsgP_initialize(); //LinkEstimatorMsgP_initialize(); } PacketHandler * fb_get_packet_handler(uint8_t am_type) { return dispatch_table[am_type]; } --- NEW FILE: linkmsg.c --- /** * This class is automatically generated by mig. DO NOT EDIT THIS FILE. * This code implements C interface to the 'LinkMsgP' * message type. */ #include <stdio.h> #include <stdlib.h> #include <memory.h> /** Private header is programmer specified for handling * conversion functions, etc. */ //#include "LinkMsgP_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 _LinkMsgP LinkMsgP; #ifndef TELOS_MOTE typedef struct _XbowSensorboardPacket XbowSensorboardPacket; #endif /** The Active Message type associated with this message. */ //static const int AM_TYPE = 200; //#define AM_TYPE 200 // 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 _LinkMsgP { uint16_t header_am_type; uint16_t header_seqno; uint32_t tstamp; uint16_t moteid; uint16_t RSSI; uint16_t LQI; }; void LinkMsgP_set_header_am_type(LinkMsgP * userdata, uint16_t header_am_type) { userdata->header_am_type = header_am_type; } uint16_t LinkMsgP_get_header_am_type(LinkMsgP * userdata) { return userdata->header_am_type; } void LinkMsgP_set_header_seqno(LinkMsgP * userdata, uint16_t header_seqno) { userdata->header_seqno = header_seqno; } uint16_t LinkMsgP_get_header_seqno(LinkMsgP * userdata) { return userdata->header_seqno; } void LinkMsgP_set_tstamp(LinkMsgP * userdata, uint32_t tstamp) { userdata->tstamp = tstamp; } uint32_t LinkMsgP_get_tstamp(LinkMsgP * userdata) { return userdata->tstamp; } void LinkMsgP_set_moteid(LinkMsgP * userdata, uint16_t moteid) { userdata->moteid = moteid; } uint16_t LinkMsgP_get_moteid(LinkMsgP * userdata) { return userdata->moteid; } void LinkMsgP_set_RSSI(LinkMsgP * userdata, uint16_t RSSI) { userdata->RSSI = RSSI; } uint16_t LinkMsgP_get_RSSI(LinkMsgP * userdata) { return userdata->RSSI; } void LinkMsgP_set_LQI(LinkMsgP * userdata, uint16_t LQI) { userdata->LQI = LQI; } uint16_t LinkMsgP_get_LQI(LinkMsgP * userdata) { return userdata->LQI; } //Format string generated automatically, //static char formatstring[] = "%i, %i, %i, %i, %i, %i"; //static char formatstring[] = "%i, %i, %i, %i, %i, %i"; static char insert_stmt[] = "INSERT into LinkMsgP (" "result_time," "header_am_type," "header_seqno," "tstamp," "moteid," "RSSI," "LQI) values (now(), %i, %i, %i, %i, %i, %i)"; void LinkMsgP_pg_log(XbowSensorboardPacket * userdata) { char pg_command[255]; LinkMsgP * data = (LinkMsgP*)userdata; sprintf(pg_command,insert_stmt, data->header_am_type, data->header_seqno, data->tstamp, data->moteid, data->RSSI, data->LQI); #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 uint16_t header_am_type_convert(uint16_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 uint16_t header_seqno_convert(uint16_t header_seqno) { return header_seqno; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint32_t tstamp_convert(uint32_t tstamp) { return tstamp; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint16_t moteid_convert(uint16_t moteid) { return moteid; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint16_t RSSI_convert(uint16_t RSSI) { return RSSI; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint16_t LQI_convert(uint16_t LQI) { return LQI; } void LinkMsgP_cook_packet(LinkMsgP * userdata) { userdata->header_am_type = header_am_type_convert(userdata->header_am_type); userdata->header_seqno = header_seqno_convert(userdata->header_seqno); userdata->tstamp = tstamp_convert(userdata->tstamp); userdata->moteid = moteid_convert(userdata->moteid); userdata->RSSI = RSSI_convert(userdata->RSSI); userdata->LQI = LQI_convert(userdata->LQI); } /** User has to fill in any conversion code * necessary for processing. */ LinkMsgP * LinkMsgP_convert(char * data) { // Just to keep gcc happy. return (LinkMsgP*)data; } /** Print the bytes of the packet. */ void LinkMsgP_print_raw (XbowSensorboardPacket *packet) { printf("LinkMsgP print raw.\n"); } /** Print cooked output. */ void LinkMsgP_print_cooked (XbowSensorboardPacket * userdata) { LinkMsgP * data = (LinkMsgP*)userdata; printf("LinkMsgP print cooked:\n"); printf(" header_am_type: %i,\n",data->header_am_type); printf(" header_seqno: %i,\n",data->header_seqno); printf(" tstamp: %i,\n",data->tstamp); printf(" moteid: %i,\n",data->moteid); printf(" RSSI: %i,\n",data->RSSI); printf(" LQI: %i,\n",data->LQI); } #ifdef TELOS_MOTE XPacketHandler LinkMsgP_packet_handler = { // This should be replaced with the AM_TYPE 200, "$Id: linkmsg.c,v 1.1 2006/07/10 17:17:16 doolin Exp $", LinkMsgP_print_raw, LinkMsgP_print_cooked, LinkMsgP_print_raw, LinkMsgP_print_cooked, LinkMsgP_pg_log, {0} }; void LinkMsgP_initialize() { xpacket_add_type(&LinkMsgP_packet_handler); } #endif /** The default size of this message type in bytes. */ //static int DEFAULT_MESSAGE_SIZE = 14; /** If incomplete types are used, we need to provide a way * to manage memory. */ LinkMsgP * LinkMsgP_new() { LinkMsgP * userdata = (LinkMsgP*)malloc(sizeof(LinkMsgP)); memset((void*)userdata,0xda,sizeof(LinkMsgP)); return userdata; } void LinkMsgP_delete(LinkMsgP * userdata) { memset((void*)userdata,0xdd,sizeof(LinkMsgP)); free(userdata); } --- NEW FILE: sirf_id2_2.c --- /** * This class is automatically generated by mig. DO NOT EDIT THIS FILE. * This code implements C interface to the 'SiRF_ID2_2P' * message type. */ #include <stdio.h> #include <stdlib.h> #include <memory.h> /** Private header is programmer specified for handling * conversion functions, etc. */ //#include "SiRF_ID2_2P_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_ID2_2P SiRF_ID2_2P; #ifndef TELOS_MOTE typedef struct _XbowSensorboardPacket XbowSensorboardPacket; #endif /** The Active Message type associated with this message. */ //static const int AM_TYPE = 151; //#define AM_TYPE 151 // 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_ID2_2P { uint8_t header_mote_id; uint8_t header_seqno; uint8_t header_am_type; uint8_t header_blockcount; uint32_t gps_tow; uint8_t sv_in_fix; uint8_t ch1; uint8_t ch2; uint8_t ch3; uint8_t ch4; uint8_t ch5; uint8_t ch6; uint8_t ch7; uint8_t ch8; uint8_t ch9; uint8_t ch10; uint8_t ch11; uint8_t ch12; }; void SiRF_ID2_2P_set_header_mote_id(SiRF_ID2_2P * userdata, uint8_t header_mote_id) { userdata->header_mote_id = header_mote_id; } uint8_t SiRF_ID2_2P_get_header_mote_id(SiRF_ID2_2P * userdata) { return userdata->header_mote_id; } void SiRF_ID2_2P_set_header_seqno(SiRF_ID2_2P * userdata, uint8_t header_seqno) { userdata->header_seqno = header_seqno; } uint8_t SiRF_ID2_2P_get_header_seqno(SiRF_ID2_2P * userdata) { return userdata->header_seqno; } void SiRF_ID2_2P_set_header_am_type(SiRF_ID2_2P * userdata, uint8_t header_am_type) { userdata->header_am_type = header_am_type; } uint8_t SiRF_ID2_2P_get_header_am_type(SiRF_ID2_2P * userdata) { return userdata->header_am_type; } void SiRF_ID2_2P_set_header_blockcount(SiRF_ID2_2P * userdata, uint8_t header_blockcount) { userdata->header_blockcount = header_blockcount; } uint8_t SiRF_ID2_2P_get_header_blockcount(SiRF_ID2_2P * userdata) { return userdata->header_blockcount; } void SiRF_ID2_2P_set_gps_tow(SiRF_ID2_2P * userdata, uint32_t gps_tow) { userdata->gps_tow = gps_tow; } uint32_t SiRF_ID2_2P_get_gps_tow(SiRF_ID2_2P * userdata) { return userdata->gps_tow; } void SiRF_ID2_2P_set_sv_in_fix(SiRF_ID2_2P * userdata, uint8_t sv_in_fix) { userdata->sv_in_fix = sv_in_fix; } uint8_t SiRF_ID2_2P_get_sv_in_fix(SiRF_ID2_2P * userdata) { return userdata->sv_in_fix; } void SiRF_ID2_2P_set_ch1(SiRF_ID2_2P * userdata, uint8_t ch1) { userdata->ch1 = ch1; } uint8_t SiRF_ID2_2P_get_ch1(SiRF_ID2_2P * userdata) { return userdata->ch1; } void SiRF_ID2_2P_set_ch2(SiRF_ID2_2P * userdata, uint8_t ch2) { userdata->ch2 = ch2; } uint8_t SiRF_ID2_2P_get_ch2(SiRF_ID2_2P * userdata) { return userdata->ch2; } void SiRF_ID2_2P_set_ch3(SiRF_ID2_2P * userdata, uint8_t ch3) { userdata->ch3 = ch3; } uint8_t SiRF_ID2_2P_get_ch3(SiRF_ID2_2P * userdata) { return userdata->ch3; } void SiRF_ID2_2P_set_ch4(SiRF_ID2_2P * userdata, uint8_t ch4) { userdata->ch4 = ch4; } uint8_t SiRF_ID2_2P_get_ch4(SiRF_ID2_2P * userdata) { return userdata->ch4; } void SiRF_ID2_2P_set_ch5(SiRF_ID2_2P * userdata, uint8_t ch5) { userdata->ch5 = ch5; } uint8_t SiRF_ID2_2P_get_ch5(SiRF_ID2_2P * userdata) { return userdata->ch5; } void SiRF_ID2_2P_set_ch6(SiRF_ID2_2P * userdata, uint8_t ch6) { userdata->ch6 = ch6; } uint8_t SiRF_ID2_2P_get_ch6(SiRF_ID2_2P * userdata) { return userdata->ch6; } void SiRF_ID2_2P_set_ch7(SiRF_ID2_2P * userdata, uint8_t ch7) { userdata->ch7 = ch7; } uint8_t SiRF_ID2_2P_get_ch7(SiRF_ID2_2P * userdata) { return userdata->ch7; } void SiRF_ID2_2P_set_ch8(SiRF_ID2_2P * userdata, uint8_t ch8) { userdata->ch8 = ch8; } uint8_t SiRF_ID2_2P_get_ch8(SiRF_ID2_2P * userdata) { return userdata->ch8; } void SiRF_ID2_2P_set_ch9(SiRF_ID2_2P * userdata, uint8_t ch9) { userdata->ch9 = ch9; } uint8_t SiRF_ID2_2P_get_ch9(SiRF_ID2_2P * userdata) { return userdata->ch9; } void SiRF_ID2_2P_set_ch10(SiRF_ID2_2P * userdata, uint8_t ch10) { userdata->ch10 = ch10; } uint8_t SiRF_ID2_2P_get_ch10(SiRF_ID2_2P * userdata) { return userdata->ch10; } void SiRF_ID2_2P_set_ch11(SiRF_ID2_2P * userdata, uint8_t ch11) { userdata->ch11 = ch11; } uint8_t SiRF_ID2_2P_get_ch11(SiRF_ID2_2P * userdata) { return userdata->ch11; } void SiRF_ID2_2P_set_ch12(SiRF_ID2_2P * userdata, uint8_t ch12) { userdata->ch12 = ch12; } uint8_t SiRF_ID2_2P_get_ch12(SiRF_ID2_2P * userdata) { return userdata->ch12; } //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"; //static char formatstring[] = "%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_ID2_2P (" "result_time," "header_mote_id," "header_seqno," "header_am_type," "header_blockcount," "gps_tow," "sv_in_fix," "ch1," "ch2," "ch3," "ch4," "ch5," "ch6," "ch7," "ch8," "ch9," "ch10," "ch11," "ch12) values (now(), %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"; void SiRF_ID2_2P_pg_log(XbowSensorboardPacket * userdata) { char pg_command[255]; SiRF_ID2_2P * data = (SiRF_ID2_2P*)userdata; sprintf(pg_command,insert_stmt, data->header_mote_id, data->header_seqno, data->header_am_type, data->header_blockcount, data->gps_tow, data->sv_in_fix, data->ch1, data->ch2, data->ch3, data->ch4, data->ch5, data->ch6, data->ch7, data->ch8, data->ch9, data->ch10, data->ch11, data->ch12); #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 uint32_t gps_tow_convert(uint32_t gps_tow) { return gps_tow; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t sv_in_fix_convert(uint8_t sv_in_fix) { return sv_in_fix; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch1_convert(uint8_t ch1) { return ch1; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch2_convert(uint8_t ch2) { return ch2; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch3_convert(uint8_t ch3) { return ch3; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch4_convert(uint8_t ch4) { return ch4; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch5_convert(uint8_t ch5) { return ch5; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch6_convert(uint8_t ch6) { return ch6; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch7_convert(uint8_t ch7) { return ch7; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch8_convert(uint8_t ch8) { return ch8; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch9_convert(uint8_t ch9) { return ch9; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch10_convert(uint8_t ch10) { return ch10; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch11_convert(uint8_t ch11) { return ch11; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch12_convert(uint8_t ch12) { return ch12; } void SiRF_ID2_2P_cook_packet(SiRF_ID2_2P * 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->gps_tow = gps_tow_convert(userdata->gps_tow); userdata->sv_in_fix = sv_in_fix_convert(userdata->sv_in_fix); userdata->ch1 = ch1_convert(userdata->ch1); userdata->ch2 = ch2_convert(userdata->ch2); userdata->ch3 = ch3_convert(userdata->ch3); userdata->ch4 = ch4_convert(userdata->ch4); userdata->ch5 = ch5_convert(userdata->ch5); userdata->ch6 = ch6_convert(userdata->ch6); userdata->ch7 = ch7_convert(userdata->ch7); userdata->ch8 = ch8_convert(userdata->ch8); userdata->ch9 = ch9_convert(userdata->ch9); userdata->ch10 = ch10_convert(userdata->ch10); userdata->ch11 = ch11_convert(userdata->ch11); userdata->ch12 = ch12_convert(userdata->ch12); } /** User has to fill in any conversion code * necessary for processing. */ SiRF_ID2_2P * SiRF_ID2_2P_convert(char * data) { // Just to keep gcc happy. return (SiRF_ID2_2P*)data; } /** Print the bytes of the packet. */ void SiRF_ID2_2P_print_raw (XbowSensorboardPacket *packet) { printf("SiRF_ID2_2P print raw.\n"); } /** Print cooked output. */ void SiRF_ID2_2P_print_cooked (XbowSensorboardPacket * userdata) { SiRF_ID2_2P * data = (SiRF_ID2_2P*)userdata; printf("SiRF_ID2_2P 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(" gps_tow: %i,\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); } #ifdef TELOS_MOTE XPacketHandler SiRF_ID2_2P_packet_handler = { // This should be replaced with the AM_TYPE 151, "$Id: sirf_id2_2.c,v 1.1 2006/07/10 17:17:16 doolin Exp $", SiRF_ID2_2P_print_raw, SiRF_ID2_2P_print_cooked, SiRF_ID2_2P_print_raw, SiRF_ID2_2P_print_cooked, SiRF_ID2_2P_pg_log, {0} }; void SiRF_ID2_2P_initialize() { xpacket_add_type(&SiRF_ID2_2P_packet_handler); } #endif /** The default size of this message type in bytes. */ //static int DEFAULT_MESSAGE_SIZE = 21; /** If incomplete types are used, we need to provide a way * to manage memory. */ SiRF_ID2_2P * SiRF_ID2_2P_new() { SiRF_ID2_2P * userdata = (SiRF_ID2_2P*)malloc(sizeof(SiRF_ID2_2P)); memset((void*)userdata,0xda,sizeof(SiRF_ID2_2P)); return userdata; } void SiRF_ID2_2P_delete(SiRF_ID2_2P * userdata) { memset((void*)userdata,0xdd,sizeof(SiRF_ID2_2P)); free(userdata); } --- NEW FILE: sirf_id2.c --- /** * This class is automatically generated by mig. DO NOT EDIT THIS FILE. * This code implements C interface to the 'SiRF_ID2P' * message type. */ #include <stdio.h> #include <stdlib.h> #include <memory.h> /** Private header is programmer specified for handling * conversion functions, etc. */ //#include "SiRF_ID2P_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_ID2P SiRF_ID2P; #ifndef TELOS_MOTE typedef struct _XbowSensorboardPacket XbowSensorboardPacket; #endif /** The Active Message type associated with this message. */ //static const int AM_TYPE = 155; //#define AM_TYPE 155 // 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_ID2P { uint8_t header_mote_id; uint8_t header_seqno; uint8_t header_am_type; uint8_t header_blockcount; 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; uint32_t gps_tow; uint8_t sv_in_fix; uint8_t ch1; uint8_t ch2; uint8_t ch3; uint8_t ch4; uint8_t ch5; uint8_t ch6; uint8_t ch7; uint8_t ch8; uint8_t ch9; uint8_t ch10; uint8_t ch11; uint8_t ch12; }; void SiRF_ID2P_set_header_mote_id(SiRF_ID2P * userdata, uint8_t header_mote_id) { userdata->header_mote_id = header_mote_id; } uint8_t SiRF_ID2P_get_header_mote_id(SiRF_ID2P * userdata) { return userdata->header_mote_id; } void SiRF_ID2P_set_header_seqno(SiRF_ID2P * userdata, uint8_t header_seqno) { userdata->header_seqno = header_seqno; } uint8_t SiRF_ID2P_get_header_seqno(SiRF_ID2P * userdata) { return userdata->header_seqno; } void SiRF_ID2P_set_header_am_type(SiRF_ID2P * userdata, uint8_t header_am_type) { userdata->header_am_type = header_am_type; } uint8_t SiRF_ID2P_get_header_am_type(SiRF_ID2P * userdata) { return userdata->header_am_type; } void SiRF_ID2P_set_header_blockcount(SiRF_ID2P * userdata, uint8_t header_blockcount) { userdata->header_blockcount = header_blockcount; } uint8_t SiRF_ID2P_get_header_blockcount(SiRF_ID2P * userdata) { return userdata->header_blockcount; } void SiRF_ID2P_set_xpos(SiRF_ID2P * userdata, int xpos) { userdata->xpos = xpos; } int SiRF_ID2P_get_xpos(SiRF_ID2P * userdata) { return userdata->xpos; } void SiRF_ID2P_set_ypos(SiRF_ID2P * userdata, int ypos) { userdata->ypos = ypos; } int SiRF_ID2P_get_ypos(SiRF_ID2P * userdata) { return userdata->ypos; } void SiRF_ID2P_set_zpos(SiRF_ID2P * userdata, int zpos) { userdata->zpos = zpos; } int SiRF_ID2P_get_zpos(SiRF_ID2P * userdata) { return userdata->zpos; } void SiRF_ID2P_set_xvel(SiRF_ID2P * userdata, uint16_t xvel) { userdata->xvel = xvel; } uint16_t SiRF_ID2P_get_xvel(SiRF_ID2P * userdata) { return userdata->xvel; } void SiRF_ID2P_set_yvel(SiRF_ID2P * userdata, uint16_t yvel) { userdata->yvel = yvel; } uint16_t SiRF_ID2P_get_yvel(SiRF_ID2P * userdata) { return userdata->yvel; } void SiRF_ID2P_set_zvel(SiRF_ID2P * userdata, uint16_t zvel) { userdata->zvel = zvel; } uint16_t SiRF_ID2P_get_zvel(SiRF_ID2P * userdata) { return userdata->zvel; } void SiRF_ID2P_set_mode1(SiRF_ID2P * userdata, uint8_t mode1) { userdata->mode1 = mode1; } uint8_t SiRF_ID2P_get_mode1(SiRF_ID2P * userdata) { return userdata->mode1; } void SiRF_ID2P_set_dop(SiRF_ID2P * userdata, uint8_t dop) { userdata->dop = dop; } uint8_t SiRF_ID2P_get_dop(SiRF_ID2P * userdata) { return userdata->dop; } void SiRF_ID2P_set_mode2(SiRF_ID2P * userdata, uint8_t mode2) { userdata->mode2 = mode2; } uint8_t SiRF_ID2P_get_mode2(SiRF_ID2P * userdata) { return userdata->mode2; } void SiRF_ID2P_set_gps_week(SiRF_ID2P * userdata, uint16_t gps_week) { userdata->gps_week = gps_week; } uint16_t SiRF_ID2P_get_gps_week(SiRF_ID2P * userdata) { return userdata->gps_week; } void SiRF_ID2P_set_gps_tow(SiRF_ID2P * userdata, uint32_t gps_tow) { userdata->gps_tow = gps_tow; } uint32_t SiRF_ID2P_get_gps_tow(SiRF_ID2P * userdata) { return userdata->gps_tow; } void SiRF_ID2P_set_sv_in_fix(SiRF_ID2P * userdata, uint8_t sv_in_fix) { userdata->sv_in_fix = sv_in_fix; } uint8_t SiRF_ID2P_get_sv_in_fix(SiRF_ID2P * userdata) { return userdata->sv_in_fix; } void SiRF_ID2P_set_ch1(SiRF_ID2P * userdata, uint8_t ch1) { userdata->ch1 = ch1; } uint8_t SiRF_ID2P_get_ch1(SiRF_ID2P * userdata) { return userdata->ch1; } void SiRF_ID2P_set_ch2(SiRF_ID2P * userdata, uint8_t ch2) { userdata->ch2 = ch2; } uint8_t SiRF_ID2P_get_ch2(SiRF_ID2P * userdata) { return userdata->ch2; } void SiRF_ID2P_set_ch3(SiRF_ID2P * userdata, uint8_t ch3) { userdata->ch3 = ch3; } uint8_t SiRF_ID2P_get_ch3(SiRF_ID2P * userdata) { return userdata->ch3; } void SiRF_ID2P_set_ch4(SiRF_ID2P * userdata, uint8_t ch4) { userdata->ch4 = ch4; } uint8_t SiRF_ID2P_get_ch4(SiRF_ID2P * userdata) { return userdata->ch4; } void SiRF_ID2P_set_ch5(SiRF_ID2P * userdata, uint8_t ch5) { userdata->ch5 = ch5; } uint8_t SiRF_ID2P_get_ch5(SiRF_ID2P * userdata) { return userdata->ch5; } void SiRF_ID2P_set_ch6(SiRF_ID2P * userdata, uint8_t ch6) { userdata->ch6 = ch6; } uint8_t SiRF_ID2P_get_ch6(SiRF_ID2P * userdata) { return userdata->ch6; } void SiRF_ID2P_set_ch7(SiRF_ID2P * userdata, uint8_t ch7) { userdata->ch7 = ch7; } uint8_t SiRF_ID2P_get_ch7(SiRF_ID2P * userdata) { return userdata->ch7; } void SiRF_ID2P_set_ch8(SiRF_ID2P * userdata, uint8_t ch8) { userdata->ch8 = ch8; } uint8_t SiRF_ID2P_get_ch8(SiRF_ID2P * userdata) { return userdata->ch8; } void SiRF_ID2P_set_ch9(SiRF_ID2P * userdata, uint8_t ch9) { userdata->ch9 = ch9; } uint8_t SiRF_ID2P_get_ch9(SiRF_ID2P * userdata) { return userdata->ch9; } void SiRF_ID2P_set_ch10(SiRF_ID2P * userdata, uint8_t ch10) { userdata->ch10 = ch10; } uint8_t SiRF_ID2P_get_ch10(SiRF_ID2P * userdata) { return userdata->ch10; } void SiRF_ID2P_set_ch11(SiRF_ID2P * userdata, uint8_t ch11) { userdata->ch11 = ch11; } uint8_t SiRF_ID2P_get_ch11(SiRF_ID2P * userdata) { return userdata->ch11; } void SiRF_ID2P_set_ch12(SiRF_ID2P * userdata, uint8_t ch12) { userdata->ch12 = ch12; } uint8_t SiRF_ID2P_get_ch12(SiRF_ID2P * userdata) { return userdata->ch12; } //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_ID2P (" "result_time," "header_mote_id," "header_seqno," "header_am_type," "header_blockcount," "xpos," "ypos," "zpos," "xvel," "yvel," "zvel," "mode1," "dop," "mode2," "gps_week," "gps_tow," "sv_in_fix," "ch1," "ch2," "ch3," "ch4," "ch5," "ch6," "ch7," "ch8," "ch9," "ch10," "ch11," "ch12) 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_ID2P_pg_log(XbowSensorboardPacket * userdata) { char pg_command[255]; SiRF_ID2P * data = (SiRF_ID2P*)userdata; sprintf(pg_command,insert_stmt, data->header_mote_id, data->header_seqno, data->header_am_type, data->header_blockcount, data->xpos, data->ypos, data->zpos, data->xvel, data->yvel, data->zvel, data->mode1, data->dop, data->mode2, data->gps_week, data->gps_tow, data->sv_in_fix, data->ch1, data->ch2, data->ch3, data->ch4, data->ch5, data->ch6, data->ch7, data->ch8, data->ch9, data->ch10, data->ch11, data->ch12); #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 int xpos_convert(int xpos) { return xpos; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static int ypos_convert(int ypos) { return ypos; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static int zpos_convert(int zpos) { return zpos; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint16_t xvel_convert(uint16_t xvel) { return xvel; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint16_t yvel_convert(uint16_t yvel) { return yvel; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint16_t zvel_convert(uint16_t zvel) { return zvel; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t mode1_convert(uint8_t mode1) { return mode1; } /** @brief Default behavior is to return the input as output. * 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) { return gps_week; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint32_t gps_tow_convert(uint32_t gps_tow) { return gps_tow; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t sv_in_fix_convert(uint8_t sv_in_fix) { return sv_in_fix; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch1_convert(uint8_t ch1) { return ch1; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch2_convert(uint8_t ch2) { return ch2; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch3_convert(uint8_t ch3) { return ch3; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch4_convert(uint8_t ch4) { return ch4; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch5_convert(uint8_t ch5) { return ch5; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch6_convert(uint8_t ch6) { return ch6; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch7_convert(uint8_t ch7) { return ch7; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch8_convert(uint8_t ch8) { return ch8; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch9_convert(uint8_t ch9) { return ch9; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch10_convert(uint8_t ch10) { return ch10; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch11_convert(uint8_t ch11) { return ch11; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t ch12_convert(uint8_t ch12) { return ch12; } void SiRF_ID2P_cook_packet(SiRF_ID2P * 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->xpos = xpos_convert(userdata->xpos); userdata->ypos = ypos_convert(userdata->ypos); userdata->zpos = zpos_convert(userdata->zpos); userdata->xvel = xvel_convert(userdata->xvel); userdata->yvel = yvel_convert(userdata->yvel); 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); userdata->gps_tow = gps_tow_convert(userdata->gps_tow); userdata->sv_in_fix = sv_in_fix_convert(userdata->sv_in_fix); userdata->ch1 = ch1_convert(userdata->ch1); userdata->ch2 = ch2_convert(userdata->ch2); userdata->ch3 = ch3_convert(userdata->ch3); userdata->ch4 = ch4_convert(userdata->ch4); userdata->ch5 = ch5_convert(userdata->ch5); userdata->ch6 = ch6_convert(userdata->ch6); userdata->ch7 = ch7_convert(userdata->ch7); userdata->ch8 = ch8_convert(userdata->ch8); userdata->ch9 = ch9_convert(userdata->ch9); userdata->ch10 = ch10_convert(userdata->ch10); userdata->ch11 = ch11_convert(userdata->ch11); userdata->ch12 = ch12_convert(userdata->ch12); } /** User has to fill in any conversion code * necessary for processing. */ SiRF_ID2P * SiRF_ID2P_convert(char * data) { // Just to keep gcc happy. return (SiRF_ID2P*)data; } /** Print the bytes of the packet. */ void SiRF_ID2P_print_raw (XbowSensorboardPacket *packet) { printf("SiRF_ID2P print raw.\n"); } /** Print cooked output. */ void SiRF_ID2P_print_cooked (XbowSensorboardPacket * userdata) { SiRF_ID2P * data = (SiRF_ID2P*)userdata; printf("SiRF_ID2P 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(" 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); printf(" gps_tow: %i,\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); } #ifdef TELOS_MOTE XPacketHandler SiRF_ID2P_packet_handler = { // This should be replaced with the AM_TYPE 155, "$Id: sirf_id2.c,v 1.1 2006/07/10 17:17:16 doolin Exp $", SiRF_ID2P_print_raw, SiRF_ID2P_print_cooked, SiRF_ID2P_print_raw, SiRF_ID2P_print_cooked, SiRF_ID2P_pg_log, {0} }; void SiRF_ID2P_initialize() { xpacket_add_type(&SiRF_ID2P_packet_handler); } #endif /** The default size of this message type in bytes. */ //static int DEFAULT_MESSAGE_SIZE = 44; /** If incomplete types are used, we need to provide a way * to manage memory. */ SiRF_ID2P * SiRF_ID2P_new() { SiRF_ID2P * userdata = (SiRF_ID2P*)malloc(sizeof(SiRF_ID2P)); memset((void*)userdata,0xda,sizeof(SiRF_ID2P)); return userdata; } void SiRF_ID2P_delete(SiRF_ID2P * userdata) { memset((void*)userdata,0xdd,sizeof(SiRF_ID2P)); free(userdata); } --- NEW FILE: sirf_id28.c --- /** * 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_id28.c,v 1.1 2006/07/10 17:17:16 doolin Exp $", 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); } --- NEW FILE: sirf_id28_2.c --- /** * This class is automatically generated by mig. DO NOT EDIT THIS FILE. * This code implements C interface to the 'SiRF_ID28_2P' * message type. */ #include <stdio.h> #include <stdlib.h> #include <memory.h> /** Private header is programmer specified for handling * conversion functions, etc. */ //#include "SiRF_ID28_2P_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_ID28_2P SiRF_ID28_2P; #ifndef TELOS_MOTE typedef struct _XbowSensorboardPacket XbowSensorboardPacket; #endif /** The Active Message type associated with this message. */ //static const int AM_TYPE = 153; //#define AM_TYPE 153 // 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_ID28_2P { uint8_t header_mote_id; uint8_t header_seqno; uint8_t header_am_type; uint8_t header_blockcount; uint32_t pseudo_range; uint32_t carrier_freq; uint32_t carrier_phase; uint16_t time_in_track; }; void SiRF_ID28_2P_set_header_mote_id(SiRF_ID28_2P * userdata, uint8_t header_mote_id) { userdata->header_mote_id = header_mote_id; } uint8_t SiRF_ID28_2P_get_header_mote_id(SiRF_ID28_2P * userdata) { return userdata->header_mote_id; } void SiRF_ID28_2P_set_header_seqno(SiRF_ID28_2P * userdata, uint8_t header_seqno) { userdata->header_seqno = header_seqno; } uint8_t SiRF_ID28_2P_get_header_seqno(SiRF_ID28_2P * userdata) { return userdata->header_seqno; } void SiRF_ID28_2P_set_header_am_type(SiRF_ID28_2P * userdata, uint8_t header_am_type) { userdata->header_am_type = header_am_type; } uint8_t SiRF_ID28_2P_get_header_am_type(SiRF_ID28_2P * userdata) { return userdata->header_am_type; } void SiRF_ID28_2P_set_header_blockcount(SiRF_ID28_2P * userdata, uint8_t header_blockcount) { userdata->header_blockcount = header_blockcount; } uint8_t SiRF_ID28_2P_get_header_blockcount(SiRF_ID28_2P * userdata) { return userdata->header_blockcount; } void SiRF_ID28_2P_set_pseudo_range(SiRF_ID28_2P * userdata, uint32_t pseudo_range) { userdata->pseudo_range = pseudo_range; } uint32_t SiRF_ID28_2P_get_pseudo_range(SiRF_ID28_2P * userdata) { return userdata->pseudo_range; } void SiRF_ID28_2P_set_carrier_freq(SiRF_ID28_2P * userdata, uint32_t carrier_freq) { userdata->carrier_freq = carrier_freq; } uint32_t SiRF_ID28_2P_get_carrier_freq(SiRF_ID28_2P * userdata) { return userdata->carrier_freq; } void SiRF_ID28_2P_set_carrier_phase(SiRF_ID28_2P * userdata, uint32_t carrier_phase) { userdata->carrier_phase = carrier_phase; } uint32_t SiRF_ID28_2P_get_carrier_phase(SiRF_ID28_2P * userdata) { return userdata->carrier_phase; } void SiRF_ID28_2P_set_time_in_track(SiRF_ID28_2P * userdata, uint16_t time_in_track) { userdata->time_in_track = time_in_track; } uint16_t SiRF_ID28_2P_get_time_in_track(SiRF_ID28_2P * userdata) { return userdata->time_in_track; } //Format string generated automatically, //static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i"; //static char formatstring[] = "%i, %i, %i, %i, %i, %i, %i, %i"; static char insert_stmt[] = "INSERT into SiRF_ID28_2P (" "result_time," "header_mote_id," "header_seqno," "header_am_type," "header_blockcount," "pseudo_range," "carrier_freq," "carrier_phase," "time_in_track) values (now(), %i, %i, %i, %i, %i, %i, %i, %i)"; void SiRF_ID28_2P_pg_log(XbowSensorboardPacket * userdata) { char pg_command[255]; SiRF_ID28_2P * data = (SiRF_ID28_2P*)userdata; sprintf(pg_command,insert... [truncated message content] |