X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=apps%2Ftutorials%2FPrintf%2FTestPrintfC.nc;h=9d35c464cb1084fc6b51ca85ba10b9763e602594;hb=e7e66ced6080596f50597ebeb827a0b5f02b0701;hp=47fe191bed1fb170210cb9262f2831b8573d07ec;hpb=2f3b4d843e48cfe098d8b01159d756fddd6420b8;p=tinyos-2.x.git diff --git a/apps/tutorials/Printf/TestPrintfC.nc b/apps/tutorials/Printf/TestPrintfC.nc index 47fe191b..9d35c464 100644 --- a/apps/tutorials/Printf/TestPrintfC.nc +++ b/apps/tutorials/Printf/TestPrintfC.nc @@ -37,52 +37,21 @@ #include "printf.h" module TestPrintfC { uses { - interface Boot; - interface Leds; - interface SplitControl as PrintfControl; - interface PrintfFlush; + interface Boot; } } implementation { - #define NUM_TIMES_TO_PRINT 5 - uint16_t counter=0; uint8_t dummyVar1 = 123; uint16_t dummyVar2 = 12345; uint32_t dummyVar3 = 1234567890; event void Boot.booted() { - call PrintfControl.start(); - } - - event void PrintfControl.startDone(error_t error) { 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); - call PrintfFlush.flush(); - } - - event void PrintfControl.stopDone(error_t error) { - counter = 0; - call Leds.led2Toggle(); - 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\ncharacters since that is the limit of the size I put on my\nmaximum buffer when I instantiated the PrintfC component.\n"); - printf("Only part of this line should get printed because by writing\nthis sentence, I go over my character limit that the internal Printf buffer can hold.\n"); - call PrintfFlush.flush(); - } - else call PrintfControl.stop(); - counter++; + printfflush(); } }