Microsoft PowerPoint - [이론4]TinyOS와NesC [호환 모드]

Similar documents
<4D F736F F F696E74202D205BBDC7BDC0345DC1B6B5B5BCBEBCADC1A6BEEE2E BC8A3C8AF20B8F0B5E55D>

<283130C1D6294C454420B9D720BCBEBCAD20C1A6BEEE2E687770>

TinyOS_programming.hwp

슬라이드 1

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F >

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A638C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

Chapter #01 Subject

Microsoft Word - FunctionCall

C++ Programming

Something that can be seen, touched or otherwise sensed

PCServerMgmt7

Microsoft PowerPoint - additional01.ppt [호환 모드]

UML

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

<333820B1E8C8AFBFEB2D5A B8A620C0CCBFEBC7D120BDC7BFDC20C0A7C4A1C3DFC1A42E687770>

T100MD+

PowerPoint Template

KEY 디바이스 드라이버

<4D F736F F F696E74202D20322DBDC7BDC3B0A320BFEEBFB5C3BCC1A6>

슬라이드 1

6주차.key

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A634C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

강의10

Microsoft PowerPoint - ch07.ppt

RVC Robot Vaccum Cleaner

이도경, 최덕재 Dokyeong Lee, Deokjai Choi 1. 서론

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

SRC PLUS 제어기 MANUAL

목차 Ⅰ. 서론 73 Ⅱ. 기술개발동향 개요 연구개발동향 76 가. TinyOS 76 나. TRON 92 다. 저전력멀티- 홉(multi-hop) 네트워크기술 39 라. 국내기술개발현황 97 Ⅲ. 기술특성분석 98 Ⅳ. 결론및전망 99 참고자료 1

untitled

untitled

PowerPoint 프레젠테이션

CANTUS Evaluation Board Ap. Note

MAX+plus II Getting Started - 무작정따라하기

- 목차 - - ios 개발환경및유의사항. - 플랫폼 ios Project. - Native Controller와플랫폼화면연동. - 플랫폼 Web(js)-Native 간데이터공유. - 플랫폼확장 WN Interface 함수개발. - Network Manager clas

thesis

임베디드시스템설계강의자료 6 system call 1/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

Microsoft PowerPoint App Fundamentals[Part1](1.0h).pptx

MPLAB C18 C

4 CD Construct Special Model VI 2 nd Order Model VI 2 Note: Hands-on 1, 2 RC 1 RLC mass-spring-damper 2 2 ζ ω n (rad/sec) 2 ( ζ < 1), 1 (ζ = 1), ( ) 1

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

목차 1. 개요 USB 드라이버 설치 (FTDI DRIVER) FTDI DRIVER 실행파일 USB 드라이버 확인방법 DEVICE-PROGRAMMER 설치 DEVICE-PROGRAMMER

Microsoft PowerPoint - AC3.pptx

2. GCC Assembler와 AVR Assembler의차이 A. GCC Assembler 를사용하는경우 i. Assembly Language Program은.S Extension 을갖는다. ii. C Language Program은.c Extension 을갖는다.

hd1300_k_v1r2_Final_.PDF

DE1-SoC Board

놀이동산미아찾기시스템

PowerPoint Template

1217 WebTrafMon II

CAN-fly Quick Manual

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

제11장 프로세스와 쓰레드

Microsoft PowerPoint App Fundamentals[Part1].pptx

iii. Design Tab 을 Click 하여 WindowBuilder 가자동으로생성한 GUI 프로그래밍환경을확인한다.

<4D F736F F F696E74202D203137C0E55FBFACBDC0B9AEC1A6BCD6B7E7BCC72E707074>

Microsoft PowerPoint - polling.pptx

제8장 자바 GUI 프로그래밍 II

Microsoft PowerPoint - ccs33_bios_PRD.ppt [호환 모드]

final_thesis

API 매뉴얼

JVM 메모리구조

임베디드시스템설계강의자료 4 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

슬라이드 1

Abstract View of System Components

Microsoft Word - ASG AT90CAN128 모듈.doc

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning

금오공대 컴퓨터공학전공 강의자료

서현수

쉽게 풀어쓴 C 프로그래밍

Chap06(Interprocess Communication).PDF

歯I-3_무선통신기반차세대망-조동호.PDF

PowerPoint Presentation

고급 프로그래밍 설계

UI TASK & KEY EVENT

PowerPoint 프레젠테이션

Microsoft PowerPoint - 30.ppt [호환 모드]

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A636C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint APUE(Intro).ppt

PRO1_16E [읽기 전용]

(SW3704) Gingerbread Source Build & Working Guide

을 할 때, 결국 여러 가지 단어를 넣어서 모두 찾아야 한다는 것이다. 그 러나 가능한 모든 용어 표현을 상상하기가 쉽지 않고, 또 모두 찾기도 어 렵다. 용어를 표준화하여 한 가지 표현만 쓰도록 하여야 한다고 하지만, 말은 쉬워도 모든 표준화된 용어를 일일이 외우기는

Microsoft PowerPoint - chap06-5 [호환 모드]

설계란 무엇인가?

2002년 2학기 자료구조

<B8C5B4BABEF320BFCFBCBABABB2E687770>

Microsoft Word - PEB08_USER_GUIDE.doc

17장 클래스와 메소드

(specifications) 3 ~ 10 (introduction) 11 (storage bin) 11 (legs) 11 (important operating requirements) 11 (location selection) 12 (storage bin) 12 (i

Smart Power Scope Release Informations.pages

thesis

Microsoft Word - ExecutionStack

Figure 5.01

Microsoft PowerPoint Android-구조.애플리케이션 기초(1.0h).pptx

API - Notification 메크로를통하여어느특정상황이되었을때 SolidWorks 및보낸경로를통하여알림메시지를보낼수있습니다. 이번기술자료에서는메크로에서이벤트처리기를통하여진행할예정이며, 메크로에서작업을수행하는데유용할것입니다. 알림이벤트핸들러는응용프로그램구현하는데있어

PowerPoint 프레젠테이션

No Slide Title

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Transcription:

TinyOS 와 NesC 한백전자

TinyOS 2

TinyOS TinyOS (TOS) = atmega128 에서수행가능한이미지 event-driven 구조 단일스택 TinyOS 의제한사항 커널없음 동적메모리관리없음 가상메모리사용안함 Main 함수에서구동되는 Simple FIFO 스케줄러 3

TinyOS 응용프로그램 TOS application = graph of components + scheduler main { // component initialization while(1) { while(more_tasks) schedule_task; sleep; // while //main Main (includes Scheduler) Application (User Components) Actuating Sensing Communication Communication i Hardware Abstractions 4

하드웨어구성 하드웨어의구성 : LED (pin numbering/hw wiring) CLOCK (counter interrupt) UART (baud rate control, transfer) ADC (ADC interrupt t handling) RFM (abstracts bit level timing, RFM specific control logic) 센서 Main (includes Scheduler) Application (User Components) Actuating Sensing Communication Communication Hardware Abstractions 5

ADC the Sensor stack: 각종센서에서측정한아날로그데이터를디지털데이터로바꾸어주는장치 ADC component를통해제어 데이터요청, 센싱이끝날때까지대기 Main (includes Scheduler) Application (User Components) Actuating Sensing Communication Communication i Hardware Abstractions 6

무선통신 무선통신스택 : RFM (bit level) 부터시작 bit level abstracts away radio specifics byte level l radio component collects Main (includes Scheduler) individual bits into bytes packet level constructs packets Application (User Components) from bytes messaging layer interprets packets as messages Communication Actuating Sensing Communication Hardware Abstractions 7

TinyOS 의구성 /opt/tinyos-1.x 1x TinyOS 의폴더 8

tos 의구성 interfaces: 구현된 interface 를모아놓은곳 system : CPU 중심적컴포넌트와스케줄러 Platform : tinyos 를사용하는플랫폼을정의 Types : tinyos 메시지해더를정의 9

NesC 10

컴포넌트 (component) 모델언어 NesC 의특징 NesC와같은컴포넌트 (component) 모델언어는여러개의컴포넌트블록 (block) 들을컴파일시연결 ( 와이어링 or wiring) 하여하나의응용프로그램형태로조합한다. 센서노드에올라갈하나의응용프로그램을위해, 꼭필요한라이브러리및커널컴포넌트들만을선택하여컴파일하기때문에코드사이즈가작다 NesC의문법은기존에많이사용되고있는 C 언어와비슷하지만, 아래표와같은차이점을가지고있다. NesC 의특징들 형태개발코드사이즈제한점 컴포넌트기반 기존 C 에비해편리함 - 필요한컴포넌트들만연결해주면원하는프로그램작성가능 매우작은 - 소규모임베디드장비에최적화 No Dynamic Memory 11

NesC 에서사용하는컴포넌트관련용어 NesC 에서사용하는용어들 Application 실제센서노드에서실행가능한하나의프로그램 Component - NesC 를구성하는기본블록으로, configuration 과 module 로구분된다. Component Interface - Interface는두개의컴포넌트사이를연결하기위해정의된포트를의미한다. 컴포넌트는여러개의 interface를사용할수있으며, 이 interface를이용하여 command, message가처리된다. 두컴포넌트사이의연결통로 ( 인터페이스 ) 를연결하는것을와이어링 (wiring) 이라고한다. Configuration - 하나의새로운컴포넌트를정의하고, 사용할다른하부컴포넌트들을선언한다. 그리고이들간의연결 ( 와이어링 ) 을어떻게정의할것인가에대해기술한다. Module - 새로운컴포넌트의동작및다른컴포넌트들과의연동을실제로구현하는곳이다. 12

Component Component interface: 함수의구현 함수의호출 이벤트에대한응답의구현 이벤트발생 Messaging Component Internal Tasks Internal State Component 구성 Commands Events Interface가정의된파일 Configuration : 사용할하부컴포넌트선언및와이어링 Module : 실제동작구현 13

Interface NesC 에서 Interface 양방향성을가지며제공자 (provider) 와사용자 (user) 가되는컴포넌트를연결하는포트의역할을수행한다. Interface는 command와 event 타입의함수로정의되며, 그차이는다음과같다. Command Event Command로정의된함수는현컴포넌트의 module 부분에구현된함수로써, 현컴포넌트를사용하는상위컴포넌트에서 'signal' 명령을통해호출되어진다. Event로정의된함수는현컴포넌트를사용하는상위컴포넌트에구현되어져야하는함수로써, 특정인터럽트나조건이만족되어졌을경우, 현컴포넌트가어떤정보를상위컴포넌트에게전달할때사용한다. 14

Command - Call Command C 에서함수와유사 하부컴포넌트의 command 함수를호출 호출한함수로결과를돌려받음 인터페이스되어있어야사용가능 Call 명령어를통해호출 call Timer.stop() 15

Event Event - Signal 특정인터럽트나조건을만족했을때호출됨 상위컴포넌트의 event 함수호출 인터페이스되어있어야사용가능 Signal 명령어를통해호출 signal Timer.fired(); 16

Interface 예제 기술형태 interface identifier { command result_t function_name prototype event result_t function_name prototype 예제 (Timer.nc) interface Timer { command result_t start (char type, uint32_t interval); command result_t stop (); event result_t fired (); 17

Component configuration i Configuration 파일 Configuration 파일은현컴포넌트에서사용할여려하부컴포넌트들의선언및그들간의연결에대해기술한다. 사용할컴포넌트를나열하고그들간의연결을기술하는방법은다음과같다. configuration identifier { provides { interface interface_name1name1 implementation { components identifierm, com1, com2... interface_name1 = identifierm.interface_name1 identifierm.interface_name2 -> com1.interface_name3 com1.interface_name3 name3 <- identifierm.interface_name2interface name2 18

컴포넌트간연결 ( 와이어링 -wiring) Wiring 의종류 <, >, = Interface 1 = interface 2 두개의 interface 가같음을 Interface1 > interface2 interface1에서사용한함수가 interface2에구현 Interface1 < interface2 Interface2 > interface1과동일한표기방법 일단와이어링이되면 command, event, interface 를사용할수있다. 19

Configuration 예제 예제 (TimerC.nc) configuration TimerC { provides {... interface Timer; implementation { components TimerM, ClockC,... ;... TimerM.Clock -> ClockC.Clock;... 20

Component - module Module 파일 Module 파일에는해당컴포넌트의실제구현에대한내용이기술됨 Module 의기술방법은다음과같다. ( 두방법모두같음 ) module identifier { module identifier { provides { interface a; interface b; provides interface a; provides interface b; uses { uses interface x; interface x; uses interface y; interface y; implementation { implementation {............ 21

Module 예제 예제 (TimerM.nc) module TimerM { provides { interface StdControl; t interface Timer; uses interface Clock; implementation { // 실제컴포넌트의동작이구현되는부분 command result_t Timer.start( ) {... command result_t Timer.stop() {... event void Clock.tick() {... 22

Task 와 Event 스케줄링 : 2-level scheduling (events and tasks) single shared stack, used by events and function calls Task: 이벤트에선점가능 함수의호출 Signal을발생 다른 Task 에의해선점되지않음 Event 인터럽트에의해발생되는프로세서 INTERRUPT(_output_compare2_)() { // Hardware Timer Event Handler TOS_SIGNAL_EVENT(CLOCK_FIRE_EVENT)(); // Software event 23

async async,atomic 타스크가비동기적으로실행되도록코드를구성 atomic 전역변수에대해 race condition이발생하지않도록코드를구성 atomic { sharedvar = sharedvar+1; 24

TinyOS layer 25

Tinyos 의디렉토리구조 /opt/tinyos-1.x /apps /contrib /zigbex /tools /tos interfaces system flatform sensorboards lib types 한백에서개발한드라이버와예제자바와 make platform 인터페이스들하드웨어와관련된공통컴포넌트플랫폼에서사용된컴포넌트센서보드들의컴포넌트각종라이브러리 TinyOS 메시지헤더 26

NesC 프로그래밍 27

nesc Programming comp1: module comp3 Components: 구성 - module: C 로구현 - configuration: select and wire interfaces - provides interface - uses interface comp2: configuration comp4 application: configuration 28

nesc Programming Component 의종류 : configuration: 컴포넌트의연결을나타냄 module: 인터페이스의동작을기술, 이벤트핸들러작성 29

nesc Programming Configurations 의연결 : configuration app { implementation { components c1, c2, c3; c1 -> c2; // implicit interface sel. c2.out -> c3.triangle; c3 <- c2.side; Configuration 의부분기술 : component c2c3 { provides interface triangle t1; implementation { components c2, c3; t1 -> c2.in; c2.out -> c3triangle; c3.triangle; c3 <- c2.side; C1 C2 C3 C2 C3 30

nesc Programming Language modules: module C1 { uses interface triangle; implementation {... C1 module C2 { C2 provides interface triangle in; uses { interface triangle out; interface rectangle side; implementation {... C3 module C3 { provides interface triangle; provides interface rectangle; implementation {... 31

nesc Blink example blink.nc nc (configuration) configuration Blink { implementation { components Main, BlinkM, TimerC, LedsC; Main.StdControl -> TimerC.StdControl; Main.StdControl -> BlinkM.StdControl; BlinkM.Timer -> TimerC.Timer[unique( Timer[unique("Timer")]; BlinkM.Leds -> LedsC; 32

nesc Blink example blinkm.nc nc (module) module BlinkM { provides { interface StdControl; t uses { interface Timer as Timer; interface Leds; implementation { command result_t t StdControl.init() { call Leds.init(); return SUCCESS; command result_t StdControl.start() { call Timer.start(TIMER_REPEAT, 1000); return SUCCESS; command result_t StdControl.stop() { call Timer.stop(); return SUCCESS; event result_t Timer.fired() { call Leds.redToggle(); return SUCCESS; 33

Blink 의구조 컴포넌트 : Main, TimerC, LedsC, BlinkM /opt/tinyos-1.x/tos/system/main.nc configuration Main { uses interface StdControl; implementation { components RealMain, PotC, HPLInit; StdControl t = RealMain.StdControl; t l; RealMain.hardwareInit -> HPLInit; RealMain.Pot -> PotC; 34

Main.nc Component : RealMain, PotC, HPLInit StdControlt Main 같은 interface 이므로 = 로연결 RealMain Pot Provide 와 use interface 이므로 -> 로연결 Hardwareinit PotC HPLInit 35

RealMain <-> HPLInit module RealMain { uses { command result_t hardwareinit(); interface StdControl; interface Pot; implementation{ int main() attribute ((C, spontaneous)) { call hardwareinit(); call Pot.init(10); TOSH_sched_init(); call StdControl.init(); call StdControl.start(); nesc_enable_interrupt(); enable while(1) { TOSH_run_task(); Simple FIFO 스케줄러 /opt/tinyos- 1.x/platform/avrmote/HPLInit.nc module HPLInit { provides command result_t init(); Implementation { // Basic hardware init. command result_t init() { TOSH_SET_PIN_DIRECTIONS(); return SUCCESS; 36

RealMain<->PotC /opt/tinyos-1.x/system/potc.nc / / y / module RealMain { configuration PotC{ uses { provides interface Pot; command result_t hardwareinit(); interface StdControl; implementation interface Pot; { components PotM, HPLPotC; Pot = PotM; implementation{ PotM.HPLPot -> HPLPotC; int main() attribute ((C, spontaneous)) { call hardwareinit(); call Pot.init(10); module PotM{ TOSH_sched_init(); provides interface Pot; call StdControl.init(); uses interface HPLPot; call StdControl.start(); implementation { nesc_enable_interrupt(); enable while(1) { TOSH_run_task();. command result_t Pot.init(uint8_t initialsetting) { setpot(initialsetting); return SUCCESS;.. 37

RealMain<->BlinkM module RealMain { uses { command result_t hardwareinit(); interface StdControl; interface Pot; implementation{ int main() attribute ((C, spontaneous)) { call hardwareinit(); call Pot.init(10); TOSH_sched_init(); call StdControl.init(); call StdControl.start(); nesc_enable_interrupt(); while(1) { TOSH_run_task(); module BlinkM{ provides { interface StdControl; uses { interface Timer as Timer; interface Leds; implementation { command result_t StdControl.init() { call Leds.init(); return SUCCESS; command result_t StdControl.start() { call Timer.start(TIMER_REPEAT, 1000); return SUCCESS; StdControl.stop() { call Timer.stop(); return SUCCESS; event result_t Timer.fired() { call Leds.redToggle(); return SUCCESS; 38

사용된 Interface StdControl, Pot, hardwareinit(); interface StdControl{ command result_t t init(); command result_t start(); command result_t stop(); interface Pot { command result_t init(uint8_t initialsetting); commandresult result_t tset(uint8_t tsetting); command result_t increase(); command result_t decrease(); command uint8_t t get(); command result_t hardwareinit(); 39

Blink 의구조 컴포넌트 :Main Main, TimerC, LedsC, BlinkM configuration TimerC { provides interface Timer[uint8_t id]; provides interface StdControl; implementation { components TimerM, ClockC, NoLeds, HPLPowerManagementM; M TimerM.Leds -> NoLeds; TimerM.Clock -> ClockC; TimerM.PowerManagement -> HPLPowerManagementM; StdControl = TimerM; Timer = TimerM; 40

TimerC TimerC 의구조 Timer StdControl TimerC TimerM Leds Clock PowerManagement NoLeds ClockC HPLPowerManagementM 41

Blink 의구조 컴포넌트 :Main Main, TimerC, LedsC, BlinkM module LedsC { provides interface Leds; implementation{ uint8_t ledson; enum { RED_BIT = 1, GREEN_BIT = 2, YELLOW_BIT = 4 ; async command result_t Leds.init() { return SUCCESS; async command result_t Leds.redOn() { async command result_t Leds.redOff() { async command result_t Leds.redToggle() {. async command uint8_t Leds.get() { async command result_t Leds.set(uint8_t ledsnum) { 42

Blink 의구조 컴포넌트 : Main, TimerC, LedsC, BlinkM module BlinkM{ provides { interface StdControl; uses { interface Timer as Timer; interface Leds; implementation ti { command result_t StdControl.init() {call Leds.init(); return SUCCESS; command result_t StdControl.start() {call Timer.start(TIMER_REPEAT, 1000); return SUCCESS; SS StdControl.stop() { call Timer.stop(); return SUCCESS; event result_t Timer.fired() { call Leds.redToggle(); return SUCCESS; 43

BlinkM <->LedsC module BlinkM{ provides { interface StdControl; uses { interface Timer as Timer; interface Leds; implementation { command result_t StdControl.init() { call Leds.init(); return SUCCESS; command result_t StdControl.start() { module LedsC { provides interface Leds; implementation{ uint8_t ledson; enum { RED_BIT = 1, GREEN_BIT = 2, YELLOW_BIT = 4 ; async command result_t Leds.init() { return SUCCESS; async command result_t Leds.redOn() { async command result_t Leds.redOff() { call Timer.start(TIMER_REPEAT, 1000); async command result_t Leds.redToggle() return SUCCESS; { StdControl.stop() { call Timer.stop(); return SUCCESS; event result_t Timer.fired() { call Leds.redToggle(); dt return SUCCESS;. async command uint8_t Leds.get() { async command result_t Leds.set(uint8_t ledsnum) ){ 44