[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/Deluge
NetProgMsgs.h, NONE, 1.1 NetProg.h, 1.2, 1.3 NetProgC.nc, 1.3,
1.4 NetProgM.nc, 1.4, 1.5
Jonathan Hui
jwhui at users.sourceforge.net
Tue Mar 15 11:54:15 PST 2005
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/STM25P/STM25P
StorageManagerM.nc, 1.3, 1.4
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/delugetools
Deluge.java, 1.7, 1.8 Makefile, 1.14, 1.15 Pinger.java, 1.3,
1.4 Rebooter.java, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3885
Modified Files:
NetProg.h NetProgC.nc NetProgM.nc
Added Files:
NetProgMsgs.h
Log Message:
- Added support to grab Ident info of currently executing image.
--- NEW FILE: NetProgMsgs.h ---
#ifndef __NETPROG_MSGS_H__
#define __NETPROG_MSGS_H__
enum {
AM_NETPROGMSG = 164,
};
typedef struct NetProgMsg {
uint16_t sourceAddr;
Ident_t ident;
} NetProgMsg;
#endif
Index: NetProg.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/NetProg.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** NetProg.h 26 Nov 2004 18:59:10 -0000 1.2
--- NetProg.h 15 Mar 2005 19:54:11 -0000 1.3
***************
*** 34,42 ****
#define __NETPROG_H__
! #define IFLASH_LOCALID_ADDR 0x50 // 2 bytes
! #define IFLASH_GROUPID_ADDR 0x52 // 2 bytes
! #define IFLASH_CHECKSUM_ADDR 0x54 // 2 bytes
#define IFLASH_NODE_DESC_ADDR 0x56 // 6 bytes
#define NETPROG_DISABLE_WDT() WDTCTL = WDTPW + WDTHOLD;
#define NETPROG_ACTUAL_REBOOT() WDTCTL = WDT_ARST_1_9; while(1);
--- 34,46 ----
#define __NETPROG_H__
! #define IFLASH_TOS_INFO_ADDR 0x50 // 6 bytes
#define IFLASH_NODE_DESC_ADDR 0x56 // 6 bytes
+ typedef struct NetProg_TOSInfo {
+ uint16_t addr;
+ uint8_t groupId;
+ uint16_t crc;
+ } NetProg_TOSInfo;
+
#define NETPROG_DISABLE_WDT() WDTCTL = WDTPW + WDTHOLD;
#define NETPROG_ACTUAL_REBOOT() WDTCTL = WDT_ARST_1_9; while(1);
Index: NetProgC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/NetProgC.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** NetProgC.nc 26 Nov 2004 22:38:43 -0000 1.3
--- NetProgC.nc 15 Mar 2005 19:54:11 -0000 1.4
***************
*** 30,33 ****
--- 30,34 ----
includes NetProg;
+ includes NetProgMsgs;
includes TOSBoot;
***************
*** 44,48 ****
DelugeMetadataC as Metadata,
DelugeStorageC as Storage,
! NetProgM;
#ifndef PLATFORM_PC
--- 45,52 ----
DelugeMetadataC as Metadata,
DelugeStorageC as Storage,
! GenericComm as Comm,
! Main,
! NetProgM,
! SharedMsgBufM;
#ifndef PLATFORM_PC
***************
*** 52,60 ****
StdControl = NetProgM;
-
NetProg = NetProgM;
!
NetProgM.Metadata -> Metadata.Metadata[unique("DelugeMetadata")];
NetProgM.MetadataControl -> Metadata;
NetProgM.Storage -> Storage;
--- 56,69 ----
StdControl = NetProgM;
NetProg = NetProgM;
!
! Main.StdControl -> Comm;
! Main.StdControl -> SharedMsgBufM;
!
NetProgM.Metadata -> Metadata.Metadata[unique("DelugeMetadata")];
NetProgM.MetadataControl -> Metadata;
+ NetProgM.ReceiveMsg -> Comm.ReceiveMsg[AM_NETPROGMSG];
+ NetProgM.SendMsg -> Comm.SendMsg[AM_NETPROGMSG];
+ NetProgM.SharedMsgBuf -> SharedMsgBufM.SharedMsgBuf[DELUGE_SHARED_MSG_BUF];
NetProgM.Storage -> Storage;
Index: NetProgM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/NetProgM.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** NetProgM.nc 11 Mar 2005 21:46:38 -0000 1.4
--- NetProgM.nc 15 Mar 2005 19:54:11 -0000 1.5
***************
*** 38,41 ****
--- 38,44 ----
interface DelugeStorage as Storage;
interface InternalFlash as IFlash;
+ interface ReceiveMsg;
+ interface SendMsg;
+ interface SharedMsgBuf;
interface SplitControl as MetadataControl;
}
***************
*** 44,75 ****
implementation {
! uint8_t checkSum(uint16_t _addr, uint8_t _group) {
! return ~(_addr + _group);
}
void writeTOSinfo() {
! uint8_t checksum = checkSum(TOS_LOCAL_ADDRESS, TOS_AM_GROUP);
! call IFlash.write((uint8_t*)IFLASH_GROUPID_ADDR, &TOS_AM_GROUP, sizeof(TOS_AM_GROUP));
! call IFlash.write((uint16_t*)IFLASH_LOCALID_ADDR, &TOS_LOCAL_ADDRESS, sizeof(TOS_LOCAL_ADDRESS));
! call IFlash.write((uint8_t*)IFLASH_CHECKSUM_ADDR, &checksum, sizeof(checkSum));
}
command result_t StdControl.init() {
! // grab addr, pid, and gid from internal flash
! uint16_t addr;
! uint32_t curImageAddr;
! uint8_t group, sum;
! result_t result;
! result = call MetadataControl.init();
! call IFlash.read((uint16_t*)TOSBOOT_CUR_IMG_START_ADDR, &curImageAddr, sizeof(curImageAddr));
! call IFlash.read((uint16_t*)IFLASH_LOCALID_ADDR, &addr, sizeof(addr));
! call IFlash.read((uint8_t*)IFLASH_GROUPID_ADDR, &group, sizeof(group));
! call IFlash.read((uint8_t*)IFLASH_CHECKSUM_ADDR, &sum, sizeof(sum));
! if (sum == checkSum(addr, group)) {
! TOS_AM_GROUP = group;
! atomic TOS_LOCAL_ADDRESS = addr;
}
else {
--- 47,82 ----
implementation {
! uint16_t computeTosInfoCrc(NetProg_TOSInfo* tosInfo) {
! uint8_t *buf = (uint8_t*)tosInfo;
! uint16_t crc;
! uint8_t i;
! for ( i = 0, crc = 0; i < sizeof(NetProg_TOSInfo)-2; i++ )
! crc = crcByte(crc, *buf++);
! return crc;
}
void writeTOSinfo() {
! NetProg_TOSInfo tosInfo;
! call IFlash.read((uint8_t*)IFLASH_TOS_INFO_ADDR, &tosInfo, sizeof(tosInfo));
! // don't write if data is already correct
! if (tosInfo.addr == TOS_LOCAL_ADDRESS && tosInfo.groupId == TOS_AM_GROUP
! && tosInfo.crc == computeTosInfoCrc(&tosInfo))
! return;
! tosInfo.addr = TOS_LOCAL_ADDRESS;
! tosInfo.groupId = TOS_AM_GROUP;
! tosInfo.crc = computeTosInfoCrc(&tosInfo);
! call IFlash.write((uint8_t*)IFLASH_TOS_INFO_ADDR, &tosInfo, sizeof(tosInfo));
}
command result_t StdControl.init() {
! NetProg_TOSInfo tosInfo;
! result_t result = call MetadataControl.init();
! call IFlash.read((uint8_t*)IFLASH_TOS_INFO_ADDR, &tosInfo, sizeof(tosInfo));
! if (tosInfo.crc == computeTosInfoCrc(&tosInfo)) {
! TOS_AM_GROUP = tosInfo.groupId;
! atomic TOS_LOCAL_ADDRESS = tosInfo.addr;
}
else {
***************
*** 87,99 ****
command result_t StdControl.stop() { return SUCCESS; }
- void markExplicitRebootFlag() {
- #ifndef PLATFORM_PC
- uint8_t tmp;
- call IFlash.read((uint8_t*)TOSBOOT_FLAGS_ADDR, &tmp, sizeof(tmp));
- tmp |= TOSBOOT_EXPLICIT_REBOOT;
- call IFlash.write((uint8_t*)TOSBOOT_FLAGS_ADDR, &tmp, sizeof(tmp));
- #endif
- }
-
event result_t MetadataControl.initDone() { return SUCCESS; }
event result_t MetadataControl.startDone() { return SUCCESS; }
--- 94,97 ----
***************
*** 105,109 ****
NETPROG_DISABLE_WDT();
writeTOSinfo();
- markExplicitRebootFlag();
NETPROG_ACTUAL_REBOOT();
}
--- 103,106 ----
***************
*** 122,126 ****
NETPROG_DISABLE_WDT();
writeTOSinfo();
- markExplicitRebootFlag();
imageAddr = call Storage.imgNum2Addr(newImgNum) + DELUGE_IDENT_SIZE;
--- 119,122 ----
***************
*** 139,145 ****
--- 135,168 ----
}
+ event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr pMsg) {
+
+ NetProgMsg* rxMsg = (NetProgMsg*)pMsg->data;
+
+ if (rxMsg->sourceAddr == TOS_UART_ADDR
+ || rxMsg->sourceAddr == TOS_BCAST_ADDR) {
+ if (!call SharedMsgBuf.isLocked()) {
+ TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
+ NetProgMsg* txMsg = (NetProgMsg*)pMsgBuf->data;
+ txMsg->sourceAddr = TOS_LOCAL_ADDRESS;
+ txMsg->ident = G_Ident;
+ if (call SendMsg.send(rxMsg->sourceAddr, sizeof(NetProgMsg), pMsgBuf) == SUCCESS)
+ call SharedMsgBuf.lock();
+ }
+ }
+
+ return pMsg;
+
+ }
+
+ event result_t SendMsg.sendDone(TOS_MsgPtr pMsg, result_t result) {
+ call SharedMsgBuf.unlock();
+ return SUCCESS;
+ }
+
event void Metadata.setupNewImageDone(result_t result) { ; }
event void Metadata.receivedPageDone(result_t result) { ; }
event void Storage.loadImagesDone(result_t result) { ; }
+ event void SharedMsgBuf.bufFree() { ; }
+
}
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/STM25P/STM25P
StorageManagerM.nc, 1.3, 1.4
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/delugetools
Deluge.java, 1.7, 1.8 Makefile, 1.14, 1.15 Pinger.java, 1.3,
1.4 Rebooter.java, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-beta-commits
mailing list