Presentation is loading. Please wait.

Presentation is loading. Please wait.

Implementation of Embedded OS Lab5 Real-time Programming on μ C/OS-III.

Similar presentations


Presentation on theme: "Implementation of Embedded OS Lab5 Real-time Programming on μ C/OS-III."— Presentation transcript:

1 Implementation of Embedded OS Lab5 Real-time Programming on μ C/OS-III

2 Lab5 Goal  Practice real-time programming on μ C/OS-III. 2015/6/9 /132 Source: http://micrium.com/page/home

3 Lab5 Environment  Host System  Windows XP  Build System  VirtualBox + Ubuntu 8.04  Target System  PTK development board (STM32F207)  Software  Reference codes  You can download them from RSWiki IEOS Course SoftwareRSWiki IEOS Course Software 2015/6/9 /133

4 Lab5 Scenario 2015/6/9 /134  In sensor network, the main job of sensors is to transmit collected data to a server.  It is common to use multiple communication channels with different levels of priority between a sensor and the server.  Monitoring data versus alarm events  Control messages versus data traffic  … Sensor Server Message Channel (higher priority) Data Channel (lower priority)

5 Lab5 Problem 2015/6/9 /135  In this lab, we would like to implement the following communication model. PTKUbuntu Request 1 Response 1 Request 2 Response 2 Request 100 Response 100 20ms 10ms Message Channel PTKUbuntu Packet 1 Packet 2 random (ms) Data Channel TCP Sockets Sensor (PTK) Sensor (PTK) Server (Ubuntu) Server (Ubuntu) Message Channel Data Channel

6 Lab5 Specification (1/8) 2015/6/9 /136  Request Message Format  REQ_TS_SEC: a four-byte unsigned integer representing the time when the request is sent in seconds  REQ_TS_USEC: a four-byte unsigned integer representing the fractional part of the time when the request is sent in microseconds Request Message REQ_TS_SEC 4 bytes REQ_TS_USEC 4 bytes

7 Lab5 Specification (2/8) 2015/6/9 /137  Response Message Format  RECV_TS_TICK: a four-byte unsigned integer representing the arrival time of the request in ticks*  RECV_TS_CYCLE: a four-byte unsigned integer representing the arrival time of the request in cycles*  REP_TS_TICK: a four-byte unsigned integer representing the time when the response is sent in ticks  REP_TS_CYCLE: a four-byte unsigned integer representing the time when the response is sent in cycles RECV_TS_TICK 4 bytes Response Message RECV_TS_CYCLE 4 bytes REP_TS_TICK 4 bytes REP_TS_CYCLE 4 bytes *Please refer to P.11 for how to obtain these values.

8 Lab5 Specification (3/8) 2015/6/9 /138  Data Packet Format  LEN: a two-byte unsigned short integer representing the length of data payload  The value of LEN should range from 1 to 4095.  DATA[0..LEN-1]: data payload of LEN bytes  You should fill DATA with the values [0, 255] in sequence and wrapping around when LEN is larger than 255.  The data length and transmission interval are generated randomly by the algorithm shown on the next page. Data Packet LEN 2 bytes DATA LEN bytes

9 Lab5 Specification (4/8) 2015/6/9 /139  Random Number Generator  Please use the following C codes to generate random numbers.  Use (my_rand(0) % PACKET_SIZE) to generate random numbers for LEN, PACKET_SIZE <= 4096.  Use (my_rand(1) % TRANS_INT) to generate random numbers for transmission interval, TRANS_INT = 20. unsigned int my_seed[2] = {0x1234, 0x5678}; unsigned int my_rand(int idx) { my_seed[idx] = ((my_seed[idx] * 1103515245) + 12345) & 0x7fffffff; return my_seed[idx]; }

10 Lab5 Specification (5/8) 2015/6/9 /1310  Timing  You need to measure the time of the following events for all messages and data.  In μ C/OS-III  Receiving time of each message request  Sending time of each message response  In Linux  Sending time of each message request  Receiving time of each message response  Start time of each incoming data transmission  Finish time of each data transmission  All measurement should be done right before the socket function send or after the socket function read.  You should stop the measurement as soon as the last response is processed.

11 Lab5 Specification (6/8) 2015/6/9 /1311  Timing Functions  In μ C/OS-III, you should use OSTimeGet to obtain the current value of the tick counter, and use OS_TS_GET to obtain the current value of the CPU cycle counter.  In Linux, you should use gettimeofday for all timing.

12 Lab5 Specification (7/8) 2015/6/9 /1312  Program Input  N, PACKET_SIZE,TRANS_INT  Program Output  In Linux, for each pair of request/response messages, output a comma-separated list per line as follows.  MSG_NO, REQ_TS_SEC, REQ_TS_USEC, RECV_TS_TICK, RECV_TS_CYCLE, REP_TS_TICK, REP_TS_CYCLE, REP_RECV_TS_SEC, REP_RECV_TS_USEC  MSG_NO is the message number from 1 to N.  REP_RECV_TS_SEC/REP_RECV_TS_USEC is the time when the response is received in Linux.  Others are specified in the message formats.

13 Lab5 Specification (8/8) 2015/6/9 /1313


Download ppt "Implementation of Embedded OS Lab5 Real-time Programming on μ C/OS-III."

Similar presentations


Ads by Google