110 likes | 125 Vues
Embedded Network Programming nesC, TinyOS, Networking, Microcontrollers. Jonathan Hui University of California, Berkeley. Outline. Quick overview of Microcontrollers TinyOS Lab nesC Programming Language Embedded sockets interface Sensor/actuator drivers Texas Instruments MSP430.
E N D
Embedded Network Programming nesC, TinyOS, Networking, Microcontrollers Jonathan Hui University of California, Berkeley EECS194-5
Outline • Quick overview of • Microcontrollers • TinyOS • Lab • nesC Programming Language • Embedded sockets interface • Sensor/actuator drivers • Texas Instruments MSP430 EECS194-5
Computer Systems • Traditional systems: separate chips • Microcontroller: integrate on single chip Mote MCU CPU Timer Network Peripherals Memory Storage EECS194-5
48K ROM 10K RAM 250 kbps Microcontrollers EECS194-5
Mote Characteristics • Limited resources • RAM, ROM, Computation, Energy Wakeup, do work as quickly as possible, sleep • Hardware modules operate concurrently • No parallel execution of code (not Core 2 Duos!) Asynchronous operation is first class • Diverse application requirements Efficient modularity • Robust operation • Numerous, unattended, critical Predictable operation EECS194-5
Web Server Link TinyOS Basics • What is an OS? • Manages sharing of resources (hardware and software) • Interface to access those resources • TinyOS Basics • System Graph of components • Components • Provides interfaces • Uses interfaces • Interfaces • Commands • Events Network EECS194-5
Application IPv6 Network Kernel Driver Driver Driver Driver Driver Driver Sensors Actuator Sensors Actuator Radio Timer Flash Sensor Actuator TinyOS IPv6 Network Kernel • Network Kernel • Manages communication and storage • Scheduler (decides when to signal events) EECS194-5
Event-Based Execution • All execution occurs in event handlers • Events do not preempt each other • Commands • Get information from underlying components • Get current time • Configure underlying components • Start timer (will cause a future event) • Bind socket to a port • Helper functions • Format an IPv6 address EECS194-5
Event: Boot Command: Start timer Event: Timer fired Command: Send message Event: Message received Command: Toggle an LED event void Boot.booted() { call Timer.startPeriodic(100); } event void Timer.fired() { call Udp.sendto(buf, len, &to); } event void Udp.recvfrom(void *buf, uint16_t len, sockaddr_in6_t *from) { call Leds.led0Toggle(); } Example Flow Start Timer Send Msg Toggle LED System Init Radio Transmit Radio Receive … Sleep … … Sleep … EECS194-5
= HW Timer Overflow What’s Happening Underneath? • MCU hardware modules operate concurrently Must handle events in a timely manner • Hardware events preempt application events • Allows system to operate asynchronously from app • Tasks are used to signal application events • Kernel scheduler executes tasks one-by-one Start Timer Send Msg Toggle LED System Init Radio Transmit Radio Receive … Sleep … … Sleep … EECS194-5
That’s a Start • We’ll learn lots more in lab! EECS194-5