<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://anrg.usc.edu/contiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Haimobai</id>
		<title>Contiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://anrg.usc.edu/contiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Haimobai"/>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php/Special:Contributions/Haimobai"/>
		<updated>2026-10-07T14:33:29Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Contiki_Programming_Guide&amp;diff=1310</id>
		<title>Contiki Programming Guide</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Contiki_Programming_Guide&amp;diff=1310"/>
				<updated>2014-11-09T04:16:36Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: /* Modifying the Makefiles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
•	Contiki  is developed by a group of developers from industry and academia lead by &amp;#039;&amp;#039;&amp;#039;Adam Dunkels&amp;#039;&amp;#039;&amp;#039; from the Swedish Institute of Computer Science. The Contiki team currently  consists  of tens of developers  from &amp;#039;&amp;#039;&amp;#039;SICS, SAP AG, Cisco, Atmel, NewAE and TU  Munich(Technical University of Munich).&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
----&lt;br /&gt;
•	Contiki is &amp;#039;&amp;#039;&amp;#039;multi-tasking&amp;#039;&amp;#039;&amp;#039; operating system, especially designed for microcontrollers with small &amp;#039;&amp;#039;&amp;#039;amount of memory&amp;#039;&amp;#039;&amp;#039;(35KB of ROM and around 3K of RAM), which are used in networked embedded systems and wireless sensor networks.&lt;br /&gt;
----&lt;br /&gt;
•	Contiki is written in the C programming language. &lt;br /&gt;
----&lt;br /&gt;
•	It is freely available as open source under a &amp;#039;&amp;#039;&amp;#039;BSD-style license&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
----&lt;br /&gt;
•	Contiki was the &amp;#039;&amp;#039;&amp;#039;first&amp;#039;&amp;#039;&amp;#039; OS which introduced IP communication in low-power sensor networks&lt;br /&gt;
&lt;br /&gt;
== You will learn ==&lt;br /&gt;
Understand the idea of threads and Events for Contiki&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Review for Protothreads and Events ==&lt;br /&gt;
Define system processes&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
procinit(&amp;amp;etimer_process, &amp;amp;mac_process, &amp;amp;tcpip_process);&lt;br /&gt;
#define PROCINIT(...)&lt;br /&gt;
const struct process *prooinit[] = {__VA_ARGS__, NULL}&lt;br /&gt;
void procinit_init(void){&lt;br /&gt;
    int i;&lt;br /&gt;
    for(i = 0; procinit[i] != NULL; ++i){&lt;br /&gt;
        process_start((struct process *)procinit[i], NULL);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(void){&lt;br /&gt;
    /*initialize hardware*/&lt;br /&gt;
    intit_lowlevel();&lt;br /&gt;
    clock_init();&lt;br /&gt;
    process_init();&lt;br /&gt;
    procinit_init();&lt;br /&gt;
    autostart_start(autostart_processes);&lt;br /&gt;
    printf(&amp;quot;*****************BOOTING CONTIKI****************\n&amp;quot;);&lt;br /&gt;
    while(1){&lt;br /&gt;
        process_run();&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The process thread in this part&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
PROCESS_THREAD(tcpip_process, ev, data);&lt;br /&gt;
PROCESS_THREAD(mac_process, ev, data);&lt;br /&gt;
PROCESS_THREAD(etimer_process, ev, data){&lt;br /&gt;
    struct etimer *t, *u;&lt;br /&gt;
    PROCESS_BEGIN();&lt;br /&gt;
    timerlist = NULL;&lt;br /&gt;
    while(1){&lt;br /&gt;
        PROCESS_YIELD();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Start system processes&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void&lt;br /&gt;
process_start(struct process *p, cnst char *arg){&lt;br /&gt;
    struct process *q;&lt;br /&gt;
    /*first make sure that we do not try to start a process that is already running*/&lt;br /&gt;
    for(q = process_list; q != p &amp;amp;&amp;amp; q != NULL; q = q-&amp;gt;next);&lt;br /&gt;
    /*If we found the process on the process list, we will bail out*/&lt;br /&gt;
    if(q == p){&lt;br /&gt;
         return;&lt;br /&gt;
    }&lt;br /&gt;
    /*Put on the process list*/&lt;br /&gt;
    p-&amp;gt;next = process_list;&lt;br /&gt;
    process_list = p;&lt;br /&gt;
    p-&amp;gt;state = PROCESS_STATE_RUNNING;&lt;br /&gt;
    PT_INIT(&amp;amp;p-&amp;gt;pt);&lt;br /&gt;
    &lt;br /&gt;
    printf(&amp;quot;process: starting &amp;#039;%s&amp;#039;\n&amp;quot;, p-&amp;gt;name);&lt;br /&gt;
    /*Post a synchronous initialization event to the process*/&lt;br /&gt;
    process_post_synch(p, PROCESS_EVENT_INIT, (process_data_t)arg);&lt;br /&gt;
}&lt;br /&gt;
/*----------------------------------------------------------------------------------*/&lt;br /&gt;
/* PROCESS_POST_SYNCH will execute code between PROCESS_BEGIN(); and PROCESS_YIELD();*/&lt;br /&gt;
PROCESS_THREAD(etimer_process, ev, data){&lt;br /&gt;
    struct etimer *t, *u;&lt;br /&gt;
    PROCESS_BEGIN();&lt;br /&gt;
    timerlist = NULL;&lt;br /&gt;
    while(1){&lt;br /&gt;
        PROCESS_YIELD();&lt;br /&gt;
        if(ev == PROCESS_EVENT_EXITED){&lt;br /&gt;
            struct process *p = data;&lt;br /&gt;
            while(timerlist != NULL &amp;amp;&amp;amp; timerlist -&amp;gt; p == p){&lt;br /&gt;
                timerlist = timerlist -&amp;gt; next;&lt;br /&gt;
            }&lt;br /&gt;
            if(timerlist != NULL){&lt;br /&gt;
                 t = timerlist;&lt;br /&gt;
                 while(t -&amp;gt; next != NULL){&lt;br /&gt;
                     t = timerlist -&amp;gt; next;&lt;br /&gt;
                 }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Start user processes&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/*PROCINIT(&amp;amp;etimer_process, &amp;amp;mac_process, &amp;amp;tcpip_process);*/&lt;br /&gt;
/*follow by define system processes main function*/&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;temp_measure_cmd_sender, &amp;amp;serial_cmd_process){&lt;br /&gt;
     int i;&lt;br /&gt;
     for(i = 0; processes[i] != NULL; ++i){&lt;br /&gt;
          process_start(processes[i], NULL);&lt;br /&gt;
          PRINTF(&amp;quot;autostart_start: starting process &amp;#039;%s&amp;#039;\n&amp;quot;, processes[i]-&amp;gt;name);&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The process thread in this part&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
PROCESS_THREAD(temp_measure_cmd_sender, ev, data);&lt;br /&gt;
PROCESS_THREAD(serial_cmd_process, ev, data){&lt;br /&gt;
     PROCESS_BEGIN();&lt;br /&gt;
     while(1){&lt;br /&gt;
         PROCESS_WAIT_EVEN();&lt;br /&gt;
         if(ev = SERIAL_CMD){&lt;br /&gt;
             process_post(&amp;amp;temp_measure_cmd_sender, TEMP_CMD, 0);&lt;br /&gt;
         } &lt;br /&gt;
     }&lt;br /&gt;
     PROCESS_END();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Main scheduler loop&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/*loop until poll_requested == 1 || nevents &amp;gt; 0*/&lt;br /&gt;
int process_run(void){&lt;br /&gt;
    /*process poll events*/&lt;br /&gt;
    if(pull_requested){&lt;br /&gt;
        do_poll();&lt;br /&gt;
    }&lt;br /&gt;
    /*Process one event from the queue*/&lt;br /&gt;
    do_event();&lt;br /&gt;
    &lt;br /&gt;
    return nevents + poll_requested;    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void do_event(void){&lt;br /&gt;
    /*&lt;br /&gt;
    if there are any events in the queue, take the first one and walk through the&lt;br /&gt;
    list of processes to see if the event should be delivered to any of them. If &lt;br /&gt;
    so, we call the event handler function for the process. We only process one &lt;br /&gt;
    event at a time and call the poll handlers inbetween.&lt;br /&gt;
    */&lt;br /&gt;
    if(nevents &amp;gt;0){&lt;br /&gt;
       ...&lt;br /&gt;
       call_process(receiver, ev, data);  &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Method: POLL&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
ISR(AVR_OUTPUT_COMPARE_INT){&lt;br /&gt;
    ++count;&lt;br /&gt;
    if(etimer_pending()){&lt;br /&gt;
         etimer_request_poll();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
void etimer_request_poll(void){&lt;br /&gt;
    process_poll(&amp;amp;etimer_process);&lt;br /&gt;
}&lt;br /&gt;
void process_poll(struct process *p){&lt;br /&gt;
    if(p != NULL){&lt;br /&gt;
        if(p-&amp;gt;state == PROCESS_STATE_RUNNING ||&lt;br /&gt;
           p-&amp;gt;state == PROCESS_STATE_CALLED){&lt;br /&gt;
           p-&amp;gt;needspoll = 1;&lt;br /&gt;
           poll_requested = 1;&lt;br /&gt;
        }   &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
int process_run(void){&lt;br /&gt;
    /*process poll events*/&lt;br /&gt;
    if(poll_requested){&lt;br /&gt;
        do_poll();&lt;br /&gt;
    }&lt;br /&gt;
    /*Process one event from the queue*/&lt;br /&gt;
    do_event();&lt;br /&gt;
    return nevents + poll_requested;&lt;br /&gt;
}&lt;br /&gt;
static void do_poll(void){&lt;br /&gt;
    struct process *p;&lt;br /&gt;
    poll_requested = 0;&lt;br /&gt;
    /*Call the processes that needs to be polled*/&lt;br /&gt;
    for(p = process_list; p != NULL; p = p-&amp;gt;next){&lt;br /&gt;
        if(p-&amp;gt;needspoll){&lt;br /&gt;
            p-&amp;gt;state = PROCESS_STATE_RUNNING;&lt;br /&gt;
            p-&amp;gt;needspoll = 0;&lt;br /&gt;
            call_process(p, PROCESS_EVENT_POLL, NULL);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Method: POST&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
PROCESS_THREAD(etimer_process, ev, data){&lt;br /&gt;
    ...&lt;br /&gt;
    for(t = timerlist; t != NULL; t = t-&amp;gt;next){&lt;br /&gt;
        if(timer_expired(&amp;amp;t-&amp;gt;timer)){&lt;br /&gt;
             if(process_post(t-&amp;gt;p, PROCESS_EVENT_TIMER, t) == PROCESS_ERR_OK)&lt;br /&gt;
             ...&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
int process_post(struct process *p, process_event_t ev, process_data_t data){&lt;br /&gt;
    ...&lt;br /&gt;
    anum = (fevent + nevents) % PROCESS_CONF_NUMEVENTS;&lt;br /&gt;
    events[snum].ev = ev;&lt;br /&gt;
    events[snum].data = data;&lt;br /&gt;
    events[snum].p = p;&lt;br /&gt;
    ++ nevents;&lt;br /&gt;
    ...&lt;br /&gt;
}&lt;br /&gt;
int process_run(void){&lt;br /&gt;
    /*Process poll events*/&lt;br /&gt;
    if(poll_requested){&lt;br /&gt;
        do_poll();&lt;br /&gt;
    }&lt;br /&gt;
    /*Process one event from the queue*/&lt;br /&gt;
    do_event();&lt;br /&gt;
    return nevents + poll_requested;&lt;br /&gt;
}&lt;br /&gt;
static void do_event(void){&lt;br /&gt;
    ...&lt;br /&gt;
    /*&lt;br /&gt;
    if there are any events in the queue, take the first one and walk through the&lt;br /&gt;
    list of processes to see if the event should be delivered to any of them. If &lt;br /&gt;
    so, we call the event handler function for the process. We only process one &lt;br /&gt;
    event at a time and call the poll handlers inbetween.&lt;br /&gt;
    */&lt;br /&gt;
    if(nevents &amp;gt; 0){&lt;br /&gt;
        ...&lt;br /&gt;
        call_process(reveiver, ev, data);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It is clear to see according to the figure 1 &lt;br /&gt;
----&lt;br /&gt;
[[File:1.jpg]]&lt;br /&gt;
figure 1&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Code Style: Names in Contiki&lt;br /&gt;
In Contiki, all names are prefixed with the module name&lt;br /&gt;
(example: process_start(), rime_init(), clock_time(), memb_alloc(), list_add()...)&lt;br /&gt;
Prefix makes it possible to mentally locate all function calls&lt;br /&gt;
All code must abide by this: &lt;br /&gt;
There are a few exceptions in the current code, but those are to be removed in the future&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Code Style: What to avoid&lt;br /&gt;
 -noCamelCase()&lt;br /&gt;
 -No_Capital_letters()&lt;br /&gt;
 -#define EXCEPT_FOR_MACROS()&lt;br /&gt;
----&lt;br /&gt;
Code Sytle: File names&lt;br /&gt;
Contiki uses hyphenated-file-names rather than underscore_in_file_names&lt;br /&gt;
&lt;br /&gt;
== The Motivation – Safe Tiny OS ==&lt;br /&gt;
&lt;br /&gt;
The Safe Tiny OS tool chain is shown in Figure 2. The most immediate benefit of Safe TinyOS was that during its development 4 severe bugs in TinyOS could be found out and were corrected.&lt;br /&gt;
----&lt;br /&gt;
[[File:2.png]]&lt;br /&gt;
figure 2&lt;br /&gt;
----&lt;br /&gt;
Building A Safe Application&lt;br /&gt;
&lt;br /&gt;
To build an application Safe, we have to provide the parameter ‘safe’ in the command line of ‘make’.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 cd $TOSROOT/apps/Blink &lt;br /&gt;
 make micaz safe&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
== Making Safety Optional ==&lt;br /&gt;
=== Implementation Overview ===&lt;br /&gt;
The source code of Contiki consists of nearly 1200 files, including both the OS core and the applications. The OS core itself consists of around 300 files. The work comprises of annotating each pointer access in all these files and recompiling with Deputy. Once the core is free of Safety errors, we can go for the Safety of applications. After this step, we set Deputy as the default compiler of Contiki. Programmers will have to adapt to the Annotations of Deputy, which are very simple and easy to learn.&lt;br /&gt;
----&lt;br /&gt;
The flow graph of Safe Contiki development is given in Figure 3&lt;br /&gt;
----&lt;br /&gt;
[[File:3.jpg]]&lt;br /&gt;
figure 3&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Modifying the Makefiles ===&lt;br /&gt;
The implementation was started by editing the makefiles associated with the ‘native’ processor. The Makefile.native mainly contains definitions for the C compiler used for the native processor. The file is located in contiki-2.x/cpu/native/ directory. The current contents of the 6th and 7th lines are&lt;br /&gt;
 - CC = gcc&lt;br /&gt;
 - LD = gcc&lt;br /&gt;
----&lt;br /&gt;
which indicates that for the native CPU, the compiler and the linker are the same, the gcc. We replaced this with&lt;br /&gt;
 - CC = deputy&lt;br /&gt;
 - LD = deputy&lt;br /&gt;
&lt;br /&gt;
=== A New Argument To Make ===&lt;br /&gt;
As an illustration of how the SAFETY argument is used, the following commands will create the Safe version of the ‘hello-world’ program for the ‘native’ platform.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 cd /home/user/contiki-2.x/examples/hello-world/&lt;br /&gt;
 make TARGET=native SAFETY=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Safety is an optional feature; programs are made Unsafe, by default. The following command makes the program without Safety features, for the ‘native’ platform.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
make TARGET=native&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conditional Making And The gcc -D Flag ===&lt;br /&gt;
In order to make ‘making’ conditional, depending on the value of the variable SAFETY, we further modified the Makefile.native file in the contiki-2.x/cpu/native/ directory.&lt;br /&gt;
Makefile.native is shown below&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
ifeq ($(SAFETY),yes)&lt;br /&gt;
CC = deputy&lt;br /&gt;
LD = deputy&lt;br /&gt;
else&lt;br /&gt;
CC = gcc&lt;br /&gt;
LD = gcc&lt;br /&gt;
CFLAGS += -DNTS=&amp;#039;&amp;#039; -DSAFE=&amp;#039;&amp;#039; \&lt;br /&gt;
-DCOUNT\(x\)=&amp;#039;&amp;#039; \&lt;br /&gt;
-DTC\(x\)=x -DBOUND\(x,y\)=&amp;#039;&amp;#039; \&lt;br /&gt;
-DTRUSTED=&amp;#039;&amp;#039; -DNTDROP\(x\)=x \&lt;br /&gt;
-DNTEXPAND\(x\)=x&lt;br /&gt;
endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
[1]The Safe TinyOS, 2008. http://docs.tinyos.net/index.php/Safe_TinyOS&lt;br /&gt;
[2]The Contiki OS, http://www.sics.se/contiki/&lt;br /&gt;
[2]Contiki Programming, 2011. http://wenku.baidu.com/view/&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Contiki_Programming_Guide&amp;diff=1309</id>
		<title>Contiki Programming Guide</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Contiki_Programming_Guide&amp;diff=1309"/>
				<updated>2014-11-09T04:16:17Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: /* Conditional Making And The gcc -D Flag */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
•	Contiki  is developed by a group of developers from industry and academia lead by &amp;#039;&amp;#039;&amp;#039;Adam Dunkels&amp;#039;&amp;#039;&amp;#039; from the Swedish Institute of Computer Science. The Contiki team currently  consists  of tens of developers  from &amp;#039;&amp;#039;&amp;#039;SICS, SAP AG, Cisco, Atmel, NewAE and TU  Munich(Technical University of Munich).&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
----&lt;br /&gt;
•	Contiki is &amp;#039;&amp;#039;&amp;#039;multi-tasking&amp;#039;&amp;#039;&amp;#039; operating system, especially designed for microcontrollers with small &amp;#039;&amp;#039;&amp;#039;amount of memory&amp;#039;&amp;#039;&amp;#039;(35KB of ROM and around 3K of RAM), which are used in networked embedded systems and wireless sensor networks.&lt;br /&gt;
----&lt;br /&gt;
•	Contiki is written in the C programming language. &lt;br /&gt;
----&lt;br /&gt;
•	It is freely available as open source under a &amp;#039;&amp;#039;&amp;#039;BSD-style license&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
----&lt;br /&gt;
•	Contiki was the &amp;#039;&amp;#039;&amp;#039;first&amp;#039;&amp;#039;&amp;#039; OS which introduced IP communication in low-power sensor networks&lt;br /&gt;
&lt;br /&gt;
== You will learn ==&lt;br /&gt;
Understand the idea of threads and Events for Contiki&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Review for Protothreads and Events ==&lt;br /&gt;
Define system processes&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
procinit(&amp;amp;etimer_process, &amp;amp;mac_process, &amp;amp;tcpip_process);&lt;br /&gt;
#define PROCINIT(...)&lt;br /&gt;
const struct process *prooinit[] = {__VA_ARGS__, NULL}&lt;br /&gt;
void procinit_init(void){&lt;br /&gt;
    int i;&lt;br /&gt;
    for(i = 0; procinit[i] != NULL; ++i){&lt;br /&gt;
        process_start((struct process *)procinit[i], NULL);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(void){&lt;br /&gt;
    /*initialize hardware*/&lt;br /&gt;
    intit_lowlevel();&lt;br /&gt;
    clock_init();&lt;br /&gt;
    process_init();&lt;br /&gt;
    procinit_init();&lt;br /&gt;
    autostart_start(autostart_processes);&lt;br /&gt;
    printf(&amp;quot;*****************BOOTING CONTIKI****************\n&amp;quot;);&lt;br /&gt;
    while(1){&lt;br /&gt;
        process_run();&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The process thread in this part&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
PROCESS_THREAD(tcpip_process, ev, data);&lt;br /&gt;
PROCESS_THREAD(mac_process, ev, data);&lt;br /&gt;
PROCESS_THREAD(etimer_process, ev, data){&lt;br /&gt;
    struct etimer *t, *u;&lt;br /&gt;
    PROCESS_BEGIN();&lt;br /&gt;
    timerlist = NULL;&lt;br /&gt;
    while(1){&lt;br /&gt;
        PROCESS_YIELD();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Start system processes&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void&lt;br /&gt;
process_start(struct process *p, cnst char *arg){&lt;br /&gt;
    struct process *q;&lt;br /&gt;
    /*first make sure that we do not try to start a process that is already running*/&lt;br /&gt;
    for(q = process_list; q != p &amp;amp;&amp;amp; q != NULL; q = q-&amp;gt;next);&lt;br /&gt;
    /*If we found the process on the process list, we will bail out*/&lt;br /&gt;
    if(q == p){&lt;br /&gt;
         return;&lt;br /&gt;
    }&lt;br /&gt;
    /*Put on the process list*/&lt;br /&gt;
    p-&amp;gt;next = process_list;&lt;br /&gt;
    process_list = p;&lt;br /&gt;
    p-&amp;gt;state = PROCESS_STATE_RUNNING;&lt;br /&gt;
    PT_INIT(&amp;amp;p-&amp;gt;pt);&lt;br /&gt;
    &lt;br /&gt;
    printf(&amp;quot;process: starting &amp;#039;%s&amp;#039;\n&amp;quot;, p-&amp;gt;name);&lt;br /&gt;
    /*Post a synchronous initialization event to the process*/&lt;br /&gt;
    process_post_synch(p, PROCESS_EVENT_INIT, (process_data_t)arg);&lt;br /&gt;
}&lt;br /&gt;
/*----------------------------------------------------------------------------------*/&lt;br /&gt;
/* PROCESS_POST_SYNCH will execute code between PROCESS_BEGIN(); and PROCESS_YIELD();*/&lt;br /&gt;
PROCESS_THREAD(etimer_process, ev, data){&lt;br /&gt;
    struct etimer *t, *u;&lt;br /&gt;
    PROCESS_BEGIN();&lt;br /&gt;
    timerlist = NULL;&lt;br /&gt;
    while(1){&lt;br /&gt;
        PROCESS_YIELD();&lt;br /&gt;
        if(ev == PROCESS_EVENT_EXITED){&lt;br /&gt;
            struct process *p = data;&lt;br /&gt;
            while(timerlist != NULL &amp;amp;&amp;amp; timerlist -&amp;gt; p == p){&lt;br /&gt;
                timerlist = timerlist -&amp;gt; next;&lt;br /&gt;
            }&lt;br /&gt;
            if(timerlist != NULL){&lt;br /&gt;
                 t = timerlist;&lt;br /&gt;
                 while(t -&amp;gt; next != NULL){&lt;br /&gt;
                     t = timerlist -&amp;gt; next;&lt;br /&gt;
                 }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Start user processes&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/*PROCINIT(&amp;amp;etimer_process, &amp;amp;mac_process, &amp;amp;tcpip_process);*/&lt;br /&gt;
/*follow by define system processes main function*/&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;temp_measure_cmd_sender, &amp;amp;serial_cmd_process){&lt;br /&gt;
     int i;&lt;br /&gt;
     for(i = 0; processes[i] != NULL; ++i){&lt;br /&gt;
          process_start(processes[i], NULL);&lt;br /&gt;
          PRINTF(&amp;quot;autostart_start: starting process &amp;#039;%s&amp;#039;\n&amp;quot;, processes[i]-&amp;gt;name);&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The process thread in this part&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
PROCESS_THREAD(temp_measure_cmd_sender, ev, data);&lt;br /&gt;
PROCESS_THREAD(serial_cmd_process, ev, data){&lt;br /&gt;
     PROCESS_BEGIN();&lt;br /&gt;
     while(1){&lt;br /&gt;
         PROCESS_WAIT_EVEN();&lt;br /&gt;
         if(ev = SERIAL_CMD){&lt;br /&gt;
             process_post(&amp;amp;temp_measure_cmd_sender, TEMP_CMD, 0);&lt;br /&gt;
         } &lt;br /&gt;
     }&lt;br /&gt;
     PROCESS_END();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Main scheduler loop&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/*loop until poll_requested == 1 || nevents &amp;gt; 0*/&lt;br /&gt;
int process_run(void){&lt;br /&gt;
    /*process poll events*/&lt;br /&gt;
    if(pull_requested){&lt;br /&gt;
        do_poll();&lt;br /&gt;
    }&lt;br /&gt;
    /*Process one event from the queue*/&lt;br /&gt;
    do_event();&lt;br /&gt;
    &lt;br /&gt;
    return nevents + poll_requested;    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void do_event(void){&lt;br /&gt;
    /*&lt;br /&gt;
    if there are any events in the queue, take the first one and walk through the&lt;br /&gt;
    list of processes to see if the event should be delivered to any of them. If &lt;br /&gt;
    so, we call the event handler function for the process. We only process one &lt;br /&gt;
    event at a time and call the poll handlers inbetween.&lt;br /&gt;
    */&lt;br /&gt;
    if(nevents &amp;gt;0){&lt;br /&gt;
       ...&lt;br /&gt;
       call_process(receiver, ev, data);  &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Method: POLL&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
ISR(AVR_OUTPUT_COMPARE_INT){&lt;br /&gt;
    ++count;&lt;br /&gt;
    if(etimer_pending()){&lt;br /&gt;
         etimer_request_poll();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
void etimer_request_poll(void){&lt;br /&gt;
    process_poll(&amp;amp;etimer_process);&lt;br /&gt;
}&lt;br /&gt;
void process_poll(struct process *p){&lt;br /&gt;
    if(p != NULL){&lt;br /&gt;
        if(p-&amp;gt;state == PROCESS_STATE_RUNNING ||&lt;br /&gt;
           p-&amp;gt;state == PROCESS_STATE_CALLED){&lt;br /&gt;
           p-&amp;gt;needspoll = 1;&lt;br /&gt;
           poll_requested = 1;&lt;br /&gt;
        }   &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
int process_run(void){&lt;br /&gt;
    /*process poll events*/&lt;br /&gt;
    if(poll_requested){&lt;br /&gt;
        do_poll();&lt;br /&gt;
    }&lt;br /&gt;
    /*Process one event from the queue*/&lt;br /&gt;
    do_event();&lt;br /&gt;
    return nevents + poll_requested;&lt;br /&gt;
}&lt;br /&gt;
static void do_poll(void){&lt;br /&gt;
    struct process *p;&lt;br /&gt;
    poll_requested = 0;&lt;br /&gt;
    /*Call the processes that needs to be polled*/&lt;br /&gt;
    for(p = process_list; p != NULL; p = p-&amp;gt;next){&lt;br /&gt;
        if(p-&amp;gt;needspoll){&lt;br /&gt;
            p-&amp;gt;state = PROCESS_STATE_RUNNING;&lt;br /&gt;
            p-&amp;gt;needspoll = 0;&lt;br /&gt;
            call_process(p, PROCESS_EVENT_POLL, NULL);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Method: POST&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
PROCESS_THREAD(etimer_process, ev, data){&lt;br /&gt;
    ...&lt;br /&gt;
    for(t = timerlist; t != NULL; t = t-&amp;gt;next){&lt;br /&gt;
        if(timer_expired(&amp;amp;t-&amp;gt;timer)){&lt;br /&gt;
             if(process_post(t-&amp;gt;p, PROCESS_EVENT_TIMER, t) == PROCESS_ERR_OK)&lt;br /&gt;
             ...&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
int process_post(struct process *p, process_event_t ev, process_data_t data){&lt;br /&gt;
    ...&lt;br /&gt;
    anum = (fevent + nevents) % PROCESS_CONF_NUMEVENTS;&lt;br /&gt;
    events[snum].ev = ev;&lt;br /&gt;
    events[snum].data = data;&lt;br /&gt;
    events[snum].p = p;&lt;br /&gt;
    ++ nevents;&lt;br /&gt;
    ...&lt;br /&gt;
}&lt;br /&gt;
int process_run(void){&lt;br /&gt;
    /*Process poll events*/&lt;br /&gt;
    if(poll_requested){&lt;br /&gt;
        do_poll();&lt;br /&gt;
    }&lt;br /&gt;
    /*Process one event from the queue*/&lt;br /&gt;
    do_event();&lt;br /&gt;
    return nevents + poll_requested;&lt;br /&gt;
}&lt;br /&gt;
static void do_event(void){&lt;br /&gt;
    ...&lt;br /&gt;
    /*&lt;br /&gt;
    if there are any events in the queue, take the first one and walk through the&lt;br /&gt;
    list of processes to see if the event should be delivered to any of them. If &lt;br /&gt;
    so, we call the event handler function for the process. We only process one &lt;br /&gt;
    event at a time and call the poll handlers inbetween.&lt;br /&gt;
    */&lt;br /&gt;
    if(nevents &amp;gt; 0){&lt;br /&gt;
        ...&lt;br /&gt;
        call_process(reveiver, ev, data);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It is clear to see according to the figure 1 &lt;br /&gt;
----&lt;br /&gt;
[[File:1.jpg]]&lt;br /&gt;
figure 1&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Code Style: Names in Contiki&lt;br /&gt;
In Contiki, all names are prefixed with the module name&lt;br /&gt;
(example: process_start(), rime_init(), clock_time(), memb_alloc(), list_add()...)&lt;br /&gt;
Prefix makes it possible to mentally locate all function calls&lt;br /&gt;
All code must abide by this: &lt;br /&gt;
There are a few exceptions in the current code, but those are to be removed in the future&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Code Style: What to avoid&lt;br /&gt;
 -noCamelCase()&lt;br /&gt;
 -No_Capital_letters()&lt;br /&gt;
 -#define EXCEPT_FOR_MACROS()&lt;br /&gt;
----&lt;br /&gt;
Code Sytle: File names&lt;br /&gt;
Contiki uses hyphenated-file-names rather than underscore_in_file_names&lt;br /&gt;
&lt;br /&gt;
== The Motivation – Safe Tiny OS ==&lt;br /&gt;
&lt;br /&gt;
The Safe Tiny OS tool chain is shown in Figure 2. The most immediate benefit of Safe TinyOS was that during its development 4 severe bugs in TinyOS could be found out and were corrected.&lt;br /&gt;
----&lt;br /&gt;
[[File:2.png]]&lt;br /&gt;
figure 2&lt;br /&gt;
----&lt;br /&gt;
Building A Safe Application&lt;br /&gt;
&lt;br /&gt;
To build an application Safe, we have to provide the parameter ‘safe’ in the command line of ‘make’.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 cd $TOSROOT/apps/Blink &lt;br /&gt;
 make micaz safe&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
== Making Safety Optional ==&lt;br /&gt;
=== Implementation Overview ===&lt;br /&gt;
The source code of Contiki consists of nearly 1200 files, including both the OS core and the applications. The OS core itself consists of around 300 files. The work comprises of annotating each pointer access in all these files and recompiling with Deputy. Once the core is free of Safety errors, we can go for the Safety of applications. After this step, we set Deputy as the default compiler of Contiki. Programmers will have to adapt to the Annotations of Deputy, which are very simple and easy to learn.&lt;br /&gt;
----&lt;br /&gt;
The flow graph of Safe Contiki development is given in Figure 3&lt;br /&gt;
----&lt;br /&gt;
[[File:3.jpg]]&lt;br /&gt;
figure 3&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Modifying the Makefiles ===&lt;br /&gt;
The implementation was started by editing the makefiles associated with the ‘native’ processor. The Makefile.native mainly contains definitions for the C compiler used for the native processor. The file is located in contiki-2.x/cpu/native/ directory. The current contents of the 6th and 7th lines are&lt;br /&gt;
 - CC = gcc&lt;br /&gt;
 - LD = gcc&lt;br /&gt;
----&lt;br /&gt;
which indicates that for the native CPU, the compiler and the linker are the same, the gcc. We replaced this with&lt;br /&gt;
 - CC = deputy&lt;br /&gt;
 - LD = deputy&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== A New Argument To Make ===&lt;br /&gt;
As an illustration of how the SAFETY argument is used, the following commands will create the Safe version of the ‘hello-world’ program for the ‘native’ platform.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 cd /home/user/contiki-2.x/examples/hello-world/&lt;br /&gt;
 make TARGET=native SAFETY=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Safety is an optional feature; programs are made Unsafe, by default. The following command makes the program without Safety features, for the ‘native’ platform.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
make TARGET=native&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conditional Making And The gcc -D Flag ===&lt;br /&gt;
In order to make ‘making’ conditional, depending on the value of the variable SAFETY, we further modified the Makefile.native file in the contiki-2.x/cpu/native/ directory.&lt;br /&gt;
Makefile.native is shown below&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
ifeq ($(SAFETY),yes)&lt;br /&gt;
CC = deputy&lt;br /&gt;
LD = deputy&lt;br /&gt;
else&lt;br /&gt;
CC = gcc&lt;br /&gt;
LD = gcc&lt;br /&gt;
CFLAGS += -DNTS=&amp;#039;&amp;#039; -DSAFE=&amp;#039;&amp;#039; \&lt;br /&gt;
-DCOUNT\(x\)=&amp;#039;&amp;#039; \&lt;br /&gt;
-DTC\(x\)=x -DBOUND\(x,y\)=&amp;#039;&amp;#039; \&lt;br /&gt;
-DTRUSTED=&amp;#039;&amp;#039; -DNTDROP\(x\)=x \&lt;br /&gt;
-DNTEXPAND\(x\)=x&lt;br /&gt;
endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
[1]The Safe TinyOS, 2008. http://docs.tinyos.net/index.php/Safe_TinyOS&lt;br /&gt;
[2]The Contiki OS, http://www.sics.se/contiki/&lt;br /&gt;
[2]Contiki Programming, 2011. http://wenku.baidu.com/view/&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Contiki_Programming_Guide&amp;diff=1307</id>
		<title>Contiki Programming Guide</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Contiki_Programming_Guide&amp;diff=1307"/>
				<updated>2014-11-09T04:13:20Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: Created page with &amp;quot;== Introduction == •	Contiki  is developed by a group of developers from industry and academia lead by &amp;#039;&amp;#039;&amp;#039;Adam Dunkels&amp;#039;&amp;#039;&amp;#039; from the Swedish Institute of Computer Science. The...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
•	Contiki  is developed by a group of developers from industry and academia lead by &amp;#039;&amp;#039;&amp;#039;Adam Dunkels&amp;#039;&amp;#039;&amp;#039; from the Swedish Institute of Computer Science. The Contiki team currently  consists  of tens of developers  from &amp;#039;&amp;#039;&amp;#039;SICS, SAP AG, Cisco, Atmel, NewAE and TU  Munich(Technical University of Munich).&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
----&lt;br /&gt;
•	Contiki is &amp;#039;&amp;#039;&amp;#039;multi-tasking&amp;#039;&amp;#039;&amp;#039; operating system, especially designed for microcontrollers with small &amp;#039;&amp;#039;&amp;#039;amount of memory&amp;#039;&amp;#039;&amp;#039;(35KB of ROM and around 3K of RAM), which are used in networked embedded systems and wireless sensor networks.&lt;br /&gt;
----&lt;br /&gt;
•	Contiki is written in the C programming language. &lt;br /&gt;
----&lt;br /&gt;
•	It is freely available as open source under a &amp;#039;&amp;#039;&amp;#039;BSD-style license&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
----&lt;br /&gt;
•	Contiki was the &amp;#039;&amp;#039;&amp;#039;first&amp;#039;&amp;#039;&amp;#039; OS which introduced IP communication in low-power sensor networks&lt;br /&gt;
&lt;br /&gt;
== You will learn ==&lt;br /&gt;
Understand the idea of threads and Events for Contiki&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Review for Protothreads and Events ==&lt;br /&gt;
Define system processes&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
procinit(&amp;amp;etimer_process, &amp;amp;mac_process, &amp;amp;tcpip_process);&lt;br /&gt;
#define PROCINIT(...)&lt;br /&gt;
const struct process *prooinit[] = {__VA_ARGS__, NULL}&lt;br /&gt;
void procinit_init(void){&lt;br /&gt;
    int i;&lt;br /&gt;
    for(i = 0; procinit[i] != NULL; ++i){&lt;br /&gt;
        process_start((struct process *)procinit[i], NULL);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(void){&lt;br /&gt;
    /*initialize hardware*/&lt;br /&gt;
    intit_lowlevel();&lt;br /&gt;
    clock_init();&lt;br /&gt;
    process_init();&lt;br /&gt;
    procinit_init();&lt;br /&gt;
    autostart_start(autostart_processes);&lt;br /&gt;
    printf(&amp;quot;*****************BOOTING CONTIKI****************\n&amp;quot;);&lt;br /&gt;
    while(1){&lt;br /&gt;
        process_run();&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The process thread in this part&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
PROCESS_THREAD(tcpip_process, ev, data);&lt;br /&gt;
PROCESS_THREAD(mac_process, ev, data);&lt;br /&gt;
PROCESS_THREAD(etimer_process, ev, data){&lt;br /&gt;
    struct etimer *t, *u;&lt;br /&gt;
    PROCESS_BEGIN();&lt;br /&gt;
    timerlist = NULL;&lt;br /&gt;
    while(1){&lt;br /&gt;
        PROCESS_YIELD();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Start system processes&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void&lt;br /&gt;
process_start(struct process *p, cnst char *arg){&lt;br /&gt;
    struct process *q;&lt;br /&gt;
    /*first make sure that we do not try to start a process that is already running*/&lt;br /&gt;
    for(q = process_list; q != p &amp;amp;&amp;amp; q != NULL; q = q-&amp;gt;next);&lt;br /&gt;
    /*If we found the process on the process list, we will bail out*/&lt;br /&gt;
    if(q == p){&lt;br /&gt;
         return;&lt;br /&gt;
    }&lt;br /&gt;
    /*Put on the process list*/&lt;br /&gt;
    p-&amp;gt;next = process_list;&lt;br /&gt;
    process_list = p;&lt;br /&gt;
    p-&amp;gt;state = PROCESS_STATE_RUNNING;&lt;br /&gt;
    PT_INIT(&amp;amp;p-&amp;gt;pt);&lt;br /&gt;
    &lt;br /&gt;
    printf(&amp;quot;process: starting &amp;#039;%s&amp;#039;\n&amp;quot;, p-&amp;gt;name);&lt;br /&gt;
    /*Post a synchronous initialization event to the process*/&lt;br /&gt;
    process_post_synch(p, PROCESS_EVENT_INIT, (process_data_t)arg);&lt;br /&gt;
}&lt;br /&gt;
/*----------------------------------------------------------------------------------*/&lt;br /&gt;
/* PROCESS_POST_SYNCH will execute code between PROCESS_BEGIN(); and PROCESS_YIELD();*/&lt;br /&gt;
PROCESS_THREAD(etimer_process, ev, data){&lt;br /&gt;
    struct etimer *t, *u;&lt;br /&gt;
    PROCESS_BEGIN();&lt;br /&gt;
    timerlist = NULL;&lt;br /&gt;
    while(1){&lt;br /&gt;
        PROCESS_YIELD();&lt;br /&gt;
        if(ev == PROCESS_EVENT_EXITED){&lt;br /&gt;
            struct process *p = data;&lt;br /&gt;
            while(timerlist != NULL &amp;amp;&amp;amp; timerlist -&amp;gt; p == p){&lt;br /&gt;
                timerlist = timerlist -&amp;gt; next;&lt;br /&gt;
            }&lt;br /&gt;
            if(timerlist != NULL){&lt;br /&gt;
                 t = timerlist;&lt;br /&gt;
                 while(t -&amp;gt; next != NULL){&lt;br /&gt;
                     t = timerlist -&amp;gt; next;&lt;br /&gt;
                 }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Start user processes&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/*PROCINIT(&amp;amp;etimer_process, &amp;amp;mac_process, &amp;amp;tcpip_process);*/&lt;br /&gt;
/*follow by define system processes main function*/&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;temp_measure_cmd_sender, &amp;amp;serial_cmd_process){&lt;br /&gt;
     int i;&lt;br /&gt;
     for(i = 0; processes[i] != NULL; ++i){&lt;br /&gt;
          process_start(processes[i], NULL);&lt;br /&gt;
          PRINTF(&amp;quot;autostart_start: starting process &amp;#039;%s&amp;#039;\n&amp;quot;, processes[i]-&amp;gt;name);&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The process thread in this part&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
PROCESS_THREAD(temp_measure_cmd_sender, ev, data);&lt;br /&gt;
PROCESS_THREAD(serial_cmd_process, ev, data){&lt;br /&gt;
     PROCESS_BEGIN();&lt;br /&gt;
     while(1){&lt;br /&gt;
         PROCESS_WAIT_EVEN();&lt;br /&gt;
         if(ev = SERIAL_CMD){&lt;br /&gt;
             process_post(&amp;amp;temp_measure_cmd_sender, TEMP_CMD, 0);&lt;br /&gt;
         } &lt;br /&gt;
     }&lt;br /&gt;
     PROCESS_END();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Main scheduler loop&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/*loop until poll_requested == 1 || nevents &amp;gt; 0*/&lt;br /&gt;
int process_run(void){&lt;br /&gt;
    /*process poll events*/&lt;br /&gt;
    if(pull_requested){&lt;br /&gt;
        do_poll();&lt;br /&gt;
    }&lt;br /&gt;
    /*Process one event from the queue*/&lt;br /&gt;
    do_event();&lt;br /&gt;
    &lt;br /&gt;
    return nevents + poll_requested;    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void do_event(void){&lt;br /&gt;
    /*&lt;br /&gt;
    if there are any events in the queue, take the first one and walk through the&lt;br /&gt;
    list of processes to see if the event should be delivered to any of them. If &lt;br /&gt;
    so, we call the event handler function for the process. We only process one &lt;br /&gt;
    event at a time and call the poll handlers inbetween.&lt;br /&gt;
    */&lt;br /&gt;
    if(nevents &amp;gt;0){&lt;br /&gt;
       ...&lt;br /&gt;
       call_process(receiver, ev, data);  &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Method: POLL&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
ISR(AVR_OUTPUT_COMPARE_INT){&lt;br /&gt;
    ++count;&lt;br /&gt;
    if(etimer_pending()){&lt;br /&gt;
         etimer_request_poll();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
void etimer_request_poll(void){&lt;br /&gt;
    process_poll(&amp;amp;etimer_process);&lt;br /&gt;
}&lt;br /&gt;
void process_poll(struct process *p){&lt;br /&gt;
    if(p != NULL){&lt;br /&gt;
        if(p-&amp;gt;state == PROCESS_STATE_RUNNING ||&lt;br /&gt;
           p-&amp;gt;state == PROCESS_STATE_CALLED){&lt;br /&gt;
           p-&amp;gt;needspoll = 1;&lt;br /&gt;
           poll_requested = 1;&lt;br /&gt;
        }   &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
int process_run(void){&lt;br /&gt;
    /*process poll events*/&lt;br /&gt;
    if(poll_requested){&lt;br /&gt;
        do_poll();&lt;br /&gt;
    }&lt;br /&gt;
    /*Process one event from the queue*/&lt;br /&gt;
    do_event();&lt;br /&gt;
    return nevents + poll_requested;&lt;br /&gt;
}&lt;br /&gt;
static void do_poll(void){&lt;br /&gt;
    struct process *p;&lt;br /&gt;
    poll_requested = 0;&lt;br /&gt;
    /*Call the processes that needs to be polled*/&lt;br /&gt;
    for(p = process_list; p != NULL; p = p-&amp;gt;next){&lt;br /&gt;
        if(p-&amp;gt;needspoll){&lt;br /&gt;
            p-&amp;gt;state = PROCESS_STATE_RUNNING;&lt;br /&gt;
            p-&amp;gt;needspoll = 0;&lt;br /&gt;
            call_process(p, PROCESS_EVENT_POLL, NULL);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Method: POST&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
PROCESS_THREAD(etimer_process, ev, data){&lt;br /&gt;
    ...&lt;br /&gt;
    for(t = timerlist; t != NULL; t = t-&amp;gt;next){&lt;br /&gt;
        if(timer_expired(&amp;amp;t-&amp;gt;timer)){&lt;br /&gt;
             if(process_post(t-&amp;gt;p, PROCESS_EVENT_TIMER, t) == PROCESS_ERR_OK)&lt;br /&gt;
             ...&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
int process_post(struct process *p, process_event_t ev, process_data_t data){&lt;br /&gt;
    ...&lt;br /&gt;
    anum = (fevent + nevents) % PROCESS_CONF_NUMEVENTS;&lt;br /&gt;
    events[snum].ev = ev;&lt;br /&gt;
    events[snum].data = data;&lt;br /&gt;
    events[snum].p = p;&lt;br /&gt;
    ++ nevents;&lt;br /&gt;
    ...&lt;br /&gt;
}&lt;br /&gt;
int process_run(void){&lt;br /&gt;
    /*Process poll events*/&lt;br /&gt;
    if(poll_requested){&lt;br /&gt;
        do_poll();&lt;br /&gt;
    }&lt;br /&gt;
    /*Process one event from the queue*/&lt;br /&gt;
    do_event();&lt;br /&gt;
    return nevents + poll_requested;&lt;br /&gt;
}&lt;br /&gt;
static void do_event(void){&lt;br /&gt;
    ...&lt;br /&gt;
    /*&lt;br /&gt;
    if there are any events in the queue, take the first one and walk through the&lt;br /&gt;
    list of processes to see if the event should be delivered to any of them. If &lt;br /&gt;
    so, we call the event handler function for the process. We only process one &lt;br /&gt;
    event at a time and call the poll handlers inbetween.&lt;br /&gt;
    */&lt;br /&gt;
    if(nevents &amp;gt; 0){&lt;br /&gt;
        ...&lt;br /&gt;
        call_process(reveiver, ev, data);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It is clear to see according to the figure 1 &lt;br /&gt;
----&lt;br /&gt;
[[File:1.jpg]]&lt;br /&gt;
figure 1&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Code Style: Names in Contiki&lt;br /&gt;
In Contiki, all names are prefixed with the module name&lt;br /&gt;
(example: process_start(), rime_init(), clock_time(), memb_alloc(), list_add()...)&lt;br /&gt;
Prefix makes it possible to mentally locate all function calls&lt;br /&gt;
All code must abide by this: &lt;br /&gt;
There are a few exceptions in the current code, but those are to be removed in the future&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Code Style: What to avoid&lt;br /&gt;
 -noCamelCase()&lt;br /&gt;
 -No_Capital_letters()&lt;br /&gt;
 -#define EXCEPT_FOR_MACROS()&lt;br /&gt;
----&lt;br /&gt;
Code Sytle: File names&lt;br /&gt;
Contiki uses hyphenated-file-names rather than underscore_in_file_names&lt;br /&gt;
&lt;br /&gt;
== The Motivation – Safe Tiny OS ==&lt;br /&gt;
&lt;br /&gt;
The Safe Tiny OS tool chain is shown in Figure 2. The most immediate benefit of Safe TinyOS was that during its development 4 severe bugs in TinyOS could be found out and were corrected.&lt;br /&gt;
----&lt;br /&gt;
[[File:2.png]]&lt;br /&gt;
figure 2&lt;br /&gt;
----&lt;br /&gt;
Building A Safe Application&lt;br /&gt;
&lt;br /&gt;
To build an application Safe, we have to provide the parameter ‘safe’ in the command line of ‘make’.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 cd $TOSROOT/apps/Blink &lt;br /&gt;
 make micaz safe&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
== Making Safety Optional ==&lt;br /&gt;
=== Implementation Overview ===&lt;br /&gt;
The source code of Contiki consists of nearly 1200 files, including both the OS core and the applications. The OS core itself consists of around 300 files. The work comprises of annotating each pointer access in all these files and recompiling with Deputy. Once the core is free of Safety errors, we can go for the Safety of applications. After this step, we set Deputy as the default compiler of Contiki. Programmers will have to adapt to the Annotations of Deputy, which are very simple and easy to learn.&lt;br /&gt;
----&lt;br /&gt;
The flow graph of Safe Contiki development is given in Figure 3&lt;br /&gt;
----&lt;br /&gt;
[[File:3.jpg]]&lt;br /&gt;
figure 3&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Modifying the Makefiles ===&lt;br /&gt;
The implementation was started by editing the makefiles associated with the ‘native’ processor. The Makefile.native mainly contains definitions for the C compiler used for the native processor. The file is located in contiki-2.x/cpu/native/ directory. The current contents of the 6th and 7th lines are&lt;br /&gt;
 - CC = gcc&lt;br /&gt;
 - LD = gcc&lt;br /&gt;
----&lt;br /&gt;
which indicates that for the native CPU, the compiler and the linker are the same, the gcc. We replaced this with&lt;br /&gt;
 - CC = deputy&lt;br /&gt;
 - LD = deputy&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== A New Argument To Make ===&lt;br /&gt;
As an illustration of how the SAFETY argument is used, the following commands will create the Safe version of the ‘hello-world’ program for the ‘native’ platform.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 cd /home/user/contiki-2.x/examples/hello-world/&lt;br /&gt;
 make TARGET=native SAFETY=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Safety is an optional feature; programs are made Unsafe, by default. The following command makes the program without Safety features, for the ‘native’ platform.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
make TARGET=native&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conditional Making And The gcc -D Flag ===&lt;br /&gt;
In order to make ‘making’ conditional, depending on the value of the variable SAFETY, we further modified the Makefile.native file in the contiki-2.x/cpu/native/ directory.&lt;br /&gt;
Makefile.native is shown below&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
ifeq ($(SAFETY),yes)&lt;br /&gt;
CC = deputy&lt;br /&gt;
LD = deputy&lt;br /&gt;
else&lt;br /&gt;
CC = gcc&lt;br /&gt;
LD = gcc&lt;br /&gt;
CFLAGS += -DNTS=&amp;#039;&amp;#039; -DSAFE=&amp;#039;&amp;#039; \&lt;br /&gt;
-DCOUNT\(x\)=&amp;#039;&amp;#039; \&lt;br /&gt;
-DTC\(x\)=x -DBOUND\(x,y\)=&amp;#039;&amp;#039; \&lt;br /&gt;
-DTRUSTED=&amp;#039;&amp;#039; -DNTDROP\(x\)=x \&lt;br /&gt;
-DNTEXPAND\(x\)=x&lt;br /&gt;
endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Reference&lt;br /&gt;
----&lt;br /&gt;
[1]The Safe TinyOS, 2008. http://docs.tinyos.net/index.php/Safe_TinyOS&lt;br /&gt;
[2]The Contiki OS, http://www.sics.se/contiki/&lt;br /&gt;
[2]Contiki Programming, 2011. http://wenku.baidu.com/view/&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=File:3.jpg&amp;diff=1294</id>
		<title>File:3.jpg</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=File:3.jpg&amp;diff=1294"/>
				<updated>2014-11-09T03:45:48Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=File:2.png&amp;diff=1293</id>
		<title>File:2.png</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=File:2.png&amp;diff=1293"/>
				<updated>2014-11-09T03:30:40Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=File:1.jpg&amp;diff=1290</id>
		<title>File:1.jpg</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=File:1.jpg&amp;diff=1290"/>
				<updated>2014-11-09T03:17:45Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Contiki_tutorials&amp;diff=1207</id>
		<title>Contiki tutorials</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Contiki_tutorials&amp;diff=1207"/>
				<updated>2014-11-09T01:42:44Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: /* List of Tutorials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Main_Page | Back to Main Page]]&lt;br /&gt;
&lt;br /&gt;
== List of Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Completed&lt;br /&gt;
# [[Installation]]&lt;br /&gt;
# [[Hello World]]&lt;br /&gt;
# [[Broadcast Example]]&lt;br /&gt;
# [[Collect View]]&lt;br /&gt;
# [[Contiki build system]]&lt;br /&gt;
# [[Interfacing with Python]]&lt;br /&gt;
# [[Sensor acquisition]] (light, temperature, humidity)&lt;br /&gt;
&lt;br /&gt;
Need review&lt;br /&gt;
# [[Timers]] Tim, Leo&lt;br /&gt;
# [[CFS-Coffee]] Kevin&lt;br /&gt;
&lt;br /&gt;
Starting&lt;br /&gt;
# [[Tutornet]] Pedro, Kwame&lt;br /&gt;
# [[Cooja Simulator]] (Getting started, debugging) Pedro&lt;br /&gt;
# [[Network Stack]]&lt;br /&gt;
# [[CSMA]] Tim, Leo&lt;br /&gt;
# [[RSS measurement]]&lt;br /&gt;
# [[RPL objective function modification and simulation in cooja  ]] Ashwini Telang&lt;br /&gt;
# [[RPL UDP]] Jiahao Liang&lt;br /&gt;
# [[MAC protocols in ContikiOS]] Pedro&lt;br /&gt;
# [[RPL Border Router]] Chhavi&lt;br /&gt;
# [[REST example running on Cooja and Sky motes]] Mrunal Muni &lt;br /&gt;
# [[Trickle library]] Subhashini Sundaresan&lt;br /&gt;
# [[Packetbuffer Basics]] Pradipta&lt;br /&gt;
# [[Antelope(Database Management System) - Contiki]] Gopi Krishna&lt;br /&gt;
# [[Mobility of Nodes in Cooja]] Pratyush Deshpande&lt;br /&gt;
# [[Contiki Shell]] Abhilash Nagaraj Hegde&lt;br /&gt;
# [[Contiki Coffee File System]] Zhikun Liu&lt;br /&gt;
# [[Contiki Programming Guide]] Haimo Bai&lt;br /&gt;
&amp;lt;!--[[Processes]] Yash --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--# [[Collect-view Code Details]] Pradipta --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;Be sure to include references in your tutorials, especially if you quote material from other sites!&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Contiki_tutorials&amp;diff=1206</id>
		<title>Contiki tutorials</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Contiki_tutorials&amp;diff=1206"/>
				<updated>2014-11-09T01:42:16Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: /* List of Tutorials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Main_Page | Back to Main Page]]&lt;br /&gt;
&lt;br /&gt;
== List of Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Completed&lt;br /&gt;
# [[Installation]]&lt;br /&gt;
# [[Hello World]]&lt;br /&gt;
# [[Broadcast Example]]&lt;br /&gt;
# [[Collect View]]&lt;br /&gt;
# [[Contiki build system]]&lt;br /&gt;
# [[Interfacing with Python]]&lt;br /&gt;
# [[Sensor acquisition]] (light, temperature, humidity)&lt;br /&gt;
&lt;br /&gt;
Need review&lt;br /&gt;
# [[Timers]] Tim, Leo&lt;br /&gt;
# [[CFS-Coffee]] Kevin&lt;br /&gt;
&lt;br /&gt;
Starting&lt;br /&gt;
# [[Tutornet]] Pedro, Kwame&lt;br /&gt;
# [[Cooja Simulator]] (Getting started, debugging) Pedro&lt;br /&gt;
# [[Network Stack]]&lt;br /&gt;
# [[CSMA]] Tim, Leo&lt;br /&gt;
# [[RSS measurement]]&lt;br /&gt;
# [[RPL objective function modification and simulation in cooja  ]] Ashwini Telang&lt;br /&gt;
# [[RPL UDP]] Jiahao Liang&lt;br /&gt;
# [[MAC protocols in ContikiOS]] Pedro&lt;br /&gt;
# [[RPL Border Router]] Chhavi&lt;br /&gt;
# [[REST example running on Cooja and Sky motes]] Mrunal Muni &lt;br /&gt;
# [[Trickle library]] Subhashini Sundaresan&lt;br /&gt;
# [[Packetbuffer Basics]] Pradipta&lt;br /&gt;
# [[Antelope(Database Management System) - Contiki]] Gopi Krishna&lt;br /&gt;
# [[Mobility of Nodes in Cooja]] Pratyush Deshpande&lt;br /&gt;
# [[Contiki Shell]] Abhilash Nagaraj Hegde&lt;br /&gt;
# [[Contiki Coffee File System]] Zhikun Liu&lt;br /&gt;
# [[Contiki Programming Starter Guide]] Haimo Bai&lt;br /&gt;
&amp;lt;!--[[Processes]] Yash --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--# [[Collect-view Code Details]] Pradipta --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;Be sure to include references in your tutorials, especially if you quote material from other sites!&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Contiki_tutorials&amp;diff=1205</id>
		<title>Contiki tutorials</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Contiki_tutorials&amp;diff=1205"/>
				<updated>2014-11-09T01:42:04Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: /* List of Tutorials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Main_Page | Back to Main Page]]&lt;br /&gt;
&lt;br /&gt;
== List of Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Completed&lt;br /&gt;
# [[Installation]]&lt;br /&gt;
# [[Hello World]]&lt;br /&gt;
# [[Broadcast Example]]&lt;br /&gt;
# [[Collect View]]&lt;br /&gt;
# [[Contiki build system]]&lt;br /&gt;
# [[Interfacing with Python]]&lt;br /&gt;
# [[Sensor acquisition]] (light, temperature, humidity)&lt;br /&gt;
&lt;br /&gt;
Need review&lt;br /&gt;
# [[Timers]] Tim, Leo&lt;br /&gt;
# [[CFS-Coffee]] Kevin&lt;br /&gt;
&lt;br /&gt;
Starting&lt;br /&gt;
# [[Tutornet]] Pedro, Kwame&lt;br /&gt;
# [[Cooja Simulator]] (Getting started, debugging) Pedro&lt;br /&gt;
# [[Network Stack]]&lt;br /&gt;
# [[CSMA]] Tim, Leo&lt;br /&gt;
# [[RSS measurement]]&lt;br /&gt;
# [[RPL objective function modification and simulation in cooja  ]] Ashwini Telang&lt;br /&gt;
# [[RPL UDP]] Jiahao Liang&lt;br /&gt;
# [[MAC protocols in ContikiOS]] Pedro&lt;br /&gt;
# [[RPL Border Router]] Chhavi&lt;br /&gt;
# [[REST example running on Cooja and Sky motes]] Mrunal Muni &lt;br /&gt;
# [[Trickle library]] Subhashini Sundaresan&lt;br /&gt;
# [[Packetbuffer Basics]] Pradipta&lt;br /&gt;
# [[Antelope(Database Management System) - Contiki]] Gopi Krishna&lt;br /&gt;
# [[Mobility of Nodes in Cooja]] Pratyush Deshpande&lt;br /&gt;
# [[Contiki Shell]] Abhilash Nagaraj Hegde&lt;br /&gt;
# [[Contiki Coffee File System]] Zhikun Liu&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[[Processes]] Yash --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--# [[Collect-view Code Details]] Pradipta --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;Be sure to include references in your tutorials, especially if you quote material from other sites!&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Contiki_Programming_Starter_Guide&amp;diff=1204</id>
		<title>Contiki Programming Starter Guide</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Contiki_Programming_Starter_Guide&amp;diff=1204"/>
				<updated>2014-11-09T01:40:24Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;Introduction&amp;#039;&amp;#039;&amp;#039;&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Introduction&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Contiki_tutorials&amp;diff=1203</id>
		<title>Contiki tutorials</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Contiki_tutorials&amp;diff=1203"/>
				<updated>2014-11-09T01:39:16Z</updated>
		
		<summary type="html">&lt;p&gt;Haimobai: /* List of Tutorials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Main_Page | Back to Main Page]]&lt;br /&gt;
&lt;br /&gt;
== List of Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Completed&lt;br /&gt;
# [[Installation]]&lt;br /&gt;
# [[Hello World]]&lt;br /&gt;
# [[Broadcast Example]]&lt;br /&gt;
# [[Collect View]]&lt;br /&gt;
# [[Contiki build system]]&lt;br /&gt;
# [[Interfacing with Python]]&lt;br /&gt;
# [[Sensor acquisition]] (light, temperature, humidity)&lt;br /&gt;
&lt;br /&gt;
Need review&lt;br /&gt;
# [[Timers]] Tim, Leo&lt;br /&gt;
# [[CFS-Coffee]] Kevin&lt;br /&gt;
&lt;br /&gt;
Starting&lt;br /&gt;
# [[Tutornet]] Pedro, Kwame&lt;br /&gt;
# [[Cooja Simulator]] (Getting started, debugging) Pedro&lt;br /&gt;
# [[Network Stack]]&lt;br /&gt;
# [[CSMA]] Tim, Leo&lt;br /&gt;
# [[RSS measurement]]&lt;br /&gt;
# [[RPL objective function modification and simulation in cooja  ]] Ashwini Telang&lt;br /&gt;
# [[RPL UDP]] Jiahao Liang&lt;br /&gt;
# [[MAC protocols in ContikiOS]] Pedro&lt;br /&gt;
# [[RPL Border Router]] Chhavi&lt;br /&gt;
# [[REST example running on Cooja and Sky motes]] Mrunal Muni &lt;br /&gt;
# [[Trickle library]] Subhashini Sundaresan&lt;br /&gt;
# [[Packetbuffer Basics]] Pradipta&lt;br /&gt;
# [[Antelope(Database Management System) - Contiki]] Gopi Krishna&lt;br /&gt;
# [[Mobility of Nodes in Cooja]] Pratyush Deshpande&lt;br /&gt;
# [[Contiki Shell]] Abhilash Nagaraj Hegde&lt;br /&gt;
# [[Contiki Coffee File System]] Zhikun Liu&lt;br /&gt;
# [[Contiki Programming Starter Guide]] Haimo Bai&lt;br /&gt;
&amp;lt;!--[[Processes]] Yash --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--# [[Collect-view Code Details]] Pradipta --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;Be sure to include references in your tutorials, especially if you quote material from other sites!&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Haimobai</name></author>	</entry>

	</feed>