Thread: [Firebug-cvs] firebug/project/src/gps TestMTS350.nc,NONE,1.1 TestMTS350M.nc,NONE,1.1 gpsBcast.class,
Brought to you by:
doolin
From: <cs...@us...> - 2003-07-08 21:51:39
|
Update of /cvsroot/firebug/firebug/project/src/gps In directory sc8-pr-cvs1:/tmp/cvs-serv27755 Modified Files: gps.nc gpsCmd.nc gpsCmdM.nc gpsM.nc Added Files: TestMTS350.nc TestMTS350M.nc gpsBcast.class gpsBcast.java Removed Files: LogMsg.class LogMsg.java gpsCmdMsg.class gpsCmdMsg.java Log Message: use TestMTS350 for Leadtek --- NEW FILE: TestMTS350.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ configuration TestMTS350 { } implementation { components Main, TestMTS350M, RadioCRCPacket as Comm, UARTNoCRCPacket,SensirionHumidity, MicaWbSwitch,UARTGpsPacket,TimerC, LedsC, Logger; Main.StdControl -> TestMTS350M; Main.StdControl -> TimerC; TestMTS350M.UARTControl -> UARTNoCRCPacket; TestMTS350M.UARTSend -> UARTNoCRCPacket; TestMTS350M.UARTReceive -> UARTNoCRCPacket; TestMTS350M.GpsControl -> UARTGpsPacket; TestMTS350M.GpsSend -> UARTGpsPacket; TestMTS350M.GpsReceive -> UARTGpsPacket; TestMTS350M.GpsCmd -> UARTGpsPacket.GpsCmd; // TestMTS350M.SwitchControl -> MicaWbSwitch.StdControl; // TestMTS350M.Switch1 -> MicaWbSwitch.Switch[0]; // TestMTS350M.SwitchI2W -> MicaWbSwitch.Switch[1]; TestMTS350M.ADCControl -> SensirionHumidity; TestMTS350M.Humidity -> SensirionHumidity.Humidity; TestMTS350M.Temperature -> SensirionHumidity.Temperature; // Do we need these? // TestMTS350M.HumidityError -> SensirionHumidity.HumidityError; // TestMTS350M.TemperatureError -> SensirionHumidity.TemperatureError; TestMTS350M.RadioControl -> Comm; TestMTS350M.RadioSend -> Comm; TestMTS350M.RadioReceive -> Comm; TestMTS350M.Leds -> LedsC; TestMTS350M.Timer -> TimerC.Timer[unique("Timer")]; TestMTS350M.LoggerWrite -> Logger.LoggerWrite; TestMTS350M.LoggerRead -> Logger; } --- NEW FILE: TestMTS350M.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* History: created 1/25/2001 * * */ /* TestMTS350: - - */ includes gps; #define MSG_LENGTH 100 #define GGA_BYTES 12 #define NUM_FIELDS 6 #define NUM_BYTES_PER_FIELD 10 #define DELIMITER ',' #define START_STRING '$' #define END_STRING '*' module TestMTS350M { provides { interface StdControl; command result_t parseGPS(int8_t NMEAstr[MSG_LENGTH], uint8_t length); command result_t logGPS(char write[NUM_FIELDS][NUM_BYTES_PER_FIELD]); } uses { interface StdControl as UARTControl; interface BareSendMsg as UARTSend; interface ReceiveMsg as UARTReceive; interface StdControl as GpsControl; interface BareSendMsg as GpsSend; interface ReceiveMsg as GpsReceive; interface GpsCmd; interface StdControl as RadioControl; interface BareSendMsg as RadioSend; interface ReceiveMsg as RadioReceive; interface Timer; interface Leds; interface LoggerWrite; interface LoggerRead; // interface SplitControl as ADCControl; interface StdControl as ADCControl; interface ADC as Humidity; interface ADC as Temperature; interface ADCError as HumidityError; interface ADCError as TemperatureError; } } implementation { #include "SODebug.h" TOS_Msg buffer; TOS_MsgPtr ourBuffer; bool sendPending; uint8_t b_test; /* Generic.Base.Init: initialize lower components. initialize component state, including constant portion of msgs. */ command result_t StdControl.init() { result_t ok1, ok2, ok3 , ok4; b_test = 0; ourBuffer = &buffer; sendPending = TRUE; ok1 = call UARTControl.init(); ok2 = call RadioControl.init(); ok3 = call Leds.init(); ok4 = call GpsControl.init(); call ADCControl.init(); sendPending = FALSE; //***************************************************************************** // init debug uart init_debug(); //***************************************************************************** dbg(DBG_BOOT, "GenericBase initialized\n"); return rcombine4(ok1, ok2, ok3, ok4); } command result_t StdControl.start() { result_t ok1, ok2, ok3; //call Timer.start(TIMER_REPEAT, 5000); ok1 = call UARTControl.start(); ok2 = call RadioControl.start(); ok3 = call ADCControl.start(); call GpsCmd.GpsPower(1); //turn on GPS power return rcombine(ok1, ok2); } command result_t StdControl.stop() { result_t ok1, ok2; call ADCControl.stop(); ok1 = call UARTControl.stop(); ok2 = call RadioControl.stop(); return rcombine(ok1, ok2); } TOS_MsgPtr receive(TOS_MsgPtr received, bool fromUART) { TOS_MsgPtr nextReceiveBuffer = received; dbg(DBG_USR1, "GenericBase received %s packet\n", fromUART ? "UART" : "radio"); if ((!sendPending) && (received->group == (TOS_AM_GROUP & 0xff))) { result_t ok; nextReceiveBuffer = ourBuffer; ourBuffer = received; dbg(DBG_USR1, "GenericBase forwarding packet to %s\n", fromUART ? "radio" : "UART"); if (fromUART) { //call Leds.redOn(); ok = call RadioSend.send(received); } else { // call Leds.greenOn(); received->addr = TOS_UART_ADDR; ok = call UARTSend.send(received); } if (ok != FAIL) { dbg(DBG_USR1, "GenericBase send pending\n"); sendPending = TRUE; } else { //call Leds.yellowToggle(); } } return nextReceiveBuffer; } result_t sendDone(TOS_MsgPtr sent, result_t success) { if(ourBuffer == sent) { dbg(DBG_USR1, "GenericBase send buffer free\n"); if (success == FAIL) //call Leds.yellowToggle(); sendPending = FALSE; } return SUCCESS; } event TOS_MsgPtr RadioReceive.receive(TOS_MsgPtr data) { if (data->crc) { return receive(data, FALSE); } else { return data; } } /* ************************** *Packet received from GPS* ************************** * *The following should be executed in GpsPacket */ event TOS_MsgPtr GpsReceive.receive(TOS_MsgPtr data) { int8_t gga_string[MSG_LENGTH]; bool gga_read = FALSE; bool gga_read_done = FALSE; uint16_t i = 0; uint8_t j = 0; GPS_MsgPtr gps_data = (GPS_MsgPtr)data; while (!gga_read_done) { if(gps_data->data[i] == 'G') { if(gps_data->data[i+1] == 'G') { if(gps_data->data[i+2] == 'A') { gga_read = TRUE; } } } if(gps_data->data[i] == '*') { if(gga_read) { call parseGPS(gga_string, j); gga_read = FALSE; gga_read_done = TRUE; } } if(gga_read) { gga_string[j] = gps_data->data[i]; j++; } i++; } } /* **************** *Parse GPS Data* **************** * * Fields are comma delimited * NMEA string parsed by field and stored into * write array */ command result_t parseGPS(int8_t NMEAstr[MSG_LENGTH], uint8_t length) { char write[NUM_FIELDS][NUM_BYTES_PER_FIELD]; bool end_of_field = FALSE; uint8_t i=0; uint8_t j,m; uint16_t k=0; //***DEBUG: Output NMEA message*** //uint16_t q; //for(q=0; q<length; q++) UARTPutChar(NMEAstr[q]); //SODbg(DBG_USR2, "\n"); //******************************** // Parse and store comma delimited fields into EEPROM while (i < NUM_FIELDS) { // assemble write array end_of_field = FALSE; j = 0; while (!end_of_field & k < length) { if (NMEAstr[k] == DELIMITER) { end_of_field = TRUE; } else { write[i][j] = NMEAstr[k]; } j++; k++; } // if field is empty, set it equal to 0 if (j <= 1) { for (m=0; m<10; m++) write[i][m] = 0; } i++; } call logGPS(write); return SUCCESS; } /* ************** *Log GGA data* ************** * * Assemble GGA message structure from write * Store GGA data into line 25 of EEPROM */ command result_t logGPS(char write[NUM_FIELDS][NUM_BYTES_PER_FIELD]) { GGA_Msg *pGGA; //char log_array[GGA_BYTES]; char log_array[16]; char NS; char EW; uint8_t i,j; // Assemble GGA_Msg pGGA->hours = 10*(write[1][0]-'0') + (write[1][1]-'0'); pGGA->minutes = 10*(write[1][2]-'0') + (write[1][3]-'0'); pGGA->dec_sec = 10000*(write[1][4]-'0') + 1000*(write[1][5]-'0') + 100*(write[1][7]-'0') + 10*(write[1][8]-'0') + (write[1][9]-'0'); pGGA->Lat_deg = 10*(write[2][0]-'0') + (write[2][1]-'0'); pGGA->Lat_dec_min = 100000*(write[2][4]-'0') + 10000*(write[2][5]-'0') + 1000*(write[2][7]-'0') + 100*(write[2][8]-'0') + 10*(write[2][9]-'0') + (write[2][10]-'0'); pGGA->Long_deg = 10*(write[4][0]-'0') + (write[4][1]-'0'); pGGA->Long_dec_min = 100000*(write[4][4]-'0') + 10000*(write[4][5]-'0') + 1000*(write[4][7]-'0') + 100*(write[4][8]-'0') + 10*(write[4][9]-'0') + (write[4][10]-'0'); NS = (write[3][0] == 'N') ? 1 : 0; EW = (write[5][0] == 'W') ? 1 : 0; pGGA->NSEWind = EW | (NS<<4); // eg. Status = 000N000E = 00010000 // Log GGA_Msg j = 0; log_array[j++] = pGGA->hours; log_array[j++] = pGGA->minutes; log_array[j++] = (pGGA->dec_sec)>>8; // MSB log_array[j++] = pGGA->dec_sec; // LSB log_array[j++] = pGGA->Lat_deg; log_array[j++] = (pGGA->Lat_dec_min)>>8; log_array[j++] = pGGA->Lat_dec_min; log_array[j++] = pGGA->Long_deg; log_array[j++] = (pGGA->Long_dec_min)>>8; log_array[j++] = pGGA->Long_dec_min; log_array[j++] = pGGA->NSEWind; log_array[j++] = 0xFF; log_array[j++] = 0xFF; log_array[j++] = 0xFF; log_array[j++] = 0xFF; //if(call GpsCmd.GpsPower(0)) { // SODbg(DBG_USR2, "GPS Power Off\n"); //} if(call LoggerWrite.write(0x19,(char *)log_array)){ call Leds.redOn(); } return SUCCESS; } event result_t LoggerWrite.writeDone(result_t status){ //***DEBUG: Read and Output Stored GGA data*** //char line[32]; //uint8_t i; //if (call LoggerRead.read(0x19,line)) { // for(i=0; i<32; i++) UARTPutChar(line[i]); //} //SODbg(DBG_USR2, "\n"); //SODbg(DBG_USR2, "\n"); //********************************************* return SUCCESS; } event result_t LoggerRead.readDone(uint8_t * packet, result_t status){ return SUCCESS; } event result_t GpsSend.sendDone(TOS_MsgPtr msg, result_t success) { // call Leds.greenOff(); return sendDone(msg, success); } event TOS_MsgPtr UARTReceive.receive(TOS_MsgPtr data) { return receive(data, TRUE); } event result_t UARTSend.sendDone(TOS_MsgPtr msg, result_t success) { call Leds.greenOff(); return sendDone(msg, success); } event result_t RadioSend.sendDone(TOS_MsgPtr msg, result_t success) { call Leds.redOff(); return sendDone(msg, success); } /****************************************************************************** * Timer fired, test GPS *****************************************************************************/ event result_t Timer.fired() { // sample SODbg(DBG_USR2, "Timer fired\n"); if (!b_test){ //call Leds.redOn(); call GpsCmd.GpsPower(1); //turn on GPS power b_test = 1; } else{ //call Leds.redOff(); // call GpsCmd.GpsPower(0); //turn on GPS power b_test = 0; } // call ADCControl.start(); return SUCCESS; } /****************************************************************************** * Sensirion *****************************************************************************/ #ifdef ADC_CONTROL event result_t ADCControl.startDone() { call Humidity.getData(); return SUCCESS; } event result_t ADCControl.initDone() { return SUCCESS; } event result_t ADCControl.stopDone() { return SUCCESS; } #endif event result_t HumidityError.error(uint8_t token) { // short* sdata = (short*)(msg_buf.data); // sdata[1] = 0; call Leds.redOff(); call Temperature.getData(); return SUCCESS; } event result_t Humidity.dataReady(uint16_t data) { // short* sdata = (short*)(msg_buf.data); // sdata[1] = data; call Temperature.getData(); return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { // short* sdata = (short*)(msg_buf.data); // sdata[0] = TOS_LOCAL_ADDRESS; // sdata[2] = 0; // msg->data[6] = 0x99; call ADCControl.stop(); // call Send.send(TOS_BCAST_ADDR, 7, msg); return SUCCESS; } event result_t Temperature.dataReady(uint16_t data) { // short* sdata = (short*)(msg_buf.data); // sdata[0] = TOS_LOCAL_ADDRESS; // sdata[2] = data; // msg->data[6] = 0x99; call ADCControl.stop(); // call Send.send(TOS_BCAST_ADDR, 7, msg); return SUCCESS; } } Index: gps.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/gps/gps.nc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** gps.nc 22 May 2003 22:29:47 -0000 1.13 --- gps.nc 8 Jul 2003 21:51:35 -0000 1.14 *************** *** 65,69 **** components Main, LedsC, ! gpsM; components GenericComm as Comm, Logger; --- 65,70 ---- components Main, LedsC, ! gpsM, ! gpsCmd; components GenericComm as Comm, Logger; Index: gpsCmd.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/gps/gpsCmd.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gpsCmd.nc 22 May 2003 22:29:47 -0000 1.1 --- gpsCmd.nc 8 Jul 2003 21:51:35 -0000 1.2 *************** *** 52,58 **** Main.StdControl -> gpsCmdM; ! SimpleCmdM.Leds -> LedsC; ! gpsRetrive = gpsCmdM.gpsRetrieve; gpsCmdM.CommControl -> Comm; --- 52,58 ---- Main.StdControl -> gpsCmdM; ! gpsCmdM.Leds -> LedsC; ! gpsRetrieve = gpsCmdM.gpsRetrieve; gpsCmdM.CommControl -> Comm; Index: gpsCmdM.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/gps/gpsCmdM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gpsCmdM.nc 22 May 2003 22:29:47 -0000 1.1 --- gpsCmdM.nc 8 Jul 2003 21:51:35 -0000 1.2 *************** *** 87,91 **** } ! signal ProcessCmd.done(cur_msg, status); } --- 87,91 ---- } ! signal gpsRetrieve.done(cur_msg, status); } *************** *** 130,134 **** TOS_MsgPtr ret = cur_msg; - call Leds.greenToggle(); retval = call gpsRetrieve.execute(pmsg); if (retval==SUCCESS) { --- 130,133 ---- Index: gpsM.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/gps/gpsM.nc,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** gpsM.nc 22 May 2003 22:29:47 -0000 1.26 --- gpsM.nc 8 Jul 2003 21:51:36 -0000 1.27 *************** *** 121,124 **** --- 121,125 ---- command result_t StdControl.init() { + TOSH_MAKE_PW0_OUTPUT(); //make PW1 an output //TOSH_SET_PW0_PIN(); //turn on GPS power *************** *** 146,150 **** // Enable reciever and transmitter, disabletheir interrupts outp(((0 << RXCIE) | (0 << TXCIE) | (1 << RXEN) | (1 << TXEN)) ,UCSR0B); ! return rcombine(call SubControl.init(), call Leds.init()); } --- 147,151 ---- // Enable reciever and transmitter, disabletheir interrupts outp(((0 << RXCIE) | (0 << TXCIE) | (1 << RXEN) | (1 << TXEN)) ,UCSR0B); ! return rcombine(call SubControl.init(), call Leds.init()); } *************** *** 274,278 **** } - /* ************** --- 275,278 ---- *************** *** 321,330 **** // write to EEPROM ! call LoggerWrite.write(25 + field,(char *)write); } - - return SUCCESS; } /* --- 321,331 ---- // write to EEPROM ! if(call LoggerWrite.write(25+field,(char *)write)) { ! signal LoggerWrite.writeDone(SUCCESS); ! } } } + /* --- LogMsg.class DELETED --- --- LogMsg.java DELETED --- --- gpsCmdMsg.class DELETED --- --- gpsCmdMsg.java DELETED --- |