OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [libtests/] [rtems++/] [Task3.cc] - Blame information for rev 507

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  Task_3
2
 *
3
 *  This routine serves as a test task. Loopback the messages and test
4
 *  timeouts
5
 *
6
 *  Input parameters:
7
 *    argument - task argument
8
 *
9
 *  Output parameters:  NONE
10
 *
11
 *  COPYRIGHT (c) 1989-1999.
12
 *  On-Line Applications Research Corporation (OAR).
13
 *
14
 *  The license and distribution terms for this file may be
15
 *  found in the file LICENSE in this distribution or at
16
 *  http://www.OARcorp.com/rtems/license.html.
17
 *
18
 *  $Id: Task3.cc,v 1.2 2001-09-27 12:02:13 chris Exp $
19
 */
20
 
21
#include "System.h"
22
 
23
Task3::Task3(const char* name,
24
             const rtems_task_priority initial_priority,
25
             const rtems_unsigned32 stack_size)
26
  : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
27
{
28
}
29
 
30
void Task3::body(rtems_task_argument )
31
{
32
  screen6();
33
 
34
  printf("%s - destroy itself\n", name_string());
35
  destroy();
36
}
37
 
38
void Task3::screen6()
39
{
40
  rtemsMessageQueue mq_2("MQ2");
41
  printf("%s - construction connect mq_2 - %s\n", name_string(), mq_2.last_status_string());
42
 
43
  if (mq_2.successful())
44
  {
45
    char in[100];
46
    char out[100];
47
    rtems_unsigned32 size;
48
    bool loopback = true;
49
 
50
    while (loopback)
51
    {
52
    printf("%s - loopback from mq_2 to mq_2 ...\n", name_string()); fflush(stdout);
53
 
54
    mq_2.receive(in, size);
55
      printf("%s - mq_2 receive - %s, size=%i, message string size=%i\n",
56
             name_string(), mq_2.last_status_string(), size, (int) strlen(in));
57
      if (mq_2.successful())
58
      {
59
        if (size > (100 - 5))
60
          printf("%s - size to large\n", name_string());
61
        else
62
        {
63
          strcpy(out, name_string());
64
          strcpy(out + 4, in);
65
 
66
          printf("%s - loopback to mq_2 - ", name_string());
67
          mq_2.send(out, strlen(out) + 1);
68
          printf("%s\n", mq_2.last_status_string());
69
        }
70
 
71
        if (strcmp(in, "broadcast message") == 0)
72
          loopback = false;
73
        else
74
          wake_after(1500000);
75
      }
76
    }
77
  }
78
}
79
 
80
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.