firebug-cvs Mailing List for FireBug: wireless wildfire monitoring
Brought to you by:
doolin
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(36) |
Jun
(45) |
Jul
(108) |
Aug
(31) |
Sep
(2) |
Oct
(4) |
Nov
(113) |
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(63) |
Feb
(37) |
Mar
(24) |
Apr
(6) |
May
(5) |
Jun
(5) |
Jul
(71) |
Aug
(42) |
Sep
(7) |
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
(3) |
Apr
|
May
(64) |
Jun
(71) |
Jul
(51) |
Aug
(89) |
Sep
(24) |
Oct
(1) |
Nov
(1) |
Dec
(2) |
2006 |
Jan
|
Feb
|
Mar
(3) |
Apr
(2) |
May
|
Jun
|
Jul
(21) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
From: <sc...@bj...> - 2007-12-03 08:43:11
|
Dear Open Source developer, I'm student of the Leuphana University in Lueneburg, Germany. I'm writing my doctoral thesis about the innovativity of Project Communitie= s.=20 I've picked your Project at random at sourceforge.net and would like to ask= =20 you to take part of this pilot study. To complete the questionair form will take you 15 to 20 minutes. You'll fin= de=20 it under http://dissertation.bjoern-benz.de/output/project_communities/ Thank you for your participation, Bj=C3=B6rn Benz P.S. I will publish the results in approximately 6 months under =20 http://dissertation.bjoern-benz.de/results/project_communities/ =2D- Bj=C3=B6rn Benz Leuphana Universit=C3=A4t L=C3=BCneburg 21335 L=C3=BCneburg Mail: science at bjoern-benz.de |
From: David M. D. <do...@us...> - 2006-07-10 18:21:03
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten/ucb In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv12561/ucb Added Files: ucb.h Log Message: . --- NEW FILE: ucb.h --- /** Offset of payload relative to surge packet. */ #define SURGE_RELATIVE_OFFSET 0 // Match the xbow stuff for now. #define XPACKET_DATASTART_UCB 12 //!< Offset to Fireworks data #define XPACKET_DATASTART_FIREWORKS 10 //!< Offset to Fireworks data #define XPACKET_DATASTART_LINKEST 18 //!< Offset to Fireworks data // This is all from xbow code, but it needs to be // cleaned up a lot. typedef void (*packet_printer)(void * packet); typedef union BoardFlags { unsigned flat; struct { unsigned table_init : 1; //!< whether logging table is validated }; } BoardFlags; typedef struct PacketHandler { uint8_t type; //!< sensorboard id char * version; //!< CVS version string of boards source file packet_printer print_parsed; packet_printer print_cooked; packet_printer export_parsed; packet_printer export_cooked; packet_printer log_cooked; BoardFlags flags; //!< flags for board specific management } PacketHandler; /* typedef struct dispatch_table { uint8_t am_type; PacketHandler * ph; } dispatch_table_t; */ void LinkMsgP_initialize (void); void SurgeMsgP_initialize (void); void LinkEstimatorMsgP_initialize (void); |
From: David M. D. <do...@us...> - 2006-07-10 18:21:02
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten/boards In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv12561/boards Added Files: Makefile Log Message: . --- NEW FILE: Makefile --- clean: rm -rf *~ *.bak |
From: David M. D. <do...@us...> - 2006-07-10 18:20:23
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten/ucb In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv12490 Added Files: Makefile linkmsg.c sirf_id7.c ucb.c ucbtest.c Log Message: . --- NEW FILE: sirf_id7.c --- /** * This class is automatically generated by mig. DO NOT EDIT THIS FILE. * This code implements C interface to the 'SiRF_ID7P' * message type. */ #include <stdio.h> #include <stdlib.h> #include <memory.h> /** Private header is programmer specified for handling * conversion functions, etc. */ //#include "SiRF_ID7P_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_ID7P SiRF_ID7P; #ifndef TELOS_MOTE typedef struct _XbowSensorboardPacket XbowSensorboardPacket; #endif /** The Active Message type associated with this message. */ //static const int AM_TYPE = 158; //#define AM_TYPE 158 // 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_ID7P { uint8_t header_mote_id; uint8_t header_seqno; uint8_t header_am_type; uint8_t header_blockcount; uint32_t clock_bias; uint8_t SV; }; void SiRF_ID7P_set_header_mote_id(SiRF_ID7P * userdata, uint8_t header_mote_id) { userdata->header_mote_id = header_mote_id; } uint8_t SiRF_ID7P_get_header_mote_id(SiRF_ID7P * userdata) { return userdata->header_mote_id; } void SiRF_ID7P_set_header_seqno(SiRF_ID7P * userdata, uint8_t header_seqno) { userdata->header_seqno = header_seqno; } uint8_t SiRF_ID7P_get_header_seqno(SiRF_ID7P * userdata) { return userdata->header_seqno; } void SiRF_ID7P_set_header_am_type(SiRF_ID7P * userdata, uint8_t header_am_type) { userdata->header_am_type = header_am_type; } uint8_t SiRF_ID7P_get_header_am_type(SiRF_ID7P * userdata) { return userdata->header_am_type; } void SiRF_ID7P_set_header_blockcount(SiRF_ID7P * userdata, uint8_t header_blockcount) { userdata->header_blockcount = header_blockcount; } uint8_t SiRF_ID7P_get_header_blockcount(SiRF_ID7P * userdata) { return userdata->header_blockcount; } void SiRF_ID7P_set_clock_bias(SiRF_ID7P * userdata, uint32_t clock_bias) { userdata->clock_bias = clock_bias; } uint32_t SiRF_ID7P_get_clock_bias(SiRF_ID7P * userdata) { return userdata->clock_bias; } void SiRF_ID7P_set_SV(SiRF_ID7P * userdata, uint8_t SV) { userdata->SV = SV; } uint8_t SiRF_ID7P_get_SV(SiRF_ID7P * userdata) { return userdata->SV; } //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 SiRF_ID7P (" "result_time," "header_mote_id," "header_seqno," "header_am_type," "header_blockcount," "clock_bias," "SV) values (now(), %i, %i, %i, %i, %i, %i)"; void SiRF_ID7P_pg_log(XbowSensorboardPacket * userdata) { char pg_command[255]; SiRF_ID7P * data = (SiRF_ID7P*)userdata; sprintf(pg_command,insert_stmt, data->header_mote_id, data->header_seqno, data->header_am_type, data->header_blockcount, data->clock_bias, data->SV); #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 clock_bias_convert(uint32_t clock_bias) { return clock_bias; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint8_t SV_convert(uint8_t SV) { return SV; } void SiRF_ID7P_cook_packet(SiRF_ID7P * 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->clock_bias = clock_bias_convert(userdata->clock_bias); userdata->SV = SV_convert(userdata->SV); } /** User has to fill in any conversion code * necessary for processing. */ SiRF_ID7P * SiRF_ID7P_convert(char * data) { // Just to keep gcc happy. return (SiRF_ID7P*)data; } /** Print the bytes of the packet. */ void SiRF_ID7P_print_raw (XbowSensorboardPacket *packet) { printf("SiRF_ID7P print raw.\n"); } /** Print cooked output. */ void SiRF_ID7P_print_cooked (XbowSensorboardPacket * userdata) { SiRF_ID7P * data = (SiRF_ID7P*)userdata; printf("SiRF_ID7P 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(" clock_bias: %i,\n",data->clock_bias); printf(" SV: %i,\n",data->SV); } #ifdef TELOS_MOTE XPacketHandler SiRF_ID7P_packet_handler = { // This should be replaced with the AM_TYPE 158, "$Id: sirf_id7.c,v 1.1 2006/07/10 18:20:20 doolin Exp $", SiRF_ID7P_print_raw, SiRF_ID7P_print_cooked, SiRF_ID7P_print_raw, SiRF_ID7P_print_cooked, SiRF_ID7P_pg_log, {0} }; void SiRF_ID7P_initialize() { xpacket_add_type(&SiRF_ID7P_packet_handler); } #endif /** The default size of this message type in bytes. */ //static int DEFAULT_MESSAGE_SIZE = 9; /** If incomplete types are used, we need to provide a way * to manage memory. */ SiRF_ID7P * SiRF_ID7P_new() { SiRF_ID7P * userdata = (SiRF_ID7P*)malloc(sizeof(SiRF_ID7P)); memset((void*)userdata,0xda,sizeof(SiRF_ID7P)); return userdata; } void SiRF_ID7P_delete(SiRF_ID7P * userdata) { memset((void*)userdata,0xdd,sizeof(SiRF_ID7P)); free(userdata); } --- 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: Makefile --- SRCS = ucb.c LIBSRCS = sirf_id2.c \ sirf_id28.c \ ucbtest: gcc -o ucbtest ucbtest.c $(SRCS) -L../../../gps/SiRF -lsirftest libsirf: gcc -c $(LIBSRCS) ar -q libsirf.a sirf_*.o clean: rm -rf *.exe *.o *~ --- NEW FILE: ucbtest.c --- #include <stdio.h> #include "/home/dave/sf.net/firebug/fireboard/beta/tos/lib/SiRF/sirf.h" // From telos/AM.h. Can't include directly because // bool types aren't supported in C. typedef struct TOS_Msg { /* The following fields are transmitted/received on the radio. */ uint8_t length; uint8_t fcfhi; uint8_t fcflo; uint8_t dsn; uint16_t destpan; uint16_t addr; uint8_t type; uint8_t group; int8_t data[TOSH_DATA_LENGTH]; /* The following fields are not actually transmitted or received * on the radio! They are used for internal accounting only. * The reason they are in this structure is that the AM interface * requires them to be part of the TOS_Msg that is passed to * send/receive operations. */ uint8_t strength; uint8_t lqi; char crc; char ack; uint16_t time; } __attribute((packed)) TOS_Msg; // From MultuHop.h in MultiHopLQI. Can't // include the header file directly because it // includes AM.h, which won't compile in C. typedef struct MultihopMsg { uint16_t sourceaddr; uint16_t originaddr; int16_t seqno; int16_t originseqno; uint16_t hopcount; uint8_t data[(TOSH_DATA_LENGTH - 10)]; } TOS_MHopMsg; #define AM_MULTIHOPMSG 250 #define AM_FRAGMENT 251 /** General outline: * * 1. Create a TOS Msg with a regular payload, parse that * successfully. * * 2. Create a MultiHopMsg with a payload, and parse that successfully. * * 3. Parse a TOS msg that contains a MH msg with a payload. * * 4. Add fragments to the above. */ static TOS_Msg tosmsg = {0x0}; typedef struct payload { int int1; int int2; } payload_t; void parse_tos_message() { tosmsg.length = sizeof(TOS_Msg); tosmsg.fcfhi = 1; tosmsg.fcflo = 2; tosmsg.dsn = 3; tosmsg.destpan = 4; tosmsg.addr = 5; tosmsg.type = 6; tosmsg.group = 7; //tosmsg.data; // already zeroed. /* The following fields are not actually transmitted or received * on the radio! They are used for internal accounting only. * The reason they are in this structure is that the AM interface * requires them to be part of the TOS_Msg that is passed to * send/receive operations. */ tosmsg.strength = 100; tosmsg.lqi = 101; tosmsg.crc = 0; tosmsg.ack = 0; tosmsg.time = 103; // Grab the AM_TYPE // Invoke the print handler callback. } void parse_mh_message() { } void parse_tos_mh_message() { } void parse_tos_mh_frag_message() { } void print_surge_message() { } void print_payload_message() { } /** TODO: Next test: fill a struct, then pack that struct * and unpack a copy of it, then compare the two structs * for field-wise equality. We will need field-wise testing * testing to make sure that the bytes line up between * a struct packed on a mote and a struct unpacked on * a pc using a typedef. */ int main() { uint8_t * sirfid2; SiRF_ID2_t * sid2; printf("TOSH_DATA_LENGTH: %d\n", TOSH_DATA_LENGTH); sirfid2 = get_sirfid2_example(); sid2 = parse_sirfid2 (sirfid2); //SiRF_ID2P_print_cooked(sid2); return 0; } --- 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 18:20:20 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); } |
From: David M. D. <do...@us...> - 2006-07-10 18:20:02
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv12087 Added Files: firebug.c Log Message: . --- NEW FILE: firebug.c --- |
From: David M. D. <do...@us...> - 2006-07-10 18:19:30
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv12054 Modified Files: Makefile genc.pm xpacket.c xsensors.h Log Message: . Index: xpacket.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/src/xlisten/xpacket.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** xpacket.c 8 Aug 2005 22:26:39 -0000 1.10 --- xpacket.c 10 Jul 2006 18:19:28 -0000 1.11 *************** *** 14,20 **** #include "xpacket.h" ! #define AM_SURGEMSG 17 ! #define AM_LINKESTIMATORMSG 20 ! #define AM_PINGMSG 21 static unsigned g_datastart = XPACKET_DATASTART; --- 14,18 ---- #include "xpacket.h" ! #include "ucb/ucb.h" static unsigned g_datastart = XPACKET_DATASTART; *************** *** 45,50 **** mts310_initialize(); /* From boards/mts300.c */ - fireboard_initialize(); - mts400_initialize(); /* From boards/mts400.c */ //mts420_initialize(); /* From boards/mts400.c */ --- 43,46 ---- *************** *** 60,66 **** xtutorial_initialize(); /* From boards/xtutorial.c */ ! LinkMsgP_initialize(); ! SurgeMsgP_initialize(); ! LinkEstimatorMsgP_initialize(); } --- 56,60 ---- xtutorial_initialize(); /* From boards/xtutorial.c */ ! ucb_initialize(); } *************** *** 114,118 **** if (len < 2) return; - //printf("Mode is %d\n", mode); switch (mode) { case 0: --- 108,111 ---- *************** *** 167,193 **** break; - /* - case AMTYPE_FIREWORKS: - datastart = XPACKET_DATASTART_FIREWORKS; - //fprintf(stderr,"fireworks datastart: %d\n", datastart); - break; - - case XTYPE_TESTLINK: - datastart = XPACKET_DATASTART_FIREWORKS; - //fprintf(stderr,"fireworks datastart: %d\n", datastart); - break; - */ - - case AM_LINKMSG: - datastart = XPACKET_DATASTART_FIREWORKS; - //fprintf(stderr,"fireworks datastart: %d\n", datastart); - break; - - case AM_LINKESTIMATORMSG: - datastart = XPACKET_DATASTART_LINKEST; - //fprintf(stderr,"fireworks datastart: %d\n", datastart); - break; - default: return NULL; } --- 160,165 ---- break; default: + // Handle firebug AM_TYPES here? return NULL; } *************** *** 299,303 **** { int i = 256, entry; - while (--i >= 0) { entry = table + i; --- 271,274 ---- *************** *** 306,319 **** return g_packetTable[entry]; } - return NULL; } ! XPacketHandler * ! xpacket_get_handler(char *tos_packet) { unsigned char am_type = tos_packet[XPACKET_TYPE]; - //fprintf("xpacket_get_handler am_type: %d\n", am_type); switch (am_type) { case AMTYPE_XMULTIHOP: --- 277,288 ---- return g_packetTable[entry]; } return NULL; } ! XPacketHandler *xpacket_get_handler(char *tos_packet) ! { unsigned char am_type = tos_packet[XPACKET_TYPE]; switch (am_type) { case AMTYPE_XMULTIHOP: *************** *** 332,380 **** } - /* - case AMTYPE_FIREWORKS: { - XbowSensorboardPacket *packet; - packet = xpacket_get_sensor_data(tos_packet); - //fprintf(stderr, "xpacket_get_handler fireworks\n"); - if (xpacket_print_common(packet)) { - fprintf(stderr, - "xpacket_get_handler error1: no packet handler for board id 0x%02x\n", - packet->board_id); - return NULL; - } - return xsensor_get_handler(am_type, XPACKET_BOARD_TABLE); - } - - - case XTYPE_TESTLINK: { - XbowSensorboardPacket *packet; - packet = xpacket_get_sensor_data(tos_packet); - //fprintf(stderr, "xpacket_get_handler fireworks\n"); - if (xpacket_print_common(packet)) { - fprintf(stderr, - "xpacket_get_handler error1: no packet handler for board id 0x%02x\n", - packet->board_id); - return NULL; - } - return xsensor_get_handler(am_type, XPACKET_BOARD_TABLE); - } - */ - case AM_LINKMSG: - case AM_LINKESTIMATORMSG: { - - XbowSensorboardPacket *packet; - packet = xpacket_get_sensor_data(tos_packet); - //fprintf(stderr, "xpacket_get_handler fireworks\n"); - if (xpacket_print_common(packet)) { - fprintf(stderr, - "xpacket_get_handler error1: no packet handler for board id 0x%02x\n", - packet->board_id); - return NULL; - } - return xsensor_get_handler(am_type, XPACKET_BOARD_TABLE); - } - - - case AMTYPE_HEALTH: case AMTYPE_SURGE_MSG: --- 301,304 ---- *************** *** 382,385 **** --- 306,311 ---- default: + //Handle firebug AM_TYPES here. + return (XPacketHandler*)fb_get_packet_handler(am_type); break; } *************** *** 390,394 **** } - /** * Display a parsed packet as raw ADC values for each sensor on the board. --- 316,319 ---- *************** *** 541,544 **** --- 466,470 ---- ); + packet = (uint8_t *)mhop; // i=2 --> skip board_id/packet_id, node/parent for (i=0; i<tosmsg->length; i++) { // include CRC *************** *** 546,551 **** printf(","); } ! uint16_t crc = *(uint16_t *)((char *)mhop + tosmsg->length); ! printf(" %u\n",crc); } --- 472,477 ---- printf(","); } ! // uint16_t crc = *(uint16_t *)((char *)mhop + tosmsg->length); ! // printf(" %u\n",crc); } Index: xsensors.h =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/src/xlisten/xsensors.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** xsensors.h 9 Aug 2005 00:39:50 -0000 1.11 --- xsensors.h 10 Jul 2006 18:19:28 -0000 1.12 *************** *** 129,134 **** #define XPACKET_DATASTART_MULTIHOP 12 //!< Multihop offset to data payload #define XPACKET_DATASTART 12 //!< Default offset to data payload ! #define XPACKET_DATASTART_FIREWORKS 10 //!< Offset to Fireworks data ! #define XPACKET_DATASTART_LINKEST 18 //!< Offset to Fireworks data #define XPACKET_BOARD_TABLE 0 //!< offset to XSensor board table --- 129,134 ---- #define XPACKET_DATASTART_MULTIHOP 12 //!< Multihop offset to data payload #define XPACKET_DATASTART 12 //!< Default offset to data payload ! //#define XPACKET_DATASTART_FIREWORKS 10 //!< Offset to Fireworks data ! //#define XPACKET_DATASTART_LINKEST 18 //!< Offset to Fireworks data #define XPACKET_BOARD_TABLE 0 //!< offset to XSensor board table *************** *** 233,237 **** void xtutorial_initialize(); /* From baords/xtutorial.c */ ! void LinkMsgP_initialize(); #endif /* __SENSORS_H__ */ --- 233,237 ---- void xtutorial_initialize(); /* From baords/xtutorial.c */ ! void ucb_initialize(); #endif /* __SENSORS_H__ */ Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/src/xlisten/Makefile,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Makefile 8 Aug 2005 20:37:37 -0000 1.16 --- Makefile 10 Jul 2006 18:19:28 -0000 1.17 *************** *** 21,25 **** SRCS += boards/sirf_id28_1.c boards/sirf_id28_2.c boards/sirf_id28_3.c SRCS += boards/LinkEstimatorMsg.c ! SRCS += boards/SurgeMsg.c INCLUDES = -I../../../tos/sensorboards/mts400/GPS --- 21,27 ---- SRCS += boards/sirf_id28_1.c boards/sirf_id28_2.c boards/sirf_id28_3.c SRCS += boards/LinkEstimatorMsg.c ! SRCS += boards/SurgeMsg.c ! ! SRCS += ucb/ucb.c INCLUDES = -I../../../tos/sensorboards/mts400/GPS *************** *** 57,59 **** clean: ! rm -f *.o boards/*.o xlisten xlisten-arm xlisten.exe fbpacket.exe xlisten-telos.exe --- 59,61 ---- clean: ! rm -f *.o boards/*.o xlisten xlisten-arm xlisten.exe fbpacket.exe xlisten-telos.exe *~ *.bak |
From: David M. D. <do...@us...> - 2006-07-10 18:19:12
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv12034 Modified Files: Makefile Added Files: README Log Message: Synching with beta failed due to dependencies on the sensorboard branch. --- NEW FILE: README --- This part of the tree needs to be synched with the xlisten code in the beta branch, which requires the sensorboard directories to be synched as well. Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 10 Jul 2006 17:18:15 -0000 1.2 --- Makefile 10 Jul 2006 18:19:06 -0000 1.3 *************** *** 1,4 **** # Makefile for xlisten # $Id$ ! CC = gcc ARMCC = arm-linux-gcc --- 1,4 ---- # Makefile for xlisten # $Id$ ! CC = gcc ARMCC = arm-linux-gcc *************** *** 7,17 **** LFLAGS = -lpq -lm CFLAGS = -O2 -Wall -Wno-format ! ! # Main xlisten sources SRCS = xpacket.c xconvert.c xdb.c SRCS += xserial.c xsocket.c args.c ! ! # Add Mote Sensor board support ! SRCS += boards/mts300.c boards/mts400.c boards/mts510.c boards/mts101.c SRCS += boards/mep500.c boards/mep401.c boards/ggbacltst.c SRCS += boards/mica2.c boards/mica2dot.c boards/micaz.c boards/fireboard.c --- 7,17 ---- LFLAGS = -lpq -lm CFLAGS = -O2 -Wall -Wno-format ! ! # Main xlisten sources SRCS = xpacket.c xconvert.c xdb.c SRCS += xserial.c xsocket.c args.c ! ! # Add Mote Sensor board support ! SRCS += boards/mts300.c boards/mts400.c boards/mts510.c boards/mts101.c SRCS += boards/mep500.c boards/mep401.c boards/ggbacltst.c SRCS += boards/mica2.c boards/mica2dot.c boards/micaz.c boards/fireboard.c *************** *** 27,35 **** INCLUDES = -I../../../tos/sensorboards/mts400/GPS INCLUDES += -I../../../apps/XSensorMTS400 ! INCLUDES += -I../../../fireworks/apps/MultihopLinkEstimator ! ! # Add Mote Data Aquisition board support ! SRCS += boards/mda500.c boards/mda300.c ! # Add Mica2 integrated sensorboards SRCS += boards/msp410.c --- 27,35 ---- INCLUDES = -I../../../tos/sensorboards/mts400/GPS INCLUDES += -I../../../apps/XSensorMTS400 ! INCLUDES += -I../../../beta/fireworks/apps/MultihopLinkEstimator ! ! # Add Mote Data Aquisition board support ! SRCS += boards/mda500.c boards/mda300.c ! # Add Mica2 integrated sensorboards SRCS += boards/msp410.c *************** *** 45,52 **** all: xlisten fbpacket xlisten-telos ! ! xlisten: $(SRCS) $(CC) $(CFLAGS) -o $@ xlisten.c $(SRCS) $(INCLUDES) $(LFLAGS) ! fbpacket: fbpacket.c $(CC) $(CFLAGS) -o $@ fbpacket.c $(SRCS) $(INCLUDES) $(LFLAGS) --- 45,52 ---- all: xlisten fbpacket xlisten-telos ! ! xlisten: $(SRCS) $(CC) $(CFLAGS) -o $@ xlisten.c $(SRCS) $(INCLUDES) $(LFLAGS) ! fbpacket: fbpacket.c $(CC) $(CFLAGS) -o $@ fbpacket.c $(SRCS) $(INCLUDES) $(LFLAGS) *************** *** 54,58 **** xlisten-telos: $(SRCS) $(CC) $(CFLAGS) -o $@ -DTELOS_MOTE xlisten.c $(SRCS) $(INCLUDES) $(LFLAGS) ! xlisten-arm: $(SRCS) $(ARMCC) -I$(INCDIR) $(INCLUDES) $(CFLAGS) -o $@ $(SRCS) -L$(LIBDIR) $(LFLAGS) --- 54,58 ---- xlisten-telos: $(SRCS) $(CC) $(CFLAGS) -o $@ -DTELOS_MOTE xlisten.c $(SRCS) $(INCLUDES) $(LFLAGS) ! xlisten-arm: $(SRCS) $(ARMCC) -I$(INCDIR) $(INCLUDES) $(CFLAGS) -o $@ $(SRCS) -L$(LIBDIR) $(LFLAGS) |
From: David M. D. <do...@us...> - 2006-07-10 17:20:04
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20795 Added Files: genpgsql.pm Log Message: updating from beta. --- NEW FILE: genpgsql.pm --- # This file is part of the nesC compiler. # Copyright (C) 2002 Intel Corporation # # The attached "nesC" software is provided to you under the terms and # conditions of the GNU General Public License Version 2 as published by the # Free Software Foundation. # # nesC is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with nesC; see the file COPYING. If not, write to # the Free Software Foundation, 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. ## TODO for autogenerating postgres sql code. ## ---------------------------------------------------------- ## Several things need to be done to make this viable for the ## kinds of messages we want to process. The first part is ## to get rid of the java type conversions, and preserve the ## structure as defined the tinyos header file. We can do this ## because nesc native types are identical to c native types. ## ## Parts of this code were written for the NSF_ITR funded ## firebug project. ## ## Code based on genjava.pm written by David Gay (?) ## authors David Gay (? + others?), Dave Doolin true; sub gen() { my ($classname, @spec) = @_; require migdecode; &decode(@spec); &usage("no classname name specified") if !defined($java_classname); $java_extends = "net.tinyos.message.Message" if !defined($java_extends); # See if name has a package specifier if ($java_classname =~ /(.*)\.([^.]*)$/) { $package = $1; $java_classname = $2."P"; } $I = " "; $smallskip = "\n\n"; $medskip = "\n\n\n\n"; $bigskip = "\n\n\n\n\n\n"; print "/**\n"; print " * This class is automatically generated by mig. DO NOT EDIT THIS FILE.\n"; print " * This code provides postgres table to the '$java_classname'\n"; print " * message type.\n"; print " */\n\n"; &gen_sql_table(); print $medskip; } sub gen_sql_table() { print "CREATE TABLE $java_classname (\n"; print " result_time timestamp without time zone,\n"; # Get the size of the array. $numfields = $#fields; $i = 0; for (@fields) { ($field, $type, $bitlength, $offset, $amax, $abitsize, $aoffset) = @{$_}; ($ctype, $java_access, $arrayspec) = &cbasetype($type, $bitlength, 0); # This is clunky but will work. A better way to do it would be to store # the nested struct internally in the field array somehow. # Maybe a perl guru can figure that out. # What needs to be done is to find one of these, then # store it until all the members written out, # then print it. if ($field =~ /(.*)\.([^.]*)$/) { $struct = $1; $member = $2; #print STDERR $struct;#.", "$member."\n"; } ## Gets an array of format specifiers useful in *print* functions ## in libc. the @format array can be passed push(@format, &formatstring($type, $bitlength, 0)); $field =~ s/\./_/g; printf "$I$field $ctype"; if ($i < $numfields) { print ",\n"; } $i++; } print ");"; } sub gen_struct() { print "struct _$java_classname {\n"; ## todo move this to sub print_msg_struct(). for (@fields) { ($field, $type, $bitlength, $offset, $amax, $abitsize, $aoffset) = @{$_}; ($ctype, $java_access, $arrayspec) = &cbasetype($type, $bitlength, 0); # This is clunky but will work. A better way to do it would be to store # the nested struct internally in the field array somehow. # Maybe a perl guru can figure that out. # What needs to be done is to find one of these, then # store it until all the members written out, # then print it. if ($field =~ /(.*)\.([^.]*)$/) { $struct = $1; $member = $2; #print STDERR $struct;#.", "$member."\n"; } ## Gets an array of format specifiers useful in *print* functions ## in libc. the @format array can be passed push(@format, &formatstring($type, $bitlength, 0)); $field =~ s/\./_/g; printf "$I$field $ctype,\n"; } print "};"; } ## TODO Change all these back to the base types available in c, which are ## the same as in nesc. Probably need to add a "bitfield" handler to ## do it right. sub cbasetype() { my ($basetype, $bitlength, $arraydims) = @_; my $jtype, $acc; # Pick the java type whose range is closest to the corresponding C type if ($basetype eq "U") { $acc = "UIntElement"; if ($bitlength < 8) { $jtype = "smallint"; } elsif ($bitlength < 16) { $jtype = "integer"; } elsif ($bitlength < 32) { $jtype = "integer"; } else { $jtype = "integer"; } } elsif ($basetype eq "I") { $acc = "SIntElement"; if ($bitlength <= 8) { $jtype = "smallint"; } elsif ($bitlength <= 16) { $jtype = "smallint"; } elsif ($bitlength <= 32) { $jtype = "integer"; } else { $jtype = "long"; } } elsif ($basetype eq "F" || $basetype eq "D" || $basetype eq "LD") { $acc = "FloatElement"; $jtype = "float"; } if ($arraydims > 0) { # For array types $arrayspec = ""; for ($i = 0; $i < $arraydims; $i++) { $arrayspec = "[]" . $arrayspec; } } return ($jtype, $acc, $arrayspec); } ## TODO Get rid of all the superfluous code, ## or move the functionality into cbasetype. sub formatstring() { my ($basetype, $bitlength, $arraydims) = @_; my $jtype, $acc, $formatstring; # Pick the java type whose range is closest to the corresponding C type if ($basetype eq "U") { $acc = "UIntElement"; if ($bitlength < 8) { $jtype = "byte"; $formatstring = "c";} elsif ($bitlength < 16) { $jtype = "short"; $formatstring = "i";} elsif ($bitlength < 32) { $jtype = "int"; $formatstring = "i";} else { $jtype = "long"; $formatstring = "%i"} } elsif ($basetype eq "I") { $acc = "SIntElement"; if ($bitlength <= 8) { $jtype = "byte"; $formatstring = "c";} elsif ($bitlength <= 16) { $jtype = "short"; $formatstring = "i";} elsif ($bitlength <= 32) { $jtype = "int"; $formatstring = "i";} else { $jtype = "long"; } } elsif ($basetype eq "F" || $basetype eq "D" || $basetype eq "LD") { $acc = "FloatElement"; $jtype = "float"; $formatstring = "f"; } if ($arraydims > 0) { # For array types $arrayspec = ""; for ($i = 0; $i < $arraydims; $i++) { $arrayspec = "[]" . $arrayspec; } } #return ($jtype, $acc, $arrayspec, $formatstring); return ($formatstring); } sub printoffset() { my ($offset, $max, $bitsize, $aoffset, $inbits) = @_; print " int offset = $offset;\n"; for ($i = 1; $i <= @$max; $i++) { # check index bounds. 0-sized arrays don't get an upper-bound check # (they represent variable size arrays. Normally they should only # occur as the first-dimension of the last element of the structure) if ($$max[$i - 1] != 0) { print " if (index$i < 0 || index$i >= $$max[$i - 1]) throw new ArrayIndexOutOfBoundsException();\n"; } else { print " if (index$i < 0) throw new ArrayIndexOutOfBoundsException();\n"; } print " offset += $$aoffset[$i - 1] + index$i * $$bitsize[$i - 1];\n"; } if ($inbits) { print " return offset;\n"; } else { print " return (offset / 8);\n"; } } sub printarrayget() { my ($javafield, $javatype, $arrayspec, $bitlength, $amax, $abitsize) = @_; # Check whether array has known size for ($i = 0; $i < @$amax; $i++) { if ($$amax[$i] == 0) { print " throw new IllegalArgumentException(\"Cannot get field as array - unknown size\");\n"; return; } } print " $javatype$arrayspec tmp = new $javatype"; for ($i = 0; $i < @$amax; $i++) { print "[$$amax[$i]]"; } print ";\n"; $indent = " "; for ($i = 0; $i < @$amax; $i++) { print " $indent for (int index$i = 0; index$i < numElements_$javafield($i); index$i++) {\n"; $indent = $indent . " "; } $indent = $indent . " "; print " $indent tmp"; for ($i = 0; $i < @$amax; $i++) { print "[index$i]"; } print " = getElement_$javafield("; for ($i = 0; $i < @$amax; $i++) { print "index$i"; if ($i != @$amax-1) { print ","; } } print ");\n"; $indent = substr($indent, 0, length($indent)-2); for ($i = 0; $i < @$amax; $i++) { $indent = substr($indent, 0, length($indent)-2); print " $indent }\n"; } print " return tmp;\n"; } sub printarrayset() { my ($javafield, $javatype, $arrayspec, $bitlength, $amax, $abitsize) = @_; $indent = " "; $val = ""; for ($i = 0; $i < @$amax; $i++) { print " $indent for (int index$i = 0; index$i < value$val.length; index$i++) {\n"; $val = $val . "[index$i]"; $indent = $indent . " "; } $indent = $indent . " "; print " $indent setElement_$javafield("; for ($i = 0; $i < @$amax; $i++) { print "index$i"; if ($i != @$amax-1) { print ","; } } print ", value"; for ($i = 0; $i < @$amax; $i++) { print "[index$i]"; } print ");\n"; $indent = substr($indent, 0, length($indent)-2); for ($i = 0; $i < @$amax; $i++) { $indent = substr($indent, 0, length($indent)-2); print " $indent }\n"; } } |
From: David M. D. <do...@us...> - 2006-07-10 17:19:46
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20732 Added Files: Makefile.am configure.in Log Message: updating from beta. --- NEW FILE: Makefile.am --- --- NEW FILE: configure.in --- |
From: David M. D. <do...@us...> - 2006-07-10 17:19:30
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20688 Added Files: args.c args.h fbpacket.c Log Message: updating from beta. --- NEW FILE: fbpacket.c --- /** * $Id: fbpacket.c,v 1.1 2006/07/10 17:19:27 doolin Exp $ */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <time.h> #include <sys/times.h> #include "xdb.h" #include "xsensors.h" #include "boards/fireboard.h" #include "args.h" /* uint8_t hours; uint8_t minutes; uint8_t Lat_deg; uint8_t Long_deg; float dec_sec; float Lat_dec_min; float Long_dec_min; uint8_t NSEWind; uint8_t fixQuality; uint8_t num_sats; */ // This next block is required to get the program to // link, has no use in the program. const char *g_version = "$Id: fbpacket.c,v 1.1 2006/07/10 17:19:27 doolin Exp $"; int g_istream; //!< Handle of input stream int xmain_get_verbose(s_params * g_params) { //return !g_params->bits.mode_quiet; return 0; } // end useless block /* Function call adds 1 clock_t to each cycle * through the loop compared to setting the * values in the loop. */ void init_gga_data(GGA_Data * gga_data) { gga_data->hours = 1; gga_data->minutes = 1; gga_data->Lat_deg = 1; gga_data->Long_deg = 1; gga_data->dec_sec = 1; gga_data->Lat_dec_min = 1; gga_data->Long_dec_min = 1; gga_data->NSEWind = 1; gga_data->fixQuality = 1; gga_data->num_sats = 1; } /** Clocking code is shitty, should be abstracted * out into a set of small useful functions, or * use a more convenient libc API. */ int main(int argc, char **argv) { int i; //struct tms tms_start, tms_end; clock_t start, stop; GGA_Data gga_data = {0}; XbowSensorboardPacket packet = {0}; start = clock(); printf("start: %d\n",start); init_gga_data(&gga_data); // This is a royal pain in the ass because the packets // on the mote side are built using unions to for // embedded headers, but on the processing side the data // is assumed to be aggregated. What a fuckin bitch for // writing test code. memcpy(packet.data,&gga_data,sizeof(packet.data)); for (i=0; i<100; i++) { fb_pg_log_gga_data(&packet); } stop = clock(); printf("stop: %d\n",stop); printf("clocks per sec: %d\n", CLOCKS_PER_SEC); printf("Elapsed time: %f\n", ((float)(stop - start)/CLOCKS_PER_SEC)); return 0; } --- NEW FILE: args.c --- #include "xsensors.h" #include "args.h" /** Global var containing xlisten cvs Id tag. */ extern const char *g_version; /** FILE pointer for the input device. * TODO: Open this device in main instead of * here where it is set. */ extern int g_istream; // TODO: 1. Move the argument parsing code in here. // 2. Change to getopts parsing. /** * Extracts command line options and sets flags internally. * * @param argc Argument count * @param argv Argument vector * * @author Martin Turon * * @version 2004/3/10 mturon Intial version * @n 2004/3/12 mturon Added -b,-s,-q,-x * @n 2004/8/04 mturon Added -l [ver. 1.11] * @n 2004/8/22 mturon Added -i [ver. 1.13] * @n 2004/9/27 mturon Added -t [ver. 1.15] * @n 2004/9/29 mturon Added -f,-a [v 1.16] */ void parse_args(int argc, char **argv, s_params * g_params) { // This value is set if/when the bitflag is set. unsigned baudrate = 0; char *server, *port; g_params->flat = 0; /* default to no params set */ while (argc) { if ((argv[argc]) && (*argv[argc] == '-')) { switch(argv[argc][1]) { case '?': g_params->bits.display_help = 1; break; case 'q': g_params->bits.mode_quiet = 1; break; case 'p': g_params->bits.display_parsed = 1; break; case 'r': g_params->bits.display_raw = 1; break; case 'a': g_params->bits.display_ascii = 1; break; case 'c': g_params->bits.display_cooked = 1; break; case 'x': switch (argv[argc][2]) { case 'c': g_params->bits.export_cooked = 1; break; default: case 'r': g_params->bits.export_parsed = 1; break; } break; case 'f': switch (argv[argc][2]) { case '=': // specify arbitrary offset g_params->bits.mode_framing = atoi(argv[argc]+3)&3; break; case 'a': // automatic deframing g_params->bits.mode_framing = 0; break; case '0': case 'n': // assume no framing g_params->bits.mode_framing = 2; break; case '1': // force framing default: g_params->bits.mode_framing = 1; break; } break; case 'w': case 'h': { int offset = XPACKET_DATASTART_MULTIHOP; g_params->bits.mode_header = 1; switch (argv[argc][2]) { case '=': // specify arbitrary offset offset = atoi(argv[argc]+3); break; case '0': // direct uart (no wireless) case '1': // single hop offset offset = XPACKET_DATASTART_STANDARD; break; } xpacket_set_start(offset); break; } case 'l': g_params->bits.log_cooked = 1; if (argv[argc][2] == '=') { //xdb_set_table(argv[argc]+3); if (!xdb_db_exists(argv[argc]+3)) { xdb_createdb(argv[argc]+3); xdb_set_dbname(argv[argc]+3); } } break; case 'b': if (argv[argc][2] == '=') { baudrate = xserial_set_baud(argv[argc]+3); g_params->bits.display_baud = 1; } break; case 's': switch (argv[argc][2]) { case '=': xserial_set_device(argv[argc]+3); break; case 'f': g_params->bits.mode_sf = 1; g_params->bits.mode_socket = 1; if (argv[argc][3] == '=') { server = argv[argc]+4; port = strchr(server, ':'); if (port) { *port++ = '\0'; xsocket_set_port(port); } xsocket_set_server(server); } break; } break; case 't': g_params->bits.display_time = 1; break; case 'i': g_params->bits.mode_sf = 0; g_params->bits.mode_socket = 1; if (argv[argc][2] == '=') { server = argv[argc]+3; port = strchr(server, ':'); if (port) { *port++ = '\0'; xsocket_set_port(port); } xsocket_set_server(server); } break; case 'v': g_params->bits.mode_version = 1; break; case 'd': g_params->bits.mode_debug = 1; break; } } argc--; } if (!g_params->bits.mode_quiet) { // Summarize parameter settings printf("xlisten Ver:%s\n", g_version); if (g_params->bits.mode_version) xpacket_print_versions(); printf("Using params: "); if (g_params->bits.display_help) printf("[help] "); if (g_params->bits.display_baud) printf("[baud=0x%04x] ", baudrate); if (g_params->bits.display_raw) printf("[raw] "); if (g_params->bits.display_ascii) printf("[ascii] "); if (g_params->bits.display_parsed) printf("[parsed] "); if (g_params->bits.display_cooked) printf("[cooked] "); if (g_params->bits.export_parsed) printf("[export] "); if (g_params->bits.display_time) printf("[timed] "); if (g_params->bits.export_cooked) printf("[convert] "); if (g_params->bits.log_cooked) printf("[logging] "); if (g_params->bits.mode_framing==1)printf("[framed] "); if (g_params->bits.mode_framing==2)printf("[unframed] "); if (g_params->bits.mode_header) printf("[header=%i] ", xpacket_get_start()); if (g_params->bits.mode_socket) printf("[inet=%s:%u] ", xsocket_get_server(), xsocket_get_port()); if (g_params->bits.mode_debug) { printf("[debug - serial dump!] \n"); xserial_port_dump(); } printf("\n"); } if (g_params->bits.display_help) { printf( "\nUsage: xlisten <-?|r|p|c|x|l|d|v|q> <-l=table>" "\n <-s=device> <-b=baud> <-i=server:port>" "\n -? = display help [help]" "\n -r = raw display of tos packets [raw]" "\n -a = ascii display of tos packets [ascii]" "\n -p = parse packet into raw sensor readings [parsed]" "\n -c = convert data to engineering units [cooked]" "\n -l = log data to database or file [logged]" "\n -xr = export raw readings in csv spreadsheet format [export]" "\n -xc = export cooked in csv spreadsheet format [export]" "\n -d = debug serial port by dumping bytes [debug]" "\n -b = set the baudrate [baud=#|mica2|mica2dot]" "\n -s = set serial port device [device=com1]" "\n -i = use socket input [inet=host:port]" "\n -sf = use serial forwarder input [inet=host:port]" "\n -f = specify framing (0=auto|1=on|2=off)" "\n -h = specify header size [header=offset]" "\n -t = display time packet was received [timed]" "\n -q = quiet mode (suppress headers)" "\n -v = show version of all modules" "\n" ); exit(0); } /* Default to displaying packets as raw, parsed, and cooked. */ if (g_params->options.output == 0) { g_params->bits.display_raw = 1; g_params->bits.display_parsed = 1; g_params->bits.display_cooked = 1; } /** TODO: This should probably go back into main. * Once the code is tested out, delete the following. */ #if 0 /* Stream initialization */ // Set STDOUT and STDERR to be line buffered, so output is not delayed. setlinebuf(stdout); setlinebuf(stderr); if (g_params->bits.mode_socket) { g_istream = xsocket_port_open(); } else { g_istream = xserial_port_open(); } #endif } --- NEW FILE: args.h --- /** A structure to store parsed parameter flags. */ typedef union { unsigned flat; struct { // output display options unsigned display_raw : 1; //!< raw TOS packets unsigned display_parsed : 1; //!< pull out sensor readings unsigned display_cooked : 1; //!< convert to engineering units unsigned export_parsed : 1; //!< output comma delimited fields unsigned export_cooked : 1; //!< output comma delimited fields unsigned log_parsed : 1; //!< log output to database unsigned log_cooked : 1; //!< log output to database unsigned display_time : 1; //!< display timestamp of packet unsigned display_ascii : 1; //!< display packet as ASCII characters unsigned display_rsvd : 7; //!< pad first word for output options // modes of operation unsigned display_help : 1; unsigned display_baud : 1; //!< baud was set by user unsigned mode_debug : 1; //!< debug serial port unsigned mode_quiet : 1; //!< suppress headers unsigned mode_version : 1; //!< print versions of all modules unsigned mode_header : 1; //!< user using custom packet header unsigned mode_socket : 1; //!< connect to a serial socket unsigned mode_sf : 1; //!< connect to a serial forwarder unsigned mode_framing : 2; //!< auto=0, framed=1, unframed=2 } bits; struct { unsigned short output; //!< one output option required unsigned short mode; } options; } s_params; void parse_args (int argc, char **argv, s_params * g_params); |
From: David M. D. <do...@us...> - 2006-07-10 17:18:18
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20227 Modified Files: Makefile genc.pm xlisten.c xpacket.c xsensors.h xserial.c Log Message: updating from beta. Index: xsensors.h =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/xsensors.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** xsensors.h 4 Aug 2004 01:56:13 -0000 1.2 --- xsensors.h 10 Jul 2006 17:18:15 -0000 1.3 *************** *** 15,18 **** --- 15,34 ---- #include <stdio.h> + #include <stdlib.h> + #include <string.h> + #include <unistd.h> + + #ifdef __arm__ + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; + #endif + + #include "xdb.h" + #include "xconvert.h" + + #include "../../../fireworks/apps/TestLink/LinkMsg.h" + //#include "MultihopLinkEstimator.h" + /** *************** *** 28,31 **** --- 44,50 ---- */ typedef enum { + // surge packet + XTYPE_SURGE = 0x00, + // mica2dot sensorboards XTYPE_MDA500 = 0x01, *************** *** 33,36 **** --- 52,60 ---- XTYPE_MEP500, + // mote boards + XTYPE_MICA2 = 0x60, + XTYPE_MICA2DOT, + XTYPE_MICAZ, + // mica2 sensorboards XTYPE_MDA400 = 0x80, *************** *** 42,47 **** --- 66,89 ---- XTYPE_MTS420, XTYPE_MEP401, + XTYPE_XTUTORIAL = 0x88, + XTYPE_GGBACLTST, + + //XTYPE_TESTLINK = 0xfb, + // mica2 integrated boards + XTYPE_MSP410 = 0xA0, + } XbowSensorboardType; + typedef enum { + AMTYPE_XUART = 0x00, + AMTYPE_HEALTH = 0x03, + AMTYPE_SURGE_MSG = 0x11, + AMTYPE_XDEBUG = 0x31, + AMTYPE_XSENSOR = 0x32, + AMTYPE_XMULTIHOP = 0x33, + AMTYPE_MHOP_MSG = 0xFA, + //AMTYPE_FIREWORKS = 0xC7 + } XbowAMType; + /** * Reserves general packet types that xlisten handles for all sensorboards. *************** *** 51,54 **** --- 93,101 ---- typedef enum { // reserved packet ids + // reserved packet ids + XPACKET_ACK = 0x40, + XPACKET_W_ACK = 0x41, + XPACKET_NO_ACK = 0x42, + XPACKET_ESC = 0x7D, //!< Reserved for serial packetizer escape code. XPACKET_START = 0x7E, //!< Reserved for serial packetizer start code. *************** *** 58,83 **** /** Encodes sensor readings into the data payload of a TOS message. */ typedef struct { ! uint8_t sensorboard_id; ! uint8_t packet_id; ! uint8_t node_id; ! uint8_t reserved; ! uint16_t data[12]; ! uint8_t reserved2; } XbowSensorboardPacket; ! #define XPACKET_SIZE 36 #define XPACKET_GROUP 3 //!< offset to group id of TOS packet #define XPACKET_LENGTH 4 //!< offset to length of TOS packet ! #define XPACKET_DATASTART 5 //!< UART offset to data payload ! #define XPACKET_DATASTART_WIRELESS 5 //!< Wireless offset to data payload #define XPACKET_DATASTART_MULTIHOP 12 //!< Multihop offset to data payload /* Sensorboard data packet definitions */ ! void xpacket_print_raw (unsigned char *tos_packet); void xpacket_print_parsed (unsigned char *tos_packet); void xpacket_print_cooked (unsigned char *tos_packet); void xpacket_export_parsed (unsigned char *tos_packet); ! void xpacket_depacketize (unsigned char *tos_packet); void xpacket_set_start (unsigned offset); /* Serial port routines. */ --- 105,188 ---- /** Encodes sensor readings into the data payload of a TOS message. */ typedef struct { ! uint8_t board_id; //!< Unique sensorboard id ! uint8_t packet_id; //!< Unique packet type for sensorboard ! uint8_t node_id; //!< Id of originating node ! uint8_t parent; //!< Id of node's parent ! uint16_t data[12]; //!< Data payload defaults to 24 bytes ! uint8_t terminator; //!< Reserved for null terminator } XbowSensorboardPacket; ! ! #define XPACKET_MIN_SIZE 4 //!< minimum valid packet size ! ! ! #ifdef TELOS_MOTE ! #define XPACKET_TYPE 8 //!< telos offset to type of TOS packet ! #else ! #define XPACKET_TYPE 2 //!< mica2 offset to type of TOS packet ! #endif ! #define XPACKET_GROUP 3 //!< offset to group id of TOS packet #define XPACKET_LENGTH 4 //!< offset to length of TOS packet ! ! #define XPACKET_DATASTART_STANDARD 5 //!< Standard offset to data payload #define XPACKET_DATASTART_MULTIHOP 12 //!< Multihop offset to data payload + #define XPACKET_DATASTART 12 //!< Default offset to data payload + //#define XPACKET_DATASTART_FIREWORKS 10 //!< Offset to Fireworks data + //#define XPACKET_DATASTART_LINKEST 18 //!< Offset to Fireworks data + + #define XPACKET_BOARD_TABLE 0 //!< offset to XSensor board table + #define XPACKET_AM_TABLE 256 //!< offset to AM lookup table + + enum { + XPACKET_DECODE_MODE_AUTO = 0, + XPACKET_DECODE_MODE_FRAMED, + XPACKET_DECODE_MODE_UNFRAMED + }; + + // Much easier to change arguments. + typedef void (*PacketPrinter)(XbowSensorboardPacket *packet); + + typedef union XBoardFlags { + unsigned flat; + struct { + unsigned table_init : 1; //!< whether logging table is validated + }; + } XBoardFlags; + + typedef struct XPacketHandler { + uint8_t type; //!< sensorboard id + char * version; //!< CVS version string of boards source file + + PacketPrinter print_parsed; + PacketPrinter print_cooked; + PacketPrinter export_parsed; + PacketPrinter export_cooked; + PacketPrinter log_cooked; + + XBoardFlags flags; //!< flags for board specific management + } XPacketHandler; + + /* Linkage to main */ + int xmain_get_verbose (); /* Sensorboard data packet definitions */ ! void xpacket_print_raw (unsigned char *tos_packet, int len); ! void xpacket_print_ascii (unsigned char *tos_packet, int len); void xpacket_print_parsed (unsigned char *tos_packet); void xpacket_print_cooked (unsigned char *tos_packet); void xpacket_export_parsed (unsigned char *tos_packet); ! void xpacket_export_cooked (unsigned char *tos_packet); ! void xpacket_log_cooked (unsigned char *tos_packet); ! ! void xpacket_initialize (); ! void xpacket_decode (unsigned char *tos_packet, int len, int mode); ! void xpacket_add_type (XPacketHandler *handler); ! void xpacket_add_amtype (XPacketHandler *handler); ! void xpacket_print_output (unsigned out_flags, unsigned char *tos_packet); ! void xpacket_print_time (); ! void xpacket_print_versions(); void xpacket_set_start (unsigned offset); + int xpacket_get_start (); /* Serial port routines. */ *************** *** 85,134 **** int xserial_port_dump (); int xserial_port_sync_packet (int serline); ! int xserial_port_read_packet (int serline, unsigned char *buffer, int cnt); unsigned xserial_set_baudrate (unsigned baudrate); unsigned xserial_set_baud (const char *baud); void xserial_set_device (const char *device); - void xserial_set_verbose (int verbose); ! /* Sensorboard specific conversion routines. */ ! /* From boards/mda500.c */ ! void mda500_print_raw (XbowSensorboardPacket *packet); ! void mda500_print_cooked (XbowSensorboardPacket *packet); ! void mda400_print_raw (XbowSensorboardPacket *packet); ! void mda400_print_cooked (XbowSensorboardPacket *packet); ! /* From boards/mda300.c */ ! void mda300_print_raw (XbowSensorboardPacket *packet); ! void mda300_print_cooked (XbowSensorboardPacket *packet); ! /* From boards/mts300.c */ ! void mts300_print_raw (XbowSensorboardPacket *packet); ! void mts300_print_cooked (XbowSensorboardPacket *packet); ! void mts310_print_raw (XbowSensorboardPacket *packet); ! void mts310_print_cooked (XbowSensorboardPacket *packet); ! /* From boards/mts400.c */ ! void mts400_print_raw (XbowSensorboardPacket *packet); ! void mts400_print_cooked (XbowSensorboardPacket *packet); ! void mts420_print_raw (XbowSensorboardPacket *packet); ! void mts420_print_cooked (XbowSensorboardPacket *packet); ! /* From boards/mts510.c */ ! void mts510_print_raw (XbowSensorboardPacket *packet); ! void mts510_print_cooked (XbowSensorboardPacket *packet); ! /* From boards/mts101.c */ ! void mts101_print_raw (XbowSensorboardPacket *packet); ! void mts101_print_cooked (XbowSensorboardPacket *packet); ! /* From boards/mep500.c */ ! void mep500_print_raw (XbowSensorboardPacket *packet); ! void mep500_print_cooked (XbowSensorboardPacket *packet); ! /* From boards/mep401.c */ ! void mep401_print_raw (XbowSensorboardPacket *packet); ! void mep401_print_cooked (XbowSensorboardPacket *packet); #endif /* __SENSORS_H__ */ --- 190,237 ---- int xserial_port_dump (); int xserial_port_sync_packet (int serline); ! int xserial_port_read_packet (int serline, unsigned char *buffer); unsigned xserial_set_baudrate (unsigned baudrate); unsigned xserial_set_baud (const char *baud); void xserial_set_device (const char *device); ! /* Socket routines. */ ! int xsocket_port_open (); ! void xsocket_set_port (const char *port); ! unsigned xsocket_get_port (); ! void xsocket_set_server (const char *server); ! const char * xsocket_get_server (); ! int xsocket_read_packet (int serline, unsigned char *buffer); ! void mica2_initialize(); /* From boards/mica2.c */ ! void mica2dot_initialize(); /* From boards/mica2dot.c */ ! void micaz_initialize(); /* From boards/micaz.c */ ! /* Sensorboard specific conversion routines. */ ! void mda300_initialize(); /* From boards/mda300.c */ ! void mda400_initialize(); /* From boards/mda500.c */ ! void mda500_initialize(); /* From boards/mda500.c */ ! void mts300_initialize(); /* From boards/mts300.c */ ! void mts310_initialize(); /* From boards/mts300.c */ ! void mts400_initialize(); /* From boards/mts400.c */ ! void mts420_initialize(); /* From boards/mts400.c */ ! void fireboard_initialize(); /* From boards/mts400.c */ ! void mts510_initialize(); /* From boards/mts510.c */ ! void mts101_initialize(); /* From boards/mts101.c */ ! void mep500_initialize(); /* From boards/mep500.c */ ! void mep401_initialize(); /* From boards/mep401.c */ ! void ggbacltst_initialize(); /* From boards/ggbacltst.c */ ! void msp410_initialize(); /* From boards/msp410.c */ ! void surge_initialize(); /* From boards/surge.c */ ! void health_initialize(); /* From amtypes/health.c */ + void xtutorial_initialize(); /* From baords/xtutorial.c */ + + void ucb_initialize(); #endif /* __SENSORS_H__ */ Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 15 Jul 2004 17:03:39 -0000 1.1 --- Makefile 10 Jul 2006 17:18:15 -0000 1.2 *************** *** 1,21 **** ! CFLAGS = -Wall -O2 -Wno-format ! all: xlisten # Main xlisten sources ! SRCS = xlisten.c xserial.c xpacket.c # Add Mote Sensor board support SRCS += boards/mts300.c boards/mts400.c boards/mts510.c boards/mts101.c ! SRCS += boards/mep500.c boards/mep401.c timestamp.c # Add Mote Data Aquisition board support SRCS += boards/mda500.c boards/mda300.c xlisten: $(SRCS) ! gcc $(CFLAGS) -o $@ $(SRCS) ! clean: ! rm -rf *~ *.o *.exe *.stackdump --- 1,61 ---- ! # Makefile for xlisten # $Id$ ! CC = gcc ! ARMCC = arm-linux-gcc ! INCDIR = /usr/local/arm/3.4.1/pgsql/include ! LIBDIR = /usr/local/arm/3.4.1/pgsql/lib ! LFLAGS = -lpq -lm ! CFLAGS = -O2 -Wall -Wno-format # Main xlisten sources ! SRCS = xpacket.c xconvert.c xdb.c ! SRCS += xserial.c xsocket.c args.c # Add Mote Sensor board support SRCS += boards/mts300.c boards/mts400.c boards/mts510.c boards/mts101.c ! SRCS += boards/mep500.c boards/mep401.c boards/ggbacltst.c ! SRCS += boards/mica2.c boards/mica2dot.c boards/micaz.c boards/fireboard.c ! SRCS += boards/pg_test.c ! SRCS += boards/linkmsg.c #boards/testlink.c ! SRCS += boards/sirf_id2_1.c boards/sirf_id2_2.c ! SRCS += boards/sirf_id28_1.c boards/sirf_id28_2.c boards/sirf_id28_3.c ! SRCS += boards/LinkEstimatorMsg.c ! SRCS += boards/SurgeMsg.c ! ! SRCS += ucb/ucb.c ! ! INCLUDES = -I../../../tos/sensorboards/mts400/GPS ! INCLUDES += -I../../../apps/XSensorMTS400 ! INCLUDES += -I../../../fireworks/apps/MultihopLinkEstimator # Add Mote Data Aquisition board support SRCS += boards/mda500.c boards/mda300.c + # Add Mica2 integrated sensorboards + SRCS += boards/msp410.c + + # Add support for "virtual" board that XsensorTutorial + # uses during Training seminar + SRCS += boards/xtutorial.c + + # Add AM types + SRCS += amtypes/health.c amtypes/surge.c + + SRCS += timestamp/timestamp.c + + all: xlisten fbpacket xlisten-telos xlisten: $(SRCS) ! $(CC) $(CFLAGS) -o $@ xlisten.c $(SRCS) $(INCLUDES) $(LFLAGS) ! fbpacket: fbpacket.c ! $(CC) $(CFLAGS) -o $@ fbpacket.c $(SRCS) $(INCLUDES) $(LFLAGS) ! ! xlisten-telos: $(SRCS) ! $(CC) $(CFLAGS) -o $@ -DTELOS_MOTE xlisten.c $(SRCS) $(INCLUDES) $(LFLAGS) + xlisten-arm: $(SRCS) + $(ARMCC) -I$(INCDIR) $(INCLUDES) $(CFLAGS) -o $@ $(SRCS) -L$(LIBDIR) $(LFLAGS) + + clean: + rm -f *.o boards/*.o xlisten xlisten-arm xlisten.exe fbpacket.exe xlisten-telos.exe *~ *.bak Index: xlisten.c =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/xlisten.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** xlisten.c 4 Aug 2004 01:56:13 -0000 1.2 --- xlisten.c 10 Jul 2006 17:18:15 -0000 1.3 *************** *** 11,195 **** */ - #include <stdio.h> - #include <stdlib.h> - #include <signal.h> - #include <string.h> - #include "xsensors.h" ! #include "timestamp.h" ! ! ! FILE * logfile; ! char logfilename[256] = {0}; ! Timestamp * ts; const char *g_version = "$Id$"; - /** A structure to store parsed parameter flags. */ - typedef union { - unsigned flat; - - struct { - // output display options - unsigned display_raw : 1; //!< raw TOS packets - unsigned display_parsed : 1; //!< pull out sensor readings - unsigned display_cooked : 1; //!< convert to engineering units - unsigned export_parsed : 1; //!< output comma delimited fields - unsigned display_rsvd : 12; //!< pad first word for output options - - // modes of operation - unsigned display_help : 1; - unsigned display_baud : 1; //!< baud was set by user - unsigned mode_quiet : 1; //!< suppress headers - unsigned mode_wireless : 1; //!< use wireless network headers - unsigned mode_debug : 1; //!< debug serial port - } bits; - - struct { - unsigned short output; //!< must have at least one output option - unsigned short mode; - } options; - } s_params; - - /** A variable to store parsed parameter flags. */ - s_params g_params; - - - /** - * Shut down cleanly. - */ - void - catch_sigint(int signal) { - - if (logfile != NULL && logfile != stdout) { - fflush(logfile); - fclose(logfile); - } - exit(0); - } ! ! /** ! * Extracts command line options and sets flags internally. ! * ! * @param argc Argument count ! * @param argv Argument vector ! * ! * @author Martin Turon ! * ! * @version 2004/3/10 mturon Intial version ! * @n 2004/3/12 mturon Added -b,-s,-q,-x */ ! void parse_args(int argc, char **argv) ! { ! unsigned baudrate = 0; ! g_params.flat = 0; /* default to no params set */ ! ! while (argc) { ! if ((argv[argc]) && (*argv[argc] == '-')) { ! switch(argv[argc][1]) { ! case '?': ! g_params.bits.display_help = 1; ! break; ! ! case 'q': ! xserial_set_verbose(0); ! g_params.bits.mode_quiet = 1; ! break; ! ! case 'p': ! g_params.bits.display_parsed = 1; ! break; ! ! case 'r': ! g_params.bits.display_raw = 1; ! break; ! ! case 'c': ! g_params.bits.display_cooked = 1; ! break; ! ! case 'x': ! g_params.bits.export_parsed = 1; ! break; ! ! case 'w': ! g_params.bits.mode_wireless = 1; ! int offset = XPACKET_DATASTART_WIRELESS; ! if (argv[argc][2] == '=') ! offset = atoi(argv[argc]+3); ! xpacket_set_start(offset); ! break; ! ! case 'b': ! if (argv[argc][2] == '=') { ! baudrate = xserial_set_baud(argv[argc]+3); ! g_params.bits.display_baud = 1; ! } ! break; ! ! case 's': ! if (argv[argc][2] == '=') { ! xserial_set_device(argv[argc]+3); ! } ! break; ! ! case 'o': ! if (argv[argc][2] == '=') { ! strcpy(logfilename,argv[argc]+3); ! } ! break; ! ! case 'd': ! g_params.bits.mode_debug = 1; ! break; ! } ! } ! argc--; ! } ! ! if (!g_params.bits.mode_quiet) { ! // Summarize parameter settings ! printf("xlisten Ver:%s\n", g_version); ! printf("Using params: "); ! if (g_params.bits.display_help) printf("[help] "); ! if (g_params.bits.display_baud) printf("[baud=0x%04x] ", baudrate); ! if (g_params.bits.display_raw) printf("[raw] "); ! if (g_params.bits.display_parsed) printf("[parsed] "); ! if (g_params.bits.display_cooked) printf("[cooked] "); ! if (g_params.bits.export_parsed) printf("[export] "); ! if (g_params.bits.mode_wireless) printf("[wireless] "); ! if (g_params.bits.mode_debug) { ! printf("[debug - serial dump!] \n"); ! xserial_port_dump(); ! } ! printf("\n"); ! } - if (g_params.bits.display_help) { - printf( - "\nUsage: xlisten <-?|r|p|x|c|d|q> <-b=baud> <-s=device>" - "\n -? = display help [help]" - "\n -r = raw display of tos packets [raw]" - "\n -p = parse packet into raw sensor readings [parsed]" - "\n -x = export readings in csv spreadsheet format [export]" - "\n -c = convert data to engineering units [cooked]" - "\n -d = debug serial port by dumping bytes [debug]" - "\n -b = set the baudrate [baud=#|mica2|mica2dot]" - "\n -s = set serial port device [device=com1]" - "\n -w = read wireless network packets from TOSBase" - "\n -q = quiet mode (suppress headers)" - "\n" - ); - exit(0); - } ! /* Default to displaying packets as raw, parsed, and cooked. */ ! if (g_params.options.output == 0) { ! g_params.bits.display_raw = 1; ! g_params.bits.display_parsed = 1; ! g_params.bits.display_cooked = 1; ! } } --- 11,31 ---- */ #include "xsensors.h" ! #include "args.h" + /** It's OK to make this global. */ const char *g_version = "$Id$"; ! /** TODO: Set the name of the input stream in the argument ! * parsing code, but open it in main. */ ! int g_istream; //!< Handle of input stream ! int ! xmain_get_verbose(s_params * g_params) { ! return !g_params->bits.mode_quiet; } *************** *** 203,232 **** * @version 2004/3/10 mturon Intial version */ ! int main(int argc, char **argv) ! { ! parse_args(argc, argv); ! //char c; ! //int i, partial = 0; ! int serline; ! unsigned char buffer[64]; ! ts = timestamp_new(); ! if (*logfilename == 0) { ! logfile = stdout; } else { ! logfile = fopen(logfilename,"w"); } ! signal(SIGINT, catch_sigint); - serline = xserial_port_open(); while (1) { ! if (xserial_port_read_packet(serline, buffer, XPACKET_SIZE)) continue; // ignore patial packets and packetizer frame end ! //if (g_params.bits.display_raw) xpacket_print_raw(buffer); ! ! if (g_params.bits.mode_wireless) xpacket_depacketize(buffer); if (g_params.bits.display_parsed) xpacket_print_parsed(buffer); --- 39,86 ---- * @version 2004/3/10 mturon Intial version */ ! int ! main(int argc, char **argv) { ! int length; ! unsigned char buffer[255]; ! /* A variable to store parsed parameter flags. */ ! s_params g_params; ! parse_args(argc, argv, &g_params); ! /* Stream initialization */ ! // Set STDOUT and STDERR to be line buffered, so output is not delayed. ! setlinebuf(stdout); ! setlinebuf(stderr); ! if (g_params.bits.mode_socket) { ! g_istream = xsocket_port_open(); } else { ! g_istream = xserial_port_open(); } ! /* Each different sensor board has different packet ! * layouts, which are initialized in the following. ! */ ! xpacket_initialize(); while (1) { ! if (g_params.bits.mode_sf) { ! // Serial forwarder read ! length = xsocket_read_packet(g_istream, buffer); ! } else { ! // Serial read direct, or over socket (mib600) ! length = xserial_port_read_packet(g_istream, buffer); ! } ! ! if (length < XPACKET_MIN_SIZE) continue; // ignore patial packets and packetizer frame end ! if (g_params.bits.display_time) xpacket_print_time(); ! ! if (g_params.bits.display_raw) xpacket_print_raw(buffer, length); ! ! if (g_params.bits.display_ascii) xpacket_print_ascii(buffer, length); ! ! if (!g_params.bits.mode_sf) ! xpacket_decode(buffer, length, g_params.bits.mode_framing); if (g_params.bits.display_parsed) xpacket_print_parsed(buffer); *************** *** 234,240 **** if (g_params.bits.export_parsed) xpacket_export_parsed(buffer); if (g_params.bits.display_cooked) xpacket_print_cooked(buffer); - //if (g_params.bits.display_cooked) xpacket_print_tabbed(buffer); } } --- 88,99 ---- if (g_params.bits.export_parsed) xpacket_export_parsed(buffer); + if (g_params.bits.export_cooked) xpacket_export_cooked(buffer); + + if (g_params.bits.log_cooked) xpacket_log_cooked(buffer); + if (g_params.bits.display_cooked) xpacket_print_cooked(buffer); } + + } *************** *** 249,253 **** @section usage Usage ! Usage: xlisten <-?|r|p|x|c|d|q> <-b=baud> <-s=device> @n @n -? = display help [help] --- 108,112 ---- @section usage Usage ! Usage: xlisten <-?|r|p|c|x|l|d|v|q> <-b=baud> <-s=device> <-h=size> @n @n -? = display help [help] *************** *** 256,266 **** @n -x = export readings in csv spreadsheet format [export] @n -c = convert data to engineering units [cooked] @n -d = debug serial port by dumping bytes [debug] @n -b = set the baudrate [baud=#|mica2|mica2dot] @n -s = set serial port device [device=com1] ! @n -w = read wireless network packets from TOSBase @n -q = quiet mode (suppress headers) @n - @section params Parameters --- 115,130 ---- @n -x = export readings in csv spreadsheet format [export] @n -c = convert data to engineering units [cooked] + @n -t = display time packet was received [timed] + @n -a = ascii display of tos packets [ascii] + @n -l = log data to database [logged] @n -d = debug serial port by dumping bytes [debug] @n -b = set the baudrate [baud=#|mica2|mica2dot] @n -s = set serial port device [device=com1] ! @n -i = use socket input [inet=host:port] ! @n -sf = use serial forwarder input [inet=host:port] ! @n -h = specify size of TOS_msg header [header=size] ! @n -v = display complete version information for all modules [version] @n -q = quiet mode (suppress headers) @n @section params Parameters *************** *** 280,283 **** --- 144,153 ---- This flag gives the user the ability to specify which COM port or device xlisten should use. The default port is /dev/ttyS0 or the UNIX equivalent to COM1. The given port must be passed directly after the equals sign with no spaces, i.e. -s=com3. + @subsection internet -i=hostname:port [inet] + This flag tells xlisten to attach to a virtual serial connection over a TCP/IP internet socket. Specify the hostname and port to connect in the argument. The default hostname is localhost, and the default port 9001. The keyword 'mib600' can be passed as an alias to port 10002 when connecting to that hardware device. The hostname and port must be passed directly after the equals sign with no spaces with a optional colon inbetween, i.e. -i=remote, -i=10.1.1.1:9000, -i=mymib:mib600, -i=:9002, -i=localhost:9003, or -i=stargate.xbow.com. + + @subsection serial forwarder -sf=hostname:port [inet] + This flag tells xlisten to attach to a serial forwarder connection over a TCP/IP internet socket. The hostname and port arguments are the same as the -i flag. The -sf flag tells xlisten to specifically use the TinyOS serial forwarder protocol. + @subsection raw -r [raw] Raw mode displays the actual TOS packets as a sequence of bytes as seen coming over the serial line. Sample output follows: *************** *** 338,343 **** @n 6,194,516,413,335,288,301,287 ! @subsection wireless -w [wireless] ! Passing the wireless flag tells xlisten to use a different offset when parsing packets that are being forwarded by TOSBase. This flag is required to see parsed and cooked values from motes over a wireless network. @subsection debug -d [debug] --- 208,243 ---- @n 6,194,516,413,335,288,301,287 ! @subsection timed -t [timed] ! Displays the time at which the packet was received. ! ! @n $ xlisten -t ! @n [2004/09/29 10:24:29] ! @n [2004/09/29 10:36:57] ! ! @subsection ascii -a [ascii] ! Displays the raw packet contents as ASCII characters. ! ! @subsection logging -l [logged] ! Logs incoming readings to a Postgres database. Default connection settings are: server=localhost, port=5432, user=tele, pass=tiny. ! ! @subsection header -h=size [header] ! Passing the header flag tells xlisten to use a different offset when parsing packets that are being forwarded by TOSBase. Generally this flag is not required as xlisten autodetects the header size from the AM type. When this flag is passed all xlisten will assume all incoming packets have a data payload begining after the header size offset. ! ! @subsection versions -v [versions] ! Displays complete version information for all sensorboard decoding modules within xlisten. ! ! @n $ xlisten -v ! @n xlisten Ver: Id: xlisten.c,v 1.11 2004/08/04 21:06:41 mturon Exp ! @n 87: Id: mep401.c,v 1.10 2004/08/04 21:06:41 mturon Exp ! @n 86: Id: mts400.c,v 1.15 2004/08/04 21:06:41 husq Exp ! @n 85: Id: mts400.c,v 1.15 2004/08/04 21:06:41 mturon Exp ! @n 84: Id: mts300.c,v 1.14 2004/08/04 21:06:41 husq Exp ! @n 83: Id: mts300.c,v 1.14 2004/08/04 21:06:41 mturon Exp ! @n 82: Id: mts101.c,v 1.5 2004/08/04 21:06:41 husq Exp ! @n 81: Id: mda300.c,v 1.4 2004/08/04 17:15:22 jdprabhu Exp ! @n 80: Id: mda500.c,v 1.11 2004/08/04 21:06:41 husq Exp ! @n 03: Id: mep500.c,v 1.3 2004/08/04 21:06:41 mturon Exp ! @n 02: Id: mts510.c,v 1.6 2004/08/04 21:06:41 husq Exp ! @n 01: Id: mda500.c,v 1.11 2004/08/04 21:06:41 abroad Exp @subsection debug -d [debug] Index: xpacket.c =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/xpacket.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** xpacket.c 4 Aug 2004 01:56:13 -0000 1.5 --- xpacket.c 10 Jul 2006 17:18:15 -0000 1.6 *************** *** 12,18 **** --- 12,62 ---- #include "xsensors.h" + #include "xpacket.h" + + #include "ucb/ucb.h" static unsigned g_datastart = XPACKET_DATASTART; + static XPacketHandler *g_packetTable[512]; + + /** + * Adds all packet handlers for known sensorboards. + * + * @author Martin Turon + * @version 2004/7/28 mturon Intial version + */ + void xpacket_initialize() + { + health_initialize(); /* From amtypes/health.c */ + + mica2_initialize(); /* From boards/mica2.c */ + mica2dot_initialize(); /* From boards/mica2.c */ + micaz_initialize(); /* From boards/mica2.c */ + + surge_initialize(); /* From boards/surge.c */ + + mda300_initialize(); /* From boards/mda300.c */ + mda400_initialize(); /* From boards/mda500.c */ + mda500_initialize(); /* From boards/mda500.c */ + + mts300_initialize(); /* From boards/mts300.c */ + mts310_initialize(); /* From boards/mts300.c */ + + mts400_initialize(); /* From boards/mts400.c */ + //mts420_initialize(); /* From boards/mts400.c */ + + + mts510_initialize(); /* From boards/mts510.c */ + mts101_initialize(); /* From boards/mts101.c */ + mep500_initialize(); /* From boards/mep500.c */ + mep401_initialize(); /* From boards/mep401.c */ + ggbacltst_initialize(); /* From boards/ggbacltst.c */ + msp410_initialize(); /* From boards/msp410.c */ + + xtutorial_initialize(); /* From boards/xtutorial.c */ + + ucb_initialize(); + } + /** * Set the offset to the sensor data payload within the TOS packet. *************** *** 25,29 **** void xpacket_set_start(unsigned offset) { ! g_datastart = offset; } --- 69,78 ---- void xpacket_set_start(unsigned offset) { ! g_datastart = offset; ! } ! ! int xpacket_get_start() ! { ! return g_datastart; } *************** *** 34,51 **** * @version 2004/4/07 mturon Intial version */ ! void xpacket_depacketize(unsigned char *tos_packet) { ! int i = 0, o = 2; // index and offset ! while(i < XPACKET_SIZE) { ! // Handle escape characters ! if (tos_packet[o] == XPACKET_ESC) { ! tos_packet[i++] = tos_packet[++o] ^ 0x20; ! ++o; ! } else { ! tos_packet[i++] = tos_packet[o++]; ! } ! } } /** * Returns a pointer into the packet to the data payload. --- 83,136 ---- * @version 2004/4/07 mturon Intial version */ ! void xpacket_unframe(unsigned char *tos_packet, int len) { ! int i = 0, o = 2; // index and offset ! ! while(i < len) { ! // Handle escape characters ! if (tos_packet[o] == XPACKET_ESC) { ! tos_packet[i++] = tos_packet[++o] ^ 0x20; ! ++o; ! } else { ! tos_packet[i++] = tos_packet[o++]; ! } ! } ! } ! ! /** ! * Detects if incoming packet is UART framed and unframes if needed. ! * ! * @author Martin Turon ! * @version 2004/8/05 mturon Intial version ! */ ! void xpacket_decode(unsigned char *tos_packet, int len, int mode) ! { ! if (len < 2) return; ! ! switch (mode) { ! case 0: ! // Automatic detection of framing ! switch (tos_packet[1]) { ! // case AMTYPE_XUART: // temp hack for FEATURE_UART_DEBUG ! case XPACKET_ACK: ! case XPACKET_W_ACK: ! case XPACKET_NO_ACK: ! xpacket_unframe(tos_packet, len); ! break; ! } ! break; ! ! case 1: ! // Framed packet ! xpacket_unframe(tos_packet, len); ! break; ! ! default: ! // Unframed packet ! break; ! } } + /** * Returns a pointer into the packet to the data payload. *************** *** 58,230 **** XbowSensorboardPacket *xpacket_get_sensor_data(unsigned char *tos_packet) { ! return (XbowSensorboardPacket *)(tos_packet + g_datastart); } /** ! * Display a raw packet. * - * @param packet The TOS packet as raw bytes from the serial port - * * @author Martin Turon ! * @version 2004/3/10 mturon Intial version */ ! void xpacket_print_raw(unsigned char *packet) { ! int i, cnt = XPACKET_SIZE; ! for (i=0; i<cnt; i++) { ! printf("%02x", packet[i]); ! } ! printf("\n"); } /** ! * Display a parsed packet as exportable data -- comma delimited text. * - * @param packet The TOS packet as raw bytes from the serial port - * * @author Martin Turon ! * @version 2004/3/12 mturon Intial version */ ! void xpacket_export_parsed(unsigned char *tos_packet) { ! int i; ! uint16_t *packet = (uint16_t *)xpacket_get_sensor_data(tos_packet); ! packet += 2; // Ignore sensorboard_id and packet_id ! ! for (i=0; i<8; i++) { ! if (i>0) printf(","); ! printf("%d",packet[i]); ! } ! printf("\n"); } /** ! * Display a parsed packet as raw ADC values for each sensor on the board. * - * @param packet The TOS packet as raw bytes from the serial port - * * @author Martin Turon ! * @version 2004/3/10 mturon Intial version */ ! void xpacket_print_parsed(unsigned char *tos_packet) { ! XbowSensorboardPacket *packet = xpacket_get_sensor_data(tos_packet); ! ! switch(packet->packet_id) { ! case XPACKET_TEXT_MSG: ! packet->reserved2 = '\0'; ! printf("msg from id=%d: %s\n", packet->node_id, ! (char *)packet->data); ! return; ! } ! ! switch(packet->sensorboard_id) { ! case XTYPE_MDA500: ! mda500_print_raw(packet); ! break; ! ! case XTYPE_MDA400: ! mda400_print_raw(packet); ! break; ! ! case XTYPE_MDA300: ! mda300_print_raw(packet); ! break; ! ! case XTYPE_MTS300: ! mts300_print_raw(packet); ! break; ! ! case XTYPE_MTS310: ! mts310_print_raw(packet); ! break; ! case XTYPE_MTS400: ! mts400_print_raw(packet); ! break; ! case XTYPE_MTS420: ! mts420_print_raw(packet); ! break; - case XTYPE_MTS510: - mts510_print_raw(packet); - break; - - case XTYPE_MTS101: - mts101_print_raw(packet); - break; - - case XTYPE_MEP500: - mep500_print_raw(packet); - break; - - case XTYPE_MEP401: - mep401_print_raw(packet); - break; ! /* More sensor boards go here... */ ! } } ! // This typedef eventually gets moved to a header file. ! typedef struct _packetprinter Packetprinter; ! // Keep this as incomplete type to eliminate unnecessary ! // meddling. The definition can be expanded to ! // include more than cooked. Also, if the arguments change ! // to the print function, it's relatively easy to change. ! struct _packetprinter { ! unsigned int type; ! void (*print_cooked)(XbowSensorboardPacket * packet); ! }; ! // Add XTYPE and function for cooking up output anywhere ! // before the last {0,NULL} entry. You're done. ! Packetprinter packet_printer [] = { ! {XTYPE_MDA500,mda500_print_cooked}, ! {XTYPE_MDA400,mda400_print_cooked}, ! {XTYPE_MDA300,mda300_print_cooked}, ! {XTYPE_MTS300,mts300_print_cooked}, ! {XTYPE_MTS310,mts310_print_cooked}, ! {XTYPE_MTS400,mts400_print_cooked}, ! {XTYPE_MTS420,mts420_print_cooked}, ! {XTYPE_MTS510,mts510_print_cooked}, ! {XTYPE_MTS101,mts101_print_cooked}, ! {XTYPE_MEP500,mep500_print_cooked}, ! {XTYPE_MEP401,mep401_print_cooked}, ! {0 ,NULL} ! }; ! void xpacket_print_cooked_new(unsigned char *tos_packet) { ! XbowSensorboardPacket *packet = xpacket_get_sensor_data(tos_packet); ! unsigned int sensorboard_id = packet->sensorboard_id; ! int i = 0; ! ! switch(packet->packet_id) { ! case XPACKET_TEXT_MSG: ! packet->reserved2 = '\0'; ! printf("MSG from id=%d: %s\n\n", packet->node_id, ! (char*)packet->data); ! return; ! } ! ! // Since the array of printing functions is static ! // data declared above, the while loop has almost the ! // same overhead as the switchyard. ! while (packet_printer[i].type != 0) { ! if (packet_printer[i].type == sensorboard_id) { ! packet_printer[i].print_cooked(packet); ! return; ! } ! i++; ! } ! fprintf(stderr,"No print function defined for this sensor board.\n"); } --- 143,340 ---- XbowSensorboardPacket *xpacket_get_sensor_data(unsigned char *tos_packet) { ! int am_type = tos_packet[XPACKET_TYPE]; ! int datastart = g_datastart; ! ! if (datastart == XPACKET_DATASTART) { ! switch (am_type) { ! case AMTYPE_XUART: ! case AMTYPE_XSENSOR: ! case AMTYPE_SURGE_MSG: ! case AMTYPE_HEALTH: ! datastart = XPACKET_DATASTART_STANDARD; ! break; ! ! case AMTYPE_XDEBUG: ! case AMTYPE_XMULTIHOP: ! datastart = XPACKET_DATASTART_MULTIHOP; ! break; ! ! default: ! // Handle firebug AM_TYPES here? ! return NULL; ! } ! } ! ! return (XbowSensorboardPacket *)(tos_packet + datastart); } /** ! * Prints out standard packet types for all sensorboards. ! * @return true when packet is to be ignored * * @author Martin Turon ! * @version 2004/8/05 mturon Intial version */ ! int xpacket_print_common(XbowSensorboardPacket *packet) { ! if (!packet) return 1; ! ! switch(packet->packet_id) { ! case XPACKET_TEXT_MSG: ! packet->terminator = '\0'; ! printf("MSG from id=%d: %s\n\n", packet->node_id, ! (char *)packet->data); ! return 1; ! } ! ! return 0; } /** ! * Adds a packet handler for a given sensorboard. * * @author Martin Turon ! * @version 2004/7/28 mturon Intial version */ ! void xpacket_add_type(XPacketHandler *handler) { ! if (!handler) return; ! g_packetTable[handler->type] = handler; } /** ! * Adds a packet handler for the given AM packet type. * * @author Martin Turon ! * @version 2004/7/28 mturon Intial version */ ! void xpacket_add_amtype(XPacketHandler *handler) { ! if (!handler) return; ! g_packetTable[handler->type + XPACKET_AM_TABLE] = handler; ! } ! /** ! * Print out the timestamp of when the packet was heard. ! * ! * @author Martin Turon ! * @version 2004/9/27 mturon Intial version ! */ ! void xpacket_print_timestamp() ! { ! char timestring[TIMESTRING_SIZE]; ! Timestamp *time_now = timestamp_new(); ! timestamp_get_string(time_now, timestring); ! printf("%s", timestring); ! timestamp_delete(time_now); ! } ! /** ! * Print out the timestamp of when the packet was heard. ! * ! * @author Martin Turon ! * @version 2004/9/27 mturon Intial version ! */ ! void xpacket_print_time() ! { ! printf("["); ! xpacket_print_timestamp(); ! printf("]\n"); ! } ! /** ! * Print out the version information for all the packet handlers. ! * ! * @author Martin Turon ! * @version 2004/7/28 mturon Intial version ! */ ! void xpacket_print_versions() ! { ! int i = 256; ! printf("XSensor boards\n"); ! while (--i >= 0) { ! if ((g_packetTable[i]) && (g_packetTable[i]->version)) ! printf(" %02x: %s\n", ! g_packetTable[i]->type, g_packetTable[i]->version); ! } ! i = 512; ! printf("AM packet types\n"); ! while (--i >= XPACKET_AM_TABLE) { ! if ((g_packetTable[i]) && (g_packetTable[i]->version)) ! printf(" %02x: %s\n", ! g_packetTable[i]->type, g_packetTable[i]->version); ! } } + XPacketHandler *xsensor_get_handler(uint8_t type_id, int table) + { + int i = 256, entry; + while (--i >= 0) { + entry = table + i; + if (!(g_packetTable[entry])) continue; + if (g_packetTable[entry]->type == type_id) + return g_packetTable[entry]; + } + return NULL; + } ! XPacketHandler *xpacket_get_handler(char *tos_packet) ! { ! unsigned char am_type = tos_packet[XPACKET_TYPE]; ! switch (am_type) { ! case AMTYPE_XMULTIHOP: ! case AMTYPE_XUART: ! case AMTYPE_XDEBUG: ! case AMTYPE_XSENSOR: { ! XbowSensorboardPacket *packet; ! packet = xpacket_get_sensor_data(tos_packet); ! if (xpacket_print_common(packet)) { ! fprintf(stderr, ! "xpacket_get_handler error1: no packet handler for board id 0x%02x\n", ! packet->board_id); ! return NULL; ! } ! return xsensor_get_handler(packet->board_id, XPACKET_BOARD_TABLE); ! } + case AMTYPE_HEALTH: + case AMTYPE_SURGE_MSG: + return xsensor_get_handler(am_type, XPACKET_AM_TABLE); ! default: ! //Handle firebug AM_TYPES here. ! return (XPacketHandler*)fb_get_packet_handler(am_type); ! break; ! } ! fprintf(stderr, "xpacket_get_handler error2: no packet handler for tos type 0x%02x\n", ! am_type); + return NULL; + } ! /** ! * Display a parsed packet as raw ADC values for each sensor on the board. ! * ! * @param packet The TOS packet as raw bytes from the serial port ! * ! * @author Martin Turon ! * @version 2004/3/10 mturon Intial version ! */ ! void xpacket_print_parsed(unsigned char *tos_packet) { ! XPacketHandler *handler = xpacket_get_handler(tos_packet); ! if (!handler) return; ! XbowSensorboardPacket *packet = xpacket_get_sensor_data(tos_packet); ! if ((packet) && (handler->print_parsed)) { ! return handler->print_parsed(packet); ! } else { ! fprintf(stderr, "xpacket_print_parsed error: no packet handler for board id 0x%02x\n", ! packet->board_id); ! return; ! } } *************** *** 239,331 **** void xpacket_print_cooked(unsigned char *tos_packet) { ! XbowSensorboardPacket *packet = xpacket_get_sensor_data(tos_packet); ! ! switch(packet->packet_id) { ! case XPACKET_TEXT_MSG: ! packet->reserved2 = '\0'; ! printf("MSG from id=%d: %s\n\n", packet->node_id, ! (char *)packet->data); ! return; ! } ! ! switch(packet->sensorboard_id) { ! case XTYPE_MDA500: ! mda500_print_cooked(packet); ! break; ! ! case XTYPE_MDA400: ! mda400_print_cooked(packet); ! break; ! ! case XTYPE_MDA300: ! mda300_print_cooked(packet); ! break; ! ! case XTYPE_MTS300: ! mts300_print_cooked(packet); ! break; ! case XTYPE_MTS310: ! mts310_print_cooked(packet); ! break; ! case XTYPE_MTS400: ! mts400_print_cooked(packet); ! break; ! case XTYPE_MTS420: ! mts420_print_cooked(packet); ! break; ! case XTYPE_MTS510: ! mts510_print_cooked(packet); ! break; ! ! case XTYPE_MTS101: ! mts101_print_cooked(packet); ! break; ! ! case XTYPE_MEP500: ! mep500_print_cooked(packet); ! break; ! case XTYPE_MEP401: ! mep401_print_cooked(packet); ! break; ! /* More sensor boards go here... */ ! } } /** ! * Display a packet as cooked values in engineering units. * * @param packet The TOS packet as raw bytes from the serial port * * @author Martin Turon ! * @version 2004/3/11 mturon Intial version */ ! void xpacket_print_tabbed(unsigned char *tos_packet) { ! XbowSensorboardPacket *packet = xpacket_get_sensor_data(tos_packet); - /* - switch(packet->packet_id) { - case XPACKET_TEXT_MSG: - packet->reserved2 = '\0'; - printf("MSG from id=%d: %s\n\n", packet->node_id, - (char *)packet->data); - return; - } - */ ! switch(packet->sensorboard_id) { ! case XTYPE_MTS420: ! //mts420_print_cooked(packet); ! break; ! /* More sensor boards go here... */ ! } } --- 349,477 ---- void xpacket_print_cooked(unsigned char *tos_packet) { ! XPacketHandler *handler = xpacket_get_handler(tos_packet); ! if (!handler) return; ! XbowSensorboardPacket *packet = xpacket_get_sensor_data(tos_packet); ! if ((packet) && (handler->print_cooked)) { ! return handler->print_cooked(packet); ! } else { ! fprintf(stderr, "xpacket_print_cooked error: no packet handler for board id 0x%02x\n", ! packet->board_id); ! return; ! } ! } ! /** ! * Display a packet as cooked values in engineering units. ! * ! * @param packet The TOS packet as raw bytes from the serial port ! * ! * @author Martin Turon ! * @version 2004/3/11 mturon Intial version ! */ ! void xpacket_export_cooked(unsigned char *tos_packet) ! { ! XPacketHandler *handler = xpacket_get_handler(tos_packet); ! if (!handler) return; ! XbowSensorboardPacket *packet = xpacket_get_sensor_data(tos_packet); ! if ((packet) && (handler->export_cooked)) { ! return handler->export_cooked(packet); ! } else { ! fprintf(stderr, "xpacket_export_cooked error: no packet handler for board id 0x%02x\n", ! packet->board_id); ! return; ! } ! } ! /** ! * Log a packet as cooked values in engineering units into a database. ! * ! * @param packet The TOS packet as raw bytes from the serial port ! * ! * @author Martin Turon ! * @version 2004/7/28 mturon Intial version ! */ ! void xpacket_log_cooked(unsigned char *tos_packet) ! { ! XPacketHandler *handler = xpacket_get_handler(tos_packet); ! if (!handler) return; ! XbowSensorboardPacket *packet = xpacket_get_sensor_data(tos_packet); ! if ((packet) && (handler->log_cooked)) { ! return handler->log_cooked(packet); ! } else { ! fprintf(stderr, "xpacket_log_cooked error: no packet handler for board id 0x%02x\n", ! packet->board_id); ! return; ! } ! } ! /** ! * Display a packet as ascii. ! * ! * @param packet The TOS packet as raw bytes from the serial port ! * ! * @author Martin Turon ! * @version 2004/9/29 mturon Intial version ! */ ! void xpacket_print_ascii(unsigned char *packet, int len) ! { ! int i; ! for (i=0; i<len; i++) { ! printf("%c", packet[i]); ! } ! printf("\n", len); } /** ! * Display a raw packet. * * @param packet The TOS packet as raw bytes from the serial port * * @author Martin Turon ! * @version 2004/3/10 mturon Intial version */ ! void xpacket_print_raw(unsigned char *packet, int len) { ! int i; ! for (i=0; i<len; i++) { ! printf("%02x", packet[i]); ! } ! printf(" [%i]\n", len); ! } ! /** ! * Display a parsed packet as exportable data -- comma delimited text. ! * ! * @param packet The TOS packet as raw bytes from the serial port ! * ! * @author Martin Turon ! * @version 2004/7/28 mturon Intial version ! */ ! void xpacket_export_parsed(unsigned char *tos_packet) ! { ! int i=0; ! uint8_t *packet = (uint8_t *)xpacket_get_sensor_data(tos_packet); ! if (xpacket_print_common((XbowSensorboardPacket *)packet)) return; ! TosMsg *tosmsg = (TosMsg *)tos_packet; ! MultihopMsg *mhop = (MultihopMsg *)(tos_packet + sizeof(TosMsg)); ! xpacket_print_timestamp(); ! printf (", %u,%u,%u, %u,%u,%u, ", ! tosmsg->am_type, tosmsg->group, tosmsg->length, ! mhop->nodeid, mhop->seqno, mhop->hops ! ); ! ! packet = (uint8_t *)mhop; ! // i=2 --> skip board_id/packet_id, node/parent ! for (i=0; i<tosmsg->length; i++) { // include CRC ! printf("%u",packet[i]); ! printf(","); ! } ! // uint16_t crc = *(uint16_t *)((char *)mhop + tosmsg->length); ! // printf(" %u\n",crc); } Index: genc.pm =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/genc.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** genc.pm 2 Aug 2004 23:07:01 -0000 1.4 --- genc.pm 10 Jul 2006 17:18:15 -0000 1.5 *************** *** 28,268 **** ## Parts of this code were written for the NSF_ITR funded ## firebug project. true; sub gen() { - my ($classname, @spec) = @_; ! require migdecode; ! &decode(@spec); ! &usage("no classname name specified") if !defined($java_classname); ! $java_extends = "net.tinyos.message.Message" if !defined($java_extends); ! # See if name has a package specifier ! if ($java_classname =~ /(.*)\.([^.]*)$/) { ! $package = $1; ! $java_classname = $2; ! } ! $I = " "; ! $smallskip = "\n\n"; ! $medskip = "\n\n\n\n"; ! $bigskip = "\n\n\n\n\n\n"; ! print "/**\n"; ! print " * This class is automatically generated by mig. DO NOT EDIT THIS FILE.\n"; ! print " * This code implements C interface to the '$java_classname'\n"; ! print " * message type.\n"; ! print " */\n\n"; ! print "#include <stdio.h>\n"; ! print "#include <stdlib.h>\n"; ! print "#include <memory.h>\n"; ! print $medskip; - print "/** Private header is programmer specified for handling\n"; - print " * conversion functions, etc.\n */\n"; - print "//#include \"$java_classname\_private.h\"\n"; ! print $medskip; ! print "/** These need to be moved to a header file. */\n"; ! print "typedef struct _$java_classname $java_classname;\n"; ! print "typedef struct _XbowSensorboardPacket XbowSensorboardPacket;\n"; ! print $smallskip; ! print "// This struct is defined to keep gcc happy while the module\n"; ! print "// is under development. At some point in the near future, a\n"; ! print "// a convention for passing arguments into the functions will\n"; ! print "// have to be defined.\n"; ! print "struct _XbowSensorboardPacket {\n"; ! print " unsigned char data[29];\n"; ! print "};\n"; ! print $medskip; ! # print "struct _$java_classname {\n"; ! # for (@fields) { ! # ($field, $type, $bitlength, $offset, $amax, $abitsize, $aoffset) = @{$_}; ! # ($ctype, $java_access, $arrayspec) = &cbasetype($type, $bitlength, 0); ! # if ($field =~ /(.*)\.([^.]*)$/) { ! # $struct = $1; ! # $member = $2; ! # } ! # push(@format, &formatstring($type, $bitlength, 0)); ! # $field =~ s/\./_/g; ! # printf "$I$ctype $field;\n"; ! # } ! # print "};"; ! &gen_struct(); ! print $medskip; ! &gen_get_set(); ! print $medskip; ! ## Default behavior is to return the input as output. ! ## User is responsible for "cooking" the data. ! for (@fields) { ! ($field, $type, $bitlength, $offset, $amax, $abitsize, $aoffset) = @{$_}; ! ($ctype, $java_access, $arrayspec) = &cbasetype($type, $bitlength, 0); ! $field =~ s/\./_/g; ! print "/** \@brief Default behavior is to return the input as output.\n"; ! print " * User is responsible for \"cooking\" the data.\n */\n"; ! print "static $ctype\n"; ! print "$field\_convert($ctype $field) {\n"; ! print " return $field;\n"; ! print "}\n\n"; ! } ! ## Function for cooking whole packet. Fields are ! ## by calling the individual "cook" functions for ! ## each member. ! print "void\n"; ! print "$java_classname\_cook\_packet($java_classname * userdata) {\n"; ! for (@fields) { ! ($field, $type, $bitlength, $offset, $amax, $abitsize, $aoffset) = @{$_}; ! ($ctype, $java_access, $arrayspec) = &cbasetype($type, $bitlength, 0); ! $field =~ s/\./_/g; ! print " userdata->$field = $field\_convert(userdata->$field);\n"; ! } print "}\n\n"; - print $medskip; ! print "//Format string can be generated automatically,\n"; ! print "//then the delimiters added later: @format\n"; - print $medskip; - ## In the code for the xlisten boards, the conversions are - ## in the print statement. If the conversions were done - ## before the print statement, then the conversion function - ## becomes the only function needing to be stubbed. The - ## runtime differences are neglible. ! print "/** User has to fill in any conversion code\n"; ! print " * necessary for processing.\n"; ! print " */\n"; ! print "$java_classname * convert(char * data) {\n"; ! print " // Just to keep gcc happy.\n"; ! print " return ($java_classname*)data;\n"; ! print "}\n"; ! print $medskip; ! ## Start printing output functions. ! print "/** Print the bytes of the packet. */\n"; ! print "void $java_classname\_print\_raw (XbowSensorboardPacket *packet) {\n\n"; ! print "$I$java_classname * userdata = ($java_classname*)packet->data;\n"; ! print "}\n\n"; ! print "/** Print typed output. */\n"; ! print "void $java_classname\_print\_cooked (XbowSensorboardPacket *packet) {\n\n"; ! print "$I$java_classname * userdata = ($java_classname*)packet->data;\n"; ! print "}\n\n"; ! print "/** Print cooked with tabs. */\n"; ! print "void $java_classname\_print\_tabbed (XbowSensorboardPacket *packet) {\n\n"; ! print "$I$java_classname * userdata = ($java_classname*)packet->data;\n"; ! print "}\n\n"; ! # print "package $package;\n\n" if $package; - # print "public class $java_classname extends $java_extends {\n\n"; ! print "/** The default size of this message type in bytes. */\n"; ! print "static int DEFAULT_MESSAGE_SIZE = $size;\n\n"; ! print "/** The Active Message type associated with this message. */\n"; ! print "static int AM_TYPE = $amtype;\n\n"; - print "/** If incomplete types are used, we need to provide a way\n"; - print " * to manage memory.\n"; - print " */\n"; - print "$java_classname *\n"; - print "$java_classname\_new() {\n"; - print " $java_classname * userdata = ($java_classname*)malloc(sizeof($java_classname));\n"; - print " memset((void*)userdata,0xda,sizeof($java_classname));\n"; - print " return userdata;\n"; - print "}\n"; ! print $medskip; ! print "void\n"; ! print "$java_classname\_delete($java_classname * userdata) {\n"; ! print " memset((void*)userdata,0xdd,sizeof($java_classname));\n"; ! print " free(userdata);\n"; ! print "}\n"; } sub gen_struct() { ! print "struct _$java_classname {\n"; ! ## todo move this to sub print_msg_struct(). ! for (@fields) { ! ($field, $type, $bitlength, $offset, $amax, $abitsize, $aoffset) = @{$_}; ! ($ctype, $java_access, $arrayspec) = &cbasetype($type, $bitlength, 0); ! # This is clunky but will work. A better way to do it would be to store ! # the nested struct internally in the field array somehow. ! # Maybe a perl guru can figure that out. ! # What needs to be done is to find one of these, then ! # store it until all the members written out, ! # then print it. ! if ($field =~ /(.*)\.([^.]*)$/) { ! $struct = $1; ! $member = $2; ! #print STDERR $struct;#.", "$member."\n"; ! } ! ## Gets an array of format specifiers useful in *print* functions ! ## in libc. the @format array can be passed ! push(@format, &formatstring($type, $bitlength, 0)); ! $field =~ s/\./_/g; ! printf "$I$ctype $field;\n"; ! } ! print "};"; } sub gen_get_set() { ! ## The get/set code is more to investigate the mechanics of ! ## the autogeneration of structs. It's probably more useful ! ## use the defined type directly, at least for now. ! ## ! ## todo move this to sub_get_set_methods() ! for (@fields) { ! ($field, $type, $bitlength, $offset, $amax, $abitsize, $aoffset) = @{$_}; ! ($ctype, $java_access, $arrayspec) = &cbasetype($type, $bitlength, 0); ! $field =~ s/\./_/g; ! print "void\n"; ! print "$java_classname\_set\_$field($java_classname * userdata, $ctype $field) {\n"; ! print " userdata->$field = $field;\n"; ! print "}\n\n"; ! #### Get methods ! print "$ctype\n"; ! print "$java_classname\_get\_$field($java_classname * userdata) {\n"; ! print " return userdata->$field;\n"; ! print "}\n\n"; ! } } --- 28,497 ---- ## Parts of this code were written for the NSF_ITR funded ## firebug project. + ## + ## Code based on genjava.pm written by David Gay (?) + ## authors David Gay (? + others?), Dave Doolin true; + + + sub gen() { ! my %struct_hash; ! my ($tmp,$fmtstr); ! my ($classname, @spec) = @_; ! require migdecode; ! &decode(@spec); ! &usage("no classname name specified") if !defined($java_classname); ! $java_extends = "net.tinyos.message.Message" if !defined($java_extends); ! # See if name has a package specifier ! if ($java_classname =~ /(.*)\.([^.]*)$/) { ! $package = $1; ! $java_classname = $2; ! $structname = $java_classname."P"; ! } ! $I = " "; ! $smallskip = "\n\n"; ! $medskip = "\n\n\n\n"; ! $bigskip = "\n\n\n\n\n\n"; + print "/**\n"; + print " * This class is automatically generated by mig. DO NOT EDIT THIS FILE.\n"; + print " * This code implements C interface to the '$structname'\n"; + print " * message type.\n"; + print " */\n\n"; + print "#include <stdio.h>\n"; + print "#include <stdlib.h>\n"; + print "#include <memory.h>\n"; ! print $medskip; ! print "/** Private header is programmer specified for handling\n"; ! print " * conversion functions, etc.\n */\n"; ! print "//#include \"$structname\_private.h\"\n"; ! print "/** Not the best way to handle xbow dependencies. */\n"; ! print "#ifdef TELOS_MOTE\n"; ! print "#include \"../xdb.h\"\n"; ! print "#include \"../xsensors.h\"\n"; ! print "#endif\n"; ! print $medskip; ! print "/** These need to be moved to a header file. */\n"; ! print "typedef struct _$structname $structname;\n"; ! print "#ifndef TELOS_MOTE\n"; ! print "typedef struct _XbowSensorboardPacket XbowSensorboardPacket;\n"; ! print "#endif\n"; ! print $medskip + print "/** The Active Message type associated with this message. */\n"; + print "//static const int AM_TYPE = $amtype;\n\n"; + print "//#define AM_TYPE $amtype\n\n"; ! print $smallskip; ! print "// This struct is defined to keep gcc happy while the module\n"; ! print "// is under development. At some point in the near future, a\n"; ! print "// a convention for passing arguments into the functions will\n"; ! print "// have to be defined.\n"; ! print "struct _XbowSensorboardPacket {\n"; ! print " unsigned char data[29];\n"; ! print "};\n"; + print $medskip; + # print "struct _$structname {\n"; + # for (@fields) { + # ($field, $type, $bitlength, $offset, $amax, $abitsize, $aoffset) = @{$_}; + # ($ctype, $java_access, $arrayspec) = &cbasetype($type, $bitlength, 0); + # if ($field =~ /(.*)\.([^.]*)$/) { + # $struct = $1; + # $member = $2; + # } + # push(@format, &formatstring($type, $bitlength, 0)); + # $field =~ s/\./_/g; + # printf "$I$ctype $field;\n"; + # } + # print "};"; ! ! ! print $medskip; ! ! ! &gen_struct(); ! print $medskip; ! ! &gen_get_set(); ! print $medskip; ! ! print "//Format string generated automatically,\n"; ! $tmp = @format[$#format-1]; ! $tmp =~ s/,//g; ! $fmtstr = "@format[0..($#format-1)] $tmp"; ! #print "Fmt: $fmtstr\n"; ! print "//static char formatstring[] = \"@format[0..($#format-1)] $tmp\";\n\n\n";... [truncated message content] |
From: David M. D. <do...@us...> - 2006-07-10 17:17:55
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/ucb In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv19861 Added Files: ucb.h Log Message: updating from beta. --- NEW FILE: ucb.h --- /** Offset of payload relative to surge packet. */ #define SURGE_RELATIVE_OFFSET 0 // Match the xbow stuff for now. #define XPACKET_DATASTART_UCB 12 //!< Offset to Fireworks data #define XPACKET_DATASTART_FIREWORKS 10 //!< Offset to Fireworks data #define XPACKET_DATASTART_LINKEST 18 //!< Offset to Fireworks data // This is all from xbow code, but it needs to be // cleaned up a lot. typedef void (*packet_printer)(void * packet); typedef union BoardFlags { unsigned flat; struct { unsigned table_init : 1; //!< whether logging table is validated }; } BoardFlags; typedef struct PacketHandler { uint8_t type; //!< sensorboard id char * version; //!< CVS version string of boards source file packet_printer print_parsed; packet_printer print_cooked; packet_printer export_parsed; packet_printer export_cooked; packet_printer log_cooked; BoardFlags flags; //!< flags for board specific management } PacketHandler; /* typedef struct dispatch_table { uint8_t am_type; PacketHandler * ph; } dispatch_table_t; */ void LinkMsgP_initialize (void); void SurgeMsgP_initialize (void); void LinkEstimatorMsgP_initialize (void); |
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] |
From: David M. D. <do...@us...> - 2006-07-10 17:16:37
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/boards In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv19374 Added Files: fireboard.h Log Message: updating from beta. --- NEW FILE: fireboard.h --- #ifndef FB_FIREBOARD_H #define FB_FIREBOARD_H #include <NMEA.h> #include "../xdb.h" #include "../xsensors.h" void fb_pg_log_gga_data (XbowSensorboardPacket *packet); /** * When the schema changes, or for whatever other * reason, the firebug tables may need to be recreated * from scratch. */ void fb_pg_recreate_tables (void); #endif /* FB_FIREBOARD_H */ |
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/boards In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv19309 Added Files: LinkEstimatorMsg.c Makefile SurgeMsg.c fireboard.c ggbacltst.c linkmsg.c mica2.c mica2dot.c micaz.c msp410.c pg_test.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 testlink.c xtutorial.c Log Message: updating from beta. --- NEW FILE: micaz.c --- /** * Handles parsing of micaz packets. * * @file micaz.c * @author Hu Siquan * @version 2004/4/12 husq Initial version * * Refer to: * - Xbow MTS/MDA Sensor and DataAcquistion Manual * * Copyright (c) 2004 Crossbow Technology, Inc. All rights reserved. * * $Id: micaz.c,v 1.1 2006/07/10 17:16:11 doolin Exp $ */ #include <math.h> #include "../xsensors.h" /** micaz XMesh packet 1 -- contains serialID information */ typedef struct SerialIDData { uint8_t id[8]; } __attribute__ ((packed)) SerialIDData; typedef struct ConfigData { uint16_t nodeid; uint8_t group; uint8_t rf_power; uint8_t rf_channel; } __attribute__ ((packed)) ConfigData; int table_micaz_power[8][2] ={{31,0},{27,-1},{23,-3},{19,-5},{15,-7},{11,-10},{7,-15},{3,-25}}; int getDBMfromRTP(int table[][2], int index) { int i; for(i=0;i<8;i++){ if (table[i][0] == index) return table[i][1]; } return 0xff; } extern XPacketHandler micaz_packet_handler; /** micaz Specific outputs of raw readings within an XBowSensorboardPacket */ void micaz_print_raw(XbowSensorboardPacket *packet) { switch(packet->packet_id){ case 1:{ SerialIDData *data = (SerialIDData *)packet->data; printf("micaz id=%02x SerialID = %02x%02x%02x%02x%02x%02x%02x%02x\n", packet->node_id, data->id[0], data->id[1],data->id[2],data->id[3], data->id[4],data->id[5], data->id[6],data->id[7]); break; } case 2:{ ConfigData *data = (ConfigData *)packet->data; printf("micaz config parameters: nodeid=%04x groupid=%02x rf_power=%02x rf_channel=%02x\n", data->nodeid, data->group,data->rf_power,data->rf_channel); break; } default: break; } } /** micaz specific display of converted readings from XBowSensorboardPacket */ void micaz_print_cooked(XbowSensorboardPacket *packet) { switch(packet->packet_id){ case 1:{ SerialIDData *data = (SerialIDData *)packet->data; printf("MicaZ id=%02x SerialID information: \n" " CRC code = %02x\n" " Serial Number = %02x%02x%02x%02x%02x%02x\n" " Family Code = %02x\n", packet->node_id, data->id[7],data->id[6],data->id[5], data->id[4], data->id[3],data->id[2],data->id[1],data->id[0]); break; } case 2:{ ConfigData *data = (ConfigData *)packet->data; printf("MicaZ Config parameters: \n" " nodeid=%d groupid=%d " " RF Power=%ddbm; RF Channel=%dMHz\n", data->nodeid, data->group, getDBMfromRTP(table_micaz_power,data->rf_power),2405+5*(data->rf_channel-11)); break; } default: break; } printf("\n"); } /** * Logs raw readings to a Postgres database. * * @author Martin Turon * * @version 2004/7/28 mturon Initial revision * */ void micaz_log_raw(XbowSensorboardPacket *packet) { } XPacketHandler micaz_packet_handler = { XTYPE_MICAZ, "$Id: micaz.c,v 1.1 2006/07/10 17:16:11 doolin Exp $", micaz_print_raw, micaz_print_cooked, micaz_print_raw, micaz_print_cooked, micaz_log_raw }; void micaz_initialize() { xpacket_add_type(&micaz_packet_handler); } --- NEW FILE: SurgeMsg.c --- /** * This class is automatically generated by mig. DO NOT EDIT THIS FILE. * This code implements C interface to the 'SurgeMsgP' * message type. */ #include <stdio.h> #include <stdlib.h> #include <memory.h> /** Private header is programmer specified for handling * conversion functions, etc. */ //#include "SurgeMsgP_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 _SurgeMsgP SurgeMsgP; #ifndef TELOS_MOTE typedef struct _XbowSensorboardPacket XbowSensorboardPacket; #endif /** The Active Message type associated with this message. */ //static const int AM_TYPE = 17; //#define AM_TYPE 17 // 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 _SurgeMsgP { uint16_t type; uint16_t reading; uint16_t parentaddr; uint16_t seq_no; }; void SurgeMsgP_set_type(SurgeMsgP * userdata, uint16_t type) { userdata->type = type; } uint16_t SurgeMsgP_get_type(SurgeMsgP * userdata) { return userdata->type; } void SurgeMsgP_set_reading(SurgeMsgP * userdata, uint16_t reading) { userdata->reading = reading; } uint16_t SurgeMsgP_get_reading(SurgeMsgP * userdata) { return userdata->reading; } void SurgeMsgP_set_parentaddr(SurgeMsgP * userdata, uint16_t parentaddr) { userdata->parentaddr = parentaddr; } uint16_t SurgeMsgP_get_parentaddr(SurgeMsgP * userdata) { return userdata->parentaddr; } void SurgeMsgP_set_seq_no(SurgeMsgP * userdata, uint16_t seq_no) { userdata->seq_no = seq_no; } uint16_t SurgeMsgP_get_seq_no(SurgeMsgP * userdata) { return userdata->seq_no; } //Format string generated automatically, //static char formatstring[] = "%i, %i, %i, %i"; //static char formatstring[] = "%i, %i, %i, %i"; static char insert_stmt[] = "INSERT into SurgeMsgP (" "result_time," "type," "reading," "parentaddr," "seq_no) values (now(), %i, %i, %i, %i)"; void SurgeMsgP_pg_log(XbowSensorboardPacket * userdata) { char pg_command[255]; SurgeMsgP * data = (SurgeMsgP*)userdata; sprintf(pg_command,insert_stmt, data->type, data->reading, data->parentaddr, data->seq_no); #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 type_convert(uint16_t type) { return type; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint16_t reading_convert(uint16_t reading) { return reading; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint16_t parentaddr_convert(uint16_t parentaddr) { return parentaddr; } /** @brief Default behavior is to return the input as output. * User is responsible for "cooking" the data. */ static uint16_t seq_no_convert(uint16_t seq_no) { return seq_no; } void SurgeMsgP_cook_packet(SurgeMsgP * userdata) { userdata->type = type_convert(userdata->type); userdata->reading = reading_convert(userdata->reading); userdata->parentaddr = parentaddr_convert(userdata->parentaddr); userdata->seq_no = seq_no_convert(userdata->seq_no); } /** User has to fill in any conversion code * necessary for processing. */ SurgeMsgP * SurgeMsgP_convert(char * data) { // Just to keep gcc happy. return (SurgeMsgP*)data; } /** Print the bytes of the packet. */ void SurgeMsgP_print_raw (XbowSensorboardPacket *packet) { printf("SurgeMsgP print raw.\n"); } /** Print cooked output. */ void SurgeMsgP_print_cooked (XbowSensorboardPacket * userdata) { SurgeMsgP * data = (SurgeMsgP*)userdata; printf("SurgeMsgP print cooked:\n"); printf(" type: %i,\n",data->type); printf(" reading: %i,\n",data->reading); printf(" parentaddr: %i,\n",data->parentaddr); printf(" seq_no: %i,\n",data->seq_no); } #ifdef TELOS_MOTE XPacketHandler SurgeMsgP_packet_handler = { // This should be replaced with the AM_TYPE 17, "$Id: SurgeMsg.c,v 1.1 2006/07/10 17:16:11 doolin Exp $", SurgeMsgP_print_raw, SurgeMsgP_print_cooked, SurgeMsgP_print_raw, SurgeMsgP_print_cooked, SurgeMsgP_pg_log, {0} }; void SurgeMsgP_initialize() { xpacket_add_type(&SurgeMsgP_packet_handler); } #endif /** The default size of this message type in bytes. */ //static int DEFAULT_MESSAGE_SIZE = 8; /** If incomplete types are used, we need to provide a way * to manage memory. */ SurgeMsgP * SurgeMsgP_new() { SurgeMsgP * userdata = (SurgeMsgP*)malloc(sizeof(SurgeMsgP)); memset((void*)userdata,0xda,sizeof(SurgeMsgP)); return userdata; } void SurgeMsgP_delete(SurgeMsgP * userdata) { memset((void*)userdata,0xdd,sizeof(SurgeMsgP)); free(userdata); } --- NEW FILE: ggbacltst.c --- /** * Handles conversion to engineering units of ggbacltst packets. * * Copyright (c) 2004 Crossbow Technology, Inc. All rights reserved. * * $Id: ggbacltst.c,v 1.1 2006/07/10 17:16:11 doolin Exp $ */ #include "../xdb.h" #include "../xsensors.h" typedef struct { uint16_t vref; uint16_t high_vertical; uint16_t high_horizontal; uint16_t low_vertical; uint16_t low_horizontal; uint16_t temperature; } XSensorGGBACLTSTData; extern XPacketHandler ggbacltst_packet_handler; void ggbacltst_print_raw(XbowSensorboardPacket *packet) { XSensorGGBACLTSTData *data = (XSensorGGBACLTSTData *)packet->data; printf("ggbacltst id=%02x vref=%4x\n" " acl_high_vertical=%04x acl_high_horizontal=%04x\n" " acl_low_vertical=%04x acl_low_horizontal=%04x\n" " temperature=%04x\n", packet->node_id, data->vref, data->high_vertical, data->high_horizontal, data->low_vertical, data->low_horizontal, data->temperature); } void ggbacltst_print_cooked(XbowSensorboardPacket *packet) { XSensorGGBACLTSTData *data = (XSensorGGBACLTSTData *)packet->data; uint16_t tmpr = data->temperature; int i; for (i = 0; i < 3; i++) { tmpr >>= 1; if (tmpr & 0x4000) tmpr |= 0x8000; } printf("GGBACLTST [sensor data converted to engineering units]:\n" " health: node id=%i parent=%i\n" " battery: = %i mv \n" " acl high vertical: = %f g, horizontal: = %f g\n" " acl low vertical: = %f g, horizontal: = %f g\n" " temperature=%0.2f degC\n", packet->node_id, packet->parent, xconvert_battery_mica2(data->vref), (double)data->high_vertical / (double) 65536 * 0.2 - 0.1 + 1, (double)data->high_horizontal / (double) 65536 * 0.2 - 0.1, (double)data->low_vertical / (double) 16384 - 2, (double)data->low_horizontal / (double) 16384 - 2, (double)(short)tmpr * (double)125 / (double)(0x3e87 >> 3) ); printf("\n"); } const char *ggbacltst_db_create_table = "CREATE TABLE %s%s ( result_time timestamp without time zone, " "epoch integer, nodeid integer, parent integer, " "voltage integer, acl_high_vertical integer, acl_high_horizontal integer," "acl_low_vertical integer, acl_low_horizontal integer, temperature integer)"; const char *ggbacltst_db_create_rule = "CREATE RULE cache_%s AS ON INSERT TO %s DO ( " "DELETE FROM %s_L WHERE nodeid = NEW.nodeid; " "INSERT INTO %s_L VALUES (NEW.*); )"; void ggbacltst_log_raw(XbowSensorboardPacket *packet) { XSensorGGBACLTSTData *data = (XSensorGGBACLTSTData *)packet->data; char command[512]; char *table = xdb_get_table(); if (!*table) table = "ggbacltst_results"; if (!ggbacltst_packet_handler.flags.table_init) { int exists = xdb_table_exists(table); if (!exists) { // Create results table. sprintf(command, ggbacltst_db_create_table, table, ""); xdb_execute(command); // Create last result cache sprintf(command, ggbacltst_db_create_table, table, "_L"); xdb_execute(command); // Add rule to populate last result table sprintf(command, ggbacltst_db_create_rule, table, table, table, table); xdb_execute(command); // Add results table to query log. int q_id = XTYPE_GGBACLTST, sample_time = 99000; sprintf(command, "INSERT INTO task_query_log " "(query_id, tinydb_qid, query_text, query_type, " "table_name) VALUES (%i, %i, 'SELECT nodeid,parent,voltage," "acl_high_vertical,acl_high_horizontal,acl_low_vertical,acl_low_horizontal,temperature " "SAMPLE PERIOD %i', 'sensor', '%s')", q_id, q_id, sample_time, table); xdb_execute(command); // Log start time of query in time log. sprintf(command, "INSERT INTO task_query_time_log " "(query_id, start_time) VALUES (%i, now())", q_id); xdb_execute(command); } ggbacltst_packet_handler.flags.table_init = 1; } sprintf(command, "INSERT into %s " "(result_time,nodeid,parent,voltage,acl_high_vertical,acl_high_horizontal," "acl_low_vertical,acl_low_horizontal,temperature)" " values (now(),%u,%u,%u,%u,%u,%u,%u,%u)", table, //timestring, packet->node_id, packet->parent, data->vref, data->high_vertical, data->high_horizontal, data->low_vertical, data->low_horizontal, data->temperature ); xdb_execute(command); } XPacketHandler ggbacltst_packet_handler = { XTYPE_GGBACLTST, "$Id: ggbacltst.c,v 1.1 2006/07/10 17:16:11 doolin Exp $", ggbacltst_print_raw, ggbacltst_print_cooked, ggbacltst_print_raw, ggbacltst_print_cooked, ggbacltst_log_raw }; void ggbacltst_initialize() { xpacket_add_type(&ggbacltst_packet_handler); } --- 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:16:11 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:16:11 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:16:11 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: mica2.c --- /** * Handles parsing of mica2 packets. * * @file mica2.c * @author Hu Siquan * @version 2004/4/12 husq Initial version * * Refer to: * - Xbow MTS/MDA Sensor and DataAcquistion Manual * * Copyright (c) 2004 Crossbow Technology, Inc. All rights reserved. * * $Id: mica2.c,v 1.1 2006/07/10 17:16:11 doolin Exp $ */ #include <math.h> #include "../xsensors.h" /** mica2 XMesh packet 1 -- contains serialID information */ typedef struct SerialIDData { uint8_t id[8]; } __attribute__ ((packed)) SerialIDData; typedef struct ConfigData { uint16_t nodeid; uint8_t group; uint8_t rf_power; uint8_t rf_channel; } __attribute__ ((packed)) ConfigData; struct bandItem{ int channel; int band; double freq; } table_cc1k_band[35] ={{0,433,433.002},{1,916,914.998},{2,433,434.845}, {3,916,914.077},{4,315,315.179},{5,433,433.113}, {6,433,433.616},{7,433,434.108},{8,433,434.618}, {9,916,903.018},{10,916,904.023},{11,916,905.003}, {12,916,905.967},{13,916,907.231},{14,916,908.045}, {15,916,908.973},{16,916,909.981},{17,916,911.005}, {18,916,911.971},{19,916,913.024},{20,916,914.077}, {21,916,914.999},{22,916,915.920},{23,916,917.026}, {24,916,918.047},{25,916,918.992},{26,916,919.975}, {27,916,920.923},{28,916,922.017},{29,916,923.030}, {30,916,924.083},{31,916,925.136},{32,916,925.987}, {33,916,926.980},{34,315,315.179}}; int table_433MHz_power[23][2] = {{1,-20},{2,-17},{3,-14},{4,-11},{5,-9},{6,-8},{7,-7},{8,-6},{9,-5}, {10,-4},{11,-3},{12,-2},{14,-1},{15,0},{64,1},{80,2},{96,4},{112,5},{128,6}, {144,7},{192,8},{224,9},{255,10}} ; int table_916MHz_power[21][2] = {{2,-20},{4,-16},{5,-14},{6,-13},{7,-12},{8,-11},{9,-10},{11,-9},{12,-8}, {13,-7},{15,-6},{64,-5},{80,-4},{96,-2},{112,-1},{128,0}, {144,1},{176,2},{192,3},{240,4},{255,5}} ; double getCC1KFreq(int rf_channel){ int i; for(i=0;i<35;i++){ if (table_cc1k_band[i].channel == rf_channel) return table_cc1k_band[i].freq; } return -1.0; // error } int getCC1KDBMfromRTP(int rf_channel,int rf_power) { int i,j,band; band = 0; for(i=0;i<35;i++){ if (table_cc1k_band[i].channel == rf_channel) band = table_cc1k_band[i].band; } if(band==433 || band ==315){ for(j=1;j<23;j++){if(table_433MHz_power[j][0]<rf_power) continue; else {if(j>0) j--;return table_433MHz_power[j][1];}} } if(band==916){ for(j=1;j<21;j++){if(table_916MHz_power[j][0]<rf_power) continue; else {if(j>0) j--;return table_916MHz_power[j][1];}} } return 0xff; } extern XPacketHandler mica2_packet_handler; /** mica2 Specific outputs of raw readings within an XBowSensorboardPacket */ void mica2_print_raw(XbowSensorboardPacket *packet) { switch(packet->packet_id){ case 1:{ SerialIDData *data = (SerialIDData *)packet->data; printf("mica2 id=%02x SerialID = %02x%02x%02x%02x%02x%02x%02x%02x\n", packet->node_id, data->id[0], data->id[1],data->id[2],data->id[3], data->id[4],data->id[5], data->id[6],data->id[7]); break; } case 2:{ ConfigData *data = (ConfigData *)packet->data; printf("mica2 config parameters: nodeid=%04x groupid=%02x rf_power=%02x rf_channel=%02x\n", data->nodeid, data->group,data->rf_power,data->rf_channel); break; } default: break; } } /** mica2 specific display of converted readings from XBowSensorboardPacket */ void mica2_print_cooked(XbowSensorboardPacket *packet) { switch(packet->packet_id){ case 1:{ SerialIDData *data = (SerialIDData *)packet->data; printf("Mica2 id=%02x SerialID information: \n" " CRC code = %02x\n" " Serial Number = %02x%02x%02x%02x%02x%02x\n" " Family Code = %02x\n", packet->node_id, data->id[7],data->id[6],data->id[5], data->id[4], data->id[3],data->id[2],data->id[1],data->id[0]); break; } case 2:{ ConfigData *data = (ConfigData *)packet->data; printf("Mica2 Config parameters: \n" " nodeid=%d groupid=%d " " RF Power=%ddbm; RF Channel=%8.3fMHz\n", data->nodeid, data->group, getCC1KDBMfromRTP(data->rf_channel,data->rf_power),getCC1KFreq(data->rf_channel)); break; } default: break; } printf("\n"); } /** * Logs raw readings to a Postgres database. * * @author Martin Turon * * @version 2004/7/28 mturon Initial revision * */ void mica2_log_raw(XbowSensorboardPacket *packet) { } XPacketHandler mica2_packet_handler = { XTYPE_MICA2, "$Id: mica2.c,v 1.1 2006/07/10 17:16:11 doolin Exp $", mica2_print_raw, mica2_print_cooked, mica2_print_raw, mica2_print_cooked, mica2_log_raw }; void mica2_initialize() { xpacket_add_type(&mica2_packet_handler); } --- NEW FILE: testlink.c --- #include "fireboard.h" void LinkMsg_print_raw(XbowSensorboardPacket *packet); void LinkMsg_print_cooked(XbowSensorboardPacket *packet); void testlink_print_raw(XbowSensorboardPacket *packet) { } void testlink_print_cooked(XbowSensorboardPacket *packet) { } void testlink_log_raw(XbowSensorboardPacket *packet) { } XPacketHandler testlink_packet_handler = { AM_LINKMSG, "$Id: testlink.c,v 1.1 2006/07/10 17:16:11 doolin Exp $", LinkMsg_print_raw, LinkMsg_print_cooked, testlink_print_raw, testlink_print_cooked, testlink_log_raw }; void testlink_initialize() { xpacket_add_type(&testlink_packet_handler); } --- 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 ... [truncated message content] |
From: David M. D. <do...@us...> - 2006-07-10 17:15:53
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/boards In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv18914 Modified Files: mda300.c mda500.c mep401.c mep500.c mts101.c mts300.c mts400.c mts510.c Log Message: updating from beta. Index: mts510.c =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/boards/mts510.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mts510.c 15 Jul 2004 17:04:21 -0000 1.1 --- mts510.c 10 Jul 2006 17:15:46 -0000 1.2 *************** *** 14,17 **** --- 14,18 ---- #define SOUNDSAMPLES 5 + #define ACCEL_SAMPLES 5 #include "../xsensors.h" *************** *** 24,114 **** } XSensorMTS510Data; ! float mts510_convert_accel_x(uint16_t data); ! float mts510_convert_accel_y(uint16_t data); ! /** ! * Computes the ADC count of a Accelerometer - for X axis reading into ! * Engineering Unit (g), per calibration ! * ! * Calibration done for one test sensor - should be repeated for each unit. ! * @author Jaidev Prabhu ! * ! * @version 2004/3/24 jdprabhu Initial revision ! * ! */ ! float mts510_convert_accel_x(uint16_t data) { ! uint16_t minus_one_calibration; ! uint16_t plus_one_calibration; ! float zero_value; ! float reading; ! minus_one_calibration = 490; ! plus_one_calibration = 615; ! zero_value = ( plus_one_calibration - minus_one_calibration ) / 2; ! reading = (zero_value - (plus_one_calibration - data) ) / zero_value; ! return reading; } /** ! * Computes the ADC count of a Accelerometer - for Y axis reading into ! * Engineering Unit (g), per calibration ! * Calibration done for one test sensor - should be repeated for each unit. ! * ! * @author Jaidev Prabhu * ! * @version 2004/3/24 jdprabhu Initial revision * */ ! float mts510_convert_accel_y(uint16_t data) { ! uint16_t minus_one_calibration; ! uint16_t plus_one_calibration; ! ! float zero_value; ! float reading; ! minus_one_calibration = 432; ! plus_one_calibration = 552; ! zero_value = ( plus_one_calibration - minus_one_calibration ) / 2; ! reading = ( zero_value - (plus_one_calibration - data) ) / zero_value; ! return reading; ! } ! /** MTS510 Specific outputs of raw readings within an XBowSensorboardPacket */ ! void mts510_print_raw(XbowSensorboardPacket *packet) ! { ! XSensorMTS510Data *data = (XSensorMTS510Data *)packet->data; ! printf("mts510 id=%02x light=%04x acc_x=%04x acc_y=%04x \n" ! " sound[0]=%02x sound[1]=%02x sound[2]=%02x sound[3]=%02x sound[4]=%02x \n", ! packet->node_id, data->light, data->accel_x, data->accel_y, ! data->sound[0], data->sound[1], data->sound[2], data->sound[3], data->sound[4] ); } ! /** MTS510 Specific display of converted readings within an XBowSensorboardPacket */ ! void mts510_print_cooked(XbowSensorboardPacket *packet) { ! XSensorMTS510Data *pd; ! pd = (XSensorMTS510Data *) packet->data; ! printf("MTS510 [sensor data converted to engineering units]:\n" ! " health: node id=%i\n" ! " light: =%i ADC counts\n" ! " X-axis Accel: =%f g \n" ! " Y-axis Accel: =%f g \n", ! packet->node_id, ! pd->light, ! mts510_convert_accel_x(pd->accel_x), ! mts510_convert_accel_y(pd->accel_y)); ! printf("\n"); ! } --- 25,204 ---- } XSensorMTS510Data; ! typedef struct { ! uint16_t seq_no; ! uint16_t accel[2][ACCEL_SAMPLES]; ! } XSensorMTS510Data2; + extern XPacketHandler mts510_packet_handler; ! /** MTS510 Specific outputs of raw readings within an XBowSensorboardPacket */ ! void mts510_print_raw(XbowSensorboardPacket *packet) { + switch (packet->packet_id) { + case 1: { + XSensorMTS510Data *data = (XSensorMTS510Data *)packet->data; + printf("mts510 id=%02x light=%04x acc_x=%04x acc_y=%04x \n" + " sound[0]=%02x sound[1]=%02x sound[2]=%02x " + "sound[3]=%02x sound[4]=%02x \n", + packet->node_id, data->light, data->accel_x, data->accel_y, + data->sound[0], data->sound[1], + data->sound[2], data->sound[3], data->sound[4] ); + break; + } ! case 2: { ! XSensorMTS510Data2 *data = (XSensorMTS510Data2 *)packet->data; ! printf("mts510 id=%02x seq_no=%04x acc_x[0]=%04x acc_y[0]=%04x \n" ! " acc_x[1]=%04x acc_y[1]=%04x acc_x[2]=%04x acc_y[2]=%04x\n" ! " acc_x[3]=%04x acc_y[3]=%04x acc_x[4]=%04x acc_y[4]=%04x\n", ! packet->node_id, data->seq_no, ! data->accel[0][0], data->accel[1][0], ! data->accel[0][1], data->accel[1][1], ! data->accel[0][2], data->accel[1][2], ! data->accel[0][3], data->accel[1][3], ! data->accel[0][4], data->accel[1][4] ! ); ! break; ! } ! } ! } ! /** MTS510 Specific display of converted readings within an XBowSensorboardPacket */ ! void mts510_print_cooked(XbowSensorboardPacket *packet) ! { ! switch (packet->packet_id) { ! case 1: { ! XSensorMTS510Data *pd; ! pd = (XSensorMTS510Data *) packet->data; ! printf("MTS510 [sensor data converted to engineering units]:\n" ! " health: node id=%i\n" ! " light: =%i ADC counts\n" ! " X-axis Accel: =%f g \n" ! " Y-axis Accel: =%f g \n" ! " mic = %i ADC counts\n", ! packet->node_id, ! pd->light, ! xconvert_accel(pd->accel_x), ! xconvert_accel(pd->accel_y), ! (pd->sound[0]+pd->sound[1]+pd->sound[2]+pd->sound[3]+pd->sound[4])/5 ); ! printf("\n"); ! break; ! } ! case 2: { ! XSensorMTS510Data2 *pd; ! pd = (XSensorMTS510Data2 *) packet->data; ! printf("MTS510 [sensor data converted to engineering units]:\n" ! " health: node id=%i seq_no=%i\n" ! " Accel_X: %1.4f g, %1.4f g, %1.4f g, %1.4f g, %1.4f g\n" ! " Accel_Y: %1.4f g, %1.4f g, %1.4f g, %1.4f g, %1.4f g\n", ! packet->node_id, pd->seq_no, ! xconvert_accel(pd->accel[0][0]), ! xconvert_accel(pd->accel[0][1]), ! xconvert_accel(pd->accel[0][2]), ! xconvert_accel(pd->accel[0][3]), ! xconvert_accel(pd->accel[0][4]), ! xconvert_accel(pd->accel[1][0]), ! xconvert_accel(pd->accel[1][1]), ! xconvert_accel(pd->accel[1][2]), ! xconvert_accel(pd->accel[1][3]), ! xconvert_accel(pd->accel[1][4]) ! ); ! printf("\n"); ! break; ! } ! } } + const char *mts510_db_create_table = + "CREATE TABLE %s%s ( result_time timestamp without time zone, " + "epoch integer, nodeid integer, parent integer, " + "voltage integer, temp integer, light integer, " + "accel_x integer, accel_y integer, " + "mag_x integer, mag_y integer, mic integer )"; + + const char *mts510_db_create_rule = + "CREATE RULE cache_%s AS ON INSERT TO %s DO ( " + "DELETE FROM %s_L WHERE nodeid = NEW.nodeid; " + "INSERT INTO %s_L VALUES (NEW.*); )"; + /** ! * Logs raw readings to a Postgres database. ! * ! * @author Martin Turon * ! * @version 2004/7/28 mturon Initial revision * */ ! void mts510_log_raw(XbowSensorboardPacket *packet) { + XSensorMTS510Data *data = (XSensorMTS510Data *)packet->data; + if (packet->packet_id != 1) return; ! char command[512]; ! char *table = xdb_get_table(); ! if (!*table) table = "mts510_results"; ! if (!mts510_packet_handler.flags.table_init) { ! int exists = xdb_table_exists(table); ! if (!exists) { ! // Create results table. ! sprintf(command, mts510_db_create_table, table, ""); ! xdb_execute(command); ! // Create last result cache ! sprintf(command, mts510_db_create_table, table, "_L"); ! xdb_execute(command); ! ! // Add rule to populate last result table ! sprintf(command, mts510_db_create_rule, table, table, table, table); ! xdb_execute(command); ! // Add results table to query log. ! int q_id = XTYPE_MTS510, sample_time = 99000; ! sprintf(command, "INSERT INTO task_query_log " ! "(query_id, tinydb_qid, query_text, query_type, " ! "table_name) VALUES (%i, %i, 'SELECT nodeid,parent," ! "voltage,temp,light,accel_x,accel_y,mic " ! "SAMPLE PERIOD %i', 'sensor', '%s')", q_id, q_id, ! sample_time, table); ! xdb_execute(command); ! // Log start time of query in time log. ! sprintf(command, "INSERT INTO task_query_time_log " ! "(query_id, start_time) VALUES (%i, now())", q_id); ! xdb_execute(command); ! } ! mts510_packet_handler.flags.table_init = 1; ! } ! sprintf(command, ! "INSERT into %s " ! "(result_time,nodeid,parent,light," ! "accel_x,accel_y,mic)" ! " values (now(),%u,%u,%u,%u,%u,%u)", ! table, ! //timestring, ! packet->node_id, packet->parent, ! data->light, data->accel_x, data->accel_y, data->sound[0] ! ); ! xdb_execute(command); } ! XPacketHandler mts510_packet_handler = { ! XTYPE_MTS510, ! "$Id$", ! mts510_print_raw, ! mts510_print_cooked, ! mts510_print_raw, ! mts510_print_cooked, ! mts510_log_raw, ! // {0} ! }; ! void mts510_initialize() { ! xpacket_add_type(&mts510_packet_handler); } Index: mep500.c =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/boards/mep500.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mep500.c 15 Jul 2004 17:04:21 -0000 1.1 --- mep500.c 10 Jul 2006 17:15:46 -0000 1.2 *************** *** 12,74 **** */ #include "../xsensors.h" typedef struct { ! uint16_t temp; ! uint16_t humidity; ! } XSensorMEP500Data; /** ! * Computes the temperature ADC count of Sensirion SHT15 humidity/temperature ! * sensor into Engineering Unit (degC) ! * ! * @author Hu Siquan * ! * @version 2004/6/14 husq Initial revision * */ ! float mep500_convert_temp(XSensorMEP500Data *data) { ! float TempData,fTemp; ! ! TempData = (float)data->temp; ! fTemp = -38.4 + 0.0098 * TempData; ! return fTemp; } /** ! * Computes the humidity ADC count of Sensirion SHT15 humidity/temperature ! * sensor into Engineering Unit (%) ! * ! * @author Hu Siquan * ! * @version 2004/6/14 husq Initial revision * */ ! float mep500_convert_humidity(XSensorMEP500Data *data) { ! float TempData,HumData; ! float fTemp,fHumidity; ! ! TempData = (float)data->temp; ! HumData = (float)data->humidity; ! ! fTemp = -38.4 + 0.0098 * (float)TempData; ! fHumidity = -4.0 + 0.0405 * HumData - 0.0000028 * HumData * HumData; ! fHumidity = (fTemp - 25.0)*(0.01 + 0.00008 * HumData) + fHumidity; ! return fHumidity; } /** mep500 Specific outputs of raw readings within an XBowSensorboardPacket */ void mep500_print_raw(XbowSensorboardPacket *packet) { ! XSensorMEP500Data *data = (XSensorMEP500Data *)packet->data; ! printf("mep500 id=%02x temperature=%04x humidity=%04x \n", ! packet->node_id, data->temp, data->humidity); } --- 12,170 ---- */ + #include <math.h> + #include "../xdb.h" #include "../xsensors.h" + typedef struct { + uint8_t vref; + uint16_t thermistor; + uint16_t humid; + uint16_t humtemp; // 13 + } __attribute__ ((packed)) XSensorMEP500Data1; typedef struct { ! uint16_t seqno; ! uint8_t vref; ! uint16_t thermistor; ! uint16_t humid; ! uint16_t humtemp; // 13 ! // XSensorSensirion sensirion; ! } __attribute__ ((packed)) XSensorMEP500Data2; + uint16_t mep500_convert_thermistor_resistance (uint16_t thermistor); + float mep500_convert_thermistor_temperature(uint16_t thermistor); + + extern XPacketHandler mep500_packet_handler; /** ! * Converts mica2 battery reading from raw vref ADC data to battery engineering units. * ! * @author Martin Turon ! * ! * To compute the battery voltage after measuring the voltage ref: ! * BV = RV*ADC_FS/data ! * where: ! * BV = Battery Voltage ! * ADC_FS = 1023 ! * RV = Voltage Reference for mica2 (1.223 volts) ! * data = data from the adc measurement of channel 1 ! * BV (volts) = 1252.352/data ! * BV (mv) = 1252352/data ! * ! * Note: ! * The thermistor resistance to temperature conversion is highly non-linear. ! * ! * @version 2004/3/29 mturon Initial revision * */ ! uint16_t mep500_convert_battery(uint16_t vref) { ! float x = (float)(vref << 1); ! uint16_t vdata = (uint16_t) (614400 / x); ! return vdata; ! } ! /** ! * Converts thermistor reading from raw ADC data to engineering units. ! * ! * @author Martin Turon, Alan Broad ! * ! * To compute the thermistor resistance after measuring the thermistor voltage: ! * - Thermistor is a temperature variable resistor ! * - There is a 10K resistor in series with the thermistor resistor. ! * - Compute expected adc output from voltage on thermistor as: ! * ADC= 1023*Rthr/(R1+Rthr) ! * where R1 = 10K ! * Rthr = unknown thermistor resistance ! * Rthr = R1*ADC/(ADC_FS-ADC) ! * where ADC_FS = 1023 ! * ! * Note: ! * The thermistor resistance to temperature conversion is highly non-linear. ! * ! * @return Thermistor resistance as a uint16 in unit (Ohms) ! * ! * @version 2004/3/11 mturon Initial revision ! * ! */ ! uint16_t mep500_convert_thermistor_resistance(uint16_t thermistor) ! { ! float x = (float)thermistor; ! uint16_t vdata = 10000*x / (1023-x); ! return vdata; } /** ! * Converts thermistor reading from raw ADC data to engineering units. * ! * @author Martin Turon ! * ! * @return Temperature reading from thermistor as a float in degrees Celcius ! * ! * @version 2004/3/22 mturon Initial revision * */ ! float mep500_convert_thermistor_temperature(uint16_t thermistor) { ! float temperature, a, b, c, Rt; ! a = 0.001307050; ! b = 0.000214381; ! c = 0.000000093; ! Rt = mep500_convert_thermistor_resistance(thermistor); ! temperature = 1 / (a + b * log(Rt) + c * pow(log(Rt),3)); ! temperature -= 273.15; // Convert from Kelvin to Celcius + //printf("debug: a=%f b=%f c=%f Rt=%f temp=%f\n",a,b,c,Rt,temperature); + + return temperature; } + /** mep500 Specific outputs of raw readings within an XBowSensorboardPacket */ void mep500_print_raw(XbowSensorboardPacket *packet) { ! switch(packet->packet_id) ! { ! case 1: ! { ! XSensorMEP500Data1 *data = (XSensorMEP500Data1 *)(packet->data); ! printf("mep500 id=%02x packet_id=%02x vref=%04x therm=%04x temperature=%04x humidity=%04x \n", ! packet->node_id, packet->packet_id, data->vref, ! data->thermistor, data->humtemp, ! data->humid); ! break; ! } ! case 2: ! { ! XSensorMEP500Data2 *data = (XSensorMEP500Data2 *)(packet->data); ! printf("mep500 id=%02x parent=%02x vref=%04x therm=%04x temperature=%04x humidity=%04x \n", ! packet->node_id, packet->parent, data->vref, ! data->thermistor, data->humtemp, ! data->humid); ! break; ! } ! case 11: ! { ! XSensorMEP500Data1 *data = (XSensorMEP500Data1 *)(packet->data); ! printf("mep510 id=%02x packet_id=%02x vref=%04x therm=%04x temperature=%04x humidity=%04x \n", ! packet->node_id, packet->packet_id, data->vref, ! data->thermistor, data->humtemp, ! data->humid); ! break; ! } ! case 12: ! { ! XSensorMEP500Data2 *data = (XSensorMEP500Data2 *)(packet->data); ! printf("MEP510 id=%02x parent=%02x vref=%04x therm=%04x temperature=%04x humidity=%04x \n", ! packet->node_id, packet->parent, data->vref, ! data->thermistor, data->humtemp, ! data->humid); ! break; ! } ! default: ! printf("MEP510 error: unknown packet_id (%i)\n", packet->packet_id); ! ! } } *************** *** 76,90 **** void mep500_print_cooked(XbowSensorboardPacket *packet) { ! XSensorMEP500Data *pd; ! pd = (XSensorMEP500Data *) packet->data; ! printf("mep500 [sensor data converted to engineering units]:\n" ! " health: node id=%i\n" ! " temperature: =%0.2f degC \n" ! " humidity: =%0.1f%% \n", ! packet->node_id, ! mep500_convert_temp(pd), ! mep500_convert_humidity(pd)); ! printf("\n"); } --- 172,427 ---- void mep500_print_cooked(XbowSensorboardPacket *packet) { ! XSensorSensirion xsensor; ! switch(packet->packet_id) ! { ! case 1: ! { ! XSensorMEP500Data1 *pd; ! pd = (XSensorMEP500Data1 *) (packet->data); ! xsensor.humidity=pd->humid, ! xsensor.thermistor=pd->humtemp, ! printf("mep500 [sensor data converted to engineering units]:\n" ! " health: node id=%u packet_id=%u \n" ! " battery: =%i mv \n" ! " thermistor: resistance=%i ohms, tempurature=%0.2f C\n" ! " temperature: =%0.2f degC \n" ! " humidity: =%0.1f%% \n", ! packet->node_id, ! packet->packet_id, ! xconvert_battery_dot(pd->vref <<1), ! mep500_convert_thermistor_resistance(pd->thermistor), ! mep500_convert_thermistor_temperature(pd->thermistor), ! xconvert_sensirion_temp(&xsensor), ! xconvert_sensirion_humidity(&xsensor)); ! printf("\n"); ! break; ! } ! case 2: ! { ! XSensorMEP500Data2 *pd; ! ! pd = (XSensorMEP500Data2 *) (packet->data); ! xsensor.humidity=pd->humid, ! xsensor.thermistor=pd->humtemp, ! printf("mep500 [sensor data converted to engineering units]:\n" ! " health: node id=%u parent=%u seq=%u\n" ! " battery: =%i mv \n" ! " thermistor: resistance=%i ohms, tempurature=%0.2f C\n" ! " temperature: =%0.2f degC \n" ! " humidity: =%0.1f%% \n", ! packet->node_id, ! packet->parent, ! pd->seqno, ! xconvert_battery_dot(pd->vref <<1), ! mep500_convert_thermistor_resistance(pd->thermistor), ! mep500_convert_thermistor_temperature(pd->thermistor), ! xconvert_sensirion_temp(&xsensor), ! xconvert_sensirion_humidity(&xsensor)); ! printf("\n"); ! break; ! } ! case 11: ! { ! XSensorMEP500Data1 *pd; ! pd = (XSensorMEP500Data1 *) (packet->data); ! xsensor.humidity=pd->humid, ! xsensor.thermistor=pd->humtemp, ! printf("mep510 [sensor data converted to engineering units]:\n" ! " health: node id=%u packet_id=%u \n" ! " battery: =%i mv \n" ! " thermistor: resistance=%i ohms, tempurature=%0.2f C\n" ! " temperature: =%0.2f degC \n" ! " humidity: =%0.1f%% \n", ! packet->node_id, ! packet->packet_id, ! xconvert_battery_dot(pd->vref <<1), ! mep500_convert_thermistor_resistance(pd->thermistor), ! mep500_convert_thermistor_temperature(pd->thermistor), ! xconvert_sensirion_temp(&xsensor), ! xconvert_sensirion_humidity(&xsensor)); ! printf("\n"); ! break; ! } ! case 12: ! { ! XSensorMEP500Data2 *pd; ! ! pd = (XSensorMEP500Data2 *) (packet->data); ! xsensor.humidity=pd->humid, ! xsensor.thermistor=pd->humtemp, ! printf("MEP510 [sensor data converted to engineering units]:\n" ! " health: node id=%u parent=%u seq=%u\n" ! " battery: =%i mv \n" ! " thermistor: resistance=%i ohms, tempurature=%0.2f C\n" ! " temperature: =%0.2f degC \n" ! " humidity: =%0.1f%% \n", ! packet->node_id, ! packet->parent, ! pd->seqno, ! xconvert_battery_dot(pd->vref <<1), ! mep500_convert_thermistor_resistance(pd->thermistor), ! mep500_convert_thermistor_temperature(pd->thermistor), ! xconvert_sensirion_temp(&xsensor), ! xconvert_sensirion_humidity(&xsensor)); ! printf("\n"); ! break; ! } ! default: ! printf("MEP510 error: unknown packet_id (%i)\n", packet->packet_id); ! } ! } ! const char *mep500_db_create_table = ! "CREATE TABLE %s%s ( result_time timestamp without time zone, " ! "epoch integer,nodeid integer,parent integer," ! "voltage integer,therm integer,humid integer,humtemp integer," ! "inthum integer,inttemp integer,photo1 integer,photo2 integer," ! "photo3 integer,photo4 integer,accel_x integer,accel_y integer," ! "prtemp integer,press integer)"; ! ! const char *mep500_db_create_rule = ! "CREATE RULE cache_%s AS ON INSERT TO %s DO ( " ! "DELETE FROM %s_L WHERE nodeid = NEW.nodeid; " ! "INSERT INTO %s_L VALUES (NEW.*); )"; ! ! ! /** ! * Logs raw readings to a Postgres database. ! * ! * @author Martin Turon ! * ! * @version 2004/7/28 mturon Initial revision ! * ! */ ! void mep500_log_raw(XbowSensorboardPacket *packet) ! { ! XSensorMEP500Data2 *data = (XSensorMEP500Data2 *)packet->data; ! ! char command[512]; ! char *table = xdb_get_table(); ! if (!*table) table = "enviro_results"; ! ! if (!mep500_packet_handler.flags.table_init) { ! int exists = xdb_table_exists(table); ! if (!exists) { ! // Create results table. ! sprintf(command, mep500_db_create_table, table, ""); ! xdb_execute(command); ! // Create last result cache ! sprintf(command, mep500_db_create_table, table, "_L"); ! xdb_execute(command); ! ! // Add rule to populate last result table ! sprintf(command, mep500_db_create_rule, table, table, table, table); ! xdb_execute(command); ! ! // Add results table to query log. ! int q_id = XTYPE_MEP500, sample_time = 3000; ! sprintf(command, "INSERT INTO task_query_log " ! "(query_id, tinydb_qid, query_text, query_type, " ! "table_name) VALUES (%i, %i, 'SELECT nodeid,parent," ! "voltage,therm,humid,humtemp,inthum,inttemp,photo1,photo2," ! "photo3,photo4,accel_x,accel_y,prtemp,press " ! "SAMPLE PERIOD %i', 'sensor', '%s')", q_id, q_id, ! sample_time, table); ! xdb_execute(command); ! ! // Log start time of query in time log. ! sprintf(command, "INSERT INTO task_query_time_log " ! "(query_id, start_time) VALUES (%i, now())", q_id); ! xdb_execute(command); ! } ! mep500_packet_handler.flags.table_init = 1; ! } ! ! switch(packet->packet_id) ! { ! case 1: ! { ! sprintf(command, ! "INSERT into %s " ! "(result_time,nodeid,parent,voltage," ! "therm,humid,humtemp)" ! " values (now(),%u,%u,%u,%u,%u,%u)", ! table, ! //timestring, ! packet->node_id, packet->parent, ! /* Note saved as mica2 vref via 2x multiplier */ ! data->vref << 2, ! data->thermistor, ! data->humid, data->humtemp ! ); ! break; ! } ! case 2: ! { ! sprintf(command, ! "INSERT into %s " ! "(result_time,nodeid,parent,epoch,voltage," ! "therm,humid,humtemp)" ! " values (now(),%u,%u,%u,%u,%u,%u,%u)", ! table, ! //timestring, ! packet->node_id, packet->parent, ! data->seqno, ! /* Note saved as mica2 vref via 2x multiplier */ ! data->vref << 2, ! data->thermistor, ! data->humid, data->humtemp ! ); ! break; ! } ! case 11: ! { ! sprintf(command, ! "INSERT into %s " ! "(result_time,nodeid,parent,voltage," ! "therm,humid,humtemp)" ! " values (now(),%u,%u,%u,%u,%u,%u)", ! table, ! //timestring, ! packet->node_id, packet->parent, ! /* Note saved as mica2 vref via 2x multiplier */ ! data->vref << 2, ! data->thermistor, ! data->humid, data->humtemp ! ); ! break; ! } ! case 12: ! { ! sprintf(command, ! "INSERT into %s " ! "(result_time,nodeid,parent,epoch,voltage," ! "therm,humid,humtemp)" ! " values (now(),%u,%u,%u,%u,%u,%u,%u)", ! table, ! //timestring, ! packet->node_id, packet->parent, ! data->seqno, ! /* Note saved as mica2 vref via 2x multiplier */ ! data->vref << 2, ! data->thermistor, ! data->humid, data->humtemp ! ); ! break; ! } ! } ! xdb_execute(command); } + + XPacketHandler mep500_packet_handler = + { + XTYPE_MEP500, + "$Id$", + mep500_print_raw, + mep500_print_cooked, + mep500_print_raw, + mep500_print_cooked, + mep500_log_raw + }; + + void mep500_initialize() { + xpacket_add_type(&mep500_packet_handler); + } Index: mts400.c =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/boards/mts400.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mts400.c 4 Aug 2004 01:56:14 -0000 1.4 --- mts400.c 10 Jul 2006 17:15:46 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- * @version 2004/3/10 mturon Initial version * @n 2004/3/28 husiquan Added temp,pressure,accel,light,gps + * @n 2004/11/15 husiquan Added database logging * * Copyright (c) 2004 Crossbow Technology, Inc. All rights reserved. *************** *** 13,24 **** */ #include <math.h> [...1070 lines suppressed...] + }; + + void mts400_initialize() { + xpacket_add_type(&mts400_packet_handler); + } + + XPacketHandler mts420_packet_handler = + { + XTYPE_MTS420, + "$Id$", + mts420_print_raw, + mts420_print_cooked, + mts420_print_raw, + mts420_print_cooked, + mts420_log_raw + }; + + void mts420_initialize() { + xpacket_add_type(&mts420_packet_handler); + } Index: mda500.c =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/boards/mda500.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mda500.c 15 Jul 2004 17:04:20 -0000 1.1 --- mda500.c 10 Jul 2006 17:15:46 -0000 1.2 *************** *** 16,20 **** */ - #include <math.h> #include "../xsensors.h" --- 16,19 ---- *************** *** 31,37 **** } XSensorMDA500Data; ! uint16_t mda500_convert_battery (XbowSensorboardPacket *packet); ! uint16_t mda500_convert_thermistor_resistance (XbowSensorboardPacket *packet); ! float mda500_convert_thermistor_temperature(XbowSensorboardPacket *packet); uint16_t mda500_convert_adc(XbowSensorboardPacket *packet, uint16_t index); --- 30,35 ---- } XSensorMDA500Data; ! extern XPacketHandler mda500_packet_handler; ! uint16_t mda500_convert_adc(XbowSensorboardPacket *packet, uint16_t index); *************** *** 50,53 **** --- 48,52 ---- void mda500_print_cooked(XbowSensorboardPacket *packet) { + XSensorMDA500Data *pd = (XSensorMDA500Data *)packet->data; printf("MDA500 [sensor data converted to engineering units]:\n" " health: node id=%i\n" *************** *** 61,67 **** " adc chan 7: voltage=%i mv\n", packet->node_id, ! mda500_convert_battery(packet), ! mda500_convert_thermistor_resistance(packet), ! mda500_convert_thermistor_temperature(packet), mda500_convert_adc(packet, 2), mda500_convert_adc(packet, 3), --- 60,66 ---- " adc chan 7: voltage=%i mv\n", packet->node_id, ! xconvert_battery_dot(pd->battery), ! xconvert_thermistor_resistance(pd->thermistor), ! xconvert_thermistor_temperature(pd->thermistor), mda500_convert_adc(packet, 2), mda500_convert_adc(packet, 3), *************** *** 73,184 **** } - /** - * Converts battery reading from raw ADC data to engineering units. - * - * @author Martin Turon, Alan Broad - * - * To compute the battery voltage after measuring the voltage ref: - * BV = RV*ADC_FS/data - * where: - * BV = Battery Voltage - * ADC_FS = 1023 - * RV = Voltage Reference (0.6 volts) - * data = data from the adc measurement of channel 1 - * BV (volts) = 614.4/data - * BV (mv) = 614400/data - * - * Note: - * The thermistor resistance to temperature conversion is highly non-linear. - * - * @return Battery voltage as uint16 in millivolts (mV) - * - * @version 2004/3/11 mturon Initial revision - * - */ - uint16_t mda500_convert_battery(XbowSensorboardPacket *packet) - { - XSensorMDA500Data *data = (XSensorMDA500Data *)packet->data; - float x = (float)data->battery; - uint16_t vdata = (uint16_t) (614400 / x); /*613800*/ - return vdata; - } /** ! * Converts thermistor reading from raw ADC data to engineering units. ! * ! * @author Martin Turon, Alan Broad ! * ! * To compute the thermistor resistance after measuring the thermistor voltage: ! * - Thermistor is a temperature variable resistor ! * - There is a 10K resistor in series with the thermistor resistor. ! * - Compute expected adc output from voltage on thermistor as: ! * ADC= 1023*Rthr/(R1+Rthr) ! * where R1 = 10K ! * Rthr = unknown thermistor resistance ! * Rthr = R1*ADC/(ADC_FS-ADC) ! * where ADC_FS = 1023 * ! * Note: ! * The thermistor resistance to temperature conversion is highly non-linear. * ! * @return Thermistor resistance as a uint16 in unit (Ohms) * ! * @version 2004/3/11 mturon Initial revision * */ ! uint16_t mda500_convert_thermistor_resistance(XbowSensorboardPacket *packet) { ! XSensorMDA500Data *data = (XSensorMDA500Data *)packet->data; ! float x = (float)data->thermistor; ! uint16_t vdata = 10000*x / (1023-x); ! return vdata; } /** ! * Converts thermistor reading from raw ADC data to engineering units. ! * * @author Martin Turon * ! * @return Temperature reading from thermistor as a float in degrees Celcius ! * ! * @version 2004/3/22 mturon Initial revision * */ ! float mda500_convert_thermistor_temperature(XbowSensorboardPacket *packet) { ! //XSensorMDA500Data *data = (XSensorMDA500Data *)packet->data; ! float temperature, a, b, c, Rt; ! a = 0.001307050; ! b = 0.000214381; ! c = 0.000000093; ! Rt = mda500_convert_thermistor_resistance(packet); ! temperature = 1 / (a + b * log(Rt) + c * pow(log(Rt),3)); ! temperature -= 273.15; // Convert from Kelvin to Celcius ! //printf("debug: a=%f b=%f c=%f Rt=%f temp=%f\n",a,b,c,Rt,temperature); ! return temperature; ! } ! /** ! * Computes the voltage of an adc channel using the reference voltage. ! * ! * @author Martin Turon ! * ! * @return Voltage of ADC channel as an unsigned integer in mV ! * ! * @version 2004/3/22 mturon Initial revision ! * ! */ ! uint16_t mda500_convert_adc(XbowSensorboardPacket *packet, uint16_t index) ! { ! //XSensorMDA500Data *data = (XSensorMDA500Data *)packet->data; ! float Vbat = mda500_convert_battery(packet); ! uint16_t Vadc = (uint16_t) (packet->data[index] * Vbat / 1023); ! return (uint16_t)Vadc; } /*==========================================================================*/ --- 72,168 ---- } /** ! * Computes the voltage of an adc channel using the reference voltage. * ! * @author Martin Turon * ! * @return Voltage of ADC channel as an unsigned integer in mV * ! * @version 2004/3/22 mturon Initial revision * */ ! uint16_t mda500_convert_adc(XbowSensorboardPacket *packet, uint16_t index) { ! XSensorMDA500Data *pd = (XSensorMDA500Data *)packet->data; ! float Vbat = xconvert_battery_dot(pd->battery); ! uint16_t Vadc = (uint16_t) (packet->data[index] * Vbat / 1023); ! return (uint16_t)Vadc; } + + const char *mda500_db_create_table = + "CREATE TABLE %s%s ( result_time timestamp without time zone, " + "epoch integer, nodeid integer, parent integer, " + "voltage integer, temp integer, adc2 integer," + "adc3 integer, adc4 integer, adc5 integer, adc6 integer, adc7 integer)"; + + const char *mda500_db_create_rule = + "CREATE RULE cache_%s AS ON INSERT TO %s DO ( " + "DELETE FROM %s_L WHERE nodeid = NEW.nodeid; " + "INSERT INTO %s_L VALUES (NEW.*); )"; + /** ! * Logs raw readings to a Postgres database. ! * * @author Martin Turon * ! * @version 2004/7/28 mturon Initial revision * */ ! void mda500_log_raw(XbowSensorboardPacket *packet) { ! XSensorMDA500Data *data = (XSensorMDA500Data *)packet->data; ! char command[512]; ! char *table = xdb_get_table(); ! if (!*table) table = "mda500_results"; ! if (!mda500_packet_handler.flags.table_init) { ! int exists = xdb_table_exists(table); ! if (!exists) { ! // Create results table. ! sprintf(command, mda500_db_create_table, table, ""); ! xdb_execute(command); ! // Create last result cache ! sprintf(command, mda500_db_create_table, table, "_L"); ! xdb_execute(command); ! ! // Add rule to populate last result table ! sprintf(command, mda500_db_create_rule, table, table, table, table); ! xdb_execute(command); ! // Add results table to query log. ! int q_id = XTYPE_MDA500, sample_time = 99000; ! sprintf(command, "INSERT INTO task_query_log " ! "(query_id, tinydb_qid, query_text, query_type, " ! "table_name) VALUES (%i, %i, 'SELECT nodeid,parent,voltage,temp,adc2,adc3, adc4, adc5, adc6, adc7 " ! "SAMPLE PERIOD %i', 'sensor', '%s')", q_id, q_id, ! sample_time, table); ! xdb_execute(command); ! // Log start time of query in time log. ! sprintf(command, "INSERT INTO task_query_time_log " ! "(query_id, start_time) VALUES (%i, now())", q_id); ! xdb_execute(command); ! } ! mda500_packet_handler.flags.table_init = 1; ! } ! sprintf(command, ! "INSERT into %s " ! "(result_time,nodeid,parent,voltage,temp,adc2,adc3, adc4, adc5, adc6, adc7)" ! " values (now(),%u,%u,%u,%u,%u,%u,%u,%u,%u,%u)", ! table, ! //timestring, ! packet->node_id, packet->parent, ! data->battery, data->thermistor, data->adc2, data->adc3, data->adc4, ! data->adc5, data->adc6, data->adc7 ! ); ! ! xdb_execute(command); } + /*==========================================================================*/ *************** *** 198,209 **** void mda400_print_cooked(XbowSensorboardPacket *packet) { ! printf("MDA400 [sensor data converted to engineering units]:\n" ! " health: node id=%i\n" ! " battery: volts=%i mv\n" ! " thermistor: resistance=%i ohms\n", ! packet->node_id, ! mda500_convert_battery(packet), ! mda500_convert_thermistor_resistance(packet)); ! printf("\n"); } --- 182,223 ---- void mda400_print_cooked(XbowSensorboardPacket *packet) { ! XSensorMDA500Data *pd = (XSensorMDA500Data *)packet->data; ! printf("MDA400 [sensor data converted to engineering units]:\n" ! " health: node id=%i\n" ! " battery: volts=%i mv\n" ! " thermistor: resistance=%i ohms, tempurature=%0.2f C\n", ! packet->node_id, ! xconvert_battery_mica2(pd->battery), ! xconvert_thermistor_resistance(pd->thermistor), ! xconvert_thermistor_temperature(pd->thermistor)); ! printf("\n"); } + XPacketHandler mda500_packet_handler = + { + XTYPE_MDA500, + "$Id$", + mda500_print_raw, + mda500_print_cooked, + mda500_print_raw, + mda500_print_cooked, + mda500_log_raw + }; + + void mda500_initialize() { + xpacket_add_type(&mda500_packet_handler); + } + + XPacketHandler mda400_packet_handler = + { + XTYPE_MDA400, + "$Id$", + mda400_print_raw, + mda400_print_cooked, + mda400_print_raw, + mda400_print_cooked + }; + + void mda400_initialize() { + xpacket_add_type(&mda400_packet_handler); + } Index: mts300.c =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/boards/mts300.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mts300.c 15 Jul 2004 17:04:21 -0000 1.1 --- mts300.c 10 Jul 2006 17:15:46 -0000 1.2 *************** *** 6,9 **** --- 6,10 ---- * @version 2004/3/10 mturon Initial version * @n 2004/4/15 husiquan Added temp,light,accel,mic,sounder,mag + * @n 2004/8/2 mturon Added database logging * * Copyright (c) 2004 Crossbow Technology, Inc. All rights reserved. *************** *** 11,19 **** * $Id$ */ ! #include <math.h> #include "../xsensors.h" typedef struct { ! uint16_t vref; uint16_t thermistor; uint16_t light; --- 12,21 ---- * $Id$ */ ! #include "../xdb.h" #include "../xsensors.h" + // packetid =1 ; sersor data typedef struct { ! uint16_t vref; uint16_t thermistor; uint16_t light; *************** *** 32,123 **** } XSensorMTS310Data; ! ! /** ! * Converts mica2 battery reading from raw ADC data to engineering units. ! * ! * @author Martin Turon ! * ! * To compute the battery voltage after measuring the voltage ref: ! * BV = RV*ADC_FS/data ! * where: ! * BV = Battery Voltage ! * ADC_FS = 1024 ! * RV = Voltage Reference for mica2 (1.223 volts) ! * data = data from the adc measurement of channel 7 ! * BV (volts) = 1252.352/data ! * BV (mv) = 1252352/data ! * ! * Note: ! * The thermistor resistance to temperature conversion is highly non-linear. ! * ! * @version 2004/3/29 mturon Initial revision ! * ! */ ! uint16_t mts300_convert_battery(uint16_t vref) ! { ! float x = (float)vref; ! uint16_t vdata = (uint16_t) (1252352 / x); ! return vdata; ! } ! ! ! /** ! * Converts thermistor reading from raw ADC data to engineering units. ! * ! * @author Martin Turon, Alan Broad ! * ! * To compute the thermistor resistance after measuring the thermistor voltage: ! * - Thermistor is a temperature variable resistor ! * - There is a 10K resistor in series with the thermistor resistor. ! * - Compute expected adc output from voltage on thermistor as: ! * ADC= 1023*Rthr/(R1+Rthr) ! * where R1 = 10K ! * Rthr = unknown thermistor resistance ! * Rthr = R1*(ADC_FS-ADC)/ADC ! * where ADC_FS = 1023 ! * ! * Note: ! * The thermistor resistance to temperature conversion is highly non-linear. ! * ! * @return Thermistor resistance as a uint16 in unit (Ohms) ! * ! * @version 2004/3/11 mturon Initial revision ! * ! */ ! uint16_t mts300_convert_thermistor_resistance(uint16_t thermistor) ! { ! float x = (float)thermistor; ! ! uint16_t vdata = 10000* (1023-x) /x; ! ! return vdata; ! } ! ! /** ! * Converts thermistor reading from raw ADC data to engineering units. ! * ! * @author Martin Turon ! * ! * @return Temperature reading from thermistor as a float in degrees Celcius ! * ! * @version 2004/3/22 mturon Initial revision ! * @version 2004/4/19 husq ! * ! */ ! float mts300_convert_thermistor_temperature(uint16_t thermistor) ! { ! float temperature, a, b, c, Rt; ! a = 0.001307050; ! b = 0.000214381; ! c = 0.000000093; ! Rt = mts300_convert_thermistor_resistance(thermistor); ! ! temperature = 1 / (a + b * log(Rt) + c * pow(log(Rt),3)); ! temperature -= 273.15; // Convert from Kelvin to Celcius ! ! //printf("debug: a=%f b=%f c=%f Rt=%f temp=%f\n",a,b,c,Rt,temperature); ! ! return temperature; ! } /** --- 34,39 ---- } XSensorMTS310Data; ! extern XPacketHandler mts300_packet_handler; ! extern XPacketHandler mts310_packet_handler; /** *************** *** 133,137 **** uint16_t mts300_convert_light(uint16_t light, uint16_t vref) { ! float Vbat = mts300_convert_battery(vref); uint16_t Vadc = (uint16_t) (light * Vbat / 1023); return Vadc; --- 49,53 ---- uint16_t mts300_convert_light(uint16_t light, uint16_t vref) { ! float Vbat = xconvert_battery_mica2(vref); uint16_t Vadc = (uint16_t) (light * Vbat / 1023); return Vadc; *************** *** 140,202 **** /** - * Computes the ADC count of a Accelerometer - for X axis reading into - * Engineering Unit (g), per calibration - * - * Calibration done for one test sensor - should be repeated for each unit. - * @author Jaidev Prabhu, Hu Siquan - * - * @version 2004/3/24 jdprabhu Initial revision - * @n 2004/4/19 husq adaption to mts310 - * - */ - float mts310_convert_accel_x(uint16_t data) - { - - uint16_t minus_one_calibration; - uint16_t plus_one_calibration; - - float zero_value; - float reading; - - minus_one_calibration = 0x18D; - plus_one_calibration = 0x1FC; - - zero_value = ( plus_one_calibration - minus_one_calibration ) / 2; - reading = (zero_value - (plus_one_calibration - data) ) / zero_value; - - return reading; - } - - /** - * Computes the ADC count of a Accelerometer - for Y axis reading into - * Engineering Unit (g), per calibration - * Calibration done for one test sensor - should be repeated for each unit. - * - * @author Jaidev Prabhu,Hu Siquan - * - * @version 2004/3/24 jdprabhu Initial revision - * @version 2004/4/19 husq adaption to mts310 - * - */ - float mts310_convert_accel_y(uint16_t data) - { - - uint16_t minus_one_calibration; - uint16_t plus_one_calibration; - - float zero_value; - float reading; - - minus_one_calibration = 0x1AE; - plus_one_calibration = 0x218; - - zero_value = ( plus_one_calibration - minus_one_calibration ) / 2; - reading = ( zero_value - (plus_one_calibration - data) ) / zero_value; - - return reading; - - } - - /** * Computes the ADC count of the Magnetometer - for X axis reading into * Engineering Unit (mgauss), no calibration --- 56,59 ---- *************** *** 256,262 **** void mts300_print_raw(XbowSensorboardPacket *packet) { ! XSensorMTS300Data *data = (XSensorMTS300Data *)packet->data; ! printf("mts300 id=%02x vref=%04x thrm=%04x light=%04x mic=%04x\n", ! packet->node_id, data->vref, data->thermistor, data->light, data->mic); } --- 113,126 ---- void mts300_print_raw(XbowSensorboardPacket *packet) { ! switch(packet->packet_id){ ! case 1:{ ! XSensorMTS300Data *data = (XSensorMTS300Data *)packet->data; ! printf("mts300 id=%02x vref=%04x thrm=%04x light=%04x mic=%04x\n", ! packet->node_id, data->vref, data->thermistor, data->light, data->mic); ! break;} ! default: ! break; ! } ! } *************** *** 264,282 **** void mts300_print_cooked(XbowSensorboardPacket *packet) { ! XSensorMTS300Data *data = (XSensorMTS300Data *)packet->data; ! printf("MTS300 [sensor data converted to engineering units]:\n" ! " health: id = %i\n" ! " battery: = %i mv \n" ! " temperature: = %0.2f degC\n" ! " light: = %i mv\n" ! " microphone: = %i ADC counts\n", ! packet->node_id, ! mts300_convert_battery(data->vref), ! mts300_convert_thermistor_temperature(data->thermistor), ! mts300_convert_light(data->light, data->vref), data->mic); ! printf("\n"); } --- 128,222 ---- void mts300_print_cooked(XbowSensorboardPacket *packet) { ! switch(packet->packet_id){ ! case 1:{ ! XSensorMTS300Data *data = (XSensorMTS300Data *)packet->data; ! printf("MTS300 [sensor data converted to engineering units]:\n" ! " health: node id=%i parent=%i\n" ! " battery: = %i mv \n" ! " temperature: =%0.2f degC\n" ! " light: = %i mv\n" ! " mic: = %i ADC counts\n", ! packet->node_id, packet->parent, ! xconvert_battery_mica2(data->vref), ! xconvert_thermistor_temperature(data->thermistor), ! mts300_convert_light(data->light, data->vref), data->mic); ! ! break;} ! } ! printf("\n"); } + const char *mts300_db_create_table = + "CREATE TABLE %s%s ( result_time timestamp without time zone, " + "epoch integer, nodeid integer, parent integer, " + "voltage integer, temp integer, light integer)"; + + const char *mts300_db_create_rule = + "CREATE RULE cache_%s AS ON INSERT TO %s DO ( " + "DELETE FROM %s_L WHERE nodeid = NEW.nodeid; " + "INSERT INTO %s_L VALUES (NEW.*); )"; + + /** + * Logs raw readings to a Postgres database. + * + * @author Martin Turon + * + * @version 2004/7/28 mturon Initial revision + * + */ + void mts300_log_raw(XbowSensorboardPacket *packet) + { + XSensorMTS300Data *data = (XSensorMTS300Data *)packet->data; + + char command[512]; + char *table = xdb_get_table(); + if (!*table) table = "mts300_results"; + + if (!mts300_packet_handler.flags.table_init) { + int exists = xdb_table_exists(table); + if (!exists) { + // Create results table. + sprintf(command, mts300_db_create_table, table, ""); + xdb_execute(command); + // Create last result cache + sprintf(command, mts300_db_create_table, table, "_L"); + xdb_execute(command); + + // Add rule to populate last result table + sprintf(command, mts300_db_create_rule, table, table, table, table); + xdb_execute(command); + + // Add results table to query log. + int q_id = XTYPE_MTS300, sample_time = 99000; + sprintf(command, "INSERT INTO task_query_log " + "(query_id, tinydb_qid, query_text, query_type, " + "table_name) VALUES (%i, %i, 'SELECT nodeid,parent,voltage,temp,light,mic," + "SAMPLE PERIOD %i', 'sensor', '%s')", q_id, q_id, + sample_time, table); + xdb_execute(command); + + // Log start time of query in time log. + sprintf(command, "INSERT INTO task_query_time_log " + "(query_id, start_time) VALUES (%i, now())", q_id); + xdb_execute(command); + } + mts300_packet_handler.flags.table_init = 1; + } + + sprintf(command, + "INSERT into %s " + "(result_time,nodeid,parent,voltage,temp,light)" + " values (now(),%u,%u,%u,%u,%u,%u)", + table, + //timestring, + packet->node_id, packet->parent, + data->vref, data->thermistor, data->light, data->mic + ); + + xdb_execute(command); + + } + *************** *** 284,317 **** void mts310_print_raw(XbowSensorboardPacket *packet) { ! XSensorMTS310Data *data = (XSensorMTS310Data *)packet->data; ! printf("mts310 id=%02x vref=%04x thrm=%04x light=%04x mic=%04x\n" ! " accelX=%04x accelY=%04x magX=%04x magY=%04x\n", ! packet->node_id, data->vref, data->thermistor, data->light, data->mic, ! data->accelX,data->accelY, data->magX, data->magY); } void mts310_print_cooked(XbowSensorboardPacket *packet) { ! XSensorMTS310Data *data = (XSensorMTS310Data *)packet->data; ! printf("MTS310 [sensor data converted to engineering units]:\n" ! " health: id = %i\n" ! " battery: = %i mv \n" ! " temperature: = %0.2f degC\n" ! " light: = %i ADC mv\n" ! " microphone: = %i ADC counts\n" ! " AccelX: = %f g, AccelY: = %f g\n" ! " MagX: = %0.2f mgauss, MagY: =%0.2f mgauss\n", ! packet->node_id, ! mts300_convert_battery(data->vref), ! mts300_convert_thermistor_temperature(data->thermistor), ! mts300_convert_light(data->light, data->vref), data->mic, ! mts310_convert_accel_x(data->accelX), ! mts310_convert_accel_y(data->accelY), ! mts310_convert_mag_x(data->magX,data->vref), mts310_convert_mag_y(data->magY,data->vref) ! ); ! printf("\n"); ! } --- 224,371 ---- void mts310_print_raw(XbowSensorboardPacket *packet) { ! switch(packet->packet_id){ ! case 1:{ ! XSensorMTS310Data *data = (XSensorMTS310Data *)packet->data; ! printf("mts310 id=%02x vref=%4x thrm=%04x light=%04x mic=%04x\n" ! " accelX=%04x accelY=%04x magX=%04x magY=%04x\n", ! packet->node_id, data->vref, data->thermistor, data->light, data->mic, ! data->accelX,data->accelY, data->magX, data->magY); ! break; } ! default: ! break; ! } } void mts310_print_cooked(XbowSensorboardPacket *packet) { ! switch(packet->packet_id){ ! case 1:{ ! XSensorMTS310Data *data = (XSensorMTS310Data *)packet->data; ! printf("MTS310 [sensor data converted to engineering units]:\n" ! " health: node id=%i parent=%i\n" ! " battery: = %i mv \n" ! " temperature=%0.2f degC\n" ! " light: = %i ADC mv\n" ! " mic: = %i ADC counts\n" ! " AccelX: = %f milliG, AccelY: = %f milliG\n" ! " MagX: = %0.2f mgauss, MagY: =%0.2f mgauss\n", ! packet->node_id, packet->parent, ! xconvert_battery_mica2(data->vref), ! xconvert_thermistor_temperature(data->thermistor), ! mts300_convert_light(data->light, data->vref), data->mic, ! xconvert_accel(data->accelX), xconvert_accel(data->accelY), ! mts310_convert_mag_x(data->magX,data->vref), ! mts310_convert_mag_y(data->magY,data->vref) ! ); ! break;} ! } ! printf("\n"); ! } ! ! const char *mts310_db_create_table = ! "CREATE TABLE %s%s ( result_time timestamp without time zone, " ! "epoch integer, nodeid integer, parent integer, " ! "voltage integer, temp integer, light integer, " ! "accel_x integer, accel_y integer, " ! "mag_x integer, mag_y integer, mic integer )"; ! ! const char *mts310_db_create_rule = ! "CREATE RULE cache_%s AS ON INSERT TO %s DO ( " ! "DELETE FROM %s_L WHERE nodeid = NEW.nodeid; " ! "INSERT INTO %s_L VALUES (NEW.*); )"; ! ! ! /** ! * Logs raw readings to a Postgres database. ! * ! * @author Martin Turon ! * ! * @version 2004/7/28 mturon Initial revision ! * ! */ ! void mts310_log_raw(XbowSensorboardPacket *packet) ! { XSensorMTS310Data *data = (XSensorMTS310Data *)packet->data; ! ! char command[512]; ! char *table = xdb_get_table(); ! if (!*table) table = "mts310_results"; ! ! if (!mts310_packet_handler.flags.table_init) { ! int exists = xdb_table_exists(table); ! if (!exists) { ! // Create results table. ! sprintf(command, mts310_db_create_table, table, ""); ! xdb_execute(command); ! // Create last result cache ! sprintf(command, mts310_db_create_table, table, "_L"); ! xdb_execute(command); ! ! // Add rule to populate last result table ! sprintf(command, mts310_db_create_rule, table, table, table, table); ! xdb_execute(command); ! ! // Add results table to query log. ! int q_id = XTYPE_MTS310, sample_time = 99000; ! sprintf(command, "INSERT INTO task_query_log " ! "(query_id, tinydb_qid, query_text, query_type, " ! "table_name) VALUES (%i, %i, 'SELECT nodeid,parent," ! "voltage,temp,light,accel_x,accel_y,mag_x,mag_y,mic," ! "SAMPLE PERIOD %i', 'sensor', '%s')", q_id, q_id, ! sample_time, table); ! xdb_execute(command); ! ! // Log start time of query in time log. ! sprintf(command, "INSERT INTO task_query_time_log " ! "(query_id, start_time) VALUES (%i, now())", q_id); ! xdb_execute(command); ! } ! mts310_packet_handler.flags.table_init = 1; ! } ! ! sprintf(command, ! "INSERT into %s " ! "(result_time,nodeid,parent,voltage,temp,light," ! "accel_x,accel_y,mag_x,mag_y,mic)" ! " values (now(),%u,%u,%u,%u,%u,%u,%u,%u,%u,%u)", ! table, ! //timestring, ! packet->node_id, packet->parent, ! data->vref, data->thermistor, data->light, ! data->accelX, data->accelY, data->magX, data->magY, data->mic ! ); ! ! xdb_execute(command); ! } ! ! ! XPacketHandler mts300_packet_handler = ! { ! XTYPE_MTS300, ! "$Id$", ! mts300_print_raw, ! mts300_print_cooked, ! mts300_print_raw, ! mts300_print_cooked, ! mts300_log_raw ! }; ! ! void mts300_initialize() { ! xpacket_add_type(&mts300_packet_handler); } + XPacketHandler mts310_packet_handler = + { + XTYPE_MTS310, + "$Id$", + mts310_print_raw, + mts310_print_cooked, + mts310_print_raw, + mts310_print_cooked, + mts310_log_raw, + {0} + }; + void mts310_initialize() { + xpacket_add_type(&mts310_packet_handler); + } Index: mep401.c =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/boards/mep401.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mep401.c 15 Jul 2004 17:04:20 -0000 1.1 --- mep401.c 10 Jul 2006 17:15:46 -0000 1.2 *************** *** 11,43 **** * $Id$ */ #include <math.h> #include "../xsensors.h" ! /** MEP401 XSensor packet 1 -- contains Accel/Light/Humidity sensors readings */ ! typedef struct { ! uint16_t vref; uint16_t accel_x; uint16_t accel_y; [...1035 lines suppressed...] ! PQfinish(conn); } ! ! ! ! XPacketHandler mep401_packet_handler = { ! XTYPE_MEP401, ! "$Id$", ! mep401_print_raw, ! mep401_print_cooked, ! mep401_print_raw, ! mep401_print_cooked, ! mep401_log_raw ! }; + void mep401_initialize() { + xpacket_add_type(&mep401_packet_handler); + } Index: mda300.c =================================================================== RCS file: /cvsroot/firebug/fireboard/tools/src/xlisten/boards/mda300.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mda300.c 15 Jul 2004 17:04:20 -0000 1.1 --- mda300.c 10 Jul 2006 17:15:46 -0000 1.2 *************** *** 12,15 **** --- 12,20 ---- #include <math.h> + + #ifdef __arm__ + #include <sys/types.h> + #endif + #include "../xsensors.h" *************** *** 49,62 **** typedef struct { uint16_t battery; ! uint16_t humidity; ! uint16_t temperature; uint16_t counter; } XSensorMDA300Data4; ! uint32_t mda300_convert_adc_single (uint16_t adc_prec); ! int32_t mda300_convert_adc_precision (uint16_t adc_prec); ! float mda300_convert_temperature (XSensorMDA300Data4 *data); ! uint16_t mda300_convert_humidity (XSensorMDA300Data4 *data); ! uint16_t mda300_convert_battery (XSensorMDA300Data4 *data); /** --- 54,84 ---- typedef struct { uint16_t battery; ! XSensorSensirion sensirion; uint16_t counter; } XSensorMDA300Data4; ! /** MDA300 XSensor packet 5 -- contains MultiHop packets. */ ! typedef struct { ! uint16_t seq_no; ! uint16_t adc0; ! uint16_t adc1; ! uint16_t adc2; ! uint16_t battery; ! XSensorSensirion sensirion; ! } __attribute__ ((packed)) XSensorMDA300Data5; ! ! //pp:multihop need only the packet6 ! typedef struct XSensorMDA300Data6 { ! uint16_t vref; ! uint16_t humid; ! uint16_t humtemp; ! uint16_t adc0; ! uint16_t adc1; ! uint16_t adc2; ! uint16_t dig0; ! uint16_t dig1; ! uint16_t dig2; ! } __attribute__ ((packed)) XSensorMDA300Data6; ! extern XPacketHandler mda300_packet_handler; /** *************** *** 92,96 **** case 3: { XSensorMDA300Data3 *data = (XSensorMDA300Data3 *)packet->data; ! printf("mda300 id=%02x d1=%04x d2=%04x d3=%04x d4=%04x d5=%04x\n", packet->node_id, data->digi0, data->digi1, data->digi2, data->digi3, data->digi4, data->digi5); --- 114,118 ---- case 3: { XSensorMDA300Data3 *data = (XSensorMDA300Data3 *)packet->data; ! printf("mda300 id=%02x d1=%04x d2=%04x d3=%04x d4=%04x d5=%04x", packet->node_id, data->digi0, data->digi1, data->digi2, data->digi3, data->digi4, data->digi5); *************** *** 101,106 **** XSensorMDA300Data4 *data = (XSensorMDA300Data4 *)packet->data; printf("mda300 id=%02x bat=%04x hum=%04x temp=%04x cntr=%04x\n", ! packet->node_id, data->battery, data->humidity, ! data->temperature, data->counter); break; } --- 123,149 ---- XSensorMDA300Data4 *data = (XSensorMDA300Data4 *)packet->data; printf("mda300 id=%02x bat=%04x hum=%04x temp=%04x cntr=%04x\n", ! packet->node_id, data->battery, data->sensirion.humidity, ! data->sensirion.thermistor, data->counter); ! break; ! } ! ! case 5: { ! XSensorMDA300Data5 *data = (XSensorMDA300Data5 *)packet->data; ! printf("mda300 id=%02x bat=%04x hum=%04x temp=%04x " ! " echo10=%04x echo20=%04x soiltemp=%04x\n", ! packet->node_id, data->battery, ! data->sensirion.humidity, data->sensirion.thermistor, ! data->adc0, data->adc1, data->adc2); ! break; ! } ! case 6: { ! XSensorMDA300Data6 *data = (XSensorMDA300Data6 *)packet->data; ! printf("mda300 id=%02x bat=%04x hum=%04x temp=%04x " ! " adc0=%04x adc1=%04x adc2=%04x\n" ! " dig0=%04x dig1=%04x dig2=%04x\n", ! packet->node_id, data->vref, ! data->humid, data->humtemp, ! data->adc0, data->adc1, data->adc2, ! data->dig0, data->dig1, data->dig2); break; } *************** *** 124,134 **** " adc chan 6: voltage=%i mV\n\n", packet->node_id, packet->packet_id, ! mda300_convert_adc_single(packet->data[0]), ! mda300_convert_adc_single(packet->data[1]), ! mda300_convert_adc_single(packet->data[2]), ! mda300_convert_adc_single(packet->data[3]), ! mda300_convert_adc_single(packet->data[4]), ! mda300_convert_adc_single(packet->data[5]), ! mda300_convert_adc_single(packet->data[6])); } --- 167,177 ---- " adc chan 6: voltage=%i mV\n\n", packet->node_id, packet->packet_id, ! xconvert_adc_single(packet->data[0]), ! xconvert_adc_single(packet->da... [truncated message content] |
From: David M. D. <do...@us...> - 2006-07-10 17:10:29
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/timestamp In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv16741 Added Files: timestamp.c timestamp.h Log Message: . --- NEW FILE: timestamp.h --- /** * Standard TinyOS license here. */ /** * Parts of this code were developed as part of * the NSF-ITR FireBug project. * * @author David M. Doolin * * @url http://firebug.sourceforge.net * */ /** * $Id: timestamp.h,v 1.1 2006/07/10 17:10:27 doolin Exp $ */ #ifndef FB_TIMESTAMP_H #define FB_TIMESTAMP_H #ifdef __cplusplus extern "C" { #endif #define TIMESTRING_SIZE 128 /** Incomplete type, easier to extend later. */ typedef struct _timestamp Timestamp; Timestamp * timestamp_new (void); void timestamp_delete (Timestamp * ts); /** A handy format matching a mysql's time stamping syntax. * The date written as text can be imported directly into * a mysql table. */ void timestamp_get_ymdhms (Timestamp * ts, char * timestring); void timestamp_get_string (Timestamp * ts, char * timestring); #ifdef __cplusplus } #endif #endif /* FB_TIMESTAMP_H */ --- NEW FILE: timestamp.c --- /** * Standard TinyOS license here. */ /** * Parts of this code were developed as part of * the NSF-ITR FireBug project. * * @author David M. Doolin * * @url http://firebug.sourceforge.net * */ /** * $Id: timestamp.c,v 1.1 2006/07/10 17:10:27 doolin Exp $ */ #include <time.h> #include <stdlib.h> #include <memory.h> #include <locale.h> #include "timestamp.h" #ifdef __cplusplus extern "C" { #endif struct _timestamp { struct tm * time; }; Timestamp * timestamp_new (void) { Timestamp * ts = (Timestamp*)malloc(sizeof(Timestamp)); // Shred memory to indicate initialization status. memset((void*)ts,0xda,sizeof(Timestamp)); return ts; } void timestamp_delete (Timestamp * ts) { // Shred memory going out to indicate invalid access. memset((void*)ts,0xdd,sizeof(Timestamp)); free(ts); } /** @brief Get a timestamp in MySQL compatible format. * The innards could probably be slightly * improved. See header file to check/adjust * TIMESTRING_SIZE * * @author David M. Doolin */ void timestamp_get_ymdhms (Timestamp * ts, char timestring[TIMESTRING_SIZE]) { struct tm * l_time = ts->time; time_t timetype; timetype = time(NULL); l_time = localtime(&timetype); strftime(timestring, TIMESTRING_SIZE, "%Y%m%d%H%M%S", l_time); } /** * Return string of timestamp in YYYY/MM/DD hh:mm:ss format. * * @version 2004/9/27 mturon Initial revision */ void timestamp_get_string (Timestamp * ts, char timestring[TIMESTRING_SIZE]) { struct tm * l_time = ts->time; time_t timetype; timetype = time(NULL); l_time = localtime(&timetype); strftime(timestring, TIMESTRING_SIZE, "%Y/%m/%d %H:%M:%S", l_time); } #ifdef __cplusplus } #endif |
From: David M. D. <do...@us...> - 2006-07-10 17:09:13
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/ucb In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv16267/ucb Log Message: Directory /cvsroot/firebug/fireboard/tools/src/xlisten/ucb added to the repository |
From: David M. D. <do...@us...> - 2006-07-10 17:06:47
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/amtypes In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv15092 Added Files: health.c surge.c Log Message: . --- NEW FILE: health.c --- /** * Handles conversion to engineering units of mts500 packets. * * @file health.c * @author Martin Turon * @version 2005/1/21 mturon Initial version * * Copyright (c) 2005 Crossbow Technology, Inc. All rights reserved. * * $Id: health.c,v 1.1 2006/07/10 17:06:44 doolin Exp $ */ #include "../xdb.h" #include "../xsensors.h" typedef struct DBGEstEntry { uint16_t id; uint8_t hopcount; uint8_t sendEst; } __attribute__ ((packed)) DBGEstEntry; typedef struct HealthData { // MultihopMsg uint16_t nodeid; uint16_t originaddr; int16_t seqno; uint8_t hopcount; // HealthMsg uint8_t estEntries; DBGEstEntry estList[4]; } __attribute__ ((packed)) HealthData; extern XPacketHandler health_packet_handler; #define health_nhood(x) ((x)->estEntries & 0xF) /** HEALTH Specific outputs of raw readings within an XBowSensorboardPacket */ void health_print_raw(XbowSensorboardPacket *packet) { HealthData *data = (HealthData *)packet; printf("health id=%04x seq=%04x hops=%02x nhood=%02x\n", data->nodeid, data->seqno, data->hopcount, health_nhood(data)); } void health_print_cooked(XbowSensorboardPacket *packet) { HealthData *data = (HealthData *)packet; int nhood = health_nhood(data); printf("HEALTH : node_id=%i seq_no=%i hops=%i nhood=%i\n", data->nodeid, data->seqno, data->hopcount, nhood ); while(nhood--) { printf(" neighbor: id=%i hops=%i est=%i\n", data->estList[nhood].id, data->estList[nhood].hopcount, data->estList[nhood].sendEst ); } printf("\n"); } const char *health_db_create_table = "CREATE TABLE %s%s ( result_time timestamp without time zone, " "nodeid integer,parent integer,epoch integer," "voltage integer,temp integer,light integer," "accel_x integer,accel_y integer," "mag_x integer,mag_y integer)"; const char *health_db_create_rule = "CREATE RULE cache_%s AS ON INSERT TO %s DO ( " "DELETE FROM %s_L WHERE nodeid = NEW.nodeid; " "INSERT INTO %s_L VALUES (NEW.*); )"; /** * Logs raw readings to a Postgres database. * * @author Martin Turon * * @version 2004/7/28 mturon Initial revision * */ void health_log_raw(XbowSensorboardPacket *packet) { #if 0 HealthData *data = (HealthData *)packet; char command[512]; char *table = xdb_get_table(); if (!*table) table = "health_results"; if (!health_packet_handler.flags.table_init) { int exists = xdb_table_exists(table); if (!exists) { // Create results table. sprintf(command, health_db_create_table, table, ""); xdb_execute(command); // Create last result cache sprintf(command, health_db_create_table, table, "_L"); xdb_execute(command); // Add rule to populate last result table sprintf(command, health_db_create_rule, table, table, table, table); xdb_execute(command); // Add results table to query log. int q_id = XTYPE_HEALTH, sample_time = 99000; sprintf(command, "INSERT INTO task_query_log " "(query_id, tinydb_qid, query_text, query_type, " "table_name) VALUES (%i, %i, 'SELECT nodeid,parent," "epoch,voltage,temp,light,accel_x,accel_y,mag_x,mag_y " "SAMPLE PERIOD %i', 'sensor', '%s')", q_id, q_id, sample_time, table); xdb_execute(command); // Log start time of query in time log. sprintf(command, "INSERT INTO task_query_time_log " "(query_id, start_time) VALUES (%i, now())", q_id); xdb_execute(command); } health_packet_handler.flags.table_init = 1; } sprintf(command, "INSERT into %s " "(result_time,nodeid,parent,epoch,voltage,temp,light," "accel_x,accel_y,mag_x,mag_y)" " values (now(),%u,%u,%u,%u,%u,%u,%u,%u,%u,%u)", table, //timestring, data->nodeid, data->parent, health_get_epoch(data), health_get_vref(data), data->thermistor<<2, data->light, data->accelX<<2, data->accelY<<2, data->magX, data->magY ); xdb_execute(command); #endif } XPacketHandler health_packet_handler = { AMTYPE_HEALTH, //XTYPE_HEALTH, "$Id: health.c,v 1.1 2006/07/10 17:06:44 doolin Exp $", health_print_raw, health_print_cooked, health_print_raw, health_print_cooked, health_log_raw }; void health_initialize() { xpacket_add_amtype(&health_packet_handler); } --- NEW FILE: surge.c --- /** * Handles conversion to engineering units of mts500 packets. * * @file mts300.c * @author Martin Turon, Hu Siquan * @version 2004/3/10 mturon Initial version * @n 2004/4/15 husiquan Added temp,light,accel,mic,sounder,mag * @n 2004/8/2 mturon Added database logging * * Copyright (c) 2004 Crossbow Technology, Inc. All rights reserved. * * $Id: surge.c,v 1.1 2006/07/10 17:06:44 doolin Exp $ */ #include "../xdb.h" #include "../xsensors.h" typedef struct SurgeData { // MultihopMsg uint16_t destaddr; uint16_t nodeid; int16_t seqno; uint8_t hopcount; // SurgeMsg uint8_t type; uint16_t current; uint16_t parent; uint32_t seq_no; // encoded vref in higher 9 bits uint8_t light; uint8_t thermistor; uint8_t magX; uint8_t magY; uint8_t accelX; uint8_t accelY; } __attribute__ ((packed)) SurgeData; /** Mad, wild, jhill-i-fied voltage encoding, saves space, cost: time! ;) */ #define surge_get_vref(x) (((x)->seq_no & 0xFF800000) >> 23) #define surge_get_epoch(x) ((x)->seq_no & 0x007FFFFF) extern XPacketHandler surge_packet_handler; /** * Computes the Clairex CL94L light sensor reading * * @author Hu Siquan * * @return Voltage of ADC channel as an unsigned integer in mV * * @version 2004/4/19 husq Initial revision * */ uint16_t surge_convert_light(uint16_t light, uint16_t vref) { float Vbat = xconvert_battery_mica2(vref); uint16_t Vadc = (uint16_t) (light * Vbat / 1023); return Vadc; } /** * Computes the ADC count of the Magnetometer - for X axis reading into * Engineering Unit (mgauss), no calibration * * SENSOR Honeywell HMC1002 * SENSITIVITY 3.2mv/Vex/gauss * EXCITATION 3.0V (nominal) * AMPLIFIER GAIN 2262 * ADC Input 22mV/mgauss * * @author Hu Siquan * * @version 2004/4/26 husq Initial Version * */ float surge_convert_mag_x(uint16_t data,uint16_t vref) { // float Vbat = surge_convert_battery(vref); // float Vadc = data * Vbat / 1023; // return Vadc/(2.262*3.0*3.2); float Magx = data / (1.023*2.262*3.2); return Magx; } /** * Computes the ADC count of the Magnetometer - for Y axis reading into * Engineering Unit (mgauss), no calibration * * SENSOR Honeywell HMC1002 * SENSITIVITY 3.2mv/Vex/gauss * EXCITATION 3.0V (nominal) * AMPLIFIER GAIN 2262 * ADC Input 22mV/mgauss * * @author Hu Siquan * * @version 2004/4/26 husq Initial Version * */ float surge_convert_mag_y(uint16_t data,uint16_t vref) { // float Vbat = surge_convert_battery(vref); // float Vadc = (data * Vbat / 1023); // return Vadc/(2.262*3.0*3.2); float Magy = data / (1.023*2.262*3.2); return Magy; } /** SURGE Specific outputs of raw readings within an XBowSensorboardPacket */ void surge_print_raw(XbowSensorboardPacket *packet) { SurgeData *data = (SurgeData *)packet; printf("surge id=%02x parent=%02x seq=%04x vref=%04x \n" " thrm=%04x light=%04x accelX=%04x accelY=%04x " "magX=%04x magY=%04x\n", data->nodeid, data->parent, surge_get_epoch(data), surge_get_vref(data), data->thermistor, data->light, data->accelX, data->accelY, data->magX, data->magY); } void surge_print_cooked(XbowSensorboardPacket *packet) { SurgeData *data = (SurgeData *)packet; printf("SURGE [sensor data converted to engineering units]:\n" " health: node id=%i parent=%i seq_no=%i\n" " battery = %i mv\n" " temperature = %0.2f degC\n" " light: = %i ADC mv\n" " AccelX: = %f g, AccelY: = %f g\n" " MagX: = %0.2f mgauss, MagY: = %0.2f mgauss\n", data->nodeid, data->parent, surge_get_epoch(data), xconvert_battery_mica2(surge_get_vref(data)), xconvert_thermistor_temperature(data->thermistor<<2), surge_convert_light(data->light, surge_get_vref(data)), xconvert_accel(data->accelX<<2), xconvert_accel(data->accelY<<2), surge_convert_mag_x(data->magX,surge_get_vref(data)), surge_convert_mag_y(data->magY,surge_get_vref(data)) ); printf("\n"); } const char *surge_db_create_table = "CREATE TABLE %s%s ( result_time timestamp without time zone, " "nodeid integer,parent integer,epoch integer," "voltage integer,temp integer,light integer," "accel_x integer,accel_y integer," "mag_x integer,mag_y integer)"; const char *surge_db_create_rule = "CREATE RULE cache_%s AS ON INSERT TO %s DO ( " "DELETE FROM %s_L WHERE nodeid = NEW.nodeid; " "INSERT INTO %s_L VALUES (NEW.*); )"; /** * Logs raw readings to a Postgres database. * * @author Martin Turon * * @version 2004/7/28 mturon Initial revision * */ void surge_log_raw(XbowSensorboardPacket *packet) { SurgeData *data = (SurgeData *)packet; char command[512]; char *table = xdb_get_table(); if (!*table) table = "surge_results"; if (!surge_packet_handler.flags.table_init) { int exists = xdb_table_exists(table); if (!exists) { // Create results table. sprintf(command, surge_db_create_table, table, ""); xdb_execute(command); // Create last result cache sprintf(command, surge_db_create_table, table, "_L"); xdb_execute(command); // Add rule to populate last result table sprintf(command, surge_db_create_rule, table, table, table, table); xdb_execute(command); // Add results table to query log. int q_id = XTYPE_SURGE, sample_time = 99000; sprintf(command, "INSERT INTO task_query_log " "(query_id, tinydb_qid, query_text, query_type, " "table_name) VALUES (%i, %i, 'SELECT nodeid,parent," "epoch,voltage,temp,light,accel_x,accel_y,mag_x,mag_y " "SAMPLE PERIOD %i', 'sensor', '%s')", q_id, q_id, sample_time, table); xdb_execute(command); // Log start time of query in time log. sprintf(command, "INSERT INTO task_query_time_log " "(query_id, start_time) VALUES (%i, now())", q_id); xdb_execute(command); } surge_packet_handler.flags.table_init = 1; } sprintf(command, "INSERT into %s " "(result_time,nodeid,parent,epoch,voltage,temp,light," "accel_x,accel_y,mag_x,mag_y)" " values (now(),%u,%u,%u,%u,%u,%u,%u,%u,%u,%u)", table, //timestring, data->nodeid, data->parent, surge_get_epoch(data), surge_get_vref(data), data->thermistor<<2, data->light, data->accelX<<2, data->accelY<<2, data->magX, data->magY ); xdb_execute(command); } XPacketHandler surge_packet_handler = { AMTYPE_SURGE_MSG, //XTYPE_SURGE, "$Id: surge.c,v 1.1 2006/07/10 17:06:44 doolin Exp $", surge_print_raw, surge_print_cooked, surge_print_raw, surge_print_cooked, surge_log_raw }; void surge_initialize() { xpacket_add_amtype(&surge_packet_handler); } |
From: David M. D. <do...@us...> - 2006-07-10 17:04:29
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/timestamp In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv14267/timestamp Log Message: Directory /cvsroot/firebug/fireboard/tools/src/xlisten/timestamp added to the repository |
From: David M. D. <do...@us...> - 2006-07-10 17:04:29
|
Update of /cvsroot/firebug/fireboard/tools/src/xlisten/amtypes In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv14267/amtypes Log Message: Directory /cvsroot/firebug/fireboard/tools/src/xlisten/amtypes added to the repository |
From: David M. D. <do...@us...> - 2006-07-10 16:53:28
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten/ucb In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv9436 Modified Files: 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 Log Message: Added new types. |
From: David M. D. <do...@us...> - 2006-04-17 02:40:38
|
Update of /cvsroot/firebug/firebug/project/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20461/project/java Modified Files: mhrun.sh Log Message: > Index: mhrun.sh =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/mhrun.sh,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** mhrun.sh 14 Sep 2004 23:37:59 -0000 1.11 --- mhrun.sh 17 Apr 2006 02:40:34 -0000 1.12 *************** *** 28,34 **** echo $HOSTNAME export MSGPATH=C:\\cygwin\\opt\\tinyos-1.x\\tools\\java ! elif [ $HOSTNAME = Firebug2 ]; then ! echo $HOSTNAME ! export MSGPATH=C:\\cygwin\\opt\\tinyos-1.x\\tools\\java else echo Set MSGPATH to point to tinyos-1.x/tools/java --- 28,34 ---- echo $HOSTNAME export MSGPATH=C:\\cygwin\\opt\\tinyos-1.x\\tools\\java ! #elif [ $HOSTNAME = Firebug2 ]; then ! # echo $HOSTNAME ! # export MSGPATH=C:\\cygwin\\opt\\tinyos-1.x\\tools\\java else echo Set MSGPATH to point to tinyos-1.x/tools/java |
From: David M. D. <do...@us...> - 2006-04-17 02:40:38
|
Update of /cvsroot/firebug/fireboard/beta/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20461/fireboard/beta/bin Modified Files: fbusers.sh Log Message: > Index: fbusers.sh =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/bin/fbusers.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fbusers.sh 2 Aug 2005 17:37:41 -0000 1.2 --- fbusers.sh 17 Apr 2006 02:40:34 -0000 1.3 *************** *** 1,5 **** #!/bin/sh ! createuser dave --echo --adduser --createdb #--pwprompt createuser kar --echo --adduser --createdb #--pwprompt createuser test --echo --adduser --createdb #--pwprompt --- 1,5 ---- #!/bin/sh ! createuser dave --echo --adduser --createdb -U postgres #--pwprompt createuser kar --echo --adduser --createdb #--pwprompt createuser test --echo --adduser --createdb #--pwprompt |
From: David M. D. <do...@us...> - 2006-03-20 23:10:11
|
Update of /cvsroot/firebug/firebug/project/hazelatlas/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19266/data Log Message: Directory /cvsroot/firebug/firebug/project/hazelatlas/data added to the repository |