1 | /* Task1 |
---|
2 | * |
---|
3 | * This task is the main line for the test. It creates other |
---|
4 | * tasks which can create |
---|
5 | * |
---|
6 | * Input parameters: |
---|
7 | * argument - task argument |
---|
8 | * |
---|
9 | * Output parameters: NONE |
---|
10 | * |
---|
11 | * COPYRIGHT (c) 1997 |
---|
12 | * Objective Design Systems Ltd Pty (ODS) |
---|
13 | * All rights reserved (R) Objective Design Systems Ltd Pty |
---|
14 | * |
---|
15 | * COPYRIGHT (c) 1989-1997. |
---|
16 | * On-Line Applications Research Corporation (OAR). |
---|
17 | * Copyright assigned to U.S. Government, 1994. |
---|
18 | * |
---|
19 | * The license and distribution terms for this file may be |
---|
20 | * found in the file LICENSE in this distribution or at |
---|
21 | * http://www.OARcorp.com/rtems/license.html. |
---|
22 | * |
---|
23 | * $Id$ |
---|
24 | */ |
---|
25 | |
---|
26 | #include <stdlib.h> |
---|
27 | #include <string.h> |
---|
28 | #include "System.h" |
---|
29 | |
---|
30 | void Task1::body(rtems_task_argument argument) |
---|
31 | { |
---|
32 | rtems_test_pause_and_screen_number(1); |
---|
33 | |
---|
34 | printf(" * START Task Class test *\n"); |
---|
35 | |
---|
36 | printf("%s - test argument - ", name_string()); |
---|
37 | if (argument != 0xDEADDEAD) |
---|
38 | printf("argument is not 0xDEADDEAD\n"); |
---|
39 | else |
---|
40 | printf("argument matched\n"); |
---|
41 | |
---|
42 | screen1(); |
---|
43 | rtems_test_pause_and_screen_number(2); |
---|
44 | |
---|
45 | screen2(); |
---|
46 | rtems_test_pause_and_screen_number(3); |
---|
47 | |
---|
48 | screen3(); |
---|
49 | rtems_test_pause_and_screen_number(4); |
---|
50 | |
---|
51 | screen4(); |
---|
52 | rtems_test_pause_and_screen_number(5); |
---|
53 | |
---|
54 | screen5(); |
---|
55 | rtems_test_pause_and_screen_number(6); |
---|
56 | |
---|
57 | screen6(); |
---|
58 | |
---|
59 | // do not call exit(0) from this thread as this object is static |
---|
60 | // the static destructor call delete the task which is calling exit |
---|
61 | // so exit never completes |
---|
62 | |
---|
63 | EndTask end_task("ENDT", (rtems_task_priority) 1, RTEMS_MINIMUM_STACK_SIZE * 6); |
---|
64 | end_task.start(0); |
---|
65 | |
---|
66 | rtemsEvent block_me; |
---|
67 | rtems_event_set out; |
---|
68 | |
---|
69 | block_me.receive(RTEMS_SIGNAL_0, out); |
---|
70 | |
---|
71 | printf("**** TASK 1 did not block ????\n"); |
---|
72 | } |
---|
73 | |
---|
74 | void Task1::screen1(void) |
---|
75 | { |
---|
76 | // create two local task objects to connect to this task |
---|
77 | rtemsTask local_task_1 = *this; |
---|
78 | rtemsTask local_task_2; |
---|
79 | |
---|
80 | local_task_2 = *this; |
---|
81 | |
---|
82 | // check the copy constructor works |
---|
83 | printf("%s - copy constructor - ", name_string()); |
---|
84 | if (local_task_1.id_is() == id_is()) |
---|
85 | printf("local and this id's match\n"); |
---|
86 | else |
---|
87 | printf("local and this id's do not match\n"); |
---|
88 | |
---|
89 | printf("%s - copy constructor - ", name_string()); |
---|
90 | if (local_task_1.name_is() == name_is()) |
---|
91 | printf("local and this name's match\n"); |
---|
92 | else |
---|
93 | printf("local and this name's do not match\n"); |
---|
94 | |
---|
95 | // check the copy operator works |
---|
96 | printf("%s - copy operator - ", name_string()); |
---|
97 | if (local_task_2.id_is() == id_is()) |
---|
98 | printf("local and this id's match\n"); |
---|
99 | else |
---|
100 | printf("local and this id's do not match\n"); |
---|
101 | printf("%s - copy operator - ", name_string()); |
---|
102 | if (local_task_2.name_is() == name_is()) |
---|
103 | printf("local and this name's match\n"); |
---|
104 | else |
---|
105 | printf("local and this name's do not match\n"); |
---|
106 | |
---|
107 | // check that the owner of the id cannot delete this task |
---|
108 | printf("%s - not owner destroy's task - ", local_task_1.name_string()); |
---|
109 | local_task_1.destroy(); |
---|
110 | printf("%s\n", local_task_1.last_status_string()); |
---|
111 | |
---|
112 | // connect to a valid task |
---|
113 | printf("%s - connect to a local valid task name - ", local_task_2.name_string()); |
---|
114 | local_task_2.connect("TA1 ", RTEMS_SEARCH_ALL_NODES); |
---|
115 | printf("%s\n", local_task_2.last_status_string()); |
---|
116 | |
---|
117 | // connect to an invalid task |
---|
118 | printf("%s - connect to an invalid task name - ", local_task_2.name_string()); |
---|
119 | local_task_2.connect("BADT", RTEMS_SEARCH_ALL_NODES); |
---|
120 | printf("%s\n", local_task_2.last_status_string()); |
---|
121 | |
---|
122 | // connect to a task an invalid node |
---|
123 | printf("%s - connect to a task on an invalid node - ", local_task_2.name_string()); |
---|
124 | local_task_2.connect("BADT", 10); |
---|
125 | printf("%s\n", local_task_2.last_status_string()); |
---|
126 | |
---|
127 | // restart this task |
---|
128 | printf("%s - restart from a non-owner - ", name_string()); |
---|
129 | local_task_1.restart(0); |
---|
130 | printf("%s\n", local_task_1.last_status_string()); |
---|
131 | } |
---|
132 | |
---|
133 | void Task1::screen2(void) |
---|
134 | { |
---|
135 | // wake after using this object |
---|
136 | |
---|
137 | printf("%s - wake after 0 secs - ", name_string()); |
---|
138 | wake_after(0); |
---|
139 | printf("%s\n", last_status_string()); |
---|
140 | |
---|
141 | printf("%s - wake after 500 msecs - ", name_string()); |
---|
142 | wake_after(500000); |
---|
143 | printf("%s\n", last_status_string()); |
---|
144 | |
---|
145 | printf("%s - wake after 5 secs - ", name_string()); |
---|
146 | wake_after(5000000); |
---|
147 | printf("%s\n", last_status_string()); |
---|
148 | |
---|
149 | printf("%s - wake when - to do\n", name_string()); |
---|
150 | |
---|
151 | rtemsTask task_1 = *this; |
---|
152 | |
---|
153 | // wake after using a connected object |
---|
154 | |
---|
155 | printf("%s - connected object wake after 0 secs - ", task_1.name_string()); |
---|
156 | task_1.wake_after(0); |
---|
157 | printf("%s\n", task_1.last_status_string()); |
---|
158 | |
---|
159 | printf("%s - connected object wake after 500 msecs - ", task_1.name_string()); |
---|
160 | task_1.wake_after(500000); |
---|
161 | printf("%s\n", task_1.last_status_string()); |
---|
162 | |
---|
163 | printf("%s - connected object wake after 5 secs - ", task_1.name_string()); |
---|
164 | task_1.wake_after(5000000); |
---|
165 | printf("%s\n", task_1.last_status_string()); |
---|
166 | |
---|
167 | printf("%s - connected object wake when - to do\n", task_1.name_string()); |
---|
168 | |
---|
169 | rtemsTask task_2; |
---|
170 | |
---|
171 | // wake after using a self object |
---|
172 | |
---|
173 | printf("%s - self object wake after 0 secs - ", task_2.name_string()); |
---|
174 | task_2.wake_after(0); |
---|
175 | printf("%s\n", task_2.last_status_string()); |
---|
176 | |
---|
177 | printf("%s - self object wake after 500 msecs - ", task_2.name_string()); |
---|
178 | task_2.wake_after(500000); |
---|
179 | printf("%s\n", task_2.last_status_string()); |
---|
180 | |
---|
181 | printf("%s - self object wake after 5 secs - ", task_2.name_string()); |
---|
182 | task_2.wake_after(5000000); |
---|
183 | printf("%s\n", task_2.last_status_string()); |
---|
184 | |
---|
185 | printf("%s - self object wake when - to do\n", task_2.name_string()); |
---|
186 | |
---|
187 | rtems_task_priority current_priority; |
---|
188 | rtems_task_priority priority; |
---|
189 | |
---|
190 | // priorities with this object |
---|
191 | |
---|
192 | printf("%s - get priority - ", name_string()); |
---|
193 | get_priority(current_priority); |
---|
194 | printf("%s, priority is %i\n", last_status_string(), current_priority); |
---|
195 | |
---|
196 | printf("%s - set priority to 512 - ", name_string()); |
---|
197 | set_priority(512); |
---|
198 | printf("%s\n", last_status_string()); |
---|
199 | |
---|
200 | printf("%s - set priority to 25 - ", name_string()); |
---|
201 | set_priority(25); |
---|
202 | printf("%s\n", last_status_string()); |
---|
203 | |
---|
204 | printf("%s - set priority to original - ", name_string()); |
---|
205 | set_priority(current_priority, priority); |
---|
206 | printf("%s, priority was %i\n", last_status_string(), priority); |
---|
207 | |
---|
208 | // priorities with connected object |
---|
209 | |
---|
210 | printf("%s - connected object get priority - ", task_1.name_string()); |
---|
211 | task_1.get_priority(current_priority); |
---|
212 | printf("%s, priority is %i\n", task_1.last_status_string(), current_priority); |
---|
213 | |
---|
214 | printf("%s - connected object set priority to 512 - ", task_1.name_string()); |
---|
215 | task_1.set_priority(512); |
---|
216 | printf("%s\n", task_1.last_status_string()); |
---|
217 | |
---|
218 | printf("%s - connected object set priority to 25 - ", task_1.name_string()); |
---|
219 | task_1.set_priority(25); |
---|
220 | printf("%s\n", task_1.last_status_string()); |
---|
221 | |
---|
222 | printf("%s - connected object set priority to original - ", task_1.name_string()); |
---|
223 | task_1.set_priority(current_priority, priority); |
---|
224 | printf("%s, priority was %i\n", task_1.last_status_string(), priority); |
---|
225 | |
---|
226 | // priorities with self object |
---|
227 | |
---|
228 | printf("%s - self object get priority - ", task_2.name_string()); |
---|
229 | task_2.get_priority(current_priority); |
---|
230 | printf("%s, priority is %i\n", task_2.last_status_string(), current_priority); |
---|
231 | |
---|
232 | printf("%s - self object set priority to 512 - ", task_2.name_string()); |
---|
233 | task_2.set_priority(512); |
---|
234 | printf("%s\n", task_2.last_status_string()); |
---|
235 | |
---|
236 | printf("%s - self object set priority to 25 - ", task_2.name_string()); |
---|
237 | task_2.set_priority(25); |
---|
238 | printf("%s\n", task_2.last_status_string()); |
---|
239 | |
---|
240 | printf("%s - self object set priority to original - ", task_2.name_string()); |
---|
241 | task_2.set_priority(current_priority, priority); |
---|
242 | printf("%s, priority was %i\n", task_2.last_status_string(), priority); |
---|
243 | |
---|
244 | rtems_unsigned32 current_note; |
---|
245 | rtems_unsigned32 note; |
---|
246 | |
---|
247 | // notepad registers for this object |
---|
248 | |
---|
249 | printf("%s - get note - ", name_string()); |
---|
250 | get_note(0, current_note); |
---|
251 | printf("%s, note is %i\n", last_status_string(), current_note); |
---|
252 | |
---|
253 | printf("%s - get with bad notepad number - ", name_string()); |
---|
254 | get_note(100, current_note); |
---|
255 | printf("%s, note is %i\n", last_status_string(), current_note); |
---|
256 | |
---|
257 | printf("%s - set note to 0xDEADBEEF - ", name_string()); |
---|
258 | set_note(0, 0xDEADBEEF); |
---|
259 | printf("%s\n", last_status_string()); |
---|
260 | |
---|
261 | printf("%s - get note - ", name_string()); |
---|
262 | get_note(0, note); |
---|
263 | printf("%s, note is 0x%08X\n", last_status_string(), note); |
---|
264 | |
---|
265 | printf("%s - set note to original value - ", name_string()); |
---|
266 | set_note(0, current_note); |
---|
267 | printf("%s\n", last_status_string()); |
---|
268 | |
---|
269 | // notepad registers for connected object |
---|
270 | |
---|
271 | printf("%s - connected object get note - ", task_1.name_string()); |
---|
272 | task_1.get_note(0, current_note); |
---|
273 | printf("%s, notepad is %i\n", task_1.last_status_string(), current_note); |
---|
274 | |
---|
275 | printf("%s - connected object get with bad notepad number - ", task_1.name_string()); |
---|
276 | task_1.get_note(100, current_note); |
---|
277 | printf("%s, note is %i\n", task_1.last_status_string(), current_note); |
---|
278 | |
---|
279 | printf("%s - connected object set note to 0xDEADBEEF - ", task_1.name_string()); |
---|
280 | task_1.set_note(0, 0xDEADBEEF); |
---|
281 | printf("%s\n", task_1.last_status_string()); |
---|
282 | |
---|
283 | printf("%s - connected object get note - ", task_1.name_string()); |
---|
284 | task_1.get_note(0, note); |
---|
285 | printf("%s, note is 0x%08X\n", task_1.last_status_string(), note); |
---|
286 | |
---|
287 | printf("%s - connected object set note to original value - ", task_1.name_string()); |
---|
288 | task_1.set_note(0, current_note); |
---|
289 | printf("%s\n", task_1.last_status_string()); |
---|
290 | |
---|
291 | // notepad registers for self object |
---|
292 | |
---|
293 | printf("%s - self object get note - ", task_2.name_string()); |
---|
294 | task_2.get_note(0, current_note); |
---|
295 | printf("%s, note is %i\n", task_2.last_status_string(), current_note); |
---|
296 | |
---|
297 | printf("%s - self object get with bad notepad number - ", task_2.name_string()); |
---|
298 | task_2.get_note(100, current_note); |
---|
299 | printf("%s, note is %i\n", task_2.last_status_string(), current_note); |
---|
300 | |
---|
301 | printf("%s - self object set note to 0xDEADBEEF - ", task_2.name_string()); |
---|
302 | task_2.set_note(0, 0xDEADBEEF); |
---|
303 | printf("%s\n", task_2.last_status_string()); |
---|
304 | |
---|
305 | printf("%s - self object get note - ", task_2.name_string()); |
---|
306 | task_2.get_note(0, note); |
---|
307 | printf("%s, notepad is 0x%08X\n", task_2.last_status_string(), note); |
---|
308 | |
---|
309 | printf("%s - self object set note to original value - ", task_2.name_string()); |
---|
310 | task_2.set_note(0, current_note); |
---|
311 | printf("%s\n", task_2.last_status_string()); |
---|
312 | |
---|
313 | printf(" * END Task Class test *\n"); |
---|
314 | } |
---|
315 | |
---|
316 | #define RTEMS_ALL_MODES (RTEMS_PREEMPT_MASK | \ |
---|
317 | RTEMS_TIMESLICE_MASK | \ |
---|
318 | RTEMS_ASR_MASK | \ |
---|
319 | RTEMS_INTERRUPT_MASK) |
---|
320 | |
---|
321 | void Task1::screen3(void) |
---|
322 | { |
---|
323 | printf(" * START TaskMode Class test *\n"); |
---|
324 | |
---|
325 | rtemsTask self; |
---|
326 | rtemsTaskMode task_mode; |
---|
327 | rtems_mode current_mode; |
---|
328 | rtems_mode mode; |
---|
329 | |
---|
330 | printf("%s - get mode - ", self.name_string()); |
---|
331 | task_mode.get_mode(current_mode); |
---|
332 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), current_mode); |
---|
333 | print_mode(current_mode, RTEMS_ALL_MODES); |
---|
334 | printf("\n"); |
---|
335 | |
---|
336 | // PREEMPTION mode control |
---|
337 | |
---|
338 | printf("%s - get preemption state - ", self.name_string()); |
---|
339 | task_mode.get_preemption_state(mode); |
---|
340 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
341 | print_mode(mode, RTEMS_PREEMPT_MASK); |
---|
342 | printf("\n"); |
---|
343 | |
---|
344 | printf("%s - set preemption state to RTEMS_PREEMPT - ", self.name_string()); |
---|
345 | task_mode.set_preemption_state(RTEMS_PREEMPT); |
---|
346 | task_mode.get_mode(mode); |
---|
347 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
348 | print_mode(mode, RTEMS_ALL_MODES); |
---|
349 | printf("\n"); |
---|
350 | |
---|
351 | printf("%s - set preemption state to RTEMS_NO_PREEMPT - ", self.name_string()); |
---|
352 | task_mode.set_preemption_state(RTEMS_NO_PREEMPT); |
---|
353 | task_mode.get_mode(mode); |
---|
354 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
355 | print_mode(mode, RTEMS_ALL_MODES); |
---|
356 | printf("\n"); |
---|
357 | |
---|
358 | // TIMESLICE mode control |
---|
359 | |
---|
360 | printf("%s - get timeslice state - ", self.name_string()); |
---|
361 | task_mode.get_timeslice_state(mode); |
---|
362 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
363 | print_mode(mode, RTEMS_TIMESLICE_MASK); |
---|
364 | printf("\n"); |
---|
365 | |
---|
366 | printf("%s - set timeslice state to RTEMS_TIMESLICE - ", self.name_string()); |
---|
367 | task_mode.set_timeslice_state(RTEMS_TIMESLICE); |
---|
368 | task_mode.get_mode(mode); |
---|
369 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
370 | print_mode(mode, RTEMS_ALL_MODES); |
---|
371 | printf("\n"); |
---|
372 | |
---|
373 | printf("%s - set timeslice state to RTEMS_NO_TIMESLICE - ", self.name_string()); |
---|
374 | task_mode.set_timeslice_state(RTEMS_NO_TIMESLICE); |
---|
375 | task_mode.get_mode(mode); |
---|
376 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
377 | print_mode(mode, RTEMS_ALL_MODES); |
---|
378 | printf("\n"); |
---|
379 | |
---|
380 | // ASR mode control |
---|
381 | |
---|
382 | printf("%s - get asr state - ", self.name_string()); |
---|
383 | task_mode.get_asr_state(mode); |
---|
384 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
385 | print_mode(mode, RTEMS_ASR_MASK); |
---|
386 | printf("\n"); |
---|
387 | |
---|
388 | printf("%s - set asr state to RTEMS_ASR - ", self.name_string()); |
---|
389 | task_mode.set_asr_state(RTEMS_ASR); |
---|
390 | task_mode.get_mode(mode); |
---|
391 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
392 | print_mode(mode, RTEMS_ALL_MODES); |
---|
393 | printf("\n"); |
---|
394 | |
---|
395 | printf("%s - set asr state to RTEMS_NO_ASR - ", self.name_string()); |
---|
396 | task_mode.set_asr_state(RTEMS_NO_ASR); |
---|
397 | task_mode.get_mode(mode); |
---|
398 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
399 | print_mode(mode, RTEMS_ALL_MODES); |
---|
400 | printf("\n"); |
---|
401 | |
---|
402 | // interrupt level control |
---|
403 | |
---|
404 | rtems_interrupt_level current_level; |
---|
405 | rtems_interrupt_level level; |
---|
406 | |
---|
407 | printf("%s - get current interrupt level - ", self.name_string()); |
---|
408 | task_mode.get_interrupt_level(current_level); |
---|
409 | printf("%s, level is %i\n", task_mode.last_status_string(), current_level); |
---|
410 | |
---|
411 | printf("%s - set interrupt level to 102 - ", self.name_string()); |
---|
412 | task_mode.set_interrupt_level(102); |
---|
413 | printf("%s\n", task_mode.last_status_string()); |
---|
414 | |
---|
415 | printf("%s - set interrupt level to original level - ", self.name_string()); |
---|
416 | task_mode.set_interrupt_level(current_level, level); |
---|
417 | printf("%s, level was %i\n", task_mode.last_status_string(), level); |
---|
418 | |
---|
419 | printf("%s - set mode to original mode - ", self.name_string()); |
---|
420 | task_mode.set_mode(current_mode, |
---|
421 | RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK | |
---|
422 | RTEMS_ASR_MASK | RTEMS_INTERRUPT_MASK); |
---|
423 | task_mode.get_mode(mode); |
---|
424 | printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); |
---|
425 | print_mode(mode, RTEMS_ALL_MODES); |
---|
426 | printf("\n"); |
---|
427 | |
---|
428 | printf(" * END TaskMode Class test *\n"); |
---|
429 | } |
---|
430 | |
---|
431 | void Task1::screen4(void) |
---|
432 | { |
---|
433 | printf(" * START Event Class test *\n"); |
---|
434 | |
---|
435 | printf("%s - create task 2 - ", name_string()); |
---|
436 | Task2 task_2("TA2", (rtems_task_priority) 9, RTEMS_MINIMUM_STACK_SIZE * 6); |
---|
437 | printf("%s\n", task_2.last_status_string()); |
---|
438 | |
---|
439 | printf("%s - start task 2 - ", name_string()); |
---|
440 | task_2.start(0); |
---|
441 | printf("%s\n", task_2.last_status_string()); |
---|
442 | |
---|
443 | printf("%s - construct event connecting to task 2 - ", name_string()); |
---|
444 | rtemsEvent event_2("TA2 "); |
---|
445 | printf("%s\n", event_2.last_status_string()); |
---|
446 | |
---|
447 | // wait for task 2 to complete its timeout tests |
---|
448 | wake_after(7000000); |
---|
449 | |
---|
450 | printf("%s - send event signal 0 using the task id - ", name_string()); |
---|
451 | event_2.send(task_2.id_is(), RTEMS_SIGNAL_0); |
---|
452 | printf("%s\n", event_2.last_status_string()); |
---|
453 | |
---|
454 | wake_after(1000000); |
---|
455 | |
---|
456 | printf("%s - send event signal 0 using the task object reference - ", name_string()); |
---|
457 | event_2.send(task_2, RTEMS_SIGNAL_0); |
---|
458 | printf("%s\n", event_2.last_status_string()); |
---|
459 | |
---|
460 | wake_after(1000000); |
---|
461 | |
---|
462 | printf("%s - send event signal 31 using connected id - ", name_string()); |
---|
463 | event_2.send(RTEMS_SIGNAL_31); |
---|
464 | printf("%s\n", event_2.last_status_string()); |
---|
465 | |
---|
466 | wake_after(1000000); |
---|
467 | |
---|
468 | rtemsEvent event_2_2; |
---|
469 | |
---|
470 | event_2_2.connect("TA2"); |
---|
471 | |
---|
472 | printf("%s - send event signal 0 and 31 - ", name_string()); |
---|
473 | event_2_2.send(task_2, RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31); |
---|
474 | printf("%s\n", event_2_2.last_status_string()); |
---|
475 | |
---|
476 | printf("%s - waiting 5 secs for TA2 to finish\n", name_string()); |
---|
477 | wake_after(500000); |
---|
478 | |
---|
479 | printf(" * END Event Class test *\n"); |
---|
480 | } |
---|
481 | |
---|
482 | void Task1::screen5(void) |
---|
483 | { |
---|
484 | printf(" * START Interrupt Class test *\n"); |
---|
485 | |
---|
486 | printf(" do not know a portable BSP type interrupt test\n"); |
---|
487 | |
---|
488 | printf(" * END Interrupt Class test *\n"); |
---|
489 | } |
---|
490 | |
---|
491 | void Task1::screen6(void) |
---|
492 | { |
---|
493 | printf(" * START MessageQueue Class test *\n"); |
---|
494 | |
---|
495 | printf("%s - construct message queue 1 with no memory error - ", name_string()); |
---|
496 | rtemsMessageQueue mq_1("MQ1", 1000000, 1000); |
---|
497 | printf("%s\n", mq_1.last_status_string()); |
---|
498 | |
---|
499 | printf("%s - construct/create message queue 2 - ", name_string()); |
---|
500 | rtemsMessageQueue mq_2("MQ2", 4, 50); |
---|
501 | printf("%s\n", mq_2.last_status_string()); |
---|
502 | |
---|
503 | char *u1 = "normal send"; |
---|
504 | char *u2 = "urgent send"; |
---|
505 | char in[100]; |
---|
506 | rtems_unsigned32 size; |
---|
507 | |
---|
508 | printf("%s - send u1 to mq_2 - ", name_string()); |
---|
509 | mq_2.send(u1, strlen(u1) + 1); |
---|
510 | printf("%s\n", mq_2.last_status_string()); |
---|
511 | |
---|
512 | printf("%s - urgent send u2 to mq_2 - ", name_string()); |
---|
513 | mq_2.urgent(u2, strlen(u2) + 1); |
---|
514 | printf("%s\n", mq_2.last_status_string()); |
---|
515 | |
---|
516 | printf("%s - create task 3_1 - ", name_string()); |
---|
517 | Task3 task_3_1("TA31", 9, RTEMS_MINIMUM_STACK_SIZE * 6); |
---|
518 | printf("%s\n", task_3_1.last_status_string()); |
---|
519 | |
---|
520 | printf("%s - start task 3_1 - ", name_string()); |
---|
521 | task_3_1.start(0); |
---|
522 | printf("%s\n", task_3_1.last_status_string()); |
---|
523 | |
---|
524 | printf("%s - create task 3_2 - ", name_string()); |
---|
525 | Task3 task_3_2("TA32", 9, RTEMS_MINIMUM_STACK_SIZE * 6); |
---|
526 | printf("%s\n", task_3_2.last_status_string()); |
---|
527 | |
---|
528 | printf("%s - start task 3_2 - ", name_string()); |
---|
529 | task_3_2.start(0); |
---|
530 | printf("%s\n", task_3_1.last_status_string()); |
---|
531 | |
---|
532 | wake_after(1000000); |
---|
533 | |
---|
534 | printf("%s - receive u2 on mq_2 ...\n", name_string()); fflush(stdout); |
---|
535 | mq_2.receive(in, size, 5000000); |
---|
536 | printf("%s - %s\n", name_string(), mq_2.last_status_string()); |
---|
537 | |
---|
538 | if (size == (strlen(u2) + 5)) |
---|
539 | { |
---|
540 | if ((strncmp(in, task_3_1.name_string(), 4) == 0) && |
---|
541 | (strcmp(in + 4, u2) == 0)) |
---|
542 | { |
---|
543 | printf("%s - message u2 received correctly\n", name_string()); |
---|
544 | } |
---|
545 | else |
---|
546 | { |
---|
547 | printf("%s - message u2 received incorrectly, message='%s', size=%i\n", |
---|
548 | name_string(), in, size); |
---|
549 | } |
---|
550 | } |
---|
551 | else |
---|
552 | printf("%s - message u2 size incorrect, size=%i\n", name_string(), size); |
---|
553 | |
---|
554 | printf("%s - receive u1 on mq_2 ...\n", name_string()); fflush(stdout); |
---|
555 | mq_2.receive(in, size, 5000000); |
---|
556 | printf("%s - %s\n", name_string(), mq_2.last_status_string()); |
---|
557 | |
---|
558 | if (size == (strlen(u1) + 5)) |
---|
559 | { |
---|
560 | if ((strncmp(in, task_3_2.name_string(), 4) == 0) && |
---|
561 | (strcmp(in + 4, u1) == 0)) |
---|
562 | { |
---|
563 | printf("%s - message u1 received correctly\n", name_string()); |
---|
564 | } |
---|
565 | else |
---|
566 | { |
---|
567 | printf("%s - message u1 received incorrectly, message='%s', size=%i\n", |
---|
568 | name_string(), in, size); |
---|
569 | } |
---|
570 | } |
---|
571 | else |
---|
572 | printf("%s - message u1 size incorrect, size=%i\n", name_string(), size); |
---|
573 | |
---|
574 | wake_after(3000000); |
---|
575 | |
---|
576 | char *b1 = "broadcast message"; |
---|
577 | rtems_unsigned32 count; |
---|
578 | |
---|
579 | printf("%s - broadcast send b1 ...\n", name_string()); |
---|
580 | mq_2.broadcast(b1, strlen(b1) + 1, count); |
---|
581 | printf("%s - mq_2 broadcast send - %s, count=%i\n", |
---|
582 | name_string(), mq_2.last_status_string(), count); |
---|
583 | |
---|
584 | wake_after(1000000); |
---|
585 | |
---|
586 | printf("%s - receive message b1 on mq_2 from %s...\n", |
---|
587 | name_string(), task_3_1.name_string()); fflush(stdout); |
---|
588 | mq_2.receive(in, size, 5000000); |
---|
589 | printf("%s - %s\n", name_string(), mq_2.last_status_string()); |
---|
590 | |
---|
591 | if (size == (strlen(b1) + 5)) |
---|
592 | { |
---|
593 | if ((strncmp(in, task_3_1.name_string(), 4) == 0) && |
---|
594 | (strcmp(in + 4, b1) == 0)) |
---|
595 | { |
---|
596 | printf("%s - message b1 received correctly\n", name_string()); |
---|
597 | } |
---|
598 | else |
---|
599 | { |
---|
600 | printf("%s - message b1 received incorrectly, message='%s'\n", |
---|
601 | name_string(), in); |
---|
602 | } |
---|
603 | } |
---|
604 | else |
---|
605 | printf("%s - message b1 size incorrect, size=%i\n", name_string(), size); |
---|
606 | |
---|
607 | printf("%s - receive message b1 on mq_2 from %s...\n", |
---|
608 | name_string(), task_3_1.name_string()); fflush(stdout); |
---|
609 | mq_2.receive(in, size, 5000000); |
---|
610 | printf("%s - %s\n", name_string(), mq_2.last_status_string()); |
---|
611 | |
---|
612 | if (size == (strlen(b1) + 5)) |
---|
613 | { |
---|
614 | if ((strncmp(in, task_3_2.name_string(), 4) == 0) && |
---|
615 | (strcmp(in + 4, b1) == 0)) |
---|
616 | { |
---|
617 | printf("%s - message b1 received correctly\n", name_string()); |
---|
618 | } |
---|
619 | else |
---|
620 | { |
---|
621 | printf("%s - message b1 received incorrectly, message='%s', size=%i\n", |
---|
622 | name_string(), in, size); |
---|
623 | } |
---|
624 | } |
---|
625 | else |
---|
626 | printf("%s - message b1 size incorrect, size=%i\n", name_string(), size); |
---|
627 | |
---|
628 | // wait for task 3_1, and 3_2 to complete their timeout tests, will start these after |
---|
629 | // getting the broadcast message |
---|
630 | wake_after(7000000); |
---|
631 | |
---|
632 | char *f1 = "flush message"; |
---|
633 | |
---|
634 | printf("%s - send f1 to mq_2 - ", name_string()); |
---|
635 | mq_2.send(f1, strlen(f1) + 1); |
---|
636 | printf("%s\n", mq_2.last_status_string()); |
---|
637 | |
---|
638 | printf("%s - send f1 to mq_2 - ", name_string()); |
---|
639 | mq_2.send(f1, strlen(f1) + 1); |
---|
640 | printf("%s\n", mq_2.last_status_string()); |
---|
641 | |
---|
642 | printf("%s - send f1 to mq_2 - ", name_string()); |
---|
643 | mq_2.send(f1, strlen(f1) + 1); |
---|
644 | printf("%s\n", mq_2.last_status_string()); |
---|
645 | |
---|
646 | printf("%s - flush mq_2 - ", name_string()); |
---|
647 | mq_2.flush(size); |
---|
648 | printf("%s, flushed=%i\n", mq_2.last_status_string(), size); |
---|
649 | |
---|
650 | printf(" * END MessageQueue Class test *\n"); |
---|
651 | } |
---|
652 | |
---|
653 | void Task1::print_mode(rtems_mode mode, rtems_mode mask) |
---|
654 | { |
---|
655 | rtemsTaskMode task_mode; |
---|
656 | if (mask & RTEMS_PREEMPT_MASK) |
---|
657 | printf("RTEMS_%sPREEMPT ", |
---|
658 | task_mode.preemption_set(mode) ? "" : "NO_"); |
---|
659 | if (mask & RTEMS_TIMESLICE_MASK) |
---|
660 | printf("RTEMS_%sTIMESLICE ", |
---|
661 | task_mode.preemption_set(mode) ? "" : "NO_"); |
---|
662 | if (mask & RTEMS_ASR_MASK) |
---|
663 | printf("RTEMS_%sASR ", |
---|
664 | task_mode.asr_set(mode) ? "" : "NO_"); |
---|
665 | if (mask & RTEMS_INTERRUPT_MASK) |
---|
666 | printf("INTMASK=%i", |
---|
667 | mode & RTEMS_INTERRUPT_MASK); |
---|
668 | } |
---|
669 | |
---|
670 | EndTask::EndTask(const char* name, |
---|
671 | const rtems_task_priority initial_priority, |
---|
672 | const rtems_unsigned32 stack_size) |
---|
673 | : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT) |
---|
674 | { |
---|
675 | } |
---|
676 | |
---|
677 | void EndTask::body(rtems_task_argument ) |
---|
678 | { |
---|
679 | printf("*** END OF RTEMS++ TEST ***\n"); |
---|
680 | exit(0); |
---|
681 | } |
---|
682 | |
---|