source: rtems/testsuites/samples/capture/init.c @ 16b1599f

4.11
Last change on this file since 16b1599f was 16b1599f, checked in by Ralf Corsepius <ralf.corsepius@…>, on Oct 7, 2011 at 9:39:53 AM

2011-10-07 Ralf Corsépius <ralf.corsepius@…>

  • capture/init.c: Declare notification only if being used.
  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *  It is called from init_exec and has the responsibility for creating
5 *  and starting the tasks that make up the test.  If the time of day
6 *  clock is required for the test, it should also be set to a known
7 *  value by this function.
8 *
9 *  Input parameters:  NONE
10 *
11 *  Output parameters:  NONE
12 *
13 *  COPYRIGHT (c) 1989-1997.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may in
17 *  the file LICENSE in this distribution or at
18 *  http://www.rtems.com/license/LICENSE.
19 *
20 *  $Id$
21 */
22
23#define CONFIGURE_INIT
24
25#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include "system.h"
30#include <stdio.h>
31#include <stdlib.h>
32
33#include <rtems.h>
34#include <rtems/capture-cli.h>
35#include <rtems/monitor.h>
36#include <rtems/shell.h>
37
38volatile int can_proceed = 1;
39
40#if !BSP_SMALL_MEMORY
41static void notification(int fd, int seconds_remaining, void *arg)
42{
43  printf(
44    "Press any key to start capture engine (%is remaining)\n",
45    seconds_remaining
46  );
47}
48#endif
49
50rtems_task Init(
51  rtems_task_argument ignored
52)
53{
54#if BSP_SMALL_MEMORY
55  printf("NO Capture Engine. MEMORY TOO SMALL");
56#else
57  rtems_status_code   status;
58  rtems_task_priority old_priority;
59  rtems_mode          old_mode;
60
61  puts( "\n\n*** TEST CAPTURE ENGINE ***" );
62
63  status = rtems_shell_wait_for_input(
64    STDIN_FILENO,
65    20,
66    notification,
67    NULL
68  );
69  if (status == RTEMS_SUCCESSFUL) {
70    /* lower the task priority to allow created tasks to execute */
71
72    rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
73    rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
74
75    while (!can_proceed)
76    {
77      printf ("Sleeping\n");
78      usleep (1000000);
79    }
80
81    rtems_monitor_init (0);
82    rtems_capture_cli_init (0);
83
84    setup_tasks_to_watch ();
85
86    rtems_task_delete (RTEMS_SELF);
87  } else {
88    puts( "*** END OF TEST CAPTURE ENGINE ***" );
89
90    exit( 0 );
91  }
92#endif
93}
Note: See TracBrowser for help on using the repository browser.