Difference between revisions of "Hello World"

From Contiki
Jump to: navigation, search
(Introduction)
Line 5: Line 5:
 
== Introduction ==
 
== Introduction ==
  
This tutorial teaches you how to compile a program on Contiki OS. This is a simple Hello World program which is used to show the compilation and upload steps on a Tmote Sky.
+
This article is about the Hello World program, which is used to show the compilation and upload steps of a simple program on a Tmote Sky.
 +
 
 +
== You will learn ==
 +
 
 +
This tutorial teaches you how to compile a program on Contiki OS and also the most basic syntax of programming in ContikiOS.
 +
 
 +
=== Step 1 ===
 +
 
 +
Open the terminal window.
 +
 
 +
=== Step 2 === 
 +
 
 +
In the terminal window, go to the hello world example folder.
  
*Step 1 - Open the terminal window.
 
*Step 2 - In the terminal window, go to the hello world example folder.
 
 
:: <code>.cd /examples/hello-world</code>
 
:: <code>.cd /examples/hello-world</code>
*Step 3 - Compile the code for the native platform (to be used when no mote is connected to the laptop.)
+
 
 +
===Step 3===
 +
 
 +
Compile the code for the native platform (to be used when no mote is connected to the laptop.)
 +
 
 
:: <code>make TARGET=native</code>
 
:: <code>make TARGET=native</code>
*Step 4 - Once the compilation is over, run the Hello World program.  
+
 
 +
=== Step 4 ===
 +
 
 +
Once the compilation is over, run the Hello World program.  
 +
 
 
:: <code>./hello-world.native</code>
 
:: <code>./hello-world.native</code>
*Step 5 - This will print the words "Hello, world" on the terminal window. The code will appear to hang, however, it is still running on Contiki, but not producing any output as the Hello World program is finished. Press Ctrl-C to quit.
+
 
 +
=== Step 5 ===
 +
 
 +
This will print the words "Hello, world" on the terminal window. The code will appear to hang, however, it is still running on Contiki, but not producing any output as the Hello World program is finished. Press Ctrl-C to quit.
  
 
'''Hello World on the Tmote Sky!'''
 
'''Hello World on the Tmote Sky!'''
 +
 
*Step 1 - Using the opened terminal window compile and upload the Hello World program on the Tmote Sky.
 
*Step 1 - Using the opened terminal window compile and upload the Hello World program on the Tmote Sky.
 
:: <code>make TARGET=sky savetarget</code>  (This save the target for any future compilations)
 
:: <code>make TARGET=sky savetarget</code>  (This save the target for any future compilations)

Revision as of 14:21, 19 February 2014

Back to Contiki Tutorials

Introduction

This article is about the Hello World program, which is used to show the compilation and upload steps of a simple program on a Tmote Sky.

You will learn

This tutorial teaches you how to compile a program on Contiki OS and also the most basic syntax of programming in ContikiOS.

Step 1

Open the terminal window.

Step 2

In the terminal window, go to the hello world example folder.

.cd /examples/hello-world

Step 3

Compile the code for the native platform (to be used when no mote is connected to the laptop.)

make TARGET=native

Step 4

Once the compilation is over, run the Hello World program.

./hello-world.native

Step 5

This will print the words "Hello, world" on the terminal window. The code will appear to hang, however, it is still running on Contiki, but not producing any output as the Hello World program is finished. Press Ctrl-C to quit.

Hello World on the Tmote Sky!

  • Step 1 - Using the opened terminal window compile and upload the Hello World program on the Tmote Sky.
make TARGET=sky savetarget (This save the target for any future compilations)
make hello-world.upload (This will upload the code on the Tmote Sky)
make login (This will enable us to view the output. If permission error occurs, use sudo command at the beginning)
  • Step 2 - Press the reset button on the Tmote Sky. The following message will appear on the terminal window -
Contiki 2.7 started. Node id is set to 3.
Rime started with address 3.0
MAC 00:12:ff:11:65:23:52:ed
Starting 'Hello world process'
Hello, world
The boot up code of Contiki-OS prints the first four lines whereas the last line is printed by the Hello World program.
  • Step 3 - Press Ctrl-C to quit.


Back to Contiki Tutorials