source: rtems/testsuites/sptests/spwatchdog/task1.c @ 1bde0e5

4.104.115
Last change on this file since 1bde0e5 was 22fa9d61, checked in by Jennifer Averett <Jennifer.Averett@…>, on 01/16/09 at 18:57:53

2009-01-16 Jennifer Averett <jennifer.averett@…>

  • Makefile.am, configure.ac: Add new test to test Watchdog display helper routines. These reach into the SuperCore?.
  • spwatchdog/.cvsignore, spwatchdog/Makefile.am, spwatchdog/delay.c, spwatchdog/init.c, spwatchdog/prtime.c, spwatchdog/spwatchdog.scn, spwatchdog/system.h, spwatchdog/task1.c: New files.
  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*  Task_1
2 *
3 *  This routine serves as a test task.  XXX
4 *
5 *  Input parameters:
6 *    argument - task argument
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 2009.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include "system.h"
21
22rtems_task Task_1(
23  rtems_task_argument argument
24)
25{
26  rtems_id          tmid;
27  rtems_time_of_day time;
28  rtems_status_code status;
29
30/* Get id */
31
32  puts( "TA1 - rtems_timer_ident - identing timer 1" );
33  status = rtems_timer_ident( Timer_name[ 1 ], &tmid );
34  directive_failed( status, "rtems_timer_ident" );
35  printf( "TA1 - timer 1 has id (0x%x)\n", tmid );
36
37/* after which is allowed to fire */
38
39  Print_time();
40
41  puts( "TA1 - rtems_timer_fire_after - timer 1 in 3 seconds" );
42  status = rtems_timer_fire_after(
43    tmid,
44    3 * TICKS_PER_SECOND,
45    Delayed_resume,
46    NULL
47  );
48  directive_failed( status, "rtems_timer_fire_after" );
49
50  puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" );
51  status = rtems_task_suspend( RTEMS_SELF );
52  directive_failed( status, "rtems_task_suspend" );
53
54  Print_time();
55
56/* after which is reset and allowed to fire */
57
58  puts( "TA1 - rtems_timer_fire_after - timer 1 in 3 seconds" );
59  status = rtems_timer_fire_after(
60    tmid,
61    3 * TICKS_PER_SECOND,
62    Delayed_resume,
63    NULL
64  );
65  directive_failed( status, "rtems_timer_fire_after" );
66
67  puts( "TA1 - rtems_task_wake_after - 1 second" );
68  status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
69  directive_failed( status, "rtems_task_wake_after" );
70
71  Print_time();
72
73  puts( "TA1 - rtems_timer_reset - timer 1" );
74  status = rtems_timer_reset( tmid );
75  directive_failed( status, "rtems_timer_reset" );
76
77
78
79
80#if 0
81  puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" );
82  status = rtems_task_suspend( RTEMS_SELF );
83  directive_failed( status, "rtems_task_suspend" );
84
85  Print_time();
86
87  rtems_test_pause();
88
89  /*
90   *  Reset the time since we do not know how long the user waited
91   *  before pressing <cr> at the pause.  This insures that the
92   *  actual output matches the screen.
93   */
94
95  build_time( &time, 12, 31, 1988, 9, 0, 7, 0 );
96
97  status = rtems_clock_set( &time );
98  directive_failed( status, "rtems_clock_set" );
99
100/* after which is canceled */
101
102  puts( "TA1 - rtems_timer_fire_after - timer 1 in 3 seconds" );
103  status = rtems_timer_fire_after(
104    tmid,
105    3 * TICKS_PER_SECOND,
106    Delayed_resume,
107    NULL
108  );
109  directive_failed( status, "rtems_timer_fire_after" );
110
111  puts( "TA1 - rtems_timer_cancel - timer 1" );
112  status = rtems_timer_cancel( tmid );
113  directive_failed( status, "rtems_timer_cancel" );
114
115/* when which is allowed to fire */
116
117  Print_time();
118
119  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
120  directive_failed( status, "rtems_clock_get" );
121
122  time.second += 3;
123
124  puts( "TA1 - rtems_timer_fire_when - timer 1 in 3 seconds" );
125  status = rtems_timer_fire_when( tmid, &time, Delayed_resume, NULL );
126  directive_failed( status, "rtems_timer_fire_when" );
127
128  puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" );
129  status = rtems_task_suspend( RTEMS_SELF );
130  directive_failed( status, "rtems_task_suspend" );
131
132  Print_time();
133
134/* when which is canceled */
135
136  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
137  directive_failed( status, "rtems_clock_get" );
138
139  time.second += 3;
140
141  puts( "TA1 - rtems_timer_fire_when - timer 1 in 3 seconds" );
142  status = rtems_timer_fire_when( tmid, &time, Delayed_resume, NULL );
143  directive_failed( status, "rtems_timer_fire_when" );
144
145  puts( "TA1 - rtems_task_wake_after - 1 second" );
146  status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
147  directive_failed( status, "rtems_task_wake_after" );
148
149  Print_time();
150
151  puts( "TA1 - rtems_timer_cancel - timer 1" );
152  status = rtems_timer_cancel( tmid );
153  directive_failed( status, "rtems_timer_cancel" );
154
155/* delete */
156  puts( "TA1 - rtems_task_wake_after - YIELD (only task at priority)" );
157  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
158  directive_failed( status, "rtems_task_wake_after" );
159#endif
160
161  _Watchdog_Report_chain(
162   "_Watchdog_Ticks_chain",
163    & _Watchdog_Ticks_chain
164  );
165
166  puts( "TA1 - timer_deleting - timer 1" );
167  status = rtems_timer_delete( tmid );
168  directive_failed( status, "rtems_timer_delete" );
169
170  puts( "*** END OF RTEMS WATCHDOG PROGRAM ***" );
171  rtems_test_exit( 0 );
172}
Note: See TracBrowser for help on using the repository browser.