|
|
Line 1: |
Line 1: |
− | The following instructions assume you have a working version of [http://www.tinyos.net TinyOS] installed on your machine.
| |
| | | |
− | == Step 1: Download ==
| |
− | Download the tarball of Agilla's source code from [[Downloading Agilla|here]]. Alternatively, you can grab an older version of Agilla via the [[Download Agilla using CVS|TinyOS 1.x CVS repository]].
| |
− |
| |
− | == Step 2: Extract ==
| |
− | Extract the files using the commands below. By default, the files go under $TOSROOT. On a Windows XP/Cygwin system, $TOSROOT is by default /opt/tinyos-1.x. On a Linux or OSX machine, $TOSROOT is wherever you have installed TinyOS 1.x.
| |
− |
| |
− | <pre>
| |
− | mv Agilla*.tar.gz $TOSROOT
| |
− | cd $TOSROOT
| |
− | tar zxvf Agilla*.tar.gz
| |
− | </pre>
| |
− |
| |
− | Once you have extracted the tarball, Agilla's source code will be located in three directories:
| |
− |
| |
− | * $TOSROOT/contrib/wustl/apps/Agilla: Agilla's firmware
| |
− | * $TOSROOT/contrib/wustl/tools/java: Agilla's Agent Injector Application
| |
− | * $TOSROOT/contrib/wustl/apps/AgillaAgents: Example Mobile Agents.
| |
− |
| |
− | == Step 3: Create Makefile.Agilla ==
| |
− |
| |
− | Create a file called "Makefile.Agilla" that contains local settings in $TOSROOT/contrib/wustl/apps/Agilla. To do this, you can simply copy the example file that comes with Agilla.
| |
− |
| |
− | <pre>
| |
− | cd $TOSROOT/contrib/wustl/apps/Agilla
| |
− | cp Example\ Makefile.Agilla Makefile.Agilla
| |
− | </pre>
| |
− |
| |
− | See $TOSROOT/contrib/wustl/apps/Agilla/README for details on how to customize this file.
| |
− |
| |
− | == Step 4: Compile and Install Agilla on a Mote ==
| |
− | Compile and install Agilla onto every mote including the one that is directly attached to the PC. Be sure that every mote has a unique TinyOS address.
| |
− |
| |
− | <pre>
| |
− | cd $TOSROOT/contrib/wustl/apps/Agilla/
| |
− | make [platform]
| |
− | make [platform] reinstall.[id][programming board],[port]
| |
− | </pre>
| |
− |
| |
− | The actual command may differ slightly between Windows XP and Linux/OSX platforms, mostly because of the different ways serial ports are named. The following example commands assume a Windows XP environment.
| |
− |
| |
− | Here's a command that will install Agilla on a TelosB mote on COM5 with TinyOS address 0:
| |
− |
| |
− | <pre>
| |
− | cd $TOSROOT/contrib/wustl/apps/Agilla/
| |
− | make telosb
| |
− | make telosb reinstall.0 bsl,4
| |
− | </pre>
| |
− |
| |
− | Here's a command that will install Agilla on a Mica2 mote on COM1 with TinyOS address 1:
| |
− |
| |
− | <pre>
| |
− | cd $TOSROOT/contrib/wustl/apps/Agilla/
| |
− | make mica2
| |
− | make mica2 reinstall.1 mib510,/dev/ttyS0</pre>
| |
− |
| |
− | == Step 5: Compile the AgentInjector ==
| |
− | The AgentInjector is a Java application that enables users to inject mobile agents into an Agilla WSN. It is located in $TOSROOT/contrib/wustl/tools/java/. The main class is edu.wustl.mobilab.agilla.AgentInjector. In order to compile the AgentInjector, $TOSROOT/contrib/wustl/tools/java must be in the classpath. View the classpath using the following command:
| |
− |
| |
− | <pre>
| |
− | echo $CLASSPATH
| |
− | </pre>
| |
− |
| |
− | If it is not in the classpath, add it:
| |
− |
| |
− | <pre>
| |
− | export CLASSPATH=$CLASSPATH:$TOSROOT/contrib/wustl/tools/java
| |
− | </pre>
| |
− |
| |
− | Once the classpath is set, create a file called "Makefile.Agilla" within $TOSROOT/tools/java/edu/wustl/mobilab/agilla using the following command:
| |
− |
| |
− | <pre>
| |
− | cd $TOSROOT/contrib/wustl/tools/java/edu/wustl/mobilab/agilla
| |
− | cp Example\ Makefile.Agilla Makefile.Agilla
| |
− | make
| |
− | </pre>
| |
− |
| |
− | This file defines the MIG variable, which specifies what type of target environment the AgentInjector is connecting to. The default content of this file contains:
| |
− |
| |
− | <pre>
| |
− | #MIG = mig -target=pc java
| |
− | MIG = mig java
| |
− | </pre>
| |
− |
| |
− | If the AgentInjector is to connect to a real WSN, leave the default content as it is. If it is going to be used with TOSSIM, uncomment the first line and comment out the second line.
| |
− |
| |
− | Once you have configured Makefile.Agilla, compile the AgentInjector:
| |
− |
| |
− | <pre>
| |
− | make
| |
− | </pre>
| |
− |
| |
− | This will generate all of Agilla's messages and compile the AgentInjector.
| |
− |
| |
− | == Step 6: Creating an agilla.properties file ==
| |
− | Create a file called "agilla.properties" within $TOSROOT/contrib/wustl/tools/java/ that contains local settings for the AgentInjector:
| |
− |
| |
− | <pre>
| |
− | cd $TOSROOT/contrib/wustl/tools/java/
| |
− | cp Example\ agilla.properties agilla.properties
| |
− | </pre>
| |
− |
| |
− | == Step 7: Adding RMI Support ==
| |
− | This step is only required if you plan on remotely injecting agents using Java RMI. To enable the RMI feature, create a file called "java.policy" in $TOSROOT/tools/java with the following text:
| |
− |
| |
− | <pre>
| |
− | grant {
| |
− | permission java.net.SocketPermission "*:1024-65535","accept,connect,listen,resolve";
| |
− | permission java.io.FilePermission "<<ALL FILES>>","read,write,execute";
| |
− | permission java.util.PropertyPermission "user.dir","read,write";
| |
− | };
| |
− | </pre>
| |
− |
| |
− | == Step 8: Launch the AgentInjector ==
| |
− |
| |
− | You are now ready to inject mobile agents into the WSN! See [[Agilla Tutorial Lesson 2: Injecting an Agent|lesson 2]] of the tutorial on how to inject a mobile agent into the WSN.
| |
− |
| |
− | == Optional Step 1: Creating a Makelocal file ==
| |
− |
| |
− | A Makelocal file is used by TinyOS to record settings that are specific to the local platform. If you already are familiar with a Makelocal file, you can skip this step. The Makelocal file goes in $TOSROOT/tools/make and may contain the following:
| |
− |
| |
− | <pre>
| |
− | # Radio Frequencies for Mica2 motes: uncomment the line which
| |
− | # has the frequency that you want your motes to use
| |
− | #Channel 0:
| |
− | #PFLAGS += -DCC1K_DEF_FREQ=433002000
| |
− | #Channel 2:
| |
− | #PFLAGS += -DCC1K_DEF_FREQ=433616400
| |
− | #Channel 4:
| |
− | PFLAGS += -DCC1K_DEF_FREQ=434107920
| |
− | #Channel 6:
| |
− | #PFLAGS += -DCC1K_DEF_FREQ=434845141
| |
− |
| |
− | # channel 0-2: 614400
| |
− | # channel 2-4: 491520
| |
− | # channel 4-6: 737221
| |
− | #PFLAGS += -DCC1K_DEF_PRESET=4
| |
− |
| |
− | # Radio Frequencies for MicaZ and Telos motes: uncomment the
| |
− | # line which has the frequency that you want your motes to use
| |
− | #PFLAGS += -DCC2420_DEF_CHANNEL=11
| |
− | #PFLAGS += -DCC2420_DEF_CHANNEL=14
| |
− | #PFLAGS += -DCC2420_DEF_CHANNEL=15
| |
− | #PFLAGS += -DCC2420_DEF_CHANNEL=20
| |
− | #PFLAGS += -DCC2420_DEF_CHANNEL=26
| |
− |
| |
− |
| |
− | # Define for your local group in hex (otherwise it is 0x7d).
| |
− | DEFAULT_LOCAL_GROUP=0x07
| |
− |
| |
− | # Choose programmer and port. If nothing uncommented, then assumes MIB500.
| |
− | #MIB510=/dev/ttyS5
| |
− |
| |
− | # Uncomment out the following to enable Deluge
| |
− | # TINYOS_NP = BNP
| |
− | </pre>
| |
− |
| |
− | == Optional Step 2: Configuring Environment Variables ==
| |
− |
| |
− | There are several environment variables that will make using Agilla easier. They are not required, but provide shortcuts when performing common tasks. In a Windows XP/Cygwin environment, the following commands may be included in a file called "washu.sh" located within /etc/profile.d/. In a Linux or OSX environment, they can be included in ~/.bash_profile or ~/.bashrc depending on your specific shell.
| |
− |
| |
− | <pre>
| |
− | export WUBASE=$TOSROOT/contrib/wustl
| |
− | alias cdwu="cd $WUBASE"
| |
− | alias cdwuj="cd $WUBASE/tools/java"
| |
− | alias cdwua="cd $WUBASE/apps"
| |
− | alias runsf_pc="java net.tinyos.sf.SerialForwarder -comm tossim-serial &"
| |
− | alias runsf_com1="java net.tinyos.sf.SerialForwarder -comm serial@COM1:mica2 &"
| |
− |
| |
− | export AGILLA=$WUBASE/apps/Agilla
| |
− | alias cda="cd $AGILLA"
| |
− | alias cdaa="cd $WUBASE/apps/AgillaAgents"
| |
− | alias cdaj="cd $WUBASE/tools/java/edu/wustl/mobilab/agilla"
| |
− | alias ri="java -Djava.security.policy=java.policy edu.wustl.mobilab.agilla.AgentInjector -comm COM1:115200 -d &"
| |
− | alias ri_sim="java -Djava.security.policy=java.policy edu.wustl.mobilab.agilla.AgentInjector -comm tossim-serial -d &"
| |
− | alias ri_nc="java -Djava.security.policy=java.policy edu.wustl.mobilab.agilla.AgentInjector -nc -d &"
| |
− | alias mj="cd $TOSROOT/tools/java/edu/wustl/mobilab/agilla; javac *.java"
| |
− | </pre>
| |
− |
| |
− | == Optional Step 3: Enabling direct serial communication between Mica2 and Imote2 motes ==
| |
− |
| |
− | In order for Mica2 and MicaZ motes to communicate with Cricket motes, you need to change their UART ports to operate at 115.2kbps (the default is 57.6kbps). To change this, open $TOSROOT/tos/platforms/<platform>/HPLUART0M.nc and change outp(15, UBRR0L); to outp(7, UBRR0L);.
| |
− |
| |
− | == Optional Step 4: Configuring a Text Editor to Edit Agilla Agents ==
| |
− |
| |
− | For Windows users, I recommend using TextPad to edit NesC and Mobile Agent files. Here are the color-syntax configurations for NesC and Agilla Agent files. Install them in <Program Files>\TextPad 4\system.
| |
− |
| |
− | * NesC
| |
− | * Mobile Agent
| |
− |
| |
− | If you are using Linux, I recommend gEdit. Here are the syntax files. Install them in /usr/share/gtksourceview-1.0/language-specs/
| |
− |
| |
− | * NesC
| |
− | * Mobile Agent
| |