[Firebug-cvs] mts400/sensors/gps GpsPacket.nc,1.2,1.3 gps.h,1.1,1.2 SensirionHumidity.nc,1.1,NONE Se
Brought to you by:
doolin
Update of /cvsroot/firebug/mts400/sensors/gps In directory sc8-pr-cvs1:/tmp/cvs-serv25577/sensors/gps Modified Files: GpsPacket.nc gps.h Removed Files: SensirionHumidity.nc SensirionHumidityM.nc TempHum.nc TempHumM.nc Log Message: GPS sensor now runs by itself independently of the humidity sensor. Not sure if it is running correctly yet. Will need to compare output with GGA spec. Index: GpsPacket.nc =================================================================== RCS file: /cvsroot/firebug/mts400/sensors/gps/GpsPacket.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GpsPacket.nc 12 Nov 2003 00:11:47 -0000 1.2 --- GpsPacket.nc 12 Nov 2003 01:44:20 -0000 1.3 *************** *** 127,131 **** norace uint8_t state; ! norace uint16_t rxCount, rxLength, txCount, txLength; --- 127,139 ---- norace uint8_t state; ! norace uint16_t rxLength, txCount, txLength; ! ! /** This is only used in ByteComm.rxByteReady(), but ! * apparently needs to maintain its value between ! * successive calls. ! * FIXME: Why isn't rxCount declared static in its ! * function? Remove if possible. ! */ ! uint16_t rxCount; *************** *** 162,166 **** state_gps_pkt = NO_GPS_START_BYTE; state = IDLE; ! txCount = rxCount = 0; rxLength = GPS_DATA_LENGTH; return call ByteControl.init(); --- 170,175 ---- state_gps_pkt = NO_GPS_START_BYTE; state = IDLE; ! txCount = 0; ! rxCount = 0; rxLength = GPS_DATA_LENGTH; return call ByteControl.init(); *************** *** 199,318 **** } } ! return FAIL; } /* Command to transmit a packet */ ! command result_t Send.send(TOS_MsgPtr msg) { ! state = PACKET; ! msg->crc = 1; /* Fake out the CRC as passed. */ ! return call txBytes((uint8_t *)msg, TOS_MsgLength(msg->type)); ! } /* Command to transfer a variable length packet */ ! command result_t SendVarLenPacket.send(uint8_t* packet, uint8_t numBytes) { ! state = BYTES; ! return call txBytes(packet, numBytes); ! } ! task void sendDoneFailTask() { ! txCount = 0; ! state = IDLE; ! signal Send.sendDone((TOS_MsgPtr)sendPtr, FAIL); ! } - task void sendDoneSuccessTask() { ! txCount = 0; ! state = IDLE; ! signal Send.sendDone((TOS_MsgPtr)sendPtr, SUCCESS); ! } ! task void sendVarLenFailTask() { ! txCount = 0; ! state = IDLE; ! signal SendVarLenPacket.sendDone((uint8_t*)sendPtr, FAIL); ! } ! task void sendVarLenSuccessTask() { ! txCount = 0; ! state = IDLE; ! signal SendVarLenPacket.sendDone((uint8_t*)sendPtr, SUCCESS); ! } - void sendComplete(result_t success) { ! if (state == PACKET) { ! TOS_MsgPtr msg = (TOS_MsgPtr)sendPtr; /* This is a non-ack based layer */ ! if (success) { ! msg->ack = TRUE; ! post sendDoneSuccessTask(); ! } else { ! post sendDoneFailTask(); ! } ! } ! else if (state == BYTES) { ! if (success) { ! post sendVarLenSuccessTask(); ! } ! else { ! post sendVarLenFailTask(); } ! } ! else { ! txCount = 0; ! state = IDLE; ! } ! } ! default event result_t SendVarLenPacket.sendDone(uint8_t* packet, result_t success) { ! return success; ! } ! default event result_t Send.sendDone(TOS_MsgPtr msg, result_t success){ ! return success; ! } /* Byte level component signals it is ready to accept the next byte. Send the next byte if there are data pending to be sent */ ! async event result_t ByteComm.txByteReady(bool success) { - if (txCount > 0) - { - if (!success) - { dbg(DBG_ERROR, "TX_packet failed, TX_byte_failed"); sendComplete(FAIL); ! } ! else if (txCount < txLength) ! { dbg(DBG_PACKET, "PACKET: byte sent: %x, COUNT: %d\n", sendPtr[txCount], txCount); ! if (!call ByteComm.txByte(sendPtr[txCount++])) sendComplete(FAIL); ! } } ! return SUCCESS; ! } ! async event result_t ByteComm.txDone() { ! if (txCount == txLength) ! sendComplete(TRUE); ! return SUCCESS; ! } --- 208,328 ---- } } ! return FAIL; } /* Command to transmit a packet */ ! command result_t Send.send(TOS_MsgPtr msg) { ! state = PACKET; ! msg->crc = 1; /* Fake out the CRC as passed. */ ! return call txBytes((uint8_t *)msg, TOS_MsgLength(msg->type)); ! } /* Command to transfer a variable length packet */ ! command result_t SendVarLenPacket.send(uint8_t* packet, uint8_t numBytes) { ! state = BYTES; ! return call txBytes(packet, numBytes); ! } ! task void sendDoneFailTask() { ! txCount = 0; ! state = IDLE; ! signal Send.sendDone((TOS_MsgPtr)sendPtr, FAIL); ! } ! task void sendDoneSuccessTask() { ! txCount = 0; ! state = IDLE; ! signal Send.sendDone((TOS_MsgPtr)sendPtr, SUCCESS); ! } ! task void sendVarLenFailTask() { ! txCount = 0; ! state = IDLE; ! signal SendVarLenPacket.sendDone((uint8_t*)sendPtr, FAIL); ! } ! ! task void sendVarLenSuccessTask() { ! ! txCount = 0; ! state = IDLE; ! signal SendVarLenPacket.sendDone((uint8_t*)sendPtr, SUCCESS); ! } ! void sendComplete(result_t success) { ! if (state == PACKET) { ! ! TOS_MsgPtr msg = (TOS_MsgPtr)sendPtr; /* This is a non-ack based layer */ ! if (success) { ! msg->ack = TRUE; ! post sendDoneSuccessTask(); ! } else { ! post sendDoneFailTask(); ! } ! } else if (state == BYTES) { ! if (success) { ! post sendVarLenSuccessTask(); ! } else { ! post sendVarLenFailTask(); ! } ! } else { ! txCount = 0; ! state = IDLE; } ! } ! default event result_t SendVarLenPacket.sendDone(uint8_t* packet, result_t success) { ! return success; ! } ! default event result_t Send.sendDone(TOS_MsgPtr msg, result_t success){ ! return success; ! } /* Byte level component signals it is ready to accept the next byte. Send the next byte if there are data pending to be sent */ ! async event result_t ByteComm.txByteReady(bool success) { ! ! if (txCount > 0) { ! ! if (!success) { dbg(DBG_ERROR, "TX_packet failed, TX_byte_failed"); sendComplete(FAIL); ! } else if (txCount < txLength) { ! dbg(DBG_PACKET, "PACKET: byte sent: %x, COUNT: %d\n", sendPtr[txCount], txCount); ! if (!call ByteComm.txByte(sendPtr[txCount++])) { sendComplete(FAIL); ! } ! } } ! return SUCCESS; ! } ! async event result_t ByteComm.txDone() { ! if (txCount == txLength) { ! sendComplete(TRUE); ! } ! return SUCCESS; ! } *************** *** 324,328 **** /** FIXME: tmp is unused. */ ! TOS_Msg* tmp = signal Receive.receive(bufferPtr); state_gps_pkt = NO_GPS_START_BYTE; } --- 334,338 ---- /** FIXME: tmp is unused. */ ! TOS_Msg * tmp = signal Receive.receive(bufferPtr); state_gps_pkt = NO_GPS_START_BYTE; } *************** *** 331,341 **** * Byte received from GPS * First byte in gps packet is reserved to count number of bytes rcvd. ! * Gps messages start with '$' (0x24) and end with <cr><lf> (0x0D, 0x0A) */ async event result_t ByteComm.rxByteReady(uint8_t data, bool error, ! uint16_t strength) { ! //SODbg(DBG_USR2, "PACKET: byte arrived: %x, COUNT: %i\n", data, rxCount); if (error) { --- 341,354 ---- * Byte received from GPS * First byte in gps packet is reserved to count number of bytes rcvd. ! * Gps messages start with '$' (0x24) and end with <cr><lf> (0x0D, 0x0A), ! * which are defined in the header file. */ async event result_t ByteComm.rxByteReady(uint8_t data, bool error, ! uint16_t strength) { + //SODbg(DBG_USR2, "PACKET: byte arrived: %x, COUNT: %i\n", data, rxCount); ! //FIXME: See if this works, remove global if possible. ! //static uint16_t rxCount = 0; if (error) { *************** *** 358,362 **** recPtr[rxCount++] = data; recPtr[0] = rxCount; ! if (rxCount == GPS_DATA_LENGTH ) { --- 371,376 ---- recPtr[rxCount++] = data; recPtr[0] = rxCount; ! ! /** Hopefully, rxCount won't ever exceed GPS_DATA_LENGTH */ if (rxCount == GPS_DATA_LENGTH ) { *************** *** 374,378 **** // bufferIndex = bufferIndex ^ 1; ! // recPtr = (uint8_t*)bufferPtr; ping pong buffers !!!!!!!!!!!!!!!!!! // SODbg(DBG_USR2, "got gps packet; # of bytes = %i \n", rxCount); // rxCount = 0; --- 388,392 ---- // bufferIndex = bufferIndex ^ 1; ! // recPtr = (uint8_t*)bufferPtr; ping pong buffers !!!!!!!!!!!!!!!!!! // SODbg(DBG_USR2, "got gps packet; # of bytes = %i \n", rxCount); // rxCount = 0; *************** *** 417,421 **** event result_t PowerSwitch.setDone(bool local_result) { - if (state_gps == GPS_PWR_SWITCH_WAIT) { if (call PowerSwitch.set(MICAWB_GPS_ENABLE ,power_gps) == SUCCESS) { --- 431,434 ---- *************** *** 432,436 **** event result_t PowerSwitch.getDone(char value) { ! return SUCCESS; } --- 445,449 ---- event result_t PowerSwitch.getDone(char value) { ! return SUCCESS; } *************** *** 439,454 **** event result_t IOSwitch.setDone(bool local_result) { ! if (state_gps == GPS_TX_SWITCH_WAIT) { ! if (call IOSwitch.set( MICAWB_GPS_RX_SELECT ,power_gps) == SUCCESS) { ! state_gps = GPS_RX_SWITCH_WAIT; ! } ! } ! else if (state_gps == GPS_RX_SWITCH_WAIT) { ! SODbg(DBG_USR2, "GpsPacket: all switches set \n"); ! state_gps = GPS_SWITCH_IDLE; ! signal GpsCmd.SwitchesSet(state_gps); ! } ! return SUCCESS; } --- 452,466 ---- event result_t IOSwitch.setDone(bool local_result) { ! if (state_gps == GPS_TX_SWITCH_WAIT) { ! if (call IOSwitch.set( MICAWB_GPS_RX_SELECT ,power_gps) == SUCCESS) { ! state_gps = GPS_RX_SWITCH_WAIT; ! } ! } else if (state_gps == GPS_RX_SWITCH_WAIT) { ! SODbg(DBG_USR2, "GpsPacket: all switches set \n"); ! state_gps = GPS_SWITCH_IDLE; ! signal GpsCmd.SwitchesSet(state_gps); ! } ! return SUCCESS; } Index: gps.h =================================================================== RCS file: /cvsroot/firebug/mts400/sensors/gps/gps.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gps.h 11 Nov 2003 01:59:40 -0000 1.1 --- gps.h 12 Nov 2003 01:44:20 -0000 1.2 *************** *** 69,74 **** #define GPS_DATA_LENGTH 128 #define GPS_PACKET_START 0x24 //start of gps packet ! #define GPS_PACKET_END1 0x0D //end if gps packet ! #define GPS_PACKET_END2 0x0A //end of gps packet // This isn't used yet, but should be. #define GPS_POWER_OFF 0 --- 69,74 ---- #define GPS_DATA_LENGTH 128 #define GPS_PACKET_START 0x24 //start of gps packet ! #define GPS_PACKET_END1 0x0D //penultimate byte of gps packet ! #define GPS_PACKET_END2 0x0A //last byte of gps packet // This isn't used yet, but should be. #define GPS_POWER_OFF 0 --- SensirionHumidity.nc DELETED --- --- SensirionHumidityM.nc DELETED --- --- TempHum.nc DELETED --- --- TempHumM.nc DELETED --- |