[Firebug-cvs] fireboard/beta/tools/src/xlisten/boards linkmsg.c,NONE,1.1 testlink.c,NONE,1.1
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2005-07-30 02:15:34
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten/boards In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20044 Added Files: linkmsg.c testlink.c Log Message: fireworks messages compile. --- NEW FILE: linkmsg.c --- /** * This class is automatically generated by mig. DO NOT EDIT THIS FILE. * This code implements C interface to the 'LinkMsg' * message type. */ #include <stdio.h> #include <stdlib.h> #include <memory.h> /** Private header is programmer specified for handling * conversion functions, etc. */ //#include "LinkMsg_private.h" /** Not the best way to handle xbow dependencies. */ #include "../xdb.h" /** These need to be moved to a header file. */ typedef struct _LinkMsg LinkMsg; typedef struct _XbowSensorboardPacket XbowSensorboardPacket; // 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 _LinkMsg { uint16_t header_am_type; uint16_t header_seqno; uint32_t tstamp; uint16_t moteid; uint16_t RSSI; uint16_t LQI; }; void LinkMsg_set_header_am_type(LinkMsg * userdata, uint16_t header_am_type) { userdata->header_am_type = header_am_type; } uint16_t LinkMsg_get_header_am_type(LinkMsg * userdata) { return userdata->header_am_type; } void LinkMsg_set_header_seqno(LinkMsg * userdata, uint16_t header_seqno) { userdata->header_seqno = header_seqno; } uint16_t LinkMsg_get_header_seqno(LinkMsg * userdata) { return userdata->header_seqno; } void LinkMsg_set_tstamp(LinkMsg * userdata, uint32_t tstamp) { userdata->tstamp = tstamp; } uint32_t LinkMsg_get_tstamp(LinkMsg * userdata) { return userdata->tstamp; } void LinkMsg_set_moteid(LinkMsg * userdata, uint16_t moteid) { userdata->moteid = moteid; } uint16_t LinkMsg_get_moteid(LinkMsg * userdata) { return userdata->moteid; } void LinkMsg_set_RSSI(LinkMsg * userdata, uint16_t RSSI) { userdata->RSSI = RSSI; } uint16_t LinkMsg_get_RSSI(LinkMsg * userdata) { return userdata->RSSI; } void LinkMsg_set_LQI(LinkMsg * userdata, uint16_t LQI) { userdata->LQI = LQI; } uint16_t LinkMsg_get_LQI(LinkMsg * 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 LinkMsg (" "header_am_type," "header_seqno," "tstamp," "moteid," "RSSI," "LQI) values (%i, %i, %i, %i, %i, %i)"; void LinkMsg_pg_log(XbowSensorboardPacket * userdata) { char pg_command[255]; LinkMsg * data = (LinkMsg*)userdata; sprintf(pg_command,insert_stmt, data->header_am_type, data->header_seqno, data->tstamp, data->moteid, data->RSSI, data->LQI); xdb_execute(pg_command); } /** @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 LinkMsg_cook_packet(LinkMsg * 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. */ LinkMsg * LinkMsg_convert(char * data) { // Just to keep gcc happy. return (LinkMsg*)data; } /** Print the bytes of the packet. */ void LinkMsg_print_raw (XbowSensorboardPacket *packet) { } /** Print cooked output. */ void LinkMsg_print_cooked (XbowSensorboardPacket * userdata) { LinkMsg * data = (LinkMsg*)userdata; 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); } /** The default size of this message type in bytes. */ //static int DEFAULT_MESSAGE_SIZE = 14; /** The Active Message type associated with this message. */ //static int AM_TYPE = 200; /** If incomplete types are used, we need to provide a way * to manage memory. */ LinkMsg * LinkMsg_new() { LinkMsg * userdata = (LinkMsg*)malloc(sizeof(LinkMsg)); memset((void*)userdata,0xda,sizeof(LinkMsg)); return userdata; } void LinkMsg_delete(LinkMsg * userdata) { memset((void*)userdata,0xdd,sizeof(LinkMsg)); free(userdata); } --- 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 = { XTYPE_TESTLINK, "$Id: testlink.c,v 1.1 2005/07/30 02:15:17 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); } |