[Firebug-cvs] mts400/apps/TestGPS gps_new.nc,1.2,1.3 gps_newM.nc,1.4,1.5
Brought to you by:
doolin
From: <do...@us...> - 2003-11-13 00:17:21
|
Update of /cvsroot/firebug/mts400/apps/TestGPS In directory sc8-pr-cvs1:/tmp/cvs-serv12616/apps/TestGPS Modified Files: gps_new.nc gps_newM.nc Log Message: Clean up commit to make nothing was missed when the offline driver and test applications were added and commited. Index: gps_new.nc =================================================================== RCS file: /cvsroot/firebug/mts400/apps/TestGPS/gps_new.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gps_new.nc 12 Nov 2003 01:44:20 -0000 1.2 --- gps_new.nc 13 Nov 2003 00:17:18 -0000 1.3 *************** *** 22,28 **** gps_newM.Leds -> LedsC; ! gps_newM.Timer -> TimerC.Timer[unique("Timer")]; ! /** Use gps without sensirion. */ //gps_newM.SwitchControl -> MicaWbSwitch.StdControl; gps_newM.PowerSwitch -> MicaWbSwitch.Switch[0]; --- 22,29 ---- gps_newM.Leds -> LedsC; ! gps_newM.GPSTimer -> TimerC.Timer[unique("Timer")]; ! gps_newM.REDTimer -> TimerC.Timer[unique("Timer")]; ! /** Use gps without sensirion or adxl. */ //gps_newM.SwitchControl -> MicaWbSwitch.StdControl; gps_newM.PowerSwitch -> MicaWbSwitch.Switch[0]; Index: gps_newM.nc =================================================================== RCS file: /cvsroot/firebug/mts400/apps/TestGPS/gps_newM.nc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gps_newM.nc 12 Nov 2003 02:49:10 -0000 1.4 --- gps_newM.nc 13 Nov 2003 00:17:18 -0000 1.5 *************** *** 7,17 **** interface StdControl; } uses { ! interface Timer; interface Leds; interface StdControl as SwitchControl; interface Switch as PowerSwitch; --- 7,23 ---- interface StdControl; + + command void readGps(); + command void stopGps(); } uses { ! interface Leds; + interface Timer as GPSTimer; + interface Timer as REDTimer; + interface StdControl as SwitchControl; interface Switch as PowerSwitch; *************** *** 40,48 **** char state; enum {IDLE, BUSY, BUSY_0, BUSY_1, GET_SAMPLE_0, GET_SAMPLE_1, OPENSCK, OPENDATA, CLOSESCK, CLOSEDATA, POWEROFF, MAIN_SWITCH_ON, MAIN_SWITCH_OFF, WAIT_SWITCH_ON, ! WAIT_SWITCH_OFF, TIMER}; --- 46,55 ---- char state; + char gps_state; enum {IDLE, BUSY, BUSY_0, BUSY_1, GET_SAMPLE_0, GET_SAMPLE_1, OPENSCK, OPENDATA, CLOSESCK, CLOSEDATA, POWEROFF, MAIN_SWITCH_ON, MAIN_SWITCH_OFF, WAIT_SWITCH_ON, ! WAIT_SWITCH_OFF, TIMER, GPS_WORKING, GPS_FINISHED}; *************** *** 61,105 **** call Leds.redOn(); ! /* Control.start in GpsPacket.nc */ call GpsControl.start(); ! /* Implementation is in GpsPacket.nc */ ! if (!call GpsCmd.PowerSwitch(GPS_POWER_ON)) { ! SODbg(DBG_USR2, "Failed to power on gps \n"); ! } ! ! /** Do we need this? */ ! call Timer.start(TIMER_REPEAT, 1000) ; return SUCCESS; } - command result_t StdControl.stop() { ! SODbg(DBG_USR2, "StdControl.stop() \n"); if (call GpsCmd.PowerSwitch(GPS_POWER_OFF)) { ! SODbg(DBG_USR2, "GPS sensor powered off. \n"); } - /** Timer.stop always returns success. */ - call Timer.stop(); - return SUCCESS; } ! /****************************************************/ ! /** Timer */ ! event result_t Timer.fired() { ! //call Leds.greenToggle(); return SUCCESS; } - /****************************************************/ - /** PowerSwitch */ event result_t PowerSwitch.getDone(char value) { --- 68,133 ---- call Leds.redOn(); ! /** Control.start in GpsPacket.nc, calls ! * SwitchControl.start and ByteControl.start() ! */ call GpsControl.start(); + call GPSTimer.start(TIMER_REPEAT, 10000) ; + call REDTimer.start(TIMER_REPEAT, 500) ; + return SUCCESS; + } ! command result_t StdControl.stop() { + /** Turn the timer off so that it doesn't fire any + * sensor readings. Timer.stop always returns success. + */ + call GPSTimer.stop(); + call REDTimer.stop(); return SUCCESS; } ! command void stopGps() { if (call GpsCmd.PowerSwitch(GPS_POWER_OFF)) { ! SODbg(DBG_USR2, "gps_newM.StdControl.stop(): GPS sensor powered off. \n"); } } + /** Ok, this function turns on the gps unit for reading, + * which is turned of elsewhere when the read is finished. + * If the read isn't finished, the function exits. + */ + command void readGps() { ! if (gps_state == GPS_WORKING) { ! SODbg(DBG_USR2, "gps_newM.readGps(): GPS_WORKING\n"); ! return; ! } ! call Leds.greenToggle(); ! /* Implementation is in GpsPacket.nc */ ! if (call GpsCmd.PowerSwitch(GPS_POWER_ON)) { ! SODbg(DBG_USR2, "gps_newM.readGps(): GPS powered on\n"); ! gps_state = GPS_WORKING; ! } ! } ! ! ! event result_t GPSTimer.fired() { ! ! call readGps(); return SUCCESS; } + event result_t REDTimer.fired() { + + call Leds.redToggle(); + return SUCCESS; + } event result_t PowerSwitch.getDone(char value) { *************** *** 107,111 **** } - /** FIXME: Make sure we don't need the startDone, stopDone * calls. --- 135,138 ---- *************** *** 116,119 **** --- 143,147 ---- case MAIN_SWITCH_ON: + SODbg(DBG_USR2, "PowerSwitch.setDone() MAIN_SWITCH_ON\n"); state = IDLE; /** GpsControl is wired to GpsPacket.nc */ *************** *** 122,125 **** --- 150,154 ---- case MAIN_SWITCH_OFF: + SODbg(DBG_USR2, "PowerSwitch.setDone() MAIN_SWITCH_OFF\n"); state = POWEROFF; /** GpsControl is wired to GpsPacket.nc */ *************** *** 128,131 **** --- 157,161 ---- case WAIT_SWITCH_ON: + SODbg(DBG_USR2, "PowerSwitch.setDone() WAIT_SWITCH_ON\n"); if (call PowerSwitch.set(MICAWB_GPS_POWER,1) == SUCCESS) { state = MAIN_SWITCH_ON; *************** *** 134,137 **** --- 164,168 ---- case WAIT_SWITCH_OFF: + SODbg(DBG_USR2, "PowerSwitch.setDone() WAIT_SWITCH_OFF\n"); if (call PowerSwitch.set(MICAWB_GPS_POWER,0) == SUCCESS) { state = MAIN_SWITCH_OFF; *************** *** 144,148 **** } - event result_t PowerSwitch.setAllDone(bool local_result) { return SUCCESS; --- 175,178 ---- *************** *** 150,153 **** --- 180,184 ---- + event result_t IOSwitch.getDone(char value) { return SUCCESS; *************** *** 159,183 **** /** FIXME: Rewrite this with a switch/case. */ event result_t IOSwitch.setDone(bool local_result) { ! SODbg(DBG_USR2, "IOSwitch.setDone(): state: %i \n", state); if (state == OPENSCK) { //SCK line enabled state = OPENDATA; return call IOSwitch.set(MICAWB_HUMIDITY_DATA,1); } else if (state == OPENDATA) { //Data line enabled state = TIMER; ! SODbg(DBG_USR2, "IOSwitch.setDone(): Timer Started, state: %i \n", state); ! return call Timer.start(TIMER_ONE_SHOT, 100); } else if (state == CLOSESCK) { state = CLOSEDATA; return call IOSwitch.set(MICAWB_HUMIDITY_DATA,0); } else if (state == CLOSEDATA) { ! } return SUCCESS; } /** * Packet received from GPS - ASCII msg --- 190,223 ---- /** FIXME: Rewrite this with a switch/case. */ + /** FIXME: I see no reason why we need I2C information this + * high in the application. All this I2C bus info needs + * to be shoved down a level, and wired from here to something + * like turnSensorOn(), turnSensorOff(), etc. + */ event result_t IOSwitch.setDone(bool local_result) { ! //SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): state: %i \n", state); if (state == OPENSCK) { //SCK line enabled + SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SCK enabled \n"); state = OPENDATA; return call IOSwitch.set(MICAWB_HUMIDITY_DATA,1); } else if (state == OPENDATA) { //Data line enabled + SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SDA enabled \n"); state = TIMER; ! SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): Timer Started, state: %i \n", state); ! return call GPSTimer.start(TIMER_ONE_SHOT, 100); } else if (state == CLOSESCK) { state = CLOSEDATA; + SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SCK disabled \n"); return call IOSwitch.set(MICAWB_HUMIDITY_DATA,0); } else if (state == CLOSEDATA) { ! SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SDA disabled \n"); } return SUCCESS; } + /** * Packet received from GPS - ASCII msg *************** *** 185,190 **** * async used only for testing. * ! * FIXME: Why is the data return? It should be ! * declared const. * * This function is called from GpsPacket.receiveTask(). --- 225,230 ---- * async used only for testing. * ! * FIXME: Why is the data returned? It's passed in. ! * It should be declared const. * * This function is called from GpsPacket.receiveTask(). *************** *** 197,209 **** for (i=0; i<=gps_data->data[0]; i++) { UARTPutChar(gps_data->data[i]); } SODbg(DBG_USR2, "\n"); #if GPS_ONE_SHOT { ! static uint16_t msg_count = 0; ! if (msg_count == 4) { ! call StdControl.stop(); } msg_count++; --- 237,262 ---- for (i=0; i<=gps_data->data[0]; i++) { + /** UARTPutChar is an SODebug function. + * FIXME: Change this to use a char[]. + */ UARTPutChar(gps_data->data[i]); } SODbg(DBG_USR2, "\n"); + + /** FIXME: Pulled the preprocessor define out, + * code this up as a user defined variable that + * is set when the gps unit is initialized. + */ #if GPS_ONE_SHOT { ! /** Already written out one message. */ ! static uint16_t msg_count = 1; ! if (msg_count == 2) { ! atomic { ! gps_state = GPS_FINISHED; ! } ! call stopGps(); ! msg_count = 0; } msg_count++; *************** *** 216,220 **** event result_t GpsSend.sendDone(TOS_MsgPtr msg, result_t success) { ! SODbg(DBG_USR2, "GpsSend.sendDone()\n", state); return SUCCESS; --- 269,273 ---- event result_t GpsSend.sendDone(TOS_MsgPtr msg, result_t success) { ! SODbg(DBG_USR2, "GpsSend.sendDone(): state: %i \n", state); return SUCCESS; *************** *** 223,227 **** event result_t GpsCmd.SwitchesSet(uint8_t PowerState) { ! SODbg(DBG_USR2, "Gps power on \n"); call Leds.yellowOn(); call Leds.redOff(); --- 276,283 ---- event result_t GpsCmd.SwitchesSet(uint8_t PowerState) { ! char tmp[] = {"Foo"}; ! ! //SODbg(DBG_USR2, "gps_new.GpsCmd.SwitchesSet(): PowerState: %i \n\n", PowerState); ! SODbg(DBG_USR2, "gps_new.GpsCmd.SwitchesSet(): dummy string: %s \n", tmp); call Leds.yellowOn(); call Leds.redOff(); |