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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.application/] [vopd/] [1.0/] [src/] [09_vop_rec.c] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/**
2
 *
3
 * @file   09_vop_rec.c
4
 * @author Lasse Lehtonen
5
 *
6
 * @brief VOPD - vop_rec node.
7
 *
8
 */
9
 
10
 
11
#include "common.h"
12
 
13
#include <mcapi.h>
14
 
15
#include <stdlib.h>
16
#include <stdio.h>
17
#include <signal.h>
18
#include <getopt.h>
19
 
20
const int LOCAL    = 9;
21
 
22
const int REMOTE1  = 10;
23
const int TX_PORT1 = 20;
24
const int RX_PORT1 = 21;
25
const int TX_DATA1 = 320;//512;
26
 
27
 
28
const int IN_PORT1  = 19;
29
const int IN_PORT2  = 27;
30
 
31
 
32
 
33
mcapi_pktchan_recv_hndl_t       send_handle1;
34
mcapi_pktchan_recv_hndl_t       recv_handle1;
35
mcapi_pktchan_recv_hndl_t       recv_handle2;
36
 
37
static struct sigaction oldactions[32];
38
 
39
static void signalled(int signal, siginfo_t *info, void *context)
40
{
41
        struct sigaction *action;
42
 
43
        action = &oldactions[signal];
44
 
45
        if ((action->sa_flags & SA_SIGINFO) && action->sa_sigaction)
46
                action->sa_sigaction(signal, info, context);
47
        else if (action->sa_handler)
48
                action->sa_handler(signal);
49
 
50
        exit(signal);
51
}
52
 
53
struct sigaction action = {
54
        .sa_sigaction = signalled,
55
        .sa_flags = SA_SIGINFO,
56
};
57
 
58
 
59
int main(int argc, char* argv[])
60
{
61
 
62
   mcapi_status_t status;
63
   mcapi_version_t version;
64
 
65
   char   outgoing1[TX_DATA1];
66
   char*  incoming;
67
   size_t bytes;
68
   int count = 0;
69
 
70
 
71
   mcapi_initialize(LOCAL, &version, &status);
72
   mcapi_assert_success(status);
73
   printf("Node %d: MCAPI Initialized\n", LOCAL);
74
 
75
   connect_fwd(LOCAL, TX_PORT1, &send_handle1, REMOTE1, RX_PORT1);
76
   connect_rev(LOCAL, IN_PORT2, &recv_handle2);
77
   connect_rev(LOCAL, IN_PORT1, &recv_handle1);
78
 
79
 
80
   atexit(cleanup);
81
   sigaction(SIGQUIT, &action, &oldactions[SIGQUIT]);
82
   sigaction(SIGABRT, &action, &oldactions[SIGABRT]);
83
   sigaction(SIGTERM, &action, &oldactions[SIGTERM]);
84
   sigaction(SIGINT,  &action, &oldactions[SIGINT]);
85
 
86
   while(1) {
87
 
88
      mcapi_pktchan_recv(recv_handle1, (void *)&incoming, &bytes,
89
                        &status);
90
      printf("Node %d: received %d bytes :%s\n", LOCAL, bytes, incoming);
91
 
92
      mcapi_pktchan_free(incoming, &status);
93
      mcapi_assert_success(status);
94
 
95
 
96
      mcapi_pktchan_recv(recv_handle2, (void *)&incoming, &bytes,
97
                        &status);
98
      printf("Node %d: received %d bytes :%s\n", LOCAL, bytes, incoming);
99
 
100
      mcapi_pktchan_free(incoming, &status);
101
      mcapi_assert_success(status);
102
 
103
      count = (count+1) % 10;
104
      memset(outgoing1, 0, TX_DATA1);
105
      sprintf(outgoing1, "Node %d: vop_rec (%d)", LOCAL, count);
106
      mcapi_pktchan_send(send_handle1, outgoing1, TX_DATA1,
107
                         &status);
108
      mcapi_assert_success(status);
109
 
110
   }
111
 
112
   return 0;
113
}
114
 
115
// Local Variables:
116
// mode: c++
117
// c-file-style: "ellemtel"
118
// c-basic-offset: 3
119
// End:
120
 

powered by: WebSVN 2.1.0

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