source: rtems/testsuites/libtests/rtems++/Task3.cc @ c499856

4.115
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.9 KB
Line 
1/*  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-2007.
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.rtems.org/license/LICENSE.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include "System.h"
24
25Task3::Task3(const char* name,
26             const rtems_task_priority initial_priority,
27             const uint32_t   stack_size)
28  : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
29{
30}
31 
32void Task3::body(rtems_task_argument )
33{
34  screen6();
35
36  printf("%s - destroy itself\n", name_string());
37  destroy();
38}
39
40void Task3::screen6()
41{
42  rtemsMessageQueue mq_2("MQ2");
43  printf("%s - construction connect mq_2 - %s\n", name_string(), mq_2.last_status_string());
44
45  if (mq_2.successful())
46  {
47    char in[100];
48    char out[100];
49    size_t   size;
50    bool loopback = true;
51 
52    while (loopback)
53    {
54    printf("%s - loopback from mq_2 to mq_2 ...\n", name_string()); fflush(stdout);
55
56    mq_2.receive(in, size);
57      printf("%s - mq_2 receive - %s, size=%zu, message string size=%zu\n",
58             name_string(), mq_2.last_status_string(), size, strlen(in));
59      if (mq_2.successful())
60      {
61        if (size > (100 - 5))
62          printf("%s - size to large\n", name_string());
63        else
64        {
65          strcpy(out, name_string());
66          strcpy(out + 4, in);
67     
68          printf("%s - loopback to mq_2 - ", name_string());
69          mq_2.send(out, strlen(out) + 1);
70          printf("%s\n", mq_2.last_status_string());
71        }
72
73        if (strcmp(in, "broadcast message") == 0)
74          loopback = false;
75        else
76          wake_after(1500000);
77      }
78    }
79  }
80}
81
82
Note: See TracBrowser for help on using the repository browser.