[Tinyos-help] Platform specific code sections
Philip Levis
pal at cs.stanford.edu
Thu Mar 1 09:09:33 PST 2007
On Mar 1, 2007, at 7:48 AM, Steve McKown wrote:
>
> The best way to handle platform-specific code is to write
> components that
> abstract the platform specific behavior. So for example, MyComponentC
> implements the platform-agnostic MyComponent interface. Each
> platform has
> its own MyComponentC. The code using MyComponentC is now platform
> agnostic.
> TimerMilliC is a good example of this strategy.
>
> The heart of this concept is documented nicely in TEP2, which
> documents the
> architectural layering strategy for tos2 code:
> http://tinyos.cvs.sourceforge.net/*checkout*/tinyos/tinyos-2.x/doc/
> html/tep2.html
>
> The TinyOS build system must be informed so that it can select the
> right
> MyComponentC.nc file when building for a given platform. To wedge
> the code
> in, you could do something easy, like adding this to your Makefile:
> PFLAGS += platforms/$PLATFORM
>
> This would give your application a separate local directory for
> each platform,
> where you could place platform-specific components. If you are
> doing basic
> things and not creating support for new chipsets or platforms, this
> strategy
> might be good enough. A more comprehensive strategy would be to
> follow the
> tos2 example of /opt/tinyos-2.x/tos/{chips,platforms,etc} using
> the .platform
> file, but this is also far more involved.
This is 100% correct.
Phil
More information about the Tinyos-help
mailing list