forked from airbus/a653lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpartition_a.c
More file actions
217 lines (169 loc) · 6.35 KB
/
partition_a.c
File metadata and controls
217 lines (169 loc) · 6.35 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/**
* @file prcs_a.c
* @author nicolaus.baer@airbus.com
* @date Tue Oct 24 15:53:18 CEST 2023
* @brief partition main function
* @details
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//--------------------
#include <errno.h>
#include <time.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
#include "a653Lib.h"
/* #include "a653Init.h" */
/* #include "a653_config.h" */
/* a653_global_config_t global_config = A653_PARTITION_CONFIG_DEF; */
/* a653_process_config_t A653_PROCESS_CONFIG[] = A653_PROCESS_CONFIG_DEF; */
/* a653_sampling_port_config_t A653_SP_CONFIG[] = A653_SP_CONFIG_DEF; */
/* a653_queuing_port_config_t A653_QP_CONFIG[] = A653_QP_CONFIG_DEF; */
void PeriodicProcess(void){
RETURN_CODE_TYPE return_code;
MESSAGE_SIZE_TYPE length;
VALIDITY_TYPE validity;
SYSTEM_TIME_TYPE system_time;
unsigned short count = 0;
A653_BYTE data_sp_tx[32] = "sp_test1234";
A653_BYTE data_sp_rx[32] = " ";
A653_BYTE data_qp_tx[32] = "qp_test1234";
A653_BYTE data_qp_rx[32] = " ";
SAMPLING_PORT_ID_TYPE sp_id_tx;
SAMPLING_PORT_ID_TYPE sp_id_rx;
QUEUING_PORT_ID_TYPE qp_id_tx;
QUEUING_PORT_ID_TYPE qp_id_rx;
GET_SAMPLING_PORT_ID ("SP_Prcs_A to Prcs B ",
&sp_id_tx,
&return_code);
GET_SAMPLING_PORT_ID ("SP_Prcs_B to Prcs A ",
&sp_id_rx,
&return_code);
GET_QUEUING_PORT_ID("QP_Prcs_A to Prcs B ",
&qp_id_tx,
&return_code);
GET_QUEUING_PORT_ID("QP_Prcs_B to Prcs A ",
&qp_id_rx,
&return_code);
int index = 0;
while (1){
count++;
sprintf((char *)data_sp_tx,"Prcs A: 0x%04x",count);
WRITE_SAMPLING_MESSAGE(sp_id_tx, /* sampling port id */
data_sp_tx, /* pointer to data */
32, /* send size */
&return_code); /* return code */
SEND_QUEUING_MESSAGE(qp_id_tx,
data_qp_tx,
30, // size
0, //timeout
&return_code);
printDebug(3,"%06d Prcs A send %s \n",index++,data_sp_tx);
READ_SAMPLING_MESSAGE(sp_id_rx,
data_sp_rx,
&length,
&validity,
&return_code);
if (validity == VALID && length > 0){
printDebug(3,"Prcs A: SP we got this : >%s<\n",(char *)data_sp_rx);
} else {
printDebug(3,"Prcs A: validity >%d< length >%d<\n",validity,length);
}
RECEIVE_QUEUING_MESSAGE(qp_id_rx,
0, /* time out */
data_qp_rx, /* pointer to data */
&length, /* received length */
&return_code); /* return code */
if(return_code == NO_ERROR && length !=0){
printDebug(3,"Prcs A: QP we got this : >%s<\n",(char *)data_qp_rx);
} else {
printDebug(3,"Prcs A: return >%d<\n",return_code);
}
GET_TIME (&system_time, &return_code);
printDebug(3,"Prcs A: GET_TIME >%lld<\n",system_time);
PERIODIC_WAIT(&return_code);
}
}
/* have a look to init.c beforeMain is called before main!!!!! */
int main (int argc, char *argv[]){
RETURN_CODE_TYPE return_code;
RETURN_CODE_TYPE Init_Process_ret;
PROCESS_ID_TYPE Init_process_ID;
PROCESS_ATTRIBUTE_TYPE process_data;
A653_INTEGER PortId;
int ret_val = 0;
/* 0 1 2 3 */
/* 01234567890123456789012345678901 */
CREATE_SAMPLING_PORT("SP_Prcs_A to Prcs B ",
32, // Size in Bytes
0, // 0 tx : 1 rx
40000000, // currently unused
&PortId,
&return_code
);
/* 0 1 2 3 */
/* 01234567890123456789012345678901 */
CREATE_SAMPLING_PORT("SP_Prcs_B to Prcs A ",
32, // Size in Bytes
1, // 0 tx : 1 rx
40000000, // currently unused
&PortId,
&return_code
);
/* 0 1 2 3 */
/* 01234567890123456789012345678901 */
CREATE_QUEUING_PORT("QP_Prcs_A to Prcs B ",
32, // Size in Bytes
4, // number of entries
0, // 0 tx : 1 rx
FIFO,
&PortId,
&return_code
);
/* 0 1 2 3 */
/* 01234567890123456789012345678901 */
CREATE_QUEUING_PORT("QP_Prcs_B to Prcs A ",
32, // Size in Bytes
4, // number of entries
1, // 0 tx : 1 rx
FIFO,
&PortId,
&return_code
);
//Start initialization
// InitSamplingPorts();
//Initialization of the processes
memset((char*)(&process_data.NAME), 0, sizeof(process_data.NAME));
sprintf((char*)(&process_data.NAME), "Process A ");
process_data.PERIOD = 100000000LL; /* nsec 0,1 sec*/
process_data.TIME_CAPACITY = 0;
process_data.STACK_SIZE = 0x5000000;
process_data.ENTRY_POINT = &PeriodicProcess; //Entrypoint to periodic process
process_data.BASE_PRIORITY = 40 ;
process_data.DEADLINE = SOFT;
CREATE_PROCESS(&process_data, &Init_process_ID, &Init_Process_ret);
/* if( Init_Process_ret != NO_ERROR )
RAISE_APPLICATION_ERROR( APPLICATION_ERROR, errorMsgs[Init_Process_ret], 10, &raiseErrorRet ); */
//Creation of ports
/* for(portCnt=0;portCnt<NbOfPorts;portCnt++) */
/* { */
/* CREATE_SAMPLING_PORT(Ports_cfg[portCnt].PortName, */
/* Ports_cfg[portCnt].MsgSize, */
/* Ports_cfg[portCnt].Direction, */
/* Ports_cfg[portCnt].RefreshPeriod, */
/* &(Ports[portCnt].PortID), */
/* &(Ports[portCnt].Create_ret)); */
/* Ports[portCnt].size = Ports_cfg[portCnt].MsgSize; */
/* } */
//Starting processes
START(Init_process_ID, &Init_Process_ret);
/* if( Init_Process_ret != NO_ERROR )
RAISE_APPLICATION_ERROR( APPLICATION_ERROR, errorMsgs[Init_Process_ret], 10, &raiseErrorRet ); */
//Set normal mode
SET_PARTITION_MODE(NORMAL, &Init_Process_ret);
/* if( Init_Process_ret != NO_ERROR )
RAISE_APPLICATION_ERROR( APPLICATION_ERROR, errorMsgs[Init_Process_ret], 10, &raiseErrorRet ); */
return ret_val;
}