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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

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

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[5f0cd34]1/*
2 *  COPYRIGHT (c) 1989-2012.
[a23427e]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
[c499856]7 *  http://www.rtems.org/license/LICENSE.
[a23427e]8 */
9
10#define CONFIGURE_INIT
11
[e313551]12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
[a23427e]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>
[7c9d27e]23#include <rtems/shell.h>
[a23427e]24
[5f0cd34]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
[9391f6d]31const char rtems_test_name[] = "CAPTURE ENGINE";
32
[a23427e]33volatile int can_proceed = 1;
34
[16b1599f]35#if !BSP_SMALL_MEMORY
[7c9d27e]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}
[16b1599f]43#endif
[7c9d27e]44
[a23427e]45rtems_task Init(
46  rtems_task_argument ignored
47)
48{
[cdf44d93]49#if BSP_SMALL_MEMORY
50  printf("NO Capture Engine. MEMORY TOO SMALL");
51#else
[7c9d27e]52  rtems_status_code   status;
[a23427e]53  rtems_task_priority old_priority;
54  rtems_mode          old_mode;
55
[9391f6d]56  rtems_test_begin();
[a23427e]57
[7c9d27e]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 */
[a23427e]66
[7c9d27e]67    rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
68    rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
[a23427e]69
[7c9d27e]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);
[a23427e]78
[7c9d27e]79    setup_tasks_to_watch ();
[b1274bd9]80
[7c9d27e]81    rtems_task_delete (RTEMS_SELF);
82  } else {
[9391f6d]83    rtems_test_end();
[a23427e]84
[7c9d27e]85    exit( 0 );
86  }
[cdf44d93]87#endif
[a23427e]88}
Note: See TracBrowser for help on using the repository browser.