[Tinyos-2-commits] CVS: tinyos-2.x/apps/tutorials/BlinkConfig
BlinkConfigC.nc, 1.5, 1.6 README.txt, 1.6, 1.7
Prabal Dutta
prabal at users.sourceforge.net
Thu Apr 5 19:48:46 PDT 2007
Update of /cvsroot/tinyos/tinyos-2.x/apps/tutorials/BlinkConfig
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv9130
Modified Files:
BlinkConfigC.nc README.txt
Log Message:
Added volume valid check. Verified operation with telos and micaz
Index: BlinkConfigC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tutorials/BlinkConfig/BlinkConfigC.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** BlinkConfigC.nc 6 Apr 2007 01:13:59 -0000 1.5
--- BlinkConfigC.nc 6 Apr 2007 02:48:44 -0000 1.6
***************
*** 53,57 ****
CONFIG_ADDR = 0,
CONFIG_VERSION = 1,
! DEFAULT_PERIOD = 1024
};
--- 53,59 ----
CONFIG_ADDR = 0,
CONFIG_VERSION = 1,
! DEFAULT_PERIOD = 1024,
! MIN_PERIOD = 128,
! MAX_PERIOD = 1024
};
***************
*** 60,63 ****
--- 62,67 ----
event void Boot.booted() {
+ conf.period = DEFAULT_PERIOD;
+
if (call Mount.mount() != SUCCESS) {
// Handle failure
***************
*** 66,76 ****
event void Mount.mountDone(error_t error) {
! if (error != SUCCESS) {
! // Handle failure
}
else{
! if (call Config.read(CONFIG_ADDR, &conf, sizeof(conf)) != SUCCESS) {
! // Handle failure
! }
}
}
--- 70,92 ----
event void Mount.mountDone(error_t error) {
! if (error == SUCCESS) {
! if (call Config.valid() == TRUE) {
! if (call Config.read(CONFIG_ADDR, &conf, sizeof(conf)) != SUCCESS) {
! // Handle failure
! }
! }
! else {
! // Invalid volume. Commit to make valid.
! call Leds.led1On();
! if (call Config.commit() == SUCCESS) {
! call Leds.led0On();
! }
! else {
! // Handle failure
! }
! }
}
else{
! // Handle failure
}
}
***************
*** 82,86 ****
memcpy(&conf, buf, len);
if (conf.version == CONFIG_VERSION) {
! conf.period = conf.period > 128 ? conf.period/2 : DEFAULT_PERIOD;
}
else {
--- 98,104 ----
memcpy(&conf, buf, len);
if (conf.version == CONFIG_VERSION) {
! conf.period = conf.period/2;
! conf.period = conf.period > MAX_PERIOD ? MAX_PERIOD : conf.period;
! conf.period = conf.period < MIN_PERIOD ? MAX_PERIOD : conf.period;
}
else {
Index: README.txt
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tutorials/BlinkConfig/README.txt,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** README.txt 6 Apr 2007 01:13:59 -0000 1.6
--- README.txt 6 Apr 2007 02:48:44 -0000 1.7
***************
*** 1,3 ****
! $Id$: README.txt,v 1.5 2006/12/12 18:22:52 vlahan Exp $
README for Config
--- 1,3 ----
! $Id$
README for Config
***************
*** 20,30 ****
and 8Hz.
! The first time this application is installed, the green LED will
! light up and remain on (indicating that the configuration storage
! volume did not have the expected version number).
The red LED will remain lit during the flash write/commit operation.
! The blue (yellow) LED blinks at the period stored and read from flash.
See Lesson 7 for details.
--- 20,32 ----
and 8Hz.
! The first two times this application is installed, the green LED
! will light up and remain on (the first time indicating that the
! storage volume is not valid and second time that the volume does not
! have the expected version number).
The red LED will remain lit during the flash write/commit operation.
! The blue (yellow) LED blinks with the period stored and read from
! flash.
See Lesson 7 for details.
More information about the Tinyos-2-commits
mailing list