From 82ff984239b5b5088c952b684a5ab0f8112b8074 Mon Sep 17 00:00:00 2001 From: gnawali Date: Thu, 14 Jan 2010 21:53:58 +0000 Subject: [PATCH] explain test procedure and how to interpret results; change code to use leds to indicate basic errors --- apps/tests/TestNetwork/README.txt | 18 ++++++++++++++++++ apps/tests/TestNetwork/TestNetworkC.nc | 22 +++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/apps/tests/TestNetwork/README.txt b/apps/tests/TestNetwork/README.txt index ed522050..b533acdc 100644 --- a/apps/tests/TestNetwork/README.txt +++ b/apps/tests/TestNetwork/README.txt @@ -14,6 +14,24 @@ Collection Tree Protocol for details. There are scripts on net2 website to parse the debug messages sent by the nodes. +To test, start with two motes with no program that transmits +packets. Example., erase the mote or install Blink. Program a mote with +node id 0. The mote will toggle led1 (green on TelosB) approximately +every 8s. Then program the second mote with id 1. Once programming is +complete, the mote with id 0 will toggle led1 twice every 8s. Each +toggle corresponds to the reception of collection message (once from +itself, and once from the mote with id 1). + +Errors indications: + +Motes 0 and 1 will set led0 (red on TelosB) if there are errors while +sending the packet. + +Mote 0 will set led2 (blue on TelosB) if the gap in sequence number on +consecutive packet reception from node 1 is greater than 1. This is +expected to be a rare event while doing experiment on a desk. + + Known bugs/limitations: None. diff --git a/apps/tests/TestNetwork/TestNetworkC.nc b/apps/tests/TestNetwork/TestNetworkC.nc index 7e727824..05e44d2f 100644 --- a/apps/tests/TestNetwork/TestNetworkC.nc +++ b/apps/tests/TestNetwork/TestNetworkC.nc @@ -114,7 +114,6 @@ implementation { event void Timer.fired() { uint32_t nextInt; - call Leds.led0Toggle(); dbg("TestNetworkC", "TestNetworkC: Timer fired.\n"); nextInt = call Random.rand32() % SEND_INTERVAL; nextInt += SEND_INTERVAL >> 1; @@ -125,7 +124,7 @@ implementation { event void Send.sendDone(message_t* m, error_t err) { if (err != SUCCESS) { - // call Leds.led0On(); + call Leds.led0On(); } sendBusy = FALSE; dbg("TestNetworkC", "Send completed.\n"); @@ -137,13 +136,26 @@ implementation { call Timer.startPeriodic(*newVal); } + + uint8_t prevSeq = 0; + uint8_t firstMsg = 0; + event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) { dbg("TestNetworkC", "Received packet at %s from node %hhu.\n", sim_time_string(), call CollectionPacket.getOrigin(msg)); - call Leds.led1Toggle(); - if (!call Pool.size() <= (TEST_NETWORK_QUEUE_SIZE < 4)? 1:3) { - // call CtpCongestion.setClientCongested(TRUE); + call Leds.led1Toggle(); + + if (call CollectionPacket.getOrigin(msg) == 1) { + if (firstMsg == 1) { + if (call CollectionPacket.getSequenceNumber(msg) - prevSeq > 1) { + call Leds.led2On(); + } + } else { + firstMsg = 1; + } + prevSeq = call CollectionPacket.getSequenceNumber(msg); } + if (!call Pool.empty() && call Queue.size() < call Queue.maxSize()) { message_t* tmp = call Pool.get(); call Queue.enqueue(msg); -- 2.39.2