[Tinyos-commits] CVS: tinyos-1.x/tos/lib/Deluge DelugeM.nc, 1.55,
1.56
Jonathan Hui
jwhui at users.sourceforge.net
Wed Aug 17 19:28:11 PDT 2005
Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/Deluge
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6192
Modified Files:
DelugeM.nc
Log Message:
- Check crc's before sending adv msg.
Index: DelugeM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/Deluge/DelugeM.nc,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** DelugeM.nc 18 Aug 2005 01:55:31 -0000 1.55
--- DelugeM.nc 18 Aug 2005 02:28:09 -0000 1.56
***************
*** 196,199 ****
--- 196,204 ----
}
+ bool isNodeDescValid(DelugeNodeDesc* tmpNodeDesc) {
+ return ( tmpNodeDesc->crc == call Crc.crc16(tmpNodeDesc, 8)
+ || tmpNodeDesc->vNum == DELUGE_INVALID_VNUM );
+ }
+
void sendAdvMsg(int imgNum, uint16_t addr) {
***************
*** 206,211 ****
--- 211,229 ----
pMsg->version = DELUGE_VERSION;
pMsg->type = (imagesLoaded) ? DELUGE_ADV_NORMAL : DELUGE_ADV_ERROR;
+
+ // make sure node desc is valid
memcpy(&pMsg->nodeDesc, &nodeDesc, sizeof(DelugeNodeDesc));
+ if ( !isNodeDescValid( &pMsg->nodeDesc ) )
+ memset( &nodeDesc, 0xff, sizeof( nodeDesc ) );
+
+ // make sure img desc is valid
memcpy(&pMsg->imgDesc, imgDesc, sizeof(DelugeImgDesc));
+ if ( !call Metadata.isImgDescValid( &pMsg->imgDesc ) ) {
+ imgDesc->vNum = DELUGE_INVALID_VNUM;
+ imgDesc->imgNum = imgNum;
+ imgDesc->numPgs = 0;
+ imgDesc->numPgsComplete = 0;
+ }
+
pMsg->numImages = DELUGE_NUM_IMAGES;
if (call SendAdvMsg.send(addr, sizeof(DelugeAdvMsg), pMsgBuf) == SUCCESS) {
***************
*** 253,261 ****
}
- bool isNodeDescValid(DelugeNodeDesc* tmpNodeDesc) {
- return ( tmpNodeDesc->crc == call Crc.crc16(tmpNodeDesc, 8)
- || tmpNodeDesc->vNum == DELUGE_INVALID_VNUM );
- }
-
event TOS_MsgPtr ReceiveAdvMsg.receive(TOS_MsgPtr pMsg) {
--- 271,274 ----
More information about the Tinyos-commits
mailing list