📄 mote-mote radio communication - tinyos documentation wiki.htm
字号:
rather than interrupt context (events that have the <CODE>async</CODE> keyword
can execute in interrupt context). Since the TinyOS execution model allows
only one task to execute at a time, if all accesses to a variable occur in
task context, then no race conditions will occur for that variable. Since all
accesses to <CODE>counter</CODE> occur in task context, no critical sections
are needed when accessing it. </P>
<LI><B>Update the implementation block of the application configuration file
by adding a components statement for each component used that provides one of
the interfaces chosen earlier.</B> <BR>The following lines can be added just
below the existing <CODE>components</CODE> declarations in the implementation
block of <CODE>BlinkToRadioAppsC.nc</CODE>: <PRE>implementation {
...
components new AMReceiverC(AM_BLINKTORADIO);
...
}
</PRE>
<P>This statement means that a new instance of <CODE>AMReceiverC</CODE> will
be created. <CODE>AMReceiver</CODE> is a generic, parameterized component. The
<CODE>new</CODE> keyword indicates that a new instance of
<CODE>AMReceiverC</CODE> will be created. The <CODE>AM_BLINKTORADIO</CODE>
parameter indicates the AM type of the <CODE>AMReceiverC</CODE> and is chosen
to be the same as that used for the <CODE>AMSenderC</CODE> used earlier, which
ensures that the same AM type is being used for both transmissions and
receptions. <CODE>AM_BLINKTORADIO</CODE> is defined in the
<CODE>BlinkToRadio.h</CODE> header file. </P>
<LI><B>Wire the the interfaces used by the application to the components which
provide those interfaces.</B> <BR>Update the wiring by insert the following
line just before the closing brace of the <CODE>implementation</CODE> block in
BlinkToRadioAppC: <PRE>implementation {
...
App.Receive -> AMReceiverC;
}
</PRE>
<LI><B>Test your application!</B> <BR>Testing your application is easy. Get
two motes. They can be mica2, micaz, telosa, telosb, or tmote. For this
exercise, let's assume that the motes are telosb (if not, skip past the
motelist part and program the mote using whatever the appropriate programmer
parameters are for your hardware). Assuming you are using a telosb, first open
a Cygwin or Linux shell and cd to the <CODE>apps/tutorials/BlinkToRadio</CODE>
directory. Then, insert the first telosb mote into an available USB port on
the PC and type <CODE>motelist</CODE> the at the Cygwin or Linux prompt ($).
You should see exactly one mote listed. For example: <PRE>$ motelist
Reference CommPort Description
---------- ---------- ----------------------------------------
UCC89MXV COM17 Telos (Rev B 2004-09-27)
</PRE>
<P>Now, assuming you are in the <CODE>apps/tutorials/BlinkToRadio</CODE>
directory, type <CODE>make telosb install,1</CODE>. You should see a lot text
scroll by that looks something like: </P><PRE>$ make telosb install,1
mkdir -p build/telosb
compiling BlinkToRadioAppC to a telosb binary
ncc -o build/telosb/main.exe -Os -O -mdisable-hwmul -Wall -Wshadow -DDEF_TOS_AM_GROUP=0x7d
-Wnesc-all -target=telosb -fnesc-cfile=build/telosb/app.c -board= BlinkToRadioAppC.nc -lm
compiled BlinkToRadioAppC to build/telosb/main.exe
9040 bytes in ROM
246 bytes in RAM
msp430-objcopy --output-target=ihex build/telosb/main.exe build/telosb/main.ihex
writing TOS image
tos-set-symbols --objcopy msp430-objcopy --objdump msp430-objdump --target ihex build/telosb/main.ihex
build/telosb/main.ihex.out-1 TOS_NODE_ID=1 ActiveMessageAddressC$addr=1
found mote on COM17 (using bsl,auto)
installing telosb binary using bsl
tos-bsl --telosb -c 16 -r -e -I -p build/telosb/main.ihex.out-1
MSP430 Bootstrap Loader Version: 1.39-telos-8
Mass Erase...
Transmit default password ...
Invoking BSL...
Transmit default password ...
Current bootstrap loader version: 1.61 (Device ID: f16c)
Changing baudrate to 38400 ...
Program ...
9072 bytes programmed.
Reset device ...
rm -f build/telosb/main.exe.out-1 build/telosb/main.ihex.out-1
</PRE>
<P>Now, remove the first telosb from the USB port, insert the batteries, and
set it aside. Insert the second telos into the USB port and once again type
<CODE>motelist</CODE>. You should again see something like: </P><PRE>$ motelist
Reference CommPort Description
---------- ---------- ----------------------------------------
UC9VN03I COM14 Telos (Rev B 2004-09-27)
</PRE>
<P>Finally, type <CODE>make telosb reinstall,2</CODE> and you should once
again see something like the following scroll by: </P><PRE>$ make telosb reinstall,2
tos-set-symbols --objcopy msp430-objcopy --objdump msp430-objdump --target ihex build/telosb/main.ihex
build/telosb/main.ihex.out-2 TOS_NODE_ID=2 ActiveMessageAddressC$addr=2
found mote on COM14 (using bsl,auto)
installing telosb binary using bsl
tos-bsl --telosb -c 13 -r -e -I -p build/telosb/main.ihex.out-2
MSP430 Bootstrap Loader Version: 1.39-telos-8
Mass Erase...
Transmit default password ...
Invoking BSL...
Transmit default password ...
Current bootstrap loader version: 1.61 (Device ID: f16c)
Changing baudrate to 38400 ...
Program ...
9072 bytes programmed.
Reset device ...
rm -f build/telosb/main.exe.out-2 build/telosb/main.ihex.out-2
</PRE>
<P><B><FONT color=red>At this point, both motes should be blinking their
LEDs.</FONT></B> If you press the RESET button on either telosb, then the LEDs
on the <I>other</I> telosb will pause on whatever was being displayed at the
moment you pressed RESET. When you release the RESET the button, the paused
mote will be reset and then resume counting from one. </P></LI></OL><A
name=Conclusions></A>
<H1><SPAN class=mw-headline>Conclusions</SPAN></H1>
<P>This lesson has introduced radio communications TinyOS 2.x. </P><A
name=Related_Documentation></A>
<H1><SPAN class=mw-headline>Related Documentation</SPAN></H1>
<OL class=references>
<LI id=_note-fn1>↑ <SUP><A title=""
href="http://docs.tinyos.net/index.php/Mote-mote_radio_communication#_ref-fn1_0">1.0</A></SUP>
<SUP><A title=""
href="http://docs.tinyos.net/index.php/Mote-mote_radio_communication#_ref-fn1_1">1.1</A></SUP>
<A class="external text"
title=http://www.tinyos.net/tinyos-2.x/doc/html/tep111.html
href="http://www.tinyos.net/tinyos-2.x/doc/html/tep111.html" rel=nofollow>TEP
111: message_t</A>
<LI id=_note-fn3><A title=""
href="http://docs.tinyos.net/index.php/Mote-mote_radio_communication#_ref-fn3_0">↑</A>
<B>Programming Hint 15:</B>Always use platform independent types when defining
message formats. From Phil Levis' <A class="external text"
title=http://csl.stanford.edu/~pal/pubs/tinyos-programming-1-0.pdf
href="http://csl.stanford.edu/~pal/pubs/tinyos-programming-1-0.pdf"
rel=nofollow><I>TinyOS Programming</I></A>
<LI id=_note-fn4><A title=""
href="http://docs.tinyos.net/index.php/Mote-mote_radio_communication#_ref-fn4_0">↑</A>
<B>Programming Hint 16:</B>If you have to perform significant computation on a
platform independent type or access it many (hundreds or more) times, then
temporarily copying it to a native type can be a good idea. From Phil Levis'
<A class="external text"
title=http://csl.stanford.edu/~pal/pubs/tinyos-programming-1-0.pdf
href="http://csl.stanford.edu/~pal/pubs/tinyos-programming-1-0.pdf"
rel=nofollow><I>TinyOS Programming</I></A></LI></OL>
<HR>
<CENTER>
<P>< <B><A title="Modules and the TinyOS Execution Model"
href="http://docs.tinyos.net/index.php/Modules_and_the_TinyOS_Execution_Model">Previous
Lesson</A></B> | <B><A title="Mote-mote radio communication"
href="http://docs.tinyos.net/index.php/Mote-mote_radio_communication#Introduction">Top</A></B>
| <B><A title="Mote-PC serial communication and SerialForwarder"
href="http://docs.tinyos.net/index.php/Mote-PC_serial_communication_and_SerialForwarder">Next
Lesson</A> ></B> </P></CENTER><!-- Saved in parser cache with key tinyosdocs:pcache:idhash:9-0!1!0!!en!2!edit=0 and timestamp 20080401121724 -->
<DIV class=printfooter>Retrieved from "<A
href="http://docs.tinyos.net/index.php/Mote-mote_radio_communication">http://docs.tinyos.net/index.php/Mote-mote_radio_communication</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/Mote-mote_radio_communication">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:Mote-mote_radio_communication&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=Mote-mote_radio_communication&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=Mote-mote_radio_communication&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=Mote-mote_radio_communication">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/Mote-mote_radio_communication">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/Mote-mote_radio_communication">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=Mote-mote_radio_communication&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=Mote-mote_radio_communication&oldid=852">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="Mote-mote radio communication - TinyOS Documentation Wiki.files/poweredby_mediawiki_88x31.png"></A></DIV>
<UL id=f-list>
<LI id=lastmod>This page was last modified 10:39, 28 March 2008.
<LI id=viewcount>This page has been accessed 1,380 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.308 secs. --></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -