X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=apps%2Ftosthreads%2Fcapps%2FTestCollection%2FTestCollection.c;h=aaf811db233e0e9ead4a0f785261cd08135f8f98;hb=c5b798cd21ab503fcbad0b4d145301589975a0d2;hp=21aca5a0ff6426540ae2a9afaf3f04cb8da9d3fb;hpb=1fe0446fd667275237d1852719c97034d9bf1aad;p=tinyos-2.x.git diff --git a/apps/tosthreads/capps/TestCollection/TestCollection.c b/apps/tosthreads/capps/TestCollection/TestCollection.c index 21aca5a0..aaf811db 100644 --- a/apps/tosthreads/capps/TestCollection/TestCollection.c +++ b/apps/tosthreads/capps/TestCollection/TestCollection.c @@ -41,6 +41,8 @@ #include "tosthread_sinesensor.h" #include "MultihopOscilloscope.h" +#define MY_COLLECTION_ID 0x02 + void fatal_problem(); void report_problem(); void report_sent(); @@ -58,12 +60,14 @@ void tosthread_main(void* arg) { while ( amRadioStart() != SUCCESS ); while ( collectionRoutingStart() != SUCCESS ); - + + collectionSetCollectionId(AM_OSCILLOSCOPE, MY_COLLECTION_ID); + if (local.id % 500 == 0) { - while ( amSerialStart() != SUCCESS); + while ( amSerialStart() != SUCCESS ); collectionSetRoot(); for (;;) { - if ( collectionReceive(&recvbuf, 0, AM_OSCILLOSCOPE) == SUCCESS) { + if (collectionReceive(&recvbuf, 0, MY_COLLECTION_ID) == SUCCESS) { oscilloscope_t *recv_o = (oscilloscope_t *) collectionGetPayload(&recvbuf, sizeof(oscilloscope_t)); oscilloscope_t *send_o = (oscilloscope_t *) serialGetPayload(&sendbuf, sizeof(oscilloscope_t)); memcpy(send_o, recv_o, sizeof(oscilloscope_t)); @@ -73,7 +77,7 @@ void tosthread_main(void* arg) { } } else { uint16_t var; - + for (;;) { if (reading == NREADINGS) { oscilloscope_t *o = (oscilloscope_t *) collectionGetPayload(&sendbuf, sizeof(oscilloscope_t)); @@ -91,11 +95,11 @@ void tosthread_main(void* arg) { reading = 0; } - + if (sinesensor_read(&var) == SUCCESS) { local.readings[reading++] = var; } - + tosthread_sleep(local.interval); } }