Leo:TinyOS-development

From DiLab
Revision as of 17:56, 12 November 2008 by Leo (talk | contribs) (Extra tools)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Working with motes and the Testbed

These notes are by Leo Selavo. Follow them at your own risk.

Programming a TelosB mote

To program a TelosB mote you need to compile your program for telosb and then install it.

make telosb
make reinstall telosb

Programming a mote on a specific USB port

If you have a testbed with many motes attached to a computer by USB hub, you may want to select a specific mote for reprogramming. Then you need to specify the port using "bsl,<port>" argument on the make telosb reinstall line, as in the examples below.

In order to see which ports are assigned to the motes, run motelist.

In Windows - Cygwin

$> motelist

Reference  CommPort   Description
---------- ---------- ----------------------------------------
XBQDTMW2   COM35      Crossbow Telos Rev.B
XBQ8OQ47   COM36      Crossbow Telos Rev.B
XBQF0342   COM37      Crossbow Telos Rev.B
XBQF033F   COM38      Crossbow Telos Rev.B 

$> make telosb reinstall bsl,36

The above example will program the mote on COM37 (notice the COM number is higher by one).

In Linux - Ubuntu

$> motelist

Reference  Device           Description
---------- ---------------- ---------------------------------------------
XBQDTMXJ   /dev/ttyUSB0     XBOW Crossbow Telos Rev.B
XBQDTMWO   /dev/ttyUSB1     XBOW Crossbow Telos Rev.B
XBQDTN1D   /dev/ttyUSB2     XBOW Crossbow Telos Rev.B
XBQDTN9C   /dev/ttyUSB3     XBOW Crossbow Telos Rev.B

$> make telosb reinstall bsl,/dev/ttyUSB2

The above example will program the mote on USB2.

Programming a mote with a specific address

Sometimes you want to give the mote a specific address, that will be used by the mote software, for example, to identify which mote is sending what packets. This address is accessible in TinyOS program as TOS_NODE_ID.

To specify the address when uploading the program you include the address as an integer after reinstall, like this (note the comma inbetween):

make telosb reinstall,17 bsl,/dev/ttyUSB5

The above command will install the software to the mote attached as USB5, with the address 17.

Listening to packets

To see the communication coming from the sensor network you can use Serial Forwarder and Listen tools that come with TinyOS. For this one mote must be programmed using TOSBase (in TinyOS-1.x) or BaseStation (in TinyOS-2.x, $TOSROOT/apps/Basestation) application and attached to the computer's or Tmote Connect devices USB port.

Serial forwarder will act as a gateway between the serial (or USB) port and the TCP port, usually port 900x.

Using Tmote Connect

When motes are attached to Tmote Connect, you can check the web interface to the Tmote Connect for the port numbers assigned to the connected motes. You may need to export MOTECOM variable specifying the port as in the example below and then you can use the java Listener tool to see raw packets coming in.

export MOTECOM="sf@10.176.254.16:9002"
java net.tinyos.tools.Listen

The example above assumes that the Tmote Connect is on the IP address 10.176.254.16 and the mote is accessible via port 9002 which usually is the second USB port. To speed things up I alias the above commands for your working environment.

Extra tools

I have written some extra tools (in perl) to make tinyos development life easier.

 * pretty-gcc.pl - Pretty compilation errors - colorizes the output of gcc and hides uninteresting output. Piping the compilation error output to this tool I find the errors much faster, because they stand out. You may want to alias the bellow to something shorter.
make telosb 2>&1 | perl /home/elo/bin/pretty-gcc.pl
 * relisten.pl - pipe the "java net.tinyos.tools.Listen" to this tool to reformat the hex-dump to a few decimal numbers that can  be imported to a spreadsheet later. Specify the single and double byte fields in the perl file in your local copy, see the comments in the file. You can pipe the result further in a log file as needed (just do not cancel it before the log file is flushed).
java net.tinyos.tools.Listen | perl relisten.pl