-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathglobalcounter.h
More file actions
159 lines (138 loc) · 3.58 KB
/
Copy pathglobalcounter.h
File metadata and controls
159 lines (138 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
* $Id: globalcounter.h,v 1.1 2006/05/24 09:42:11 nito Exp $
*
* Global counter structure
*
* Currently only serial sync is supported
*/
#ifndef GLOBALCOUNTER_H
#define GLOBALCOUNTER_H
union validcountervalues {
char *string;
int counter;
};
struct globalcounter {
union validcountervalues value;
const char *name;
const char *description;
};
#define NUM_GLOBALCOUNTERS 20
/*#define NUM_GLOBALCOUNTERS sizeof(globalcounters)/sizeof(struct globalcounter)*/
extern struct globalcounter globalcounters[];
#define SERIAL_IF_WRITE_BYTES 0
#define SERIAL_IF_READ_BYTES 1
#define SERIAL_IF_WRITE_ERRORS 2
#define SERIAL_IF_READ_ERRORS 3
#define SERIAL_IF_MTU 3
#define SERIAL_IF_SPEED 4
#define SERIAL_IF_ADMIN_STATUS 5
#define SERIAL_IF_OPER_STATUS 6
#define SERIAL_IF_ABORT_SIGNALS 7
#define SERIAL_IF_CRC_ERRORS 8
#define SERIAL_IF_CTS_TIMEOUTS 9
#define SERIAL_IF_CARRIER_DROPS 10
#define SERIAL_IF_TX_UNDERRUN 11
#define SERIAL_IF_RCVR_OVERRUN 12
#define SERIAL_IF_RCVR_NO_BUFFERS 13
#define SERIAL_IF_IN_OCTETS 14
#define SERIAL_IF_IN_PKTS 15
#define SERIAL_IF_IN_ERRORS 16
#define SERIAL_IF_OUT_OCTETS 17
#define SERIAL_IF_OUT_PKTS 18
#define SERIAL_IF_OUT_ERRORS 19
/* Size of the globalcounters array */
/*
* add_to_globalcounter
*
* Adds a value to the global counter
* Input:
* - The index of the counter 0..num_globalcounters - 1
* - The value
* Output:
* - The value of the counter or -1 in case that the index
* is out of bounds
*/
#define add_to_globalcounter(index,myvalue) \
(index < 0 || index >= NUM_GLOBALCOUNTERS) ? \
-1 : \
(globalcounters[index].value.counter += myvalue)
/*
* get_globalcounter
*
* Adds a value to the global counter
* Input:
* - The index of the counter 0..num_globalcounters - 1
* Output:
* - The value of the counter or -1 in case that the index
* is out of bounds
*/
#define get_globalcounter(index) \
((index < 0) || (index >= NUM_GLOBALCOUNTERS)) ? \
-1 : \
globalcounters[index].value.counter
/*
* set_globalcounter
*
* sets the value of the global counter
* Input:
* - The index of the counter 0..num_globalcounters - 1
* - The value
* Output:
* - The value of the counter or -1 in case that the index
* is out of bounds
*/
#define set_globalcounter(index,myvalue) \
(index < 0 || index >= NUM_GLOBALCOUNTERS) ? \
-1 : \
(globalcounters[index].value.counter=myvalue)
/*
* reset_globalcounter
*
* sets the value of the global counter to 0
* Input:
* - The index of the counter 0..num_globalcounters - 1
* Output:
* - The value of the counter or -1 in case that the index
* is out of bounds
*/
#define reset_globalcounter(index) \
set_globalcounter(index,0)
/*
* reset_allglobalcounter
*
* sets the value of the all the global counters to 0
* Input:
* - None
* Output:
* - None
*/
int reset_allglobalcounters();
/*
* get_globalcounter_name
*
* Returns the name of the global counter
* Input:
* - The index of the counter 0..num_globalcounters - 1
* Output:
* - The name of the counter or NULL in case that the index
* is out of bounds
*/
#define get_globalcounter_name(index) \
(index < 0 || index >= NUM_GLOBALCOUNTERS) ? \
NULL: \
globalcounters[index].name
/*
* get_globalcounter_description
*
* Returns the description of the global counter
* Input:
* - The index of the counter 0..num_globalcounters - 1
* Output:
* - The name of the counter or NULL in case that the index
* is out of bounds
*/
#define get_globalcounter_description(index) \
(index < 0 || index >= NUM_GLOBALCOUNTERS) ? \
NULL: \
globalcounters[index].description
#endif