source: rtems/testsuites/samples/capture/init.c @ c499856

4.11
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may in
6 *  the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#define CONFIGURE_INIT
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include "system.h"
17#include <stdio.h>
18#include <stdlib.h>
19
20#include <rtems.h>
21#include <rtems/capture-cli.h>
22#include <rtems/monitor.h>
23#include <rtems/shell.h>
24
25/* forward declarations to avoid warnings */
26rtems_task Init(rtems_task_argument argument);
27#if !BSP_SMALL_MEMORY
28  static void notification(int fd, int seconds_remaining, void *arg);
29#endif
30
31const char rtems_test_name[] = "CAPTURE ENGINE";
32
33volatile int can_proceed = 1;
34
35#if !BSP_SMALL_MEMORY
36static void notification(int fd, int seconds_remaining, void *arg)
37{
38  printf(
39    "Press any key to start capture engine (%is remaining)\n",
40    seconds_remaining
41  );
42}
43#endif
44
45rtems_task Init(
46  rtems_task_argument ignored
47)
48{
49#if BSP_SMALL_MEMORY
50  printf("NO Capture Engine. MEMORY TOO SMALL");
51#else
52  rtems_status_code   status;
53  rtems_task_priority old_priority;
54  rtems_mode          old_mode;
55
56  rtems_test_begin();
57
58  status = rtems_shell_wait_for_input(
59    STDIN_FILENO,
60    20,
61    notification,
62    NULL
63  );
64  if (status == RTEMS_SUCCESSFUL) {
65    /* lower the task priority to allow created tasks to execute */
66
67    rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
68    rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
69
70    while (!can_proceed)
71    {
72      printf ("Sleeping\n");
73      usleep (1000000);
74    }
75
76    rtems_monitor_init (0);
77    rtems_capture_cli_init (0);
78
79    setup_tasks_to_watch ();
80
81    rtems_task_delete (RTEMS_SELF);
82  } else {
83    rtems_test_end();
84
85    exit( 0 );
86  }
87#endif
88}
Note: See TracBrowser for help on using the repository browser.