wsn labs ver4 -...

3
實驗五 BaseStation 實驗目的 z 利用 BaseStation 程式,將從其他 sensor 發送出的封包內容顯示到 PC 上。 實驗步驟 1. 了解 nesC 語法中”task”的使用方法。 z TinyOS provides a twolevel scheduling hierarchy consisting of tasks and hardware event handlers. z Tasks are used to perform longer processing operations, such as background data processing, and can be preempted by hardware event handler. z A task is declared in your implementation module using the syntax : task void taskname() { ... } z To dispatch a task for (later) execution, use the syntax: post taskname(); 2. 了解 BaseStation 的運作原理 封包從 PC 經由 UART 送給 BaseStation 以後,可以再 broadcast 出去。 而由 Radio 傳送進來的封包,可以再經由 BaseStation 轉送到 UART 端到 PC 上顯示。 分別用兩個不同的 queue 來維持由 UART 和由 radio 送封包。 message_t uartQueueBufs[UART_QUEUE_LEN]; uint8_t uartIn, uartOut; bool uartBusy, uartFull; message_t radioQueueBufs[RADIO_QUEUE_LEN]; uint8_t radioIn, radioOut; bool radioBusy, radioFull;

Upload: dangnhi

Post on 17-Apr-2018

218 views

Category:

Documents


4 download

TRANSCRIPT

  • BaseStation

    BaseStation sensor PC

    1. nesCtask TinyOSprovidesatwolevelschedulinghierarchyconsistingoftasksand

    hardwareeventhandlers.

    Tasksareusedtoperformlongerprocessingoperations,suchasbackgrounddataprocessing,andcanbepreemptedbyhardwareeventhandler.

    Ataskisdeclaredinyourimplementationmoduleusingthesyntax: taskvoidtaskname(){...}

    Todispatchataskfor(later)execution,usethesyntax: posttaskname();

    2. BaseStation

    PC UART BaseStation broadcast Radio BaseStation UART

    PC

    queue UART radio

    message_t uartQueueBufs[UART_QUEUE_LEN];

    uint8_t uartIn,uartOut;

    bool uartBusy,uartFull;

    message_t radioQueueBufs[RADIO_QUEUE_LEN];

    uint8_t radioIn,radioOut;

    bool radioBusy,radioFull;

  • RadioReceice Radio

    UART UARTSendTask URATSend

    uartQueueBufs

    UARTSendTask

    UARTReceice UART

    3. sensor sensor BaseStation PC USB

    4. sensorBlinkToRadionodeid BaseStation sensor

    nodeid makeoctopus ($input

    id)

    nodeid 1 2(

    $input 1 2)\build\octopus

    main.out1.ihex main.out2.ihex

    sensor

    tossetsymbolsobjcopymsp430objcopyobjdumpmsp430objdumptargetihexbuild/octopus/main.ihex

    build/octopus/main.out$input.ihexTOS_NODE_ID=$input

  • 5. sensor

    cygwin Listen BaseStation UART Sensor1 Sensor2