Debugging NesC made easy with Printf library

Put watch , breakpoints ... all sort of such powerful debugging we miss when we do tinyos and nesc. I had a good struggle to find out what went wrong in a code till I figured out serialforwarder and the libraries to print values in between. This again needs many routine calls and stuffs.
To make things easier, there is a library "tinyos printf". Anyone who had used printf in C, same syntax will work. This post is on how to use tinyos printf library.
Before we begin, I assume that you are familiar with serialforwarder interface and simple blink application. Again the screenshots are done with original mote. Avrora users can do the same with micaz compilation, then follow the post using serialforwarder interface with avrora.

This is simple application which generates random numbers with Random interface and prints the value to the screen. All you need is
  1. Include printf path in Makefile
  2. Include printf.h in your application
  3. Invoke the Serialforwarder
  4. Type java and see the output.
The screenshots are given below.

The corresponding files can be found here

Related posts
Running tinyos programs using avrora
Using Serialforwarder with Avrora