1 | /* Task_3 |
---|
2 | * |
---|
3 | * This routine serves as a test task. Loopback the messages and test |
---|
4 | * timeouts |
---|
5 | * |
---|
6 | * Input parameters: |
---|
7 | * argument - task argument |
---|
8 | * |
---|
9 | * Output parameters: NONE |
---|
10 | * |
---|
11 | * COPYRIGHT (c) 1989-2007. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.com/license/LICENSE. |
---|
17 | * |
---|
18 | * $Id$ |
---|
19 | */ |
---|
20 | |
---|
21 | #include "System.h" |
---|
22 | |
---|
23 | Task3::Task3(const char* name, |
---|
24 | const rtems_task_priority initial_priority, |
---|
25 | const uint32_t stack_size) |
---|
26 | : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT) |
---|
27 | { |
---|
28 | } |
---|
29 | |
---|
30 | void Task3::body(rtems_task_argument ) |
---|
31 | { |
---|
32 | screen6(); |
---|
33 | |
---|
34 | printf("%s - destroy itself\n", name_string()); |
---|
35 | destroy(); |
---|
36 | } |
---|
37 | |
---|
38 | void Task3::screen6() |
---|
39 | { |
---|
40 | rtemsMessageQueue mq_2("MQ2"); |
---|
41 | printf("%s - construction connect mq_2 - %s\n", name_string(), mq_2.last_status_string()); |
---|
42 | |
---|
43 | if (mq_2.successful()) |
---|
44 | { |
---|
45 | char in[100]; |
---|
46 | char out[100]; |
---|
47 | size_t size; |
---|
48 | bool loopback = true; |
---|
49 | |
---|
50 | while (loopback) |
---|
51 | { |
---|
52 | printf("%s - loopback from mq_2 to mq_2 ...\n", name_string()); fflush(stdout); |
---|
53 | |
---|
54 | mq_2.receive(in, size); |
---|
55 | printf("%s - mq_2 receive - %s, size=%i, message string size=%i\n", |
---|
56 | name_string(), mq_2.last_status_string(), size, (int) strlen(in)); |
---|
57 | if (mq_2.successful()) |
---|
58 | { |
---|
59 | if (size > (100 - 5)) |
---|
60 | printf("%s - size to large\n", name_string()); |
---|
61 | else |
---|
62 | { |
---|
63 | strcpy(out, name_string()); |
---|
64 | strcpy(out + 4, in); |
---|
65 | |
---|
66 | printf("%s - loopback to mq_2 - ", name_string()); |
---|
67 | mq_2.send(out, strlen(out) + 1); |
---|
68 | printf("%s\n", mq_2.last_status_string()); |
---|
69 | } |
---|
70 | |
---|
71 | if (strcmp(in, "broadcast message") == 0) |
---|
72 | loopback = false; |
---|
73 | else |
---|
74 | wake_after(1500000); |
---|
75 | } |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | |
---|