##// END OF EJS Templates
avf2 prc2 tasks added...
paul -
r124:9657f56b7e43 VHDLib206
parent child
Show More
@@ -0,0 +1,358
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "avf0_prc0.h"
11
12 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
13 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
15 ring_node_asm *current_ring_node_asm_norm_f0;
16
17 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
20 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
21
22 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
23
24 void reset_nb_sm_f0( unsigned char lfrMode )
25 {
26 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
27 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
28 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
29 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
30 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
31 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
32 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
33 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
34 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
35
36 if (lfrMode == LFR_MODE_SBM1)
37 {
38 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
39 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
40 }
41 else if (lfrMode == LFR_MODE_SBM2)
42 {
43 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
44 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
45 }
46 else if (lfrMode == LFR_MODE_BURST)
47 {
48 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
49 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
50 }
51 else
52 {
53 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
54 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
55 }
56 }
57
58 //************
59 // RTEMS TASKS
60
61 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
62 {
63 int i;
64
65 rtems_event_set event_out;
66 rtems_status_code status;
67 rtems_id queue_id_prc0;
68 asm_msg msgForMATR;
69 ring_node_sm *ring_node_tab[8];
70
71 unsigned int nb_norm_bp1;
72 unsigned int nb_norm_bp2;
73 unsigned int nb_norm_asm;
74 unsigned int nb_sbm_bp1;
75 unsigned int nb_sbm_bp2;
76
77 nb_norm_bp1 = 0;
78 nb_norm_bp2 = 0;
79 nb_norm_asm = 0;
80 nb_sbm_bp1 = 0;
81 nb_sbm_bp2 = 0;
82
83 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
84 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
85 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
86 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
87 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
88
89 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
90
91 status = get_message_queue_id_prc0( &queue_id_prc0 );
92 if (status != RTEMS_SUCCESSFUL)
93 {
94 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
95 }
96
97 while(1){
98 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
99 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
100 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
101 {
102 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
103 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
104 }
105
106 // compute the average and store it in the averaged_sm_f1 buffer
107 SM_average( current_ring_node_asm_norm_f0->matrix,
108 current_ring_node_asm_burst_sbm_f0->matrix,
109 ring_node_tab,
110 nb_norm_bp1, nb_sbm_bp1 );
111
112 // update nb_average
113 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
114 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
115 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
116 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
117 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
118
119 //****************************************
120 // initialize the mesage for the MATR task
121 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
122 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
123 msgForMATR.norm = current_ring_node_asm_norm_f0;
124 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
125 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
126 msgForMATR.coarseTime = time_management_regs->coarse_time;
127 msgForMATR.fineTime = time_management_regs->fine_time;
128
129 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
130 {
131 nb_sbm_bp1 = 0;
132 // set another ring for the ASM storage
133 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
134 if ( (lfrCurrentMode == LFR_MODE_BURST)
135 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
136 {
137 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
138 }
139 }
140
141 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
142 {
143 nb_sbm_bp2 = 0;
144 if ( (lfrCurrentMode == LFR_MODE_BURST)
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
146 {
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
148 }
149 }
150
151 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
152 {
153 nb_norm_bp1 = 0;
154 // set another ring for the ASM storage
155 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
156 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
157 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
158 {
159 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
160 }
161 }
162
163 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
164 {
165 nb_norm_bp2 = 0;
166 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
167 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
168 {
169 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
170 }
171 }
172
173 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
174 {
175 nb_norm_asm = 0;
176 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
177 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
178 {
179 // PRINTF1("%lld\n", localTime)
180 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
181 }
182 }
183
184 //*************************
185 // send the message to MATR
186 if (msgForMATR.event != 0x00)
187 {
188 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
189 }
190
191 if (status != RTEMS_SUCCESSFUL) {
192 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
193 }
194 }
195 }
196
197 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
198 {
199 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
200 size_t size; // size of the incoming TC packet
201 asm_msg *incomingMsg;
202 //
203 spw_ioctl_pkt_send spw_ioctl_send_ASM;
204 rtems_status_code status;
205 rtems_id queue_id;
206 rtems_id queue_id_q_p0;
207 Header_TM_LFR_SCIENCE_ASM_t headerASM;
208 bp_packet_with_spare packet_norm_bp1_f0;
209 bp_packet packet_norm_bp2_f0;
210 bp_packet packet_sbm_bp1_f0;
211 bp_packet packet_sbm_bp2_f0;
212
213 unsigned long long int localTime;
214
215 ASM_init_header( &headerASM );
216
217 //*************
218 // NORM headers
219 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
222 BP_init_header( &packet_norm_bp2_f0.header,
223 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
224 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
225
226 //****************************
227 // BURST SBM1 and SBM2 headers
228 if ( lfrRequestedMode == LFR_MODE_BURST )
229 {
230 BP_init_header( &packet_sbm_bp1_f0.header,
231 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
232 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
233 BP_init_header( &packet_sbm_bp2_f0.header,
234 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
235 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
236 }
237 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
238 {
239 BP_init_header( &packet_sbm_bp1_f0.header,
240 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
241 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
242 BP_init_header( &packet_sbm_bp2_f0.header,
243 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
244 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
245 }
246 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
247 {
248 BP_init_header( &packet_sbm_bp1_f0.header,
249 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
250 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
251 BP_init_header( &packet_sbm_bp2_f0.header,
252 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
253 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
254 }
255 else
256 {
257 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
258 }
259
260 status = get_message_queue_id_send( &queue_id );
261 if (status != RTEMS_SUCCESSFUL)
262 {
263 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
264 }
265 status = get_message_queue_id_prc0( &queue_id_q_p0);
266 if (status != RTEMS_SUCCESSFUL)
267 {
268 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
269 }
270
271 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
272
273 while(1){
274 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
275 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
276
277 incomingMsg = (asm_msg*) incomingData;
278
279 localTime = getTimeAsUnsignedLongLongInt( );
280 //****************
281 //****************
282 // BURST SBM1 SBM2
283 //****************
284 //****************
285 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
286 {
287 // 1) compress the matrix for Basic Parameters calculation
288 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
289 nb_sm_before_f0.burst_sbm_bp1,
290 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
291 ASM_F0_INDICE_START);
292 // 2) compute the BP1 set
293
294 // 3) send the BP1 set
295 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
296 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
297 BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id,
298 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
299 // 4) compute the BP2 set if needed
300 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
301 {
302 // 1) compute the BP2 set
303
304 // 2) send the BP2 set
305 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
306 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
307 BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id,
308 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
309 }
310 }
311
312 //*****
313 //*****
314 // NORM
315 //*****
316 //*****
317 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
318 {
319 // 1) compress the matrix for Basic Parameters calculation
320 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
321 nb_sm_before_f0.norm_bp1,
322 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
323 ASM_F0_INDICE_START );
324 // 2) compute the BP1 set
325
326 // 3) send the BP1 set
327 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
328 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
329 BP_send( (char *) &packet_norm_bp1_f0.header, queue_id,
330 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
331 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
332 {
333 // 1) compute the BP2 set using the same ASM as the one used for BP1
334
335 // 2) send the BP2 set
336 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
337 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
338 BP_send( (char *) &packet_norm_bp2_f0.header, queue_id,
339 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
340 }
341 }
342
343 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
344 {
345 // 1) reorganize the ASM and divide
346 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
347 asm_f0_reorganized,
348 nb_sm_before_f0.norm_bp1 );
349 // 2) convert the float array in a char array
350 ASM_convert( asm_f0_reorganized, asm_f0_char);
351 // 3) send the spectral matrix packets
352 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
353 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
354 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
355 }
356
357 }
358 }
@@ -0,0 +1,30
1 #ifndef AVF0_PRC0_H
2 #define AVF0_PRC0_H
3
4 #include "fsw_processing.h"
5
6 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
10 unsigned int burst_sbm_bp1;
11 unsigned int burst_sbm_bp2;
12 unsigned int burst_bp1;
13 unsigned int burst_bp2;
14 unsigned int sbm1_bp1;
15 unsigned int sbm1_bp2;
16 unsigned int sbm2_bp1;
17 unsigned int sbm2_bp2;
18 } nb_sm_before_bp_asm_f0;
19
20 extern struct ring_node_sm *current_ring_node_sm_f0;
21 extern struct ring_node_sm *ring_node_for_averaging_sm_f0;
22
23 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
24
25 void reset_nb_sm_f0( unsigned char lfrMode );
26
27 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
28 rtems_task prc0_task( rtems_task_argument lfrRequestedMode );
29
30 #endif // AVF0_PRC0_H
@@ -0,0 +1,339
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "avf1_prc1.h"
11
12 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
13 ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
15 ring_node_asm *current_ring_node_asm_norm_f1;
16
17 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
20 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
21
22 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
23
24 void reset_nb_sm_f1( unsigned char lfrMode )
25 {
26 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
27 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
28 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
29 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
30 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
31 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
32 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
33
34 if (lfrMode == LFR_MODE_SBM2)
35 {
36 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
37 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
38 }
39 else if (lfrMode == LFR_MODE_BURST)
40 {
41 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
42 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
43 }
44 else
45 {
46 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
47 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
48 }
49 }
50
51 //************
52 // RTEMS TASKS
53
54 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
55 {
56 int i;
57
58 rtems_event_set event_out;
59 rtems_status_code status;
60 rtems_id queue_id_prc1;
61 asm_msg msgForMATR;
62 ring_node_sm *ring_node_tab[8];
63
64 unsigned int nb_norm_bp1;
65 unsigned int nb_norm_bp2;
66 unsigned int nb_norm_asm;
67 unsigned int nb_sbm_bp1;
68 unsigned int nb_sbm_bp2;
69
70 nb_norm_bp1 = 0;
71 nb_norm_bp2 = 0;
72 nb_norm_asm = 0;
73 nb_sbm_bp1 = 0;
74 nb_sbm_bp2 = 0;
75
76 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
77 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
78 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
79 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
80 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
81
82 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
83
84 status = get_message_queue_id_prc1( &queue_id_prc1 );
85 if (status != RTEMS_SUCCESSFUL)
86 {
87 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
88 }
89
90 while(1){
91 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
92 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
93 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
94 {
95 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
96 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
97 }
98
99 // compute the average and store it in the averaged_sm_f1 buffer
100 SM_average( current_ring_node_asm_norm_f1->matrix,
101 current_ring_node_asm_burst_sbm_f1->matrix,
102 ring_node_tab,
103 nb_norm_bp1, nb_sbm_bp1 );
104
105 // update nb_average
106 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
107 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
108 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
109 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
110 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
111
112 //****************************************
113 // initialize the mesage for the MATR task
114 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
115 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
116 msgForMATR.norm = current_ring_node_asm_norm_f1;
117 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
118 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
119 msgForMATR.coarseTime = time_management_regs->coarse_time;
120 msgForMATR.fineTime = time_management_regs->fine_time;
121
122 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
123 {
124 nb_sbm_bp1 = 0;
125 // set another ring for the ASM storage
126 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
127 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
128 {
129 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1;
130 }
131 }
132
133 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
134 {
135 nb_sbm_bp2 = 0;
136 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
137 {
138 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1;
139 }
140 }
141
142 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
143 {
144 nb_norm_bp1 = 0;
145 // set another ring for the ASM storage
146 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
147 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
148 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
149 {
150 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
151 }
152 }
153
154 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
155 {
156 nb_norm_bp2 = 0;
157 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
158 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
159 {
160 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
161 }
162 }
163
164 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
165 {
166 nb_norm_asm = 0;
167 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
168 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
169 {
170 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
171 }
172 }
173
174 //*************************
175 // send the message to MATR
176 if (msgForMATR.event != 0x00)
177 {
178 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
179 }
180
181 if (status != RTEMS_SUCCESSFUL) {
182 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
183 }
184 }
185 }
186
187 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
188 {
189 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
190 size_t size; // size of the incoming TC packet
191 asm_msg *incomingMsg;
192 //
193 spw_ioctl_pkt_send spw_ioctl_send_ASM;
194 rtems_status_code status;
195 rtems_id queue_id_send;
196 rtems_id queue_id_q_p1;
197 Header_TM_LFR_SCIENCE_ASM_t headerASM;
198 bp_packet_with_spare packet_norm_bp1;
199 bp_packet packet_norm_bp2;
200 bp_packet packet_sbm_bp1;
201 bp_packet packet_sbm_bp2;
202
203 unsigned long long int localTime;
204
205 ASM_init_header( &headerASM );
206
207 //*************
208 // NORM headers
209 BP_init_header_with_spare( &packet_norm_bp1.header,
210 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
211 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
212 BP_init_header( &packet_norm_bp2.header,
213 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
214 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
215
216 //***********************
217 // BURST and SBM2 headers
218 if ( lfrRequestedMode == LFR_MODE_BURST )
219 {
220 BP_init_header( &packet_sbm_bp1.header,
221 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
222 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
223 BP_init_header( &packet_sbm_bp2.header,
224 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
225 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
226 }
227 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
228 {
229 BP_init_header( &packet_sbm_bp1.header,
230 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
232 BP_init_header( &packet_sbm_bp2.header,
233 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
234 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
235 }
236 else
237 {
238 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
239 }
240
241 status = get_message_queue_id_send( &queue_id_send );
242 if (status != RTEMS_SUCCESSFUL)
243 {
244 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
245 }
246 status = get_message_queue_id_prc1( &queue_id_q_p1);
247 if (status != RTEMS_SUCCESSFUL)
248 {
249 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
250 }
251
252 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
253
254 while(1){
255 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
256 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
257
258 incomingMsg = (asm_msg*) incomingData;
259
260 localTime = getTimeAsUnsignedLongLongInt( );
261 //***********
262 //***********
263 // BURST SBM2
264 //***********
265 //***********
266 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 )
267 {
268 // 1) compress the matrix for Basic Parameters calculation
269 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
270 nb_sm_before_f1.burst_sbm_bp1,
271 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
272 ASM_F1_INDICE_START);
273 // 2) compute the BP1 set
274
275 // 3) send the BP1 set
276 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
277 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
278 BP_send( (char *) &packet_sbm_bp1.header, queue_id_send,
279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA);
280 // 4) compute the BP2 set if needed
281 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 )
282 {
283 // 1) compute the BP2 set
284
285 // 2) send the BP2 set
286 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
287 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
288 BP_send( (char *) &packet_sbm_bp2.header, queue_id_send,
289 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA);
290 }
291 }
292
293 //*****
294 //*****
295 // NORM
296 //*****
297 //*****
298 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
299 {
300 // 1) compress the matrix for Basic Parameters calculation
301 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
302 nb_sm_before_f1.norm_bp1,
303 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
304 ASM_F0_INDICE_START );
305 // 2) compute the BP1 set
306
307 // 3) send the BP1 set
308 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
309 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
310 BP_send( (char *) &packet_norm_bp1.header, queue_id_send,
311 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA);
312 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
313 {
314 // 1) compute the BP2 set
315
316 // 2) send the BP2 set
317 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
318 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
319 BP_send( (char *) &packet_norm_bp2.header, queue_id_send,
320 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA);
321 }
322 }
323
324 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
325 {
326 // 1) reorganize the ASM and divide
327 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
328 asm_f1_reorganized,
329 nb_sm_before_f1.norm_bp1 );
330 // 2) convert the float array in a char array
331 ASM_convert( asm_f1_reorganized, asm_f1_char);
332 // 3) send the spectral matrix packets
333 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
334 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
335 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
336 }
337
338 }
339 }
@@ -0,0 +1,28
1 #ifndef AVF1_PRC1_H
2 #define AVF1_PRC1_H
3
4 #include "fsw_processing.h"
5
6 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
10 unsigned int burst_sbm_bp1;
11 unsigned int burst_sbm_bp2;
12 unsigned int burst_bp1;
13 unsigned int burst_bp2;
14 unsigned int sbm2_bp1;
15 unsigned int sbm2_bp2;
16 } nb_sm_before_bp_asm_f1;
17
18 extern struct ring_node_sm *current_ring_node_sm_f1;
19 extern struct ring_node_sm *ring_node_for_averaging_sm_f1;
20
21 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
22
23 void reset_nb_sm_f1( unsigned char lfrMode );
24
25 rtems_task avf1_task( rtems_task_argument lfrRequestedMode );
26 rtems_task prc1_task( rtems_task_argument lfrRequestedMode );
27
28 #endif // AVF1_PRC1_H
@@ -0,0 +1,240
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing at f2 = 256 Hz, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "avf2_prc2.h"
11
12 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
13 ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f2;
15 ring_node_asm *current_ring_node_asm_norm_f2;
16
17 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
20 float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ];
21
22 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
23
24 void reset_nb_sm_f2( void )
25 {
26 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
27 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
28 nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1];
29 }
30
31 void SM_average_f2( float *averaged_spec_mat_f2,
32 ring_node_sm *ring_node,
33 unsigned int nbAverageNormF2 )
34 {
35 float sum;
36 unsigned int i;
37
38 for(i=0; i<TOTAL_SIZE_SM; i++)
39 {
40 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
41 if ( (nbAverageNormF2 == 0) )
42 {
43 averaged_spec_mat_f2[ i ] = sum;
44 }
45 else
46 {
47 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
48 }
49 }
50 }
51
52 //************
53 // RTEMS TASKS
54
55 rtems_task avf2_task( rtems_task_argument lfrRequestedMode )
56 {
57 rtems_event_set event_out;
58 rtems_status_code status;
59 rtems_id queue_id_prc2;
60 asm_msg msgForMATR;
61
62 unsigned int nb_norm_bp1;
63 unsigned int nb_norm_bp2;
64 unsigned int nb_norm_asm;
65
66 nb_norm_bp1 = 0;
67 nb_norm_bp2 = 0;
68 nb_norm_asm = 0;
69
70 reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions
71
72 BOOT_PRINTF1("in AVF2 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
73
74 status = get_message_queue_id_prc2( &queue_id_prc2 );
75 if (status != RTEMS_SUCCESSFUL)
76 {
77 PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status)
78 }
79
80 while(1){
81 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
82
83 // compute the average and store it in the averaged_sm_f2 buffer
84 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
85 ring_node_for_averaging_sm_f2,
86 nb_norm_bp1 );
87
88 // update nb_average
89 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
90 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
91 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
92
93 //****************************************
94 // initialize the mesage for the MATR task
95 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
96 msgForMATR.burst_sbm = NULL;
97 msgForMATR.norm = current_ring_node_asm_norm_f2;
98 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
99 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
100 msgForMATR.coarseTime = time_management_regs->coarse_time;
101 msgForMATR.fineTime = time_management_regs->fine_time;
102
103 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
104 {
105 nb_norm_bp1 = 0;
106 // set another ring for the ASM storage
107 current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next;
108 if ( lfrCurrentMode == LFR_MODE_NORMAL )
109 {
110 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
111 }
112 }
113
114 if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2)
115 {
116 nb_norm_bp2 = 0;
117 if ( lfrCurrentMode == LFR_MODE_NORMAL )
118 {
119 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2;
120 }
121 }
122
123 if (nb_norm_asm == nb_sm_before_f2.norm_asm)
124 {
125 nb_norm_asm = 0;
126 if ( lfrCurrentMode == LFR_MODE_NORMAL )
127 {
128 // PRINTF1("%lld\n", localTime)
129 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
130 }
131 }
132
133 //*************************
134 // send the message to MATR
135 if (msgForMATR.event != 0x00)
136 {
137 status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
138 }
139
140 if (status != RTEMS_SUCCESSFUL) {
141 printf("in AVF2 *** Error sending message to MATR, code %d\n", status);
142 }
143 }
144 }
145
146 rtems_task prc2_task( rtems_task_argument argument )
147 {
148 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
149 size_t size; // size of the incoming TC packet
150 asm_msg *incomingMsg;
151 //
152 spw_ioctl_pkt_send spw_ioctl_send_ASM;
153 rtems_status_code status;
154 rtems_id queue_id;
155 rtems_id queue_id_q_p2;
156 Header_TM_LFR_SCIENCE_ASM_t headerASM;
157 bp_packet packet_norm_bp1_f2;
158 bp_packet packet_norm_bp2_f2;
159
160 unsigned long long int localTime;
161
162 ASM_init_header( &headerASM );
163
164 //*************
165 // NORM headers
166 BP_init_header( &packet_norm_bp1_f2.header,
167 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
168 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
169 BP_init_header( &packet_norm_bp2_f2.header,
170 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
171 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
172
173 status = get_message_queue_id_send( &queue_id );
174 if (status != RTEMS_SUCCESSFUL)
175 {
176 PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status)
177 }
178 status = get_message_queue_id_prc2( &queue_id_q_p2);
179 if (status != RTEMS_SUCCESSFUL)
180 {
181 PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status)
182 }
183
184 BOOT_PRINTF("in PRC2 ***\n")
185
186 while(1){
187 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
188 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
189
190 incomingMsg = (asm_msg*) incomingData;
191
192 localTime = getTimeAsUnsignedLongLongInt( );
193
194 //*****
195 //*****
196 // NORM
197 //*****
198 //*****
199 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
200 {
201 // 1) compress the matrix for Basic Parameters calculation
202 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2,
203 nb_sm_before_f2.norm_bp1,
204 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
205 ASM_F2_INDICE_START );
206 // 2) compute the BP1 set
207
208 // 3) send the BP1 set
209 set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
210 set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
211 BP_send( (char *) &packet_norm_bp1_f2.header, queue_id,
212 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA);
213 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
214 {
215 // 1) compute the BP2 set using the same ASM as the one used for BP1
216
217 // 2) send the BP2 set
218 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
219 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
220 BP_send( (char *) &packet_norm_bp2_f2.header, queue_id,
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA);
222 }
223 }
224
225 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
226 {
227 // 1) reorganize the ASM and divide
228 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
229 asm_f2_reorganized,
230 nb_sm_before_f2.norm_bp1 );
231 // 2) convert the float array in a char array
232 ASM_convert( asm_f2_reorganized, asm_f2_char);
233 // 3) send the spectral matrix packets
234 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
235 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
236 ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id);
237 }
238
239 }
240 }
@@ -0,0 +1,24
1 #ifndef AVF2_PRC2_H
2 #define AVF2_PRC2_H
3
4 #include "fsw_processing.h"
5
6 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
10 } nb_sm_before_bp_asm_f2;
11
12 extern struct ring_node_sm *current_ring_node_sm_f2;
13 extern struct ring_node_sm *ring_node_for_averaging_sm_f2;
14
15 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
16
17 void reset_nb_sm_f2(void );
18 void SM_average_f2( float *averaged_spec_mat_f2, ring_node_sm *ring_node, unsigned int nbAverageNormF2 );
19
20 // RTEMS TASKS
21 rtems_task avf2_task( rtems_task_argument lfrRequestedMode );
22 rtems_task prc2_task(rtems_task_argument argument );
23
24 #endif // AVF2_PRC2_H
This diff has been collapsed as it changes many lines, (570 lines changed) Show them Hide them
@@ -0,0 +1,570
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "fsw_processing.h"
11 #include "fsw_processing_globals.c"
12
13 unsigned int nb_sm_f0;
14 unsigned int nb_sm_f0_aux_f1;
15 unsigned int nb_sm_f1;
16 unsigned int nb_sm_f0_aux_f2;
17
18 //************************
19 // spectral matrices rings
20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
23 ring_node_sm *current_ring_node_sm_f0;
24 ring_node_sm *current_ring_node_sm_f1;
25 ring_node_sm *current_ring_node_sm_f2;
26 ring_node_sm *ring_node_for_averaging_sm_f0;
27 ring_node_sm *ring_node_for_averaging_sm_f1;
28 ring_node_sm *ring_node_for_averaging_sm_f2;
29
30 //***********************************************************
31 // Interrupt Service Routine for spectral matrices processing
32
33 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
34 {
35 ring_node_sm *previous_ring_node_sm_f0;
36
37 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
38
39 previous_ring_node_sm_f0 = current_ring_node_sm_f0;
40
41 if ( (spectral_matrix_regs->status & 0x2) == 0x02) // check ready matrix bit f0_1
42 {
43 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
44 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
45 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
46 nb_sm_f0 = nb_sm_f0 + 1;
47 }
48
49 //************************
50 // reset status error bits
51 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
52 {
53 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
54 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
55 }
56
57 //**************************************
58 // reset ready matrix bits for f0_0, f1 and f2
59 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff2; // 0010
60
61 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
62 {
63 ring_node_for_averaging_sm_f0 = previous_ring_node_sm_f0;
64 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
65 {
66 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
67 }
68 nb_sm_f0 = 0;
69 }
70
71 }
72
73 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
74 {
75 //***
76 // F0
77 nb_sm_f0 = nb_sm_f0 + 1;
78 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
79 {
80 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
81 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
82 {
83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
84 }
85 nb_sm_f0 = 0;
86 }
87
88 //***
89 // F1
90 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
91 if (nb_sm_f0_aux_f1 == 6)
92 {
93 nb_sm_f0_aux_f1 = 0;
94 nb_sm_f1 = nb_sm_f1 + 1;
95 }
96 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
97 {
98 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
99 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
100 {
101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
102 }
103 nb_sm_f1 = 0;
104 }
105
106 //***
107 // F2
108 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
109 if (nb_sm_f0_aux_f2 == 96)
110 {
111 nb_sm_f0_aux_f2 = 0;
112 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
113 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
114 {
115 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
116 }
117 }
118 }
119
120 //******************
121 // Spectral Matrices
122
123 void reset_nb_sm( void )
124 {
125 nb_sm_f0 = 0;
126 nb_sm_f0_aux_f1 = 0;
127 nb_sm_f0_aux_f2 = 0;
128
129 nb_sm_f1 = 0;
130 }
131
132 void SM_init_rings( void )
133 {
134 unsigned char i;
135
136 // F0 RING
137 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
138 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
139 sm_ring_f0[0].buffer_address =
140 (int) &sm_f0[ 0 ];
141
142 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
143 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
144 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
145 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
146
147 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
148 {
149 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
150 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
151 sm_ring_f0[i].buffer_address =
152 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
153 }
154
155 // F1 RING
156 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
157 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
158 sm_ring_f1[0].buffer_address =
159 (int) &sm_f1[ 0 ];
160
161 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
162 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
163 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
164 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
165
166 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
167 {
168 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
169 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
170 sm_ring_f1[i].buffer_address =
171 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
172 }
173
174 // F2 RING
175 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
176 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
177 sm_ring_f2[0].buffer_address =
178 (int) &sm_f2[ 0 ];
179
180 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
181 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
182 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
183 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
184
185 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
186 {
187 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
188 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
189 sm_ring_f2[i].buffer_address =
190 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
191 }
192
193 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
194 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
195 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
196
197 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
198 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
199 }
200
201 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
202 {
203 unsigned char i;
204
205 ring[ nbNodes - 1 ].next
206 = (ring_node_asm*) &ring[ 0 ];
207
208 for(i=0; i<nbNodes-1; i++)
209 {
210 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
211 }
212 }
213
214 void SM_reset_current_ring_nodes( void )
215 {
216 current_ring_node_sm_f0 = sm_ring_f0;
217 current_ring_node_sm_f1 = sm_ring_f1;
218 current_ring_node_sm_f2 = sm_ring_f2;
219
220 ring_node_for_averaging_sm_f0 = sm_ring_f0;
221 }
222
223 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
224 {
225 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
226 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
227 header->reserved = 0x00;
228 header->userApplication = CCSDS_USER_APP;
229 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
230 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
231 header->packetSequenceControl[0] = 0xc0;
232 header->packetSequenceControl[1] = 0x00;
233 header->packetLength[0] = 0x00;
234 header->packetLength[1] = 0x00;
235 // DATA FIELD HEADER
236 header->spare1_pusVersion_spare2 = 0x10;
237 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
238 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
239 header->destinationID = TM_DESTINATION_ID_GROUND;
240 // AUXILIARY DATA HEADER
241 header->sid = 0x00;
242 header->biaStatusInfo = 0x00;
243 header->pa_lfr_pkt_cnt_asm = 0x00;
244 header->pa_lfr_pkt_nr_asm = 0x00;
245 header->time[0] = 0x00;
246 header->time[0] = 0x00;
247 header->time[0] = 0x00;
248 header->time[0] = 0x00;
249 header->time[0] = 0x00;
250 header->time[0] = 0x00;
251 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
252 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
253 }
254
255 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
256 ring_node_sm *ring_node_tab[],
257 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
258 {
259 float sum;
260 unsigned int i;
261
262 for(i=0; i<TOTAL_SIZE_SM; i++)
263 {
264 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
265 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
266 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
267 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
268 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
269 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
270 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
271 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
272
273 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
274 {
275 averaged_spec_mat_f0[ i ] = sum;
276 averaged_spec_mat_f1[ i ] = sum;
277 }
278 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
279 {
280 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
281 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
282 }
283 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
284 {
285 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
286 averaged_spec_mat_f1[ i ] = sum;
287 }
288 else
289 {
290 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
291 }
292 }
293 }
294
295 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
296 {
297 int frequencyBin;
298 int asmComponent;
299 unsigned int offsetAveragedSpecMatReorganized;
300 unsigned int offsetAveragedSpecMat;
301
302 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
303 {
304 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
305 {
306 offsetAveragedSpecMatReorganized =
307 frequencyBin * NB_VALUES_PER_SM
308 + asmComponent;
309 offsetAveragedSpecMat =
310 asmComponent * NB_BINS_PER_SM
311 + frequencyBin;
312 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
313 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
314 }
315 }
316 }
317
318 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
319 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
320 {
321 int frequencyBin;
322 int asmComponent;
323 int offsetASM;
324 int offsetCompressed;
325 int k;
326
327 // build data
328 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
329 {
330 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
331 {
332 offsetCompressed = // NO TIME OFFSET
333 frequencyBin * NB_VALUES_PER_SM
334 + asmComponent;
335 offsetASM = // NO TIME OFFSET
336 asmComponent * NB_BINS_PER_SM
337 + ASMIndexStart
338 + frequencyBin * nbBinsToAverage;
339 compressed_spec_mat[ offsetCompressed ] = 0;
340 for ( k = 0; k < nbBinsToAverage; k++ )
341 {
342 compressed_spec_mat[offsetCompressed ] =
343 ( compressed_spec_mat[ offsetCompressed ]
344 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
345 }
346 }
347 }
348 }
349
350 void ASM_convert( volatile float *input_matrix, char *output_matrix)
351 {
352 unsigned int frequencyBin;
353 unsigned int asmComponent;
354 char * pt_char_input;
355 char * pt_char_output;
356 unsigned int offsetInput;
357 unsigned int offsetOutput;
358
359 pt_char_input = (char*) &input_matrix;
360 pt_char_output = (char*) &output_matrix;
361
362 // convert all other data
363 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
364 {
365 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
366 {
367 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
368 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
369 pt_char_input = (char*) &input_matrix [ offsetInput ];
370 pt_char_output = (char*) &output_matrix[ offsetOutput ];
371 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
372 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
373 }
374 }
375 }
376
377 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
378 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
379 {
380 unsigned int i;
381 unsigned int length = 0;
382 rtems_status_code status;
383
384 for (i=0; i<2; i++)
385 {
386 // (1) BUILD THE DATA
387 switch(sid)
388 {
389 case SID_NORM_ASM_F0:
390 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
391 spw_ioctl_send->data = &spectral_matrix[
392 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
393 ];
394 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
395 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
396 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
397 break;
398 case SID_NORM_ASM_F1:
399 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
400 spw_ioctl_send->data = &spectral_matrix[
401 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
402 ];
403 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
404 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
405 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
406 break;
407 case SID_NORM_ASM_F2:
408 break;
409 default:
410 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
411 break;
412 }
413 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
414 spw_ioctl_send->hdr = (char *) header;
415 spw_ioctl_send->options = 0;
416
417 // (2) BUILD THE HEADER
418 header->packetLength[0] = (unsigned char) (length>>8);
419 header->packetLength[1] = (unsigned char) (length);
420 header->sid = (unsigned char) sid; // SID
421 header->pa_lfr_pkt_cnt_asm = 2;
422 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
423
424 // (3) SET PACKET TIME
425 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
426 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
427 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
428 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
429 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
430 header->time[5] = (unsigned char) (time_management_regs->fine_time);
431 //
432 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
433 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
434 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
435 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
436 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
437 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
438
439 // (4) SEND PACKET
440 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
441 if (status != RTEMS_SUCCESSFUL) {
442 printf("in ASM_send *** ERR %d\n", (int) status);
443 }
444 }
445 }
446
447 //*****************
448 // Basic Parameters
449
450 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
451 unsigned int apid, unsigned char sid,
452 unsigned int packetLength, unsigned char blkNr )
453 {
454 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
455 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
456 header->reserved = 0x00;
457 header->userApplication = CCSDS_USER_APP;
458 header->packetID[0] = (unsigned char) (apid >> 8);
459 header->packetID[1] = (unsigned char) (apid);
460 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
461 header->packetSequenceControl[1] = 0x00;
462 header->packetLength[0] = (unsigned char) (packetLength >> 8);
463 header->packetLength[1] = (unsigned char) (packetLength);
464 // DATA FIELD HEADER
465 header->spare1_pusVersion_spare2 = 0x10;
466 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
467 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
468 header->destinationID = TM_DESTINATION_ID_GROUND;
469 // AUXILIARY DATA HEADER
470 header->sid = sid;
471 header->biaStatusInfo = 0x00;
472 header->time[0] = 0x00;
473 header->time[0] = 0x00;
474 header->time[0] = 0x00;
475 header->time[0] = 0x00;
476 header->time[0] = 0x00;
477 header->time[0] = 0x00;
478 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
479 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
480 }
481
482 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
483 unsigned int apid, unsigned char sid,
484 unsigned int packetLength , unsigned char blkNr)
485 {
486 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
487 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
488 header->reserved = 0x00;
489 header->userApplication = CCSDS_USER_APP;
490 header->packetID[0] = (unsigned char) (apid >> 8);
491 header->packetID[1] = (unsigned char) (apid);
492 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
493 header->packetSequenceControl[1] = 0x00;
494 header->packetLength[0] = (unsigned char) (packetLength >> 8);
495 header->packetLength[1] = (unsigned char) (packetLength);
496 // DATA FIELD HEADER
497 header->spare1_pusVersion_spare2 = 0x10;
498 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
499 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
500 header->destinationID = TM_DESTINATION_ID_GROUND;
501 // AUXILIARY DATA HEADER
502 header->sid = sid;
503 header->biaStatusInfo = 0x00;
504 header->time[0] = 0x00;
505 header->time[0] = 0x00;
506 header->time[0] = 0x00;
507 header->time[0] = 0x00;
508 header->time[0] = 0x00;
509 header->time[0] = 0x00;
510 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
511 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
512 }
513
514 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
515 {
516 rtems_status_code status;
517
518 // SEND PACKET
519 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
520 if (status != RTEMS_SUCCESSFUL)
521 {
522 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
523 }
524 }
525
526 //******************
527 // general functions
528
529 void reset_spectral_matrix_regs( void )
530 {
531 /** This function resets the spectral matrices module registers.
532 *
533 * The registers affected by this function are located at the following offset addresses:
534 *
535 * - 0x00 config
536 * - 0x04 status
537 * - 0x08 matrixF0_Address0
538 * - 0x10 matrixFO_Address1
539 * - 0x14 matrixF1_Address
540 * - 0x18 matrixF2_Address
541 *
542 */
543
544 spectral_matrix_regs->config = 0x00;
545 spectral_matrix_regs->status = 0x00;
546
547 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
548 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
549 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
550 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
551 }
552
553 void set_time( unsigned char *time, unsigned char * timeInBuffer )
554 {
555 // time[0] = timeInBuffer[2];
556 // time[1] = timeInBuffer[3];
557 // time[2] = timeInBuffer[0];
558 // time[3] = timeInBuffer[1];
559 // time[4] = timeInBuffer[6];
560 // time[5] = timeInBuffer[7];
561
562 time[0] = timeInBuffer[0];
563 time[1] = timeInBuffer[1];
564 time[2] = timeInBuffer[2];
565 time[3] = timeInBuffer[3];
566 time[4] = timeInBuffer[6];
567 time[5] = timeInBuffer[7];
568 }
569
570
@@ -0,0 +1,108
1 #ifndef FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
3
4 #include <rtems.h>
5 #include <grspw.h>
6 #include <math.h>
7 #include <stdlib.h> // abs() is in the stdlib
8 #include <stdio.h> // printf()
9 #include <math.h>
10
11 #include "fsw_params.h"
12 #include "fsw_spacewire.h"
13
14 typedef struct ring_node_sm
15 {
16 struct ring_node_sm *previous;
17 struct ring_node_sm *next;
18 int buffer_address;
19 unsigned int status;
20 unsigned int coarseTime;
21 unsigned int fineTime;
22 } ring_node_sm;
23
24 typedef struct ring_node_asm
25 {
26 struct ring_node_asm *next;
27 float matrix[ TOTAL_SIZE_SM ];
28 unsigned int status;
29 } ring_node_asm;
30
31 typedef struct bp_packet
32 {
33 Header_TM_LFR_SCIENCE_BP_t header;
34 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
35 } bp_packet;
36
37 typedef struct bp_packet_with_spare
38 {
39 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
40 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
41 } bp_packet_with_spare;
42
43 typedef struct asm_msg
44 {
45 ring_node_asm *norm;
46 ring_node_asm *burst_sbm;
47 rtems_event_set event;
48 unsigned int coarseTime;
49 unsigned int fineTime;
50 } asm_msg;
51
52 extern volatile int sm_f0[ ];
53 extern volatile int sm_f1[ ];
54 extern volatile int sm_f2[ ];
55
56 // parameters
57 extern struct param_local_str param_local;
58
59 // registers
60 extern time_management_regs_t *time_management_regs;
61 extern spectral_matrix_regs_t *spectral_matrix_regs;
62
63 extern rtems_name misc_name[5];
64 extern rtems_id Task_id[20]; /* array of task ids */
65
66 // ISR
67 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
68 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
69
70 //******************
71 // Spectral Matrices
72 void reset_nb_sm( void );
73 void SM_init_rings( void );
74 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
75 void SM_reset_current_ring_nodes( void );
76 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
77 void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
78 ring_node_sm *ring_node_tab[],
79 unsigned int firstTimeF0, unsigned int firstTimeF1 );
80 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
81 float divider );
82 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
83 float divider,
84 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
85 void ASM_convert(volatile float *input_matrix, char *output_matrix);
86 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
87 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
88
89 //*****************
90 // Basic Parameters
91
92 void BP_reset_current_ring_nodes( void );
93 void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header,
94 unsigned int apid, unsigned char sid,
95 unsigned int packetLength , unsigned char blkNr);
96 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
97 unsigned int apid, unsigned char sid,
98 unsigned int packetLength, unsigned char blkNr );
99 void BP_send(char *data,
100 rtems_id queue_id ,
101 unsigned int nbBytesToSend );
102
103 //******************
104 // general functions
105 void reset_spectral_matrix_regs( void );
106 void set_time(unsigned char *time, unsigned char *timeInBuffer );
107
108 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,253 +1,271
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Apr 24 22:14:00 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Sun Apr 27 14:59:58 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS -DBOOT_MESSAGES
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/basic_parameters
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/basic_parameters -I../src/avf_prc
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 ../src/fsw_processing.c \
49 48 ../src/fsw_misc.c \
50 49 ../src/fsw_init.c \
51 50 ../src/fsw_globals.c \
52 51 ../src/fsw_spacewire.c \
53 52 ../src/tc_load_dump_parameters.c \
54 53 ../src/tm_lfr_tc_exe.c \
55 54 ../src/tc_acceptance.c \
56 ../src/basic_parameters/basic_parameters.c
55 ../src/basic_parameters/basic_parameters.c \
56 ../src/avf_prc/fsw_processing.c \
57 ../src/avf_prc/avf0_prc0.c \
58 ../src/avf_prc/avf1_prc1.c \
59 ../src/avf_prc/avf2_prc2.c
57 60 OBJECTS = obj/wf_handler.o \
58 61 obj/tc_handler.o \
59 obj/fsw_processing.o \
60 62 obj/fsw_misc.o \
61 63 obj/fsw_init.o \
62 64 obj/fsw_globals.o \
63 65 obj/fsw_spacewire.o \
64 66 obj/tc_load_dump_parameters.o \
65 67 obj/tm_lfr_tc_exe.o \
66 68 obj/tc_acceptance.o \
67 obj/basic_parameters.o
69 obj/basic_parameters.o \
70 obj/fsw_processing.o \
71 obj/avf0_prc0.o \
72 obj/avf1_prc1.o \
73 obj/avf2_prc2.o
68 74 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
69 75 /usr/lib64/qt4/mkspecs/common/linux.conf \
70 76 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
71 77 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
72 78 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
73 79 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
74 80 /usr/lib64/qt4/mkspecs/qconfig.pri \
75 81 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
76 82 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
77 83 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
78 84 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
79 85 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
80 86 sparc.pri \
81 87 /usr/lib64/qt4/mkspecs/features/release.prf \
82 88 /usr/lib64/qt4/mkspecs/features/default_post.prf \
83 89 /usr/lib64/qt4/mkspecs/features/shared.prf \
84 90 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
85 91 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
86 92 /usr/lib64/qt4/mkspecs/features/resources.prf \
87 93 /usr/lib64/qt4/mkspecs/features/uic.prf \
88 94 /usr/lib64/qt4/mkspecs/features/yacc.prf \
89 95 /usr/lib64/qt4/mkspecs/features/lex.prf \
90 96 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
91 97 fsw-qt.pro
92 98 QMAKE_TARGET = fsw
93 99 DESTDIR = bin/
94 100 TARGET = bin/fsw
95 101
96 102 first: all
97 103 ####### Implicit rules
98 104
99 105 .SUFFIXES: .o .c .cpp .cc .cxx .C
100 106
101 107 .cpp.o:
102 108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
103 109
104 110 .cc.o:
105 111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
106 112
107 113 .cxx.o:
108 114 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
109 115
110 116 .C.o:
111 117 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
112 118
113 119 .c.o:
114 120 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
115 121
116 122 ####### Build rules
117 123
118 124 all: Makefile $(TARGET)
119 125
120 126 $(TARGET): $(OBJECTS)
121 127 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
122 128 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
123 129
124 130 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
125 131 /usr/lib64/qt4/mkspecs/common/linux.conf \
126 132 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
127 133 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
128 134 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
129 135 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
130 136 /usr/lib64/qt4/mkspecs/qconfig.pri \
131 137 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
132 138 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
133 139 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
134 140 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
135 141 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
136 142 sparc.pri \
137 143 /usr/lib64/qt4/mkspecs/features/release.prf \
138 144 /usr/lib64/qt4/mkspecs/features/default_post.prf \
139 145 /usr/lib64/qt4/mkspecs/features/shared.prf \
140 146 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
141 147 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
142 148 /usr/lib64/qt4/mkspecs/features/resources.prf \
143 149 /usr/lib64/qt4/mkspecs/features/uic.prf \
144 150 /usr/lib64/qt4/mkspecs/features/yacc.prf \
145 151 /usr/lib64/qt4/mkspecs/features/lex.prf \
146 152 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
147 153 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
148 154 /usr/lib64/qt4/mkspecs/common/unix.conf:
149 155 /usr/lib64/qt4/mkspecs/common/linux.conf:
150 156 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
151 157 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
152 158 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
153 159 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
154 160 /usr/lib64/qt4/mkspecs/qconfig.pri:
155 161 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
156 162 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
157 163 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
158 164 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
159 165 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
160 166 sparc.pri:
161 167 /usr/lib64/qt4/mkspecs/features/release.prf:
162 168 /usr/lib64/qt4/mkspecs/features/default_post.prf:
163 169 /usr/lib64/qt4/mkspecs/features/shared.prf:
164 170 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
165 171 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
166 172 /usr/lib64/qt4/mkspecs/features/resources.prf:
167 173 /usr/lib64/qt4/mkspecs/features/uic.prf:
168 174 /usr/lib64/qt4/mkspecs/features/yacc.prf:
169 175 /usr/lib64/qt4/mkspecs/features/lex.prf:
170 176 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
171 177 qmake: FORCE
172 178 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
173 179
174 180 dist:
175 181 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
176 182 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
177 183
178 184
179 185 clean:compiler_clean
180 186 -$(DEL_FILE) $(OBJECTS)
181 187 -$(DEL_FILE) *~ core *.core
182 188
183 189
184 190 ####### Sub-libraries
185 191
186 192 distclean: clean
187 193 -$(DEL_FILE) $(TARGET)
188 194 -$(DEL_FILE) Makefile
189 195
190 196
191 197 grmon:
192 198 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
193 199
194 200 check: first
195 201
196 202 compiler_rcc_make_all:
197 203 compiler_rcc_clean:
198 204 compiler_uic_make_all:
199 205 compiler_uic_clean:
200 206 compiler_image_collection_make_all: qmake_image_collection.cpp
201 207 compiler_image_collection_clean:
202 208 -$(DEL_FILE) qmake_image_collection.cpp
203 209 compiler_yacc_decl_make_all:
204 210 compiler_yacc_decl_clean:
205 211 compiler_yacc_impl_make_all:
206 212 compiler_yacc_impl_clean:
207 213 compiler_lex_make_all:
208 214 compiler_lex_clean:
209 215 compiler_clean:
210 216
211 217 ####### Compile
212 218
213 219 obj/wf_handler.o: ../src/wf_handler.c
214 220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
215 221
216 222 obj/tc_handler.o: ../src/tc_handler.c
217 223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
218 224
219 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
221
222 225 obj/fsw_misc.o: ../src/fsw_misc.c
223 226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
224 227
225 228 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
226 229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
227 230
228 231 obj/fsw_globals.o: ../src/fsw_globals.c
229 232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
230 233
231 234 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
232 235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
233 236
234 237 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
235 238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
236 239
237 240 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
238 241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
239 242
240 243 obj/tc_acceptance.o: ../src/tc_acceptance.c
241 244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
242 245
243 246 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
244 247 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
245 248
249 obj/fsw_processing.o: ../src/avf_prc/fsw_processing.c ../src/avf_prc/fsw_processing.h
250 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/avf_prc/fsw_processing.c
251
252 obj/avf0_prc0.o: ../src/avf_prc/avf0_prc0.c ../src/avf_prc/avf0_prc0.h \
253 ../src/avf_prc/fsw_processing.h
254 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/avf_prc/avf0_prc0.c
255
256 obj/avf1_prc1.o: ../src/avf_prc/avf1_prc1.c ../src/avf_prc/avf1_prc1.h \
257 ../src/avf_prc/fsw_processing.h
258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/avf_prc/avf1_prc1.c
259
260 obj/avf2_prc2.o: ../src/avf_prc/avf2_prc2.c ../src/avf_prc/avf2_prc2.h \
261 ../src/avf_prc/fsw_processing.h
262 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/avf_prc/avf2_prc2.c
263
246 264 ####### Install
247 265
248 266 install: FORCE
249 267
250 268 uninstall: FORCE
251 269
252 270 FORCE:
253 271
@@ -1,85 +1,92
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 4 CONFIG += console verbose cpu_usage_report boot_messages
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 10 SWVERSION=-1-0
11 11 DEFINES += SW_VERSION_N1=1 # major
12 12 DEFINES += SW_VERSION_N2=0 # minor
13 13 DEFINES += SW_VERSION_N3=0 # patch
14 14 DEFINES += SW_VERSION_N4=6 # internal
15 15
16 16 contains( CONFIG, debug_tch ) {
17 17 DEFINES += DEBUG_TCH
18 18 }
19 19
20 20 contains( CONFIG, vhdl_dev ) {
21 21 DEFINES += VHDL_DEV
22 22 }
23 23
24 24 contains( CONFIG, verbose ) {
25 25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
26 26 }
27 27
28 28 contains( CONFIG, debug_messages ) {
29 29 DEFINES += DEBUG_MESSAGES
30 30 }
31 31
32 32 contains( CONFIG, cpu_usage_report ) {
33 33 DEFINES += PRINT_TASK_STATISTICS
34 34 }
35 35
36 36 contains( CONFIG, stack_report ) {
37 37 DEFINES += PRINT_STACK_REPORT
38 38 }
39 39
40 40 contains( CONFIG, boot_messages ) {
41 41 DEFINES += BOOT_MESSAGES
42 42 }
43 43
44 44 #doxygen.target = doxygen
45 45 #doxygen.commands = doxygen ../doc/Doxyfile
46 46 #QMAKE_EXTRA_TARGETS += doxygen
47 47
48 48 TARGET = fsw
49 49
50 50 INCLUDEPATH += \
51 51 ../src \
52 52 ../header \
53 ../src/basic_parameters
53 ../src/basic_parameters \
54 ../src/avf_prc
54 55
55 56 SOURCES += \
56 57 ../src/wf_handler.c \
57 58 ../src/tc_handler.c \
58 ../src/fsw_processing.c \
59 59 ../src/fsw_misc.c \
60 60 ../src/fsw_init.c \
61 61 ../src/fsw_globals.c \
62 62 ../src/fsw_spacewire.c \
63 63 ../src/tc_load_dump_parameters.c \
64 64 ../src/tm_lfr_tc_exe.c \
65 65 ../src/tc_acceptance.c \
66 ../src/basic_parameters/basic_parameters.c
66 ../src/basic_parameters/basic_parameters.c \
67 ../src/avf_prc/fsw_processing.c \
68 ../src/avf_prc/avf0_prc0.c \
69 ../src/avf_prc/avf1_prc1.c \
70 ../src/avf_prc/avf2_prc2.c
67 71
68 72
69 73 HEADERS += \
70 74 ../header/wf_handler.h \
71 75 ../header/tc_handler.h \
72 76 ../header/grlib_regs.h \
73 ../header/fsw_processing.h \
74 77 ../header/fsw_params.h \
75 78 ../header/fsw_misc.h \
76 79 ../header/fsw_init.h \
77 80 ../header/ccsds_types.h \
78 81 ../header/fsw_params_processing.h \
79 82 ../header/fsw_spacewire.h \
80 83 ../header/tc_load_dump_parameters.h \
81 84 ../header/tm_lfr_tc_exe.h \
82 85 ../header/tc_acceptance.h \
83 86 ../header/fsw_params_nb_bytes.h \
84 ../src/basic_parameters/basic_parameters.h
87 ../src/basic_parameters/basic_parameters.h \
88 ../src/avf_prc/fsw_processing.h \
89 ../src/avf_prc/avf0_prc0.h \
90 ../src/avf_prc/avf1_prc1.h \
91 ../src/avf_prc/avf2_prc2.h
85 92
@@ -1,201 +1,201
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-24T22:30:22. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-27T15:09:47. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29 29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 45 </valuemap>
46 46 </data>
47 47 <data>
48 48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 49 <valuemap type="QVariantMap"/>
50 50 </data>
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
55 55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
56 56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{be73cf6a-f9d8-4d5a-8adf-adc2d83e2e44}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
70 70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 72 </valuemap>
73 73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 79 <value type="QString">-w</value>
80 80 <value type="QString">-r</value>
81 81 </valuelist>
82 82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84 84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 85 </valuemap>
86 86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 90 </valuemap>
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 98 <value type="QString">-w</value>
99 99 <value type="QString">-r</value>
100 100 </valuelist>
101 101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103 103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 104 </valuemap>
105 105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 109 </valuemap>
110 110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118 118 </valuemap>
119 119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
126 126 </valuemap>
127 127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
128 128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
129 129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
131 131 </valuemap>
132 132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
133 133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
134 134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
135 135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
136 136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
137 137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
138 138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
139 139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
140 140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
141 141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
142 142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
143 143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
144 144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
145 145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
146 146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
147 147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
148 148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
149 149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
150 150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
151 151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
152 152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
153 153 <value type="int">0</value>
154 154 <value type="int">1</value>
155 155 <value type="int">2</value>
156 156 <value type="int">3</value>
157 157 <value type="int">4</value>
158 158 <value type="int">5</value>
159 159 <value type="int">6</value>
160 160 <value type="int">7</value>
161 161 <value type="int">8</value>
162 162 <value type="int">9</value>
163 163 <value type="int">10</value>
164 164 <value type="int">11</value>
165 165 <value type="int">12</value>
166 166 <value type="int">13</value>
167 167 <value type="int">14</value>
168 168 </valuelist>
169 169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
170 170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
174 174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
177 177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
178 178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
179 179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
180 180 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
181 181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
182 182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
183 183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
184 184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
187 187 </valuemap>
188 188 </data>
189 189 <data>
190 190 <variable>ProjectExplorer.Project.TargetCount</variable>
191 191 <value type="int">1</value>
192 192 </data>
193 193 <data>
194 194 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
195 195 <value type="QByteArray">{cdbf9cdc-1e84-406e-889b-c4feef49e75c}</value>
196 196 </data>
197 197 <data>
198 198 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
199 199 <value type="int">15</value>
200 200 </data>
201 201 </qtcreator>
@@ -1,663 +1,665
1 1 #ifndef CCSDS_TYPES_H_INCLUDED
2 2 #define CCSDS_TYPES_H_INCLUDED
3 3
4 4 #include "fsw_params_processing.h"
5 5
6 6 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
7 7 #define CCSDS_TC_TM_PACKET_OFFSET 7
8 8 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
9 9 #define CCSDS_TM_PKT_MAX_SIZE 4412
10 10 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
11 11 #define CCSDS_TC_PKT_MAX_SIZE 256
12 12 #define CCSDS_TC_PKT_MIN_SIZE 16
13 13 #define CCSDS_PROCESS_ID 76
14 14 #define CCSDS_PACKET_CATEGORY 12
15 15 #define CCSDS_NODE_ADDRESS 0xfe
16 16 #define CCSDS_USER_APP 0x00
17 17
18 18 #define DEFAULT_SPARE1_PUSVERSION_SPARE2 0x10
19 19 #define DEFAULT_RESERVED 0x00
20 20 #define DEFAULT_HKBIA 0x1e // 0001 1110
21 21
22 22 // PACKET ID
23 23 #define APID_TM_TC_EXE 0x0cc1 // PID 76 CAT 1
24 24 #define APID_TM_HK 0x0cc4 // PID 76 CAT 4
25 25 #define APID_TM_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
26 26 #define APID_TM_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
27 27 #define APID_TM_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
28 28 #define TM_PACKET_PID_DEFAULT 76
29 29 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
30 30 #define TM_PACKET_CAT_TC_EXE 1
31 31 #define TM_PACKET_CAT_HK 4
32 32 #define TM_PACKET_CAT_PARAMETER_DUMP 9
33 33 #define TM_PACKET_CAT_SCIENCE 12
34 34 #define TC_PACKET_CAT 12
35 35
36 36 // PACKET SEQUENCE CONTROL
37 37 #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000]
38 38 #define TM_PACKET_SEQ_CTRL_FIRST 0x40 // [0100 0000]
39 39 #define TM_PACKET_SEQ_CTRL_LAST 0x80 // [1000 0000]
40 40 #define TM_PACKET_SEQ_CTRL_STANDALONE 0xc0 // [1100 0000]
41 41 #define TM_PACKET_SEQ_CNT_DEFAULT 0x00 // [0000 0000]
42 42
43 43 // DESTINATION ID
44 44 #define TM_DESTINATION_ID_GROUND 0
45 45 #define TM_DESTINATION_ID_MISSION_TIMELINE 110
46 46 #define TM_DESTINATION_ID_TC_SEQUENCES 111
47 47 #define TM_DESTINATION_ID_RECOVERY_ACTION_COMMAND 112
48 48 #define TM_DESTINATION_ID_BACKUP_MISSION_TIMELINE 113
49 49 #define TM_DESTINATION_ID_DIRECT_CMD 120
50 50 #define TM_DESTINATION_ID_SPARE_GRD_SRC1 121
51 51 #define TM_DESTINATION_ID_SPARE_GRD_SRC2 122
52 52 #define TM_DESTINATION_ID_OBCP 15
53 53 #define TM_DESTINATION_ID_SYSTEM_CONTROL 14
54 54 #define TM_DESTINATION_ID_AOCS 11
55 55
56 56 #define CCSDS_DESTINATION_ID 0x01
57 57 #define CCSDS_PROTOCOLE_ID 0x02
58 58 #define CCSDS_RESERVED 0x00
59 59 #define CCSDS_USER_APP 0x00
60 60
61 61 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
62 62 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
63 63 #define SIZE_HK_PARAMETERS 112
64 64
65 65 // TC TYPES
66 66 #define TC_TYPE_GEN 181
67 67 #define TC_TYPE_TIME 9
68 68
69 69 // TC SUBTYPES
70 70 #define TC_SUBTYPE_RESET 1
71 71 #define TC_SUBTYPE_LOAD_COMM 11
72 72 #define TC_SUBTYPE_LOAD_NORM 13
73 73 #define TC_SUBTYPE_LOAD_BURST 19
74 74 #define TC_SUBTYPE_LOAD_SBM1 25
75 75 #define TC_SUBTYPE_LOAD_SBM2 27
76 76 #define TC_SUBTYPE_DUMP 31
77 77 #define TC_SUBTYPE_ENTER 41
78 78 #define TC_SUBTYPE_UPDT_INFO 51
79 79 #define TC_SUBTYPE_EN_CAL 61
80 80 #define TC_SUBTYPE_DIS_CAL 63
81 81 #define TC_SUBTYPE_UPDT_TIME 129
82 82
83 83 // TC LEN
84 84 #define TC_LEN_RESET 12
85 85 #define TC_LEN_LOAD_COMM 14
86 86 #define TC_LEN_LOAD_NORM 22
87 87 #define TC_LEN_LOAD_BURST 14
88 88 #define TC_LEN_LOAD_SBM1 14
89 89 #define TC_LEN_LOAD_SBM2 14
90 90 #define TC_LEN_DUMP 12
91 91 #define TC_LEN_ENTER 20
92 92 #define TC_LEN_UPDT_INFO 46
93 93 #define TC_LEN_EN_CAL 12
94 94 #define TC_LEN_DIS_CAL 12
95 95 #define TC_LEN_UPDT_TIME 18
96 96
97 97 // TM TYPES
98 98 #define TM_TYPE_TC_EXE 1
99 99 #define TM_TYPE_HK 3
100 100 #define TM_TYPE_PARAMETER_DUMP 3
101 101 #define TM_TYPE_LFR_SCIENCE 21
102 102
103 103 // TM SUBTYPES
104 104 #define TM_SUBTYPE_EXE_OK 7
105 105 #define TM_SUBTYPE_EXE_NOK 8
106 106 #define TM_SUBTYPE_HK 25
107 107 #define TM_SUBTYPE_PARAMETER_DUMP 25
108 108 #define TM_SUBTYPE_SCIENCE 3
109 109 #define TM_SUBTYPE_LFR_SCIENCE 3
110 110
111 111 // FAILURE CODES
112 112 #define ILLEGAL_APID 0
113 113 #define WRONG_LEN_PKT 1
114 114 #define INCOR_CHECKSUM 2
115 115 #define ILL_TYPE 3
116 116 #define ILL_SUBTYPE 4
117 117 #define WRONG_APP_DATA 5 // 0x00 0x05
118 118 #define TC_NOT_EXE 42000 // 0xa4 0x10
119 119 #define WRONG_SRC_ID 42001 // 0xa4 0x11
120 120 #define FUNCT_NOT_IMPL 42002 // 0xa4 0x12
121 121 #define FAIL_DETECTED 42003 // 0xa4 0x13
122 122 #define NOT_ALLOWED 42004 // 0xa4 0x14
123 123 #define CORRUPTED 42005 // 0xa4 0x15
124 124 #define CCSDS_TM_VALID 7
125 125
126 126 // TC SID
127 127 #define SID_TC_GROUND 0
128 128 #define SID_TC_MISSION_TIMELINE 110
129 129 #define SID_TC_TC_SEQUENCES 111
130 130 #define SID_TC_RECOVERY_ACTION_CMD 112
131 131 #define SID_TC_BACKUP_MISSION_TIMELINE 113
132 132 #define SID_TC_DIRECT_CMD 120
133 133 #define SID_TC_SPARE_GRD_SRC1 121
134 134 #define SID_TC_SPARE_GRD_SRC2 122
135 135 #define SID_TC_OBCP 15
136 136 #define SID_TC_SYSTEM_CONTROL 14
137 137 #define SID_TC_AOCS 11
138 138 #define SID_TC_RPW_INTERNAL 254
139 139
140 140 enum apid_destid{
141 141 GROUND,
142 142 MISSION_TIMELINE,
143 143 TC_SEQUENCES,
144 144 RECOVERY_ACTION_CMD,
145 145 BACKUP_MISSION_TIMELINE,
146 146 DIRECT_CMD,
147 147 SPARE_GRD_SRC1,
148 148 SPARE_GRD_SRC2,
149 149 OBCP,
150 150 SYSTEM_CONTROL,
151 151 AOCS,
152 152 RPW_INTERNAL
153 153 };
154 154 // SEQUENCE COUNTERS
155 155 #define SEQ_CNT_MAX 16383
156 156 #define SEQ_CNT_NB_DEST_ID 12
157 157
158 158 // TM SID
159 159 #define SID_HK 1
160 160 #define SID_PARAMETER_DUMP 10
161 161
162 162 #define SID_NORM_SWF_F0 3
163 163 #define SID_NORM_SWF_F1 4
164 164 #define SID_NORM_SWF_F2 5
165 165 #define SID_NORM_CWF_F3 1
166 166 #define SID_BURST_CWF_F2 2
167 167 #define SID_SBM1_CWF_F1 24
168 168 #define SID_SBM2_CWF_F2 25
169 169 #define SID_NORM_ASM_F0 11
170 170 #define SID_NORM_ASM_F1 12
171 171 #define SID_NORM_ASM_F2 13
172 172 #define SID_NORM_BP1_F0 14
173 173 #define SID_NORM_BP1_F1 15
174 174 #define SID_NORM_BP1_F2 16
175 175 #define SID_NORM_BP2_F0 19
176 176 #define SID_NORM_BP2_F1 20
177 177 #define SID_NORM_BP2_F2 21
178 178 #define SID_BURST_BP1_F0 17
179 179 #define SID_BURST_BP2_F0 22
180 180 #define SID_BURST_BP1_F1 18
181 181 #define SID_BURST_BP2_F1 23
182 182 #define SID_SBM1_BP1_F0 28
183 183 #define SID_SBM1_BP2_F0 31
184 184 #define SID_SBM2_BP1_F0 29
185 185 #define SID_SBM2_BP2_F0 32
186 186 #define SID_SBM2_BP1_F1 30
187 187 #define SID_SBM2_BP2_F1 33
188 188 #define SID_NORM_CWF_LONG_F3 34
189 189
190 190 // LENGTH (BYTES)
191 191 #define LENGTH_TM_LFR_TC_EXE_MAX 32
192 192 #define LENGTH_TM_LFR_HK 126
193 193
194 194 // HEADER_LENGTH
195 195 #define TM_HEADER_LEN 16
196 196 #define HEADER_LENGTH_TM_LFR_SCIENCE_ASM 28
197 197 // PACKET_LENGTH
198 198 #define PACKET_LENGTH_TC_EXE_SUCCESS (20 - CCSDS_TC_TM_PACKET_OFFSET)
199 199 #define PACKET_LENGTH_TC_EXE_INCONSISTENT (26 - CCSDS_TC_TM_PACKET_OFFSET)
200 200 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE (26 - CCSDS_TC_TM_PACKET_OFFSET)
201 201 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED (24 - CCSDS_TC_TM_PACKET_OFFSET)
202 202 #define PACKET_LENGTH_TC_EXE_ERROR (24 - CCSDS_TC_TM_PACKET_OFFSET)
203 203 #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET)
204 204 #define PACKET_LENGTH_HK (124 - CCSDS_TC_TM_PACKET_OFFSET)
205 205 #define PACKET_LENGTH_PARAMETER_DUMP (36 - CCSDS_TC_TM_PACKET_OFFSET)
206 206 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0 (2228 - CCSDS_TC_TM_PACKET_OFFSET) // 44 * 25 * 2 + 28
207 207 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 (2628 - CCSDS_TC_TM_PACKET_OFFSET) // 52 * 25 * 2 + 28
208 208 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2 (2428 - CCSDS_TC_TM_PACKET_OFFSET) // 48 * 25 * 2 + 28
209 209 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 (126 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 9 + 27
210 210 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 (356 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 30 + 26
211 211 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 (144 - CCSDS_TC_TM_PACKET_OFFSET) // 13 * 9 + 27
212 212 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 (416 - CCSDS_TC_TM_PACKET_OFFSET) // 13 * 30 + 26
213 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 (134 - CCSDS_TC_TM_PACKET_OFFSET) // 12 * 9 + 26
214 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 (386 - CCSDS_TC_TM_PACKET_OFFSET) // 12 * 30 + 26
213 215 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26
214 216 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 (686 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 30 + 26
215 217 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 (260 - CCSDS_TC_TM_PACKET_OFFSET) // 26 * 9 + 26
216 218 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 (806 - CCSDS_TC_TM_PACKET_OFFSET) // 26 * 30 + 26
217 219
218 220 #define PACKET_LENGTH_DELTA 11 // 7 + 4
219 221
220 222 #define SPARE1_PUSVERSION_SPARE2 0x10
221 223
222 224 // R1
223 225 #define TM_LEN_SCI_SWF_340 4101 // 340 * 12 + 10 + 12 - 1
224 226 #define TM_LEN_SCI_SWF_8 117 // 8 * 12 + 10 + 12 - 1
225 227 #define TM_LEN_SCI_CWF_340 4099 // 340 * 12 + 10 + 10 - 1
226 228 #define TM_LEN_SCI_CWF_8 115 // 8 * 12 + 10 + 10 - 1
227 229 #define TM_LEN_SCI_CWF3_LIGHT_340 2059 // 340 * 6 + 10 + 10 - 1
228 230 #define TM_LEN_SCI_CWF3_LIGHT_8 67 // 8 * 6 + 10 + 10 - 1
229 231 // R2
230 232 #define TM_LEN_SCI_SWF_304 3669 // 304 * 12 + 10 + 12 - 1
231 233 #define TM_LEN_SCI_SWF_224 2709 // 224 * 12 + 10 + 12 - 1
232 234 #define TM_LEN_SCI_CWF_336 4051 // 336 * 12 + 10 + 10 - 1
233 235 #define TM_LEN_SCI_CWF_672 4051 // 672 * 6 + 10 + 10 - 1
234 236 //
235 237 #define DEFAULT_PKTCNT 0x07
236 238 #define BLK_NR_304 0x0130
237 239 #define BLK_NR_224 0x00e0
238 240 #define BLK_NR_CWF 0x0150 // 336
239 241 #define BLK_NR_CWF_SHORT_F3 0x02a0 // 672
240 242
241 243 enum TM_TYPE{
242 244 TM_LFR_TC_EXE_OK,
243 245 TM_LFR_TC_EXE_ERR,
244 246 TM_LFR_HK,
245 247 TM_LFR_SCI,
246 248 TM_LFR_SCI_SBM,
247 249 TM_LFR_PAR_DUMP
248 250 };
249 251
250 252 typedef struct {
251 253 unsigned char targetLogicalAddress;
252 254 unsigned char protocolIdentifier;
253 255 unsigned char reserved;
254 256 unsigned char userApplication;
255 257 // PACKET HEADER
256 258 unsigned char packetID[2];
257 259 unsigned char packetSequenceControl[2];
258 260 unsigned char packetLength[2];
259 261 // DATA FIELD HEADER
260 262 unsigned char spare1_pusVersion_spare2;
261 263 unsigned char serviceType;
262 264 unsigned char serviceSubType;
263 265 unsigned char destinationID;
264 266 unsigned char time[6];
265 267 //
266 268 unsigned char telecommand_pkt_id[2];
267 269 unsigned char pkt_seq_control[2];
268 270 } Packet_TM_LFR_TC_EXE_SUCCESS_t;
269 271
270 272 typedef struct {
271 273 unsigned char targetLogicalAddress;
272 274 unsigned char protocolIdentifier;
273 275 unsigned char reserved;
274 276 unsigned char userApplication;
275 277 // PACKET HEADER
276 278 unsigned char packetID[2];
277 279 unsigned char packetSequenceControl[2];
278 280 unsigned char packetLength[2];
279 281 // DATA FIELD HEADER
280 282 unsigned char spare1_pusVersion_spare2;
281 283 unsigned char serviceType;
282 284 unsigned char serviceSubType;
283 285 unsigned char destinationID;
284 286 unsigned char time[6];
285 287 //
286 288 unsigned char tc_failure_code[2];
287 289 unsigned char telecommand_pkt_id[2];
288 290 unsigned char pkt_seq_control[2];
289 291 unsigned char tc_service;
290 292 unsigned char tc_subtype;
291 293 unsigned char byte_position;
292 294 unsigned char rcv_value;
293 295 } Packet_TM_LFR_TC_EXE_INCONSISTENT_t;
294 296
295 297 typedef struct {
296 298 unsigned char targetLogicalAddress;
297 299 unsigned char protocolIdentifier;
298 300 unsigned char reserved;
299 301 unsigned char userApplication;
300 302 // PACKET HEADER
301 303 unsigned char packetID[2];
302 304 unsigned char packetSequenceControl[2];
303 305 unsigned char packetLength[2];
304 306 // DATA FIELD HEADER
305 307 unsigned char spare1_pusVersion_spare2;
306 308 unsigned char serviceType;
307 309 unsigned char serviceSubType;
308 310 unsigned char destinationID;
309 311 unsigned char time[6];
310 312 //
311 313 unsigned char tc_failure_code[2];
312 314 unsigned char telecommand_pkt_id[2];
313 315 unsigned char pkt_seq_control[2];
314 316 unsigned char tc_service;
315 317 unsigned char tc_subtype;
316 318 unsigned char lfr_status_word[2];
317 319 } Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t;
318 320
319 321 typedef struct {
320 322 unsigned char targetLogicalAddress;
321 323 unsigned char protocolIdentifier;
322 324 unsigned char reserved;
323 325 unsigned char userApplication;
324 326 // PACKET HEADER
325 327 unsigned char packetID[2];
326 328 unsigned char packetSequenceControl[2];
327 329 unsigned char packetLength[2];
328 330 // DATA FIELD HEADER
329 331 unsigned char spare1_pusVersion_spare2;
330 332 unsigned char serviceType;
331 333 unsigned char serviceSubType;
332 334 unsigned char destinationID;
333 335 unsigned char time[6];
334 336 //
335 337 unsigned char tc_failure_code[2];
336 338 unsigned char telecommand_pkt_id[2];
337 339 unsigned char pkt_seq_control[2];
338 340 unsigned char tc_service;
339 341 unsigned char tc_subtype;
340 342 } Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t;
341 343
342 344 typedef struct {
343 345 unsigned char targetLogicalAddress;
344 346 unsigned char protocolIdentifier;
345 347 unsigned char reserved;
346 348 unsigned char userApplication;
347 349 // PACKET HEADER
348 350 unsigned char packetID[2];
349 351 unsigned char packetSequenceControl[2];
350 352 unsigned char packetLength[2];
351 353 // DATA FIELD HEADER
352 354 unsigned char spare1_pusVersion_spare2;
353 355 unsigned char serviceType;
354 356 unsigned char serviceSubType;
355 357 unsigned char destinationID;
356 358 unsigned char time[6];
357 359 //
358 360 unsigned char tc_failure_code[2];
359 361 unsigned char telecommand_pkt_id[2];
360 362 unsigned char pkt_seq_control[2];
361 363 unsigned char tc_service;
362 364 unsigned char tc_subtype;
363 365 } Packet_TM_LFR_TC_EXE_ERROR_t;
364 366
365 367 typedef struct {
366 368 unsigned char targetLogicalAddress;
367 369 unsigned char protocolIdentifier;
368 370 unsigned char reserved;
369 371 unsigned char userApplication;
370 372 // PACKET HEADER
371 373 unsigned char packetID[2];
372 374 unsigned char packetSequenceControl[2];
373 375 unsigned char packetLength[2];
374 376 // DATA FIELD HEADER
375 377 unsigned char spare1_pusVersion_spare2;
376 378 unsigned char serviceType;
377 379 unsigned char serviceSubType;
378 380 unsigned char destinationID;
379 381 unsigned char time[6];
380 382 //
381 383 unsigned char tc_failure_code[2];
382 384 unsigned char telecommand_pkt_id[2];
383 385 unsigned char pkt_seq_control[2];
384 386 unsigned char tc_service;
385 387 unsigned char tc_subtype;
386 388 unsigned char pkt_len_rcv_value[2];
387 389 unsigned char pkt_datafieldsize_cnt[2];
388 390 unsigned char rcv_crc[2];
389 391 unsigned char computed_crc[2];
390 392 } Packet_TM_LFR_TC_EXE_CORRUPTED_t;
391 393
392 394 typedef struct {
393 395 unsigned char targetLogicalAddress;
394 396 unsigned char protocolIdentifier;
395 397 unsigned char reserved;
396 398 unsigned char userApplication;
397 399 unsigned char packetID[2];
398 400 unsigned char packetSequenceControl[2];
399 401 unsigned char packetLength[2];
400 402 // DATA FIELD HEADER
401 403 unsigned char spare1_pusVersion_spare2;
402 404 unsigned char serviceType;
403 405 unsigned char serviceSubType;
404 406 unsigned char destinationID;
405 407 unsigned char time[6];
406 408 // AUXILIARY HEADER
407 409 unsigned char sid;
408 410 unsigned char hkBIA;
409 411 unsigned char pktCnt;
410 412 unsigned char pktNr;
411 413 unsigned char acquisitionTime[6];
412 414 unsigned char blkNr[2];
413 415 } Header_TM_LFR_SCIENCE_SWF_t;
414 416
415 417 typedef struct {
416 418 unsigned char targetLogicalAddress;
417 419 unsigned char protocolIdentifier;
418 420 unsigned char reserved;
419 421 unsigned char userApplication;
420 422 unsigned char packetID[2];
421 423 unsigned char packetSequenceControl[2];
422 424 unsigned char packetLength[2];
423 425 // DATA FIELD HEADER
424 426 unsigned char spare1_pusVersion_spare2;
425 427 unsigned char serviceType;
426 428 unsigned char serviceSubType;
427 429 unsigned char destinationID;
428 430 unsigned char time[6];
429 431 // AUXILIARY DATA HEADER
430 432 unsigned char sid;
431 433 unsigned char hkBIA;
432 434 unsigned char acquisitionTime[6];
433 435 unsigned char blkNr[2];
434 436 } Header_TM_LFR_SCIENCE_CWF_t;
435 437
436 438 typedef struct {
437 439 unsigned char targetLogicalAddress;
438 440 unsigned char protocolIdentifier;
439 441 unsigned char reserved;
440 442 unsigned char userApplication;
441 443 unsigned char packetID[2];
442 444 unsigned char packetSequenceControl[2];
443 445 unsigned char packetLength[2];
444 446 // DATA FIELD HEADER
445 447 unsigned char spare1_pusVersion_spare2;
446 448 unsigned char serviceType;
447 449 unsigned char serviceSubType;
448 450 unsigned char destinationID;
449 451 unsigned char time[6];
450 452 // AUXILIARY HEADER
451 453 unsigned char sid;
452 454 unsigned char biaStatusInfo;
453 455 unsigned char pa_lfr_pkt_cnt_asm;
454 456 unsigned char pa_lfr_pkt_nr_asm;
455 457 unsigned char acquisitionTime[6];
456 458 unsigned char pa_lfr_asm_blk_nr[2];
457 459 } Header_TM_LFR_SCIENCE_ASM_t;
458 460
459 461 typedef struct {
460 462 unsigned char targetLogicalAddress;
461 463 unsigned char protocolIdentifier;
462 464 unsigned char reserved;
463 465 unsigned char userApplication;
464 466 unsigned char packetID[2];
465 467 unsigned char packetSequenceControl[2];
466 468 unsigned char packetLength[2];
467 469 // DATA FIELD HEADER
468 470 unsigned char spare1_pusVersion_spare2;
469 471 unsigned char serviceType;
470 472 unsigned char serviceSubType;
471 473 unsigned char destinationID;
472 474 unsigned char time[6];
473 475 // AUXILIARY HEADER
474 476 unsigned char sid;
475 477 unsigned char biaStatusInfo;
476 478 unsigned char acquisitionTime[6];
477 479 unsigned char source_data_spare[2];
478 480 unsigned char pa_lfr_bp_blk_nr[2];
479 481 } Header_TM_LFR_SCIENCE_BP_with_spare_t;
480 482
481 483 typedef struct {
482 484 unsigned char targetLogicalAddress;
483 485 unsigned char protocolIdentifier;
484 486 unsigned char reserved;
485 487 unsigned char userApplication;
486 488 unsigned char packetID[2];
487 489 unsigned char packetSequenceControl[2];
488 490 unsigned char packetLength[2];
489 491 // DATA FIELD HEADER
490 492 unsigned char spare1_pusVersion_spare2;
491 493 unsigned char serviceType;
492 494 unsigned char serviceSubType;
493 495 unsigned char destinationID;
494 496 unsigned char time[6];
495 497 // AUXILIARY HEADER
496 498 unsigned char sid;
497 499 unsigned char biaStatusInfo;
498 500 unsigned char acquisitionTime[6];
499 501 unsigned char pa_lfr_bp_blk_nr[2];
500 502 } Header_TM_LFR_SCIENCE_BP_t;
501 503
502 504 typedef struct {
503 505 //targetLogicalAddress is removed by the grspw module
504 506 unsigned char protocolIdentifier;
505 507 unsigned char reserved;
506 508 unsigned char userApplication;
507 509 unsigned char packetID[2];
508 510 unsigned char packetSequenceControl[2];
509 511 unsigned char packetLength[2];
510 512 // DATA FIELD HEADER
511 513 unsigned char headerFlag_pusVersion_Ack;
512 514 unsigned char serviceType;
513 515 unsigned char serviceSubType;
514 516 unsigned char sourceID;
515 517 unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
516 518 } ccsdsTelecommandPacket_t;
517 519
518 520 typedef struct {
519 521 unsigned char targetLogicalAddress;
520 522 unsigned char protocolIdentifier;
521 523 unsigned char reserved;
522 524 unsigned char userApplication;
523 525 unsigned char packetID[2];
524 526 unsigned char packetSequenceControl[2];
525 527 unsigned char packetLength[2];
526 528 unsigned char spare1_pusVersion_spare2;
527 529 unsigned char serviceType;
528 530 unsigned char serviceSubType;
529 531 unsigned char destinationID;
530 532 unsigned char time[6];
531 533 unsigned char sid;
532 534
533 535 //**************
534 536 // HK PARAMETERS
535 537 unsigned char lfr_status_word[2];
536 538 unsigned char lfr_sw_version[4];
537 539 unsigned char lfr_fpga_version[3];
538 540 // ressource statistics
539 541 unsigned char hk_lfr_cpu_load;
540 542 unsigned char hk_lfr_load_max;
541 543 unsigned char hk_lfr_load_aver;
542 544 // tc statistics
543 545 unsigned char hk_lfr_update_info_tc_cnt[2];
544 546 unsigned char hk_lfr_update_time_tc_cnt[2];
545 547 unsigned char hk_lfr_exe_tc_cnt[2];
546 548 unsigned char hk_lfr_rej_tc_cnt[2];
547 549 unsigned char hk_lfr_last_exe_tc_id[2];
548 550 unsigned char hk_lfr_last_exe_tc_type[2];
549 551 unsigned char hk_lfr_last_exe_tc_subtype[2];
550 552 unsigned char hk_lfr_last_exe_tc_time[6];
551 553 unsigned char hk_lfr_last_rej_tc_id[2];
552 554 unsigned char hk_lfr_last_rej_tc_type[2];
553 555 unsigned char hk_lfr_last_rej_tc_subtype[2];
554 556 unsigned char hk_lfr_last_rej_tc_time[6];
555 557 // anomaly statistics
556 558 unsigned char hk_lfr_le_cnt[2];
557 559 unsigned char hk_lfr_me_cnt[2];
558 560 unsigned char hk_lfr_he_cnt[2];
559 561 unsigned char hk_lfr_last_er_rid[2];
560 562 unsigned char hk_lfr_last_er_code;
561 563 unsigned char hk_lfr_last_er_time[6];
562 564 // vhdl_blk_status
563 565 unsigned char hk_lfr_vhdl_aa_sm;
564 566 unsigned char hk_lfr_vhdl_fft_sr;
565 567 unsigned char hk_lfr_vhdl_cic_hk;
566 568 unsigned char hk_lfr_vhdl_iir_cal;
567 569 // spacewire_if_statistics
568 570 unsigned char hk_lfr_dpu_spw_pkt_rcv_cnt[2];
569 571 unsigned char hk_lfr_dpu_spw_pkt_sent_cnt[2];
570 572 unsigned char hk_lfr_dpu_spw_tick_out_cnt;
571 573 unsigned char hk_lfr_dpu_spw_last_timc;
572 574 // ahb error statistics
573 575 unsigned int hk_lfr_last_fail_addr;
574 576 // temperatures
575 577 unsigned char hk_lfr_temp_scm[2];
576 578 unsigned char hk_lfr_temp_pcb[2];
577 579 unsigned char hk_lfr_temp_fpga[2];
578 580 // spacecraft potential
579 581 unsigned char hk_lfr_sc_v_f3[2];
580 582 unsigned char hk_lfr_sc_e1_f3[2];
581 583 unsigned char hk_lfr_sc_e2_f3[2];
582 584 // error counters
583 585 unsigned char hk_lfr_dpu_spw_parity;
584 586 unsigned char hk_lfr_dpu_spw_disconnect;
585 587 unsigned char hk_lfr_dpu_spw_escape;
586 588 unsigned char hk_lfr_dpu_spw_credit;
587 589 unsigned char hk_lfr_dpu_spw_write_sync;
588 590 unsigned char hk_lfr_dpu_spw_rx_ahb;
589 591 unsigned char hk_lfr_dpu_spw_tx_ahb;
590 592 unsigned char hk_lfr_dpu_spw_early_eop;
591 593 unsigned char hk_lfr_dpu_spw_invalid_addr;
592 594 unsigned char hk_lfr_dpu_spw_eep;
593 595 unsigned char hk_lfr_dpu_spw_rx_too_big;
594 596 // timecode
595 597 unsigned char hk_lfr_timecode_erroneous;
596 598 unsigned char hk_lfr_timecode_missing;
597 599 unsigned char hk_lfr_timecode_invalid;
598 600 // time
599 601 unsigned char hk_lfr_time_timecode_it;
600 602 unsigned char hk_lfr_time_not_synchro;
601 603 unsigned char hk_lfr_time_timecode_ctr;
602 604 // hk_lfr_buffer_dpu_
603 605 unsigned char hk_lfr_buffer_dpu_tc_fifo;
604 606 unsigned char hk_lfr_buffer_dpu_tm_fifo;
605 607 // hk_lfr_ahb_
606 608 unsigned char hk_lfr_ahb_correctable;
607 609 unsigned char hk_lfr_ahb_uncorrectable;
608 610 // spare
609 611 unsigned char parameters_spare;
610 612 } Packet_TM_LFR_HK_t;
611 613
612 614 typedef struct {
613 615 unsigned char targetLogicalAddress;
614 616 unsigned char protocolIdentifier;
615 617 unsigned char reserved;
616 618 unsigned char userApplication;
617 619 unsigned char packetID[2];
618 620 unsigned char packetSequenceControl[2];
619 621 unsigned char packetLength[2];
620 622 // DATA FIELD HEADER
621 623 unsigned char spare1_pusVersion_spare2;
622 624 unsigned char serviceType;
623 625 unsigned char serviceSubType;
624 626 unsigned char destinationID;
625 627 unsigned char time[6];
626 628 unsigned char sid;
627 629
628 630 //******************
629 631 // COMMON PARAMETERS
630 632 unsigned char unused0;
631 633 unsigned char bw_sp0_sp1_r0_r1;
632 634
633 635 //******************
634 636 // NORMAL PARAMETERS
635 637 unsigned char sy_lfr_n_swf_l[2];
636 638 unsigned char sy_lfr_n_swf_p[2];
637 639 unsigned char sy_lfr_n_asm_p[2];
638 640 unsigned char sy_lfr_n_bp_p0;
639 641 unsigned char sy_lfr_n_bp_p1;
640 642 unsigned char sy_lfr_n_cwf_long_f3;
641 643 unsigned char lfr_normal_parameters_spare;
642 644
643 645 //*****************
644 646 // BURST PARAMETERS
645 647 unsigned char sy_lfr_b_bp_p0;
646 648 unsigned char sy_lfr_b_bp_p1;
647 649
648 650 //****************
649 651 // SBM1 PARAMETERS
650 652 unsigned char sy_lfr_s1_bp_p0;
651 653 unsigned char sy_lfr_s1_bp_p1;
652 654
653 655 //****************
654 656 // SBM2 PARAMETERS
655 657 unsigned char sy_lfr_s2_bp_p0;
656 658 unsigned char sy_lfr_s2_bp_p1;
657 659
658 660 // SPARE
659 661 unsigned char source_data_spare;
660 662 } Packet_TM_LFR_PARAMETER_DUMP_t;
661 663
662 664
663 665 #endif // CCSDS_TYPES_H_INCLUDED
@@ -1,43 +1,47
1 1 #ifndef FSW_INIT_H_INCLUDED
2 2 #define FSW_INIT_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <leon.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "fsw_misc.h"
9 9 #include "fsw_processing.h"
10 #include "avf0_prc0.h"
11 #include "avf1_prc1.h"
12 #include "avf2_prc2.h"
13
10 14 #include "tc_handler.h"
11 15 #include "wf_handler.h"
12
13 16 #include "fsw_spacewire.h"
14 17
15 18 extern rtems_name Task_name[20]; /* array of task names */
16 19 extern rtems_id Task_id[20]; /* array of task ids */
17 20
18 21 // RTEMS TASKS
19 22 rtems_task Init( rtems_task_argument argument);
20 23
21 24 // OTHER functions
22 25 void create_names( void );
23 26 int create_all_tasks( void );
24 27 int start_all_tasks( void );
25 28 //
26 29 rtems_status_code create_message_queues( void );
27 30 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
28 31 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
29 32 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
30 33 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
34 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
31 35 //
32 36 int start_recv_send_tasks( void );
33 37 //
34 38 void init_local_mode_parameters( void );
35 39 void reset_local_time( void );
36 40
37 41 extern int rtems_cpu_usage_report( void );
38 42 extern int rtems_cpu_usage_reset( void );
39 43 extern void rtems_stack_checker_report_usage( void );
40 44
41 45 extern int sched_yield( void );
42 46
43 47 #endif // FSW_INIT_H_INCLUDED
@@ -1,283 +1,250
1 1 #ifndef FSW_PARAMS_H_INCLUDED
2 2 #define FSW_PARAMS_H_INCLUDED
3 3
4 4 #include "grlib_regs.h"
5 5 #include "fsw_params_processing.h"
6 6 #include "fsw_params_nb_bytes.h"
7 7 #include "tm_byte_positions.h"
8 8 #include "ccsds_types.h"
9 9
10 10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
11 11 #define UART_DEVICE_NAME "/dev/console"
12 12
13 13 typedef struct ring_node
14 14 {
15 15 struct ring_node *previous;
16 16 int buffer_address;
17 17 struct ring_node *next;
18 18 unsigned int status;
19 19 } ring_node;
20 20
21 typedef struct {
22 unsigned int norm_bp1;
23 unsigned int norm_bp2;
24 unsigned int norm_asm;
25 unsigned int burst_sbm_bp1;
26 unsigned int burst_sbm_bp2;
27 unsigned int burst_bp1;
28 unsigned int burst_bp2;
29 unsigned int sbm1_bp1;
30 unsigned int sbm1_bp2;
31 unsigned int sbm2_bp1;
32 unsigned int sbm2_bp2;
33 } nb_sm_before_bp_asm_f0;
34
35 typedef struct {
36 unsigned int norm_bp1;
37 unsigned int norm_bp2;
38 unsigned int norm_asm;
39 unsigned int burst_sbm_bp1;
40 unsigned int burst_sbm_bp2;
41 unsigned int burst_bp1;
42 unsigned int burst_bp2;
43 unsigned int sbm2_bp1;
44 unsigned int sbm2_bp2;
45 } nb_sm_before_bp_asm_f1;
46
47 typedef struct {
48 unsigned int norm_bp1_f2;
49 unsigned int norm_bp2_f2;
50 unsigned int norm_asm_f2;
51 unsigned int burst_sbm_bp1_f2;
52 unsigned int burst_sbm_bp2_f2;
53 unsigned int burst_bp1_f2;
54 unsigned int burst_bp2_f2;
55 unsigned int sbm2_bp1_f2;
56 unsigned int sbm2_bp2_f2;
57 } nb_sm_before_bp_asm_f2;
58
59 21 //************************
60 22 // flight software version
61 23 // this parameters is handled by the Qt project options
62 24
63 25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
64 26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
65 27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
66 28 #define TIME_OFFSET 2
67 29 #define TIME_OFFSET_IN_BYTES 8
68 30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
69 31 #define NB_BYTES_SWF_BLK (2 * 6)
70 32 #define NB_WORDS_SWF_BLK 3
71 33 #define NB_BYTES_CWF3_LIGHT_BLK 6
72 34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
73 35 #define NB_RING_NODES_F0 3 // AT LEAST 3
74 36 #define NB_RING_NODES_F1 5 // AT LEAST 3
75 37 #define NB_RING_NODES_F2 5 // AT LEAST 3
76 38
77 39 //**********
78 40 // LFR MODES
79 41 #define LFR_MODE_STANDBY 0
80 42 #define LFR_MODE_NORMAL 1
81 43 #define LFR_MODE_BURST 2
82 44 #define LFR_MODE_SBM1 3
83 45 #define LFR_MODE_SBM2 4
84 46
85 47 #define TDS_MODE_LFM 5
86 48 #define TDS_MODE_STANDBY 0
87 49 #define TDS_MODE_NORMAL 1
88 50 #define TDS_MODE_BURST 2
89 51 #define TDS_MODE_SBM1 3
90 52 #define TDS_MODE_SBM2 4
91 53
92 54 #define THR_MODE_STANDBY 0
93 55 #define THR_MODE_NORMAL 1
94 56 #define THR_MODE_BURST 2
95 57
96 58 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
97 59 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
98 60 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
99 61 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
100 62 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
101 63 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
102 64 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
103 65 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
104 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8
66 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
105 67 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
106 68 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
107 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11
69 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
108 70 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
109 71 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
110 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14
72 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
111 73 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_15
112 74 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_16
113 75 #define RTEMS_EVENT_BURST_SBM_BP1_F1 RTEMS_EVENT_17
114 76 #define RTEMS_EVENT_BURST_SBM_BP2_F1 RTEMS_EVENT_18
115 #define RTEMS_EVENT_BURST_SBM_BP1_F2 RTEMS_EVENT_19
116 #define RTEMS_EVENT_BURST_SBM_BP2_F2 RTEMS_EVENT_20
117 77
118 78 //****************************
119 79 // LFR DEFAULT MODE PARAMETERS
120 80 // COMMON
121 81 #define DEFAULT_SY_LFR_COMMON0 0x00
122 82 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
123 83 // NORM
124 84 #define SY_LFR_N_SWF_L 2048 // nb sample
125 85 #define SY_LFR_N_SWF_P 300 // sec
126 86 #define SY_LFR_N_ASM_P 3600 // sec
127 87 #define SY_LFR_N_BP_P0 4 // sec
128 88 #define SY_LFR_N_BP_P1 20 // sec
129 89 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
130 90 #define MIN_DELTA_SNAPSHOT 16 // sec
131 91 // BURST
132 92 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
133 93 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
134 94 // SBM1
135 95 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
136 96 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
137 97 // SBM2
138 98 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
139 99 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
140 100 // ADDITIONAL PARAMETERS
141 101 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
142 102 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
143 103 // STATUS WORD
144 104 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
145 105 #define DEFAULT_STATUS_WORD_BYTE1 0x00
146 106 //
147 107 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
148 108 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
149 109 //****************************
150 110
151 111 //*****************************
152 112 // APB REGISTERS BASE ADDRESSES
153 113 #define REGS_ADDR_APBUART 0x80000100
154 114 #define REGS_ADDR_GPTIMER 0x80000300
155 115 #define REGS_ADDR_GRSPW 0x80000500
156 116 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
157 117 #define REGS_ADDR_GRGPIO 0x80000b00
158 118
159 119 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
160 120 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
161 121
162 122 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
163 123 #define APBUART_CTRL_REG_MASK_TE 0x00000002
164 124 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
165 125
166 126 //**********
167 127 // IRQ LINES
168 128 #define IRQ_SM_SIMULATOR 9
169 129 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
170 130 #define IRQ_WAVEFORM_PICKER 14
171 131 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
172 132 #define IRQ_SPECTRAL_MATRIX 6
173 133 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
174 134
175 135 //*****
176 136 // TIME
177 137 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
178 138 #define TIMER_SM_SIMULATOR 1
179 139 #define HK_PERIOD 100 // 100 * 10ms => 1s
180 140 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
181 141 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
182 142
183 143 //**********
184 144 // LPP CODES
185 145 #define LFR_SUCCESSFUL 0
186 146 #define LFR_DEFAULT 1
187 147 #define LFR_EXE_ERROR 2
188 148
189 149 //******
190 150 // RTEMS
191 151 #define TASKID_RECV 1
192 152 #define TASKID_ACTN 2
193 153 #define TASKID_SPIQ 3
194 154 #define TASKID_STAT 4
195 155 #define TASKID_AVF0 5
196 156 #define TASKID_SWBD 6
197 157 #define TASKID_WFRM 7
198 158 #define TASKID_DUMB 8
199 159 #define TASKID_HOUS 9
200 160 #define TASKID_PRC0 10
201 161 #define TASKID_CWF3 11
202 162 #define TASKID_CWF2 12
203 163 #define TASKID_CWF1 13
204 164 #define TASKID_SEND 14
205 165 #define TASKID_WTDG 15
206 166 #define TASKID_AVF1 16
207 167 #define TASKID_PRC1 17
168 #define TASKID_AVF2 18
169 #define TASKID_PRC2 19
208 170
209 171 #define TASK_PRIORITY_SPIQ 5
210 172 #define TASK_PRIORITY_WTDG 20
211 173 #define TASK_PRIORITY_HOUS 30
212 174 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
213 175 #define TASK_PRIORITY_CWF2 35 //
214 176 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
215 177 #define TASK_PRIORITY_WFRM 40
216 178 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
217 179 #define TASK_PRIORITY_SEND 45
218 180 #define TASK_PRIORITY_RECV 50
219 181 #define TASK_PRIORITY_ACTN 50
220 182 #define TASK_PRIORITY_AVF0 60
221 183 #define TASK_PRIORITY_AVF1 70
222 184 #define TASK_PRIORITY_PRC0 100
223 185 #define TASK_PRIORITY_PRC1 100
186 #define TASK_PRIORITY_AVF2 110
187 #define TASK_PRIORITY_PRC2 110
224 188 #define TASK_PRIORITY_STAT 200
225 189 #define TASK_PRIORITY_DUMB 200
226 190
227 191 #define MSG_QUEUE_COUNT_RECV 10
228 192 #define MSG_QUEUE_COUNT_SEND 50
229 193 #define MSG_QUEUE_COUNT_PRC0 10
230 194 #define MSG_QUEUE_COUNT_PRC1 10
195 #define MSG_QUEUE_COUNT_PRC2 5
231 196 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
232 197 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
233 198 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
234 199 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
200 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
235 201
236 202 #define QUEUE_RECV 0
237 203 #define QUEUE_SEND 1
238 204 #define QUEUE_PRC0 2
239 205 #define QUEUE_PRC1 3
206 #define QUEUE_PRC2 4
240 207
241 208 //*******
242 209 // MACROS
243 210 #ifdef PRINT_MESSAGES_ON_CONSOLE
244 211 #define PRINTF(x) printf(x);
245 212 #define PRINTF1(x,y) printf(x,y);
246 213 #define PRINTF2(x,y,z) printf(x,y,z);
247 214 #else
248 215 #define PRINTF(x) ;
249 216 #define PRINTF1(x,y) ;
250 217 #define PRINTF2(x,y,z) ;
251 218 #endif
252 219
253 220 #ifdef BOOT_MESSAGES
254 221 #define BOOT_PRINTF(x) printf(x);
255 222 #define BOOT_PRINTF1(x,y) printf(x,y);
256 223 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
257 224 #else
258 225 #define BOOT_PRINTF(x) ;
259 226 #define BOOT_PRINTF1(x,y) ;
260 227 #define BOOT_PRINTF2(x,y,z) ;
261 228 #endif
262 229
263 230 #ifdef DEBUG_MESSAGES
264 231 #define DEBUG_PRINTF(x) printf(x);
265 232 #define DEBUG_PRINTF1(x,y) printf(x,y);
266 233 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
267 234 #else
268 235 #define DEBUG_PRINTF(x) ;
269 236 #define DEBUG_PRINTF1(x,y) ;
270 237 #define DEBUG_PRINTF2(x,y,z) ;
271 238 #endif
272 239
273 240 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
274 241
275 242 struct param_local_str{
276 243 unsigned int local_sbm1_nb_cwf_sent;
277 244 unsigned int local_sbm1_nb_cwf_max;
278 245 unsigned int local_sbm2_nb_cwf_sent;
279 246 unsigned int local_sbm2_nb_cwf_max;
280 247 unsigned int local_nb_interrupt_f0_MAX;
281 248 };
282 249
283 250 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,63 +1,65
1 1 #ifndef FSW_PARAMS_PROCESSING_H
2 2 #define FSW_PARAMS_PROCESSING_H
3 3
4 4 #define NB_BINS_PER_SM 128
5 5 #define NB_VALUES_PER_SM 25
6 6 #define TOTAL_SIZE_SM 3200 // 25 * 128
7 7 #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99
8 8 #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117
9 9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
10 10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
11 11 //
12 12 #define NB_RING_NODES_SM_F0 12 // AT LEAST 3
13 13 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
14 14 #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3
15 15 #define NB_RING_NODES_SM_F1 3 // AT LEAST 3
16 16 #define NB_RING_NODES_ASM_BURST_SBM_F1 5 // AT LEAST 3
17 #define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3
17 #define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3
18 18 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
19 #define NB_RING_NODES_ASM_BURST_SBM_F2 3 // AT LEAST 3
20 #define NB_RING_NODES_ASM_NORM_F2 3 // AT LEAST 3
19 21 //
20 22 #define NB_BINS_PER_ASM_F0 88
21 23 #define NB_BINS_PER_PKT_ASM_F0 44
22 24 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
23 25 #define ASM_F0_INDICE_START 17 // 88 bins
24 26 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
25 27 //
26 28 #define NB_BINS_PER_ASM_F1 104
27 29 #define NB_BINS_PER_PKT_ASM_F1 52
28 30 #define TOTAL_SIZE_ASM_F1_IN_BYTES 5200 // 25 * 104 * 2
29 31 #define ASM_F1_INDICE_START 6 // 104 bins
30 32 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
31 33 //
32 34 #define NB_BINS_PER_ASM_F2 96
33 35 #define NB_BINS_PER_PKT_ASM_F2 48
34 36 #define TOTAL_SIZE_ASM_F2_IN_BYTES 4800 // 25 * 96 * 2
35 37 #define ASM_F2_INDICE_START 7 // 96 bins
36 38 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
37 39 //
38 40 #define NB_BINS_COMPRESSED_SM_F0 11
39 41 #define NB_BINS_COMPRESSED_SM_F1 13
40 42 #define NB_BINS_COMPRESSED_SM_F2 12
41 43 #define NB_BINS_COMPRESSED_SM_SBM_F0 22
42 44 #define NB_BINS_COMPRESSED_SM_SBM_F1 26
43 45 #define NB_BINS_COMPRESSED_SM_SBM_F2 24
44 46 //
45 47 #define NB_BINS_TO_AVERAGE_ASM_F0 8
46 48 #define NB_BINS_TO_AVERAGE_ASM_F1 8
47 49 #define NB_BINS_TO_AVERAGE_ASM_F2 8
48 50 #define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4
49 51 #define NB_BINS_TO_AVERAGE_ASM_SBM_F1 4
50 52 #define NB_BINS_TO_AVERAGE_ASM_SBM_F2 4
51 53 //
52 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS
53 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS
54 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
55 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS
56 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS
57 // NORM
58 #define NB_SM_BEFORE_NORM_BP1_F0 384 // 96 * 4
54 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS
55 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS
56 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F2 300 // 12 * 25 WORDS
57 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS
58 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS
59 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 600 // 24 * 25 WORDS
59 60 // GENERAL
60 #define NB_SM_BEFORE_AVF0 8
61 #define NB_SM_BEFORE_AVF1 8
61 #define NB_SM_BEFORE_AVF0 8 // must be 8 due to the SM_average() function
62 #define NB_SM_BEFORE_AVF1 8 // must be 8 due to the SM_average() function
63 #define NB_SM_BEFORE_AVF2 1 // must be 1 due to the SM_average_f2() function
62 64
63 65 #endif // FSW_PARAMS_PROCESSING_H
@@ -1,50 +1,46
1 1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 2 #define TC_LOAD_DUMP_PARAMETERS_H
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "wf_handler.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "fsw_misc.h"
11 11
12 extern nb_sm_before_bp_asm_f0 nb_sm_before_f0;
13 extern nb_sm_before_bp_asm_f1 nb_sm_before_f1;
14 extern nb_sm_before_bp_asm_f2 nb_sm_before_f2;
15
16 12 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
17 13 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
18 14 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
19 15 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
20 16 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
21 17 int action_dump_par(rtems_id queue_id );
22 18
23 19 // NORMAL
24 20 int set_sy_lfr_n_swf_l(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
25 21 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
26 22 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
27 23 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
28 24 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
29 25 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
30 26
31 27 // BURST
32 28 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
33 29 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
34 30
35 31 // SBM1
36 32 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
37 33 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
38 34
39 35 // SBM2
40 36 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
41 37 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
42 38
43 39 // TC_LFR_UPDATE_INFO
44 40 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
45 41 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
46 42 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
47 43
48 44 void init_parameter_dump( void );
49 45
50 46 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,79 +1,75
1 1 /** Global variables of the LFR flight software.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * Among global variables, there are:
7 7 * - RTEMS names and id.
8 8 * - APB configuration registers.
9 9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 10 * - spectral matrices buffesr, used by the hardware module to store data.
11 11 * - variable related to LFR modes parameters.
12 12 * - the global HK packet buffer.
13 13 * - the global dump parameter buffer.
14 14 *
15 15 */
16 16
17 17 #include <rtems.h>
18 18 #include <grspw.h>
19 19
20 20 #include "ccsds_types.h"
21 21 #include "grlib_regs.h"
22 22 #include "fsw_params.h"
23 23
24 24 // RTEMS GLOBAL VARIABLES
25 25 rtems_name misc_name[5];
26 26 rtems_id misc_id[5];
27 27 rtems_name Task_name[20]; /* array of task names */
28 28 rtems_id Task_id[20]; /* array of task ids */
29 29 unsigned int maxCount;
30 30 int fdSPW = 0;
31 31 int fdUART = 0;
32 32 unsigned char lfrCurrentMode;
33 33
34 34 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
35 35 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
36 36 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
37 37 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
38 38 // F0
39 39 volatile int wf_snap_f0[ NB_RING_NODES_F0 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ] __attribute__((aligned(0x100)));
40 40 // F1 F2
41 41 volatile int wf_snap_f1[ NB_RING_NODES_F1 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ] __attribute__((aligned(0x100)));
42 42 volatile int wf_snap_f2[ NB_RING_NODES_F2 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ] __attribute__((aligned(0x100)));
43 43 // F3
44 44 volatile int wf_cont_f3_a [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
45 45 volatile int wf_cont_f3_b [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
46 46 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
47 47
48 48 //***********************************
49 49 // SPECTRAL MATRICES GLOBAL VARIABLES
50 50
51 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
52 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
53 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
54
55 51 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
56 52 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
57 53 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
58 54 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
59 55
60 56 // APB CONFIGURATION REGISTERS
61 57 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
62 58 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
63 59 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
64 60 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
65 61
66 62 // MODE PARAMETERS
67 63 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
68 64 struct param_local_str param_local;
69 65
70 66 // HK PACKETS
71 67 Packet_TM_LFR_HK_t housekeeping_packet;
72 68 // sequence counters are incremented by APID (PID + CAT) and destination ID
73 69 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
74 70 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
75 71 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
76 72 spw_stats spacewire_stats;
77 73 spw_stats spacewire_stats_backup;
78 74
79 75
@@ -1,709 +1,767
1 1 /** This is the RTEMS initialization module.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * This module contains two very different information:
7 7 * - specific instructions to configure the compilation of the RTEMS executive
8 8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 9 *
10 10 */
11 11
12 12 //*************************
13 13 // GPL reminder to be added
14 14 //*************************
15 15
16 16 #include <rtems.h>
17 17
18 18 /* configuration information */
19 19
20 20 #define CONFIGURE_INIT
21 21
22 22 #include <bsp.h> /* for device driver prototypes */
23 23
24 24 /* configuration information */
25 25
26 26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28 28
29 29 #define CONFIGURE_MAXIMUM_TASKS 20
30 30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 4
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 39 #ifdef PRINT_STACK_REPORT
40 40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 41 #endif
42 42
43 43 #include <rtems/confdefs.h>
44 44
45 45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 46 #ifdef RTEMS_DRVMGR_STARTUP
47 47 #ifdef LEON3
48 48 /* Add Timer and UART Driver */
49 49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 51 #endif
52 52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 54 #endif
55 55 #endif
56 56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 57 #include <drvmgr/drvmgr_confdefs.h>
58 58 #endif
59 59
60 60 #include "fsw_init.h"
61 61 #include "fsw_config.c"
62 62
63 63 rtems_task Init( rtems_task_argument ignored )
64 64 {
65 65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 66 *
67 67 * @param unused is the starting argument of the RTEMS task
68 68 *
69 69 * The INIT task create and run all other RTEMS tasks.
70 70 *
71 71 */
72 72
73 73 reset_local_time();
74 74
75 75 rtems_status_code status;
76 76 rtems_status_code status_spw;
77 77 rtems_isr_entry old_isr_handler;
78 78
79 79 // UART settings
80 80 send_console_outputs_on_apbuart_port();
81 81 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
82 82 enable_apbuart_transmitter();
83 83 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
84 84
85 85 PRINTF("\n\n\n\n\n")
86 86 PRINTF("*************************\n")
87 87 PRINTF("** LFR Flight Software **\n")
88 88 PRINTF1("** %d.", SW_VERSION_N1)
89 89 PRINTF1("%d." , SW_VERSION_N2)
90 90 PRINTF1("%d." , SW_VERSION_N3)
91 91 PRINTF1("%d **\n", SW_VERSION_N4)
92 92 PRINTF("*************************\n")
93 93 PRINTF("\n\n")
94 94
95 95 init_parameter_dump();
96 96 init_local_mode_parameters();
97 97 init_housekeeping_parameters();
98 98
99 99 init_waveform_rings(); // initialize the waveform rings
100 100 SM_init_rings(); // initialize spectral matrices rings
101 ASM_init_rings(); // initialize the average spectral matrix ring (just for burst, sbm1 and sbm2 asm @ f0 storage)
102 101
103 102 reset_wfp_burst_enable();
104 103 reset_wfp_status();
105 104 set_wfp_data_shaping();
106 105
107 106 updateLFRCurrentMode();
108 107
109 108 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
110 109
111 110 create_names(); // create all names
112 111
113 112 status = create_message_queues(); // create message queues
114 113 if (status != RTEMS_SUCCESSFUL)
115 114 {
116 115 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
117 116 }
118 117
119 118 status = create_all_tasks(); // create all tasks
120 119 if (status != RTEMS_SUCCESSFUL)
121 120 {
122 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
121 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
123 122 }
124 123
125 124 // **************************
126 125 // <SPACEWIRE INITIALIZATION>
127 126 grspw_timecode_callback = &timecode_irq_handler;
128 127
129 128 status_spw = spacewire_open_link(); // (1) open the link
130 129 if ( status_spw != RTEMS_SUCCESSFUL )
131 130 {
132 131 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
133 132 }
134 133
135 134 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
136 135 {
137 136 status_spw = spacewire_configure_link( fdSPW );
138 137 if ( status_spw != RTEMS_SUCCESSFUL )
139 138 {
140 139 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
141 140 }
142 141 }
143 142
144 143 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
145 144 {
146 145 status_spw = spacewire_start_link( fdSPW );
147 146 if ( status_spw != RTEMS_SUCCESSFUL )
148 147 {
149 148 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
150 149 }
151 150 }
152 151 // </SPACEWIRE INITIALIZATION>
153 152 // ***************************
154 153
155 154 status = start_all_tasks(); // start all tasks
156 155 if (status != RTEMS_SUCCESSFUL)
157 156 {
158 157 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
159 158 }
160 159
161 160 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
162 161 status = start_recv_send_tasks();
163 162 if ( status != RTEMS_SUCCESSFUL )
164 163 {
165 164 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
166 165 }
167 166
168 167 // suspend science tasks, they will be restarted later depending on the mode
169 168 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
170 169 if (status != RTEMS_SUCCESSFUL)
171 170 {
172 171 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
173 172 }
174 173
175 174 //******************************
176 175 // <SPECTRAL MATRICES SIMULATOR>
177 176 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
178 177 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
179 178 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
180 179 // </SPECTRAL MATRICES SIMULATOR>
181 180 //*******************************
182 181
183 182 // configure IRQ handling for the waveform picker unit
184 183 status = rtems_interrupt_catch( waveforms_isr,
185 184 IRQ_SPARC_WAVEFORM_PICKER,
186 185 &old_isr_handler) ;
187 186 // configure IRQ handling for the spectral matrices unit
188 187 status = rtems_interrupt_catch( spectral_matrices_isr,
189 188 IRQ_SPARC_SPECTRAL_MATRIX,
190 189 &old_isr_handler) ;
191 190
192 191 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
193 192 if ( status_spw != RTEMS_SUCCESSFUL )
194 193 {
195 194 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
196 195 if ( status != RTEMS_SUCCESSFUL ) {
197 196 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
198 197 }
199 198 }
200 199
201 200 BOOT_PRINTF("delete INIT\n")
202 201
203 202 send_dumb_hk();
204 203
205 204 status = rtems_task_delete(RTEMS_SELF);
206 205
207 206 }
208 207
209 208 void init_local_mode_parameters( void )
210 209 {
211 210 /** This function initialize the param_local global variable with default values.
212 211 *
213 212 */
214 213
215 214 unsigned int i;
216 215
217 216 // LOCAL PARAMETERS
218 217 set_local_nb_interrupt_f0_MAX();
219 218
220 219 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
221 220 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
222 221 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
223 222
224 223 // init sequence counters
225 224
226 225 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
227 226 {
228 227 sequenceCounters_TC_EXE[i] = 0x00;
229 228 }
230 229 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
231 230 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
232 231 }
233 232
234 233 void reset_local_time( void )
235 234 {
236 235 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
237 236 }
238 237
239 238 void create_names( void ) // create all names for tasks and queues
240 239 {
241 240 /** This function creates all RTEMS names used in the software for tasks and queues.
242 241 *
243 242 * @return RTEMS directive status codes:
244 243 * - RTEMS_SUCCESSFUL - successful completion
245 244 *
246 245 */
247 246
248 247 // task names
249 248 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
250 249 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
251 250 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
252 251 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
253 252 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
254 253 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
255 254 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
256 255 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
257 256 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
258 257 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
259 258 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
260 259 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
261 260 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
262 261 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
263 262 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
264 263 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
265 264 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
265 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
266 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
266 267
267 268 // rate monotonic period names
268 269 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
269 270
270 271 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
271 272 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
272 273 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
273 274 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
275 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
274 276 }
275 277
276 278 int create_all_tasks( void ) // create all tasks which run in the software
277 279 {
278 280 /** This function creates all RTEMS tasks used in the software.
279 281 *
280 282 * @return RTEMS directive status codes:
281 283 * - RTEMS_SUCCESSFUL - task created successfully
282 284 * - RTEMS_INVALID_ADDRESS - id is NULL
283 285 * - RTEMS_INVALID_NAME - invalid task name
284 286 * - RTEMS_INVALID_PRIORITY - invalid task priority
285 287 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
286 288 * - RTEMS_TOO_MANY - too many tasks created
287 289 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
288 290 * - RTEMS_TOO_MANY - too many global objects
289 291 *
290 292 */
291 293
292 294 rtems_status_code status;
293 295
294 296 //**********
295 297 // SPACEWIRE
296 298 // RECV
297 299 status = rtems_task_create(
298 300 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
299 301 RTEMS_DEFAULT_MODES,
300 302 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
301 303 );
302 304 if (status == RTEMS_SUCCESSFUL) // SEND
303 305 {
304 306 status = rtems_task_create(
305 307 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
306 308 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
307 309 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
308 310 );
309 311 }
310 312 if (status == RTEMS_SUCCESSFUL) // WTDG
311 313 {
312 314 status = rtems_task_create(
313 315 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
314 316 RTEMS_DEFAULT_MODES,
315 317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
316 318 );
317 319 }
318 320 if (status == RTEMS_SUCCESSFUL) // ACTN
319 321 {
320 322 status = rtems_task_create(
321 323 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
322 324 RTEMS_DEFAULT_MODES,
323 325 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
324 326 );
325 327 }
326 328 if (status == RTEMS_SUCCESSFUL) // SPIQ
327 329 {
328 330 status = rtems_task_create(
329 331 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
330 332 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
331 333 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
332 334 );
333 335 }
334 336
335 337 //******************
336 338 // SPECTRAL MATRICES
337 339 if (status == RTEMS_SUCCESSFUL) // AVF0
338 340 {
339 341 status = rtems_task_create(
340 342 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
341 343 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
342 344 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
343 345 );
344 346 }
345 347 if (status == RTEMS_SUCCESSFUL) // PRC0
346 348 {
347 349 status = rtems_task_create(
348 350 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
349 351 RTEMS_DEFAULT_MODES,
350 352 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
351 353 );
352 354 }
353 355 if (status == RTEMS_SUCCESSFUL) // AVF1
354 356 {
355 357 status = rtems_task_create(
356 358 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
357 359 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
358 360 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
359 361 );
360 362 }
361 363 if (status == RTEMS_SUCCESSFUL) // PRC1
362 364 {
363 365 status = rtems_task_create(
364 366 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
365 367 RTEMS_DEFAULT_MODES,
366 368 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
367 369 );
368 370 }
371 if (status == RTEMS_SUCCESSFUL) // AVF2
372 {
373 status = rtems_task_create(
374 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
375 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
376 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
377 );
378 }
379 if (status == RTEMS_SUCCESSFUL) // PRC2
380 {
381 status = rtems_task_create(
382 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
383 RTEMS_DEFAULT_MODES,
384 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
385 );
386 }
369 387
370 388 //****************
371 389 // WAVEFORM PICKER
372 390 if (status == RTEMS_SUCCESSFUL) // WFRM
373 391 {
374 392 status = rtems_task_create(
375 393 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
376 394 RTEMS_DEFAULT_MODES,
377 395 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
378 396 );
379 397 }
380 398 if (status == RTEMS_SUCCESSFUL) // CWF3
381 399 {
382 400 status = rtems_task_create(
383 401 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
384 402 RTEMS_DEFAULT_MODES,
385 403 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
386 404 );
387 405 }
388 406 if (status == RTEMS_SUCCESSFUL) // CWF2
389 407 {
390 408 status = rtems_task_create(
391 409 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
392 410 RTEMS_DEFAULT_MODES,
393 411 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
394 412 );
395 413 }
396 414 if (status == RTEMS_SUCCESSFUL) // CWF1
397 415 {
398 416 status = rtems_task_create(
399 417 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
400 418 RTEMS_DEFAULT_MODES,
401 419 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
402 420 );
403 421 }
404 422 if (status == RTEMS_SUCCESSFUL) // SWBD
405 423 {
406 424 status = rtems_task_create(
407 425 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
408 426 RTEMS_DEFAULT_MODES,
409 427 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
410 428 );
411 429 }
412 430
413 431 //*****
414 432 // MISC
415 433 if (status == RTEMS_SUCCESSFUL) // STAT
416 434 {
417 435 status = rtems_task_create(
418 436 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
419 437 RTEMS_DEFAULT_MODES,
420 438 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
421 439 );
422 440 }
423 441 if (status == RTEMS_SUCCESSFUL) // DUMB
424 442 {
425 443 status = rtems_task_create(
426 444 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
427 445 RTEMS_DEFAULT_MODES,
428 446 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
429 447 );
430 448 }
431 449 if (status == RTEMS_SUCCESSFUL) // HOUS
432 450 {
433 451 status = rtems_task_create(
434 452 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
435 453 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
436 454 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
437 455 );
438 456 }
439 457
440 458 return status;
441 459 }
442 460
443 461 int start_recv_send_tasks( void )
444 462 {
445 463 rtems_status_code status;
446 464
447 465 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
448 466 if (status!=RTEMS_SUCCESSFUL) {
449 467 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
450 468 }
451 469
452 470 if (status == RTEMS_SUCCESSFUL) // SEND
453 471 {
454 472 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
455 473 if (status!=RTEMS_SUCCESSFUL) {
456 474 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
457 475 }
458 476 }
459 477
460 478 return status;
461 479 }
462 480
463 481 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
464 482 {
465 483 /** This function starts all RTEMS tasks used in the software.
466 484 *
467 485 * @return RTEMS directive status codes:
468 486 * - RTEMS_SUCCESSFUL - ask started successfully
469 487 * - RTEMS_INVALID_ADDRESS - invalid task entry point
470 488 * - RTEMS_INVALID_ID - invalid task id
471 489 * - RTEMS_INCORRECT_STATE - task not in the dormant state
472 490 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
473 491 *
474 492 */
475 493 // starts all the tasks fot eh flight software
476 494
477 495 rtems_status_code status;
478 496
479 497 //**********
480 498 // SPACEWIRE
481 499 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
482 500 if (status!=RTEMS_SUCCESSFUL) {
483 501 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
484 502 }
485 503
486 504 if (status == RTEMS_SUCCESSFUL) // WTDG
487 505 {
488 506 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
489 507 if (status!=RTEMS_SUCCESSFUL) {
490 508 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
491 509 }
492 510 }
493 511
494 512 if (status == RTEMS_SUCCESSFUL) // ACTN
495 513 {
496 514 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
497 515 if (status!=RTEMS_SUCCESSFUL) {
498 516 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
499 517 }
500 518 }
501 519
502 520 //******************
503 521 // SPECTRAL MATRICES
504 522 if (status == RTEMS_SUCCESSFUL) // AVF0
505 523 {
506 524 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
507 525 if (status!=RTEMS_SUCCESSFUL) {
508 526 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
509 527 }
510 528 }
511 529 if (status == RTEMS_SUCCESSFUL) // PRC0
512 530 {
513 531 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
514 532 if (status!=RTEMS_SUCCESSFUL) {
515 533 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
516 534 }
517 535 }
518 536 if (status == RTEMS_SUCCESSFUL) // AVF1
519 537 {
520 538 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
521 539 if (status!=RTEMS_SUCCESSFUL) {
522 540 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
523 541 }
524 542 }
525 543 if (status == RTEMS_SUCCESSFUL) // PRC1
526 544 {
527 545 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
528 546 if (status!=RTEMS_SUCCESSFUL) {
529 547 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
530 548 }
531 549 }
550 if (status == RTEMS_SUCCESSFUL) // AVF2
551 {
552 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
553 if (status!=RTEMS_SUCCESSFUL) {
554 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
555 }
556 }
557 if (status == RTEMS_SUCCESSFUL) // PRC2
558 {
559 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
560 if (status!=RTEMS_SUCCESSFUL) {
561 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
562 }
563 }
532 564
533 565 //****************
534 566 // WAVEFORM PICKER
535 567 if (status == RTEMS_SUCCESSFUL) // WFRM
536 568 {
537 569 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
538 570 if (status!=RTEMS_SUCCESSFUL) {
539 571 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
540 572 }
541 573 }
542 574 if (status == RTEMS_SUCCESSFUL) // CWF3
543 575 {
544 576 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
545 577 if (status!=RTEMS_SUCCESSFUL) {
546 578 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
547 579 }
548 580 }
549 581 if (status == RTEMS_SUCCESSFUL) // CWF2
550 582 {
551 583 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
552 584 if (status!=RTEMS_SUCCESSFUL) {
553 585 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
554 586 }
555 587 }
556 588 if (status == RTEMS_SUCCESSFUL) // CWF1
557 589 {
558 590 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
559 591 if (status!=RTEMS_SUCCESSFUL) {
560 592 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
561 593 }
562 594 }
563 595 if (status == RTEMS_SUCCESSFUL) // SWBD
564 596 {
565 597 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
566 598 if (status!=RTEMS_SUCCESSFUL) {
567 599 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
568 600 }
569 601 }
570 602
571 603 //*****
572 604 // MISC
573 605 if (status == RTEMS_SUCCESSFUL) // HOUS
574 606 {
575 607 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
576 608 if (status!=RTEMS_SUCCESSFUL) {
577 609 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
578 610 }
579 611 }
580 612 if (status == RTEMS_SUCCESSFUL) // DUMB
581 613 {
582 614 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
583 615 if (status!=RTEMS_SUCCESSFUL) {
584 616 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
585 617 }
586 618 }
587 619 if (status == RTEMS_SUCCESSFUL) // STAT
588 620 {
589 621 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
590 622 if (status!=RTEMS_SUCCESSFUL) {
591 623 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
592 624 }
593 625 }
594 626
595 627 return status;
596 628 }
597 629
598 630 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
599 631 {
600 632 rtems_status_code status_recv;
601 633 rtems_status_code status_send;
602 634 rtems_status_code status_q_p0;
603 635 rtems_status_code status_q_p1;
636 rtems_status_code status_q_p2;
604 637 rtems_status_code ret;
605 638 rtems_id queue_id;
606 639
607 640 //****************************************
608 641 // create the queue for handling valid TCs
609 642 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
610 643 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
611 644 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
612 645 if ( status_recv != RTEMS_SUCCESSFUL ) {
613 646 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
614 647 }
615 648
616 649 //************************************************
617 650 // create the queue for handling TM packet sending
618 651 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
619 652 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
620 653 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
621 654 if ( status_send != RTEMS_SUCCESSFUL ) {
622 655 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
623 656 }
624 657
625 658 //*****************************************************************************
626 659 // create the queue for handling averaged spectral matrices for processing @ f0
627 660 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
628 661 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
629 662 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
630 663 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
631 664 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
632 665 }
633 666
634 667 //*****************************************************************************
635 668 // create the queue for handling averaged spectral matrices for processing @ f1
636 669 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
637 670 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
638 671 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
639 672 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
640 673 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
641 674 }
642 675
676 //*****************************************************************************
677 // create the queue for handling averaged spectral matrices for processing @ f2
678 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
679 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
680 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
681 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
682 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
683 }
684
643 685 if ( status_recv != RTEMS_SUCCESSFUL )
644 686 {
645 687 ret = status_recv;
646 688 }
647 689 else if( status_send != RTEMS_SUCCESSFUL )
648 690 {
649 691 ret = status_send;
650 692 }
651 693 else if( status_q_p0 != RTEMS_SUCCESSFUL )
652 694 {
653 695 ret = status_q_p0;
654 696 }
697 else if( status_q_p1 != RTEMS_SUCCESSFUL )
698 {
699 ret = status_q_p1;
700 }
655 701 else
656 702 {
657 ret = status_q_p1;
703 ret = status_q_p2;
658 704 }
659 705
660 706 return ret;
661 707 }
662 708
663 709 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
664 710 {
665 711 rtems_status_code status;
666 712 rtems_name queue_name;
667 713
668 714 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
669 715
670 716 status = rtems_message_queue_ident( queue_name, 0, queue_id );
671 717
672 718 return status;
673 719 }
674 720
675 721 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
676 722 {
677 723 rtems_status_code status;
678 724 rtems_name queue_name;
679 725
680 726 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
681 727
682 728 status = rtems_message_queue_ident( queue_name, 0, queue_id );
683 729
684 730 return status;
685 731 }
686 732
687 733 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
688 734 {
689 735 rtems_status_code status;
690 736 rtems_name queue_name;
691 737
692 738 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
693 739
694 740 status = rtems_message_queue_ident( queue_name, 0, queue_id );
695 741
696 742 return status;
697 743 }
698 744
699 745 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
700 746 {
701 747 rtems_status_code status;
702 748 rtems_name queue_name;
703 749
704 750 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
705 751
706 752 status = rtems_message_queue_ident( queue_name, 0, queue_id );
707 753
708 754 return status;
709 755 }
756
757 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
758 {
759 rtems_status_code status;
760 rtems_name queue_name;
761
762 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
763
764 status = rtems_message_queue_ident( queue_name, 0, queue_id );
765
766 return status;
767 }
@@ -1,921 +1,950
1 1 /** Functions and tasks related to TeleCommand handling.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TeleCommands:\n
7 7 * action launching\n
8 8 * TC parsing\n
9 9 * ...
10 10 *
11 11 */
12 12
13 13 #include "tc_handler.h"
14 14
15 15 //***********
16 16 // RTEMS TASK
17 17
18 18 rtems_task actn_task( rtems_task_argument unused )
19 19 {
20 20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 21 *
22 22 * @param unused is the starting argument of the RTEMS task
23 23 *
24 24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 25 * on the incoming TeleCommand.
26 26 *
27 27 */
28 28
29 29 int result;
30 30 rtems_status_code status; // RTEMS status code
31 31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 32 size_t size; // size of the incoming TC packet
33 33 unsigned char subtype; // subtype of the current TC packet
34 34 unsigned char time[6];
35 35 rtems_id queue_rcv_id;
36 36 rtems_id queue_snd_id;
37 37
38 38 status = get_message_queue_id_recv( &queue_rcv_id );
39 39 if (status != RTEMS_SUCCESSFUL)
40 40 {
41 41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 42 }
43 43
44 44 status = get_message_queue_id_send( &queue_snd_id );
45 45 if (status != RTEMS_SUCCESSFUL)
46 46 {
47 47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 48 }
49 49
50 50 result = LFR_SUCCESSFUL;
51 51 subtype = 0; // subtype of the current TC packet
52 52
53 53 BOOT_PRINTF("in ACTN *** \n")
54 54
55 55 while(1)
56 56 {
57 57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 59 getTime( time ); // set time to the current time
60 60 if (status!=RTEMS_SUCCESSFUL)
61 61 {
62 62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 63 }
64 64 else
65 65 {
66 66 subtype = TC.serviceSubType;
67 67 switch(subtype)
68 68 {
69 69 case TC_SUBTYPE_RESET:
70 70 result = action_reset( &TC, queue_snd_id, time );
71 71 close_action( &TC, result, queue_snd_id );
72 72 break;
73 73 //
74 74 case TC_SUBTYPE_LOAD_COMM:
75 75 result = action_load_common_par( &TC );
76 76 close_action( &TC, result, queue_snd_id );
77 77 break;
78 78 //
79 79 case TC_SUBTYPE_LOAD_NORM:
80 80 result = action_load_normal_par( &TC, queue_snd_id, time );
81 81 close_action( &TC, result, queue_snd_id );
82 82 break;
83 83 //
84 84 case TC_SUBTYPE_LOAD_BURST:
85 85 result = action_load_burst_par( &TC, queue_snd_id, time );
86 86 close_action( &TC, result, queue_snd_id );
87 87 break;
88 88 //
89 89 case TC_SUBTYPE_LOAD_SBM1:
90 90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 91 close_action( &TC, result, queue_snd_id );
92 92 break;
93 93 //
94 94 case TC_SUBTYPE_LOAD_SBM2:
95 95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 96 close_action( &TC, result, queue_snd_id );
97 97 break;
98 98 //
99 99 case TC_SUBTYPE_DUMP:
100 100 result = action_dump_par( queue_snd_id );
101 101 close_action( &TC, result, queue_snd_id );
102 102 break;
103 103 //
104 104 case TC_SUBTYPE_ENTER:
105 105 result = action_enter_mode( &TC, queue_snd_id );
106 106 close_action( &TC, result, queue_snd_id );
107 107 break;
108 108 //
109 109 case TC_SUBTYPE_UPDT_INFO:
110 110 result = action_update_info( &TC, queue_snd_id );
111 111 close_action( &TC, result, queue_snd_id );
112 112 break;
113 113 //
114 114 case TC_SUBTYPE_EN_CAL:
115 115 result = action_enable_calibration( &TC, queue_snd_id, time );
116 116 close_action( &TC, result, queue_snd_id );
117 117 break;
118 118 //
119 119 case TC_SUBTYPE_DIS_CAL:
120 120 result = action_disable_calibration( &TC, queue_snd_id, time );
121 121 close_action( &TC, result, queue_snd_id );
122 122 break;
123 123 //
124 124 case TC_SUBTYPE_UPDT_TIME:
125 125 result = action_update_time( &TC );
126 126 close_action( &TC, result, queue_snd_id );
127 127 break;
128 128 //
129 129 default:
130 130 break;
131 131 }
132 132 }
133 133 }
134 134 }
135 135
136 136 //***********
137 137 // TC ACTIONS
138 138
139 139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 140 {
141 141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 142 *
143 143 * @param TC points to the TeleCommand packet that is being processed
144 144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 145 *
146 146 */
147 147
148 148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 149 return LFR_DEFAULT;
150 150 }
151 151
152 152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
153 153 {
154 154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 155 *
156 156 * @param TC points to the TeleCommand packet that is being processed
157 157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
158 158 *
159 159 */
160 160
161 161 rtems_status_code status;
162 162 unsigned char requestedMode;
163 163 unsigned int *transitionCoarseTime_ptr;
164 164 unsigned int transitionCoarseTime;
165 165 unsigned char * bytePosPtr;
166 166
167 167 bytePosPtr = (unsigned char *) &TC->packetID;
168 168
169 169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
170 170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
171 171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
172 172
173 173 status = check_mode_value( requestedMode );
174 174
175 175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
176 176 {
177 177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
178 178 }
179 179 else // the mode value is consistent, check the transition
180 180 {
181 181 status = check_mode_transition(requestedMode);
182 182 if (status != LFR_SUCCESSFUL)
183 183 {
184 184 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
185 185 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
186 186 }
187 187 }
188 188
189 189 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
190 190 {
191 191 status = check_transition_date( transitionCoarseTime );
192 192 if (status != LFR_SUCCESSFUL)
193 193 {
194 194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
195 195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
196 196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
197 197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
198 198 }
199 199 }
200 200
201 201 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
202 202 {
203 203 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
204 204 status = enter_mode( requestedMode, transitionCoarseTime );
205 205 }
206 206
207 207 return status;
208 208 }
209 209
210 210 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
211 211 {
212 212 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
213 213 *
214 214 * @param TC points to the TeleCommand packet that is being processed
215 215 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
216 216 *
217 217 * @return LFR directive status code:
218 218 * - LFR_DEFAULT
219 219 * - LFR_SUCCESSFUL
220 220 *
221 221 */
222 222
223 223 unsigned int val;
224 224 int result;
225 225 unsigned int status;
226 226 unsigned char mode;
227 227 unsigned char * bytePosPtr;
228 228
229 229 bytePosPtr = (unsigned char *) &TC->packetID;
230 230
231 231 // check LFR mode
232 232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
233 233 status = check_update_info_hk_lfr_mode( mode );
234 234 if (status == LFR_SUCCESSFUL) // check TDS mode
235 235 {
236 236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
237 237 status = check_update_info_hk_tds_mode( mode );
238 238 }
239 239 if (status == LFR_SUCCESSFUL) // check THR mode
240 240 {
241 241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
242 242 status = check_update_info_hk_thr_mode( mode );
243 243 }
244 244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
245 245 {
246 246 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
247 247 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
248 248 val++;
249 249 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
250 250 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
251 251 }
252 252
253 253 result = status;
254 254
255 255 return result;
256 256 }
257 257
258 258 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
259 259 {
260 260 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
261 261 *
262 262 * @param TC points to the TeleCommand packet that is being processed
263 263 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
264 264 *
265 265 */
266 266
267 267 int result;
268 268 unsigned char lfrMode;
269 269
270 270 result = LFR_DEFAULT;
271 271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
272 272
273 273 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
274 274 result = LFR_DEFAULT;
275 275
276 276 return result;
277 277 }
278 278
279 279 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
280 280 {
281 281 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
282 282 *
283 283 * @param TC points to the TeleCommand packet that is being processed
284 284 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
285 285 *
286 286 */
287 287
288 288 int result;
289 289 unsigned char lfrMode;
290 290
291 291 result = LFR_DEFAULT;
292 292 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
293 293
294 294 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
295 295 result = LFR_DEFAULT;
296 296
297 297 return result;
298 298 }
299 299
300 300 int action_update_time(ccsdsTelecommandPacket_t *TC)
301 301 {
302 302 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
303 303 *
304 304 * @param TC points to the TeleCommand packet that is being processed
305 305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
306 306 *
307 307 * @return LFR_SUCCESSFUL
308 308 *
309 309 */
310 310
311 311 unsigned int val;
312 312
313 313 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
314 314 + (TC->dataAndCRC[1] << 16)
315 315 + (TC->dataAndCRC[2] << 8)
316 316 + TC->dataAndCRC[3];
317 317
318 318 PRINTF1("time received: %x\n", time_management_regs->coarse_time_load)
319 319
320 320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
321 321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
322 322 val++;
323 323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
324 324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
325 325 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
326 326
327 327 return LFR_SUCCESSFUL;
328 328 }
329 329
330 330 //*******************
331 331 // ENTERING THE MODES
332 332 int check_mode_value( unsigned char requestedMode )
333 333 {
334 334 int status;
335 335
336 336 if ( (requestedMode != LFR_MODE_STANDBY)
337 337 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
338 338 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
339 339 {
340 340 status = LFR_DEFAULT;
341 341 }
342 342 else
343 343 {
344 344 status = LFR_SUCCESSFUL;
345 345 }
346 346
347 347 return status;
348 348 }
349 349
350 350 int check_mode_transition( unsigned char requestedMode )
351 351 {
352 352 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
353 353 *
354 354 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
355 355 *
356 356 * @return LFR directive status codes:
357 357 * - LFR_SUCCESSFUL - the transition is authorized
358 358 * - LFR_DEFAULT - the transition is not authorized
359 359 *
360 360 */
361 361
362 362 int status;
363 363
364 364 switch (requestedMode)
365 365 {
366 366 case LFR_MODE_STANDBY:
367 367 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
368 368 status = LFR_DEFAULT;
369 369 }
370 370 else
371 371 {
372 372 status = LFR_SUCCESSFUL;
373 373 }
374 374 break;
375 375 case LFR_MODE_NORMAL:
376 376 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
377 377 status = LFR_DEFAULT;
378 378 }
379 379 else {
380 380 status = LFR_SUCCESSFUL;
381 381 }
382 382 break;
383 383 case LFR_MODE_BURST:
384 384 if ( lfrCurrentMode == LFR_MODE_BURST ) {
385 385 status = LFR_DEFAULT;
386 386 }
387 387 else {
388 388 status = LFR_SUCCESSFUL;
389 389 }
390 390 break;
391 391 case LFR_MODE_SBM1:
392 392 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
393 393 status = LFR_DEFAULT;
394 394 }
395 395 else {
396 396 status = LFR_SUCCESSFUL;
397 397 }
398 398 break;
399 399 case LFR_MODE_SBM2:
400 400 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
401 401 status = LFR_DEFAULT;
402 402 }
403 403 else {
404 404 status = LFR_SUCCESSFUL;
405 405 }
406 406 break;
407 407 default:
408 408 status = LFR_DEFAULT;
409 409 break;
410 410 }
411 411
412 412 return status;
413 413 }
414 414
415 415 int check_transition_date( unsigned int transitionCoarseTime )
416 416 {
417 417 int status;
418 418 unsigned int localCoarseTime;
419 419 unsigned int deltaCoarseTime;
420 420
421 421 status = LFR_SUCCESSFUL;
422 422
423 423 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
424 424 {
425 425 status = LFR_SUCCESSFUL;
426 426 }
427 427 else
428 428 {
429 429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
430 430
431 431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
432 432 {
433 433 status = LFR_DEFAULT;
434 434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
435 435 }
436 436
437 437 if (status == LFR_SUCCESSFUL)
438 438 {
439 439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
440 440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
441 441 {
442 442 status = LFR_DEFAULT;
443 443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
444 444 }
445 445 }
446 446 }
447 447
448 448 return status;
449 449 }
450 450
451 451 int stop_current_mode( void )
452 452 {
453 453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
454 454 *
455 455 * @return RTEMS directive status codes:
456 456 * - RTEMS_SUCCESSFUL - task restarted successfully
457 457 * - RTEMS_INVALID_ID - task id invalid
458 458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
459 459 *
460 460 */
461 461
462 462 rtems_status_code status;
463 463
464 464 status = RTEMS_SUCCESSFUL;
465 465
466 466 // (1) mask interruptions
467 467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
468 468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
469 469
470 470 // (2) clear interruptions
471 471 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
472 472 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
473 473
474 474 // (3) reset waveform picker registers
475 475 reset_wfp_burst_enable(); // reset burst and enable bits
476 476 reset_wfp_status(); // reset all the status bits
477 477
478 478 // (4) reset spectral matrices registers
479 479 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
480 480 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
481 481 reset_extractSWF(); // reset the extractSWF flag to false
482 482
483 483 // <Spectral Matrices simulator>
484 484 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
485 485 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
486 486 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
487 487 // </Spectral Matrices simulator>
488 488
489 489 // suspend several tasks
490 490 if (lfrCurrentMode != LFR_MODE_STANDBY) {
491 491 status = suspend_science_tasks();
492 492 }
493 493
494 494 if (status != RTEMS_SUCCESSFUL)
495 495 {
496 496 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
497 497 }
498 498
499 499 return status;
500 500 }
501 501
502 502 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
503 503 {
504 504 /** This function is launched after a mode transition validation.
505 505 *
506 506 * @param mode is the mode in which LFR will be put.
507 507 *
508 508 * @return RTEMS directive status codes:
509 509 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
510 510 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
511 511 *
512 512 */
513 513
514 514 rtems_status_code status;
515 515
516 516 //**********************
517 517 // STOP THE CURRENT MODE
518 518 status = stop_current_mode();
519 519 if (status != RTEMS_SUCCESSFUL)
520 520 {
521 521 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
522 522 }
523 523
524 524 //*************************
525 525 // ENTER THE REQUESTED MODE
526 526 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
527 527 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
528 528 {
529 529 #ifdef PRINT_TASK_STATISTICS
530 530 rtems_cpu_usage_reset();
531 531 maxCount = 0;
532 532 #endif
533 533 status = restart_science_tasks( mode );
534 534 launch_waveform_picker( mode, transitionCoarseTime );
535 535 // launch_spectral_matrix( );
536 536 launch_spectral_matrix_simu( );
537 537 }
538 538 else if ( mode == LFR_MODE_STANDBY )
539 539 {
540 540 #ifdef PRINT_TASK_STATISTICS
541 541 rtems_cpu_usage_report();
542 542 #endif
543 543
544 544 #ifdef PRINT_STACK_REPORT
545 545 PRINTF("stack report selected\n")
546 546 rtems_stack_checker_report_usage();
547 547 #endif
548 548 PRINTF1("maxCount = %d\n", maxCount)
549 549 }
550 550 else
551 551 {
552 552 status = RTEMS_UNSATISFIED;
553 553 }
554 554
555 555 if (status != RTEMS_SUCCESSFUL)
556 556 {
557 557 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
558 558 status = RTEMS_UNSATISFIED;
559 559 }
560 560
561 561 return status;
562 562 }
563 563
564 564 int restart_science_tasks(unsigned char lfrRequestedMode )
565 565 {
566 566 /** This function is used to restart all science tasks.
567 567 *
568 568 * @return RTEMS directive status codes:
569 569 * - RTEMS_SUCCESSFUL - task restarted successfully
570 570 * - RTEMS_INVALID_ID - task id invalid
571 571 * - RTEMS_INCORRECT_STATE - task never started
572 572 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
573 573 *
574 574 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
575 575 *
576 576 */
577 577
578 rtems_status_code status[8];
578 rtems_status_code status[10];
579 579 rtems_status_code ret;
580 580
581 581 ret = RTEMS_SUCCESSFUL;
582 582
583 583 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
584 584 if (status[0] != RTEMS_SUCCESSFUL)
585 585 {
586 586 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
587 587 }
588 588
589 589 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
590 590 if (status[1] != RTEMS_SUCCESSFUL)
591 591 {
592 592 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
593 593 }
594 594
595 595 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
596 596 if (status[2] != RTEMS_SUCCESSFUL)
597 597 {
598 598 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
599 599 }
600 600
601 601 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
602 602 if (status[3] != RTEMS_SUCCESSFUL)
603 603 {
604 604 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
605 605 }
606 606
607 607 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
608 608 if (status[4] != RTEMS_SUCCESSFUL)
609 609 {
610 610 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
611 611 }
612 612
613 613 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
614 614 if (status[5] != RTEMS_SUCCESSFUL)
615 615 {
616 616 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
617 617 }
618 618
619 619 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
620 620 if (status[6] != RTEMS_SUCCESSFUL)
621 621 {
622 622 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
623 623 }
624 624
625 625 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
626 626 if (status[7] != RTEMS_SUCCESSFUL)
627 627 {
628 628 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
629 629 }
630 630
631 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
632 if (status[8] != RTEMS_SUCCESSFUL)
633 {
634 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
635 }
636
637 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
638 if (status[9] != RTEMS_SUCCESSFUL)
639 {
640 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
641 }
642
631 643 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
632 644 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
633 645 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
634 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) )
646 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
647 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL))
635 648 {
636 649 ret = RTEMS_UNSATISFIED;
637 650 }
638 651
639 652 return ret;
640 653 }
641 654
642 655 int suspend_science_tasks()
643 656 {
644 657 /** This function suspends the science tasks.
645 658 *
646 659 * @return RTEMS directive status codes:
647 660 * - RTEMS_SUCCESSFUL - task restarted successfully
648 661 * - RTEMS_INVALID_ID - task id invalid
649 662 * - RTEMS_ALREADY_SUSPENDED - task already suspended
650 663 *
651 664 */
652 665
653 666 rtems_status_code status;
654 667
655 668 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
656 669 if (status != RTEMS_SUCCESSFUL)
657 670 {
658 671 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
659 672 }
660 673 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
661 674 {
662 675 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
663 676 if (status != RTEMS_SUCCESSFUL)
664 677 {
665 678 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
666 679 }
667 680 }
668 681 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
669 682 {
670 683 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
671 684 if (status != RTEMS_SUCCESSFUL)
672 685 {
673 686 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
674 687 }
675 688 }
676 689 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
677 690 {
678 691 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
679 692 if (status != RTEMS_SUCCESSFUL)
680 693 {
681 694 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
682 695 }
683 696 }
697 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
698 {
699 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
700 if (status != RTEMS_SUCCESSFUL)
701 {
702 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
703 }
704 }
705 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
706 {
707 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
708 if (status != RTEMS_SUCCESSFUL)
709 {
710 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
711 }
712 }
684 713 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
685 714 {
686 715 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
687 716 if (status != RTEMS_SUCCESSFUL)
688 717 {
689 718 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
690 719 }
691 720 }
692 721 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
693 722 {
694 723 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
695 724 if (status != RTEMS_SUCCESSFUL)
696 725 {
697 726 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
698 727 }
699 728 }
700 729 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
701 730 {
702 731 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
703 732 if (status != RTEMS_SUCCESSFUL)
704 733 {
705 734 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
706 735 }
707 736 }
708 737 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
709 738 {
710 739 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
711 740 if (status != RTEMS_SUCCESSFUL)
712 741 {
713 742 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
714 743 }
715 744 }
716 745
717 746 return status;
718 747 }
719 748
720 749 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
721 750 {
722 751 reset_current_ring_nodes();
723 752 reset_waveform_picker_regs();
724 753 set_wfp_burst_enable_register( mode );
725 754
726 755 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
727 756 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
728 757
729 758 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
730 759 if (transitionCoarseTime == 0)
731 760 {
732 761 waveform_picker_regs->start_date = time_management_regs->coarse_time;
733 762 }
734 763 else
735 764 {
736 765 waveform_picker_regs->start_date = transitionCoarseTime;
737 766 }
738 767 }
739 768
740 769 void launch_spectral_matrix( void )
741 770 {
742 771 SM_reset_current_ring_nodes();
743 ASM_reset_current_ring_nodes();
744 772 reset_spectral_matrix_regs();
773 reset_nb_sm();
745 774
746 775 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
747 776 grgpio_regs->io_port_direction_register =
748 777 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
749 778 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
750 779 set_irq_on_new_ready_matrix( 1 );
751 780 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
752 781 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
753 782 set_run_matrix_spectral( 1 );
754 783
755 784 }
756 785
757 786 void launch_spectral_matrix_simu( void )
758 787 {
759 788 SM_reset_current_ring_nodes();
760 ASM_reset_current_ring_nodes();
761 789 reset_spectral_matrix_regs();
790 reset_nb_sm();
762 791
763 792 // Spectral Matrices simulator
764 793 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
765 794 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
766 795 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
767 796 set_local_nb_interrupt_f0_MAX();
768 797 }
769 798
770 799 void set_irq_on_new_ready_matrix( unsigned char value )
771 800 {
772 801 if (value == 1)
773 802 {
774 803 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
775 804 }
776 805 else
777 806 {
778 807 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
779 808 }
780 809 }
781 810
782 811 void set_run_matrix_spectral( unsigned char value )
783 812 {
784 813 if (value == 1)
785 814 {
786 815 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
787 816 }
788 817 else
789 818 {
790 819 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
791 820 }
792 821 }
793 822
794 823 //****************
795 824 // CLOSING ACTIONS
796 825 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
797 826 {
798 827 /** This function is used to update the HK packets statistics after a successful TC execution.
799 828 *
800 829 * @param TC points to the TC being processed
801 830 * @param time is the time used to date the TC execution
802 831 *
803 832 */
804 833
805 834 unsigned int val;
806 835
807 836 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
808 837 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
809 838 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
810 839 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
811 840 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
812 841 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
813 842 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
814 843 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
815 844 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
816 845 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
817 846 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
818 847 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
819 848
820 849 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
821 850 val++;
822 851 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
823 852 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
824 853 }
825 854
826 855 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
827 856 {
828 857 /** This function is used to update the HK packets statistics after a TC rejection.
829 858 *
830 859 * @param TC points to the TC being processed
831 860 * @param time is the time used to date the TC rejection
832 861 *
833 862 */
834 863
835 864 unsigned int val;
836 865
837 866 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
838 867 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
839 868 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
840 869 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
841 870 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
842 871 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
843 872 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
844 873 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
845 874 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
846 875 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
847 876 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
848 877 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
849 878
850 879 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
851 880 val++;
852 881 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
853 882 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
854 883 }
855 884
856 885 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
857 886 {
858 887 /** This function is the last step of the TC execution workflow.
859 888 *
860 889 * @param TC points to the TC being processed
861 890 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
862 891 * @param queue_id is the id of the RTEMS message queue used to send TM packets
863 892 * @param time is the time used to date the TC execution
864 893 *
865 894 */
866 895
867 896 unsigned char requestedMode;
868 897
869 898 if (result == LFR_SUCCESSFUL)
870 899 {
871 900 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
872 901 &
873 902 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
874 903 )
875 904 {
876 905 send_tm_lfr_tc_exe_success( TC, queue_id );
877 906 }
878 907 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
879 908 {
880 909 //**********************************
881 910 // UPDATE THE LFRMODE LOCAL VARIABLE
882 911 requestedMode = TC->dataAndCRC[1];
883 912 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
884 913 updateLFRCurrentMode();
885 914 }
886 915 }
887 916 else if (result == LFR_EXE_ERROR)
888 917 {
889 918 send_tm_lfr_tc_exe_error( TC, queue_id );
890 919 }
891 920 }
892 921
893 922 //***************************
894 923 // Interrupt Service Routines
895 924 rtems_isr commutation_isr1( rtems_vector_number vector )
896 925 {
897 926 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
898 927 printf("In commutation_isr1 *** Error sending event to DUMB\n");
899 928 }
900 929 }
901 930
902 931 rtems_isr commutation_isr2( rtems_vector_number vector )
903 932 {
904 933 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
905 934 printf("In commutation_isr2 *** Error sending event to DUMB\n");
906 935 }
907 936 }
908 937
909 938 //****************
910 939 // OTHER FUNCTIONS
911 940 void updateLFRCurrentMode()
912 941 {
913 942 /** This function updates the value of the global variable lfrCurrentMode.
914 943 *
915 944 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
916 945 *
917 946 */
918 947 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
919 948 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
920 949 }
921 950
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
This diff has been collapsed as it changes many lines, (1273 lines changed) Show them Hide them
General Comments 0
You need to be logged in to leave comments. Login now