• 沒有找到結果。

Nano­RK on zigduino

N/A
N/A
Protected

Academic year: 2022

Share "Nano­RK on zigduino"

Copied!
20
0
0

加載中.... (立即查看全文)

全文

(1)

Nano­RK on zigduino

(2)

Today's outline

Nano­RK

Nano­RK TASKs

Period time, Reserve time

Wait and Signal

Nano­RK bmac & basic_rf

Tips and Tricks

(3)

Nano­RK task

(4)

What is nano­RK?

A Real­time Operating System for sensor  nodes for use in wireless sensor networks

Priority­Based Preemptive Multitasking

Resource Reservations

(5)

Priority­Based Preemptive  Multitasking

Priority

Preemptive

Multi­task

(6)

Creating a Nano­RK Task

NRK_STK TaskOne_Stack[NRK_APP_STACKSIZE];

nrk_task_type TaskOne;

void Task1(void);

...TaskOne.task = Task1;

nrk_task_set_stk( &TaskOne, TaskOne_Stack, NRK_APP_STACKSIZE);

TaskOne.prio = 2;

TaskOne.prio = 2;

TaskOne.FirstActivation = TRUE;

TaskOne.Type = BASIC_TASK;

TaskOne.SchType = PREEMPTIVE;

TaskOne.period.secs = 0;

TaskOne.period.secs = 0;

TaskOne.period.nano_secs = 100*NANOS_PER_MS;

TaskOne.period.nano_secs = 100*NANOS_PER_MS;

TaskOne.cpu_reserve.secs = 0;

TaskOne.cpu_reserve.secs = 0;

TaskOne.cpu_reserve.nano_secs = 10*NANOS_PER_MS;

TaskOne.cpu_reserve.nano_secs = 10*NANOS_PER_MS;

TaskOne.offset.secs = 0;

TaskOne.offset.nano_secs= 0;

nrk_activate_task (&TaskOne);

(7)

Task pool

Control the Nano­RK tasks

Task Management

nrk_wait_untiil_next_period();

Scheduling base on priority 

Task2 Priority=2

Task3 Priority=3

Task pool wait_next Task1

Priority=1 Task2 Priority=2

Task3 Priority=3

Task pool Task2 Priority=2

Task3 Priority=3 Task pool Task3

Priority=3 Task2 Priority=2

Task1 Priority=1

(8)

Task pool

Control the Nano­RK tasks

Signals

Create and signal

nrk_sig_t signal_one;

signal_one=nrk_signal_create();

nrk_event_signal( signal_one );

Wait a signal

nrk_signal_register(signal_one);

nrk_event_wait(SIG(signal_one));

Task2 Priority=2

Task3 Priority=3 Task pool

signal(two)

Task1

wait(one) Task2 wait(two)

Task3 wait(three)

Task pool Task2 Priority=2

Task3 Priority=3 Task pool Task2

wait(two)

Task1 wait(one)

Task3 wait(three)

(9)

Cpu reserve time

Resource Reservations

Task is forced to stop when overdraw its budget

Recharge budget next time running

Reserve time = 0 → disable reservations

ERROR? Program halt?

*NRK ERROR(1): Task Reserve Violated

//#define NRK_REPORT_ERRORS

//#define NRK_HALT_ON_ERROR

(10)

Any questions about 

Nano­RK task?

(11)

Nano­RK radio

B­MAC

Basic RF

(12)

B­MAC

CSMA base

Low­power listen

Preamble needed for TX

Trade­off between check rate and  preamble

(13)

B­MAC on nano­RK

The preamble is replaced with repeating  packets on the nano­RK w/ zigduino

Receiver go sleep after getting a packet

Implement by a bmac task

The api sets the config of this task.

(14)

Basic RF

Aloha protocol (No mac protocol)

Which means you have to listen all the time

Do nothing for collision avoidance

Hardware ack is available

While the bmac ack is not working for now

(15)

Basic RF on nano­RK

Directly using the hardware radio

The chip atmega128rfa1

For TX, hardware ack is available 

While the bmac ack is not working for now

For RX, support hardware CRC check

CRC fail => packet error

(16)

Basic RF V.S B­MAC

BMAC Basic RF

Hardware 

ACK Not work Work 

Date rate Lower Higher

Collision 

avoidance YES NO

Task base YES NO

(17)

Any questions about 

Nano­RK radio?

(18)

Tips & Tricks

(19)

It's all about stacks

Don't Allocate Large Data Structures Inside  Functions 

Use nrk_kprintf() Whenever Possible

Be Very Careful With Dynamic Memory 

Array will always be a good choice.

Avoid floating point (NO FPU)

(20)

Do it by yourself?

http://www.nano­rk.org/wiki/Documentation

http://140.112.91.208/nano­RK/HTML/

Take a look of the examples in nano­RK

參考文獻

相關文件

Aided secondary schools have to offset, in order of priority, (a) the fractional staff entitlement; (b) the Senior Secondary Curriculum Support Grant (SSCSG); and (c) the provision

Quality kindergarten education should be aligned with primary and secondary education in laying a firm foundation for the sustainable learning and growth of

pop

Although many excellent resource synchronization protocols have been pro- posed, most of them are either for hard real-time task scheduling with the maxi- mum priority inversion

• In Shutter-speed priority mode, photographers sets the shutter speed and the camera deduces the aperture. • In Program mode, the camera

• In Shutter-speed priority mode, photographers sets the shutter speed and the camera deduces the aperture. • In Program mode, the camera decides both exposure and shutter

• In Shutter-speed priority mode, photographers sets the shutter speed and the camera deduces the aperture. • In Program mode, the camera decides both exposure and shutter

• In Shutter-speed priority mode, photographers sets the shutter speed and the camera deduces the aperture. • In Program mode, the camera decides both exposure and shutter