firebug-cvs Mailing List for FireBug: wireless wildfire monitoring (Page 3)
Brought to you by:
doolin
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(36) |
Jun
(45) |
Jul
(108) |
Aug
(31) |
Sep
(2) |
Oct
(4) |
Nov
(113) |
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(63) |
Feb
(37) |
Mar
(24) |
Apr
(6) |
May
(5) |
Jun
(5) |
Jul
(71) |
Aug
(42) |
Sep
(7) |
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
(3) |
Apr
|
May
(64) |
Jun
(71) |
Jul
(51) |
Aug
(89) |
Sep
(24) |
Oct
(1) |
Nov
(1) |
Dec
(2) |
2006 |
Jan
|
Feb
|
Mar
(3) |
Apr
(2) |
May
|
Jun
|
Jul
(21) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
From: Michael N. <mne...@us...> - 2005-09-08 23:39:43
|
Update of /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19623 Modified Files: UARTGpsPacket.nc Log Message: Formatting changes Index: UARTGpsPacket.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400/UARTGpsPacket.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UARTGpsPacket.nc 17 Aug 2005 22:48:55 -0000 1.2 --- UARTGpsPacket.nc 8 Sep 2005 23:39:35 -0000 1.3 *************** *** 97,100 **** - } --- 97,99 ---- |
From: Michael N. <mne...@us...> - 2005-09-08 23:39:13
|
Update of /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19492 Modified Files: MicaWbSwitchM.nc Log Message: Add debugging printouts Index: MicaWbSwitchM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400/MicaWbSwitchM.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MicaWbSwitchM.nc 24 May 2005 21:57:34 -0000 1.2 --- MicaWbSwitchM.nc 8 Sep 2005 23:39:05 -0000 1.3 *************** *** 68,320 **** module MicaWbSwitchM { ! provides { ! interface StdControl; ! interface Switch[uint8_t id]; ! } ! uses { ! interface StdControl as I2CPacketControl; ! interface I2CPacket as I2CSwitch0; ! interface I2CPacket as I2CSwitch1; ! } } implementation { ! enum { GET_SWITCH, SET_SWITCH, SET_SWITCH_ALL, ! SET_SWITCH_GET, IDLE}; ! char sw_state; /* current state of the switch */ ! char state; /* current state of the i2c request */ ! char addr; /* destination address */ ! char position; ! char value; ! command result_t StdControl.init() { ! state = IDLE; ! return call I2CPacketControl.init(); ! } ! command result_t StdControl.start() { ! return call I2CPacketControl.start(); ! } ! command result_t StdControl.stop() { ! return call I2CPacketControl.stop(); ! } ! command result_t Switch.get[uint8_t id]() { ! if (state == IDLE) ! { ! state = GET_SWITCH; ! if (id == 0) ! return call I2CSwitch0.readPacket(1, 0x01); ! else if (id == 1) ! return call I2CSwitch1.readPacket(1, 0x01); ! } ! state = IDLE; ! return FAIL; ! } ! command result_t Switch.set[uint8_t id](char l_position, char l_value) { ! if (state == IDLE) ! { ! state = SET_SWITCH_GET; ! value = l_value; ! position = l_position; ! if (id == 0) ! return call I2CSwitch0.readPacket(1,0x01); ! else if (id == 1) ! return call I2CSwitch1.readPacket(1,0x01); ! } ! state = IDLE; ! return FAIL; ! } ! command result_t Switch.setAll[uint8_t id](char l_value) { ! if (state == IDLE) ! { ! state = SET_SWITCH_ALL; ! sw_state = l_value; ! if (id == 0) ! return call I2CSwitch0.writePacket(1, (char*)(&sw_state), 0x01); ! else if (id == 1) ! return call I2CSwitch1.writePacket(1, (char*)(&sw_state), 0x01); ! } ! state = IDLE; ! return FAIL; ! } ! event result_t I2CSwitch0.writePacketDone(bool result) { ! if (state == SET_SWITCH) ! { ! state = IDLE; ! signal Switch.setDone[0](result); ! } ! else if (state == SET_SWITCH_ALL) { ! state = IDLE; ! signal Switch.setAllDone[0](result); ! } ! return SUCCESS; ! } ! event result_t I2CSwitch1.writePacketDone(bool result) { ! if (state == SET_SWITCH) ! { ! state = IDLE; ! signal Switch.setDone[1](result); ! } ! else if (state == SET_SWITCH_ALL) { ! state = IDLE; ! signal Switch.setAllDone[1](result); ! } ! return SUCCESS; ! } ! event result_t I2CSwitch0.readPacketDone(char length, char* data) { ! if (state == GET_SWITCH) ! { ! if (length != 1) { ! state = IDLE; ! signal Switch.getDone[0](0); ! return SUCCESS; ! } ! else { ! state = IDLE; ! signal Switch.getDone[0](data[0]); ! return SUCCESS; } ! } ! if (state == SET_SWITCH_GET) ! { ! if (length != 1) { ! state = IDLE; ! signal Switch.getDone[0](0); ! return SUCCESS; ! } ! sw_state = data[0]; ! if (position == 1) { ! sw_state = sw_state & 0xFE; ! sw_state = sw_state | value; ! } ! if (position == 2) { ! sw_state = sw_state & 0xFD; ! sw_state = sw_state | (value << 1); ! } ! if (position == 3) { ! sw_state = sw_state & 0xFB; ! sw_state = sw_state | (value << 2); ! } ! if (position == 4) { ! sw_state = sw_state & 0xF7; ! sw_state = sw_state | (value << 3); ! } ! if (position == 5) { ! sw_state = sw_state & 0xEF; ! sw_state = sw_state | (value << 4); ! } ! if (position == 6) { ! sw_state = sw_state & 0xDF; ! sw_state = sw_state | (value << 5); ! } ! if (position == 7) { ! sw_state = sw_state & 0xBF; ! sw_state = sw_state | (value << 6); ! } ! if (position == 8) { ! sw_state = sw_state & 0x7F; ! sw_state = sw_state | (value << 7); ! } ! data[0] = sw_state; ! state = SET_SWITCH; ! call I2CSwitch0.writePacket(1, (char*)&sw_state, 0x01); return SUCCESS; ! } ! return SUCCESS; ! } ! event result_t I2CSwitch1.readPacketDone(char length, char* data) { ! if (state == GET_SWITCH) ! { ! if (length != 1) { ! state = IDLE; ! signal Switch.getDone[1](0); ! return SUCCESS; ! } ! else { ! state = IDLE; ! signal Switch.getDone[1](data[0]); ! return SUCCESS; } ! } ! if (state == SET_SWITCH_GET) ! { ! if (length != 1) { ! state = IDLE; ! signal Switch.getDone[1](0); ! return SUCCESS; ! } ! sw_state = data[0]; ! if (position == 1) { ! sw_state = sw_state & 0xFE; ! sw_state = sw_state | value; ! } ! if (position == 2) { ! sw_state = sw_state & 0xFD; ! sw_state = sw_state | (value << 1); ! } ! if (position == 3) { ! sw_state = sw_state & 0xFB; ! sw_state = sw_state | (value << 2); ! } ! if (position == 4) { ! sw_state = sw_state & 0xF7; ! sw_state = sw_state | (value << 3); ! } ! if (position == 5) { ! sw_state = sw_state & 0xEF; ! sw_state = sw_state | (value << 4); ! } ! if (position == 6) { ! sw_state = sw_state & 0xDF; ! sw_state = sw_state | (value << 5); ! } ! if (position == 7) { ! sw_state = sw_state & 0xBF; ! sw_state = sw_state | (value << 6); ! } ! if (position == 8) { ! sw_state = sw_state & 0x7F; ! sw_state = sw_state | (value << 7); ! } ! data[0] = sw_state; ! state = SET_SWITCH; ! call I2CSwitch1.writePacket(1, (char*)&sw_state, 0x01); return SUCCESS; ! } ! return SUCCESS; ! } ! default event result_t Switch.setDone[uint8_t id](bool result) ! { ! return SUCCESS; ! } ! default event result_t Switch.setAllDone[uint8_t id](bool result) ! { ! return SUCCESS; ! } ! default event result_t Switch.getDone[uint8_t id](char l_value) ! { ! return SUCCESS; ! } } --- 68,371 ---- module MicaWbSwitchM { ! provides { ! interface StdControl; ! interface Switch[uint8_t id]; ! } ! uses { ! interface StdControl as I2CPacketControl; ! interface I2CPacket as I2CSwitch0; ! interface I2CPacket as I2CSwitch1; ! } } implementation { ! #include "SODebug.h" ! enum { ! GET_SWITCH, ! SET_SWITCH, ! SET_SWITCH_ALL, ! SET_SWITCH_GET, ! IDLE ! } I2Cstate; /* current state of the i2c request */ ! char sw_state; /* current state of the switch */ ! char position; ! char value; ! command result_t StdControl.init() { ! I2Cstate = IDLE; ! // SODbg(DBG_USR2,"I2C switch.init\n"); ! return call I2CPacketControl.init(); ! } ! command result_t StdControl.start() { ! // SODbg(DBG_USR2,"I2C switch.start\n"); ! return call I2CPacketControl.start(); ! } ! command result_t StdControl.stop() { ! // SODbg(DBG_USR2,"I2C switch.stop\n"); ! return call I2CPacketControl.stop(); ! } ! command result_t Switch.get[uint8_t id]() { ! if (I2Cstate == IDLE) ! { ! I2Cstate = GET_SWITCH; ! if (id == 0) ! return call I2CSwitch0.readPacket(1, 0x01); ! else if (id == 1) ! return call I2CSwitch1.readPacket(1, 0x01); ! } ! SODbg(DBG_USR2,"I2C switch.get %d FAIL\n",id); ! I2Cstate = IDLE; ! return FAIL; ! } ! command result_t Switch.set[uint8_t id](char l_position, char l_value) { ! if (I2Cstate == IDLE) { ! int count = 0; ! I2Cstate = SET_SWITCH_GET; ! // SODbg(DBG_USR2,"I2C switch.set[%d] Position:%d Value:%d\n",(int)id,(int)l_position,(int)l_value); ! value = l_value; ! position = l_position; ! while (1) { ! result_t result; ! switch (id) { ! case 0: ! result = call I2CSwitch0.readPacket(1,0x01); ! break; ! case 1: ! result = call I2CSwitch1.readPacket(1,0x01); ! break; ! default: ! return FAIL; ! }; ! if (result == SUCCESS) break; ! count += 1; ! if (count > 30000) { ! SODbg(DBG_USR2,"I2C switch.set[%d] forcing I2C init\n",(int)id); ! call I2CPacketControl.init(); ! count = 0; ! }; ! }; ! return SUCCESS; ! }; ! SODbg(DBG_USR2,"I2cSwitch.set[%d] FAIL P:%d V:%d\n",id,l_position,l_value); ! I2Cstate = IDLE; ! return FAIL; ! } ! command result_t Switch.setAll[uint8_t id](char l_value) { ! if (I2Cstate == IDLE) { ! int count = 0; ! I2Cstate = SET_SWITCH_ALL; ! sw_state = l_value; ! while (1) { ! result_t result; ! switch (id) { ! case 0: ! result = call I2CSwitch0.writePacket(1, (char*)(&sw_state), 0x01); ! break; ! case 1: ! result = call I2CSwitch1.writePacket(1, (char*)(&sw_state), 0x01); ! break; ! default: ! return FAIL; ! }; ! if (result == SUCCESS) break; ! count += 1; ! if (count > 30000) { ! SODbg(DBG_USR2,"I2C switch.setAll[%d] forcing I2C init\n",(int)id); ! call I2CPacketControl.init(); ! count = 0; ! }; ! }; ! return SUCCESS; ! }; ! SODbg(DBG_USR2,"I2cSwitch.setAll %d FAIL Value: %d\n",id,l_value); ! I2Cstate = IDLE; ! return FAIL; ! } ! event result_t I2CSwitch0.writePacketDone(bool result) { ! if (I2Cstate == SET_SWITCH) { ! I2Cstate = IDLE; ! signal Switch.setDone[0](result); ! } else if (I2Cstate == SET_SWITCH_ALL) { ! I2Cstate = IDLE; ! signal Switch.setAllDone[0](result); ! } else { ! SODbg(DBG_USR2,"Unusual I2C 0 writePacketDone: %d state: %d\n",(int)result,(int)I2Cstate); ! }; ! return SUCCESS; ! } ! event result_t I2CSwitch1.writePacketDone(bool result) { ! if (I2Cstate == SET_SWITCH) { ! I2Cstate = IDLE; ! signal Switch.setDone[1](result); ! } else if (I2Cstate == SET_SWITCH_ALL) { ! I2Cstate = IDLE; ! signal Switch.setAllDone[1](result); ! } else { ! SODbg(DBG_USR2,"Unusual I2C 1 writePacketDone: %d state: %d\n",(int)result,(int)I2Cstate); ! }; ! return SUCCESS; ! } ! ! event result_t I2CSwitch0.readPacketDone(char length, char* data) { ! // SODbg(DBG_USR2,"I2C 0 readPacketDone: length %d state: %d\n",(int)length,(int)I2Cstate); ! if (I2Cstate == GET_SWITCH) { ! if (length != 1) ! { ! I2Cstate = IDLE; ! signal Switch.getDone[0](0); ! return SUCCESS; ! } ! else { ! I2Cstate = IDLE; ! signal Switch.getDone[0](data[0]); ! return SUCCESS; ! } } ! if (I2Cstate == SET_SWITCH_GET) { ! if (length != 1) ! { ! I2Cstate = IDLE; ! signal Switch.getDone[0](0); ! return SUCCESS; ! } ! sw_state = data[0]; ! if (position == 1) { ! sw_state = sw_state & 0xFE; ! sw_state = sw_state | value; ! } ! if (position == 2) { ! sw_state = sw_state & 0xFD; ! sw_state = sw_state | (value << 1); ! } ! if (position == 3) { ! sw_state = sw_state & 0xFB; ! sw_state = sw_state | (value << 2); ! } ! if (position == 4) { ! sw_state = sw_state & 0xF7; ! sw_state = sw_state | (value << 3); ! } ! if (position == 5) { ! sw_state = sw_state & 0xEF; ! sw_state = sw_state | (value << 4); ! } ! if (position == 6) { ! sw_state = sw_state & 0xDF; ! sw_state = sw_state | (value << 5); ! } ! if (position == 7) { ! sw_state = sw_state & 0xBF; ! sw_state = sw_state | (value << 6); ! } ! if (position == 8) { ! sw_state = sw_state & 0x7F; ! sw_state = sw_state | (value << 7); ! } ! data[0] = sw_state; ! I2Cstate = SET_SWITCH; ! call I2CSwitch0.writePacket(1, (char*)&sw_state, 0x01); ! return SUCCESS; ! } return SUCCESS; ! } ! event result_t I2CSwitch1.readPacketDone(char length, char* data) { ! // SODbg(DBG_USR2,"I2C 1 readPacketDone: length %d state: %d\n",(int)length,(int)I2Cstate); ! if (I2Cstate == GET_SWITCH) { ! if (length != 1) ! { ! I2Cstate = IDLE; ! signal Switch.getDone[1](0); ! return SUCCESS; ! } ! else { ! I2Cstate = IDLE; ! signal Switch.getDone[1](data[0]); ! return SUCCESS; ! } } ! if (I2Cstate == SET_SWITCH_GET) { ! if (length != 1) ! { ! I2Cstate = IDLE; ! signal Switch.getDone[1](0); ! return SUCCESS; ! } ! sw_state = data[0]; ! if (position == 1) { ! sw_state = sw_state & 0xFE; ! sw_state = sw_state | value; ! } ! if (position == 2) { ! sw_state = sw_state & 0xFD; ! sw_state = sw_state | (value << 1); ! } ! if (position == 3) { ! sw_state = sw_state & 0xFB; ! sw_state = sw_state | (value << 2); ! } ! if (position == 4) { ! sw_state = sw_state & 0xF7; ! sw_state = sw_state | (value << 3); ! } ! if (position == 5) { ! sw_state = sw_state & 0xEF; ! sw_state = sw_state | (value << 4); ! } ! if (position == 6) { ! sw_state = sw_state & 0xDF; ! sw_state = sw_state | (value << 5); ! } ! if (position == 7) { ! sw_state = sw_state & 0xBF; ! sw_state = sw_state | (value << 6); ! } ! if (position == 8) { ! sw_state = sw_state & 0x7F; ! sw_state = sw_state | (value << 7); ! } ! data[0] = sw_state; ! I2Cstate = SET_SWITCH; ! call I2CSwitch1.writePacket(1, (char*)&sw_state, 0x01); ! return SUCCESS; ! } return SUCCESS; ! } ! default event result_t Switch.setDone[uint8_t id](bool result) ! { ! // SODbg(DBG_USR2,"I2C default SetDone %d\n",id); ! return SUCCESS; ! } ! default event result_t Switch.setAllDone[uint8_t id](bool result) ! { ! // SODbg(DBG_USR2,"I2C default setAllDone %d\n",id); ! return SUCCESS; ! } ! default event result_t Switch.getDone[uint8_t id](char l_value) ! { ! // SODbg(DBG_USR2,"I2C default setDone %d\n",id); ! return SUCCESS; ! } } |
From: Michael N. <mne...@us...> - 2005-09-08 23:37:30
|
Update of /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19029 Modified Files: GpsPacket.nc Log Message: Add missing call to init I2C services Index: GpsPacket.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400/GpsPacket.nc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GpsPacket.nc 17 Aug 2005 22:48:55 -0000 1.5 --- GpsPacket.nc 8 Sep 2005 23:37:22 -0000 1.6 *************** *** 181,185 **** rxLength = GPS_DATA_LENGTH; } ! call setGPSmode(TRUE); // setting SiRF mode return call ByteControl.init(); } --- 181,186 ---- rxLength = GPS_DATA_LENGTH; } ! call setGPSmode(FALSE); // setting SiRF mode ! call SwitchControl.init(); return call ByteControl.init(); } *************** *** 189,193 **** // The switch control system is used by the GPS which depends on // the fact that it will never be turned off by anyone else. ! call SwitchControl.start(); return call ByteControl.start(); } --- 190,194 ---- // The switch control system is used by the GPS which depends on // the fact that it will never be turned off by anyone else. ! call SwitchControl.start(); return call ByteControl.start(); } *************** *** 531,537 **** if (call Switch1.set(MICAWB_GPS_POWER,(gpsPowerStatus) ? 0 : 1) == SUCCESS) { gpsSwitchState = GPS_PWR_SWITCH_WAIT; }; ! return SUCCESS; }; return FAIL; } --- 532,541 ---- if (call Switch1.set(MICAWB_GPS_POWER,(gpsPowerStatus) ? 0 : 1) == SUCCESS) { gpsSwitchState = GPS_PWR_SWITCH_WAIT; + return SUCCESS; }; ! SODbg(DBG_USR2, "GPS PowerSwitch Switch1 set failed\n"); ! return FAIL; }; + SODbg(DBG_USR2, "PowerSwitch busy\n"); return FAIL; } *************** *** 543,547 **** if (call Switch1.set(MICAWB_GPS_ENABLE ,gpsPowerStatus) == SUCCESS) { gpsSwitchState = GPS_EN_SWITCH_WAIT; ! } } else if (gpsSwitchState == GPS_EN_SWITCH_WAIT) { --- 547,553 ---- if (call Switch1.set(MICAWB_GPS_ENABLE ,gpsPowerStatus) == SUCCESS) { gpsSwitchState = GPS_EN_SWITCH_WAIT; ! } else { ! SODbg(DBG_USR2, "Switch1.setDone could not turn enable off\n"); ! }; } else if (gpsSwitchState == GPS_EN_SWITCH_WAIT) { *************** *** 595,599 **** } else if (gpsSwitchState == GPS_RX_SWITCH_WAIT) { - // SODbg(DBG_USR2, "GpsPacket: all switches set \n"); gpsSwitchState = GPS_SWITCH_IDLE; signal GpsCmd.TxRxSet(gpsPowerStatus); --- 601,604 ---- |
From: Michael N. <mne...@us...> - 2005-09-08 23:36:28
|
Update of /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18674 Modified Files: AccelM.nc Log Message: Debugging printout updates Index: AccelM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400/AccelM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AccelM.nc 19 May 2005 17:31:54 -0000 1.1 --- AccelM.nc 8 Sep 2005 23:36:20 -0000 1.2 *************** *** 126,129 **** --- 126,130 ---- state_accel = ACCEL_PWR_SWITCH; power_accel = PowerState; + SODbg(DBG_USR2,"Request ACCEL switch %d\n",PowerState); if (!call Switch1.set(MICAWB_ACCEL_POWER,power_accel) == SUCCESS) state_accel = ACCEL_PWR_SWITCH_WAIT; return SUCCESS; *************** *** 142,148 **** *****************************************************************************/ event result_t Switch1.setDone(bool local_result) { ! // SODbg(DBG_USR2, "AccelM: setDone: state %i \n", state_accel); if (state_accel == ACCEL_PWR_SWITCH_WAIT){ //try again to get I2C bus ! // SODbg(DBG_USR2, "AccelM: setDone: I2C retry \n "); state_accel = ACCEL_PWR_SWITCH; if (!call Switch1.set(MICAWB_ACCEL_POWER,power_accel) == SUCCESS) state_accel = ACCEL_PWR_SWITCH_WAIT; --- 143,149 ---- *****************************************************************************/ event result_t Switch1.setDone(bool local_result) { ! SODbg(DBG_USR2, "AccelM: setDone: state %i \n", state_accel); if (state_accel == ACCEL_PWR_SWITCH_WAIT){ //try again to get I2C bus ! SODbg(DBG_USR2, "AccelM: setDone: I2C retry \n "); state_accel = ACCEL_PWR_SWITCH; if (!call Switch1.set(MICAWB_ACCEL_POWER,power_accel) == SUCCESS) state_accel = ACCEL_PWR_SWITCH_WAIT; |
From: Michael N. <mne...@us...> - 2005-09-08 23:33:53
|
Update of /cvsroot/firebug/fireboard/beta/apps/XSensorMTS400 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18199 Modified Files: TestMTS400M.nc Log Message: double buffering and formatting changes Index: TestMTS400M.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/apps/XSensorMTS400/TestMTS400M.nc,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** TestMTS400M.nc 17 Aug 2005 23:50:14 -0000 1.18 --- TestMTS400M.nc 8 Sep 2005 23:33:46 -0000 1.19 *************** *** 639,684 **** #ifdef MTS420 ! /****************************************************************************** ! * Packet received from GPS - ASCII msg ! * 1st byte in pkt is number of ascii bytes ! * async used only for testing ! GGA - Global Positioning System Fix Data ! GGA,123519,4807.038,N,01131.324,E,1,08,0.9,545.4,M,46.9,M, , *42 ! 123519 Fix taken at 12:35:19 UTC ! 4807.038,N Latitude 48 deg 07.038' N ! 01131.324,E Longitude 11 deg 31.324' E ! 1 Fix quality: 0 = invalid ! 1 = GPS fix ! 2 = DGPS fix ! 08 Number of satellites being tracked ! 0.9 Horizontal dilution of position ! 545.4,M Altitude, Metres, above mean sea level ! 46.9,M Height of geoid (mean sea level) above WGS84 ! ellipsoid ! (empty field) time in seconds since last DGPS update ! (empty field) DGPS station ID number ! *****************************************************************************/ ! event TOS_MsgPtr GpsReceive.receive(TOS_MsgPtr data) { ! //uint32_t temp; ! //GGA_Data gga_data = {0}; char * leadtek_string; GGA_Data * gga_data_ptr; - //change to GPS packet!! - GPS_MsgPtr gps_data = (GPS_MsgPtr)data; - - //gga_data_ptr = &gga_data; - gga_data_ptr = &(pack->xData.gga_data); // if gps have been scaned then stop receiving gps uart packet - if (readStep == GPS_DONE) return data; ! leadtek_string = gps_data->data; ! #if 0 if (leadtek_string[0] == '$') { int i; ! for (i=0;i < MIN(sizeof(gps_data->data),gps_data->length);i += 1) { SODbg(DBG_USR2, "%c",leadtek_string[i]); if (leadtek_string[i] == '*') break; --- 639,668 ---- #ifdef MTS420 ! // When a packet is received from the GPS we retain a pointer to ! // that packet and hand a pointer to another buffer back to the ! // lower level. Each sucessive message swaps buffers, establishing ! // a double buffering scheme. ! static GPS_Msg gpsData; // contributed buffer for double buffering ! static GPS_Msg *pGPSdata = &gpsData; // buffer to dump ! // Report and handle the content of a message that came in from the ! // GPS and is stored inpGGAdata. ! task void handleGPSmessage() { char * leadtek_string; GGA_Data * gga_data_ptr; gga_data_ptr = &(pack->xData.gga_data); // if gps have been scaned then stop receiving gps uart packet ! // ???is this still appropriate? Double buffering should ! // eliminate the need. ! if (readStep == GPS_DONE) return; ! ! leadtek_string = pGPSdata->data; ! #if 1 if (leadtek_string[0] == '$') { int i; ! for (i=0;i < MIN(sizeof(pGPSdata->data),pGPSdata->length);i += 1) { SODbg(DBG_USR2, "%c",leadtek_string[i]); if (leadtek_string[i] == '*') break; *************** *** 708,712 **** // Deal with the following later. #if 0 ! else if (is_gsa_string(data)) { call nmea.gsa_parse(gsa_data_ptr, leadtek_string); } else if (is_gva_string(data)) { --- 692,696 ---- // Deal with the following later. #if 0 ! else if (is_gsa_string(pGPSdata->data)) { call nmea.gsa_parse(gsa_data_ptr, leadtek_string); } else if (is_gva_string(data)) { *************** *** 748,752 **** #endif }; ! return data; } --- 732,752 ---- #endif }; ! } ! ! ! // A gps message has been collected from the receiver. Log it and ! // set off a task to report it. ! // ! // Inputs: ! // pData really a pointer to a GGA_data block ! // Returns: ! // new buffer for lower level to use ! event TOS_MsgPtr GpsReceive.receive(TOS_MsgPtr pData) { ! GPS_Msg *pTemp; ! ! pTemp = pGPSdata; ! pGPSdata = (GPS_Msg *)pData; ! post handleGPSmessage(); ! return (TOS_MsgPtr)pTemp; } |
From: Karthik D. <da...@us...> - 2005-08-31 08:40:39
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24268 Modified Files: DataCollection.h DataCollectionM.nc Log Message: New communication scheme working. Now send calibration only once every so often Index: DataCollectionM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollectionM.nc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DataCollectionM.nc 29 Aug 2005 22:45:36 -0000 1.4 --- DataCollectionM.nc 31 Aug 2005 08:40:31 -0000 1.5 *************** *** 42,46 **** enum { // HUMIDITYCALIBRATION, ! PRESSURECALIBRATION=1, HUMIDITY, TEMPERATURE, --- 42,47 ---- enum { // HUMIDITYCALIBRATION, ! PRESSURECALIBRATION=0, ! SENDCALIBRATION, HUMIDITY, TEMPERATURE, *************** *** 50,55 **** IVOLT, PRESSURE, ! SEND, ! SENDCALIBRATION }; --- 51,55 ---- IVOLT, PRESSURE, ! SEND }; *************** *** 74,78 **** uint8_t sending; // sending=1 => data; sending=2 => calibration ! int timer_rate; int timer_ticks; /*********************************************************************** --- 74,79 ---- uint8_t sending; // sending=1 => data; sending=2 => calibration ! uint8_t counter; // Do calibration and send it every 256 times ! uint8_t csendcounter; // And we send calibration thrice, just for safety int timer_ticks; /*********************************************************************** *************** *** 81,85 **** static void initialize() { - timer_rate = INITIAL_TIMER_RATE; atomic sendBusy = FALSE; sleeping = FALSE; --- 82,85 ---- *************** *** 88,93 **** rebroadcast_adc_packet = FALSE; focused = FALSE; ! sending = 1; ! // Sensor initialization state = PRESSURECALIBRATION; --- 88,93 ---- rebroadcast_adc_packet = FALSE; focused = FALSE; ! csendcounter = 0; ! counter = 0; // Sensor initialization state = PRESSURECALIBRATION; *************** *** 106,109 **** --- 106,110 ---- DataCollectionMsg *pReading; uint16_t Len; + uint8_t oldsending; dbg(DBG_USR1, "DataCollectionM: Sending sensor reading\n"); *************** *** 120,125 **** sendBusy = TRUE; ! if ((call Send.send(&dataBuffer,sizeof(DataCollectionMsg))) != SUCCESS) atomic sendBusy = FALSE; } } --- 121,130 ---- sendBusy = TRUE; ! oldsending=sending; ! sending=1; ! if ((call Send.send(&dataBuffer,sizeof(DataCollectionMsg))) != SUCCESS) { atomic sendBusy = FALSE; + sending=oldsending; + } } } *************** *** 154,158 **** call HumidityError.enable(); call TemperatureError.enable(); ! randomtimer = (call Random.rand() & 0xfff) + 1; call Timer.start(TIMER_ONE_SHOT, randomtimer); return SUCCESS; --- 159,163 ---- call HumidityError.enable(); call TemperatureError.enable(); ! randomtimer = (call Random.rand() & 0x2710) + 1; call Timer.start(TIMER_ONE_SHOT, randomtimer); return SUCCESS; *************** *** 184,194 **** --- 189,233 ---- event result_t Timer.fired() { + CalibrationMsg *cReading; + uint8_t i; + uint16_t Len; + uint8_t oldsending=0; + switch(state) { case PRESSURECALIBRATION: call PressureCalibration.getData(); break; + case SENDCALIBRATION: + if(!sendBusy) { + dbg(DBG_USR2, "DataCollectionM: output complete 0x%x\n", success); + if ((cReading = (CalibrationMsg *)call Send.getBuffer(&calibrationBuffer,&Len)) != NULL) { + cReading->type = CALIBRATION; + cReading->src = TOS_LOCAL_ADDRESS; + cReading->parentaddr = call RouteControl.getParent(); + for(i=0;i<4;i++) + cReading->calibration[i]=cal[i]; + cReading->seq_no = seqno++; + + call Leds.set(SENDCALIBRATION); + atomic sendBusy = TRUE; + oldsending=sending; + sending=2; + csendcounter++; + if ((call Send.send(&calibrationBuffer,sizeof(CalibrationMsg))) != SUCCESS) { + atomic sendBusy = FALSE; + sending=oldsending; + csendcounter--; + } + } + } + else { + call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL); + } + break; + case HUMIDITY: call Humidity.getData(); break; + case TEMPERATURE: call Temperature.getData(); *************** *** 218,222 **** break; default: ! // call Timer.start(TIMER_ONE_SHOT, 10000); } return SUCCESS; --- 257,261 ---- break; default: ! // call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL00); } return SUCCESS; *************** *** 226,232 **** atomic cal[word-1] = value; if(word >= 4) { ! state = HUMIDITY; ! call Leds.set(HUMIDITY); ! call Timer.start(TIMER_ONE_SHOT, 100); } --- 265,271 ---- atomic cal[word-1] = value; if(word >= 4) { ! state = SENDCALIBRATION; ! call Leds.set(SENDCALIBRATION); ! call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL); } *************** *** 236,240 **** async event result_t Humidity.dataReady(uint16_t data) { atomic humidity = data; ! call Timer.start(TIMER_ONE_SHOT, 100); state = TEMPERATURE; call Leds.set(TEMPERATURE); --- 275,279 ---- async event result_t Humidity.dataReady(uint16_t data) { atomic humidity = data; ! call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL); state = TEMPERATURE; call Leds.set(TEMPERATURE); *************** *** 244,248 **** event result_t HumidityError.error(uint8_t token) { atomic humidity = 0; ! call Timer.start(TIMER_ONE_SHOT, 100); state = HUMIDITY; call Leds.set(HUMIDITY); --- 283,287 ---- event result_t HumidityError.error(uint8_t token) { atomic humidity = 0; ! call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL); state = HUMIDITY; call Leds.set(HUMIDITY); *************** *** 252,256 **** async event result_t Temperature.dataReady(uint16_t data) { atomic temperature = data; ! call Timer.start(TIMER_ONE_SHOT, 100); state = ITEMP; call Leds.set(ITEMP); --- 291,295 ---- async event result_t Temperature.dataReady(uint16_t data) { atomic temperature = data; ! call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL); state = ITEMP; call Leds.set(ITEMP); *************** *** 260,264 **** event result_t TemperatureError.error(uint8_t token) { atomic temperature = 0; ! call Timer.start(TIMER_ONE_SHOT, 100); state = TEMPERATURE; call Leds.set(TEMPERATURE); --- 299,303 ---- event result_t TemperatureError.error(uint8_t token) { atomic temperature = 0; ! call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL); state = TEMPERATURE; call Leds.set(TEMPERATURE); *************** *** 299,303 **** async event result_t InternalVoltage.dataReady(uint16_t data) { atomic ivolt = data; ! call Timer.start(TIMER_ONE_SHOT, 100); state = PRESSURE; call Leds.set(PRESSURE); --- 338,342 ---- async event result_t InternalVoltage.dataReady(uint16_t data) { atomic ivolt = data; ! call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL); state = PRESSURE; call Leds.set(PRESSURE); *************** *** 307,311 **** async event result_t Pressure.dataReady(uint16_t reading) { atomic pressure = reading; ! call Timer.start(TIMER_ONE_SHOT, 100); state = SEND; call Leds.set(SEND); --- 346,350 ---- async event result_t Pressure.dataReady(uint16_t reading) { atomic pressure = reading; ! call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL); state = SEND; call Leds.set(SEND); *************** *** 315,350 **** event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { - - CalibrationMsg *cReading; - uint8_t i; - uint16_t Len; - - atomic sendBusy = FALSE; - dbg(DBG_USR2, "DataCollectionM: output complete 0x%x\n", success); if(sending == 1) { ! sending = 2; ! if ((cReading = (CalibrationMsg *)call Send.getBuffer(&calibrationBuffer,&Len)) != NULL) { ! cReading->type = CALIBRATION; ! cReading->src = TOS_LOCAL_ADDRESS; ! cReading->parentaddr = call RouteControl.getParent(); ! for(i=0;i<4;i++) ! cReading->calibration[i]=cal[i]; ! cReading->seq_no = seqno++; ! ! call Leds.set(SENDCALIBRATION); ! atomic sendBusy = TRUE; ! if ((call Send.send(&calibrationBuffer,sizeof(CalibrationMsg))) != SUCCESS) ! atomic sendBusy = FALSE; } } ! else if(sending == 2) { ! state = PRESSURECALIBRATION; ! sending = 1; ! // call Leds.set(PRESSURECALIBRATION); ! call Timer.start(TIMER_ONE_SHOT, 1000); ! return SUCCESS; } } } - --- 354,382 ---- event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { if(sending == 1) { ! /* Just sent sensor data */ ! counter ++; ! if(counter%20 == 0) { ! state = PRESSURECALIBRATION; } + else { + state = HUMIDITY; + } + call Timer.start(TIMER_ONE_SHOT, SAMPLING_RATE); } ! else { ! /* Just sent calibration data */ ! if(csendcounter < 3) { ! state = PRESSURECALIBRATION; ! } ! else { ! state = HUMIDITY; ! csendcounter = 0; ! } ! call Timer.start(TIMER_ONE_SHOT, INTERSTATE_INTERVAL); } + sendBusy = FALSE; + return SUCCESS; } } Index: DataCollection.h =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollection.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DataCollection.h 29 Aug 2005 22:45:36 -0000 1.3 --- DataCollection.h 31 Aug 2005 08:40:31 -0000 1.4 *************** *** 1,8 **** int INITIAL_TIMER_RATE = 2048; - int FOCUS_TIMER_RATE = 1000; - int FOCUS_NOTME_TIMER_RATE = 1000; - - - enum { --- 1,5 ---- + int SAMPLING_RATE=1024; // Every ten seconds + int INTERSTATE_INTERVAL=100; // 100ms int INITIAL_TIMER_RATE = 2048; enum { |
From: Karthik D. <da...@us...> - 2005-08-31 08:39:54
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23744/net/sf/firebug/DataCollection Modified Files: DataCollect.java Log Message: Working new queueing system Index: DataCollect.java =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection/DataCollect.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DataCollect.java 30 Aug 2005 00:28:35 -0000 1.7 --- DataCollect.java 31 Aug 2005 08:39:46 -0000 1.8 *************** *** 43,47 **** int nPort; MoteIF dataCollectStub; ! List dlist, clist; private static void prt(String s) { --- 43,47 ---- int nPort; MoteIF dataCollectStub; ! List dataQueue, calibrationList; private static void prt(String s) { *************** *** 145,150 **** public DataCollect() { ! dlist = new LinkedList(); ! clist = new LinkedList(); this.dataCollectStub = null; try { --- 145,150 ---- public DataCollect() { ! dataQueue = new LinkedList(); ! calibrationList = new LinkedList(); this.dataCollectStub = null; try { *************** *** 161,165 **** --- 161,179 ---- public void packetReceived(byte[] packet) { } + + private void processData() { + int counter=0; + for(counter=0;counter<dataQueue.size();counter++) { + // while(data.hasNext()) { + DataCollectionMsg msg = (DataCollectionMsg) dataQueue.get(counter); + + if(get_calibration((long)msg.get_src()) != -1) { + prt("In process data - processing element"); + printData(get_calibration(msg.get_src()),msg); + break; + } + } + } public static void main(String args[]) { *************** *** 195,198 **** --- 209,213 ---- public void messageReceived(int to, Message m) { // prt("Message Received with AM Type " + m.amType()); + printCalibrationList(); if(m.amType() == DataCollectionMsg.AM_TYPE) { MultihopMsg msg = new MultihopMsg(m.dataGet()); *************** *** 202,206 **** public void pReceived(MultihopMsg m) { ! int index=0; int i; --- 217,221 ---- public void pReceived(MultihopMsg m) { ! int index=-1; int i; *************** *** 210,226 **** System.out.println("Sensor reading"); ! if(get_data((long)msg.get_seq_no(), (long)msg.get_src()) == 0) { prt("not duplicate with seq no " + msg.get_seq_no()); /* Not a duplicate */ ! if((index = get_calibration((long)msg.get_seq_no(), (long)msg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ prt("Added to list"); ! dlist.add(msg); } else { ! dlist.add(msg); prt("Sending to print"); ! printData(index, get_data((long)msg.get_seq_no(), (long)msg.get_src())); } } --- 225,243 ---- System.out.println("Sensor reading"); ! if(get_data((long)msg.get_seq_no(), (long)msg.get_src()) == -1) { prt("not duplicate with seq no " + msg.get_seq_no()); /* Not a duplicate */ ! if((index = get_calibration((long)msg.get_src())) == -1) { /* No calibration data received yet. So, add to the list */ prt("Added to list"); ! dataQueue.add(msg); ! if(dataQueue.size() > 50) ! processData(); } else { ! dataQueue.add(msg); prt("Sending to print"); ! printData(index,msg); // get_data((long)msg.get_seq_no(), (long)msg.get_src())); } } *************** *** 231,234 **** --- 248,265 ---- CalibrationMsg cMsg = new CalibrationMsg(m.dataGet(), m.offset_data(0)); if(cMsg.get_type() == CALIBRATION) { + System.out.println("Calibration"); + prt("Calibration data received for node "+cMsg.get_src()); + index = get_calibration(cMsg.get_src()); + prt("Calibration index is " + index); + if(index == -1) + calibrationList.add(cMsg); + + prt("processing data now"); + processData(); + } + } + + + /* prt("2. Type is " + msg.get_type()); // System.out.println("Data received is " + DataCollect.byteArrayToHexString(m.dataGet())); *************** *** 241,266 **** // CalibrationMsg cMsg = new CalibrationMsg(m.dataGet(),m.offset_data(0)); if(get_calibration((long)cMsg.get_seq_no(), (long)cMsg.get_src()) == 0) { ! /* Not a duplicate */ prt("not duplicate with seq no " + msg.get_seq_no()); if((index = get_data((long)cMsg.get_seq_no(), (long)cMsg.get_src())) == 0) { /* No calibration data received yet. ! So, add to the list */ prt("Added to list"); ! clist.add(cMsg); } else { ! clist.add(cMsg); prt("Send to print"); printData(get_calibration((long)cMsg.get_seq_no(), (long)cMsg.get_src()), index); } ! } ! } ! } ! void printData(int cindex, int dindex) { ! prt("In print data"); ! DataCollectionMsg dMsg = (DataCollectionMsg) dlist.get(dindex); ! CalibrationMsg cMsg = (CalibrationMsg) clist.get(cindex); ! int source; long seqno; --- 272,293 ---- // CalibrationMsg cMsg = new CalibrationMsg(m.dataGet(),m.offset_data(0)); if(get_calibration((long)cMsg.get_seq_no(), (long)cMsg.get_src()) == 0) { ! /* Not a duplicate prt("not duplicate with seq no " + msg.get_seq_no()); if((index = get_data((long)cMsg.get_seq_no(), (long)cMsg.get_src())) == 0) { /* No calibration data received yet. ! So, add to the list prt("Added to list"); ! calibrationList.add(cMsg); } else { ! calibrationList.add(cMsg); prt("Send to print"); printData(get_calibration((long)cMsg.get_seq_no(), (long)cMsg.get_src()), index); } ! } ! } ! */ ! void printData(DataCollectionMsg dMsg, CalibrationMsg cMsg) { int source; long seqno; *************** *** 285,289 **** prt("Raw humidity : "+ dMsg.get_humidity()); prt("Raw voltage : "+ dMsg.get_ivolt()); ! prt("Raw itemp : "+ dMsg.get_itemp()); prt("Raw Pressure : "+ dMsg.get_pressure()); prt("Raw calibration readings "+DataCollect.byteArrayToHexString(DataCollect.intToByteArray(cMsg.get_calibration()))); --- 312,316 ---- prt("Raw humidity : "+ dMsg.get_humidity()); prt("Raw voltage : "+ dMsg.get_ivolt()); ! // prt("Raw itemp : "+ dMsg.get_itemp()); prt("Raw Pressure : "+ dMsg.get_pressure()); prt("Raw calibration readings "+DataCollect.byteArrayToHexString(DataCollect.intToByteArray(cMsg.get_calibration()))); *************** *** 307,323 **** } /* Delete the printed data */ ! dlist.remove(dindex); ! clist.remove(cindex); ! System.out.println("\n\nSize of dlist:"+dlist.size() +" and clist:"+clist.size()+" \n\n"); } private int get_data(long seqno, long src) { boolean found=false; ! ListIterator it=dlist.listIterator(); ! int index=0; ! while(it.hasNext()) { ! DataCollectionMsg msg = (DataCollectionMsg) it.next(); if(((long)msg.get_seq_no()) == seqno && ((long)msg.get_src()) == src) { --- 334,389 ---- } /* Delete the printed data */ ! dataQueue.remove(dMsg); ! System.out.println("\n\nSize of dataQueue:"+dataQueue.size() +" and calibrationList:"+calibrationList.size()+" \n\n"); ! } ! ! void printData(int cindex, int dindex) { ! prt("In print data"); ! if(!((dataQueue.size() >0) || (calibrationList.size() > 0))) ! return; ! DataCollectionMsg dMsg = (DataCollectionMsg) dataQueue.get(dindex); ! CalibrationMsg cMsg = (CalibrationMsg) calibrationList.get(cindex); ! ! printData(dMsg, cMsg); ! } ! ! void printData(CalibrationMsg cMsg, int dindex) { ! prt("In print data"); ! if(!(dataQueue.size() >0)) ! return; ! DataCollectionMsg dMsg = (DataCollectionMsg) dataQueue.get(dindex); ! ! if(cMsg.get_src() == dMsg.get_src()) ! printData(dMsg, cMsg); } + void printData(int cindex, DataCollectionMsg dMsg) { + prt("In print data"); + if(!(calibrationList.size() >0)) + return; + + /* + if(get_calibration((long)cindex) == -1) { + return; + } + */ + + CalibrationMsg cMsg = (CalibrationMsg) calibrationList.get(cindex); + + if(cMsg.get_src() == dMsg.get_src()) { + printData(dMsg, cMsg); + } + else { + prt("Weird. It should not come here"); + } + } + private int get_data(long seqno, long src) { boolean found=false; ! int index=-1; ! for(index=0;index<dataQueue.size();index++) { ! DataCollectionMsg msg = (DataCollectionMsg) dataQueue.get(index); if(((long)msg.get_seq_no()) == seqno && ((long)msg.get_src()) == src) { *************** *** 325,362 **** break; } - else { - index++; - } } if(!found) { ! index=0; } return index; } ! ! private int get_calibration(long seqno, long src) { boolean found=false; ! ListIterator it=clist.listIterator(); ! int index=0; ! ! while(it.hasNext()) { ! CalibrationMsg msg = (CalibrationMsg) it.next(); ! ! if(((long)msg.get_seq_no()) == seqno && ((long)msg.get_src()) == src) { found=true; break; } - else { - index++; - } } ! if(!found) { ! index=0; ! } ! ! return index; } --- 391,423 ---- break; } } if(!found) { ! index=-1; } return index; } ! ! private int get_calibration(long src) { ! int retval = -1; ! int counter = 0; boolean found=false; ! ! for(counter=0;counter<calibrationList.size();counter++) { ! if((((CalibrationMsg)calibrationList.get(counter)).get_src()) == src) { ! retval = counter; found=true; break; } } ! if(!found) ! retval = -1; ! return retval; ! } ! ! private int get_calibration(long seqno, long src) { ! return get_calibration(src); } *************** *** 423,426 **** --- 484,502 ---- return byteArray; } + + void printCalibrationList() { + int i=0; + for(i=0;i<calibrationList.size();i++) + prt(" " + ((CalibrationMsg)calibrationList.get(i)).get_src()); + prt(""); + } + + + void printDataQueue() { + int i=0; + for(i=0;i<dataQueue.size();i++) + prt(" " + ((DataCollectionMsg)dataQueue.get(i)).get_src()); + prt(""); + } } |
From: Karthik D. <da...@us...> - 2005-08-30 00:28:43
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20066/net/sf/firebug/DataCollection Modified Files: DataCollect.java Log Message: Implemented file output Index: DataCollect.java =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection/DataCollect.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DataCollect.java 29 Aug 2005 23:27:01 -0000 1.6 --- DataCollect.java 30 Aug 2005 00:28:35 -0000 1.7 *************** *** 8,12 **** import net.tinyos.message.*; import java.util.*; ! /** * --- 8,13 ---- import net.tinyos.message.*; import java.util.*; ! import java.io.BufferedWriter; ! import java.io.FileWriter; /** * *************** *** 39,42 **** --- 40,44 ---- String strAddr; + protected static String fName; int nPort; MoteIF dataCollectStub; *************** *** 167,173 **** prt("AM Type for Data collection is " + DataCollectionMsg.AM_TYPE); // Thread th = new Thread(reader); // th.start(); - } --- 169,181 ---- prt("AM Type for Data collection is " + DataCollectionMsg.AM_TYPE); + /* Parse the arguments */ + if(args.length > 1) { + fName = args[0]; + } + else { + fName = "data.dat"; + } // Thread th = new Thread(reader); // th.start(); } *************** *** 254,259 **** DataCollectionMsg dMsg = (DataCollectionMsg) dlist.get(dindex); CalibrationMsg cMsg = (CalibrationMsg) clist.get(cindex); ! System.out.println("Source : "+ dMsg.get_src()); ! System.out.println("Sequence Number: "+ dMsg.get_seq_no()); prt("Raw temperature: "+ dMsg.get_temperature()); prt("Raw humidity : "+ dMsg.get_humidity()); --- 262,285 ---- DataCollectionMsg dMsg = (DataCollectionMsg) dlist.get(dindex); CalibrationMsg cMsg = (CalibrationMsg) clist.get(cindex); ! ! int source; ! long seqno; ! double pressure, humidity, temperature, voltage; ! ! /* Compute */ ! /* NOTE: ! 1. Computing the temperature from pressure sensor. Something is screwed up with the readings from the humidity sensor ! 2. Using the same temperature to correct the humidity coz the humidity sensor's temp readings are no good ! */ ! pressure = pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration()); ! temperature = pressure_temp(dMsg.get_temperature(), cMsg.get_calibration()); ! voltage = voltage(dMsg.get_ivolt()); ! humidity = humidity(dMsg.get_humidity(), pressure_temp(dMsg.get_temperature(), cMsg.get_calibration())); ! ! source = dMsg.get_src(); ! seqno = dMsg.get_seq_no(); ! ! System.out.println("Source : "+ source); ! System.out.println("Sequence Number: "+ seqno); prt("Raw temperature: "+ dMsg.get_temperature()); prt("Raw humidity : "+ dMsg.get_humidity()); *************** *** 263,271 **** prt("Raw calibration readings "+DataCollect.byteArrayToHexString(DataCollect.intToByteArray(cMsg.get_calibration()))); prt(""); ! System.out.println("Temperature : "+pressure_temp(dMsg.get_temperature(), cMsg.get_calibration())); ! System.out.println("Pressure : "+pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration())); ! System.out.println("Voltage : "+voltage(dMsg.get_ivolt())); // System.out.println("Humidity Temp : "+humidity_temp(dMsg.get_itemp())); ! System.out.println("Humidity : "+humidity(dMsg.get_humidity(), pressure_temp(dMsg.get_temperature(), cMsg.get_calibration()))); /* Delete the printed data */ dlist.remove(dindex); --- 289,309 ---- prt("Raw calibration readings "+DataCollect.byteArrayToHexString(DataCollect.intToByteArray(cMsg.get_calibration()))); prt(""); ! System.out.println("Temperature : " + temperature ); ! System.out.println("Pressure : " + pressure); ! System.out.println("Voltage : " + voltage); // System.out.println("Humidity Temp : "+humidity_temp(dMsg.get_itemp())); ! System.out.println("Humidity : " + humidity); ! /* Writing to file */ ! if(fName != null) { ! try { ! BufferedWriter out = new BufferedWriter(new FileWriter(fName, true)); ! out.write(source + " " + seqno + " " + temperature + " " + voltage + " " + humidity + " " + pressure); ! out.newLine(); ! out.close(); ! } ! catch(Exception e) { ! e.printStackTrace(); ! } ! } /* Delete the printed data */ dlist.remove(dindex); |
From: Karthik D. <da...@us...> - 2005-08-29 23:27:11
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10148 Modified Files: DataCollect.java Log Message: Commented unnecessary display Index: DataCollect.java =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection/DataCollect.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DataCollect.java 29 Aug 2005 22:45:00 -0000 1.5 --- DataCollect.java 29 Aug 2005 23:27:01 -0000 1.6 *************** *** 256,271 **** System.out.println("Source : "+ dMsg.get_src()); System.out.println("Sequence Number: "+ dMsg.get_seq_no()); ! System.out.println("Raw temperature: "+ dMsg.get_temperature()); ! System.out.println("Raw humidity : "+ dMsg.get_humidity()); ! System.out.println("Raw voltage : "+ dMsg.get_ivolt()); ! System.out.println("Raw itemp : "+ dMsg.get_itemp()); ! System.out.println("Raw Pressure : "+ dMsg.get_pressure()); ! ! System.out.println("Raw calibration readings "+DataCollect.byteArrayToHexString(DataCollect.intToByteArray(cMsg.get_calibration()))); ! System.out.println(""); System.out.println("Temperature : "+pressure_temp(dMsg.get_temperature(), cMsg.get_calibration())); System.out.println("Pressure : "+pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration())); System.out.println("Voltage : "+voltage(dMsg.get_ivolt())); ! System.out.println("Humidity Temp : "+humidity_temp(dMsg.get_itemp())); System.out.println("Humidity : "+humidity(dMsg.get_humidity(), pressure_temp(dMsg.get_temperature(), cMsg.get_calibration()))); /* Delete the printed data */ --- 256,270 ---- System.out.println("Source : "+ dMsg.get_src()); System.out.println("Sequence Number: "+ dMsg.get_seq_no()); ! prt("Raw temperature: "+ dMsg.get_temperature()); ! prt("Raw humidity : "+ dMsg.get_humidity()); ! prt("Raw voltage : "+ dMsg.get_ivolt()); ! prt("Raw itemp : "+ dMsg.get_itemp()); ! prt("Raw Pressure : "+ dMsg.get_pressure()); ! prt("Raw calibration readings "+DataCollect.byteArrayToHexString(DataCollect.intToByteArray(cMsg.get_calibration()))); ! prt(""); System.out.println("Temperature : "+pressure_temp(dMsg.get_temperature(), cMsg.get_calibration())); System.out.println("Pressure : "+pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration())); System.out.println("Voltage : "+voltage(dMsg.get_ivolt())); ! // System.out.println("Humidity Temp : "+humidity_temp(dMsg.get_itemp())); System.out.println("Humidity : "+humidity(dMsg.get_humidity(), pressure_temp(dMsg.get_temperature(), cMsg.get_calibration()))); /* Delete the printed data */ |
From: Karthik D. <da...@us...> - 2005-08-29 22:45:46
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32355 Modified Files: DataCollection.h DataCollection.nc DataCollectionM.nc Log Message: Redid the data structures to accommodate humidity temperature. All working now Index: DataCollectionM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollectionM.nc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DataCollectionM.nc 29 Aug 2005 18:52:51 -0000 1.3 --- DataCollectionM.nc 29 Aug 2005 22:45:36 -0000 1.4 *************** *** 19,23 **** // interface ADC as TSR; // interface ADC as PAR; ! // interface ADC as InternalTemperature; interface ADC as InternalVoltage; interface ADC as Pressure; --- 19,23 ---- // interface ADC as TSR; // interface ADC as PAR; ! interface ADC as HumidityTemp; interface ADC as InternalVoltage; interface ADC as Pressure; *************** *** 47,51 **** // TSRSENSOR, // PARSENSOR, ! // ITEMP, IVOLT, PRESSURE, --- 47,51 ---- // TSRSENSOR, // PARSENSOR, ! ITEMP, IVOLT, PRESSURE, *************** *** 112,119 **** pReading->type = SENSORREADING; pReading->src = TOS_LOCAL_ADDRESS; - pReading->parentaddr = call RouteControl.getParent(); pReading->humidity = humidity; pReading->temperature = temperature; ! // pReading->itemp = itemp; pReading->ivolt = ivolt; pReading->pressure = pressure; --- 112,118 ---- pReading->type = SENSORREADING; pReading->src = TOS_LOCAL_ADDRESS; pReading->humidity = humidity; pReading->temperature = temperature; ! pReading->itemp = itemp; pReading->ivolt = ivolt; pReading->pressure = pressure; *************** *** 124,128 **** atomic sendBusy = FALSE; } - } --- 123,126 ---- *************** *** 204,211 **** call PAR.getData(); break; case ITEMP: ! call InternalTemperature.getData(); break; - */ case IVOLT: --- 202,210 ---- call PAR.getData(); break; + */ case ITEMP: ! // call InternalTemperature.getData(); ! call HumidityTemp.getData(); break; case IVOLT: *************** *** 254,259 **** atomic temperature = data; call Timer.start(TIMER_ONE_SHOT, 100); ! state = IVOLT; ! call Leds.set(IVOLT); return SUCCESS; } --- 253,258 ---- atomic temperature = data; call Timer.start(TIMER_ONE_SHOT, 100); ! state = ITEMP; ! call Leds.set(ITEMP); return SUCCESS; } *************** *** 282,285 **** --- 281,286 ---- } + */ + /* async event result_t InternalTemperature.dataReady(uint16_t data) { itemp = data; *************** *** 289,292 **** --- 290,299 ---- } */ + async event result_t HumidityTemp.dataReady(uint16_t data) { + itemp = data; + call Timer.start(TIMER_ONE_SHOT, 10); + state = IVOLT; + return SUCCESS; + } async event result_t InternalVoltage.dataReady(uint16_t data) { Index: DataCollection.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollection.nc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DataCollection.nc 29 Aug 2005 18:52:51 -0000 1.3 --- DataCollection.nc 29 Aug 2005 22:45:36 -0000 1.4 *************** *** 56,60 **** DataCollectionM.HumidityControl -> HumidityC; DataCollectionM.Humidity -> HumidityC.Humidity; ! // DataCollectionM.Temperature -> HumidityC.Temperature; DataCollectionM.Temperature -> IntersemaPressure.Temperature; // DataCollectionM.TSR -> HamamatsuC.TSR; --- 56,60 ---- DataCollectionM.HumidityControl -> HumidityC; DataCollectionM.Humidity -> HumidityC.Humidity; ! DataCollectionM.HumidityTemp -> HumidityC.Temperature; DataCollectionM.Temperature -> IntersemaPressure.Temperature; // DataCollectionM.TSR -> HamamatsuC.TSR; Index: DataCollection.h =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollection.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataCollection.h 29 Aug 2005 00:25:53 -0000 1.2 --- DataCollection.h 29 Aug 2005 22:45:36 -0000 1.3 *************** *** 19,26 **** // uint16_t tsr; // uint16_t par; ! // uint16_t itemp; uint16_t ivolt; uint16_t pressure; ! uint16_t parentaddr; uint32_t seq_no; } DataCollectionMsg; --- 19,26 ---- // uint16_t tsr; // uint16_t par; ! uint16_t itemp; uint16_t ivolt; uint16_t pressure; ! // uint16_t parentaddr; uint32_t seq_no; } DataCollectionMsg; |
From: Karthik D. <da...@us...> - 2005-08-29 22:45:08
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32227/net/sf/firebug/DataCollection Modified Files: DataCollect.java Log Message: Working humidity sensor with calibration and temperature correction Index: DataCollect.java =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection/DataCollect.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DataCollect.java 29 Aug 2005 19:15:56 -0000 1.4 --- DataCollect.java 29 Aug 2005 22:45:00 -0000 1.5 *************** *** 133,136 **** --- 133,145 ---- } + public double humidity_temp(int raw_temp) { + return (-39.60 + 0.01*(raw_temp&0x3F40)); + } + + public double humidity(int raw_humidity, double temp) { + double hum = (-4 + 0.0405*raw_humidity + (-2.8 *Math.pow(10.0,-6.0))*(Math.pow(raw_humidity,2))); + return ((temp - 25.0)*(0.01 + 0.00008*raw_humidity) + hum); + } + public DataCollect() { dlist = new LinkedList(); *************** *** 147,151 **** } } ! public void packetReceived(byte[] packet) { } --- 156,160 ---- } } ! public void packetReceived(byte[] packet) { } *************** *** 193,200 **** System.out.println("Sensor reading"); ! if(get_data(msg.get_seq_no(), (long)msg.get_src()) == 0) { prt("not duplicate with seq no " + msg.get_seq_no()); /* Not a duplicate */ ! if((index = get_calibration(msg.get_seq_no(), (long)msg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ --- 202,209 ---- System.out.println("Sensor reading"); ! if(get_data((long)msg.get_seq_no(), (long)msg.get_src()) == 0) { prt("not duplicate with seq no " + msg.get_seq_no()); /* Not a duplicate */ ! if((index = get_calibration((long)msg.get_seq_no(), (long)msg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ *************** *** 205,209 **** dlist.add(msg); prt("Sending to print"); ! printData(index, get_data(msg.get_seq_no(), (long)msg.get_src())); } } --- 214,218 ---- dlist.add(msg); prt("Sending to print"); ! printData(index, get_data((long)msg.get_seq_no(), (long)msg.get_src())); } } *************** *** 223,230 **** System.out.println("Calibration"); // CalibrationMsg cMsg = new CalibrationMsg(m.dataGet(),m.offset_data(0)); ! if(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()) == 0) { /* Not a duplicate */ prt("not duplicate with seq no " + msg.get_seq_no()); ! if((index = get_data(cMsg.get_seq_no(), (long)cMsg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ --- 232,239 ---- System.out.println("Calibration"); // CalibrationMsg cMsg = new CalibrationMsg(m.dataGet(),m.offset_data(0)); ! if(get_calibration((long)cMsg.get_seq_no(), (long)cMsg.get_src()) == 0) { /* Not a duplicate */ prt("not duplicate with seq no " + msg.get_seq_no()); ! if((index = get_data((long)cMsg.get_seq_no(), (long)cMsg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ *************** *** 235,239 **** clist.add(cMsg); prt("Send to print"); ! printData(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()), index); } } --- 244,248 ---- clist.add(cMsg); prt("Send to print"); ! printData(get_calibration((long)cMsg.get_seq_no(), (long)cMsg.get_src()), index); } } *************** *** 249,253 **** System.out.println("Raw temperature: "+ dMsg.get_temperature()); System.out.println("Raw humidity : "+ dMsg.get_humidity()); ! System.out.println("Raw voltage : "+ dMsg.get_ivolt()); System.out.println("Raw Pressure : "+ dMsg.get_pressure()); --- 258,263 ---- System.out.println("Raw temperature: "+ dMsg.get_temperature()); System.out.println("Raw humidity : "+ dMsg.get_humidity()); ! System.out.println("Raw voltage : "+ dMsg.get_ivolt()); ! System.out.println("Raw itemp : "+ dMsg.get_itemp()); System.out.println("Raw Pressure : "+ dMsg.get_pressure()); *************** *** 257,260 **** --- 267,272 ---- System.out.println("Pressure : "+pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration())); System.out.println("Voltage : "+voltage(dMsg.get_ivolt())); + System.out.println("Humidity Temp : "+humidity_temp(dMsg.get_itemp())); + System.out.println("Humidity : "+humidity(dMsg.get_humidity(), pressure_temp(dMsg.get_temperature(), cMsg.get_calibration()))); /* Delete the printed data */ dlist.remove(dindex); *************** *** 272,276 **** DataCollectionMsg msg = (DataCollectionMsg) it.next(); ! if(msg.get_seq_no() == seqno && msg.get_src() == src) { found=true; break; --- 284,288 ---- DataCollectionMsg msg = (DataCollectionMsg) it.next(); ! if(((long)msg.get_seq_no()) == seqno && ((long)msg.get_src()) == src) { found=true; break; *************** *** 296,300 **** CalibrationMsg msg = (CalibrationMsg) it.next(); ! if(msg.get_seq_no() == seqno && msg.get_src() == src) { found=true; break; --- 308,312 ---- CalibrationMsg msg = (CalibrationMsg) it.next(); ! if(((long)msg.get_seq_no()) == seqno && ((long)msg.get_src()) == src) { found=true; break; |
From: Karthik D. <da...@us...> - 2005-08-29 19:16:04
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18003/net/sf/firebug/DataCollection Modified Files: DataCollect.java Log Message: Added Internal voltage sensor calibration Index: DataCollect.java =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection/DataCollect.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DataCollect.java 29 Aug 2005 18:52:25 -0000 1.3 --- DataCollect.java 29 Aug 2005 19:15:56 -0000 1.4 *************** *** 49,53 **** } ! public static double pressure_mbar(int raw_pressure, int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; if (calibration.length != 4) --- 49,53 ---- } ! private static double pressure_mbar(int raw_pressure, int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; if (calibration.length != 4) *************** *** 79,83 **** } ! public static double pressure_inHg(int raw_pressure, int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; if (calibration.length != 4) --- 79,83 ---- } ! private static double pressure_inHg(int raw_pressure, int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; if (calibration.length != 4) *************** *** 107,111 **** } ! public static double pressure_temp(int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; if (calibration.length != 4) --- 107,111 ---- } ! private static double pressure_temp(int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; if (calibration.length != 4) *************** *** 129,132 **** --- 129,136 ---- } + private static double voltage(int raw_ivolt) { + return (((double)raw_ivolt)/4096.0*1.5*2); + } + public DataCollect() { dlist = new LinkedList(); *************** *** 249,256 **** System.out.println("Raw calibration readings "+DataCollect.byteArrayToHexString(DataCollect.intToByteArray(cMsg.get_calibration()))); System.out.println("Temperature : "+pressure_temp(dMsg.get_temperature(), cMsg.get_calibration())); ! System.out.println("Pressure : "+pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration())); ! ! /* Delete the printed data */ dlist.remove(dindex); clist.remove(cindex); --- 253,261 ---- System.out.println("Raw calibration readings "+DataCollect.byteArrayToHexString(DataCollect.intToByteArray(cMsg.get_calibration()))); + System.out.println(""); System.out.println("Temperature : "+pressure_temp(dMsg.get_temperature(), cMsg.get_calibration())); ! System.out.println("Pressure : "+pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration())); ! System.out.println("Voltage : "+voltage(dMsg.get_ivolt())); ! /* Delete the printed data */ dlist.remove(dindex); clist.remove(cindex); |
From: Karthik D. <da...@us...> - 2005-08-29 18:53:00
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11617 Modified Files: DataCollection.nc DataCollectionM.nc Log Message: Working temperature and pressure sensors Index: DataCollectionM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollectionM.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataCollectionM.nc 29 Aug 2005 00:25:53 -0000 1.2 --- DataCollectionM.nc 29 Aug 2005 18:52:51 -0000 1.3 *************** *** 321,325 **** cReading->src = TOS_LOCAL_ADDRESS; cReading->parentaddr = call RouteControl.getParent(); ! for(i=0;i<=4;i++) cReading->calibration[i]=cal[i]; cReading->seq_no = seqno++; --- 321,325 ---- cReading->src = TOS_LOCAL_ADDRESS; cReading->parentaddr = call RouteControl.getParent(); ! for(i=0;i<4;i++) cReading->calibration[i]=cal[i]; cReading->seq_no = seqno++; Index: DataCollection.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollection.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataCollection.nc 29 Aug 2005 00:25:53 -0000 1.2 --- DataCollection.nc 29 Aug 2005 18:52:51 -0000 1.3 *************** *** 56,60 **** DataCollectionM.HumidityControl -> HumidityC; DataCollectionM.Humidity -> HumidityC.Humidity; ! DataCollectionM.Temperature -> HumidityC.Temperature; // DataCollectionM.TSR -> HamamatsuC.TSR; // DataCollectionM.PAR -> HamamatsuC.PAR; --- 56,61 ---- DataCollectionM.HumidityControl -> HumidityC; DataCollectionM.Humidity -> HumidityC.Humidity; ! // DataCollectionM.Temperature -> HumidityC.Temperature; ! DataCollectionM.Temperature -> IntersemaPressure.Temperature; // DataCollectionM.TSR -> HamamatsuC.TSR; // DataCollectionM.PAR -> HamamatsuC.PAR; |
From: Karthik D. <da...@us...> - 2005-08-29 18:52:37
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11552/net/sf/firebug/DataCollection Modified Files: DataCollect.java Log Message: Working pressure and temperature calibration Index: DataCollect.java =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection/DataCollect.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataCollect.java 29 Aug 2005 00:25:27 -0000 1.2 --- DataCollect.java 29 Aug 2005 18:52:25 -0000 1.3 *************** *** 1,43 **** - /* - * Author: Mike Chen <mik...@cs...> - * Inception Date: October 22th, 2000 - * - * This software is copyrighted by Mike Chen and the Regents of - * the University of California. The following terms apply to all - * files associated with the software unless explicitly disclaimed in - * individual files. - * - * The authors hereby grant permission to use this software without - * fee or royalty for any non-commercial purpose. The authors also - * grant permission to redistribute this software, provided this - * copyright and a copy of this license (for reference) are retained - * in all distributed copies. - * - * For commercial use of this software, contact the authors. - * - * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY - * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY - * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE - * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE - * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR - * MODIFICATIONS. - * - * Copyright (c) 2005 Moteiv Corporation - * All rights reserved. - * - * This file is distributed under the terms in the attached MOTEIV-LICENSE - * file. If you do not find these files, copies can be found at - * http://www.moteiv.com/MOTEIV-LICENSE.txt and by emailing in...@mo.... - * - * Modified September 11, 2004 by Rob Szewczyk <in...@mo...> - * to display readings from the contrib/moteiv/apps/PressureTest application - */ - //============================================================================== //=== DataCollect.java ============================================== --- 1,2 ---- *************** *** 56,59 **** --- 15,19 ---- * @author <A HREF="http://www.cs.berkeley.edu/~mikechen/">Mike Chen</A> * (<A HREF="mailto:mik...@cs...">mik...@cs...</A>) + * customized for data collection applicatoin by Karthik Dantu (da...@us...) * @since 1.1.6 * *************** *** 62,70 **** ! public class DataCollect implements MessageListener, Runnable { ! //========================================================================= //=== CONSTANTS ======================================================= ! private static int MSG_SIZE = 36; // 4 header bytes, 30 msg bytes, 2 crc // bytes; 2 strength bytes are not --- 22,30 ---- ! public class DataCollect implements MessageListener { //, Runnable { ! //========================================================================= //=== CONSTANTS ======================================================= ! private static int MSG_SIZE = 36; // 4 header bytes, 30 msg bytes, 2 crc // bytes; 2 strength bytes are not *************** *** 72,84 **** //========================================================================= //=== PRIVATE VARIABLES ================================================ ! static final int SENSORREADING = 0; static final int CALIBRATION = 1; String strAddr; int nPort; MoteIF dataCollectStub; - MoteIF calibrateStub; List dlist, clist; public static double pressure_mbar(int raw_pressure, int raw_temperature, int[] calibration) { --- 32,51 ---- //========================================================================= //=== PRIVATE VARIABLES ================================================ ! static final int SENSORREADING = 0; static final int CALIBRATION = 1; + static final boolean DEBUG = false; + String strAddr; int nPort; MoteIF dataCollectStub; List dlist, clist; + + private static void prt(String s) { + if(DEBUG) { + System.out.println(s); + } + } public static double pressure_mbar(int raw_pressure, int raw_temperature, int[] calibration) { *************** *** 96,104 **** c5 += calibration[1] >> 6; c6 = calibration[1] & 0x3F; ! int ut1 = 8*c5+20224; int dt = raw_temperature - ut1; double temp = 200 + dt*(c6+50)/(Math.pow(2,10)); ! double off = c2*4 + ((c4-512)*dt)/(Math.pow(2,12)); double sens = c1 + (c3*dt)/(Math.pow(2,10)) + 24576; --- 63,72 ---- c5 += calibration[1] >> 6; c6 = calibration[1] & 0x3F; ! ! prt("Calibration constants in pressure_mbar are "+c1+" "+c2+" "+c3+" "+c4+" "+c5+" "+c6+" "); int ut1 = 8*c5+20224; int dt = raw_temperature - ut1; double temp = 200 + dt*(c6+50)/(Math.pow(2,10)); ! double off = c2*4 + ((c4-512)*dt)/(Math.pow(2,12)); double sens = c1 + (c3*dt)/(Math.pow(2,10)) + 24576; *************** *** 106,114 **** (Math.pow(2,14)) - off; double p = x*100/(Math.pow(2,5)) + 250*100; ! //System.out.println("Press (mbar) : " + p/100); ! //System.out.println("Press (inHg) : " + p/(100*33.864)); return (p/100); } ! public static double pressure_inHg(int raw_pressure, int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; --- 74,82 ---- (Math.pow(2,14)) - off; double p = x*100/(Math.pow(2,5)) + 250*100; ! //prt("Press (mbar) : " + p/100); ! //prt("Press (inHg) : " + p/(100*33.864)); return (p/100); } ! public static double pressure_inHg(int raw_pressure, int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; *************** *** 125,132 **** c5 += calibration[1] >> 6; c6 = calibration[1] & 0x3F; int ut1 = 8*c5+20224; int dt = raw_temperature - ut1; ! double off = c2*4 + ((c4-512)*dt)/(Math.pow(2,12)); double sens = c1 + (c3*dt)/(Math.pow(2,10)) + 24576; --- 93,102 ---- c5 += calibration[1] >> 6; c6 = calibration[1] & 0x3F; + + prt("Calibration constants in pressure_inHg are "+c1+" "+c2+" "+c3+" "+c4+" "+c5+" "+c6+" "); int ut1 = 8*c5+20224; int dt = raw_temperature - ut1; ! double off = c2*4 + ((c4-512)*dt)/(Math.pow(2,12)); double sens = c1 + (c3*dt)/(Math.pow(2,10)) + 24576; *************** *** 136,140 **** return (p/(100*33.864)); } ! public static double pressure_temp(int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; --- 106,110 ---- return (p/(100*33.864)); } ! public static double pressure_temp(int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; *************** *** 151,155 **** c5 += calibration[1] >> 6; c6 = calibration[1] & 0x3F; ! int ut1 = 8*c5+20224; int dt = raw_temperature - ut1; --- 121,126 ---- c5 += calibration[1] >> 6; c6 = calibration[1] & 0x3F; ! ! prt("Calibration constants in pressure_temp are "+c1+" "+c2+" "+c3+" "+c4+" "+c5+" "+c6+" "); int ut1 = 8*c5+20224; int dt = raw_temperature - ut1; *************** *** 157,161 **** return (temp/10); } ! public DataCollect() { dlist = new LinkedList(); --- 128,132 ---- return (temp/10); } ! public DataCollect() { dlist = new LinkedList(); *************** *** 172,191 **** } } ! public void packetReceived(byte[] packet) { } ! ! public static void main(String args[]) { ! DataCollect reader = new DataCollect(); ! Thread th = new Thread(reader); ! th.start(); ! } public void run() { while (true) { try { Thread.sleep(500); } catch (InterruptedException e) { --- 143,167 ---- } } ! public void packetReceived(byte[] packet) { } ! ! public static void main(String args[]) { ! ! prt("In program"); DataCollect reader = new DataCollect(); ! prt("AM Type for Data collection is " + DataCollectionMsg.AM_TYPE); ! ! // Thread th = new Thread(reader); ! // th.start(); ! } + /* public void run() { while (true) { try { + prt("In thread.run"); Thread.sleep(500); } catch (InterruptedException e) { *************** *** 194,243 **** } } public void messageReceived(int to, Message m) { ! System.out.println("Message Received with AM Type " + m.amType()); if(m.amType() == DataCollectionMsg.AM_TYPE) { MultihopMsg msg = new MultihopMsg(m.dataGet()); ! this.packetReceived(msg); } } ! ! public void packetReceived(MultihopMsg m) { int index=0; DataCollectionMsg msg = new DataCollectionMsg(m.dataGet(),m.offset_data(0)); - System.out.println("Type is " + msg.get_type()); if(msg.get_type() == SENSORREADING) { System.out.println("Sensor reading"); if(get_data(msg.get_seq_no(), (long)msg.get_src()) == 0) { ! System.out.println("not duplicate with seq no " + msg.get_seq_no()); /* Not a duplicate */ if((index = get_calibration(msg.get_seq_no(), (long)msg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ ! System.out.println("Added to list"); dlist.add(msg); } else { dlist.add(msg); ! System.out.println("Sending to print"); printData(index, get_data(msg.get_seq_no(), (long)msg.get_src())); } } } ! else if(msg.get_type() == CALIBRATION) { System.out.println("Calibration"); ! CalibrationMsg cMsg = new CalibrationMsg(m.dataGet(),m.offset_data(0)); if(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()) == 0) { /* Not a duplicate */ ! System.out.println("not duplicate with seq no " + msg.get_seq_no()); if((index = get_data(cMsg.get_seq_no(), (long)cMsg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ ! System.out.println("Added to list"); clist.add(cMsg); } else { clist.add(cMsg); ! System.out.println("Send to print"); printData(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()), index); } --- 170,234 ---- } } + */ public void messageReceived(int to, Message m) { ! // prt("Message Received with AM Type " + m.amType()); if(m.amType() == DataCollectionMsg.AM_TYPE) { MultihopMsg msg = new MultihopMsg(m.dataGet()); ! this.pReceived(msg); } } ! ! public void pReceived(MultihopMsg m) { int index=0; + int i; + DataCollectionMsg msg = new DataCollectionMsg(m.dataGet(),m.offset_data(0)); if(msg.get_type() == SENSORREADING) { + prt("1. Type is " + msg.get_type()); System.out.println("Sensor reading"); + if(get_data(msg.get_seq_no(), (long)msg.get_src()) == 0) { ! prt("not duplicate with seq no " + msg.get_seq_no()); /* Not a duplicate */ if((index = get_calibration(msg.get_seq_no(), (long)msg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ ! prt("Added to list"); dlist.add(msg); } else { dlist.add(msg); ! prt("Sending to print"); printData(index, get_data(msg.get_seq_no(), (long)msg.get_src())); } } } ! ! /* Ideally, should have a root structure with type and two child structures DataCollection and Calibration. ! This way, we can use the root structure to cast to for the outer check condition. This is a quick hack */ ! CalibrationMsg cMsg = new CalibrationMsg(m.dataGet(), m.offset_data(0)); ! if(cMsg.get_type() == CALIBRATION) { ! prt("2. Type is " + msg.get_type()); ! // System.out.println("Data received is " + DataCollect.byteArrayToHexString(m.dataGet())); ! prt("Calibration Data is : "); ! int cal[] = cMsg.get_calibration(); ! for(i=0;i<4;i++) ! prt(" " +cal[i]); ! prt(""); System.out.println("Calibration"); ! // CalibrationMsg cMsg = new CalibrationMsg(m.dataGet(),m.offset_data(0)); if(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()) == 0) { /* Not a duplicate */ ! prt("not duplicate with seq no " + msg.get_seq_no()); if((index = get_data(cMsg.get_seq_no(), (long)cMsg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ ! prt("Added to list"); clist.add(cMsg); } else { clist.add(cMsg); ! prt("Send to print"); printData(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()), index); } *************** *** 245,254 **** } } ! void printData(int cindex, int dindex) { ! System.out.println("In print data"); DataCollectionMsg dMsg = (DataCollectionMsg) dlist.get(dindex); CalibrationMsg cMsg = (CalibrationMsg) clist.get(cindex); - System.out.println("--reading--"); System.out.println("Source : "+ dMsg.get_src()); System.out.println("Sequence Number: "+ dMsg.get_seq_no()); --- 236,244 ---- } } ! void printData(int cindex, int dindex) { ! prt("In print data"); DataCollectionMsg dMsg = (DataCollectionMsg) dlist.get(dindex); CalibrationMsg cMsg = (CalibrationMsg) clist.get(cindex); System.out.println("Source : "+ dMsg.get_src()); System.out.println("Sequence Number: "+ dMsg.get_seq_no()); *************** *** 256,266 **** System.out.println("Raw humidity : "+ dMsg.get_humidity()); System.out.println("Raw voltage : "+ dMsg.get_ivolt()); System.out.println("Temperature : "+pressure_temp(dMsg.get_temperature(), cMsg.get_calibration())); System.out.println("Pressure : "+pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration())); ! /* Delete the printed data */ dlist.remove(dindex); clist.remove(cindex); ! System.out.println("\n\nSize of dlist:"+dlist.size() +" and clist:"+clist.size()+" \n\n"); } --- 246,259 ---- System.out.println("Raw humidity : "+ dMsg.get_humidity()); System.out.println("Raw voltage : "+ dMsg.get_ivolt()); + System.out.println("Raw Pressure : "+ dMsg.get_pressure()); + + System.out.println("Raw calibration readings "+DataCollect.byteArrayToHexString(DataCollect.intToByteArray(cMsg.get_calibration()))); System.out.println("Temperature : "+pressure_temp(dMsg.get_temperature(), cMsg.get_calibration())); System.out.println("Pressure : "+pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration())); ! /* Delete the printed data */ dlist.remove(dindex); clist.remove(cindex); ! System.out.println("\n\nSize of dlist:"+dlist.size() +" and clist:"+clist.size()+" \n\n"); } *************** *** 270,277 **** ListIterator it=dlist.listIterator(); int index=0; ! while(it.hasNext()) { DataCollectionMsg msg = (DataCollectionMsg) it.next(); ! if(msg.get_seq_no() == seqno && msg.get_src() == src) { found=true; --- 263,270 ---- ListIterator it=dlist.listIterator(); int index=0; ! while(it.hasNext()) { DataCollectionMsg msg = (DataCollectionMsg) it.next(); ! if(msg.get_seq_no() == seqno && msg.get_src() == src) { found=true; *************** *** 282,286 **** } } ! if(!found) { index=0; --- 275,279 ---- } } ! if(!found) { index=0; *************** *** 289,301 **** return index; } ! private int get_calibration(long seqno, long src) { boolean found=false; ListIterator it=clist.listIterator(); int index=0; ! while(it.hasNext()) { CalibrationMsg msg = (CalibrationMsg) it.next(); ! if(msg.get_seq_no() == seqno && msg.get_src() == src) { found=true; --- 282,294 ---- return index; } ! private int get_calibration(long seqno, long src) { boolean found=false; ListIterator it=clist.listIterator(); int index=0; ! while(it.hasNext()) { CalibrationMsg msg = (CalibrationMsg) it.next(); ! if(msg.get_seq_no() == seqno && msg.get_src() == src) { found=true; *************** *** 306,310 **** } } ! if(!found) { index=0; --- 299,303 ---- } } ! if(!found) { index=0; *************** *** 313,316 **** --- 306,372 ---- return index; } + + /** + * Convert a byte[] array to readable string format. This makes the "hex" + readable! + * @return result String buffer in String format + * @param in byte[] buffer to convert to string format + */ + + static String byteArrayToHexString(byte in[]) { + + byte ch = 0x00; + int i = 0; + + if (in == null || in.length <= 0) + return null; + + String pseudo[] = {"0", "1", "2", + "3", "4", "5", "6", "7", "8", + "9", "A", "B", "C", "D", "E", + "F"}; + + StringBuffer out = new StringBuffer(in.length * 2); + + while (i < in.length) { + ch = (byte) (in[i] & 0xF0); // Strip off high nibble + + ch = (byte) (ch >>> 4); + // shift the bits down + + ch = (byte) (ch & 0x0F); + // must do this is high order bit is on! + + out.append(pseudo[ (int) ch]); // convert the nibble to a String Character + ch = (byte) (in[i] & 0x0F); // Strip off low nibble + out.append(pseudo[ (int) ch]); // convert the nibble to a String Character + i++; + } + + String rslt = new String(out); + + return rslt; + + } + + static private byte[] intToByteArray (final int integer) { + int byteNum = (40 - Integer.numberOfLeadingZeros (integer < 0 ? ~integer : integer)) / 8; + byte[] byteArray = new byte[4]; + + for (int n = 0; n < byteNum; n++) + byteArray[3 - n] = (byte) (integer >>> (n * 8)); + + return (byteArray); + } + + static private byte[] intToByteArray (int[] intArray) { + int i; + byte[] byteArray = new byte[4*intArray.length]; + + for(i=0;i<intArray.length; i++) + System.arraycopy(intToByteArray (intArray[i]), 0, byteArray, i*4, 4); + + return byteArray; + } } |
From: Karthik D. <da...@us...> - 2005-08-29 18:52:35
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/fireworks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11552/net/sf/firebug/fireworks Modified Files: Fireworks.java Makefile Log Message: Working pressure and temperature calibration Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/fireworks/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 26 Jul 2005 18:51:03 -0000 1.1 --- Makefile 29 Aug 2005 18:52:25 -0000 1.2 *************** *** 29,32 **** --- 29,35 ---- $(JAVAC) $@ + Fireworks.class:Fireworks.java + $(JAVAC) *.java + cleanmig: rm -f $(MSGS) Index: Fireworks.java =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/fireworks/Fireworks.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Fireworks.java 26 Jul 2005 18:51:03 -0000 1.1 --- Fireworks.java 29 Aug 2005 18:52:25 -0000 1.2 *************** *** 20,26 **** private static final boolean VERBOSE = false; static int group_id = 0x7d; ! MoteIF mote; static Fireworks fw; --- 20,31 ---- private static final boolean VERBOSE = false; + + private static final int IDLE = 0; + private static final int SENT_DATA_REQUEST = 1; + private static final int RECEIVING_DATA = 2; + static int group_id = 0x7d; ! static MoteIF mIF; static Fireworks fw; *************** *** 32,44 **** static int numPowerLevels; static int frequency; Fireworks() { data = new LinkedList(); ! ! mote = new MoteIF(PrintStreamMessenger.err, group_id); ! mote.registerListener(new DataMsg(), this); ! mote.registerListener(new DataRequestMsg(), this); ! mote.registerListener(new PingMsg(), this); ! mote.registerListener(new PingReplyMsg(), this); } --- 37,51 ---- static int numPowerLevels; static int frequency; + private static int state; Fireworks() { data = new LinkedList(); ! state = Fireworks.IDLE; ! ! mIF = new MoteIF(PrintStreamMessenger.err, group_id); ! mIF.registerListener(new DataMsg(), this); ! mIF.registerListener(new DataRequestMsg(), this); ! mIF.registerListener(new PingMsg(), this); ! mIF.registerListener(new PingReplyMsg(), this); } *************** *** 66,72 **** wait for data packets to come in */ ! ! } } --- 73,102 ---- wait for data packets to come in */ + DataRequestMsg drMsg = new DataRequestMsg(); + int seqno = 0; + int source = 0; ! while(source <numNodes) { ! if(state == Fireworks.IDLE) { ! drMsg.set_seqno(seqno++); ! drMsg.set_source(source++); ! //drMsg.set_client(target++); //set the client's address ! drMsg.set_numNodes(numNodes); ! drMsg.set_numTrials(numTrials); ! drMsg.set_numPowerLevels(numPowerLevels); ! drMsg.set_trialFrequency(frequency); ! ! try { ! if(VERBOSE) { ! System.out.println("Sending DataRequestMsg to " +source); ! mIF.send(source, drMsg); ! state = Fireworks.SENT_DATA_REQUEST; ! } ! } catch (IOException e) { ! System.err.println("Warning: Got IOException when sending DataRequestMsg"); ! e.printStackTrace(); ! } ! } ! } } } *************** *** 91,94 **** --- 121,125 ---- DataElement dElement=new DataElement(); + state = RECEIVING_DATA; if(VERBOSE) { System.out.println("Received Data Msg from " + dest); *************** *** 104,107 **** --- 135,144 ---- if(dElement.get_source() != 0 && dElement.get_source() != src) { dElement.add(dMsg.get_data(), src); + if(dElement.get_counter() >= numTrials) { + state = IDLE; + if(dElement.get_counter() > numTrials) { + System.err.println("Got more RSSI values than number of trials " + dElement.get_counter()); + } + } } else { |
From: Karthik D. <da...@us...> - 2005-08-29 00:26:01
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17281 Modified Files: Calibration.h DataCollection.h DataCollection.nc DataCollectionM.nc Makefile Log Message: Functional tos modules Index: DataCollectionM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollectionM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataCollectionM.nc 28 Aug 2005 20:03:47 -0000 1.1 --- DataCollectionM.nc 29 Aug 2005 00:25:53 -0000 1.2 *************** *** 42,46 **** enum { // HUMIDITYCALIBRATION, ! PRESSURECALIBRATION, HUMIDITY, TEMPERATURE, --- 42,46 ---- enum { // HUMIDITYCALIBRATION, ! PRESSURECALIBRATION=1, HUMIDITY, TEMPERATURE, *************** *** 50,54 **** IVOLT, PRESSURE, ! SEND }; --- 50,55 ---- IVOLT, PRESSURE, ! SEND, ! SENDCALIBRATION }; *************** *** 66,75 **** bool rebroadcast_adc_packet; ! TOS_Msg gMsgBuffer; ! norace uint16_t gSensorData; // protected by gfSendBusy flag uint32_t seqno; bool initTimer; ! bool gfSendBusy; ! int timer_rate; --- 67,76 ---- bool rebroadcast_adc_packet; ! TOS_Msg dataBuffer; ! TOS_Msg calibrationBuffer; uint32_t seqno; bool initTimer; ! bool sendBusy; ! uint8_t sending; // sending=1 => data; sending=2 => calibration int timer_rate; *************** *** 81,85 **** static void initialize() { timer_rate = INITIAL_TIMER_RATE; ! atomic gfSendBusy = FALSE; sleeping = FALSE; seqno = 0; --- 82,86 ---- static void initialize() { timer_rate = INITIAL_TIMER_RATE; ! atomic sendBusy = FALSE; sleeping = FALSE; seqno = 0; *************** *** 87,103 **** rebroadcast_adc_packet = FALSE; focused = FALSE; // Sensor initialization state = PRESSURECALIBRATION; } task void SendData() { DataCollectionMsg *pReading; - CalibrationMsg *cReading; uint16_t Len; - uint8_t i; dbg(DBG_USR1, "DataCollectionM: Sending sensor reading\n"); ! if ((pReading = (DataCollectionMsg *)call Send.getBuffer(&gMsgBuffer,&Len)) != NULL) { pReading->type = SENSORREADING; pReading->src = TOS_LOCAL_ADDRESS; --- 88,113 ---- rebroadcast_adc_packet = FALSE; focused = FALSE; + sending = 1; // Sensor initialization state = PRESSURECALIBRATION; + call Leds.set(PRESSURECALIBRATION); + } + + void clearPacket() { + uint8_t i; + for(i=0; i< 29; i++) { + dataBuffer.data[i]=0x0; + calibrationBuffer.data[i]=0x0; + } } task void SendData() { DataCollectionMsg *pReading; uint16_t Len; dbg(DBG_USR1, "DataCollectionM: Sending sensor reading\n"); ! clearPacket(); ! if ((pReading = (DataCollectionMsg *)call Send.getBuffer(&dataBuffer,&Len)) != NULL) { pReading->type = SENSORREADING; pReading->src = TOS_LOCAL_ADDRESS; *************** *** 110,134 **** pReading->seq_no = seqno; ! #ifdef MHOP_LEDS ! call Leds.redOn(); ! #endif ! if ((call Send.send(&gMsgBuffer,sizeof(DataCollectionMsg))) != SUCCESS) ! atomic gfSendBusy = FALSE; } - if ((cReading = (CalibrationMsg *)call Send.getBuffer(&gMsgBuffer,&Len)) != NULL) { - cReading->type = CALIBRATION; - cReading->src = TOS_LOCAL_ADDRESS; - cReading->parentaddr = call RouteControl.getParent(); - for(i=0;i<=4;i++) - cReading->calibration[i]=cal[i]; - cReading->seq_no = seqno++; - - #ifdef MHOP_LEDS - call Leds.redOn(); - #endif - if ((call Send.send(&gMsgBuffer,sizeof(DataCollectionMsg))) != SUCCESS) - atomic gfSendBusy = FALSE; - } } --- 120,128 ---- pReading->seq_no = seqno; ! sendBusy = TRUE; ! if ((call Send.send(&dataBuffer,sizeof(DataCollectionMsg))) != SUCCESS) ! atomic sendBusy = FALSE; } } *************** *** 149,157 **** command result_t StdControl.start() { call CC2420Control.SetRFPower(15); call MacControl.enableAck(); - call HumidityControl.start(); - call PressureControl.start(); return SUCCESS; } --- 143,151 ---- command result_t StdControl.start() { + call HumidityControl.start(); + call PressureControl.start(); call CC2420Control.SetRFPower(15); call MacControl.enableAck(); return SUCCESS; } *************** *** 187,199 **** } - event result_t PressureCalibration.dataReady(char word, uint16_t value) { - atomic cal[word-1] = value; - if(word >= 4) { - state = HUMIDITY; - } - - return SUCCESS; - } - /*********************************************************************** * Commands and events --- 181,184 ---- *************** *** 201,209 **** event result_t Timer.fired() { - // set a timeout in case a task post fails (rare) - call Timer.start(TIMER_ONE_SHOT, 100); switch(state) { case PRESSURECALIBRATION: call PressureCalibration.getData(); case HUMIDITY: call Humidity.getData(); --- 186,193 ---- event result_t Timer.fired() { switch(state) { case PRESSURECALIBRATION: call PressureCalibration.getData(); + break; case HUMIDITY: call Humidity.getData(); *************** *** 235,268 **** break; default: ! call Timer.start(TIMER_ONE_SHOT, 10000); } return SUCCESS; } async event result_t Humidity.dataReady(uint16_t data) { ! humidity = data; ! call Timer.start(TIMER_ONE_SHOT, 10); state = TEMPERATURE; return SUCCESS; } event result_t HumidityError.error(uint8_t token) { ! humidity = 0; ! call Timer.start(TIMER_ONE_SHOT, 10); state = HUMIDITY; return SUCCESS; } async event result_t Temperature.dataReady(uint16_t data) { ! temperature = data; ! call Timer.start(TIMER_ONE_SHOT, 10); state = IVOLT; return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { ! temperature = 0; ! call Timer.start(TIMER_ONE_SHOT, 10); state = TEMPERATURE; return SUCCESS; } --- 219,267 ---- break; default: ! // call Timer.start(TIMER_ONE_SHOT, 10000); } return SUCCESS; } + event result_t PressureCalibration.dataReady(char word, uint16_t value) { + atomic cal[word-1] = value; + if(word >= 4) { + state = HUMIDITY; + call Leds.set(HUMIDITY); + call Timer.start(TIMER_ONE_SHOT, 100); + } + + return SUCCESS; + } + async event result_t Humidity.dataReady(uint16_t data) { ! atomic humidity = data; ! call Timer.start(TIMER_ONE_SHOT, 100); state = TEMPERATURE; + call Leds.set(TEMPERATURE); return SUCCESS; } event result_t HumidityError.error(uint8_t token) { ! atomic humidity = 0; ! call Timer.start(TIMER_ONE_SHOT, 100); state = HUMIDITY; + call Leds.set(HUMIDITY); return SUCCESS; } async event result_t Temperature.dataReady(uint16_t data) { ! atomic temperature = data; ! call Timer.start(TIMER_ONE_SHOT, 100); state = IVOLT; + call Leds.set(IVOLT); return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { ! atomic temperature = 0; ! call Timer.start(TIMER_ONE_SHOT, 100); state = TEMPERATURE; + call Leds.set(TEMPERATURE); return SUCCESS; } *************** *** 292,298 **** async event result_t InternalVoltage.dataReady(uint16_t data) { ! ivolt = data; ! call Timer.start(TIMER_ONE_SHOT, 10); state = PRESSURE; return SUCCESS; } --- 291,298 ---- async event result_t InternalVoltage.dataReady(uint16_t data) { ! atomic ivolt = data; ! call Timer.start(TIMER_ONE_SHOT, 100); state = PRESSURE; + call Leds.set(PRESSURE); return SUCCESS; } *************** *** 300,319 **** async event result_t Pressure.dataReady(uint16_t reading) { atomic pressure = reading; ! call Timer.start(TIMER_ONE_SHOT, 10); state = SEND; ! return SUCCESS; } event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { - dbg(DBG_USR2, "DataCollectionM: output complete 0x%x\n", success); - #ifdef MHOP_LEDS - call Leds.redOff(); - #endif - atomic gfSendBusy = FALSE; - return SUCCESS; - } } --- 300,342 ---- async event result_t Pressure.dataReady(uint16_t reading) { atomic pressure = reading; ! call Timer.start(TIMER_ONE_SHOT, 100); state = SEND; ! call Leds.set(SEND); ! return SUCCESS; } event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { + CalibrationMsg *cReading; + uint8_t i; + uint16_t Len; + atomic sendBusy = FALSE; + dbg(DBG_USR2, "DataCollectionM: output complete 0x%x\n", success); + if(sending == 1) { + sending = 2; + if ((cReading = (CalibrationMsg *)call Send.getBuffer(&calibrationBuffer,&Len)) != NULL) { + cReading->type = CALIBRATION; + cReading->src = TOS_LOCAL_ADDRESS; + cReading->parentaddr = call RouteControl.getParent(); + for(i=0;i<=4;i++) + cReading->calibration[i]=cal[i]; + cReading->seq_no = seqno++; + + call Leds.set(SENDCALIBRATION); + atomic sendBusy = TRUE; + if ((call Send.send(&calibrationBuffer,sizeof(CalibrationMsg))) != SUCCESS) + atomic sendBusy = FALSE; + } + } + else if(sending == 2) { + state = PRESSURECALIBRATION; + sending = 1; + // call Leds.set(PRESSURECALIBRATION); + call Timer.start(TIMER_ONE_SHOT, 1000); + return SUCCESS; + } + } } Index: Calibration.h =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/Calibration.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Calibration.h 28 Aug 2005 20:03:47 -0000 1.1 --- Calibration.h 29 Aug 2005 00:25:53 -0000 1.2 *************** *** 1,12 **** typedef struct CalibrationMsg { - uint16_t type; uint16_t src; ! uint16_t parentaddr; uint16_t calibration[4]; ! uint16_t seq_no; } CalibrationMsg; enum { ! AM_CALIBRATIONMSG = 18 }; --- 1,12 ---- typedef struct CalibrationMsg { uint16_t src; ! uint16_t type; uint16_t calibration[4]; ! uint16_t parentaddr; ! uint32_t seq_no; } CalibrationMsg; enum { ! AM_CALIBRATIONMSG = 42 }; Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 28 Aug 2005 20:03:47 -0000 1.2 --- Makefile 29 Aug 2005 00:25:53 -0000 1.3 *************** *** 1,3 **** ! PFLAGS= -I%T/lib/MultiHopLQI -I%T/../contrib/moteiv/tos/sensorboards/pressure -DSEND_QUEUE_SIZE=8 -DMHOP_LEDS # -I%T/platform/msp430 -I%T/platform/telos PLATFORMS=telos telosa telosb tmote --- 1,3 ---- ! PFLAGS= -I%T/lib/MultiHopLQI -I%T/../contrib/moteiv/tos/sensorboards/pressure -DSEND_QUEUE_SIZE=8 -DDC_LEDS # -I%T/platform/msp430 -I%T/platform/telos PLATFORMS=telos telosa telosb tmote Index: DataCollection.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollection.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataCollection.nc 28 Aug 2005 20:04:23 -0000 1.1 --- DataCollection.nc 29 Aug 2005 00:25:53 -0000 1.2 *************** *** 8,12 **** --- 8,16 ---- components Main, DataCollectionM , TimerC + #ifdef DC_LEDS , LedsC + #else + , NoLeds as LedsC + #endif , DelugeC // , NoLeds *************** *** 67,72 **** DataCollectionM.Send -> multihopM.Send[AM_DATACOLLECTIONMSG]; multihopM.ReceiveMsg[AM_DATACOLLECTIONMSG] -> Comm.ReceiveMsg[AM_DATACOLLECTIONMSG]; ! DataCollectionM.Send -> multihopM.Send[AM_CALIBRATIONMSG]; ! multihopM.ReceiveMsg[AM_CALIBRATIONMSG] -> Comm.ReceiveMsg[AM_CALIBRATIONMSG]; //multihopM.ReceiveMsg[AM_MULTIHOPMSG] -> Comm.ReceiveMsg[AM_MULTIHOPMSG]; } --- 71,76 ---- DataCollectionM.Send -> multihopM.Send[AM_DATACOLLECTIONMSG]; multihopM.ReceiveMsg[AM_DATACOLLECTIONMSG] -> Comm.ReceiveMsg[AM_DATACOLLECTIONMSG]; ! // DataCollectionM.CalibrationSend -> multihopM.Send[AM_CALIBRATIONMSG]; ! // multihopM.ReceiveMsg[AM_CALIBRATIONMSG] -> Comm.ReceiveMsg[AM_CALIBRATIONMSG]; //multihopM.ReceiveMsg[AM_MULTIHOPMSG] -> Comm.ReceiveMsg[AM_MULTIHOPMSG]; } Index: DataCollection.h =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/DataCollection.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataCollection.h 28 Aug 2005 20:03:47 -0000 1.1 --- DataCollection.h 29 Aug 2005 00:25:53 -0000 1.2 *************** *** 8,12 **** enum { SENSORREADING = 0, ! CALIBRATION }; --- 8,12 ---- enum { SENSORREADING = 0, ! CALIBRATION = 1 }; *************** *** 27,31 **** enum { ! AM_DATACOLLECTIONMSG = 17 }; --- 27,31 ---- enum { ! AM_DATACOLLECTIONMSG = 42 }; |
From: Karthik D. <da...@us...> - 2005-08-29 00:25:37
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17154 Modified Files: DataCollect.java Makefile Log Message: Functional java modules Index: DataCollect.java =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection/DataCollect.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataCollect.java 28 Aug 2005 20:01:43 -0000 1.1 --- DataCollect.java 29 Aug 2005 00:25:27 -0000 1.2 *************** *** 73,76 **** --- 73,79 ---- //=== PRIVATE VARIABLES ================================================ + static final int SENSORREADING = 0; + static final int CALIBRATION = 1; + String strAddr; int nPort; *************** *** 156,159 **** --- 159,164 ---- public DataCollect() { + dlist = new LinkedList(); + clist = new LinkedList(); this.dataCollectStub = null; try { *************** *** 166,179 **** System.exit(1); } - - try { - this.calibrateStub = new MoteIF(); - calibrateStub.registerListener(new CalibrationMsg(), this); - - calibrateStub.start(); - } catch (Exception e) { - e.printStackTrace(); //To change body of catch statement use Options | File Templates. - System.exit(1); - } } --- 171,174 ---- *************** *** 201,231 **** public void messageReceived(int to, Message m) { int index=0; ! if (m.amType() == DataCollectionMsg.AM_TYPE) { ! DataCollectionMsg msg = new DataCollectionMsg(m,0); if(get_data(msg.get_seq_no(), (long)msg.get_src()) == 0) { /* Not a duplicate */ if((index = get_calibration(msg.get_seq_no(), (long)msg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ dlist.add(msg); } else { dlist.add(msg); printData(index, get_data(msg.get_seq_no(), (long)msg.get_src())); } } } ! else if(m.amType() == CalibrationMsg.AM_TYPE) { ! CalibrationMsg cMsg = new CalibrationMsg(m,0); if(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()) == 0) { /* Not a duplicate */ if((index = get_data(cMsg.get_seq_no(), (long)cMsg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ clist.add(cMsg); } else { clist.add(cMsg); printData(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()), index); } --- 196,243 ---- public void messageReceived(int to, Message m) { + System.out.println("Message Received with AM Type " + m.amType()); + if(m.amType() == DataCollectionMsg.AM_TYPE) { + MultihopMsg msg = new MultihopMsg(m.dataGet()); + this.packetReceived(msg); + } + } + + public void packetReceived(MultihopMsg m) { int index=0; ! DataCollectionMsg msg = new DataCollectionMsg(m.dataGet(),m.offset_data(0)); ! System.out.println("Type is " + msg.get_type()); ! if(msg.get_type() == SENSORREADING) { ! System.out.println("Sensor reading"); if(get_data(msg.get_seq_no(), (long)msg.get_src()) == 0) { + System.out.println("not duplicate with seq no " + msg.get_seq_no()); /* Not a duplicate */ if((index = get_calibration(msg.get_seq_no(), (long)msg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ + System.out.println("Added to list"); dlist.add(msg); } else { dlist.add(msg); + System.out.println("Sending to print"); printData(index, get_data(msg.get_seq_no(), (long)msg.get_src())); } } } ! else if(msg.get_type() == CALIBRATION) { ! System.out.println("Calibration"); ! CalibrationMsg cMsg = new CalibrationMsg(m.dataGet(),m.offset_data(0)); if(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()) == 0) { /* Not a duplicate */ + System.out.println("not duplicate with seq no " + msg.get_seq_no()); if((index = get_data(cMsg.get_seq_no(), (long)cMsg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ + System.out.println("Added to list"); clist.add(cMsg); } else { clist.add(cMsg); + System.out.println("Send to print"); printData(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()), index); } *************** *** 235,238 **** --- 247,251 ---- void printData(int cindex, int dindex) { + System.out.println("In print data"); DataCollectionMsg dMsg = (DataCollectionMsg) dlist.get(dindex); CalibrationMsg cMsg = (CalibrationMsg) clist.get(cindex); Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 28 Aug 2005 20:01:43 -0000 1.1 --- Makefile 29 Aug 2005 00:25:27 -0000 1.2 *************** *** 5,9 **** # List of message classes to build ! MSGS = DataCollectionMsg.java CalibrationMsg.java INITIAL_TARGETS = $(MSGS) OTHER_CLEAN = cleanmig --- 5,9 ---- # List of message classes to build ! MSGS = DataCollectionMsg.java CalibrationMsg.java MultihopMsg.java INITIAL_TARGETS = $(MSGS) OTHER_CLEAN = cleanmig *************** *** 11,14 **** --- 11,15 ---- ROOT = $(TOS)/../contrib/moteiv/tools/java include $(ROOT)/Makefile.include + DataCollectionMsg.java: $(MIG) -java-classname=$(PACKAGE).DataCollectionMsg $(APP)/DataCollection.h DataCollectionMsg >$@ *************** *** 17,20 **** --- 18,24 ---- $(MIG) -java-classname=$(PACKAGE).CalibrationMsg $(APP)/Calibration.h CalibrationMsg >$@ + MultihopMsg.java: + $(MIG) -java-classname=$(PACKAGE).MultihopMsg $(TOS)/lib/MultihopLQI/Multihop.h MultihopMsg >$@ + cleanmig: rm -f $(MSGS) |
From: Karthik D. <da...@us...> - 2005-08-28 20:04:35
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32520 Added Files: DataCollection.nc Log Message: Finishing touches --- NEW FILE: DataCollection.nc --- includes DataCollection; includes Calibration; includes MultiHop; configuration DataCollection { } implementation { components Main, DataCollectionM , TimerC , LedsC , DelugeC // , NoLeds // , DemoSensorC as Sensor , RandomLFSR , GenericComm as Comm // , Bcast , CC2420RadioC , LQIMultiHopRouter as multihopM // , QueuedSend; , HumidityC , HamamatsuC , InternalTempC , InternalVoltageC , IntersemaPressure ; Main.StdControl -> DelugeC; Main.StdControl -> TimerC; Main.StdControl -> Comm; // Main.StdControl -> Bcast.StdControl; Main.StdControl -> HamamatsuC; Main.StdControl -> InternalTempC; Main.StdControl -> InternalVoltageC; Main.StdControl -> multihopM.StdControl; // Main.StdControl -> QueuedSend.StdControl; Main.StdControl -> DataCollectionM.StdControl; DataCollectionM.Timer -> TimerC.Timer[unique("Timer")]; DataCollectionM.Leds -> LedsC; // NoLeds; DataCollectionM.Random -> RandomLFSR; // DataCollectionM.Bcast -> Bcast.Receive[AM_SURGECMDMSG]; // Bcast.ReceiveMsg[AM_SURGECMDMSG] -> Comm.ReceiveMsg[AM_SURGECMDMSG]; DataCollectionM.CC2420Control -> CC2420RadioC.CC2420Control; DataCollectionM.MacControl -> CC2420RadioC.MacControl; //Sensors DataCollectionM.HumidityControl -> HumidityC; DataCollectionM.Humidity -> HumidityC.Humidity; DataCollectionM.Temperature -> HumidityC.Temperature; // DataCollectionM.TSR -> HamamatsuC.TSR; // DataCollectionM.PAR -> HamamatsuC.PAR; // DataCollectionM.InternalTemperature -> InternalTempC; DataCollectionM.InternalVoltage -> InternalVoltageC; DataCollectionM.PressureControl -> IntersemaPressure; DataCollectionM.Pressure -> IntersemaPressure.Pressure; DataCollectionM.PressureCalibration -> IntersemaPressure.Calibration; DataCollectionM.TemperatureError -> HumidityC.TemperatureError; DataCollectionM.HumidityError -> HumidityC.HumidityError; DataCollectionM.RouteControl -> multihopM; DataCollectionM.Send -> multihopM.Send[AM_DATACOLLECTIONMSG]; multihopM.ReceiveMsg[AM_DATACOLLECTIONMSG] -> Comm.ReceiveMsg[AM_DATACOLLECTIONMSG]; DataCollectionM.Send -> multihopM.Send[AM_CALIBRATIONMSG]; multihopM.ReceiveMsg[AM_CALIBRATIONMSG] -> Comm.ReceiveMsg[AM_CALIBRATIONMSG]; //multihopM.ReceiveMsg[AM_MULTIHOPMSG] -> Comm.ReceiveMsg[AM_MULTIHOPMSG]; } |
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32407 Modified Files: Makefile Added Files: Calibration.h DataCollection.h DataCollectionM.nc Removed Files: Surge.h Surge.nc SurgeCmd.h SurgeM.nc Log Message: Rewrote DataCollection tinyos module --- SurgeM.nc DELETED --- Index: Makefile =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 28 Aug 2005 09:17:26 -0000 1.1 --- Makefile 28 Aug 2005 20:03:47 -0000 1.2 *************** *** 4,8 **** TINYOS_NP ?= BNP ! COMPONENT=Surge include ${MAKERULES} --- 4,8 ---- TINYOS_NP ?= BNP ! COMPONENT=DataCollection include ${MAKERULES} --- NEW FILE: DataCollectionM.nc --- includes DataCollection; includes Calibration; /* * Data gather application */ module DataCollectionM { provides { interface StdControl; } uses { // interface ADC; interface SplitControl as HumidityControl; interface SplitControl as PressureControl; interface ADC as Humidity; interface ADC as Temperature; // interface ADC as TSR; // interface ADC as PAR; // interface ADC as InternalTemperature; interface ADC as InternalVoltage; interface ADC as Pressure; interface ADCError as HumidityError; interface ADCError as TemperatureError; interface Calibration as PressureCalibration; interface Timer; interface Leds; interface CC2420Control; interface MacControl; interface Send; interface RouteControl; interface Random; } } implementation { enum { // HUMIDITYCALIBRATION, PRESSURECALIBRATION, HUMIDITY, TEMPERATURE, // TSRSENSOR, // PARSENSOR, // ITEMP, IVOLT, PRESSURE, SEND }; norace uint16_t humidity, temperature, tsr, par, itemp, ivolt, pressure; norace uint16_t cal[4]; norace int state; enum { TIMER_GETADC_COUNT = 1, // Timer ticks for ADC TIMER_CHIRP_COUNT = 10, // Timer on/off chirp count }; bool sleeping; // application command state bool focused; bool rebroadcast_adc_packet; TOS_Msg gMsgBuffer; norace uint16_t gSensorData; // protected by gfSendBusy flag uint32_t seqno; bool initTimer; bool gfSendBusy; int timer_rate; int timer_ticks; /*********************************************************************** * Initialization ***********************************************************************/ static void initialize() { timer_rate = INITIAL_TIMER_RATE; atomic gfSendBusy = FALSE; sleeping = FALSE; seqno = 0; initTimer = TRUE; rebroadcast_adc_packet = FALSE; focused = FALSE; // Sensor initialization state = PRESSURECALIBRATION; } task void SendData() { DataCollectionMsg *pReading; CalibrationMsg *cReading; uint16_t Len; uint8_t i; dbg(DBG_USR1, "DataCollectionM: Sending sensor reading\n"); if ((pReading = (DataCollectionMsg *)call Send.getBuffer(&gMsgBuffer,&Len)) != NULL) { pReading->type = SENSORREADING; pReading->src = TOS_LOCAL_ADDRESS; pReading->parentaddr = call RouteControl.getParent(); pReading->humidity = humidity; pReading->temperature = temperature; // pReading->itemp = itemp; pReading->ivolt = ivolt; pReading->pressure = pressure; pReading->seq_no = seqno; #ifdef MHOP_LEDS call Leds.redOn(); #endif if ((call Send.send(&gMsgBuffer,sizeof(DataCollectionMsg))) != SUCCESS) atomic gfSendBusy = FALSE; } if ((cReading = (CalibrationMsg *)call Send.getBuffer(&gMsgBuffer,&Len)) != NULL) { cReading->type = CALIBRATION; cReading->src = TOS_LOCAL_ADDRESS; cReading->parentaddr = call RouteControl.getParent(); for(i=0;i<=4;i++) cReading->calibration[i]=cal[i]; cReading->seq_no = seqno++; #ifdef MHOP_LEDS call Leds.redOn(); #endif if ((call Send.send(&gMsgBuffer,sizeof(DataCollectionMsg))) != SUCCESS) atomic gfSendBusy = FALSE; } } command result_t StdControl.init() { initialize(); call HumidityControl.init(); call PressureControl.init(); return SUCCESS; } event result_t HumidityControl.initDone() { return SUCCESS; } event result_t PressureControl.initDone() { return SUCCESS; } command result_t StdControl.start() { call CC2420Control.SetRFPower(15); call MacControl.enableAck(); call HumidityControl.start(); call PressureControl.start(); return SUCCESS; } event result_t HumidityControl.startDone() { uint16_t randomtimer; call HumidityError.enable(); call TemperatureError.enable(); randomtimer = (call Random.rand() & 0xfff) + 1; call Timer.start(TIMER_ONE_SHOT, randomtimer); return SUCCESS; } event result_t PressureControl.startDone() { return SUCCESS; } command result_t StdControl.stop() { call HumidityControl.stop(); call PressureControl.stop(); return call Timer.stop(); } event result_t HumidityControl.stopDone() { call HumidityError.disable(); call TemperatureError.disable(); return SUCCESS; } event result_t PressureControl.stopDone() { return SUCCESS; } event result_t PressureCalibration.dataReady(char word, uint16_t value) { atomic cal[word-1] = value; if(word >= 4) { state = HUMIDITY; } return SUCCESS; } /*********************************************************************** * Commands and events ***********************************************************************/ event result_t Timer.fired() { // set a timeout in case a task post fails (rare) call Timer.start(TIMER_ONE_SHOT, 100); switch(state) { case PRESSURECALIBRATION: call PressureCalibration.getData(); case HUMIDITY: call Humidity.getData(); break; case TEMPERATURE: call Temperature.getData(); break; /* case TSRSENSOR: call TSR.getData(); break; case PARSENSOR: call PAR.getData(); break; case ITEMP: call InternalTemperature.getData(); break; */ case IVOLT: call InternalVoltage.getData(); break; case PRESSURE: call Pressure.getData(); break; case SEND: post SendData(); break; default: call Timer.start(TIMER_ONE_SHOT, 10000); } return SUCCESS; } async event result_t Humidity.dataReady(uint16_t data) { humidity = data; call Timer.start(TIMER_ONE_SHOT, 10); state = TEMPERATURE; return SUCCESS; } event result_t HumidityError.error(uint8_t token) { humidity = 0; call Timer.start(TIMER_ONE_SHOT, 10); state = HUMIDITY; return SUCCESS; } async event result_t Temperature.dataReady(uint16_t data) { temperature = data; call Timer.start(TIMER_ONE_SHOT, 10); state = IVOLT; return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { temperature = 0; call Timer.start(TIMER_ONE_SHOT, 10); state = TEMPERATURE; return SUCCESS; } /* async event result_t TSR.dataReady(uint16_t data) { tsr = data; call Timer.start(TIMER_ONE_SHOT, 10); state = PARSENSOR; return SUCCESS; } async event result_t PAR.dataReady(uint16_t data) { par = data; call Timer.start(TIMER_ONE_SHOT, 10); state = ITEMP; return SUCCESS; } async event result_t InternalTemperature.dataReady(uint16_t data) { itemp = data; call Timer.start(TIMER_ONE_SHOT, 10); state = IVOLT; return SUCCESS; } */ async event result_t InternalVoltage.dataReady(uint16_t data) { ivolt = data; call Timer.start(TIMER_ONE_SHOT, 10); state = PRESSURE; return SUCCESS; } async event result_t Pressure.dataReady(uint16_t reading) { atomic pressure = reading; call Timer.start(TIMER_ONE_SHOT, 10); state = SEND; return SUCCESS; } event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { dbg(DBG_USR2, "DataCollectionM: output complete 0x%x\n", success); #ifdef MHOP_LEDS call Leds.redOff(); #endif atomic gfSendBusy = FALSE; return SUCCESS; } } --- Surge.nc DELETED --- --- SurgeCmd.h DELETED --- --- NEW FILE: DataCollection.h --- int INITIAL_TIMER_RATE = 2048; int FOCUS_TIMER_RATE = 1000; int FOCUS_NOTME_TIMER_RATE = 1000; enum { SENSORREADING = 0, CALIBRATION }; typedef struct DataCollectionMsg { uint16_t src; uint16_t type; uint16_t humidity; uint16_t temperature; // uint16_t tsr; // uint16_t par; // uint16_t itemp; uint16_t ivolt; uint16_t pressure; uint16_t parentaddr; uint32_t seq_no; } DataCollectionMsg; enum { AM_DATACOLLECTIONMSG = 17 }; --- NEW FILE: Calibration.h --- typedef struct CalibrationMsg { uint16_t type; uint16_t src; uint16_t parentaddr; uint16_t calibration[4]; uint16_t seq_no; } CalibrationMsg; enum { AM_CALIBRATIONMSG = 18 }; --- Surge.h DELETED --- |
From: Karthik D. <da...@us...> - 2005-08-28 20:01:52
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32086 Added Files: DataCollect.java Makefile Log Message: Java modules for data collection --- NEW FILE: DataCollect.java --- /* * Author: Mike Chen <mik...@cs...> * Inception Date: October 22th, 2000 * * This software is copyrighted by Mike Chen and the Regents of * the University of California. The following terms apply to all * files associated with the software unless explicitly disclaimed in * individual files. * * The authors hereby grant permission to use this software without * fee or royalty for any non-commercial purpose. The authors also * grant permission to redistribute this software, provided this * copyright and a copy of this license (for reference) are retained * in all distributed copies. * * For commercial use of this software, contact the authors. * * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR * MODIFICATIONS. * * Copyright (c) 2005 Moteiv Corporation * All rights reserved. * * This file is distributed under the terms in the attached MOTEIV-LICENSE * file. If you do not find these files, copies can be found at * http://www.moteiv.com/MOTEIV-LICENSE.txt and by emailing in...@mo.... * * Modified September 11, 2004 by Rob Szewczyk <in...@mo...> * to display readings from the contrib/moteiv/apps/PressureTest application */ //============================================================================== //=== DataCollect.java ============================================== package net.sf.firebug.DataCollection; import net.tinyos.message.MessageListener; import net.tinyos.message.*; import java.util.*; /** * * Init the serial port and reads data from it. * * @author <A HREF="http://www.cs.berkeley.edu/~mikechen/">Mike Chen</A> * (<A HREF="mailto:mik...@cs...">mik...@cs...</A>) * @since 1.1.6 * * modified by bwhull to work with the serialforwarder */ public class DataCollect implements MessageListener, Runnable { //========================================================================= //=== CONSTANTS ======================================================= private static int MSG_SIZE = 36; // 4 header bytes, 30 msg bytes, 2 crc // bytes; 2 strength bytes are not // transmitted //========================================================================= //=== PRIVATE VARIABLES ================================================ String strAddr; int nPort; MoteIF dataCollectStub; MoteIF calibrateStub; List dlist, clist; public static double pressure_mbar(int raw_pressure, int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; if (calibration.length != 4) return 0; c1 = calibration[0] >> 1; c2 = calibration[2] & 0x3F; c2 <<= 6; c2 |= (calibration[3] & 0x3F); c3 = calibration[3] >> 6; c4 = calibration[2] >> 6; c5 = calibration[0] << 10; c5 &= 0x400; c5 += calibration[1] >> 6; c6 = calibration[1] & 0x3F; int ut1 = 8*c5+20224; int dt = raw_temperature - ut1; double temp = 200 + dt*(c6+50)/(Math.pow(2,10)); double off = c2*4 + ((c4-512)*dt)/(Math.pow(2,12)); double sens = c1 + (c3*dt)/(Math.pow(2,10)) + 24576; double x = (sens * (raw_pressure - 7168))/ (Math.pow(2,14)) - off; double p = x*100/(Math.pow(2,5)) + 250*100; //System.out.println("Press (mbar) : " + p/100); //System.out.println("Press (inHg) : " + p/(100*33.864)); return (p/100); } public static double pressure_inHg(int raw_pressure, int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; if (calibration.length != 4) return 0; c1 = calibration[0] >> 1; c2 = calibration[2] & 0x3F; c2 <<= 6; c2 |= (calibration[3] & 0x3F); c3 = calibration[3] >> 6; c4 = calibration[2] >> 6; c5 = calibration[0] << 10; c5 &= 0x400; c5 += calibration[1] >> 6; c6 = calibration[1] & 0x3F; int ut1 = 8*c5+20224; int dt = raw_temperature - ut1; double off = c2*4 + ((c4-512)*dt)/(Math.pow(2,12)); double sens = c1 + (c3*dt)/(Math.pow(2,10)) + 24576; double x = (sens * (raw_pressure - 7168))/ (Math.pow(2,14)) - off; double p = x*100/(Math.pow(2,5)) + 250*100; return (p/(100*33.864)); } public static double pressure_temp(int raw_temperature, int[] calibration) { int c1,c2,c3,c4,c5,c6; if (calibration.length != 4) return 0; c1 = calibration[0] >> 1; c2 = calibration[2] & 0x3F; c2 <<= 6; c2 |= (calibration[3] & 0x3F); c3 = calibration[3] >> 6; c4 = calibration[2] >> 6; c5 = calibration[0] << 10; c5 &= 0x400; c5 += calibration[1] >> 6; c6 = calibration[1] & 0x3F; int ut1 = 8*c5+20224; int dt = raw_temperature - ut1; double temp = 200 + dt*(c6+50)/(Math.pow(2,10)); return (temp/10); } public DataCollect() { this.dataCollectStub = null; try { this.dataCollectStub = new MoteIF(); dataCollectStub.registerListener(new DataCollectionMsg(), this); dataCollectStub.start(); } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use Options | File Templates. System.exit(1); } try { this.calibrateStub = new MoteIF(); calibrateStub.registerListener(new CalibrationMsg(), this); calibrateStub.start(); } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use Options | File Templates. System.exit(1); } } public void packetReceived(byte[] packet) { } public static void main(String args[]) { DataCollect reader = new DataCollect(); Thread th = new Thread(reader); th.start(); } public void run() { while (true) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } } public void messageReceived(int to, Message m) { int index=0; if (m.amType() == DataCollectionMsg.AM_TYPE) { DataCollectionMsg msg = new DataCollectionMsg(m,0); if(get_data(msg.get_seq_no(), (long)msg.get_src()) == 0) { /* Not a duplicate */ if((index = get_calibration(msg.get_seq_no(), (long)msg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ dlist.add(msg); } else { dlist.add(msg); printData(index, get_data(msg.get_seq_no(), (long)msg.get_src())); } } } else if(m.amType() == CalibrationMsg.AM_TYPE) { CalibrationMsg cMsg = new CalibrationMsg(m,0); if(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()) == 0) { /* Not a duplicate */ if((index = get_data(cMsg.get_seq_no(), (long)cMsg.get_src())) == 0) { /* No calibration data received yet. So, add to the list */ clist.add(cMsg); } else { clist.add(cMsg); printData(get_calibration(cMsg.get_seq_no(), (long)cMsg.get_src()), index); } } } } void printData(int cindex, int dindex) { DataCollectionMsg dMsg = (DataCollectionMsg) dlist.get(dindex); CalibrationMsg cMsg = (CalibrationMsg) clist.get(cindex); System.out.println("--reading--"); System.out.println("Source : "+ dMsg.get_src()); System.out.println("Sequence Number: "+ dMsg.get_seq_no()); System.out.println("Raw temperature: "+ dMsg.get_temperature()); System.out.println("Raw humidity : "+ dMsg.get_humidity()); System.out.println("Raw voltage : "+ dMsg.get_ivolt()); System.out.println("Temperature : "+pressure_temp(dMsg.get_temperature(), cMsg.get_calibration())); System.out.println("Pressure : "+pressure_mbar(dMsg.get_pressure(), dMsg.get_temperature(), cMsg.get_calibration())); /* Delete the printed data */ dlist.remove(dindex); clist.remove(cindex); System.out.println("\n\nSize of dlist:"+dlist.size() +" and clist:"+clist.size()+" \n\n"); } private int get_data(long seqno, long src) { boolean found=false; ListIterator it=dlist.listIterator(); int index=0; while(it.hasNext()) { DataCollectionMsg msg = (DataCollectionMsg) it.next(); if(msg.get_seq_no() == seqno && msg.get_src() == src) { found=true; break; } else { index++; } } if(!found) { index=0; } return index; } private int get_calibration(long seqno, long src) { boolean found=false; ListIterator it=clist.listIterator(); int index=0; while(it.hasNext()) { CalibrationMsg msg = (CalibrationMsg) it.next(); if(msg.get_seq_no() == seqno && msg.get_src() == src) { found=true; break; } else { index++; } } if(!found) { index=0; } return index; } } --- NEW FILE: Makefile --- TOS = $(shell ncc -print-tosdir) PACKAGE = net.sf.firebug.DataCollection APP=$(FWROOT)/beta/fireworks/apps/DataCollection MIG = mig java # List of message classes to build MSGS = DataCollectionMsg.java CalibrationMsg.java INITIAL_TARGETS = $(MSGS) OTHER_CLEAN = cleanmig ROOT = $(TOS)/../contrib/moteiv/tools/java include $(ROOT)/Makefile.include DataCollectionMsg.java: $(MIG) -java-classname=$(PACKAGE).DataCollectionMsg $(APP)/DataCollection.h DataCollectionMsg >$@ CalibrationMsg.java: $(MIG) -java-classname=$(PACKAGE).CalibrationMsg $(APP)/Calibration.h CalibrationMsg >$@ cleanmig: rm -f $(MSGS) |
From: Karthik D. <da...@us...> - 2005-08-28 09:18:20
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9463/DataCollection Log Message: Directory /cvsroot/firebug/fireboard/beta/fireworks/tools/java/net/sf/firebug/DataCollection added to the repository |
From: Karthik D. <da...@us...> - 2005-08-28 09:17:35
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9349 Added Files: Makefile README Surge.h Surge.nc SurgeCmd.h SurgeM.nc Log Message: Data Collection app for Tmote sky --- NEW FILE: SurgeM.nc --- // $Id: SurgeM.nc,v 1.1 2005/08/28 09:17:26 dantu Exp $ /* tab:4 * "Copyright (c) 2000-2003 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." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, * 94704. Attention: Intel License Inquiry. */ includes Surge; includes SurgeCmd; /* * Data gather application */ module SurgeM { provides { interface StdControl; } uses { // interface ADC; interface SplitControl as HumidityControl; interface SplitControl as PressureControl; interface ADC as Humidity; interface ADC as Temperature; interface ADC as TSR; interface ADC as PAR; interface ADC as InternalTemperature; interface ADC as InternalVoltage; interface ADC as Pressure; interface ADCError as HumidityError; interface ADCError as TemperatureError; interface Calibration as PressureCalibration; interface Timer; interface Leds; interface CC2420Control; interface MacControl; interface Send; interface RouteControl; interface Random; } } implementation { enum { HUMIDITY, TEMPERATURE, TSRSENSOR, PARSENSOR, ITEMP, IVOLT, PRESSURE, SEND }; norace uint16_t humidity, temperature, tsr, par, itemp, ivolt, pressure; norace int state; enum { TIMER_GETADC_COUNT = 1, // Timer ticks for ADC TIMER_CHIRP_COUNT = 10, // Timer on/off chirp count }; bool sleeping; // application command state bool focused; bool rebroadcast_adc_packet; TOS_Msg gMsgBuffer; norace uint16_t gSensorData; // protected by gfSendBusy flag uint32_t seqno; bool initTimer; bool gfSendBusy; int timer_rate; int timer_ticks; /*********************************************************************** * Initialization ***********************************************************************/ static void initialize() { timer_rate = INITIAL_TIMER_RATE; atomic gfSendBusy = FALSE; sleeping = FALSE; seqno = 0; initTimer = TRUE; rebroadcast_adc_packet = FALSE; focused = FALSE; // Sensor initialization state = HUMIDITY; } task void SendData() { SurgeMsg *pReading; uint16_t Len; dbg(DBG_USR1, "SurgeM: Sending sensor reading\n"); if ((pReading = (SurgeMsg *)call Send.getBuffer(&gMsgBuffer,&Len)) != NULL) { pReading->type = SURGE_TYPE_SENSORREADING; pReading->parentaddr = call RouteControl.getParent(); pReading->humidity = humidity; pReading->temperature = temperature; pReading->itemp = itemp; pReading->ivolt = ivolt; pReading->pressure = pressure; pReading->seq_no = seqno++; #ifdef MHOP_LEDS call Leds.redOn(); #endif if ((call Send.send(&gMsgBuffer,sizeof(SurgeMsg))) != SUCCESS) atomic gfSendBusy = FALSE; } } command result_t StdControl.init() { initialize(); call HumidityControl.init(); call PressureControl.init(); return SUCCESS; } event result_t HumidityControl.initDone() { return SUCCESS; } event result_t PressureControl.initDone() { return SUCCESS; } command result_t StdControl.start() { uint16_t randomtimer; call CC2420Control.SetRFPower(15); call MacControl.enableAck(); randomtimer = (call Random.rand() & 0xfff) + 1; call HumidityControl.start(); call PressureControl.start(); return call Timer.start(TIMER_ONE_SHOT, randomtimer); } event result_t HumidityControl.startDone() { call HumidityError.enable(); call TemperatureError.enable(); call Timer.start( TIMER_ONE_SHOT, 250 ); return SUCCESS; } event result_t PressureControl.startDone() { call Timer.start( TIMER_REPEAT, 2048 ); return SUCCESS; } command result_t StdControl.stop() { call HumidityControl.stop(); call PressureControl.stop(); return call Timer.stop(); } event result_t HumidityControl.stopDone() { call HumidityError.disable(); call TemperatureError.disable(); return SUCCESS; } event result_t PressureControl.stopDone() { return SUCCESS; } event result_t PressureCalibration.dataReady(char word, uint16_t value) { atomic pressure = value; call Temperature.getData(); return SUCCESS; } /*********************************************************************** * Commands and events ***********************************************************************/ event result_t Timer.fired() { // set a timeout in case a task post fails (rare) call Timer.start(TIMER_ONE_SHOT, 100); switch(state) { case HUMIDITY: call Humidity.getData(); break; case TEMPERATURE: call Temperature.getData(); break; case TSRSENSOR: call TSR.getData(); break; case PARSENSOR: call PAR.getData(); break; case ITEMP: call InternalTemperature.getData(); break; case IVOLT: call InternalVoltage.getData(); break; case PRESSURE: call PressureCalibration.getData(); break; case SEND: post SendData(); break; default: call Timer.start(TIMER_ONE_SHOT, 10); } return SUCCESS; } async event result_t Humidity.dataReady(uint16_t data) { humidity = data; call Timer.start(TIMER_ONE_SHOT, 10); state = TEMPERATURE; return SUCCESS; } event result_t HumidityError.error(uint8_t token) { humidity = 0; call Timer.start(TIMER_ONE_SHOT, 10); state = TEMPERATURE; return SUCCESS; } async event result_t Temperature.dataReady(uint16_t data) { temperature = data; call Timer.start(TIMER_ONE_SHOT, 10); state = TSRSENSOR; return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { temperature = 0; call Timer.start(TIMER_ONE_SHOT, 10); state = TSRSENSOR; return SUCCESS; } async event result_t TSR.dataReady(uint16_t data) { tsr = data; call Timer.start(TIMER_ONE_SHOT, 10); state = PARSENSOR; return SUCCESS; } async event result_t PAR.dataReady(uint16_t data) { par = data; call Timer.start(TIMER_ONE_SHOT, 10); state = ITEMP; return SUCCESS; } async event result_t InternalTemperature.dataReady(uint16_t data) { itemp = data; call Timer.start(TIMER_ONE_SHOT, 10); state = IVOLT; return SUCCESS; } async event result_t InternalVoltage.dataReady(uint16_t data) { ivolt = data; call Timer.start(TIMER_ONE_SHOT, 10); state = PRESSURE; return SUCCESS; } async event result_t Pressure.dataReady(uint16_t reading) { atomic pressure = reading; call Timer.start(TIMER_ONE_SHOT, 10); state = SEND; return SUCCESS; } event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { dbg(DBG_USR2, "SurgeM: output complete 0x%x\n", success); #ifdef MHOP_LEDS call Leds.redOff(); #endif atomic gfSendBusy = FALSE; return SUCCESS; } } --- NEW FILE: Makefile --- PFLAGS= -I%T/lib/MultiHopLQI -I%T/../contrib/moteiv/tos/sensorboards/pressure -DSEND_QUEUE_SIZE=8 -DMHOP_LEDS # -I%T/platform/msp430 -I%T/platform/telos PLATFORMS=telos telosa telosb tmote TINYOS_NP ?= BNP COMPONENT=Surge include ${MAKERULES} --- NEW FILE: Surge.nc --- // $Id: Surge.nc,v 1.1 2005/08/28 09:17:26 dantu Exp $ /* tab:4 * "Copyright (c) 2000-2003 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." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, * 94704. Attention: Intel License Inquiry. */ /** * **/ includes Surge; includes SurgeCmd; includes MultiHop; configuration Surge { } implementation { components Main, SurgeM , TimerC , LedsC , DelugeC // , NoLeds // , DemoSensorC as Sensor , RandomLFSR , GenericComm as Comm // , Bcast , CC2420RadioC , LQIMultiHopRouter as multihopM // , QueuedSend; , HumidityC , HamamatsuC , InternalTempC , InternalVoltageC , IntersemaPressure ; Main.StdControl -> DelugeC; Main.StdControl -> TimerC; Main.StdControl -> Comm; // Main.StdControl -> Bcast.StdControl; Main.StdControl -> HamamatsuC; Main.StdControl -> InternalTempC; Main.StdControl -> InternalVoltageC; Main.StdControl -> multihopM.StdControl; // Main.StdControl -> QueuedSend.StdControl; Main.StdControl -> SurgeM.StdControl; SurgeM.Timer -> TimerC.Timer[unique("Timer")]; SurgeM.Leds -> LedsC; // NoLeds; SurgeM.Random -> RandomLFSR; // SurgeM.Bcast -> Bcast.Receive[AM_SURGECMDMSG]; // Bcast.ReceiveMsg[AM_SURGECMDMSG] -> Comm.ReceiveMsg[AM_SURGECMDMSG]; SurgeM.CC2420Control -> CC2420RadioC.CC2420Control; SurgeM.MacControl -> CC2420RadioC.MacControl; //Sensors SurgeM.HumidityControl -> HumidityC; SurgeM.Humidity -> HumidityC.Humidity; SurgeM.Temperature -> HumidityC.Temperature; SurgeM.TSR -> HamamatsuC.TSR; SurgeM.PAR -> HamamatsuC.PAR; SurgeM.InternalTemperature -> InternalTempC; SurgeM.InternalVoltage -> InternalVoltageC; SurgeM.PressureControl -> IntersemaPressure; SurgeM.Pressure -> IntersemaPressure.Pressure; SurgeM.PressureCalibration -> IntersemaPressure.Calibration; SurgeM.TemperatureError -> HumidityC.TemperatureError; SurgeM.HumidityError -> HumidityC.HumidityError; SurgeM.RouteControl -> multihopM; SurgeM.Send -> multihopM.Send[AM_SURGEMSG]; multihopM.ReceiveMsg[AM_SURGEMSG] -> Comm.ReceiveMsg[AM_SURGEMSG]; //multihopM.ReceiveMsg[AM_MULTIHOPMSG] -> Comm.ReceiveMsg[AM_MULTIHOPMSG]; } --- NEW FILE: SurgeCmd.h --- // $Id: SurgeCmd.h,v 1.1 2005/08/28 09:17:26 dantu Exp $ /* tab:4 * "Copyright (c) 2000-2003 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." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, * 94704. Attention: Intel License Inquiry. */ typedef struct SurgeCmdMsg { uint16_t type; union { // FOR SURGE_TYPE_SETRATE uint32_t newrate; // FOR SURGE_TYPE_FOCUS uint16_t focusaddr; } args; } SurgeCmdMsg; enum { AM_SURGECMDMSG = 18 }; --- NEW FILE: README --- README for Surge Author/Contact: tin...@mi... $Revision: 1.1 $ Description: Surge is an example application that uses MultiHop ad-hoc routing. It is designed to be used in conjunction with the Surge java tool. Each Surge node takes temperature readings and forwards them to a base station. The node can also respond to broadcast commands from the base. This version of surge in contrib/ucb/SurgeTelos only supports (and has been tested on) the Telos platform. Please do not try to run this version of Surge on any other platform. Other platforms may use Surge in tinyos-1.x/apps/Surge Tools: net.tinyos.surge.MainClass This class processes sensor data from Surge programmed nodes via a GenericBase station. The java applet snoops the multihop headers to provide a graphical view of the logical network topology. It also permits variation of the sample rates and sending pre-defined commands to the surge nodes. In tinyos-1.x/tools/java/net/tinyos/surge, you must recompile the java classes based on this version of Surge: cd $TOSDIR/../tools/java/net/tinyos/surge make clean SURGE_PLATFORM=telos make This creates classes from Surge.h and SurgeCmd.h in contrib/ucb/apps/Surge and Multihop.h from contrib/ucb/tos/lib/MultiHopLQI. Now you can run Surge with java net.tinyos.surge.MainClass 0x7D Make sure SerialForwarder is connected to Telos before running the Surge java GUI. --- NEW FILE: Surge.h --- // $Id: Surge.h,v 1.1 2005/08/28 09:17:26 dantu Exp $ /* tab:4 * "Copyright (c) 2000-2003 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." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, * 94704. Attention: Intel License Inquiry. */ int INITIAL_TIMER_RATE = 2048; int FOCUS_TIMER_RATE = 1000; int FOCUS_NOTME_TIMER_RATE = 1000; enum { SURGE_TYPE_SENSORREADING = 0, SURGE_TYPE_ROOTBEACON = 1, SURGE_TYPE_SETRATE = 2, SURGE_TYPE_SLEEP = 3, SURGE_TYPE_WAKEUP = 4, SURGE_TYPE_FOCUS = 5, SURGE_TYPE_UNFOCUS = 6 }; typedef struct SurgeMsg { uint16_t type; uint16_t humidity; uint16_t temperature; // uint16_t tsr; // uint16_t par; uint16_t itemp; uint16_t ivolt; uint16_t pressure; uint16_t parentaddr; uint32_t seq_no; } SurgeMsg; enum { AM_SURGEMSG = 17 }; |
From: Karthik D. <da...@us...> - 2005-08-28 07:45:20
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26655/DataCollection Log Message: Directory /cvsroot/firebug/fireboard/beta/fireworks/apps/DataCollection added to the repository |
From: Karthik D. <da...@us...> - 2005-08-25 03:14:20
|
Update of /cvsroot/firebug/fireboard/beta/fireworks/apps/MultihopLinkEstimator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23641 Modified Files: MultihopLinkEstimatorM.nc Log Message: only 0 will send pings now Index: MultihopLinkEstimatorM.nc =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/fireworks/apps/MultihopLinkEstimator/MultihopLinkEstimatorM.nc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MultihopLinkEstimatorM.nc 9 Aug 2005 00:07:53 -0000 1.4 --- MultihopLinkEstimatorM.nc 25 Aug 2005 03:14:11 -0000 1.5 *************** *** 166,169 **** --- 166,170 ---- call Leds.yellowOn(); #endif + linkMsg->seqno = ++leseqno; linkMsg->source = lesource; linkMsg->dest = TOS_LOCAL_ADDRESS; *************** *** 220,236 **** event result_t LinkTimer.fired() { - uint16_t rtimer; #ifdef LE_LEDS ! call Leds.greenToggle(); #endif ! /* Choose a random number between (1-4096)ms and add it to 10000. ! Basically, choose a random number between ! 10000-14096*/ ! rtimer = (call Random.rand() & 0x1fff) + 0x2710; ! call LinkTimer.start(TIMER_ONE_SHOT, rtimer); ! post sendPing(); return SUCCESS; } --- 221,240 ---- event result_t LinkTimer.fired() { + if(TOS_LOCAL_ADDRESS == 0) { + uint16_t rtimer; + #ifdef LE_LEDS ! call Leds.greenToggle(); #endif ! /* Choose a random number between (1-4096)ms and add it to 10000. ! Basically, choose a random number between ! 10000-14096*/ ! rtimer = (call Random.rand() & 0x1fff) + 0x2710; ! call LinkTimer.start(TIMER_ONE_SHOT, rtimer); ! post sendPing(); ! } return SUCCESS; } *************** *** 256,262 **** /* Build the LinkEstimatorMsg */ atomic { - LinkEstimatorMsg *le = (LinkEstimatorMsg *) &(leMsg.data); - - le->seqno = ++leseqno; lesource = pingMsg->source; lerssi = m->strength; --- 260,263 ---- |
From: David M. D. <do...@us...> - 2005-08-19 20:18:04
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten/ucb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27795/ucb Log Message: Directory /cvsroot/firebug/fireboard/beta/tools/src/xlisten/ucb added to the repository |