1 | /* Task_2 |
---|
2 | * |
---|
3 | * This routine serves as a test task. Multiple tasks are required to |
---|
4 | * verify all capabilities of the event manager. |
---|
5 | * |
---|
6 | * Input parameters: |
---|
7 | * argument - task argument |
---|
8 | * |
---|
9 | * Output parameters: NONE |
---|
10 | * |
---|
11 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * All rights assigned to U.S. Government, 1994. |
---|
14 | * |
---|
15 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
16 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
17 | * notice must appear in all copies of this file and its derivatives. |
---|
18 | * |
---|
19 | * $Id$ |
---|
20 | */ |
---|
21 | |
---|
22 | #include "system.h" |
---|
23 | |
---|
24 | rtems_task Task_2( |
---|
25 | rtems_task_argument argument |
---|
26 | ) |
---|
27 | { |
---|
28 | rtems_event_set eventout; |
---|
29 | rtems_time_of_day time; |
---|
30 | rtems_status_code status; |
---|
31 | |
---|
32 | status = rtems_task_wake_after( 1*TICKS_PER_SECOND ); |
---|
33 | directive_failed( status, "rtems_task_wake_after" ); |
---|
34 | |
---|
35 | puts( "TA2 - rtems_event_receive - waiting forever on RTEMS_EVENT_16" ); |
---|
36 | status = rtems_event_receive( |
---|
37 | RTEMS_EVENT_16, |
---|
38 | RTEMS_DEFAULT_OPTIONS, |
---|
39 | RTEMS_NO_TIMEOUT, |
---|
40 | &eventout |
---|
41 | ); |
---|
42 | directive_failed( status, "rtems_event_receive" ); |
---|
43 | printf( "TA2 - RTEMS_EVENT_16 received - eventout => %08x\n", eventout ); |
---|
44 | |
---|
45 | puts( |
---|
46 | "TA2 - rtems_event_send - send RTEMS_EVENT_14 and RTEMS_EVENT_15 to TA1" |
---|
47 | ); |
---|
48 | status = rtems_event_send( Task_id[ 1 ], RTEMS_EVENT_14 | RTEMS_EVENT_15 ); |
---|
49 | directive_failed( status, "rtems_event_send" ); |
---|
50 | |
---|
51 | puts( |
---|
52 | "TA2 - rtems_event_receive - RTEMS_EVENT_17 or " |
---|
53 | "RTEMS_EVENT_18 - forever and ANY" |
---|
54 | ); |
---|
55 | status = rtems_event_receive( |
---|
56 | RTEMS_EVENT_17 | RTEMS_EVENT_18, |
---|
57 | RTEMS_EVENT_ANY, |
---|
58 | RTEMS_NO_TIMEOUT, |
---|
59 | &eventout |
---|
60 | ); |
---|
61 | directive_failed( status, "rtems_event_receive" ); |
---|
62 | printf( |
---|
63 | "TA2 - RTEMS_EVENT_17 or RTEMS_EVENT_18 received - eventout => %08x\n", |
---|
64 | eventout |
---|
65 | ); |
---|
66 | |
---|
67 | puts( "TA2 - rtems_event_send - send RTEMS_EVENT_14 to TA1" ); |
---|
68 | status = rtems_event_send( Task_id[ 1 ], RTEMS_EVENT_14 ); |
---|
69 | directive_failed( status, "rtems_event_send" ); |
---|
70 | |
---|
71 | build_time( &time, 2, 12, 1988, 8, 15, 0, 0 ); |
---|
72 | print_time( "TA2 - rtems_clock_set - ", &time, "\n" ); |
---|
73 | status = rtems_clock_set( &time ); |
---|
74 | directive_failed( status, "TA2 rtems_clock_set" ); |
---|
75 | |
---|
76 | time.second += 5; |
---|
77 | puts( |
---|
78 | "TA2 - rtems_event_send - sending RTEMS_EVENT_10 to self after 5 seconds" |
---|
79 | ); |
---|
80 | status = rtems_timer_fire_when( |
---|
81 | Timer_id[ 5 ], |
---|
82 | &time, |
---|
83 | TA2_send_10_to_self, |
---|
84 | NULL |
---|
85 | ); |
---|
86 | directive_failed( status, "rtems_timer_fire_when after 5 seconds" ); |
---|
87 | |
---|
88 | puts( "TA2 - rtems_event_receive - waiting forever on RTEMS_EVENT_10" ); |
---|
89 | status = rtems_event_receive( |
---|
90 | RTEMS_EVENT_10, |
---|
91 | RTEMS_DEFAULT_OPTIONS, |
---|
92 | RTEMS_NO_TIMEOUT, |
---|
93 | &eventout |
---|
94 | ); |
---|
95 | directive_failed( status, "rtems_event_receive" ); |
---|
96 | |
---|
97 | status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); |
---|
98 | directive_failed( status, "rtems_clock_get" ); |
---|
99 | |
---|
100 | printf( "TA2 - RTEMS_EVENT_10 received - eventout => %08x\n", eventout ); |
---|
101 | print_time( "TA2 - rtems_clock_get - ", &time, "\n" ); |
---|
102 | |
---|
103 | puts( "TA2 - rtems_event_receive - RTEMS_PENDING_EVENTS" ); |
---|
104 | status = rtems_event_receive( |
---|
105 | RTEMS_PENDING_EVENTS, |
---|
106 | RTEMS_DEFAULT_OPTIONS, |
---|
107 | RTEMS_NO_TIMEOUT, |
---|
108 | &eventout |
---|
109 | ); |
---|
110 | directive_failed( status, "rtems_event_receive" ); |
---|
111 | printf( "TA2 - eventout => %08x\n", eventout ); |
---|
112 | |
---|
113 | puts( "TA2 - rtems_event_receive - RTEMS_EVENT_19 - RTEMS_NO_WAIT" ); |
---|
114 | status = rtems_event_receive( |
---|
115 | RTEMS_EVENT_19, |
---|
116 | RTEMS_NO_WAIT, |
---|
117 | RTEMS_NO_TIMEOUT, |
---|
118 | &eventout |
---|
119 | ); |
---|
120 | directive_failed( status, "rtems_event_receive" ); |
---|
121 | printf( "TA2 - RTEMS_EVENT_19 received - eventout => %08x\n", eventout ); |
---|
122 | |
---|
123 | puts( "TA2 - rtems_task_delete - deletes self" ); |
---|
124 | status = rtems_task_delete( Task_id[ 2 ] ); |
---|
125 | directive_failed( status, "rtems_task_delete of TA2" ); |
---|
126 | } |
---|