[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestNetwork
TestNetworkC.nc, 1.1.2.16, 1.1.2.17
Rodrigo Fonseca
rfonseca76 at users.sourceforge.net
Thu Oct 26 10:04:32 PDT 2006
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/mica2/Radio Makefile,
1.1.1.1.2.1, NONE TestRadioC.nc, 1.1.1.1.2.2,
NONE TestRadioM.nc, 1.1.1.1.2.2, NONE
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/ctp CtpDebugMsg.h,
1.1.2.1, 1.1.2.2 CtpForwardingEngineP.nc, 1.1.2.9, 1.1.2.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/TestNetwork
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv7215
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
TestNetworkC.nc
Log Message:
Removed sensor reading code from TestNetwork. Made node's transmissions uniformly staggered.
Index: TestNetworkC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestNetwork/TestNetworkC.nc,v
retrieving revision 1.1.2.16
retrieving revision 1.1.2.17
diff -C2 -d -r1.1.2.16 -r1.1.2.17
*** TestNetworkC.nc 16 Oct 2006 02:25:29 -0000 1.1.2.16
--- TestNetworkC.nc 26 Oct 2006 17:04:30 -0000 1.1.2.17
***************
*** 40,47 ****
message_t* recvPtr = &uartpacket;
uint8_t msglen;
! bool busy = FALSE, uartbusy = FALSE;
bool firstTimer = TRUE;
uint16_t seqno;
!
event void Boot.booted() {
call SerialControl.start();
--- 40,53 ----
message_t* recvPtr = &uartpacket;
uint8_t msglen;
! bool sendBusy = FALSE;
! bool uartbusy = FALSE;
bool firstTimer = TRUE;
uint16_t seqno;
! enum {
! SEND_INTERVAL = 8192
! };
!
! event void ReadSensor.readDone(error_t err, uint16_t val) { }
!
event void Boot.booted() {
call SerialControl.start();
***************
*** 60,64 ****
}
seqno = 0;
! call Timer.startOneShot(call Random.rand16() & 0x1ff);
}
}
--- 66,70 ----
}
seqno = 0;
! call Timer.startOneShot(call Random.rand16() & 0x1ff);
}
}
***************
*** 66,110 ****
event void RadioControl.stopDone(error_t err) {}
event void SerialControl.stopDone(error_t err) {}
-
- event void Timer.fired() {
- call Leds.led0Toggle();
- dbg("TestNetworkC", "TestNetworkC: Timer fired.\n");
- if (firstTimer) {
- firstTimer = FALSE;
- call Timer.startPeriodic(10240);
- }
- if (busy || call ReadSensor.read() != SUCCESS) {
- signal ReadSensor.readDone(SUCCESS, 0);
- return;
- }
- busy = TRUE;
- }
void failedSend() {
dbg("App", "%s: Send failed.\n", __FUNCTION__);
! call CollectionDebug.logEvent(NET_C_DBG_1);
}
!
! event void ReadSensor.readDone(error_t err, uint16_t val) {
TestNetworkMsg* msg = (TestNetworkMsg*)call Send.getPayload(&packet);
- uint8_t hopcount;
uint16_t metric;
am_addr_t parent;
call CtpInfo.getParent(&parent);
- // call CtpInfo.getHopcount(&hopcount);
call CtpInfo.getEtx(&metric);
msg->source = TOS_NODE_ID;
msg->seqno = seqno;
! msg->data = val;
msg->parent = parent;
! msg->hopcount = hopcount;
msg->metric = metric;
- if (err != SUCCESS) {
- dbg("App", "%s: read done failed.\n", __FUNCTION__);
- busy = FALSE;
- }
if (call Send.send(&packet, sizeof(TestNetworkMsg)) != SUCCESS) {
failedSend();
--- 72,97 ----
event void RadioControl.stopDone(error_t err) {}
event void SerialControl.stopDone(error_t err) {}
void failedSend() {
dbg("App", "%s: Send failed.\n", __FUNCTION__);
! call CollectionDebug.logEvent(NET_C_DBG_1);
}
!
!
! void sendMessage() {
TestNetworkMsg* msg = (TestNetworkMsg*)call Send.getPayload(&packet);
uint16_t metric;
am_addr_t parent;
call CtpInfo.getParent(&parent);
call CtpInfo.getEtx(&metric);
msg->source = TOS_NODE_ID;
msg->seqno = seqno;
! msg->data = 0xCAFE;
msg->parent = parent;
! msg->hopcount = 0;
msg->metric = metric;
if (call Send.send(&packet, sizeof(TestNetworkMsg)) != SUCCESS) {
failedSend();
***************
*** 113,116 ****
--- 100,104 ----
}
else {
+ sendBusy = TRUE;
seqno++;
dbg("TestNetworkC", "%s: Transmission succeeded.\n", __FUNCTION__);
***************
*** 119,129 ****
}
event void Send.sendDone(message_t* m, error_t err) {
if (err != SUCCESS) {
// call Leds.led0On();
}
! else {
! busy = FALSE;
! }
dbg("TestNetworkC", "Send completed.\n");
}
--- 107,127 ----
}
+
+ event void Timer.fired() {
+ uint16_t nextInt;
+ call Leds.led0Toggle();
+ dbg("TestNetworkC", "TestNetworkC: Timer fired.\n");
+ nextInt = call Random.rand16() % SEND_INTERVAL;
+ nextInt += SEND_INTERVAL >> 1;
+ call Timer.startOneShot(nextInt);
+ if (!sendBusy)
+ sendMessage();
+ }
+
event void Send.sendDone(message_t* m, error_t err) {
if (err != SUCCESS) {
// call Leds.led0On();
}
! sendBusy = FALSE;
dbg("TestNetworkC", "Send completed.\n");
}
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/mica2/Radio Makefile,
1.1.1.1.2.1, NONE TestRadioC.nc, 1.1.1.1.2.2,
NONE TestRadioM.nc, 1.1.1.1.2.2, NONE
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/ctp CtpDebugMsg.h,
1.1.2.1, 1.1.2.2 CtpForwardingEngineP.nc, 1.1.2.9, 1.1.2.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list