[Firebug-cvs] firebug/project/src/multihop CollectDataFB.nc,1.7,1.8 CollectDataMFB.nc,1.11,1.12
Brought to you by:
doolin
From: <che...@us...> - 2003-11-19 00:52:34
|
Update of /cvsroot/firebug/firebug/project/src/multihop In directory sc8-pr-cvs1:/tmp/cvs-serv18242 Modified Files: CollectDataFB.nc CollectDataMFB.nc Log Message: gps on radio Index: CollectDataFB.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/multihop/CollectDataFB.nc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CollectDataFB.nc 22 Aug 2003 06:47:44 -0000 1.7 --- CollectDataFB.nc 19 Nov 2003 00:52:30 -0000 1.8 *************** *** 1,45 **** ! /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ ! ! ! /** ! * Author: Terence Tong, Alec Woo, Max Min Chen, David M. Doolin ! */ ! ! includes RoutingStack; ! configuration CollectDataFB { ! ! } ! ! ! implementation { ! components Main, CollectDataMFB, MHSender, TimerWrapper, LedsC, ! VirtualComm, ParentSelection, CC1000ControlM, SensirionHumidity, ! IntersemaPressure,MicaWbSwitch; ! ! Main.StdControl -> CollectDataMFB.StdControl; ! //CollectDataMFB.MultiHopSend -> MHSender.MultiHopSend[MH_STATISTIC_TYPE]; ! //ParentSelection.InForwardReceive -> VirtualComm.ReceiveMsg[MH_STATISTIC_TYPE]; ! CollectDataMFB.MultiHopSend -> MHSender.MultiHopSend[RS_DATA_TYPE]; ! ParentSelection.InForwardReceive -> VirtualComm.ReceiveMsg[RS_DATA_TYPE]; ! CollectDataMFB.Timer -> TimerWrapper.Timer[unique("Timer")]; ! CollectDataMFB.Leds -> LedsC; ! Main.StdControl -> MHSender.StdControl; ! CollectDataMFB.CC1000Control -> CC1000ControlM; ! ! // Wiring for Sensirion humidity/temperature sensor ! CollectDataMFB.TempHumControl -> SensirionHumidity; ! CollectDataMFB.Humidity -> SensirionHumidity.Humidity; ! CollectDataMFB.Temperature -> SensirionHumidity.Temperature; ! CollectDataMFB.HumidityError -> SensirionHumidity.HumidityError; ! CollectDataMFB.TemperatureError -> SensirionHumidity.TemperatureError; ! ! // Wiring for Intersema barometric pressure/temperature sensor ! CollectDataMFB.IntersemaCal -> IntersemaPressure; ! CollectDataMFB.PressureControl -> IntersemaPressure; ! CollectDataMFB.IntersemaPressure -> IntersemaPressure.Pressure; ! CollectDataMFB.IntersemaTemp -> IntersemaPressure.Temperature; ! ! ! ! } ! --- 1,40 ---- ! /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ ! ! ! /** ! * Author: Terence Tong, Alec Woo, Max Min Chen, David M. Doolin ! */ ! ! includes RoutingStack; ! configuration CollectDataFB { ! ! } ! ! ! implementation { ! components Main, CollectDataMFB, MHSender, LedsC,MicaWbSwitch, ! VirtualComm, ParentSelection,UARTGpsPacket, TimerWrapper,//Logger, ! Accel;//CC1000ControlM ! ! ! Main.StdControl -> CollectDataMFB.StdControl; ! CollectDataMFB.MultiHopSend -> MHSender.MultiHopSend[RS_DATA_TYPE]; ! ParentSelection.InForwardReceive -> VirtualComm.ReceiveMsg[RS_DATA_TYPE]; ! CollectDataMFB.Timer1 -> TimerWrapper.Timer[unique("Timer")]; ! CollectDataMFB.Timer2 -> TimerWrapper.Timer[unique("Timer")]; ! CollectDataMFB.Leds -> LedsC; ! Main.StdControl -> MHSender.StdControl; ! ! ! // Wiring for gps ! CollectDataMFB.GpsControl -> UARTGpsPacket; ! CollectDataMFB.GpsSend -> UARTGpsPacket; ! CollectDataMFB.GpsReceive -> UARTGpsPacket; ! CollectDataMFB.GpsCmd -> UARTGpsPacket.GpsCmd; ! ! // Wiring for Accelerometer ! CollectDataMFB.AccelControl->Accel.StdControl; ! CollectDataMFB.AccelCmd -> Accel.AccelCmd; ! ! } ! Index: CollectDataMFB.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/multihop/CollectDataMFB.nc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CollectDataMFB.nc 22 Aug 2003 06:47:44 -0000 1.11 --- CollectDataMFB.nc 19 Nov 2003 00:52:30 -0000 1.12 *************** *** 1,296 **** ! /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil; font-lock-mode: t -*- */ ! ! /** ! * This is an example of a general application using the ! * Routing Stack to send message to ! * basestation. It store a message in its frame, ! * call getUsablePortion to get the right location ! * to add in its own data. passed the data down ! * the stack with the send command. A Send done ! * command will come back. A recomment way to send ! * another message is to have a one shot ! * Time. When the clock fired, we make another ! * attempt to send again. ! * ! * @author: Terence Tong, Alec Woo, Max Min Chen ! */ ! ! includes RoutingStack; ! ! module CollectDataMFB { ! ! provides { ! interface StdControl; ! } ! ! uses { ! ! interface Send as MultiHopSend; ! interface Timer as Timer; ! interface Leds; ! interface CC1000Control; ! ! //Intersema ! interface SplitControl as PressureControl; ! interface ADC as IntersemaTemp; ! interface ADC as IntersemaPressure; ! interface Calibration as IntersemaCal; ! ! //Sensirion ! interface SplitControl as TempHumControl; ! interface ADC as Humidity; ! interface ADC as Temperature; ! interface ADCError as HumidityError; ! interface ADCError as TemperatureError; ! ! } ! } ! ! #define DATA_FREQ 1000 ! implementation { ! #include "gps.h" ! ! enum {START, BUSY, HUMIDITY_DONE, PRESSURE_DONE}; ! ! TOS_Msg msgToSend; ! ! struct DataFormat_t { ! uint16_t addr; ! uint16_t cnt; ! float temp; ! float rel_hum; ! float baro_pres; ! ! }; ! ! uint16_t counter; ! uint8_t sending; ! uint8_t state; ! float TempData; ! float HumData; ! float PressureData; ! char count; ! uint16_t calibration[6]; ! uint16_t C1,C2,C3,C4,C5,C6; //intersema calibration coefficients ! ! task void SendToRadio(){ ! ! uint8_t *dataPortion; ! uint16_t availableLength = 0; ! ! struct DataFormat_t *df; ! ! if (sending != 1) { ! dataPortion = call MultiHopSend.getBuffer(&msgToSend, &availableLength); ! df = (struct DataFormat_t *) dataPortion; ! df->addr = TOS_LOCAL_ADDRESS; ! df->cnt = counter++; ! df->temp = TempData; ! df->rel_hum = HumData; ! df->baro_pres = PressureData; ! ! sending = call MultiHopSend.send(&msgToSend, sizeof(struct DataFormat_t)); ! call Leds.greenToggle(); ! } ! } ! ! ! command result_t StdControl.init() { ! call TempHumControl.init(); //init Sensirion ! call PressureControl.init(); // init Intersema ! return SUCCESS; ! } ! ! command result_t StdControl.start() { ! int i; ! counter = 0; ! for (i = 0; i < 29; i++) { ! msgToSend.data[i] = 0; ! } ! call Timer.start(TIMER_REPEAT, DATA_FREQ); ! call CC1000Control.SetRFPower(255); ! ! call HumidityError.enable(); //in case Sensirion doesn't respond ! call TemperatureError.enable(); // " ! ! return SUCCESS; ! } ! ! command result_t StdControl.stop() { ! return SUCCESS; ! } ! ! /** ! * When the clock fired we are ready to send, CollectData ask the stack ! * where in the data payload we can safely put our data. We then call ! * Multihop passed the pointer down the stack ! * ! * @author: terence ! * @param: void ! * @return: always return success ! */ ! event result_t Timer.fired() { ! if ( state == PRESSURE_DONE) state = START; ! ! if (state == START){ ! state = BUSY; ! call TempHumControl.start(); ! } ! ! if (state == HUMIDITY_DONE){ ! state = BUSY; ! call PressureControl.start(); ! } ! ! return SUCCESS; ! } ! ! ! /****************************************************************************** ! * Intersema MS5534A barometric pressure/temperature sensor ! * - 6 cal coefficients (C1..C6) are extracted from 4, 16 bit,words from sensor ! * - Temperature measurement: ! * UT1=8*C5+20224 ! * dT=data-UT1 ! * Temp=(degC x10)=200+dT(C6+50)/1024 ! * - Pressure measurement: ! * OFF=C2*4 + ((C4-512)*dT)/1024 ! * SENS=C1+(C3*dT)/1024 + 24576 ! * X=(SENS*(PressureData-7168))/16384 - OFF ! * Press(mbar)= X/32+250 ! *****************************************************************************/ ! event result_t IntersemaTemp.dataReady(uint16_t data) { ! float UT1,dT,Temp; ! float OFF,SENS,X,Press; ! //temperature ! UT1=8*(float)C5+20224; ! dT = (float)data-UT1; ! Temp = 200.0 + dT*((float)C6+50.0)/1024.0; ! //pressure ! OFF = (float)C2*4 + (((float)C4-512.0)*dT)/1024; ! SENS = (float)C1 + ((float)C3*dT)/1024 + 24576; ! X = (SENS*((float)PressureData-7168.0))/16384 - OFF; ! Press = X/32.0 + 250.0; ! ! call PressureControl.stop(); ! return SUCCESS; ! } ! ! event result_t IntersemaPressure.dataReady(uint16_t data) { ! PressureData = data; ! call Leds.yellowToggle(); ! return call IntersemaTemp.getData(); ! } ! ! event result_t IntersemaCal.dataReady(char word, uint16_t value) { ! // make sure we get all the calibration bytes ! count++; ! calibration[word-1] = value; ! ! if (count == 4) { ! C1 = calibration[0] >> 1; ! C2 = ((calibration[2] & 0x3f) << 6) | (calibration[3] & 0x3f); ! C3 = calibration[3] >> 6; ! C4 = calibration[2] >> 6; ! C5 = ((calibration[0] & 1) << 10) | (calibration[1] >> 6); ! C6 = calibration[1] & 0x3f; ! ! call IntersemaPressure.getData(); ! } ! return SUCCESS; ! } ! ! event result_t PressureControl.initDone() { ! return SUCCESS; ! } ! ! event result_t PressureControl.stopDone() { ! post SendToRadio(); ! return SUCCESS; ! ! ! } ! ! event result_t PressureControl.startDone() { ! count = 0; ! call IntersemaCal.getData(); ! return SUCCESS; ! } ! ! ! ! /****************************************************************************** ! * Sensirion SHT11 humidity/temperature sensor ! * - Humidity data is 12 bit: ! * Linear calc (no temp correction) ! * fRH = -4.0 + 0.0405 * data -0.0000028 * data^2 'RH linear ! * With temperature correction: ! * fRH = (fTemp - 25) * (0.01 + 0.00008 * data) + fRH 'RH true ! * - Temperature data is 14 bit ! * Temp(degC) = -38.4 + 0.0098 * data ! *****************************************************************************/ ! event result_t Temperature.dataReady(uint16_t data) { ! float fTemp, fHumidity; ! ! fTemp = -38.4 + 0.0098*(float)data; ! fHumidity = -4.0 + 0.0405 * HumData -0.0000028 * HumData * HumData; ! fHumidity= (fTemp-25.0)* (0.01 + 0.00008 * HumData) + fHumidity; ! fTemp = 10*fTemp; ! ! call TempHumControl.stop(); ! return SUCCESS; ! } ! ! event result_t Humidity.dataReady(uint16_t data) { ! HumData = data; //pressure data ! call Leds.redToggle(); ! return call Temperature.getData(); ! } ! ! event result_t TempHumControl.startDone() { ! call Humidity.getData(); ! return SUCCESS; ! } ! ! event result_t TempHumControl.initDone() { ! return SUCCESS; ! } ! ! event result_t TempHumControl.stopDone() { ! state = HUMIDITY_DONE; ! return SUCCESS; ! } ! ! event result_t HumidityError.error(uint8_t token) ! { ! //call Leds.redOff(); ! //call Leds.yellowOff(); ! call Temperature.getData(); ! return SUCCESS; ! } ! ! ! event result_t TemperatureError.error(uint8_t token) ! { ! call TempHumControl.stop(); ! //call Leds.yellowOff(); ! return SUCCESS; ! } ! ! ! /** ! * When a message is sent, send done event is trigger. We then schedule the ! * time to generate another message to send ! * ! * @author: terence ! * @param: void ! * @return: void ! */ ! ! event result_t MultiHopSend.sendDone(TOS_MsgPtr msg, uint8_t success) { ! sending = 0; ! state= PRESSURE_DONE; ! return SUCCESS; ! } ! ! } --- 1,476 ---- ! /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil; font-lock-mode: t -*- */ ! ! /** ! * This is an example of a general application using the ! * Routing Stack to send message to ! * basestation. It store a message in its frame, ! * call getUsablePortion to get the right location ! * to add in its own data. passed the data down ! * the stack with the send command. A Send done ! * command will come back. A recomment way to send ! * another message is to have a one shot ! * Time. When the clock fired, we make another ! * attempt to send again. ! * ! * @author: Terence Tong, Alec Woo, Max Min Chen ! */ ! ! includes RoutingStack; ! includes gps; ! ! #define GPS_MSG_LENGTH 100 ! #define GPS_CHAR 11 ! #define GPS_FIELDS 8 ! #define GPS_CHAR_PER_FIELD 10 ! #define GPS_DELIMITER ',' ! #define GPS_END_MSG '*' ! ! ! ! ! ! module CollectDataMFB { ! ! provides { ! ! interface StdControl; ! command result_t parseGPS(int8_t gga_string[GPS_MSG_LENGTH], uint8_t length); ! command result_t logGPS(char gga_fields[GPS_FIELDS][GPS_CHAR_PER_FIELD]); ! } ! ! uses { ! ! interface Send as MultiHopSend; ! interface Timer as Timer1; ! interface Timer as Timer2; ! interface Leds; ! ! interface I2CSwitchCmds as GpsCmd; ! interface StdControl as GpsControl; ! interface BareSendMsg as GpsSend; ! interface ReceiveMsg as GpsReceive; ! ! ! //Accels ! interface StdControl as AccelControl; ! interface I2CSwitchCmds as AccelCmd; ! ! } ! } ! ! implementation { ! #include "SODebug.h" ! //#include "gps.h" ! ! TOS_Msg msgToSend; ! //GGA_Msg *pGGA; ! uint8_t pHours; ! uint8_t pMinutes; ! uint16_t pDec_sec; ! uint8_t pLat_deg; ! uint16_t pLat_dec_min; ! uint8_t pLong_deg; ! uint16_t pLong_dec_min; ! uint8_t pNSEWind; ! ! struct DataFormat_t { ! uint16_t addr; ! uint16_t cnt; ! uint8_t hours; ! uint8_t minutes; ! uint16_t dec_sec; ! uint8_t Lat_deg; ! uint16_t Lat_dec_min; ! uint8_t Long_deg; ! uint16_t Long_dec_min; ! uint8_t NSEWind; ! float temp; ! //float rel_hum; ! //float baro_pres; ! }; ! ! uint16_t counter; ! uint8_t sending; ! ! char count; ! ! bool gps_active; //true if gps is active ! bool gps_done; ! ! command result_t StdControl.init() { ! ! gps_active = FALSE; ! gps_done = TRUE; ! init_debug(); ! call Leds.init(); ! call GpsControl.init(); ! ! call AccelControl.init(); //initialize accelerometer ! return SUCCESS; ! } ! ! command result_t StdControl.start() { ! int i; ! counter = 0; ! ! call GpsControl.start(); ! SODbg(DBG_USR2, "Power GPS... \n"); ! ! //call Timer1.start(TIMER_REPEAT, 5000); ! ! if (! call GpsCmd.PowerSwitch(1)) { //turn on GPS power ! call Leds.yellowToggle(); ! SODbg(DBG_USR2, "Failed to power on gps \n"); ! } ! ! //call Leds.redToggle(); ! for (i = 0; i < 29; i++) { ! msgToSend.data[i] = 0; ! } ! ! return SUCCESS; ! } ! ! command result_t StdControl.stop() { ! return SUCCESS; ! } ! ! event result_t Timer1.fired() { ! ! if (!gps_active){ ! call Leds.yellowToggle(); ! //if (! call GpsCmd.PowerSwitch(1)) { //turn on GPS power ! call GpsCmd.PowerSwitch(1); ! gps_active = TRUE; ! } ! else{ ! gps_active = FALSE; ! } ! ! return SUCCESS; ! } ! ! ! ! /** ! * When the clock fired we are ready to send, CollectData ask the stack ! * where in the data payload we can safely put our data. We then call ! * Multihop passed the pointer down the stack ! * ! * @author: terence ! * @param: void ! * @return: always return success ! */ ! ! event result_t Timer2.fired() { ! ! uint8_t *dataPortion; ! uint16_t availableLength = 0; ! ! struct DataFormat_t *df; ! ! if (sending == 1) { ! return SUCCESS; ! } ! ! dataPortion = call MultiHopSend.getBuffer(&msgToSend, &availableLength); ! df = (struct DataFormat_t *) dataPortion; ! df->addr = TOS_LOCAL_ADDRESS; ! df->cnt = counter++; ! df->hours = pHours; ! df->minutes = pMinutes; ! df->dec_sec = pDec_sec; ! df->Lat_deg = pLat_deg; ! df->Lat_dec_min = pLat_dec_min; ! df->Long_deg = pLong_deg; ! df->Long_dec_min = pLong_dec_min; ! df->NSEWind = pNSEWind; ! df->temp = 100.1; ! //df->rel_hum = 36.2; ! //df->baro_pres = 28.3; ! ! SODbg(DBG_USR2, "hours:%i\n", df->hours); ! SODbg(DBG_USR2, "hours:%i\n", pHours); ! //SODbg(DBG_USR2, "minutes:%i\n", df->minutes); ! //SODbg(DBG_USR2, "dec_sec:%i\n", df->dec_sec); ! //SODbg(DBG_USR2, "Lat_deg:%i\n", df->Lat_deg); ! //SODbg(DBG_USR2, "Lat_dec_min:%i\n", df->Lat_dec_min); ! //SODbg(DBG_USR2, "Long_deg:%i\n", df->Long_deg); ! //SODbg(DBG_USR2, "Long_dec_min:%i\n", df->Long_dec_min); ! //SODbg(DBG_USR2, "NSEWind:%i\n", df->NSEWind); ! //SODbg(DBG_USR2, "hours:%h\n", df->temp); ! ! sending = call MultiHopSend.send(&msgToSend, sizeof(struct DataFormat_t)); ! return SUCCESS; ! } ! ! ! /** ! * When a message is sent, send done event is trigger. We then schedule the ! * time to generate another message to send ! * ! * @author: terence ! * @param: void ! * @return: void ! */ ! ! event result_t MultiHopSend.sendDone(TOS_MsgPtr msg, uint8_t success) { ! sending = 0; ! gps_done=TRUE; ! call Timer2.stop(); ! call GpsCmd.PowerSwitch(1); ! SODbg(DBG_USR2, "radio_senddone, power gps again\n"); ! ! return SUCCESS; ! } ! ! ! // ************************** ! //*Packet received from GPS* ! //************************** ! // ! //*The following should be executed in GpsPacket ! ! ! event TOS_MsgPtr GpsReceive.receive(TOS_MsgPtr data) { ! ! int8_t gga_string[GPS_MSG_LENGTH]; ! bool gga_read = FALSE; ! bool gga_read_done = FALSE; ! uint16_t i = 0; ! uint8_t j = 0; ! uint8_t k = 0; ! ! GPS_MsgPtr gps_data = (GPS_MsgPtr)data; ! call Leds.greenToggle(); ! ! ! if(gps_data->data[i+3] == 'G' && gps_data->data[i+4] == 'G' && gps_data->data[i+5] == 'A' && gps_done == TRUE) { ! ! while (!gga_read_done) { ! if(gps_data->data[i+3] == 'G') { ! if(gps_data->data[i+4] == 'G') { ! if(gps_data->data[i+5] == 'A') { ! gga_read = TRUE; ! SODbg(DBG_USR2, "gps_data:%i,\n", gps_data->length); ! for (k = 0; k <= gps_data->length ; k++) UARTPutChar(gps_data->data[k]); ! gps_done = FALSE; ! } ! } ! } ! ! call Leds.redToggle(); ! if(gps_data->data[i] == GPS_END_MSG) { ! if(gga_read) { ! //if(call GpsCmd.PowerSwitch(0)) { ! // SODbg(DBG_USR2, "GPS Power Off\n"); ! //} ! ! call parseGPS(gga_string, j); ! gga_read = FALSE; ! gga_read_done = TRUE; ! } ! } ! ! if(gga_read) { ! gga_string[j] = gps_data->data[i]; ! j++; ! } ! ! i++; ! } ! ! } ! ! return data; ! } ! ! ! ! //**************** ! //*Parse GPS Data* ! //**************** ! //* ! //* Fields are comma delimited ! //* NMEA string parsed by field and stored into ! //* gga_fields array ! ! ! command result_t parseGPS(int8_t gga_string[GPS_MSG_LENGTH], uint8_t length) { ! ! char gga_fields[GPS_FIELDS][GPS_CHAR_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; ! SODbg(DBG_USR2, "parse GPS: \n"); ! for(q=0; q<length; q++) UARTPutChar(gga_string[q]); ! SODbg(DBG_USR2, "\n"); ! //******************************** ! ! // Parse and store comma delimited fields into EEPROM ! while (i < GPS_FIELDS) { ! ! // assemble gga_fields array ! end_of_field = FALSE; ! j = 0; ! while (!end_of_field & k < length) { ! if (gga_string[k] == GPS_DELIMITER) { ! end_of_field = TRUE; ! } ! else { ! gga_fields[i][j] = gga_string[k]; ! } ! j++; ! k++; ! } ! ! // two commas (,,) indicate empty field ! // if field is empty, set it equal to 0 ! if (j <= 1) { ! for (m=0; m<10; m++) gga_fields[i][m] = '0'; ! } ! ! i++; ! } ! ! call logGPS(gga_fields); ! return SUCCESS; ! } ! ! ! ! // ************** ! //*Log GGA data* ! //************** ! //* ! //* Assemble GGA message structure from gga_fields ! //* Store GGA data into line 25 of EEPROM ! ! ! command result_t logGPS(char gga_fields[GPS_FIELDS][GPS_CHAR_PER_FIELD]) { ! ! //GGA_Msg *pGGA; ! char NS; ! char EW; ! uint8_t nos; // number of satellites ! ! //if (gga_fields[6][0]== '0'){ ! // SODbg(DBG_USR2, "GPS NOT AVAILABLE:\n"); ! // return SUCCESS; ! // } ! ! ! // Assemble GGA_Msg ! //pGGA->hours = 10*(gga_fields[1][0]-'0') + (gga_fields[1][1]-'0'); ! pHours = 10*(gga_fields[1][0]-'0') + (gga_fields[1][1]-'0'); ! SODbg(DBG_USR2, "Hour:%i\n", pHours); ! ! pMinutes = 10*(gga_fields[1][2]-'0') + (gga_fields[1][3]-'0'); ! SODbg(DBG_USR2, "Minutes: %i\n", pMinutes); ! ! pDec_sec = 10000*(gga_fields[1][4]-'0') + 1000*(gga_fields[1][5]-'0') + 100*(gga_fields[1][7]-'0') + 10*(gga_fields[1][8]-'0') + (gga_fields[1][9]-'0'); ! SODbg(DBG_USR2, "Msb: %i, Lsb:%i \n", (pDec_sec)>>8, pDec_sec); ! ! ! pLat_deg = 10*(gga_fields[2][0]-'0') + (gga_fields[2][1]-'0'); ! SODbg(DBG_USR2, "Lat_deg %i:\n", pLat_deg); ! ! pLat_dec_min = 100000*(gga_fields[2][2]-'0') + 10000*(gga_fields[2][3]-'0') + 1000*(gga_fields[2][4]-'0') + 100*(gga_fields[2][5]-'0') + 10*(gga_fields[2][6]-'0') + (gga_fields[2][7]-'0'); ! SODbg(DBG_USR2, "Lat_dec_min: %i,%i\n", (pLat_dec_min)>>8, pLat_dec_min); ! ! ! pLong_deg = 100*(gga_fields[4][0]-'0') + 10*(gga_fields[4][1]-'0') + (gga_fields[4][2]-'0'); ! SODbg(DBG_USR2, "Long_deg %i:\n", pLong_deg); ! ! pLong_dec_min = 100000*(gga_fields[4][3]-'0') + 10000*(gga_fields[4][4]-'0') + 1000*(gga_fields[4][5]-'0') + 100*(gga_fields[4][6]-'0') + 10*(gga_fields[4][7]-'0') + (gga_fields[4][8]-'0'); ! SODbg(DBG_USR2, "Long_dec_min: %i,%i\n", (pLong_dec_min)>>8, pLong_dec_min); ! ! NS = (gga_fields[3][0] == 'N') ? 1 : 0; ! EW = (gga_fields[5][0] == 'W') ? 1 : 0; ! pNSEWind = EW | (NS<<4); // eg. Status = 000N000E = 00010000 ! SODbg(DBG_USR2, "NSEW: %i\n", pNSEWind); ! ! nos = 10*(gga_fields[7][0]-'0') + (gga_fields[7][1]-'0'); ! SODbg(DBG_USR2, "nos: %i\n", nos); ! ! if(call GpsCmd.PowerSwitch(0)) { ! SODbg(DBG_USR2, "GPS Power Off\n"); ! } ! ! ! call Timer2.start(TIMER_ONE_SHOT,300); ! ! return SUCCESS; ! } ! ! ! /****************************************************************************** ! * Packet received from GPS - ASCII msg ! * 1st byte in pkt is number of ascii bytes ! * async used only for testing ! *****************************************************************************/ ! ! ! ! ! //((((((((((((((This is a alternative way from the above)))))))))))))) ! /* ! ! event TOS_MsgPtr GpsReceive.receive(TOS_MsgPtr data) { //change to GPS packet!! ! uint8_t i; ! ! GPS_MsgPtr gps_data = (GPS_MsgPtr)data; ! ! //gps_data = (GPS_MsgPtr)data; ! call Leds.greenToggle(); ! SODbg(DBG_USR2, "GPSReceive.Receive\n"); ! //for (i = 0; i <= gps_data->data[0] ; i++) UARTPutChar(gps_data->data[i]); ! for (i = 0; i <= gps_data->length ; i++) UARTPutChar(gps_data->data[i]); ! SODbg(DBG_USR2, "\n"); ! ! SODbg(DBG_USR2, "<<<<:%i,%i,%i\n",gps_data->data[0],gps_data->data[1],gps_data->data[2]); ! //if(gps_data->data[3] == 'G' && gps_data->data[4] == 'G' && gps_data->data[5] == 'A') { ! //if(call GpsCmd.PowerSwitch(0)) { ! // SODbg(DBG_USR2, "GPS Power Off\n"); ! //} ! //} ! ! ! //call Timer2.start(TIMER_ONE_SHOT,300); ! return data; ! } ! ! */ ! ! event result_t GpsSend.sendDone(TOS_MsgPtr msg, result_t success) { ! return SUCCESS; ! } ! ! ! event result_t GpsCmd.SwitchesSet(uint8_t PowerState){ ! //if (PowerState == 1 ){ ! //gps_active = TRUE; ! //call Leds.yellowToggle(); ! //SODbg(DBG_USR2, "Switchset:Gps power on,Power \n"); ! //} ! //else{ ! //gps_active = FALSE; ! //call Leds.redToggle(); ! SODbg(DBG_USR2, "GpsCmd.SwithesSet\n"); ! //} ! ! return SUCCESS; ! } ! ! ! event result_t AccelCmd.SwitchesSet(uint8_t PowerState){ ! return SUCCESS; ! } ! ! ! } |