[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestMultihopLqi
CC2420ActiveMessageC.nc, 1.2, 1.3 Makefile, 1.1,
1.2 MultihopOscilloscope.h, 1.2,
1.3 MultihopOscilloscopeAppC.nc, 1.2,
1.3 MultihopOscilloscopeC.nc, 1.3, 1.4 script.py, 1.2, 1.3
Phil Levis
scipio at users.sourceforge.net
Tue Feb 19 11:49:33 PST 2008
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/TestMultihopLqi
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv31837
Modified Files:
CC2420ActiveMessageC.nc Makefile MultihopOscilloscope.h
MultihopOscilloscopeAppC.nc MultihopOscilloscopeC.nc script.py
Log Message:
Update the testing code so it tests for radios being
turned on and off.
Index: CC2420ActiveMessageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestMultihopLqi/CC2420ActiveMessageC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CC2420ActiveMessageC.nc 4 Jul 2007 15:51:54 -0000 1.2
--- CC2420ActiveMessageC.nc 19 Feb 2008 19:49:30 -0000 1.3
***************
*** 1,4 ****
--- 1,5 ----
#include <sim_gain.h>
#include <sim_tossim.h>
+ #include <AM.h>
module CC2420ActiveMessageC {
***************
*** 8,11 ****
--- 9,15 ----
implementation {
+ typedef struct cc2420_header {
+
+ } cc2420_header_t;
/**
* Get transmission power setting for current packet.
***************
*** 60,68 ****
return (uint8_t)sig;
}
- async command cc2420_header_t* Packet.getHeader(message_t* msg) {
- return NULL;
- }
- async command cc2420_metadata_t* Packet.getMetadata(message_t* msg) {
- return NULL;
- }
}
--- 64,66 ----
Index: Makefile
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestMultihopLqi/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Makefile 12 Apr 2007 23:23:58 -0000 1.1
--- Makefile 19 Feb 2008 19:49:31 -0000 1.2
***************
*** 1,4 ****
COMPONENT=MultihopOscilloscopeAppC
! CFLAGS += -I$(TOSDIR)/lib/net/ -I$(TOSDIR)/lib/net/lqi
include $(MAKERULES)
--- 1,4 ----
COMPONENT=MultihopOscilloscopeAppC
! CFLAGS += -I$(TOSDIR)/lib/net/ -I$(TOSDIR)/lib/net/lqi -I$(TOSDIR)/chips/cc2420/interfaces
include $(MAKERULES)
Index: MultihopOscilloscope.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestMultihopLqi/MultihopOscilloscope.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MultihopOscilloscope.h 4 Jul 2007 15:51:55 -0000 1.2
--- MultihopOscilloscope.h 19 Feb 2008 19:49:31 -0000 1.3
***************
*** 22,26 ****
NREADINGS = 5,
/* Default sampling period. */
! DEFAULT_INTERVAL = 200,
AM_OSCILLOSCOPE = 0x93
};
--- 22,26 ----
NREADINGS = 5,
/* Default sampling period. */
! DEFAULT_INTERVAL = 1024,
AM_OSCILLOSCOPE = 0x93
};
Index: MultihopOscilloscopeAppC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestMultihopLqi/MultihopOscilloscopeAppC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MultihopOscilloscopeAppC.nc 4 Jul 2007 15:51:55 -0000 1.2
--- MultihopOscilloscopeAppC.nc 19 Feb 2008 19:49:31 -0000 1.3
***************
*** 19,24 ****
configuration MultihopOscilloscopeAppC { }
implementation {
! components MainC, MultihopOscilloscopeC, LedsC, new TimerMilliC(),
! new DemoSensorC() as Sensor;
//MainC.SoftwareInit -> Sensor;
--- 19,24 ----
configuration MultihopOscilloscopeAppC { }
implementation {
! components MainC, MultihopOscilloscopeC, LedsC, new TimerMilliC(),
! new TimerMilliC() as OnOffTimer, new DemoSensorC() as Sensor;
//MainC.SoftwareInit -> Sensor;
***************
*** 28,32 ****
MultihopOscilloscopeC.Read -> Sensor;
MultihopOscilloscopeC.Leds -> LedsC;
!
//
// Communication components. These are documented in TEP 113:
--- 28,32 ----
MultihopOscilloscopeC.Read -> Sensor;
MultihopOscilloscopeC.Leds -> LedsC;
! MultihopOscilloscopeC.OnOffTimer -> OnOffTimer;
//
// Communication components. These are documented in TEP 113:
***************
*** 38,41 ****
--- 38,42 ----
SerialActiveMessageC, // Serial messaging
new SerialAMSenderC(AM_OSCILLOSCOPE); // Sends to the serial port
+ components RandomC;
MultihopOscilloscopeC.RadioControl -> ActiveMessageC;
***************
*** 48,52 ****
MultihopOscilloscopeC.Receive -> Collector.Receive[AM_OSCILLOSCOPE];
MultihopOscilloscopeC.RootControl -> Collector;
!
components new PoolC(message_t, 10) as UARTMessagePoolP,
new QueueC(message_t*, 10) as UARTQueueP;
--- 49,54 ----
MultihopOscilloscopeC.Receive -> Collector.Receive[AM_OSCILLOSCOPE];
MultihopOscilloscopeC.RootControl -> Collector;
! MultihopOscilloscopeC.Random -> RandomC;
!
components new PoolC(message_t, 10) as UARTMessagePoolP,
new QueueC(message_t*, 10) as UARTQueueP;
***************
*** 54,62 ****
MultihopOscilloscopeC.UARTMessagePool -> UARTMessagePoolP;
MultihopOscilloscopeC.UARTQueue -> UARTQueueP;
!
! //
! // Components for debugging collection.
! //
! components new PoolC(message_t, 20) as DebugMessagePool,
new QueueC(message_t*, 20) as DebugSendQueue,
new SerialAMSenderC(AM_LQI_DEBUG) as DebugSerialSender,
--- 56,61 ----
MultihopOscilloscopeC.UARTMessagePool -> UARTMessagePoolP;
MultihopOscilloscopeC.UARTQueue -> UARTQueueP;
!
! components new PoolC(message_t, 20) as DebugMessagePool,
new QueueC(message_t*, 20) as DebugSendQueue,
new SerialAMSenderC(AM_LQI_DEBUG) as DebugSerialSender,
***************
*** 68,70 ****
--- 67,73 ----
DebugSender.SendQueue -> DebugSendQueue;
Collector.CollectionDebug -> DebugSender;
+
+ components CC2420ActiveMessageC;
+ CC2420ActiveMessageC.SubPacket -> ActiveMessageC;
+
}
Index: MultihopOscilloscopeC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestMultihopLqi/MultihopOscilloscopeC.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** MultihopOscilloscopeC.nc 13 Sep 2007 23:10:20 -0000 1.3
--- MultihopOscilloscopeC.nc 19 Feb 2008 19:49:31 -0000 1.4
***************
*** 41,46 ****
--- 41,48 ----
// Miscalleny:
interface Timer<TMilli>;
+ interface Timer<TMilli> as OnOffTimer;
interface Read<uint16_t>;
interface Leds;
+ interface Random;
}
}
***************
*** 70,74 ****
notion of time). */
bool suppress_count_change;
!
//
// On bootup, initialize radio and serial communications, and our
--- 72,76 ----
notion of time). */
bool suppress_count_change;
! bool running = FALSE;
//
// On bootup, initialize radio and serial communications, and our
***************
*** 79,83 ****
local.id = TOS_NODE_ID;
local.version = 0;
! dbg("App", "Booted.");
// Beginning our initialization phases:
if (call RadioControl.start() != SUCCESS)
--- 81,85 ----
local.id = TOS_NODE_ID;
local.version = 0;
!
// Beginning our initialization phases:
if (call RadioControl.start() != SUCCESS)
***************
*** 86,92 ****
--- 88,97 ----
if (call RoutingControl.start() != SUCCESS)
fatal_problem();
+
+ startTimer();
}
event void RadioControl.startDone(error_t error) {
+ //dbg("App", "Radio control start done.\n");
if (error != SUCCESS)
fatal_problem();
***************
*** 97,100 ****
--- 102,108 ----
if (call SerialControl.start() != SUCCESS)
fatal_problem();
+
+ running = TRUE;
+ call OnOffTimer.startOneShot(19 + (call Random.rand32() % 173));
}
***************
*** 106,114 ****
if (local.id % 500 == 0)
call RootControl.setRoot();
- startTimer();
}
static void startTimer() {
if (call Timer.isRunning()) call Timer.stop();
call Timer.startPeriodic(local.interval);
--- 114,134 ----
if (local.id % 500 == 0)
call RootControl.setRoot();
+
}
+
+ event void OnOffTimer.fired() {
+ if (running) {
+ call RadioControl.stop();
+ }
+ else {
+ call RadioControl.start();
+ }
+
+ }
+
static void startTimer() {
+ dbg("App", "Starting timer.\n");
if (call Timer.isRunning()) call Timer.stop();
call Timer.startPeriodic(local.interval);
***************
*** 116,120 ****
}
! event void RadioControl.stopDone(error_t error) { }
event void SerialControl.stopDone(error_t error) { }
--- 136,144 ----
}
! event void RadioControl.stopDone(error_t error) {
! //dbg("App", "Radio control stop done.\n");
! running = FALSE;
! call OnOffTimer.startOneShot(3);
! }
event void SerialControl.stopDone(error_t error) { }
***************
*** 128,142 ****
oscilloscope_t* in = (oscilloscope_t*)payload;
oscilloscope_t* out;
- dbg("App", "Received a packet.\n\t");
- {
- int i;
- for (i = 0; i < len; i++) {
- dbg_clear("App", "[%hhx] ", ((uint8_t*)payload)[i]);
- }
- dbg_clear("App", "\n");
- }
if (uartbusy == FALSE) {
out = (oscilloscope_t*)call SerialSend.getPayload(&uartbuf, sizeof(oscilloscope_t));
! if (out == NULL || call Packet.payloadLength(&uartbuf) != sizeof(oscilloscope_t)) {
return msg;
}
--- 152,159 ----
oscilloscope_t* in = (oscilloscope_t*)payload;
oscilloscope_t* out;
if (uartbusy == FALSE) {
out = (oscilloscope_t*)call SerialSend.getPayload(&uartbuf, sizeof(oscilloscope_t));
! if (out == NULL) {
! fatal_problem();
return msg;
}
***************
*** 159,163 ****
out = (oscilloscope_t*)call SerialSend.getPayload(newmsg, sizeof(oscilloscope_t));
if (out == NULL) {
! return;
}
memcpy(out, in, sizeof(oscilloscope_t));
--- 176,181 ----
out = (oscilloscope_t*)call SerialSend.getPayload(newmsg, sizeof(oscilloscope_t));
if (out == NULL) {
! fatal_problem();
! return msg;
}
memcpy(out, in, sizeof(oscilloscope_t));
***************
*** 238,250 ****
oscilloscope_t *o = (oscilloscope_t *)call Send.getPayload(&sendbuf, sizeof(oscilloscope_t));
if (o == NULL) {
return;
}
memcpy(o, &local, sizeof(local));
if (call Send.send(&sendbuf, sizeof(local)) == SUCCESS) {
- dbg("App", "Sending a packet.\n");
sendbusy = TRUE;
! }
! else
report_problem();
}
--- 256,271 ----
oscilloscope_t *o = (oscilloscope_t *)call Send.getPayload(&sendbuf, sizeof(oscilloscope_t));
if (o == NULL) {
+ fatal_problem();
return;
}
memcpy(o, &local, sizeof(local));
if (call Send.send(&sendbuf, sizeof(local)) == SUCCESS) {
sendbusy = TRUE;
! dbg("App", "Sending data packet.\n");
! }
! else {
! dbg("App", "Data packet send failed.\n");
report_problem();
+ }
}
***************
*** 262,265 ****
--- 283,287 ----
event void Send.sendDone(message_t* msg, error_t error) {
+ dbg("App", "App-level send done.\n");
if (error == SUCCESS)
report_sent();
Index: script.py
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestMultihopLqi/script.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** script.py 4 Jul 2007 15:51:55 -0000 1.2
--- script.py 19 Feb 2008 19:49:31 -0000 1.3
***************
*** 12,20 ****
#t.addChannel("CpmModelC", sys.stdout)
#t.addChannel("Gain", sys.stdout)
! t.addChannel("AM", sys.stdout)
t.addChannel("App", sys.stdout)
! #t.addChannel("LQI", sys.stdout)
#t.addChannel("LQIRoute", sys.stdout)
! #t.addChannel("LQIDeliver", sys.stdout)
#t.addChannel("LQIRoute", sys.stdout)
#t.addChannel("PointerBug", sys.stdout)
--- 12,20 ----
#t.addChannel("CpmModelC", sys.stdout)
#t.addChannel("Gain", sys.stdout)
! #t.addChannel("AM", sys.stdout)
t.addChannel("App", sys.stdout)
! t.addChannel("LQI", sys.stdout)
#t.addChannel("LQIRoute", sys.stdout)
! t.addChannel("LQIDeliver", sys.stdout)
#t.addChannel("LQIRoute", sys.stdout)
#t.addChannel("PointerBug", sys.stdout)
***************
*** 55,58 ****
# print m1.generateNoise(i)
! for i in range(0, 2000):
t.runNextEvent();
--- 55,58 ----
# print m1.generateNoise(i)
! while ((t.time() / t.ticksPerSecond()) < 3000):
t.runNextEvent();
More information about the Tinyos-2-commits
mailing list