Вы находитесь на странице: 1из 6

Handout 1/2 for Using Contiki Operating System on TelosB mote EE 586 (Fall 2010) Contiki Contiki is an open

source, highly portable, multi-tasking operating system for memoryefficient networked embedded systems and wireless sensor networks. Contiki has been used in a variety of projects from road tunnel fire monitoring, intrusion detection, water monitoring to surveillance networks. Here are some of the features of Contiki: TCP/IP communication with uIP stack Loadable modules Event-driven kernel Protothreads Protocol-independent radio network with the Rime stack Cross-layer network simulation with Cooja Networked shell Memory efficient flash-based Coffee file system Software-based power profiling Contiki has a very larger user community and you should explore the website http://www.sics.se/contiki for more information. Sensor Mote The TelosB mote from CrossBow is an open source platform originally designed at University of California Berkeley for experimentation with low-power personal wireless area network (LoWPAN). Its key features include IEEE 802.15.4/ZigBee compliant RF transceiver 2.4 to 2.4835 GHz, a globally compatible ISM band 250 kbps data rate Integrated onboard antenna 8MHz TI MSP430 microcontroller with 10kB RAM Low current consumption 1MB external flash for data logging Programming and data collection via USB Optional sensor suite including integrated light, temperature and humidity sensor This platform delivers low power consumption allowing for long battery life as well as fast wakeup from sleep state. It is powered by two AA batteries. If the mote is plugged into the USB port for programming or communication, power is provided from the host computer. The mote also provides users with the capability to interface with additional devices. The two expansion connectors and onboard jumpers may be configured to control analog sensors, digital peripherals and LCD displays.

1|Page

Handout 1/2 for Using Contiki Operating System on TelosB mote EE 586 (Fall 2010) I. Installation We will use the Instant Contiki development environment. Instant Contiki is a single-file download that contains the Contiki source code and all necessary compilers and tools required for developing software for Contiki. The Instant Contiki environment is a Ubuntu Linux installation that runs within the VMware Player virtual machine execution environment. VMware Player is available for free at the VMware website. Step 1. Getting your computer ready I am assuming that you are using a PC running Windows XP connected to the internet. You will need to have at least 5GB of free hard disk space in order to complete the installation. You will also need a flash drive with around 2GB of free space for file transfer. Step 2. Installing drivers, VMware Player and Instant Contiki 1. Get the folder EE586_Contiki from me and copy it a temporary space in your computer. An online copy can be downloaded from http://www.vis.uky.edu/~cheung/courses/ee586/EE586_Contiki.zip 2. Plug in your TelosB mote. You will be asked to install two drivers. All the drivers needed for the TelosB are stored in EE586_Contiki/FTDI. Make sure this path is used when windows prompt you for specific locations for drivers. 3. Install VMware Player. The default way to do this is to register with VMware and download the free player from http://www.vmware.com/products/player/. For your convenience, I have downloaded the setup file already and stored it at EE586_Contiki/VMware-player-3.1.2-301548.exe. Just double click and follow the instruction. You may still want to register with VMware to get more goodies from them. 4. Unzip EE586_Contiki/instant-contiki-2.4.zip and create the folder instant-contiki-2.4. II. Running Simple Programs Step 1: Start Instant Contiki and try running Hello World on the native platform 1. Open the Instant Contiki folder and open the file instant-contiki.vmx 2. When the login screen appears, log into Instant Contiki using user for both username and password. 3. After loggin in, click on the terminal icon to start a terminal window. 4. In the terminal window, go to the hello world example directory, compile for the native platform, and run: 2|Page

Handout 1/2 for Using Contiki Operating System on TelosB mote EE 586 (Fall 2010)

cd contiki-2.x cd examples/hello-world make TARGET=native 5. Wait for the compilation to finish. Run the Hello World program in Contiki: ./hello-world.native 6. The program should print the words Hello, world on the screen and then appear to hang. In reality, Contiki is still running correctly, but will not produce any output because the Hello World program has finished. Press ctrl-C on the keyboard to quit. Step 2: Trying out the TelosB mote 1. Make sure the file tmote-bsl-linux in tools/sky is executable by running the following command:
chmod a+x /home/user/contiki-2.x/tools/sky/tmote-bsl-linux

2. Connect the TelosB mote to your USB port. The TelosB mote will appear in the top of the Instant Contiki (VMware Player) window with the name Futre Technologies Device. Click on the name to connect to the TelosB mote to Instant Contiki. 3. To check that the TelosB mote is correctly connected to the computer and Instant Contiki, compile and upload the blink program to the mote: make TARGET=sky blink.upload 4. Wait for the compilation and uploading procedure to finish. During the uploading, the TelosB mote should quickly flash the red LEDs next to the USB connector. After uploading finished, the blink program will start to run and flash the three blue-redfree LEDs. Step 3: Run Hello World on the TelosB mote 1. Compile and upload the Hello World program on the TelosB mote make TARGET=sky hello-world.upload 2. After the compilation and uploading has finished, connect to the USB port to view its output: Contiki 2.4 started. Node id is not set. Rime started with address 182.163 MAC 00:12:74:00:11:7b:a3:b6 CSMA X-MAC, channel check rate 4 Hz, radio channel 26 Starting Hello world process Hello, world

3|Page

Handout 1/2 for Using Contiki Operating System on TelosB mote EE 586 (Fall 2010) 3. The Contiki boot-up code prints the first three lines, and the Hello World program prints out the last line. Press ctrl-C to quit. Step 4: Run Contiki Mote Cell Contiki shell is an interactive on-mote shell that provides a set of commands for interacting with the system or a network of nodes The shell can be accessed either over a serial USB connection or over a network using Telnet. In this tutorial, we first run the shell over a USB serial connection. 1. Compile and upload the shell cd cd contiki-2.x cd examples cd sky-shell make sky-shell.upload 2. Wait for the compilation and uploading to finish. To connect to the shell over the USB port, run: make login 3. You can now enter commands to the shell via the keyboard. Help lists all installed commands, try the following commands and see what they do: help sense | senseconv power | powerconv ps blink 10 nodeid repeat 2 2 { echo again } & nodes reboot 4. Press ctrl-C to exit the shell.: III. Network programming

The following exercises consist of running and altering a set of programs that use the Rime stack to communicate with other Contiki nodes over the radio. Step 1. Broadcast

4|Page

Handout 1/2 for Using Contiki Operating System on TelosB mote EE 586 (Fall 2010) The first exercise consists of sending your name to a base station with broadcast packets. This exercise shows how to use the broadcast communication primitive in the Rime stack 1. Goto the example directory cd cd contiki-2.x/examples/rime 2. Open the file example-abc.c by typing gedit example-abc.c & 3. Go down to the line that contains Packetbuf_copyfrom(Hello, 6); 4. Change this line so that the string contains your name or email address. The second argument is the number of characters in the name string, including the terminator character. 5. Compile the upload the broadcast program to your telosB mote: in the terminal window, type: make example-abc.upload TARGET=sky 6. This will compile and upload the program to the TelosB connected to your PC. This takes some time the first time because the entire Contiki operating system is compiled. When the compilation and uploading has finished, watch your name appear on the projector screen. 7. To see what broadcast messages your TelosB see, type the following in the terminal window: make login TARGET=sky This shows all serial output that the TelosB is sending over the USB port. To stop, press Ctrl+C. Step 2. Unicast The unicast program looks similar to the broadcast program, however, a destination address is needed. 1. Goto the example directory cd cd contiki-2.x/examples/rime 5|Page

Handout 1/2 for Using Contiki Operating System on TelosB mote EE 586 (Fall 2010) 2. Open the file example-abc.c by typing gedit example-unicast.c & 3. Go down to the line that contains packetbuf_copyfrom("Hello", 5); addr.u8[0] = 41; addr.u8[1] = 41; 4. As in the first exercise, you should change Hello to your name or email address. Next, make sure that the unicast packets go the to right address. The program is configured to send data to node 41.41 (Rime address). You need to change this to the address of the projector screen node. You may also send the packets to neighboring course participants. 5. Compile and upload the program: make example-unicast.upload TARGET=sky 6. See your name appearing on the projector screen when the compilation and uploading has finished. 7. To see what your Tmote Sky sees, run: make login TARGET=sky Press Ctrl+C to exit. Step 3. Data Dissemination In this exercise, we will disseminate data from a single node to all other nodes. Open the file example-trickle.c. As in the previous exercises, you may change the data payload to your name. No destination address is needed here as the trickle dissemination protocol will send your data to all other nodes. Compile, upload and login to the node: make example-trickle.upload TARGET=sky make login TARGET=sky Your message is transmitted when the on-board user button is pressed. Press Ctrl+C to exit.

6|Page

Вам также может понравиться