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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/**
2
 *
3
 * @file   06_vid.c
4
 * @author Lasse Lehtonen
5
 *
6
 * @brief VOPD - arm 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
 
21
const int LOCAL   = 6;
22
const int REMOTE  = 7;
23
const int TX_PORT = 14;
24
const int RX_PORT = 15;
25
const int TX_DATA = 16;//386;
26
 
27
const int IN_PORT = 31;
28
 
29
mcapi_pktchan_recv_hndl_t       send_handle;
30
mcapi_pktchan_recv_hndl_t       recv_handle;
31
 
32
static struct sigaction oldactions[32];
33
 
34
static void signalled(int signal, siginfo_t *info, void *context)
35
{
36
        struct sigaction *action;
37
 
38
        action = &oldactions[signal];
39
 
40
        if ((action->sa_flags & SA_SIGINFO) && action->sa_sigaction)
41
                action->sa_sigaction(signal, info, context);
42
        else if (action->sa_handler)
43
                action->sa_handler(signal);
44
 
45
        exit(signal);
46
}
47
 
48
struct sigaction action = {
49
        .sa_sigaction = signalled,
50
        .sa_flags = SA_SIGINFO,
51
};
52
 
53
int main(int argc, char* argv[])
54
{
55
 
56
   mcapi_status_t status;
57
   mcapi_version_t version;
58
 
59
   char   outgoing[TX_DATA];
60
   int    count = 0;
61
 
62
   char*  incoming;
63
   size_t bytes;
64
 
65
   mcapi_initialize(LOCAL, &version, &status);
66
   mcapi_assert_success(status);
67
   printf("Node %d: MCAPI Initialized\n", LOCAL);
68
 
69
   connect_rev(LOCAL, IN_PORT, &recv_handle);
70
   connect_fwd(LOCAL, TX_PORT, &send_handle, REMOTE, RX_PORT);
71
 
72
   atexit(cleanup);
73
   sigaction(SIGQUIT, &action, &oldactions[SIGQUIT]);
74
   sigaction(SIGABRT, &action, &oldactions[SIGABRT]);
75
   sigaction(SIGTERM, &action, &oldactions[SIGTERM]);
76
   sigaction(SIGINT,  &action, &oldactions[SIGINT]);
77
 
78
 
79
   while(1) {
80
 
81
      mcapi_pktchan_recv(recv_handle, (void *)&incoming, &bytes,
82
                        &status);
83
      printf("Node %d: received %d bytes :%s\n", LOCAL, bytes, incoming);
84
 
85
      mcapi_pktchan_free(incoming, &status);
86
      mcapi_assert_success(status);
87
 
88
 
89
 
90
      count = (count+1) % 10;
91
      memset(outgoing, 0, TX_DATA);
92
      sprintf(outgoing, "Node %d: arm (%d)", LOCAL, count);
93
 
94
      mcapi_pktchan_send(send_handle, outgoing, TX_DATA,
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.