Title: Introduction to Contiki hacking
1Introduction to Contiki hacking
- Adam Dunkels
- Swedish Institute of Computer Science
- 2 December 2004
2Contiki, kernel, programs
- Kernel
- Contains the main loop of the system
- Calls programs when events occur
- Calls programs when no events occur (polling)
- Programs are loaded on top of kernel (core)
- All communication is made through µIP
3Contiki system control flow
4A Contiki program consists of ...
- Init function, called by program loader
- LOADER_INIT_FUNC(function_name, arg)
- Eventhandler, called by kernel
- EK_EVENTHANDLER(eventhandler, ev, data)
- Pollhandler, called repetedly by kernel
- EK_POLLHANDLER(pollhandler)
5The hard life of a Contiki program
Kernel
LOADER_INIT_FUNC()
EK_EVENTHANDLER()
EK_POLLHANDLER()
6Example beeper
7Example beeper
/ Declaration of pollhandler function
/ EK_POLLHANDLER(pollhandler)
8Example beeper
/ Declaration of eventhandler function
/ EK_EVENTHANDLER(eventhandler, ev, data)
9Example beeper
/ Declaration of process / EK_PROCESS(p,
Beeper, EK_PRIO_NORMAL,
eventhandler, pollhandler, NULL)
10Example beeper
/ Implementation of init function.
/ LOADER_INIT_FUNC(init, arg)
arg_free(arg) timer_set(timer,
CLOCK_SECOND) ek_start(p)
11Example beeper
/ Implementation of eventhandler.
/ EK_EVENTHANDLER(eventhandler,
ev, data) if(ev EK_EVENT_REQUEST_EXIT)
ek_exit() LOADER_UNLOAD()
12Example beeper
/ Implementation of pollhandler.
/ EK_POLLHANDLER(pollhandler)
if(timer_expired(timer)) beep()
timer_reset(timer)
13Team building network ping pong
- A virtual ball, hopping between sensors
- Red LED shows where ball is
- Shake sensor to alter direction of the ball
- sensors_vib()
- Perhaps use PIR detector instead?
- Single line, lattice?
14More information!
- Handouts!
- ssh user_at_10.0.0.1
- user contiki1,2,3, password cna
- cd contiki-esb-1.2-cna0/contiki-esb/build-app
- gmake blink.cprg
- ./send blink.cprg 172.16.1.2