]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - apps/tests/TestPrintf/TestPrintfC.nc
added a README.txt, updated source code documentation
[tinyos-2.x.git] / apps / tests / TestPrintf / TestPrintfC.nc
index c9b0716076f99eaa0b08c87e388f54f4def5db75..cb968d001027e5f7c2b79e827ba1d4e2b47f4335 100644 (file)
  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
  * MODIFICATIONS."
  */
+
 /**
  *
- * This application is used to test the basic functionality of the printf service.  
- * It is initiated by calling the start() command of the SplitControl interface 
- * provided by the PrintfC component.  After starting the printf service, calls to 
- * the standard c-style printf command are made to print various strings of text 
- * over the serial line.  Only upon calling PrintfFlush.flush() does the data 
- * actually get sent out over the serial line.
+ * This application is used to test the basic functionality of the printf service.
+ * Calls to the standard c-style printf command are made to print various strings
+ * of text over the serial line.  Only upon calling printfflush() does the
+ * data actually get sent out over the serial line.
  *
  * @author Kevin Klues (klueska@cs.wustl.edu)
  * @version $Revision$
  * @date $Date$
  */
 
+#include "printf.h"
 module TestPrintfC {
   uses {
-    interface Boot;  
-    interface Leds;
-    interface SplitControl as PrintfControl;
-    interface PrintfFlush;
+    interface Boot;
   }
 }
 implementation {
-       
-  #define NUM_TIMES_TO_PRINT   100
-  uint16_t counter=0;
-  uint32_t dummyVar = 345678;
 
-  event void Boot.booted() {
-    call PrintfControl.start();
-  }
-  
-  event void PrintfControl.startDone(error_t error) {
-       printf("Hi my name is Kevin Klues and I am writing to you from my telos mote\n");
-       printf("Here is a uint8: %hd\n", 123);
-       printf("Here is a uint16: %d\n", 12345);
-       printf("Here is a uint32: %ld\n", 1234567890);
-       call PrintfFlush.flush();
-  }
+  uint8_t dummyVar1 = 123;
+  uint16_t dummyVar2 = 12345;
+  uint32_t dummyVar3 = 1234567890;
 
-  event void PrintfControl.stopDone(error_t error) {
-       counter = 0;
-       printf("This should not be printed...");
-       call PrintfFlush.flush();
-  }
-  
-  event void PrintfFlush.flushDone(error_t error) {
-       if(counter < NUM_TIMES_TO_PRINT) {
-      printf("I am now iterating: %d\n", counter);
-         call PrintfFlush.flush();
-    }
-    else if(counter == NUM_TIMES_TO_PRINT) {
-      printf("This is a really short string...\n");
-      printf("I am generating this string to have just less than 250 characters since that is the limit of the size I put on my maximum buffer when I instantiated the PrintfC component.\n");
-      printf("Only part of this line should get printed because by writing this sentence, I go over my character limit that the internal Printf buffer can hold.  If I were to flush before trying to write this, or increase my buffer size when I instantiate my PrintfC component to 1000, we would see this line too\n");
-      call PrintfFlush.flush();
-    }
-    else call PrintfControl.stop();
-    counter++;
+  event void Boot.booted() {
+       printf("Hi I am writing to you from my TinyOS application!!\n");
+       printf("Here is a uint8: %u\n", dummyVar1);
+       printf("Here is a uint16: %u\n", dummyVar2);
+       printf("Here is a uint32: %ld\n", dummyVar3);
+       printfflush();
   }
 }