User Tools

Site Tools


tinyos_pritnf

This is an old revision of the document!


Using printf in TinyOS

Printf provides for a pretty fail-safe debugging strategy. It shoots data over the serial port using a TinyOS message wrapper.

The application's Boot interface must be wired to MainC to enable printf output. This is a pretty standard design pattern, so in most cases if you're modifying existing code you won't have to do this.

The interface operates at 115200bps. If you're using the MSP430 platform there can be occasional clock drift.

In TinyOS Code

Simply add #include “printf.h” to all files that require use of the printf function.

#include "printf.h"

Add this to the top level configuration file:

components PrintfC;
components SerialStartC;

Add this to your Makefile:

PFLAGS += -I$(TOSROOT)/tos/lib/printf
PFLAGS += -DNEW_PRINTF_SEMANTICS

On the Host PC

To receive data navigate to the root TinyOS directory and run the following Java applet:

$ java net.tinyos.tools.PrintfClient -comm serial@/dev/ttyUSB0:telosb

Replacing ttyUSB0 with the name of the COM port in your Linux system. To get a list of all available COM ports type ls /dev | grep USB. FTDI-based drivers should automatically install.

Data cannot be simply read from the COM port, TinyOS wraps everything in message structs.

If you see the java app stall at “resynchronizing”, make sure the programmer is set to UART and hit the reset button on the EPIC board if it's there.

tinyos_pritnf.1353991815.txt.gz · Last modified: 2012/11/26 23:50 by wwhuang