]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Fix Java compilation problem for cthreads' TestCollection app
authorliang_mike <liang_mike>
Tue, 5 Jan 2010 22:15:57 +0000 (22:15 +0000)
committerliang_mike <liang_mike>
Tue, 5 Jan 2010 22:15:57 +0000 (22:15 +0000)
apps/tosthreads/capps/TestCollection/MultihopOscilloscope.h
apps/tosthreads/capps/TestCollection/README
apps/tosthreads/capps/TestCollection/TestCollection.c

index 41d8885cca2ed3b82718a25c1ffcc1508f909c12..5f04053921da7d7eb56ffca1fc5ad93f6029e8e6 100644 (file)
 #ifndef MULTIHOP_OSCILLOSCOPE_H
 #define MULTIHOP_OSCILLOSCOPE_H
 
-#include "Collection.h"
-
 enum {
   /* Number of readings per message. If you increase this, you may have to
      increase the message_t size. */
   NREADINGS = 5,
   /* Default sampling period. */
   DEFAULT_INTERVAL = 1024,
-  AM_OSCILLOSCOPE = NEW_COLLECTION_CLIENT_ID(),
+  AM_OSCILLOSCOPE = 0x93
 };
 
 typedef nx_struct oscilloscope {
index bed5de605c3b5514b7c0293e3d168b8ff94ba588..6d98ea4a367f23ba583005d64e68280ed0066eec 100644 (file)
@@ -34,14 +34,13 @@ section.
 
 Tools:
 
-The Java application displays readings it receives from motes running the
-MultihopOscilloscope demo via a serial forwarder. To run it, change to the
-TestCollection/java subdirectory and type:
+The Java application displays readings it receives from motes via a
+serial forwarder. To run it, change to the java subdirectory and type:
 
   make
   java net.tinyos.sf.SerialForwarder -comm serial@<serial port>:<baud_rate>
-  # e.g., java net.tinyps.sf.SerialForwarder -comm serial@/dev/ttyUSB0:mica2
-  # or java net.tinyps.sf.SerialForwarder -comm serial@COM2:57600
+  # e.g., java net.tinyos.sf.SerialForwarder -comm serial@/dev/ttyUSB0:mica2
+  # or java net.tinyos.sf.SerialForwarder -comm serial@COM2:57600
   ./run
 
 NOTE::  The baud rate 57600 must be used telos based motes, as its configuration
index 508c093af966f24155f84f6dc932e099f7d938f0..bc2ddceb1d6967743dfec59f0570d913d4ee204b 100644 (file)
  * 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 <platform> threads install.0
- *        make <platform> threads install.500
- *        make <platform> threads install.1000
+ *   i.e. make <platform> cthreads install.0
+ *        make <platform> cthreads install.500
+ *        make <platform> cthreads install.1000
  * 
  * All other nodes can be installed with arbitrary NODE_IDs.
- *   make <platform> threads install.123
+ *   make <platform> cthreads 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,
@@ -54,6 +54,7 @@
  * section.
  *
  * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @author Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
  */
 
 #include "tosthread.h"
@@ -64,8 +65,6 @@
 #include "tosthread_sinesensor.h"
 #include "MultihopOscilloscope.h"
 
-#define MY_COLLECTION_ID 0x02
-
 void fatal_problem();
 void report_problem();
 void report_sent();
@@ -76,7 +75,12 @@ uint8_t reading = 0;   /* 0 to NREADINGS */
 message_t sendbuf;
 message_t recvbuf;
 
-void tosthread_main(void* arg) {
+enum {
+  MY_COLLECTION_ID = NEW_COLLECTION_CLIENT_ID(),   // Gets a collection sender instance
+};
+
+void tosthread_main(void* arg)
+{
   local.interval = DEFAULT_INTERVAL;
   local.id = TOS_NODE_ID;
   local.version = 0;
@@ -84,13 +88,15 @@ void tosthread_main(void* arg) {
   while ( amRadioStart() != SUCCESS );
   while ( collectionRoutingStart() != SUCCESS );
   
-  collectionSetCollectionId(AM_OSCILLOSCOPE, MY_COLLECTION_ID);
+  collectionSetCollectionId(MY_COLLECTION_ID, AM_OSCILLOSCOPE);   // Associates the collection sender
+                                                                  //  with AM_OSCILLOSCOPE collection ID
   
   if (local.id % 500 == 0) {
     while ( amSerialStart() != SUCCESS );
     collectionSetRoot();
     for (;;) {
-      if (collectionReceive(&recvbuf, 0, MY_COLLECTION_ID) == SUCCESS) {
+      // Waits for incoming packets with AM_OSCILLOSCOPE collection ID
+      if (collectionReceive(&recvbuf, 0, AM_OSCILLOSCOPE) == 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));
@@ -109,7 +115,7 @@ void tosthread_main(void* arg) {
           return;
         }
         memcpy(o, &local, sizeof(local));
-        if (collectionSend(&sendbuf, sizeof(local), AM_OSCILLOSCOPE) == SUCCESS) {
+        if (collectionSend(&sendbuf, sizeof(local), MY_COLLECTION_ID) == SUCCESS) {
           local.count++;
           report_sent();
         } else {
@@ -129,7 +135,8 @@ void tosthread_main(void* arg) {
 }
   
 // Use LEDs to report various status issues.
-void fatal_problem() { 
+void fatal_problem()
+{
   led0On(); 
   led1On();
   led2On();