Document 13050928

advertisement
TDDI07 Distributed embedded software and networks Department of Computer and Information Science Lab Environment
Sensor nodes
The sensor node or mote that you will use in the labs is the Crossbow Telos b,
also known as TMote Sky. Since the motes are fragile, you are required to hold
them from the lower part as it is depicted below (the black plastic where the
batteries are supposed to be placed). Never hold them from the printed circuit
board. Remember that you will be the responsible for the motes during the labs.
The important mote components used in the labs are shown in the picture: reset
button, sensors, radio chip, antenna and USB connector. If you want to know
more, check the datasheet.
Ubuntu virtual machine and setting up the motes
The labs have to be performed using the virtual machine that is provided, which
includes the needed environment to program the motes. It can be found in:
C:\Program Files\Oracle\Ubuntu_TOS_1
You are supposed to copy it to the temporary folder TEMP in the same directory.
It is better if you always use the same computer in order to avoid the need of
copying the machine at the beginning of every lab.
You need to configure the virtual machine using VirtualBox in order to use the
motes connected via USB. The following steps configure the virtual machine to
capture directly the USB devices that are connected to the computer without
passing from Windows. It is important to follow every step in order, otherwise
you will need to start from the beginning again.
1. Before starting the virtual machine, plug both sensor nodes using the USB
interface. If the drivers are installed, wait for the installation to finish. It
does not matter if the installation fails.
2. Unplug the 2 sensors after the driver installation
3. You need to configure the USB ports. Open the Oracle VM VirtualBox
manager.
a. Choose the Ubuntu virtual machine.
b. Click on USB to show the USB. Otherwise you can access them
from the USB menu via settings of the VM.
c. Disable USB 2.0 (EHCI) Controller if it is enabled.
TDDI07 Distributed embedded software and networks Department of Computer and Information Science d. Add 2 USB filters by clicking twice in the USB with the blue circle.
e. Press OK
4. Start the virtual machine and plug the 2 motes. If the VirtualBox USB
driver is not installed, it will start the installation. Wait until the driver has
been installed 2 times (for both motes). If the driver installation asks for
admin password, call the lab assistant.
5. Unplug the 2 motes.
6. Plug the 2 motes again. If the steps were correctly performed, the virtual
machine will capture directly both motes. The USB symbol on the bottom
frame of the virtual machine should have an orange circle when inserting
the motes.
7. Run motelist command to verify the both motes are recognised by the
virtual machine.
If there is any problem following the steps contact the lab assistant.
The username and password for the virtual machine are tddi07 and moteslab
respectively. Internet access can be enabled by clicking in the network icon on
the top right part of the screen and selecting “Auto eth 3”.
Programming environment
To code your applications you can use the editor that you like. We recommend
gedit since it provides nesC syntax highlighting.
Avoid leaving data in the virtual machine. Copy your code to your USB or choose
any other alternative (e.g., sshfs, Dropbox or e-mail).
TinyOS is also available for other Linux distributions, Mac OS X or Cygwin in the
Windows environment. However, we will not support you with installation and
necessary patches.
TinyOS directory
You will perform the labs with the TinyOS version 2. You can have a look to the
/opt/tinyos-2.1.1/ directory, where all the components, interfaces and some
applications can be found.
TDDI07 Distributed embedded software and networks Department of Computer and Information Science apps
doc
tools
tools/java
tos
tos/interfaces
tos/lib
tos/platform
tos/platform/pc
tos/system
tos/types
TinyOS example applications
Documentation
TinyOS simulation tools
Base directory for all TinyOS java packages
Base directory of TinyOS NesC source code.
Source code for all interface declarations
Libraries
Platform specific sources
The platform for TOSSIM simulation
Source for system interface implementations
A few system wide definitions and types
Steps to compile and install applications
Step 1: Attach the motes and export the MOTECOM variable
At the time of attaching the motes to the computer, make sure that the virtual
machine recognizes them. You can attach the mote via the menu Devices -> USB
devices or clicking in the small USB icon
.
To show the list of devices attached to the virtual machine and in which port they
are available you can use the following command:
motelist
To export the MOTECOM variable used by the serial communication java
programs:
export MOTECOM=serial@/dev/ttyUSB0:telosb
Step 2: Compile and install the application
To compile the code for the telosb platform you have to run the following
command in your application folder. The compilation errors will help you to find
out errors in your program as well:
make telosb
Install the application in the default mote without compiling the code again:
make telosb reinstall
The following command installs the application in the mote attached to the USB1
port. Moreover, it assigns the TOS_NODE_ID=1. This is really useful when you
are using more than one mote connected to the USB ports:
make telosb reinstall.1 bsl,/dev/ttyUSB1
Step 3: Serial communication commands
If you are using serial communication in the lab, the following are the commands
to listen to the serial communication via USB from the computer. The first one
prints raw data received from the mote in hexadecimal and the second one is
TDDI07 Distributed embedded software and networks Department of Computer and Information Science used to print the printf commands of the mote:
java net.tinyos.tools.Listen
java net.tinyos.tools.PrintfClient
Compiling and installing your first application
In order to try these commands, you can copy the Blink application from
/opt/tinyos-2.x/apps to your folder, compile and install it in one of your motes.
To compile the code:
tddi07@wcu-desktop:~/Blink$ ls
BlinkAppC.nc BlinkC.nc build Makefile README.txt
tddi07@wcu-desktop:~/Blink$ make telosb
mkdir -p build/telosb
compiling BlinkAppC to a telosb binary
ncc -o build/telosb/main.exe -Os -O -mdisable-hwmul -fnesc-separator=__ Wall -Wshadow -Wnesc-all -target=telosb -fnesc-cfile=build/telosb/app.c board= -DDEFINED_TOS_AM_GROUP=0x22 DIDENT_APPNAME=\"BlinkAppC\" -DIDENT_USERNAME=\"tddi07\" DIDENT_HOSTNAME=\"wcu-desktop\" -DIDENT_USERHASH=0x9b0a5586L
-DIDENT_TIMESTAMP=0x4e8c5a6cL -DIDENT_UIDHASH=0x8572cef3L
BlinkAppC.nc -lm
compiled BlinkAppC to build/telosb/main.exe
2648 bytes in ROM
54 bytes in RAM
msp430-objcopy --output-target=ihex build/telosb/main.exe
build/telosb/main.ihex
writing TOS image
Check that a motes is attached and its path:
tddi07@wcu-desktop:~/Blink$ motelist
Reference Device
Description
---------- ---------------- --------------------------------------------XBTFXN4V /dev/ttyUSB0 XBOW Crossbow Telos Rev.
Install the application in the mote, either using the simple command or specifying
where the mote is and the options:
tddi07@wcu-desktop:~/Blink$ make telosb reinstall
or
tddi07@wcu-desktop:~/Blink$ make telosb reinstall.0 bsl./dev/ttyUSB0
cp build/telosb/main.ihex build/telosb/main.ihex.out
found mote on /dev/ttyUSB0 (using bsl,auto)
installing telosb binary using bsl
tos-bsl --telosb -c /dev/ttyUSB0 -r -e -I -p build/telosb/main.ihex.out
MSP430 Bootstrap Loader Version: 1.39-telos-8
Mass Erase...
Transmit default password ...
Invoking BSL...
Transmit default password ...
TDDI07 Distributed embedded software and networks Department of Computer and Information Science Current bootstrap loader version: 1.61 (Device ID: f16c)
Changing baudrate to 38400 ...
Program ...
2680 bytes programmed.
Reset device ...
rm -f build/telosb/main.exe.out build/telosb/main.ihex.out
Now the application is working in the mote. The expected outcome is to see the
leds of the mote blinking. You can inspect and understand the code to see how.
Additional resources:
TinyOS website:
http://www.tinyos.net/
TinyOS programming:
http://www.tinyos.net/tinyos-2.x/doc/pdf/tinyos-programming.pdf
Download