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/] [04_stripe_mem.c] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/**
2
 *
3
 * @file   02_inv_scan.c
4
 * @author Lasse Lehtonen
5
 *
6
 * @brief VOPD - inv_scan 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    = 4;
21
 
22
const int REMOTE1  = 5;
23
const int TX_PORT1 = 10;
24
const int RX_PORT1 = 11;
25
const int TX_DATA1 = 27;//648;
26
 
27
const int IN_PORT  = 7;
28
 
29
 
30
 
31
mcapi_pktchan_recv_hndl_t       send_handle1;
32
mcapi_pktchan_recv_hndl_t       recv_handle;
33
 
34
static struct sigaction oldactions[32];
35
 
36
static void signalled(int signal, siginfo_t *info, void *context)
37
{
38
        struct sigaction *action;
39
 
40
        action = &oldactions[signal];
41
 
42
        if ((action->sa_flags & SA_SIGINFO) && action->sa_sigaction)
43
                action->sa_sigaction(signal, info, context);
44
        else if (action->sa_handler)
45
                action->sa_handler(signal);
46
 
47
        exit(signal);
48
}
49
 
50
struct sigaction action = {
51
        .sa_sigaction = signalled,
52
        .sa_flags = SA_SIGINFO,
53
};
54
 
55
 
56
int main(int argc, char* argv[])
57
{
58
 
59
   mcapi_status_t status;
60
   mcapi_version_t version;
61
 
62
   char   outgoing1[TX_DATA1];
63
   char*  incoming;
64
   size_t bytes;
65
   int count = 0;
66
 
67
 
68
   mcapi_initialize(LOCAL, &version, &status);
69
   mcapi_assert_success(status);
70
   printf("Node %d: MCAPI Initialized\n", LOCAL);
71
 
72
   connect_fwd(LOCAL, TX_PORT1, &send_handle1, REMOTE1, RX_PORT1);
73
   connect_rev(LOCAL, IN_PORT, &recv_handle);
74
 
75
   atexit(cleanup);
76
   sigaction(SIGQUIT, &action, &oldactions[SIGQUIT]);
77
   sigaction(SIGABRT, &action, &oldactions[SIGABRT]);
78
   sigaction(SIGTERM, &action, &oldactions[SIGTERM]);
79
   sigaction(SIGINT,  &action, &oldactions[SIGINT]);
80
 
81
   while(1) {
82
 
83
      mcapi_pktchan_recv(recv_handle, (void *)&incoming, &bytes,
84
                        &status);
85
      printf("Node %d: received %d bytes :%s\n", LOCAL, bytes, incoming);
86
 
87
      mcapi_pktchan_free(incoming, &status);
88
      mcapi_assert_success(status);
89
 
90
      count = (count+1) % 10;
91
      memset(outgoing1, 0, TX_DATA1);
92
      sprintf(outgoing1, "Node %d: stripe_mem (%d)", LOCAL, count);
93
 
94
      mcapi_pktchan_send(send_handle1, outgoing1, TX_DATA1,
95
                         &status);
96
      mcapi_assert_success(status);
97
 
98
   }
99
 
100
   return 0;
101
}
102
 
103
// Local Variables:
104
// mode: c++
105
// c-file-style: "ellemtel"
106
// c-basic-offset: 3
107
// End:
108
 

powered by: WebSVN 2.1.0

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