]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Update to TestCollection for threads
authorklueska <klueska>
Wed, 18 Jun 2008 04:22:58 +0000 (04:22 +0000)
committerklueska <klueska>
Wed, 18 Jun 2008 04:22:58 +0000 (04:22 +0000)
apps/tosthreads/capps/Blink/stack.h
apps/tosthreads/capps/RadioStress/RadioStress.c
apps/tosthreads/capps/TestCollection/Makefile
tos/lib/tosthreads/csystem/CAMRadioC.nc
tos/lib/tosthreads/csystem/CAMSerialC.nc

index fdaf48cbf3bef47262816d8b3f54ccec714036f8..30882954a74c5197f96f8290e01cf2c66add2bde 100644 (file)
@@ -34,8 +34,7 @@
  */
 
 enum {
-  NOTHING_STACK_SIZE = 500,
-  BLINK0_STACK_SIZE = 500,
-  BLINK1_STACK_SIZE = 500,
-  BLINK2_STACK_SIZE = 500,
+  BLINK0_STACK_SIZE = 200,
+  BLINK1_STACK_SIZE = 200,
+  BLINK2_STACK_SIZE = 200,
 };
index 067e08fd72ad20b55362258ff6e392daab1ff636..bd047bf5b1ed65c249b4c31d1ca0ab7f5ac32748 100644 (file)
 #include "tosthread_amradio.h"
 #include "tosthread_leds.h"
 
-typedef nx_struct RadioCountMsg {
-  nx_uint16_t counter;
-} RadioCountMsg;
+//Initialize variables associated with each thread
+tosthread_t radioStress0;
+tosthread_t radioStress1;
+tosthread_t radioStress2;
 
-enum {
-  AM_RADIOCOUNTMSG = 6,
-};
+void radioStress0_thread(void* arg);
+void radioStress1_thread(void* arg);
+void radioStress2_thread(void* arg);
 
-//Initialize variables associated with the RadioStress thread
-tosthread_t timerHandle;
-tosthread_t receiveHandle;
-tosthread_t sendHandle;
-void timer_thread(void* arg);
-void receive_thread(void* arg);
-void send_thread(void* arg);
-
-//Initialize the message variable
-message_t send_packet; 
-message_t receive_packet;  
-  
-//Initalize counter variables
-uint32_t txCounter = 0;
-uint32_t ackCounter = 0;
-uint32_t rxCounter = 0;
-int16_t timerCounter = -1;
-uint16_t errorCounter = 0;
+//Initialize messages for sending out over the radio
+message_t msg0;
+message_t msg1;
+message_t msg2;
 
 void tosthread_main(void* arg) {
-  led0On();
   while( amRadioStart() != SUCCESS );
-  led1On();
-  tosthread_create(&timerHandle, timer_thread, NULL, 200);
-  tosthread_create(&receiveHandle, receive_thread, NULL, 200);
-}
-
-void sendPacket() {
-  RadioCountMsg* rcm = (RadioCountMsg*)radioGetPayload(&send_packet, sizeof(RadioCountMsg));
-  rcm->counter = txCounter;
-  while( amRadioSend(AM_BROADCAST_ADDR, &send_packet, 2, AM_RADIOCOUNTMSG) != SUCCESS )
-    errorCounter++; 
+  tosthread_create(&radioStress0, radioStress0_thread, &msg0, 200);
+  tosthread_create(&radioStress1, radioStress1_thread, &msg1, 200);
+  tosthread_create(&radioStress2, radioStress2_thread, &msg2, 200);
 }
 
-void timer_thread(void* arg) {
-  tosthread_sleep(1000);
-  tosthread_create(&sendHandle, send_thread, NULL, 200);
+void radioStress0_thread(void* arg) {
+  message_t* m = (message_t*)arg;
   for(;;) {
-    led2Toggle();
-    timerCounter++;
-    tosthread_sleep(1000);
-    sendPacket();
+    if(TOS_NODE_ID == 0) {
+      amRadioReceive(m, 2000, 20);
+      led0Toggle();
+    }
+    else {
+      if(amRadioSend(!TOS_NODE_ID, m, 0, 20) == SUCCESS)
+        led0Toggle(); 
+    }
   }
 }
 
-void receive_thread(void* arg) {
+void radioStress1_thread(void* arg) {
+  message_t* m = (message_t*)arg;
   for(;;) {
-    amRadioReceive(&receive_packet, 0, AM_RADIOCOUNTMSG);
-    rxCounter++;
-    if ((rxCounter % 32) == 0) {
-      led0Toggle();
+    if(TOS_NODE_ID == 0) {
+      amRadioReceive(m, 2000, 21);
+      led1Toggle();
+    }
+    else {
+      if(amRadioSend(!TOS_NODE_ID, m, 0, 21) == SUCCESS)
+        led1Toggle();
     }
   }
 }
 
-void send_thread(void* arg) {
+void radioStress2_thread(void* arg) {
+  message_t* m = (message_t*)arg;
   for(;;) {
-    sendPacket();
-    txCounter++;
-    if (txCounter % 32 == 0) {
-      led1Toggle();
+    if(TOS_NODE_ID == 0) {
+      amRadioReceive(m, 2000, 22);
+      led2Toggle();
     }
-    if ( radioWasAcked(&send_packet) ) {
-      ackCounter++;
-      if (ackCounter % 32 == 0) {
-           led2Toggle();
-      }
+    else {
+      if(amRadioSend(!TOS_NODE_ID, m, 0, 22) == SUCCESS)
+        led2Toggle();
     }
   }
 }
index 66efa2d3d0dc8bf2d258ea9494d96a44ce9e24a3..47dfa4bbf58acbb9863734877d9d3d6515d5a52c 100644 (file)
@@ -1,5 +1,7 @@
 TOSTHREAD_MAIN=TestCollection.c
 
+PFLAGS += -DTOSTHREAD_MAIN_STACK_SIZE=800
+
 CFLAGS += -I$(TOSDIR)/lib/tosthreads/sensorboards/universal
 
 CFLAGS += -I$(TOSDIR)/lib/tosthreads/lib/net/
index a066c05f251e32ccf53c19a6ae1535f902800dbc..8b840bc436e4f302e6bb0d9259d6e977df357b8c 100644 (file)
@@ -30,6 +30,7 @@ configuration CAMRadioC {}
 
 implementation {
   components CAMRadioP as CAMP;
+  components ActiveMessageC;
   components BlockingActiveMessageC as AM;
   
   CAMP.BlockingStdControl -> AM;
@@ -41,4 +42,8 @@ implementation {
   CAMP.Packet -> AM;
   CAMP.AMPacket -> AM;
   CAMP.PacketAcknowledgements -> AM;
+  
+  AM.Receive -> ActiveMessageC.Receive;
+  AM.Snoop -> ActiveMessageC.Snoop;
+  AM.AMSend -> ActiveMessageC;
 }
index ac776aa46797753b969a33e9fc506e066efc3b61..ec6b299bf2c975df85cae8c66128471383ee3db4 100644 (file)
@@ -30,6 +30,7 @@ configuration CAMSerialC {}
 
 implementation {
   components CAMSerialP as CAMP;
+  components SerialActiveMessageC;
   components BlockingSerialActiveMessageC as AM;
   
   CAMP.BlockingStdControl -> AM;
@@ -39,4 +40,7 @@ implementation {
   CAMP.Packet -> AM;
   CAMP.AMPacket -> AM;
   CAMP.PacketAcknowledgements -> AM;
+  
+  AM.Receive -> SerialActiveMessageC.Receive;
+  AM.AMSend -> SerialActiveMessageC.AMSend;
 }