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

📄 getting started with tinyos - tinyos documentation wiki.htm

📁 从官方网站上下载tinyos2.0的学习指南
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0060)http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS -->
<HTML lang=en dir=ltr xml:lang="en" 
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Getting Started with TinyOS - TinyOS Documentation Wiki</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META 
content="Getting Started with TinyOS,Getting Started with TinyOS,Modules and the TinyOS Execution Model,Mote-mote radio communication,TinyOS Toolchain" 
name=keywords><LINK href="/favicon.ico" rel="shortcut icon"><LINK 
title="TinyOS Documentation Wiki (English)" href="/opensearch_desc.php" 
type=application/opensearchdescription+xml rel=search>
<STYLE type=text/css media="screen, projection">@import url( /skins/common/shared.css?97 );
@import url( /skins/monobook/main.css?97 );
</STYLE>
<LINK media=print 
href="Getting Started with TinyOS - TinyOS Documentation Wiki.files/commonPrint.css" 
type=text/css rel=stylesheet><!--[if lt IE 5.5000]><style type="text/css">@import "/skins/monobook/IE50Fixes.css?97";</style><![endif]--><!--[if IE 5.5000]><style type="text/css">@import "/skins/monobook/IE55Fixes.css?97";</style><![endif]--><!--[if IE 6]>
<STYLE type=text/css>@import url( /skins/monobook/IE60Fixes.css?97 );
</STYLE>
<![endif]--><!--[if IE 7]><style type="text/css">@import "/skins/monobook/IE70Fixes.css?97";</style><![endif]--><!--[if lt IE 7]>
<SCRIPT 
src="Getting Started with TinyOS - TinyOS Documentation Wiki.files/IEFixes.js" 
type=text/javascript></SCRIPT>

<META http-equiv=imagetoolbar content=no><![endif]-->
<SCRIPT type=text/javascript>/*<![CDATA[*/var skin = "monobook";var stylepath = "/skins";var wgArticlePath = "/index.php/$1";var wgScriptPath = "";var wgScript = "/index.php";var wgServer = "http://docs.tinyos.net";var wgCanonicalNamespace = "";var wgCanonicalSpecialPageName = false;var wgNamespaceNumber = 0;var wgPageName = "Getting_Started_with_TinyOS";var wgTitle = "Getting Started with TinyOS";var wgAction = "view";var wgRestrictionEdit = [];var wgRestrictionMove = [];var wgArticleId = "7";var wgIsArticle = true;var wgUserName = null;var wgUserGroups = null;var wgUserLanguage = "en";var wgContentLanguage = "en";var wgBreakFrames = false;var wgCurRevisionId = "853";/*]]>*/</SCRIPT>

<SCRIPT 
src="Getting Started with TinyOS - TinyOS Documentation Wiki.files/wikibits.js" 
type=text/javascript><!-- wikibits js --></SCRIPT>

<SCRIPT 
src="Getting Started with TinyOS - TinyOS Documentation Wiki.files/index.php" 
type=text/javascript><!-- site js --></SCRIPT>

<STYLE type=text/css>@import url( /index.php?title=MediaWiki:Common.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000 );
@import url( /index.php?title=MediaWiki:Monobook.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000 );
@import url( /index.php?title=-&action=raw&gen=css&maxage=18000 );
</STYLE>
<!-- Head Scripts -->
<SCRIPT 
src="Getting Started with TinyOS - TinyOS Documentation Wiki.files/ajax.js" 
type=text/javascript></SCRIPT>

<META content="MSHTML 6.00.2900.3268" name=GENERATOR></HEAD>
<BODY class="mediawiki ns-0 ltr page-Getting_Started_with_TinyOS">
<DIV id=globalWrapper>
<DIV id=column-content>
<DIV id=content><A id=top name=top></A>
<H1 class=firstHeading>Getting Started with TinyOS</H1>
<DIV id=bodyContent>
<H3 id=siteSub>From TinyOS Documentation Wiki</H3>
<DIV id=contentSub></DIV>
<DIV id=jump-to-nav>Jump to: <A 
href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#column-one">navigation</A>, 
<A 
href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#searchInput">search</A></DIV><!-- start content -->
<TABLE class=toc id=toc summary=Contents>
  <TBODY>
  <TR>
    <TD>
      <DIV id=toctitle>
      <H2>Contents</H2></DIV>
      <UL>
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Introduction"><SPAN 
        class=tocnumber>1</SPAN> <SPAN class=toctext>Introduction</SPAN></A> 
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Compiling_and_Installing"><SPAN 
        class=tocnumber>2</SPAN> <SPAN class=toctext>Compiling and 
        Installing</SPAN></A> 
        <UL>
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Making_sure_you.27re_invoking_the_right_version_of_the_nesC_compiler"><SPAN 
          class=tocnumber>2.1</SPAN> <SPAN class=toctext>Making sure you're 
          invoking the right version of the nesC compiler</SPAN></A> 
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Installing_on_a_mica-family_mote_.28micaz.2C_mica2.2C_mica2dot.29"><SPAN 
          class=tocnumber>2.2</SPAN> <SPAN class=toctext>Installing on a 
          mica-family mote (micaz, mica2, mica2dot)</SPAN></A> 
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Installing_on_telos-family_mote_.28telosa.2C_telosb.29"><SPAN 
          class=tocnumber>2.3</SPAN> <SPAN class=toctext>Installing on 
          telos-family mote (telosa, telosb)</SPAN></A> 
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Installing_on_a_TinyNode_mote"><SPAN 
          class=tocnumber>2.4</SPAN> <SPAN class=toctext>Installing on a 
          TinyNode mote</SPAN></A> 
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Installing_on_an_eyesIFX-family_mote"><SPAN 
          class=tocnumber>2.5</SPAN> <SPAN class=toctext>Installing on an 
          eyesIFX-family mote</SPAN></A> 
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Installing_on_an_IntelMote2"><SPAN 
          class=tocnumber>2.6</SPAN> <SPAN class=toctext>Installing on an 
          IntelMote2</SPAN></A> </LI></UL>
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Installation_options"><SPAN 
        class=tocnumber>3</SPAN> <SPAN class=toctext>Installation 
        options</SPAN></A> 
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Components_and_Interfaces"><SPAN 
        class=tocnumber>4</SPAN> <SPAN class=toctext>Components and 
        Interfaces</SPAN></A> 
        <UL>
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Configurations_and_Modules"><SPAN 
          class=tocnumber>4.1</SPAN> <SPAN class=toctext>Configurations and 
          Modules</SPAN></A> </LI></UL>
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Blink:_An_Example_Application"><SPAN 
        class=tocnumber>5</SPAN> <SPAN class=toctext>Blink: An Example 
        Application</SPAN></A> 
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#The_BlinkAppC.nc_Configuration"><SPAN 
        class=tocnumber>6</SPAN> <SPAN class=toctext>The BlinkAppC.nc 
        Configuration</SPAN></A> 
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#The_BlinkC.nc_Module"><SPAN 
        class=tocnumber>7</SPAN> <SPAN class=toctext>The BlinkC.nc 
        Module</SPAN></A> 
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Visualizing_a_Component_Graph"><SPAN 
        class=tocnumber>8</SPAN> <SPAN class=toctext>Visualizing a Component 
        Graph</SPAN></A> 
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Conclusion"><SPAN 
        class=tocnumber>9</SPAN> <SPAN class=toctext>Conclusion</SPAN></A> 
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Related_Documentation"><SPAN 
        class=tocnumber>10</SPAN> <SPAN class=toctext>Related 
        Documentation</SPAN></A> </LI></UL></TD></TR></TBODY></TABLE>
<SCRIPT type=text/javascript> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </SCRIPT>
<A name=Introduction></A>
<H1><SPAN class=mw-headline>Introduction</SPAN></H1>
<P>This lesson shows you how to compile a TinyOS program and install it on a 
mote, introduces the basic concepts and syntax of the TinyOS component model, 
and shows you how to generate and navigate TinyOS's source code documentation. 
</P><A name=Compiling_and_Installing></A>
<H1><SPAN class=mw-headline>Compiling and Installing</SPAN></H1>
<P>As a first exercise, you'll compile and install a very simple TinyOS 
application called Blink. If you don't have mote hardware, you can compile it 
for TOSSIM, the TinyOS simulator. </P>
<P>You compile TinyOS applications with the program <TT>make</TT>. TinyOS uses a 
powerful and extensible make system that allows you to easily add new platforms 
and compilation options. The makefile system definitions are located in 
tinyos-2.x/support/make. </P>
<P>The first step is to check that your environment is set up correctly. Run the 
<CODE>tos-check-env</CODE> command: </P><PRE>$ tos-check-env
</PRE>
<P>This script checks pretty much everything that the TinyOS environment needs. 
Most of the warnings should be somewhat self-explanatory, if you are at all 
accustomed to a UNIX environment. If you are having trouble with warnings, your 
best bet is to join and ask questions on the <A class="external text" 
title=https://mail.millennium.berkeley.edu/mailman/listinfo/tinyos-help 
href="https://mail.millennium.berkeley.edu/mailman/listinfo/tinyos-help" 
rel=nofollow>tinyos-help</A> email list. It's almost always the case that if 
you've run into a problem, someone else has too. Searching the <A 
class="external text" 
title=http://mail.millennium.berkeley.edu/pipermail/tinyos/ 
href="http://mail.millennium.berkeley.edu/pipermail/tinyos/" rel=nofollow>help 
archives</A> can therefore be useful. </P>
<P>If your system says some command is not available, then chances are you need 
to install the TinyOS tools (tos-*) RPM. Please refer to your installation 
instructions. If you have installed the RPM, then look in /usr/bin and 
/usr/local/bin for tos-check-env. If you have downloaded from CVS rather than 
used RPMs, then you need to compile and build the tools. Go to 
<CODE>tinyos-2.x/tools/tinyos</CODE> and type: </P><PRE>$ configure
$ make
$ make install
</PRE>
<P>On Linux systems, you will either need superuser abilities or access to 
<CODE>sudo</CODE> for the last command. </P>
<P>The second thing to check is that you have the TinyOS build system enabled. 
This involves the MAKERULES environment variable. In a shell, type: </P><PRE>  printenv MAKERULES 
</PRE>
<P>You should see <TT>/opt/tinyos-2.x/support/make/Makerules</TT>. If your 
TinyOS tree is installed somewhere besides the standard place, you might not see 
<TT>/opt</TT>, but rather a different initial path. If MAKERULES is not set 
(printenv prints nothing), you need to set it. Depending on your shell, this 
involves using either <TT>export</TT> (bash) or <TT>setenv</TT> (csh, tcsh). If 
you don't know about shell environment variables, this <A class="external text" 
title=http://www.ee.surrey.ac.uk/Teaching/Unix/unix8.html 
href="http://www.ee.surrey.ac.uk/Teaching/Unix/unix8.html" 
rel=nofollow>tutorial</A> should help. </P>
<P>The make command to compile a TinyOS application is <CODE>make</CODE> 
<I>[platform]</I>, executed from the application's directory. To compile Blink, 
go the <CODE>apps/Blink</CODE> directory and depending on which hardware you 
have, type <TT>make micaz</TT>, <TT>make mica2</TT>, <TT>make telosb</TT>, or, 
for simulation, type <TT>make micaz sim</TT>. </P>
<P>You should see output such as this: </P><PRE>dark /root/src/tinyos-2.x/apps/Blink -4-&gt; make telosb
mkdir -p build/telosb
    compiling BlinkAppC 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=   BlinkAppC.nc -lm
    compiled BlinkAppC to build/telosb/main.exe
            2782 bytes in ROM
              61 bytes in RAM
msp430-objcopy --output-target=ihex build/telosb/main.exe build/telosb/main.ihex
    writing TOS image
</PRE>
<P>If you compile for TOSSIM, you will see a much longer message, as building 
TOSSIM requires several steps, such as building shared libraries and scripting 
support. </P>
<P>If you are running Cygwin and see the error message "The procedure entry 
point basename could not be located in the dynamic link library cygwin1.dll" 
then you need to install the other Cygwin nesC RPM (step 4 of the <A 
class="external text" 
title=http://www.tinyos.net/tinyos-2.x/doc/html/install-tinyos.html 
href="http://www.tinyos.net/tinyos-2.x/doc/html/install-tinyos.html" 
rel=nofollow>install instructions</A> or step 2 of the <A class="external text" 
title=http://www.tinyos.net/tinyos-2.x/doc/html/upgrade-tinyos.html 
href="http://www.tinyos.net/tinyos-2.x/doc/html/upgrade-tinyos.html" 
rel=nofollow>upgrade instructions</A>) </P><A 
name=Making_sure_you.27re_invoking_the_right_version_of_the_nesC_compiler></A>
<H2><SPAN class=mw-headline>Making sure you're invoking the right version of the 
nesC compiler</SPAN></H2>
<P>If you see an error message along the lines of this: </P><PRE>BlinkAppC.nc:46: syntax error before `new'
make: *** [exe0] Error 1
</PRE>
<P>Then you are invoking an older version of the nesc compiler. Check by typing 
<TT>ncc --version</TT>. You should see: </P><PRE>ncc: 1.2.1
nescc: 1.2.6
</PRE>
<P>Followed by some information on what version of the C compiler is being used. 
If you see different versions than those above, your compilation problems are 
most probably due to the fact that make is invoking the wrong version. This can 
easily happen if you are upgrading from TinyOS 1.x. You might have passed the 
tos-check-env because you have the right compiler on your system, but for some 

⌨️ 快捷键说明

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