Pan17WJ / tinyos-main

Automatically exported from code.google.com/p/tinyos-main
1 stars 0 forks source link

Genericize putchar support for various printf solutions #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Current practice has individual components (PrintfC, SerialPrintfC, and 
PppPrintfC) all implementing the low-level libc interface to whatever function 
libc on a specific platform uses for single-character output.  This patch 
refactors the platform-specific material to a new PutcharP component in 
$(TOSDIR)/lib/printf.  Developers of components that provide printf capability 
should wire their implementation of the Putchar interface, isolating them from 
anything platform-specific.

Tested with apps/tutorials/Printf (PrintfC), apps/TestSerialPrintf 
(SerialPrintfC), and tos/lib/ppp/tests/Ipv6 (PppPrintfC).  FWIW, 
apps/tests/TestPrintf does not build and should be removed.

Original issue reported on code.google.com by pabi...@gmail.com on 17 Apr 2011 at 11:15

Attachments:

GoogleCodeExporter commented 9 years ago
Updated patch that incorporates init capability (for atmel 128 systems).

Original comment by pabi...@gmail.com on 17 Apr 2011 at 11:34

Attachments:

GoogleCodeExporter commented 9 years ago
Hi, pabigot

I've applied your two patches, but got the following error:
$ make iris
......
In file included from 
/home/qy/git/tinyos-2.x.svn/tos/lib/serialprintf/SerialPrintfP.nc:44,
                 from /home/qy/git/tinyos-2.x.svn/tos/lib/serialprintf/SerialPrintfC.nc:41,
                 from TestAppC.nc:46:
In interface `Putchar':
/home/qy/git/tinyos-2.x.svn/tos/lib/printf/Putchar.nc:42: syntax error before 
`('
In component `SerialPrintfP':
/home/qy/git/tinyos-2.x.svn/tos/lib/serialprintf/SerialPrintfP.nc:64: syntax 
error before `('
make: *** [exe0] Error 1

It seems "putchar" can't be used as a command name, for it is a macro defined 
in avr_stdio.h. 
After I rename it, the application compiles and gets on well with IRIS.

Another suggestion:
Add -I$(TOSDIR)/lib/printf in Makefile seems strange when 
-I$(TOSDIR)/lib/serialprintf is already added. 
I suggest move avr_stdio.h to tos/chips/atm128/, and implement PutcharP.nc 
separately under tos/chips/{atm128, msp430, m16c60} without ifdefs to make it 
more clear and easier to port to new platforms.

Original comment by qy.n...@gmail.com on 17 Apr 2011 at 12:57

GoogleCodeExporter commented 9 years ago
The attached patch should avoid the need to rename anything.

I'd support unifying lib/serialprintf into lib/printf.  I don't support 
spraying PutcharP.nc out to every platform directory; it's not chip-dependent, 
but toolchain-dependent.  In my opinion, putting it in one place simplifies 
maintainability: easy to find, and having found it you see examples of how it's 
handled in other toolchains.

Why doesn't avr_studio.h come from the AVR toolchain, anyway?  What's it doing 
in tinyos, declaring huge amounts of garbage that isn't used?  Since the logs 
imply it exists to support a legacy avr interface, it'd be better to replace 
its use with whatever the current toolchain provides.

Original comment by pabi...@gmail.com on 17 Apr 2011 at 2:35

Attachments:

GoogleCodeExporter commented 9 years ago
Never mind that previous patch; I found an avr toolchain, and it doesn't work.

Original comment by pabi...@gmail.com on 17 Apr 2011 at 2:37

GoogleCodeExporter commented 9 years ago
Better patch attached.  This builds; I can't test whether it works.  It 
eliminates use of avr_stdio.h in favor of avr-libc's version.  Dunno why it was 
originally added; the commit comment is lacking in explanation.

Original comment by pabi...@gmail.com on 17 Apr 2011 at 3:03

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by philip.l...@gmail.com on 20 Apr 2011 at 4:47

GoogleCodeExporter commented 9 years ago
SVN 5584 merges serialprintf into printf
SVN 5585 incorporates the Putchar interface
Tested on tmote and iris (build only)

Original comment by pabi...@gmail.com on 15 May 2011 at 3:44