[Tinyos-devel] Re: [Tinyos-help] Question about printf

Philip Levis pal at cs.stanford.edu
Fri Sep 21 15:43:29 PDT 2007


On Sep 21, 2007, at 2:18 PM, Kevin Klues wrote:

> I wanted to get a sense of how many people out there use the printf
> library provided in TinyOS 2.0.  As its written right now, its not the
> easiest thing to use since an application has to explicitly flush the
> printf buffer itself and any printf commands called while flushing
> will all fail.
>
> My question is whether people would prefer to have a bit more user
> friendly version of printf.  I have an alternate implementation where
> all that needs to be done to use printf is to include tos/lib/printf
> in your include path in your makefile.  No wiring, no nothing.  Just
> call printf() anywhere in your code and see the output spit out over
> the serial line.  Flushing is done automatically, and bytes can also
> be written to the printf buffer while this flush is occurring.  Since
> flushing is only triggered when the print buffer has a certain number
> of bytes in it, explicit flushes are of course possible, by wiring in
> a PrintfFlush interface from the PrintfC component.
>
> The reason I'm bringing all of this up is that this version of the
> printf library is incompatible with the version in previous releases.
> Would people prefer to have this newer version overwrite the current
> one (possibly breaking existing code), or be provided as an alternate
> printf service in some way?  Comments are welcome.

One issue that comes up here is hidden dependencies; if might be some  
component somewhere calls printf() but it happens some other  
subsystem included it in a configuration. If you try to incorporate  
the first into another app, then you might get mysterious compilation  
errors about printf() not being defined.

The only way TOSSIM gets away with dbg() is by incorporating it into  
tos.h.

Since your printf() is a bit different than printf(3), you might want  
a similar but distinct name.

Phil


More information about the Tinyos-devel mailing list