1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /* Task_2 |
---|
4 | * |
---|
5 | * This routine serves as a test task. Multiple tasks are required to |
---|
6 | * verify all message manager capabilities. |
---|
7 | * |
---|
8 | * Input parameters: |
---|
9 | * argument - task argument |
---|
10 | * |
---|
11 | * Output parameters: NONE |
---|
12 | * |
---|
13 | * COPYRIGHT (c) 1989-2009. |
---|
14 | * On-Line Applications Research Corporation (OAR). |
---|
15 | * |
---|
16 | * Redistribution and use in source and binary forms, with or without |
---|
17 | * modification, are permitted provided that the following conditions |
---|
18 | * are met: |
---|
19 | * 1. Redistributions of source code must retain the above copyright |
---|
20 | * notice, this list of conditions and the following disclaimer. |
---|
21 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
22 | * notice, this list of conditions and the following disclaimer in the |
---|
23 | * documentation and/or other materials provided with the distribution. |
---|
24 | * |
---|
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
35 | * POSSIBILITY OF SUCH DAMAGE. |
---|
36 | */ |
---|
37 | |
---|
38 | #ifdef HAVE_CONFIG_H |
---|
39 | #include "config.h" |
---|
40 | #endif |
---|
41 | |
---|
42 | #include "system.h" |
---|
43 | |
---|
44 | rtems_task Task_2( |
---|
45 | rtems_task_argument argument |
---|
46 | ) |
---|
47 | { |
---|
48 | long buffer[ 4 ]; |
---|
49 | size_t size; |
---|
50 | rtems_task_priority previous_priority; |
---|
51 | rtems_status_code status; |
---|
52 | |
---|
53 | puts( |
---|
54 | "TA2 - rtems_message_queue_receive - receive from queue 1 - RTEMS_NO_WAIT" |
---|
55 | ); |
---|
56 | status = rtems_message_queue_receive( |
---|
57 | Queue_id[ 1 ], |
---|
58 | buffer, |
---|
59 | &size, |
---|
60 | RTEMS_NO_WAIT, |
---|
61 | RTEMS_NO_TIMEOUT |
---|
62 | ); |
---|
63 | directive_failed( status, "rtems_message_queue_receive" ); |
---|
64 | puts_nocr( "TA2 - buffer received: " ); |
---|
65 | Put_buffer( buffer ); |
---|
66 | new_line; |
---|
67 | |
---|
68 | puts( |
---|
69 | "TA2 - rtems_message_queue_receive - receive from queue 1 - " |
---|
70 | "RTEMS_WAIT FOREVER" |
---|
71 | ); |
---|
72 | status = rtems_message_queue_receive( |
---|
73 | Queue_id[ 1 ], |
---|
74 | buffer, |
---|
75 | &size, |
---|
76 | RTEMS_DEFAULT_OPTIONS, |
---|
77 | RTEMS_NO_TIMEOUT |
---|
78 | ); |
---|
79 | directive_failed( status, "rtems_message_queue_receive" ); |
---|
80 | puts_nocr( "TA2 - buffer received: " ); |
---|
81 | Put_buffer( buffer ); |
---|
82 | new_line; |
---|
83 | |
---|
84 | puts( |
---|
85 | "TA2 - rtems_message_queue_receive - receive from queue 1 - " |
---|
86 | "RTEMS_WAIT FOREVER" |
---|
87 | ); |
---|
88 | status = rtems_message_queue_receive( |
---|
89 | Queue_id[ 1 ], |
---|
90 | buffer, |
---|
91 | &size, |
---|
92 | RTEMS_DEFAULT_OPTIONS, |
---|
93 | RTEMS_NO_TIMEOUT |
---|
94 | ); |
---|
95 | directive_failed( status, "rtems_message_queue_receive" ); |
---|
96 | puts_nocr( "TA2 - buffer received: " ); |
---|
97 | Put_buffer( buffer ); |
---|
98 | new_line; |
---|
99 | |
---|
100 | puts( "TA2 - rtems_task_set_priority - make self highest priority task" ); |
---|
101 | status = rtems_task_set_priority( RTEMS_SELF, 3, &previous_priority ); |
---|
102 | directive_failed( status, "rtems_task_set_priority" ); |
---|
103 | |
---|
104 | puts( |
---|
105 | "TA2 - rtems_message_queue_receive - receive from queue 2 - " |
---|
106 | "RTEMS_WAIT FOREVER" |
---|
107 | ); |
---|
108 | status = rtems_message_queue_receive( |
---|
109 | Queue_id[ 2 ], |
---|
110 | buffer, |
---|
111 | &size, |
---|
112 | RTEMS_DEFAULT_OPTIONS, |
---|
113 | RTEMS_NO_TIMEOUT |
---|
114 | ); |
---|
115 | directive_failed( status, "rtems_message_queue_receive" ); |
---|
116 | puts_nocr( "TA2 - buffer received: " ); |
---|
117 | Put_buffer( buffer ); |
---|
118 | new_line; |
---|
119 | |
---|
120 | Fill_buffer( "BUFFER 2 TO Q 2", (long *)buffer ); |
---|
121 | puts( "TA2 - rtems_message_queue_send - BUFFER 2 TO Q 2" ); |
---|
122 | status = rtems_message_queue_send( Queue_id[ 2 ], buffer, MESSAGE_SIZE ); |
---|
123 | directive_failed( status, "rtems_message_queue_send" ); |
---|
124 | |
---|
125 | puts( |
---|
126 | "TA2 - rtems_message_queue_receive - receive from queue 1 - " |
---|
127 | "10 second timeout" |
---|
128 | ); |
---|
129 | status = rtems_message_queue_receive( |
---|
130 | Queue_id[ 1 ], |
---|
131 | buffer, |
---|
132 | &size, |
---|
133 | RTEMS_DEFAULT_OPTIONS, |
---|
134 | 10 * rtems_clock_get_ticks_per_second() |
---|
135 | ); |
---|
136 | directive_failed( status, "rtems_message_queue_receive" ); |
---|
137 | puts_nocr( "TA2 - buffer received: " ); |
---|
138 | Put_buffer( buffer ); |
---|
139 | new_line; |
---|
140 | |
---|
141 | puts( |
---|
142 | "TA2 - rtems_message_queue_receive - receive from queue 3 - " |
---|
143 | "RTEMS_WAIT FOREVER" |
---|
144 | ); |
---|
145 | status = rtems_message_queue_receive( |
---|
146 | Queue_id[ 3 ], |
---|
147 | buffer, |
---|
148 | &size, |
---|
149 | RTEMS_DEFAULT_OPTIONS, |
---|
150 | RTEMS_NO_TIMEOUT |
---|
151 | ); |
---|
152 | directive_failed( status, "rtems_message_queue_receive" ); |
---|
153 | puts_nocr( "TA2 - buffer received: " ); |
---|
154 | Put_buffer( buffer ); |
---|
155 | new_line; |
---|
156 | |
---|
157 | } |
---|