X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=apps%2Ftosthreads%2Fapps%2FTestCollection%2FTestCollectionC.nc;h=51c9bdb03cb8fcb35f795824b83ed1d068177ef6;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hp=e401fc0537d78c10426b9a84c54cae21db16ee01;hpb=dba7b3ba714b04c28070ed1119453aeef90b2776;p=tinyos-2.x.git diff --git a/apps/tosthreads/apps/TestCollection/TestCollectionC.nc b/apps/tosthreads/apps/TestCollection/TestCollectionC.nc index e401fc05..51c9bdb0 100644 --- a/apps/tosthreads/apps/TestCollection/TestCollectionC.nc +++ b/apps/tosthreads/apps/TestCollection/TestCollectionC.nc @@ -20,7 +20,30 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/** + * TestCollection is a reimplementation of the Multihop Oscilloscope application + * using TOSThreads. It periodically samples a universal software-based SineSensor + * and broadcasts a message every few readings. These readings can be displayed by + * the Java "Oscilloscope" application found in the the TestCollection/java + * subdirectory. The sampling rate starts at 4Hz, but can be changed from the Java + * application. + * + * At least two motes must be used by this application, with one of them installed + * as a base station. Base station motes can be created by installing them with + * NODE_ID % 500 == 0. + * i.e. make threads install.0 + * make threads install.500 + * make threads install.1000 + * + * All other nodes can be installed with arbitrary NODE_IDs. + * make threads install.123 + * + * Successful running of this application is verified by all NON-base station motes + * periodically flashing LED1 upon sending a message, and the base station mote, + * flashing LED2 upon successful reception of a message. Additionally, correct + * operation should be verified by running the java tool described in the following + * section. + * * @author Chieh-Jan Mike Liang */ @@ -73,7 +96,10 @@ implementation { call RootControl.setRoot(); for (;;) { if (call BlockingReceive.receive(&recvbuf, 0) == SUCCESS) { - call SerialBlockingSend.send(AM_BROADCAST_ADDR, &recvbuf, sizeof(local)); + oscilloscope_t *recv_o = (oscilloscope_t *) call BlockingReceive.getPayload(&recvbuf, sizeof(oscilloscope_t)); + oscilloscope_t *send_o = (oscilloscope_t *) call SerialBlockingSend.getPayload(&sendbuf, sizeof(oscilloscope_t)); + memcpy(send_o, recv_o, sizeof(oscilloscope_t)); + call SerialBlockingSend.send(AM_BROADCAST_ADDR, &sendbuf, sizeof(oscilloscope_t)); report_received(); } } @@ -82,14 +108,14 @@ implementation { for (;;) { if (reading == NREADINGS) { - oscilloscope_t *o = o; - o = (oscilloscope_t *)call BlockingSend.getPayload(&sendbuf, sizeof(oscilloscope_t)); + oscilloscope_t *o = (oscilloscope_t *) call BlockingSend.getPayload(&sendbuf, sizeof(oscilloscope_t)); if (o == NULL) { fatal_problem(); return; } - memcpy(o, &local, sizeof(local)); - if (call BlockingSend.send(&sendbuf, sizeof(local)) == SUCCESS) { + memcpy(o, &local, sizeof(oscilloscope_t)); + if (call BlockingSend.send(&sendbuf, sizeof(oscilloscope_t)) == SUCCESS) { + local.count++; report_sent(); } else { report_problem();