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

5
Last change on this file since f703e7f was f703e7f, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:05

tests: Move rtems_test_printer definition

Statically initialize it to use printk().

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 1.7 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#define TEST_INIT
17
18#include "system.h"
19#include <stdio.h>
20#include <stdlib.h>
21
22#include <rtems.h>
23#include <rtems/capture-cli.h>
24#include <rtems/monitor.h>
25#include <rtems/shell.h>
26
27/* forward declarations to avoid warnings */
28rtems_task Init(rtems_task_argument argument);
29static void notification(int fd, int seconds_remaining, void *arg);
30
31const char rtems_test_name[] = "CAPTURE ENGINE";
32
33volatile int can_proceed = 1;
34
35static void notification(int fd, int seconds_remaining, void *arg)
36{
37  printf(
38    "Press any key to start capture engine (%is remaining)\n",
39    seconds_remaining
40  );
41}
42
43rtems_task Init(
44  rtems_task_argument ignored
45)
46{
47  rtems_status_code   status;
48  rtems_task_priority old_priority;
49  rtems_mode          old_mode;
50
51  rtems_print_printer_printf(&rtems_test_printer);
52  rtems_test_begin();
53
54  status = rtems_shell_wait_for_input(
55    STDIN_FILENO,
56    20,
57    notification,
58    NULL
59  );
60  if (status == RTEMS_SUCCESSFUL) {
61    /* lower the task priority to allow created tasks to execute */
62
63    rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
64    rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
65
66    while (!can_proceed)
67    {
68      printf ("Sleeping\n");
69      usleep (1000000);
70    }
71
72    rtems_monitor_init (0);
73    rtems_capture_cli_init (0);
74
75    setup_tasks_to_watch ();
76
77    rtems_task_delete (RTEMS_SELF);
78  } else {
79    rtems_test_end();
80
81    exit( 0 );
82  }
83}
Note: See TracBrowser for help on using the repository browser.