[Firebug-cvs] fireboard/fireboard/sensors/leadtek9546 GpsPacket.nc,1.4,1.5 GpsPacketM.nc,1.1,1.2 gps
Brought to you by:
doolin
From: <do...@us...> - 2004-02-04 00:04:33
|
Update of /cvsroot/firebug/fireboard/fireboard/sensors/leadtek9546 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12533/sensors/leadtek9546 Modified Files: GpsPacket.nc GpsPacketM.nc gps_driver.nc gps_driverM.nc leadtek_9546.h Log Message: Moved some clean code in. Index: GpsPacket.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/fireboard/sensors/leadtek9546/GpsPacket.nc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GpsPacket.nc 29 Jan 2004 14:48:04 -0000 1.4 --- GpsPacket.nc 3 Feb 2004 20:06:44 -0000 1.5 *************** *** 75,79 **** interface BareSendMsg as Send; interface ReceiveMsg as Receive; ! interface I2CSwitchCmds as GpsCmd; } } --- 75,79 ---- interface BareSendMsg as Send; interface ReceiveMsg as Receive; ! interface I2CSwitchCmds;// as GpsCmd; } } *************** *** 86,90 **** MicaWbSwitch; ! GpsCmd = GpsPacketM.GpsCmd; Control = GpsPacketM.Control; Send = GpsPacketM.Send; --- 86,91 ---- MicaWbSwitch; ! //GpsCmd = GpsPacketM.GpsCmd; ! I2CSwitchCmds = GpsPacketM; Control = GpsPacketM.Control; Send = GpsPacketM.Send; *************** *** 93,96 **** --- 94,100 ---- GpsPacketM.Leds -> LedsC; + // UART1 probably isn't strictly necessary, + // but it allows using local files instead + // of wiring to files in the tos tree. GpsPacketM.ByteControl -> UART1; GpsPacketM.ByteComm -> UART1; Index: GpsPacketM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/fireboard/sensors/leadtek9546/GpsPacketM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GpsPacketM.nc 29 Jan 2004 14:48:04 -0000 1.1 --- GpsPacketM.nc 3 Feb 2004 20:06:44 -0000 1.2 *************** *** 90,94 **** interface ReceiveMsg as Receive; interface SendVarLenPacket; ! interface I2CSwitchCmds as GpsCmd; command result_t txBytes(uint8_t *bytes, uint8_t numBytes); --- 90,94 ---- interface ReceiveMsg as Receive; interface SendVarLenPacket; ! interface I2CSwitchCmds;// as GpsCmd; command result_t txBytes(uint8_t *bytes, uint8_t numBytes); *************** *** 115,121 **** implementation { ! enum {GPS_SWITCH_IDLE, //GPS I2C switches are not using the I2C bus GPS_PWR_SWITCH_WAIT, //Waiting for GPS I2C power switch to set ! GPS_EN_SWITCH_WAIT, //Waiting for GPS I2C enable switch to set GPS_TX_SWITCH_WAIT, //Waiting for GPS I2C tx switch to set GPS_RX_SWITCH_WAIT, //Waiting for GPS I2C rx switch to set --- 115,125 ---- implementation { ! #include "SODebug.h" ! #define DBG_USR2 1 ! ! ! enum {GPS_I2C_SWITCH_IDLE, //GPS I2C switches are not using the I2C bus GPS_PWR_SWITCH_WAIT, //Waiting for GPS I2C power switch to set ! GPS_I2C_ENABLE_SWITCH_WAIT, //Waiting for GPS I2C enable switch to set GPS_TX_SWITCH_WAIT, //Waiting for GPS I2C tx switch to set GPS_RX_SWITCH_WAIT, //Waiting for GPS I2C rx switch to set *************** *** 175,179 **** bufferIndex = 0; (GPS_Msg*) bufferPtr = &buffer; ! state_gps = GPS_SWITCH_IDLE; state_gps_pkt = NO_GPS_START_BYTE; state = IDLE; --- 179,183 ---- bufferIndex = 0; (GPS_Msg*) bufferPtr = &buffer; ! state_gps = GPS_I2C_SWITCH_IDLE; state_gps_pkt = NO_GPS_START_BYTE; state = IDLE; *************** *** 223,230 **** command result_t Send.send(TOS_MsgPtr msg) { ! GPS_Msg * gps_msg = (GPS_Msg*)msg; ! state = PACKET; //msg->crc = 1; /* Fake out the CRC as passed. */ //return call txBytes((uint8_t *)msg, TOS_MsgLength(msg->type)); //return call txBytes(msg->data, msg->length); --- 227,235 ---- command result_t Send.send(TOS_MsgPtr msg) { ! //GPS_Msg * gps_msg = (GPS_Msg*)msg; ! //state = PACKET; //msg->crc = 1; /* Fake out the CRC as passed. */ + state = PACKET; //return call txBytes((uint8_t *)msg, TOS_MsgLength(msg->type)); //return call txBytes(msg->data, msg->length); *************** *** 238,241 **** --- 243,247 ---- state = BYTES; + return call txBytes(packet, numBytes); } *************** *** 273,276 **** --- 279,283 ---- + void sendComplete(result_t success) { *************** *** 300,303 **** --- 307,311 ---- default event result_t SendVarLenPacket.sendDone(uint8_t* packet, result_t success) { + SODbg(DBG_USR2, "$GpsPacketM.SendVarLenPacket.sendDone(): success: %i\r\n", success); return success; } *************** *** 420,429 **** *****************************************************************************/ ! command result_t GpsCmd.PowerSwitch(uint8_t PowerState){ ! //GPSDbg(DBG_USR2, "GpsPacket.PowerSwitch.setDone(): PowerState: %i \n", PowerState); ! if (state_gps == GPS_SWITCH_IDLE){ power_gps = PowerState; --- 428,437 ---- *****************************************************************************/ ! //command result_t GpsCmd.PowerSwitch(uint8_t PowerState){ ! command result_t I2CSwitchCmds.PowerSwitch(uint8_t PowerState){ //GPSDbg(DBG_USR2, "GpsPacket.PowerSwitch.setDone(): PowerState: %i \n", PowerState); ! if (state_gps == GPS_I2C_SWITCH_IDLE){ power_gps = PowerState; *************** *** 447,450 **** --- 455,459 ---- + /** Power or Enabled switch set */ event result_t PowerSwitch.setDone(bool local_result) { *************** *** 452,458 **** if (state_gps == GPS_PWR_SWITCH_WAIT) { if (call PowerSwitch.set(MICAWB_GPS_ENABLE ,power_gps) == SUCCESS) { ! state_gps = GPS_EN_SWITCH_WAIT; } ! } else if (state_gps == GPS_EN_SWITCH_WAIT) { if (call IOSwitch.set( MICAWB_GPS_TX_SELECT ,power_gps) == SUCCESS) { state_gps = GPS_TX_SWITCH_WAIT; --- 461,467 ---- if (state_gps == GPS_PWR_SWITCH_WAIT) { if (call PowerSwitch.set(MICAWB_GPS_ENABLE ,power_gps) == SUCCESS) { ! state_gps = GPS_I2C_ENABLE_SWITCH_WAIT; } ! } else if (state_gps == GPS_I2C_ENABLE_SWITCH_WAIT) { if (call IOSwitch.set( MICAWB_GPS_TX_SELECT ,power_gps) == SUCCESS) { state_gps = GPS_TX_SWITCH_WAIT; *************** *** 476,482 **** } } else if (state_gps == GPS_RX_SWITCH_WAIT) { ! //GPSDbg(DBG_USR2, "GpsPacket.IOSwitch.setDone(): all switches set \n"); ! state_gps = GPS_SWITCH_IDLE; ! signal GpsCmd.SwitchesSet(state_gps); } --- 485,491 ---- } } else if (state_gps == GPS_RX_SWITCH_WAIT) { ! state_gps = GPS_I2C_SWITCH_IDLE; ! //signal GpsCmd.SwitchesSet(state_gps); ! signal I2CSwitchCmds.SwitchesSet(state_gps); } Index: gps_driver.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/fireboard/sensors/leadtek9546/gps_driver.nc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gps_driver.nc 29 Jan 2004 14:48:04 -0000 1.5 --- gps_driver.nc 3 Feb 2004 20:06:44 -0000 1.6 *************** *** 69,72 **** gps_driverM.GpsSend -> GpsPacket; gps_driverM.GpsReceive -> GpsPacket; ! gps_driverM.GpsCmd -> GpsPacket.GpsCmd; } --- 69,76 ---- gps_driverM.GpsSend -> GpsPacket; gps_driverM.GpsReceive -> GpsPacket; ! ! // FIXME: Remove the GpsCmd abstraction. In fact, ! // remove the I2CSwitchCmds interface completely. ! //gps_driverM.GpsCmd -> GpsPacket.GpsCmd; ! gps_driverM.I2CSwitchCmds -> GpsPacket.I2CSwitchCmds; } Index: gps_driverM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/fireboard/sensors/leadtek9546/gps_driverM.nc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gps_driverM.nc 28 Jan 2004 22:40:00 -0000 1.7 --- gps_driverM.nc 3 Feb 2004 20:06:44 -0000 1.8 *************** *** 56,60 **** interface StdControl as GpsControl; ! interface I2CSwitchCmds as GpsCmd; interface BareSendMsg as GpsSend; interface ReceiveMsg as GpsReceive; --- 56,60 ---- interface StdControl as GpsControl; ! interface I2CSwitchCmds; // as GpsCmd; interface BareSendMsg as GpsSend; interface ReceiveMsg as GpsReceive; *************** *** 125,129 **** /* Implementation is in GpsPacket.nc */ ! if (call GpsCmd.PowerSwitch(GPS_POWER_ON)) { SODbg(DBG_USR2, "gps_driverM.readGps(): GPS powered on\r\n"); gps_state = GPS_WORKING; --- 125,129 ---- /* Implementation is in GpsPacket.nc */ ! if (call I2CSwitchCmds.PowerSwitch(GPS_POWER_ON)) { SODbg(DBG_USR2, "gps_driverM.readGps(): GPS powered on\r\n"); gps_state = GPS_WORKING; *************** *** 246,261 **** GPS_MsgPtr gps_data = (GPS_MsgPtr)data; ! //signal Sensor.dataReady(gps_data); if ((call isGGA(gps_data->data))) { call parse_gga(gps_data); ! if (have_gps_fix) { //signal Sensor.dataReady(gps_data); call spew_to_uart(gps_data); signal Sensor.dataReady(&gga_msg); } ! } return data; --- 246,263 ---- GPS_MsgPtr gps_data = (GPS_MsgPtr)data; ! signal Sensor.dataReady(gps_data); + #if 0 if ((call isGGA(gps_data->data))) { call parse_gga(gps_data); ! //if (have_gps_fix) { //signal Sensor.dataReady(gps_data); call spew_to_uart(gps_data); signal Sensor.dataReady(&gga_msg); + //} } ! #endif return data; *************** *** 270,274 **** ! event result_t GpsCmd.SwitchesSet(uint8_t PowerState) { //SODbg(DBG_USR2, "gps_new.GpsCmd.SwitchesSet(): PowerState: %i \n\n", PowerState); --- 272,276 ---- ! event result_t I2CSwitchCmds.SwitchesSet(uint8_t PowerState) { //SODbg(DBG_USR2, "gps_new.GpsCmd.SwitchesSet(): PowerState: %i \n\n", PowerState); *************** *** 455,459 **** //call stopGps(); ! if (call GpsCmd.PowerSwitch(GPS_POWER_OFF)) { //SODbg(DBG_USR2,"gps_driverM.StdControl.stop(): GPS sensor powered off.\n"); --- 457,461 ---- //call stopGps(); ! if (call I2CSwitchCmds.PowerSwitch(GPS_POWER_OFF)) { //SODbg(DBG_USR2,"gps_driverM.StdControl.stop(): GPS sensor powered off.\n"); *************** *** 508,524 **** command result_t Sensor.loadProgram(uint8_t * program) { ! //TOS_MsgPtr msg = {0}; //strcpy(msg->data,program); ! GPS_Msg * msg; //msg->data = program; ! msg->length = strlen(program); ! program[0] = msg->length; ! strcpy(msg->data,program); signal Sensor.dataReady((void*)program); ! return call GpsSend.send(msg); } --- 510,526 ---- command result_t Sensor.loadProgram(uint8_t * program) { ! TOS_Msg msg = {0}; //strcpy(msg->data,program); ! //GPS_Msg msg; //msg->data = program; ! msg.length = strlen(program); ! //program[0] = msg.length; ! strcpy(msg.data,program); signal Sensor.dataReady((void*)program); ! return call GpsSend.send(&msg); } Index: leadtek_9546.h =================================================================== RCS file: /cvsroot/firebug/fireboard/fireboard/sensors/leadtek9546/leadtek_9546.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** leadtek_9546.h 28 Jan 2004 22:40:00 -0000 1.4 --- leadtek_9546.h 3 Feb 2004 20:06:44 -0000 1.5 *************** *** 102,105 **** --- 102,106 ---- #define NMEA_END2 "\n" //0x0A //ultimate byte of NMEA string + #define NMEA_GSV_MASK "0x0001" #define NMEA_GSA_MASK "0x0002" |