⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writing low-power applications - tinyos documentation wiki.htm

📁 从官方网站上下载tinyos2.0的学习指南
💻 HTM
📖 第 1 页 / 共 2 页
字号:
the check period. When a node receives a packet, it stays awake long enough to 
receive a second packet. Therefore, a packet burst amortizes the wakeup cost of 
the first packet over the follow-up packets. It is therefore more energy 
efficient to send packets in bursts when using low-power listening than sending 
individual packets at some fixed constant rate. Keep this in mind when 
developing applications that require low power operation. </P>
<P>Controlling the operation of low-power listening in TinyOS is provided 
through the use of the <CODE>LowPowerListening</CODE> interface. Currently, this 
interface is only supported for the cc1000 and cc2420 radios. In the future we 
hope to support other radio platforms as well. </P><PRE>interface LowPowerListening {
  /**
   * Set this this node's radio sleep interval, in milliseconds.
   * Once every interval, the node will sleep and perform an Rx check
   * on the radio.  Setting the sleep interval to 0 will keep the radio
   * always on.
   *
   * This is the equivalent of setting the local duty cycle rate.
   *
   * @param sleepIntervalMs the length of this node's Rx check interval, in [ms]
   */
  command void setLocalSleepInterval(uint16_t sleepIntervalMs);

  /**
   * @return the local node's sleep interval, in [ms]
   */
  command uint16_t getLocalSleepInterval();

  /**
   * Set this node's radio duty cycle rate, in units of [percentage*100].
   * For example, to get a 0.05% duty cycle,
   *   call LowPowerListening.setDutyCycle(5);
   *
   * For a 100% duty cycle (always on),
   *   call LowPowerListening.setDutyCycle(10000);
   *
   * This is the equivalent of setting the local sleep interval explicitly.
   *
   * @param dutyCycle The duty cycle percentage, in units of [percentage*100]
   */
  command void setLocalDutyCycle(uint16_t dutyCycle);

  /**
   * @return this node's radio duty cycle rate, in units of [percentage*100]
   */
  command uint16_t getLocalDutyCycle();

  /**
   * Configure this outgoing message so it can be transmitted to a neighbor mote
   * with the specified Rx sleep interval.
   * @param msg Pointer to the message that will be sent
   * @param sleepInterval The receiving node's sleep interval, in [ms]
   */
  command void setRxSleepInterval(message_t *msg, uint16_t sleepIntervalMs);

  /**
   * @return the destination node's sleep interval configured in this message
   */
  command uint16_t getRxSleepInterval(message_t *msg);

  /**
   * Configure this outgoing message so it can be transmitted to a neighbor mote
   * with the specified Rx duty cycle rate.
   * Duty cycle is in units of [percentage*100], i.e. 0.25% duty cycle = 25.
   *
   * @param msg Pointer to the message that will be sent
   * @param dutyCycle The duty cycle of the receiving mote, in units of
   *     [percentage*100]
   */
  command void setRxDutyCycle(message_t *msg, uint16_t dutyCycle);

  /**
   * @return the destination node's duty cycle configured in this message
   *     in units of [percentage*100]
   */
  command uint16_t getRxDutyCycle(message_t *msg);

  /**
   * Convert a duty cycle, in units of [percentage*100], to
   * the sleep interval of the mote in milliseconds
   * @param dutyCycle The duty cycle in units of [percentage*100]
   * @return The equivalent sleep interval, in units of [ms]
   */
  command uint16_t dutyCycleToSleepInterval(uint16_t dutyCycle);

  /**
   * Convert a sleep interval, in units of [ms], to a duty cycle
   * in units of [percentage*100]
   * @param sleepInterval The sleep interval in units of [ms]
   * @return The duty cycle in units of [percentage*100]
   */
  command uint16_t sleepIntervalToDutyCycle(uint16_t sleepInterval);

}
</PRE>
<P>This interface is located in <CODE>tos/interfaces</CODE> in the standard 
TinyOS tree. Take a look at the comments for each command to familiarize 
yourself with how this interface can be used. </P>
<P>Using this interface typically involves first setting a nodes local duty 
cycle within the <CODE>Boot.booted()</CODE> event of the top level application. 
For each packet the application wishes to send, the duty cycle of its 
destination is then specified as metadata so that the correct number of 
preambles can be prepended to it. The code snippet found below demonstrates this 
usage pattern: </P><PRE>event void Boot.booted() {
  call LPL.setLocalSleepInterval(LPL_INTERVAL);
  call AMControl.start();
}

event void AMControl.startDone(error_t e) {
  if(e&nbsp;!= SUCCESS)
    call AMControl.start();
}

...

void sendMsg() {
  call LPL.setRxSleepInterval(&amp;msg, LPL_INTERVAL);
  if(call Send.send(dest_addr, &amp;msg, sizeof(my_msg_t))&nbsp;!= SUCCESS)
    post retrySendTask();
}
</PRE>
<P>The <CODE>AMControl</CODE> interface is provided by 
<CODE>ActiveMessageC</CODE>, and is used, among other things, to enable the 
operation of low-power listening for the radio. Once 
<CODE>AMControl.start()</CODE> has completed successfully, the radio begins to 
duty cycle itself as specified by the parameter to the 
<CODE>setLocalSleepInterval()</CODE> command. Calling 
<CODE>setRxSleepInterval()</CODE> with a specific sleep interval then allows the 
correct number of preambles to be sent for the message specified in its 
parameter list. </P><A name=Microcontroller_Power_Management></A>
<H1><SPAN class=mw-headline>Microcontroller Power Management</SPAN></H1>
<P>Microcontrollers often have several power states, with varying power draws, 
wakeup latencies, and peripheral support. The microcontroller should always be 
in the lowest possible power state that can satisfy application requirements. 
Determining this state accurately requires knowing a great deal about the power 
state of many subsystems and their peripherals. Additionally, state transitions 
are common. Every time a microcontroller handles an interrupt, it moves from a 
low power state to an active state, and whenever the TinyOS scheduler finds the 
task queue empty it returns the microcontroller to a low power state. TinyOS 
uses three mechanisms to decide what low power state it puts a microcontroller 
into: status and control registers, a dirty bit, and a power state override. 
Please refer to <A class="external text" 
title=http://www.tinyos.net/tinyos-2.x/doc/html/tep112.html 
href="http://www.tinyos.net/tinyos-2.x/doc/html/tep112.html" rel=nofollow>TEP 
112</A> for more information. </P>
<P>As a developer, you will not have to worry about MCU power managment at all 
in most situations. TinyOS handles everything for you automatically. At times, 
however, you may want to use the provided power state override functionality. 
Take a look at <CODE>tos/chips/atm128/timer/HplAtm128Timer0AsyncP.nc</CODE> if 
you are interested in seeing an example of where this override functionality is 
used. </P><A name=Low_Power_Sensing_Application></A>
<H1><SPAN class=mw-headline>Low Power Sensing Application</SPAN></H1>
<P>A fully functional low-power sensing application has been created that 
combines each of the techniques found in this tutorial. At present, this 
application is not included in the official TinyOS distribution (&lt;= 2.0.2). 
If you are using TinyOS from a cvs checkout, you will find it located under 
<CODE>apps/tutorials/LowPowerSensing</CODE>. Otherwise, you can obtain it from 
cvs by running the following set of commands from a terminal window: </P><PRE>cd $TOSROOT/apps/tutorials
cvs -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos login
cvs -z3 -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co -P -D 2007-10-3 -d LowPowerSensing tinyos-2.x/apps/tutorials/LowPowerSensing
</PRE>
<P>Just hit enter when prompted for a CVS password. You do not need to enter 
one. </P>
<P>This application has been tested on telosb and mica2 platforms, but should be 
usable on others without modification. Take a look at the README file found in 
the top level directory for more information. </P><A 
name=Related_Documentation></A>
<H1><SPAN class=mw-headline>Related Documentation</SPAN></H1>
<UL>
  <LI><A class="external text" 
  title=http://www.tinyos.net/tinyos-2.x/doc/html/tep103.html 
  href="http://www.tinyos.net/tinyos-2.x/doc/html/tep103.html" rel=nofollow>TEP 
  103: Permanent Data Storage (Flash)</A> 
  <LI><A class="external text" 
  title=http://www.tinyos.net/tinyos-2.x/doc/html/tep105.html 
  href="http://www.tinyos.net/tinyos-2.x/doc/html/tep105.html" rel=nofollow>TEP 
  105: Low Power Listening</A> 
  <LI><A class="external text" 
  title=http://www.tinyos.net/tinyos-2.x/doc/html/tep108.html 
  href="http://www.tinyos.net/tinyos-2.x/doc/html/tep108.html" rel=nofollow>TEP 
  108: Resource Arbitration</A> 
  <LI><A class="external text" 
  title=http://www.tinyos.net/tinyos-2.x/doc/html/tep109.html 
  href="http://www.tinyos.net/tinyos-2.x/doc/html/tep109.html" rel=nofollow>TEP 
  109: Sensors and Sensor Boards</A> 
  <LI><A class="external text" 
  title=http://www.tinyos.net/tinyos-2.x/doc/html/tep112.html 
  href="http://www.tinyos.net/tinyos-2.x/doc/html/tep112.html" rel=nofollow>TEP 
  112: Microcontroller Power Management</A> 
  <LI><A class="external text" 
  title=http://www.tinyos.net/tinyos-2.x/doc/html/tep114.html 
  href="http://www.tinyos.net/tinyos-2.x/doc/html/tep114.html" rel=nofollow>TEP 
  114: SIDs: Source and Sink Independent Drivers</A> 
  <LI><A class="external text" 
  title=http://www.tinyos.net/tinyos-2.x/doc/html/tep115.html 
  href="http://www.tinyos.net/tinyos-2.x/doc/html/tep115.html" rel=nofollow>TEP 
  115: Power Management of Non-Virtualised Devices</A> 
  <LI><A class="external text" 
  title=http://sing.stanford.edu/klueska/Black_Site/Publications_files/klues07icem.pdf 
  href="http://sing.stanford.edu/klueska/Black_Site/Publications_files/klues07icem.pdf" 
  rel=nofollow>Integrating Concurrency Control and Energy Management in Device 
  Drivers</A> </LI></UL>
<P><BR></P>
<HR>

<CENTER>
<P>&lt; <B><A title="The TinyOS printf Library" 
href="http://docs.tinyos.net/index.php/The_TinyOS_printf_Library">Previous 
Lesson</A></B> | <B><A title="" 
href="http://docs.tinyos.net/index.php/Writing_Low-Power_Applications#Overview">Top</A></B> 
| </P></CENTER><!-- Saved in parser cache with key tinyosdocs:pcache:idhash:19-0!1!0!!en!2!edit=0 and timestamp 20080402002030 -->
<DIV class=printfooter>Retrieved from "<A 
href="http://docs.tinyos.net/index.php/Writing_Low-Power_Applications">http://docs.tinyos.net/index.php/Writing_Low-Power_Applications</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/Writing_Low-Power_Applications">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:Writing_Low-Power_Applications&amp;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=Writing_Low-Power_Applications&amp;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=Writing_Low-Power_Applications&amp;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&amp;returnto=Writing_Low-Power_Applications">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>&nbsp; <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/Writing_Low-Power_Applications">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/Writing_Low-Power_Applications">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=Writing_Low-Power_Applications&amp;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=Writing_Low-Power_Applications&amp;oldid=830">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="Writing Low-Power Applications - TinyOS Documentation Wiki.files/poweredby_mediawiki_88x31.png"></A></DIV>
<UL id=f-list>
  <LI id=lastmod>This page was last modified 18:27, 2 March 2008. 
  <LI id=viewcount>This page has been accessed 677 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.277 secs. --></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -