From: klueska Date: Wed, 18 Jun 2008 04:22:58 +0000 (+0000) Subject: Update to TestCollection for threads X-Git-Tag: release_tinyos_2_1_0_0~253 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=018a52ddce1421929d6a88a21f185f593199b0fa Update to TestCollection for threads --- diff --git a/apps/tosthreads/capps/Blink/stack.h b/apps/tosthreads/capps/Blink/stack.h index fdaf48cb..30882954 100644 --- a/apps/tosthreads/capps/Blink/stack.h +++ b/apps/tosthreads/capps/Blink/stack.h @@ -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, }; diff --git a/apps/tosthreads/capps/RadioStress/RadioStress.c b/apps/tosthreads/capps/RadioStress/RadioStress.c index 067e08fd..bd047bf5 100644 --- a/apps/tosthreads/capps/RadioStress/RadioStress.c +++ b/apps/tosthreads/capps/RadioStress/RadioStress.c @@ -46,81 +46,65 @@ #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(); } } } diff --git a/apps/tosthreads/capps/TestCollection/Makefile b/apps/tosthreads/capps/TestCollection/Makefile index 66efa2d3..47dfa4bb 100644 --- a/apps/tosthreads/capps/TestCollection/Makefile +++ b/apps/tosthreads/capps/TestCollection/Makefile @@ -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/ diff --git a/tos/lib/tosthreads/csystem/CAMRadioC.nc b/tos/lib/tosthreads/csystem/CAMRadioC.nc index a066c05f..8b840bc4 100644 --- a/tos/lib/tosthreads/csystem/CAMRadioC.nc +++ b/tos/lib/tosthreads/csystem/CAMRadioC.nc @@ -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; } diff --git a/tos/lib/tosthreads/csystem/CAMSerialC.nc b/tos/lib/tosthreads/csystem/CAMSerialC.nc index ac776aa4..ec6b299b 100644 --- a/tos/lib/tosthreads/csystem/CAMSerialC.nc +++ b/tos/lib/tosthreads/csystem/CAMSerialC.nc @@ -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; }