From Lorien Documentation
Jump to: navigation, search

Lorien components do not use `printf' to generate output to stdout. Instead they use the ILog interface which performs much the same task as printf.

Its interface is defined as:

interface ILog{
   int log(char *str, ...);

To use it we declare a required interface of type ILog, for example ILog *output, and in our configuration fragment specify the connectivity of this interface to the desired component, usually Output (see the component development tutorial for example usage).

We can then invoke its log function just like printf, for example:

output -> log("Hello!\n")


output -> log("The value of n is currently %u\n", n);

The % is used exactly as in printf to indicate the format of the variable that should be printed out here, and must match the type of the corresponding variable in the parameter list.

Currently supported format specifiers on the TelosB platform are:

 %u unsigned int
 %i signed int
 %lu unsigned long
 %l signed long
 %p pointer (the pointer value is printed in hex)
 %s character string

Note the printing of floating point numbers is not currently supported on the TelosB platform.

Personal tools