1 / 13

Implementation of Embedded OS

Implementation of Embedded OS. Lab5 Real-time Programming on μ C/OS-III. Goal. Source : http://micrium.com/page/home. Practice real-time programming on μ C/OS-III. Environment. Host System Windows XP Build System VirtualBox + Ubuntu 8.04 Target System

Download Presentation

Implementation of Embedded OS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Goal Source: http://micrium.com/page/home Practice real-time programming on μC/OS-III. /13

  3. 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 Software /13

  4. Scenario Sensor Message Channel (higher priority) Server Data Channel (lower priority) /13 • 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 • …

  5. Problem TCP Sockets Sensor (PTK) Message Channel Server (Ubuntu) Data Channel Message Channel Data Channel PTK Ubuntu PTK Ubuntu Request1 Packet1 10ms Response1 20ms random (ms) Packet2 Request2 ⁞ Response2 ⁞ Request100 Response100 In this lab, we would like to implement the following communication model. /13

  6. Specification (1/8) 4 bytes REQ_TS_SEC 4 bytes REQ_TS_USEC Request Message /13 • 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

  7. Specification (2/8) *Please refer to P.11 for how to obtain these values. 4 bytes RECV_TS_TICK 4 bytes RECV_TS_CYCLE 4 bytes REP_TS_TICK 4 bytes REP_TS_CYCLE Response Message /13 • 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 representingthe time when the response is sent in cycles

  8. Specification (3/8) 2 bytes LEN DATA LEN bytes Data Packet /13 • 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.

  9. Specification (4/8) 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]; } /13 • 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.

  10. Specification (5/8) /13 • 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. Specification (6/8) /13 • 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. Specification (7/8) /13 • 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. Specification (8/8) /13 • Program Output (cont’d) • After the process receives N messages, output the statistics as follows. • REQ_INT_AVG, REQ_INT_VAR, REP_INT_AVG, REP_INT_VAR, DATA_RECV_SUM, DATA_RECV_INT_SUM, MESG_TRANS_INT_MAX • REQ_INT_AVG and REP_INT_AVG are the averages of time interval between two consecutive request and response in microseconds. • REQ_INT_VAR and REP_INT_VAR are the variance of time interval between two consecutive request and response, where the variance is calculated as . • DATA_RECV_SUM is the total number of received data in bytes. • DATA_RECV_INT_SUM is the sum of receiving time for all data packets in microseconds, where the receiving time is calculated as (finished time – start time) of that data transmission. • MESG_TRANS_INT_MAX is the maximum time of sending or receiving a message, the difference of start time on each side in microseconds.

More Related