http://tinyos.stanford.edu/tinyos-wiki/index.php?title=Mote-mote_radio_communication_(TOS_2.1.1)&feed=atom&action=historyMote-mote radio communication (TOS 2.1.1) - Revision history2024-03-28T09:35:43ZRevision history for this page on the wikiMediaWiki 1.31.14http://tinyos.stanford.edu/tinyos-wiki/index.php?title=Mote-mote_radio_communication_(TOS_2.1.1)&diff=4486&oldid=prevStevewchiang: /* Sending a Message */2010-10-12T15:40:26Z<p><span dir="auto"><span class="autocomment">Sending a Message</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 15:40, 12 October 2010</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l201" >Line 201:</td>
<td colspan="2" class="diff-lineno">Line 201:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>   }</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>   }</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>  }</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>  }</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>This code performs several operations. First, it ensures that a message transmission is not in progress by checking the busy flag. Then it gets the packet's payload portion and casts it to a pointer to the previously declared <code>BlinkToRadioMsg</code> external type. It can now use this pointer to initialise the packet's fields, and then send the packet by calling <code>AMSend.send</code>. The packet is sent to all nodes in radio range by <del class="diffchange diffchange-inline">specyfing </del><code>AM_BROADCAST_ADDR</code> as the destination address. Finally, the test against SUCCESS verifies that the AM layer accepted the message for transmission. If so, the busy flag is set to true. For the duration of the send attempt, the packet is owned by the radio, and user code must not access it. Note that we could have avoided using the <code>Packet</code> interface, as it's <code>getPayload</code> command is repeated within <code>AMSend</code>.</div></td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>This code performs several operations. First, it ensures that a message transmission is not in progress by checking the busy flag. Then it gets the packet's payload portion and casts it to a pointer to the previously declared <code>BlinkToRadioMsg</code> external type. It can now use this pointer to initialise the packet's fields, and then send the packet by calling <code>AMSend.send</code>. The packet is sent to all nodes in radio range by <ins class="diffchange diffchange-inline">specifying </ins><code>AM_BROADCAST_ADDR</code> as the destination address. Finally, the test against SUCCESS verifies that the AM layer accepted the message for transmission. If so, the busy flag is set to true. For the duration of the send attempt, the packet is owned by the radio, and user code must not access it. Note that we could have avoided using the <code>Packet</code> interface, as it's <code>getPayload</code> command is repeated within <code>AMSend</code>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><li>'''Implement any (non-initialization) events specified in the interfaces we plan on using.'''</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><li>'''Implement any (non-initialization) events specified in the interfaces we plan on using.'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><BR>Looking through the <code>Packet</code>, <code>AMPacket</code>, and <code>AMSend</code> interfaces, we see that there is only one <code>event</code> we need to worry about, <code>AMSend.sendDone</code>:</li>  </div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><BR>Looking through the <code>Packet</code>, <code>AMPacket</code>, and <code>AMSend</code> interfaces, we see that there is only one <code>event</code> we need to worry about, <code>AMSend.sendDone</code>:</li>  </div></td></tr>
</table>Stevewchianghttp://tinyos.stanford.edu/tinyos-wiki/index.php?title=Mote-mote_radio_communication_(TOS_2.1.1)&diff=2507&oldid=prevLiangmike at 02:19, 8 September 20092009-09-08T02:19:34Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 02:19, 8 September 2009</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l353" >Line 353:</td>
<td colspan="2" class="diff-lineno">Line 353:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Using TOSThreads=</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Using TOSThreads=</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>If you choose to write the application with TOSThreads, the thread package provides API for sending and receiving packets. As mentioned in previous tutorials, the thread package replaces split-phase calls with blocking calls.  </div></td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>If you choose to write the application with TOSThreads, the thread package provides API for sending and receiving <ins class="diffchange diffchange-inline">radio </ins>packets. As mentioned in previous tutorials, the thread package replaces split-phase calls with blocking calls.  </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>We will use ''RadioStress'' as an example <del class="diffchange diffchange-inline">to manipulate radios</del>, and this example application creates three threads to stress the radio operations. We wrote "RadioStress" with both the nesC and C<del class="diffchange diffchange-inline">-</del>API. The nesC version is located in [http://tinyos.cvs.sourceforge.net/viewvc/tinyos/tinyos-2.x/apps/tosthreads/apps/RadioStress/ apps/tosthreads/apps/RadioStress/].  Depending on the platform, type '''make telosb threads''' to compile. We now dive into the source code and see how the application was written with nesC API.</div></td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>We will use ''RadioStress'' as an example, and this example application creates three threads to stress the radio operations. We wrote "RadioStress" with both the nesC and C API. The nesC version is located in [http://tinyos.cvs.sourceforge.net/viewvc/tinyos/tinyos-2.x/apps/tosthreads/apps/RadioStress/ apps/tosthreads/apps/RadioStress/].  Depending on the platform, type '''make telosb threads''' to compile. We now dive into the source code and see how the application was written with nesC API.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''RadioStressAppC.nc''':</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''RadioStressAppC.nc''':</div></td></tr>
</table>Liangmikehttp://tinyos.stanford.edu/tinyos-wiki/index.php?title=Mote-mote_radio_communication_(TOS_2.1.1)&diff=2506&oldid=prevLiangmike: New page: This lesson introduces radio communications in TinyOS. You will become familar with TinyOS interfaces and components that support communications and you will learn how to: * Use <code>mes...2009-09-08T02:08:10Z<p>New page: This lesson introduces radio communications in TinyOS. You will become familar with TinyOS interfaces and components that support communications and you will learn how to: * Use <code>mes...</p>
<a href="http://tinyos.stanford.edu/tinyos-wiki/index.php?title=Mote-mote_radio_communication_(TOS_2.1.1)&diff=2506">Show changes</a>Liangmike