tinyos toolchain - tinyos documentation wiki.htm
来自「从官方网站上下载tinyos2.0的学习指南」· HTM 代码 · 共 475 行 · 第 1/2 页
HTM
475 行
and Java tools: </P><PRE>COMPONENT=RadioCountToLedsAppC
<B>BUILD_EXTRA_DEPS = RadioCountMsg.py RadioCountMsg.class</B>
RadioCountMsg.py: RadioCountToLeds.h
mig python -target=$(PLATFORM) $(CFLAGS) -python-classname=RadioCountMsg RadioCountToLeds.h RadioCountMsg -o $@
RadioCountMsg.class: RadioCountMsg.java
javac RadioCountMsg.java
RadioCountMsg.java: RadioCountToLeds.h
mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=RadioCountMsg RadioCountToLeds.h RadioCountMsg -o $@
include $(MAKERULES)
</PRE>
<P>The first and last line of this Makefile are the basic lines present in all
TinyOS Makefiles; the line in bold defining BUILD_EXTRA_DEPS specifies some
additional <I>make</I> targets to build alongside the main TinyOS application
(if you are not familiar with make, this may be a good time to read a make
tutorial, e.g., <A class="external text"
title=http://oucsace.cs.ohiou.edu/~bhumphre/makefile.html
href="http://oucsace.cs.ohiou.edu/~bhumphre/makefile.html" rel=nofollow>this
one</A>). </P>
<P>When you compile RadioCountToLeds for the first time, you will see that the
two extra targets, <CODE>RadioCountMsg.py</CODE> and
<CODE>RadioCountMsg.class</CODE>, are automatically created: </P><PRE>$ make mica2
mkdir -p build/mica2
mig python -target=mica2 -python-classname=RadioCountMsg RadioCountToLeds.h RadioCountMsg -o RadioCountMsg.py
mig java -target=mica2 -java-classname=RadioCountMsg RadioCountToLeds.h RadioCountMsg -o RadioCountMsg.java
javac RadioCountMsg.java
compiling RadioCountToLedsAppC to a mica2 binary
...
</PRE>
<P>As this Makefile is written, these generated files are not deleted when you
execute <CODE>make clean</CODE>. Fix this by adding the following line: </P><PRE>CLEAN_EXTRA = $(BUILD_EXTRA_DEPS) RadioCountMsg.java
</PRE>
<P>to <CODE>apps/RadioCountToLeds/Makefile</CODE>. This defines the CLEAN_EXTRA
make variable to be the same as BUILD_EXTRA_DEPS, with RadioCountMsg.java added
to the end. The build system's <B>clean</B> target deletes all files in
CLEAN_EXTRA: </P><PRE>$ make clean
rm -rf build RadioCountMsg.py RadioCountMsg.class RadioCountMsg.java
rm -rf _TOSSIMmodule.so TOSSIM.pyc TOSSIM.py
</PRE>
<P>Finally, to see how to pass options to the nesC compiler, we will change
RadioCountToLeds's source code to set the message sending period based on the
preprocessor symbol <CODE>SEND_PERIOD</CODE>. Change the line in
<CODE>RadioCountToLedsC.nc</CODE> that reads </P><PRE> call MilliTimer.startPeriodic(1000);
</PRE>
<P>to </P><PRE> call MilliTimer.startPeriodic(SEND_PERIOD);
</PRE>
<P>and add the following line to RadioCountToLeds's Makefile: </P><PRE>CFLAGS += -DSEND_PERIOD=2000
</PRE>
<P>Note the use of <CODE>+=</CODE> when defining CFLAGS: this allows the user to
also pass options to nesC when invoking make as we saw above (<CODE>env CFLAGS=x
make ...</CODE>). </P>
<P>Now compiling RadioCountToLeds gives: </P><PRE>$ make mica2
...
compiling RadioCountToLedsAppC to a mica2 binary
ncc -o build/mica2/main.exe ... <B>-DSEND_PERIOD=2000</B> ... RadioCountToLedsAppC.nc -lm
compiled RadioCountToLedsAppC to build/mica2/main.exe
...
</PRE><A name=TinyOS_Tools></A>
<H1><SPAN class=mw-headline>TinyOS Tools</SPAN></H1>
<P>The TinyOS build system is designed to make it easier to write Makefiles for
applications that support multiple platforms, programmers, etc in a uniform way.
However, it's use is not compulsory, and all the tools it is built on can be
used in your own build system (e.g., your own Makefile or simple build script).
Below we show how to build and install the RadioCountToLeds application for a
micaz with the mib510 programmer using just a few commands. </P>
<P>First, we compile RadioCountToLedsAppC.nc (the main component of the
application) using the nesC compiler, ncc: </P><PRE>$ ncc -target=micaz -o rcl.exe -Os -finline-limit=100000 -Wnesc-all -Wall RadioCountToLedsAppC.nc
</PRE>
<P>This generates an executable file, <CODE>rcl.exe</CODE>. Next, we want to
install this program on a mote with mote id 15. First, we create a new
executable, <CODE>rcl.exe-15</CODE>, where the variables storing the mote's
identity are changed to 15, using the <CODE>tos-set-symbols</CODE> command: </P><PRE>$ tos-set-symbols rcl.exe rcl.exe-15 TOS_NODE_ID=15 ActiveMessageAddressC\$addr=15
</PRE>
<P>Finally, we install this executable on the micaz using <CODE>uisp</CODE>, to
a mib510 programmer connected to port /dev/ttyUSB1: </P><PRE>$ uisp -dpart=ATmega128 -dprog=mib510 -dserial=/dev/ttyUSB1 --erase --upload if=rcl.exe-15
Firmware Version: 2.1
Atmel AVR ATmega128 is found.
Uploading: flash
</PRE>
<P>If you wish to follow this route, note two things: first, you can find out
what commands the build system is executing by passing the <CODE>-n</CODE>
option to make, which tells it to print rather than execute commands: </P><PRE>$ make -n micaz install.15 mib510
mkdir -p build/micaz
echo " compiling RadioCountToLedsAppC to a micaz binary"
ncc -o build/micaz/main.exe -Os -finline-limit=100000 -Wall -Wshadow -Wnesc-all -target=micaz
-fnesc-cfile=build/micaz/app.c -board=micasb -fnesc-dump=wiring -fnesc-dump='interfaces(!abstract())'
-fnesc-dump='referenced(interfacedefs, components)' -fnesc-dumpfile=build/micaz/wiring-check.xml RadioCountToLedsAppC.nc -lm
nescc-wiring build/micaz/wiring-check.xml
...
</PRE>
<P>Second, all the commands invoked by the build system should have man pages
describing their behaviour and options. For instance, try the following
commands: </P><PRE>$ man tos-set-symbols
$ man ncc
$ man nescc
</PRE><A name=Related_Documentation></A>
<H1><SPAN class=mw-headline>Related Documentation</SPAN></H1>
<UL>
<LI>mica mote Getting Started Guide at <A class="external text"
title=http://www.xbow.com href="http://www.xbow.com/"
rel=nofollow>Crossbow</A>
<LI>telos mote Getting Started Guide for <A class="external text"
title=http://www.moteiv.com href="http://www.moteiv.com/"
rel=nofollow>Moteiv</A>
<LI><A title="Getting Started with TinyOS"
href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS">Lesson
1</A> introduced the build system.
<LI><A title=Platforms
href="http://docs.tinyos.net/index.php/Platforms">Lesson 10</A> describes how
to add a new platform to the build system.
<LI>GNU make man page.
<LI>man pages for the nesC compiler (man ncc, man nescc) and the various
TinyOS tools. </LI></UL>
<P><BR></P>
<HR>
<CENTER>
<P>< <B><A title="Network Protocols"
href="http://docs.tinyos.net/index.php/Network_Protocols">Previous
Lesson</A></B> | <B><A title=""
href="http://docs.tinyos.net/index.php/TinyOS_Toolchain#TinyOS_Build_System">Top</A></B>
| <B><A title="TinyOS Tutorials"
href="http://docs.tinyos.net/index.php/TinyOS_Tutorials#Building_a_simple_but_full-featured_application">Next
Lesson </A>></B> </P></CENTER><!-- Saved in parser cache with key tinyosdocs:pcache:idhash:18-0!1!0!!en!2!edit=0 and timestamp 20080401120244 -->
<DIV class=printfooter>Retrieved from "<A
href="http://docs.tinyos.net/index.php/TinyOS_Toolchain">http://docs.tinyos.net/index.php/TinyOS_Toolchain</A>"</DIV><!-- end content -->
<DIV class=visualClear></DIV></DIV></DIV></DIV>
<DIV id=column-one>
<DIV class=portlet id=p-cactions>
<H5>Views</H5>
<DIV class=pBody>
<UL>
<LI class=selected id=ca-nstab-main><A title="View the content page [c]"
accessKey=c
href="http://docs.tinyos.net/index.php/TinyOS_Toolchain">Article</A>
<LI class=new id=ca-talk><A title="Discussion about the content page [t]"
accessKey=t
href="http://docs.tinyos.net/index.php?title=Talk:TinyOS_Toolchain&action=edit">Discussion</A>
<LI id=ca-viewsource><A
title="This page is protected. You can view its source. [e]" accessKey=e
href="http://docs.tinyos.net/index.php?title=TinyOS_Toolchain&action=edit">View
source</A>
<LI id=ca-history><A title="Past versions of this page. [h]" accessKey=h
href="http://docs.tinyos.net/index.php?title=TinyOS_Toolchain&action=history">History</A>
</LI></UL></DIV></DIV>
<DIV class=portlet id=p-personal>
<H5>Personal tools</H5>
<DIV class=pBody>
<UL>
<LI id=pt-login><A
title="You are encouraged to log in, it is not mandatory however. [o]"
accessKey=o
href="http://docs.tinyos.net/index.php?title=Special:Userlogin&returnto=TinyOS_Toolchain">Log
in / create account</A> </LI></UL></DIV></DIV>
<DIV class=portlet id=p-logo><A title="Visit the Main Page [z]"
style="BACKGROUND-IMAGE: url(/images/tos-jwall-small.jpg)" accessKey=z
href="http://docs.tinyos.net/index.php/Main_Page"></A></DIV>
<SCRIPT type=text/javascript> if (window.isMSIE55) fixalpha(); </SCRIPT>
<DIV class=portlet id=p-navigation>
<H5>Navigation</H5>
<DIV class=pBody>
<UL>
<LI id=n-mainpage><A title="Visit the Main Page [z]" accessKey=z
href="http://docs.tinyos.net/index.php/Main_Page">Main Page</A>
<LI id=n-portal><A
title="About the project, what you can do, where to find things"
href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:Community_Portal">Community
portal</A>
<LI id=n-currentevents><A
title="Find background information on current events"
href="http://docs.tinyos.net/index.php/Current_events">Current events</A>
<LI id=n-recentchanges><A title="The list of recent changes in the wiki. [r]"
accessKey=r
href="http://docs.tinyos.net/index.php/Special:Recentchanges">Recent
changes</A>
<LI id=n-randompage><A title="Load a random page [x]" accessKey=x
href="http://docs.tinyos.net/index.php/Special:Random">Random page</A>
<LI id=n-help><A title="The place to find out."
href="http://docs.tinyos.net/index.php/Help:Contents">Help</A>
<LI id=n-sitesupport><A title="Support us"
href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:Site_support">Donations</A>
</LI></UL></DIV></DIV>
<DIV class=portlet id=p-search>
<H5><LABEL for=searchInput>Search</LABEL></H5>
<DIV class=pBody id=searchBody>
<FORM id=searchform action=/index.php/Special:Search>
<DIV><INPUT id=searchInput title="Search TinyOS Documentation Wiki [f]"
accessKey=f name=search> <INPUT class=searchButton id=searchGoButton type=submit value=Go name=go> <INPUT class=searchButton id=mw-searchButton type=submit value=Search name=fulltext>
</DIV></FORM></DIV></DIV>
<DIV class=portlet id=p-tb>
<H5>Toolbox</H5>
<DIV class=pBody>
<UL>
<LI id=t-whatlinkshere><A title="List of all wiki pages that link here [j]"
accessKey=j
href="http://docs.tinyos.net/index.php/Special:Whatlinkshere/TinyOS_Toolchain">What
links here</A>
<LI id=t-recentchangeslinked><A
title="Recent changes in pages linked from this page [k]" accessKey=k
href="http://docs.tinyos.net/index.php/Special:Recentchangeslinked/TinyOS_Toolchain">Related
changes</A>
<LI id=t-upload><A title="Upload images or media files [u]" accessKey=u
href="http://docs.tinyos.net/index.php/Special:Upload">Upload file</A>
<LI id=t-specialpages><A title="List of all special pages [q]" accessKey=q
href="http://docs.tinyos.net/index.php/Special:Specialpages">Special pages</A>
<LI id=t-print><A title="Printable version of this page [p]" accessKey=p
href="http://docs.tinyos.net/index.php?title=TinyOS_Toolchain&printable=yes">Printable
version</A>
<LI id=t-permalink><A title="Permanent link to this version of the page"
href="http://docs.tinyos.net/index.php?title=TinyOS_Toolchain&oldid=297">Permanent
link</A> </LI></UL></DIV></DIV></DIV><!-- end of the left (by default at least) column -->
<DIV class=visualClear></DIV>
<DIV id=footer>
<DIV id=f-poweredbyico><A href="http://www.mediawiki.org/"><IMG
alt="Powered by MediaWiki"
src="TinyOS Toolchain - TinyOS Documentation Wiki.files/poweredby_mediawiki_88x31.png"></A></DIV>
<UL id=f-list>
<LI id=lastmod>This page was last modified 23:26, 29 December 2007.
<LI id=viewcount>This page has been accessed 574 times.
<LI id=privacy><A title="TinyOS Documentation Wiki:Privacy policy"
href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:Privacy_policy">Privacy
policy</A>
<LI id=about><A title="TinyOS Documentation Wiki:About"
href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:About">About
TinyOS Documentation Wiki</A>
<LI id=disclaimer><A title="TinyOS Documentation Wiki:General disclaimer"
href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:General_disclaimer">Disclaimers</A>
</LI></UL></DIV>
<SCRIPT type=text/javascript>if (window.runOnloadHook) runOnloadHook();</SCRIPT>
</DIV><!-- Served in 0.263 secs. --></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?