MansOS tutorial
Contents
Getting MansOS
See MansOS installation guide. For the purposes of this tutorial, you will need:
- MansOS sources. The recommended way is to checking them out from SVN by using command "svn co http://mansos.net/svn/mansos/ mansos"
- Development tools, such as msp430-gcc compiler
- Common UNIX command line tools, such as make
- A working Python installation
- At least one mote (Tmote Sky, Arduino, Epic mote, SADmote etc.) on which to run the application
- If you don't have any motes, then you can just run MansOS using its built-in simulation platform "pc"
Building and running your first application
Change location in MansOS root directory to mansos/apps/demo/Blink.
Now compile the application and program it in the device.
If you have Tmote Sky:
make telosb upload
If you have Arduino:
make atmega upload
If you have SADmote:
make telosb upload-msp430
For testing the application on simulator:
make pc run
The mote should now periodically (one change per second) turn one of its LEDs on and off.
The upload command by default tries to upload the application to serial port /dev/ttyUSB0. If your mote is attached to another port, change BSLPORT environmental variable to specify the correct port. For example:
$ export BSLPORT=/dev/ttyUSB1 $ make telosb upload ... ./../../../mos/make/scripts/tos-bsl --telosb -c "/dev/ttyUSB1" -r -e -I -p ./build/telosb/image.ihex
To see to which port the mote is attached you can use motelist utility:
$ motelist Reference Device Description ---------- ---------------- --------------------------------------------- M4AOQGBQ /dev/ttyUSB0 Moteiv tmote sky
Debugging an application
Printf-style debugging is the most commonly used form of debugging for sensor motes.
MansOS provides several macros for this:
- PRINTF(format, arguments): analogue of printf() function;
- PRINT(string): just print the string passed as argument; when compared to PRINTF(), this version has the benefit of smaller executable size;
- PRINTLN(string): print the string passed as argument with newline character appended.
By default output from these macros is sent to serial port.
To see one of these macros in action, change directory to mansos/apps/demo/CounterToSerial, compile and upload the application.
Listening to serial port
To observe the output a program capable to listening the serial port is required. If you don't know what to use, try:
- On Linux or MAC: minicom
- On Windows: putty
Use 38400 as baudrate setting, 8 bits, 1 stopbit, parity none, flow control turned off. Here is a complete minicom configuration file for reference:
pu port /dev/ttyUSB0 pu baudrate 38400 pu bits 8 pu parity N pu stopbits 1 pu rtscts No
Configure minicom/putty so that it listens to the serial port a mote is attached (/dev/ttyUSB0 for minicom by default). Compile and upload the CounterToSerial application, and launch minicom:
Alternatives to serial port output
Alternatively, the printed characters can be sent on air by using radio transceiver. To enable this option, add this line:
CONST_DPRINT_TO_RADIO=1
to application's configuration file. In this case, no output to serial port will be produced. You will need another mote which listens to radio and forwards all messages received to its serial port, i.e. acts as a proxy.
Alternatively, the printed characters can be sent to LCD terminal, if pone is attached to the mote.
Analysis of a MansOS application
main.c
Makefile
config
MansOS shell
Demo application...
PC command line tool...
Commands...
MansOS features
MansOS has support for:
- LEDs
- On Tmote Sky: red, green, and blue
- On SADmote: just red
- On Arduino: just yellow
- Bidirectional serial port communication
- Sending data to serial port
- Reading input from serial port
- Radio communication
- Packet sending
- Packet receiving
- Measuring the strength of received radio signal in different channels (in this way, a primitive spectrum analyzer can be built!)
- Optionally: TinyOS frame format support
- Optionally: rudimentary 802.15.4 MAC frame format support
- Network stack
- Sending data to a specific mote in the network
- Sending data reliably
- Collecting data from the whole network
- Synchronizing time in the whole network
- Management
- Controlling a specific mote by using an application running on computer
- Controlling whole network of motes at once
- Reading the address, serial number, sensor data etc.
- Rebooting the mote, turning LEDs on and off etc.
- Reprogramming the mote
- Parallel execution
- Preemptive multitasking
- Optionally, cooperative multitasking (similar to Contiki protothreads)
- Storing data on flash or SD card:
- Optionally, using a file system
- Reading sensors:
- Light
- Temperature
- Humidity
- Accelerometer and gyroscope
- Data from a GPS device (NMEA stream)
- Other sensors using analogue interface. Just specify the correct ADC channel you want to read and voila!
- Other sensors using digital I2C interface (you will need to write your own driver for this; however, it may be not as hard as it sounds)
- Using LCD for output
- Low power modes:
- msleep() and usleep() functions will automatically put the sensor device in low power mdoe
How different features of MansOS can be turned on and off?
config files
Default config file...
Can MansOS be used just as a library? =
Yes...
Glossary =
upload: program the application in a mote