@@ -1,1172 +1,1174 | |||
|
1 | 1 | /** Functions to load and dump parameters in the LFR registers. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
7 | 7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
8 | 8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
9 | 9 | * TC_LFR_LOAD_BURST_PAR\n |
|
10 | 10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
11 | 11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
12 | 12 | * |
|
13 | 13 | */ |
|
14 | 14 | |
|
15 | 15 | #include "tc_load_dump_parameters.h" |
|
16 | 16 | |
|
17 | 17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; |
|
18 | 18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; |
|
19 | 19 | ring_node kcoefficient_node_1; |
|
20 | 20 | ring_node kcoefficient_node_2; |
|
21 | 21 | |
|
22 | 22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
23 | 23 | { |
|
24 | 24 | /** This function updates the LFR registers with the incoming common parameters. |
|
25 | 25 | * |
|
26 | 26 | * @param TC points to the TeleCommand packet that is being processed |
|
27 | 27 | * |
|
28 | 28 | * |
|
29 | 29 | */ |
|
30 | 30 | |
|
31 | 31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; |
|
32 | 32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; |
|
33 | 33 | set_wfp_data_shaping( ); |
|
34 | 34 | return LFR_SUCCESSFUL; |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
38 | 38 | { |
|
39 | 39 | /** This function updates the LFR registers with the incoming normal parameters. |
|
40 | 40 | * |
|
41 | 41 | * @param TC points to the TeleCommand packet that is being processed |
|
42 | 42 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
43 | 43 | * |
|
44 | 44 | */ |
|
45 | 45 | |
|
46 | 46 | int result; |
|
47 | 47 | int flag; |
|
48 | 48 | rtems_status_code status; |
|
49 | 49 | |
|
50 | 50 | flag = LFR_SUCCESSFUL; |
|
51 | 51 | |
|
52 | 52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
53 | 53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
54 | 54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
55 | 55 | flag = LFR_DEFAULT; |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | // CHECK THE PARAMETERS SET CONSISTENCY |
|
59 | 59 | if (flag == LFR_SUCCESSFUL) |
|
60 | 60 | { |
|
61 | 61 | flag = check_common_par_consistency( TC, queue_id ); |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT |
|
65 | 65 | if (flag == LFR_SUCCESSFUL) |
|
66 | 66 | { |
|
67 | 67 | result = set_sy_lfr_n_swf_l( TC ); |
|
68 | 68 | result = set_sy_lfr_n_swf_p( TC ); |
|
69 | 69 | result = set_sy_lfr_n_bp_p0( TC ); |
|
70 | 70 | result = set_sy_lfr_n_bp_p1( TC ); |
|
71 | 71 | result = set_sy_lfr_n_asm_p( TC ); |
|
72 | 72 | result = set_sy_lfr_n_cwf_long_f3( TC ); |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | return flag; |
|
76 | 76 | } |
|
77 | 77 | |
|
78 | 78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
79 | 79 | { |
|
80 | 80 | /** This function updates the LFR registers with the incoming burst parameters. |
|
81 | 81 | * |
|
82 | 82 | * @param TC points to the TeleCommand packet that is being processed |
|
83 | 83 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
84 | 84 | * |
|
85 | 85 | */ |
|
86 | 86 | |
|
87 | 87 | int flag; |
|
88 | 88 | rtems_status_code status; |
|
89 | 89 | unsigned char sy_lfr_b_bp_p0; |
|
90 | 90 | unsigned char sy_lfr_b_bp_p1; |
|
91 | 91 | float aux; |
|
92 | 92 | |
|
93 | 93 | flag = LFR_SUCCESSFUL; |
|
94 | 94 | |
|
95 | 95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
96 | 96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
97 | 97 | flag = LFR_DEFAULT; |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
101 | 101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
102 | 102 | |
|
103 | 103 | // sy_lfr_b_bp_p0 |
|
104 | 104 | if (flag == LFR_SUCCESSFUL) |
|
105 | 105 | { |
|
106 | 106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) |
|
107 | 107 | { |
|
108 | 108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
109 | 109 | flag = WRONG_APP_DATA; |
|
110 | 110 | } |
|
111 | 111 | } |
|
112 | 112 | // sy_lfr_b_bp_p1 |
|
113 | 113 | if (flag == LFR_SUCCESSFUL) |
|
114 | 114 | { |
|
115 | 115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) |
|
116 | 116 | { |
|
117 | 117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); |
|
118 | 118 | flag = WRONG_APP_DATA; |
|
119 | 119 | } |
|
120 | 120 | } |
|
121 | 121 | //**************************************************************** |
|
122 | 122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
123 | 123 | if (flag == LFR_SUCCESSFUL) |
|
124 | 124 | { |
|
125 | 125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
126 | 126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
127 | 127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); |
|
128 | 128 | if (aux > FLOAT_EQUAL_ZERO) |
|
129 | 129 | { |
|
130 | 130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
131 | 131 | flag = LFR_DEFAULT; |
|
132 | 132 | } |
|
133 | 133 | } |
|
134 | 134 | |
|
135 | 135 | // SET HTE PARAMETERS |
|
136 | 136 | if (flag == LFR_SUCCESSFUL) |
|
137 | 137 | { |
|
138 | 138 | flag = set_sy_lfr_b_bp_p0( TC ); |
|
139 | 139 | flag = set_sy_lfr_b_bp_p1( TC ); |
|
140 | 140 | } |
|
141 | 141 | |
|
142 | 142 | return flag; |
|
143 | 143 | } |
|
144 | 144 | |
|
145 | 145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
146 | 146 | { |
|
147 | 147 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
148 | 148 | * |
|
149 | 149 | * @param TC points to the TeleCommand packet that is being processed |
|
150 | 150 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
151 | 151 | * |
|
152 | 152 | */ |
|
153 | 153 | |
|
154 | 154 | int flag; |
|
155 | 155 | rtems_status_code status; |
|
156 | 156 | unsigned char sy_lfr_s1_bp_p0; |
|
157 | 157 | unsigned char sy_lfr_s1_bp_p1; |
|
158 | 158 | float aux; |
|
159 | 159 | |
|
160 | 160 | flag = LFR_SUCCESSFUL; |
|
161 | 161 | |
|
162 | 162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
163 | 163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
164 | 164 | flag = LFR_DEFAULT; |
|
165 | 165 | } |
|
166 | 166 | |
|
167 | 167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
168 | 168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
169 | 169 | |
|
170 | 170 | // sy_lfr_s1_bp_p0 |
|
171 | 171 | if (flag == LFR_SUCCESSFUL) |
|
172 | 172 | { |
|
173 | 173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) |
|
174 | 174 | { |
|
175 | 175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
176 | 176 | flag = WRONG_APP_DATA; |
|
177 | 177 | } |
|
178 | 178 | } |
|
179 | 179 | // sy_lfr_s1_bp_p1 |
|
180 | 180 | if (flag == LFR_SUCCESSFUL) |
|
181 | 181 | { |
|
182 | 182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) |
|
183 | 183 | { |
|
184 | 184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); |
|
185 | 185 | flag = WRONG_APP_DATA; |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | //****************************************************************** |
|
189 | 189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
190 | 190 | if (flag == LFR_SUCCESSFUL) |
|
191 | 191 | { |
|
192 | 192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); |
|
193 | 193 | if (aux > FLOAT_EQUAL_ZERO) |
|
194 | 194 | { |
|
195 | 195 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
196 | 196 | flag = LFR_DEFAULT; |
|
197 | 197 | } |
|
198 | 198 | } |
|
199 | 199 | |
|
200 | 200 | // SET THE PARAMETERS |
|
201 | 201 | if (flag == LFR_SUCCESSFUL) |
|
202 | 202 | { |
|
203 | 203 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
204 | 204 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | return flag; |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
211 | 211 | { |
|
212 | 212 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
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 related to this execution step |
|
216 | 216 | * |
|
217 | 217 | */ |
|
218 | 218 | |
|
219 | 219 | int flag; |
|
220 | 220 | rtems_status_code status; |
|
221 | 221 | unsigned char sy_lfr_s2_bp_p0; |
|
222 | 222 | unsigned char sy_lfr_s2_bp_p1; |
|
223 | 223 | float aux; |
|
224 | 224 | |
|
225 | 225 | flag = LFR_SUCCESSFUL; |
|
226 | 226 | |
|
227 | 227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
228 | 228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
229 | 229 | flag = LFR_DEFAULT; |
|
230 | 230 | } |
|
231 | 231 | |
|
232 | 232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
233 | 233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
234 | 234 | |
|
235 | 235 | // sy_lfr_s2_bp_p0 |
|
236 | 236 | if (flag == LFR_SUCCESSFUL) |
|
237 | 237 | { |
|
238 | 238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
239 | 239 | { |
|
240 | 240 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
241 | 241 | flag = WRONG_APP_DATA; |
|
242 | 242 | } |
|
243 | 243 | } |
|
244 | 244 | // sy_lfr_s2_bp_p1 |
|
245 | 245 | if (flag == LFR_SUCCESSFUL) |
|
246 | 246 | { |
|
247 | 247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
248 | 248 | { |
|
249 | 249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); |
|
250 | 250 | flag = WRONG_APP_DATA; |
|
251 | 251 | } |
|
252 | 252 | } |
|
253 | 253 | //****************************************************************** |
|
254 | 254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
255 | 255 | if (flag == LFR_SUCCESSFUL) |
|
256 | 256 | { |
|
257 | 257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
258 | 258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
259 | 259 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
260 | 260 | if (aux > FLOAT_EQUAL_ZERO) |
|
261 | 261 | { |
|
262 | 262 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
263 | 263 | flag = LFR_DEFAULT; |
|
264 | 264 | } |
|
265 | 265 | } |
|
266 | 266 | |
|
267 | 267 | // SET THE PARAMETERS |
|
268 | 268 | if (flag == LFR_SUCCESSFUL) |
|
269 | 269 | { |
|
270 | 270 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
271 | 271 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
272 | 272 | } |
|
273 | 273 | |
|
274 | 274 | return flag; |
|
275 | 275 | } |
|
276 | 276 | |
|
277 | 277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
278 | 278 | { |
|
279 | 279 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
280 | 280 | * |
|
281 | 281 | * @param TC points to the TeleCommand packet that is being processed |
|
282 | 282 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
283 | 283 | * |
|
284 | 284 | */ |
|
285 | 285 | |
|
286 | 286 | int flag; |
|
287 | 287 | |
|
288 | 288 | flag = LFR_DEFAULT; |
|
289 | 289 | |
|
290 | 290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); |
|
291 | 291 | |
|
292 | 292 | return flag; |
|
293 | 293 | } |
|
294 | 294 | |
|
295 | 295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
296 | 296 | { |
|
297 | 297 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
298 | 298 | * |
|
299 | 299 | * @param TC points to the TeleCommand packet that is being processed |
|
300 | 300 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
301 | 301 | * |
|
302 | 302 | */ |
|
303 | 303 | |
|
304 | 304 | int flag; |
|
305 | 305 | |
|
306 | 306 | flag = LFR_DEFAULT; |
|
307 | 307 | |
|
308 | 308 | flag = set_sy_lfr_fbins( TC ); |
|
309 | 309 | |
|
310 | 310 | return flag; |
|
311 | 311 | } |
|
312 | 312 | |
|
313 | 313 | void printKCoefficients(unsigned int freq, unsigned int bin, float *k_coeff) |
|
314 | 314 | { |
|
315 | 315 | printf("freq = %d *** bin = %d *** (0) %f *** (1) %f *** (2) %f *** (3) %f *** (4) %f\n", |
|
316 | 316 | freq, |
|
317 | 317 | bin, |
|
318 | 318 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 0 ], |
|
319 | 319 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 1 ], |
|
320 | 320 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 2 ], |
|
321 | 321 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 3 ], |
|
322 | 322 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 4 ]); |
|
323 | 323 | } |
|
324 | 324 | |
|
325 | 325 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
326 | 326 | { |
|
327 | 327 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
328 | 328 | * |
|
329 | 329 | * @param TC points to the TeleCommand packet that is being processed |
|
330 | 330 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
331 | 331 | * |
|
332 | 332 | */ |
|
333 | 333 | |
|
334 | 334 | unsigned int address; |
|
335 | 335 | rtems_status_code status; |
|
336 | 336 | unsigned int freq; |
|
337 | 337 | unsigned int bin; |
|
338 | 338 | unsigned int coeff; |
|
339 | 339 | unsigned char *kCoeffPtr; |
|
340 | 340 | unsigned char *kCoeffDumpPtr; |
|
341 | 341 | |
|
342 | 342 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
343 | 343 | // F0 => 11 bins |
|
344 | 344 | // F1 => 13 bins |
|
345 | 345 | // F2 => 12 bins |
|
346 | 346 | // 36 bins to dump in two packets (30 bins max per packet) |
|
347 | 347 | |
|
348 | 348 | //********* |
|
349 | 349 | // PACKET 1 |
|
350 | 350 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
351 | 351 | kcoefficients_dump_1.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
352 | 352 | kcoefficients_dump_1.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
353 | kcoefficients_dump_1.destinationID = TC->sourceID; | |
|
353 | 354 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
354 | 355 | for( freq=0; |
|
355 | 356 | freq<NB_BINS_COMPRESSED_SM_F0; |
|
356 | 357 | freq++ ) |
|
357 | 358 | { |
|
358 | 359 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; |
|
359 | 360 | bin = freq; |
|
360 | 361 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
361 | 362 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
362 | 363 | { |
|
363 | 364 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
364 | 365 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
365 | 366 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
366 | 367 | } |
|
367 | 368 | } |
|
368 | 369 | for( freq=NB_BINS_COMPRESSED_SM_F0; |
|
369 | 370 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
370 | 371 | freq++ ) |
|
371 | 372 | { |
|
372 | 373 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
373 | 374 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
374 | 375 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
375 | 376 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
376 | 377 | { |
|
377 | 378 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
378 | 379 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
379 | 380 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
380 | 381 | } |
|
381 | 382 | } |
|
382 | 383 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
383 | 384 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); |
|
384 | 385 | freq++ ) |
|
385 | 386 | { |
|
386 | 387 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
387 | 388 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
388 | 389 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
389 | 390 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
390 | 391 | { |
|
391 | 392 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
392 | 393 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
393 | 394 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
394 | 395 | } |
|
395 | 396 | } |
|
396 | 397 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
397 | 398 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
398 | 399 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
399 | 400 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
400 | 401 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
401 | 402 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
402 | 403 | // SEND DATA |
|
403 | 404 | kcoefficient_node_1.status = 1; |
|
404 | 405 | address = (unsigned int) &kcoefficient_node_1; |
|
405 | 406 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
406 | 407 | if (status != RTEMS_SUCCESSFUL) { |
|
407 | 408 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
408 | 409 | } |
|
409 | 410 | |
|
410 | 411 | //******** |
|
411 | 412 | // PACKET 2 |
|
412 | 413 | // 6 F2 bins |
|
413 | 414 | kcoefficients_dump_2.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
414 | 415 | kcoefficients_dump_2.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
416 | kcoefficients_dump_2.destinationID = TC->sourceID; | |
|
415 | 417 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
416 | 418 | for( freq=0; freq<6; freq++ ) |
|
417 | 419 | { |
|
418 | 420 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; |
|
419 | 421 | bin = freq + 6; |
|
420 | 422 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
421 | 423 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
422 | 424 | { |
|
423 | 425 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
424 | 426 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
425 | 427 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
426 | 428 | } |
|
427 | 429 | } |
|
428 | 430 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
429 | 431 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
430 | 432 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
431 | 433 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
432 | 434 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
433 | 435 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
434 | 436 | // SEND DATA |
|
435 | 437 | kcoefficient_node_2.status = 1; |
|
436 | 438 | address = (unsigned int) &kcoefficient_node_2; |
|
437 | 439 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
438 | 440 | if (status != RTEMS_SUCCESSFUL) { |
|
439 | 441 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
440 | 442 | } |
|
441 | 443 | |
|
442 | 444 | return status; |
|
443 | 445 | } |
|
444 | 446 | |
|
445 | 447 | int action_dump_par( rtems_id queue_id ) |
|
446 | 448 | { |
|
447 | 449 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
448 | 450 | * |
|
449 | 451 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
450 | 452 | * |
|
451 | 453 | * @return RTEMS directive status codes: |
|
452 | 454 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
453 | 455 | * - RTEMS_INVALID_ID - invalid queue id |
|
454 | 456 | * - RTEMS_INVALID_SIZE - invalid message size |
|
455 | 457 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
456 | 458 | * - RTEMS_UNSATISFIED - out of message buffers |
|
457 | 459 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
458 | 460 | * |
|
459 | 461 | */ |
|
460 | 462 | |
|
461 | 463 | int status; |
|
462 | 464 | |
|
463 | 465 | // UPDATE TIME |
|
464 | 466 | parameter_dump_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
465 | 467 | parameter_dump_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
466 | 468 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
467 | 469 | |
|
468 | 470 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
469 | 471 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
470 | 472 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
471 | 473 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
472 | 474 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
473 | 475 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
474 | 476 | // SEND DATA |
|
475 | 477 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
476 | 478 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
477 | 479 | if (status != RTEMS_SUCCESSFUL) { |
|
478 | 480 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
479 | 481 | } |
|
480 | 482 | |
|
481 | 483 | return status; |
|
482 | 484 | } |
|
483 | 485 | |
|
484 | 486 | //*********************** |
|
485 | 487 | // NORMAL MODE PARAMETERS |
|
486 | 488 | |
|
487 | 489 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
488 | 490 | { |
|
489 | 491 | unsigned char msb; |
|
490 | 492 | unsigned char lsb; |
|
491 | 493 | int flag; |
|
492 | 494 | float aux; |
|
493 | 495 | rtems_status_code status; |
|
494 | 496 | |
|
495 | 497 | unsigned int sy_lfr_n_swf_l; |
|
496 | 498 | unsigned int sy_lfr_n_swf_p; |
|
497 | 499 | unsigned int sy_lfr_n_asm_p; |
|
498 | 500 | unsigned char sy_lfr_n_bp_p0; |
|
499 | 501 | unsigned char sy_lfr_n_bp_p1; |
|
500 | 502 | unsigned char sy_lfr_n_cwf_long_f3; |
|
501 | 503 | |
|
502 | 504 | flag = LFR_SUCCESSFUL; |
|
503 | 505 | |
|
504 | 506 | //*************** |
|
505 | 507 | // get parameters |
|
506 | 508 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
507 | 509 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
508 | 510 | sy_lfr_n_swf_l = msb * 256 + lsb; |
|
509 | 511 | |
|
510 | 512 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
511 | 513 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
512 | 514 | sy_lfr_n_swf_p = msb * 256 + lsb; |
|
513 | 515 | |
|
514 | 516 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
515 | 517 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
516 | 518 | sy_lfr_n_asm_p = msb * 256 + lsb; |
|
517 | 519 | |
|
518 | 520 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
519 | 521 | |
|
520 | 522 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
521 | 523 | |
|
522 | 524 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
523 | 525 | |
|
524 | 526 | //****************** |
|
525 | 527 | // check consistency |
|
526 | 528 | // sy_lfr_n_swf_l |
|
527 | 529 | if (sy_lfr_n_swf_l != 2048) |
|
528 | 530 | { |
|
529 | 531 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); |
|
530 | 532 | flag = WRONG_APP_DATA; |
|
531 | 533 | } |
|
532 | 534 | // sy_lfr_n_swf_p |
|
533 | 535 | if (flag == LFR_SUCCESSFUL) |
|
534 | 536 | { |
|
535 | 537 | if ( sy_lfr_n_swf_p < 16 ) |
|
536 | 538 | { |
|
537 | 539 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); |
|
538 | 540 | flag = WRONG_APP_DATA; |
|
539 | 541 | } |
|
540 | 542 | } |
|
541 | 543 | // sy_lfr_n_bp_p0 |
|
542 | 544 | if (flag == LFR_SUCCESSFUL) |
|
543 | 545 | { |
|
544 | 546 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
545 | 547 | { |
|
546 | 548 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
547 | 549 | flag = WRONG_APP_DATA; |
|
548 | 550 | } |
|
549 | 551 | } |
|
550 | 552 | // sy_lfr_n_asm_p |
|
551 | 553 | if (flag == LFR_SUCCESSFUL) |
|
552 | 554 | { |
|
553 | 555 | if (sy_lfr_n_asm_p == 0) |
|
554 | 556 | { |
|
555 | 557 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
556 | 558 | flag = WRONG_APP_DATA; |
|
557 | 559 | } |
|
558 | 560 | } |
|
559 | 561 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
560 | 562 | if (flag == LFR_SUCCESSFUL) |
|
561 | 563 | { |
|
562 | 564 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
563 | 565 | if (aux > FLOAT_EQUAL_ZERO) |
|
564 | 566 | { |
|
565 | 567 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
566 | 568 | flag = WRONG_APP_DATA; |
|
567 | 569 | } |
|
568 | 570 | } |
|
569 | 571 | // sy_lfr_n_bp_p1 |
|
570 | 572 | if (flag == LFR_SUCCESSFUL) |
|
571 | 573 | { |
|
572 | 574 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
573 | 575 | { |
|
574 | 576 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
575 | 577 | flag = WRONG_APP_DATA; |
|
576 | 578 | } |
|
577 | 579 | } |
|
578 | 580 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
579 | 581 | if (flag == LFR_SUCCESSFUL) |
|
580 | 582 | { |
|
581 | 583 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
582 | 584 | if (aux > FLOAT_EQUAL_ZERO) |
|
583 | 585 | { |
|
584 | 586 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
585 | 587 | flag = LFR_DEFAULT; |
|
586 | 588 | } |
|
587 | 589 | } |
|
588 | 590 | // sy_lfr_n_cwf_long_f3 |
|
589 | 591 | |
|
590 | 592 | return flag; |
|
591 | 593 | } |
|
592 | 594 | |
|
593 | 595 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
594 | 596 | { |
|
595 | 597 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
596 | 598 | * |
|
597 | 599 | * @param TC points to the TeleCommand packet that is being processed |
|
598 | 600 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
599 | 601 | * |
|
600 | 602 | */ |
|
601 | 603 | |
|
602 | 604 | int result; |
|
603 | 605 | |
|
604 | 606 | result = LFR_SUCCESSFUL; |
|
605 | 607 | |
|
606 | 608 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
607 | 609 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
608 | 610 | |
|
609 | 611 | return result; |
|
610 | 612 | } |
|
611 | 613 | |
|
612 | 614 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
613 | 615 | { |
|
614 | 616 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
615 | 617 | * |
|
616 | 618 | * @param TC points to the TeleCommand packet that is being processed |
|
617 | 619 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
618 | 620 | * |
|
619 | 621 | */ |
|
620 | 622 | |
|
621 | 623 | int result; |
|
622 | 624 | |
|
623 | 625 | result = LFR_SUCCESSFUL; |
|
624 | 626 | |
|
625 | 627 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
626 | 628 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
627 | 629 | |
|
628 | 630 | return result; |
|
629 | 631 | } |
|
630 | 632 | |
|
631 | 633 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
632 | 634 | { |
|
633 | 635 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
634 | 636 | * |
|
635 | 637 | * @param TC points to the TeleCommand packet that is being processed |
|
636 | 638 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
637 | 639 | * |
|
638 | 640 | */ |
|
639 | 641 | |
|
640 | 642 | int result; |
|
641 | 643 | |
|
642 | 644 | result = LFR_SUCCESSFUL; |
|
643 | 645 | |
|
644 | 646 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
645 | 647 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
646 | 648 | |
|
647 | 649 | return result; |
|
648 | 650 | } |
|
649 | 651 | |
|
650 | 652 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
651 | 653 | { |
|
652 | 654 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
653 | 655 | * |
|
654 | 656 | * @param TC points to the TeleCommand packet that is being processed |
|
655 | 657 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
656 | 658 | * |
|
657 | 659 | */ |
|
658 | 660 | |
|
659 | 661 | int status; |
|
660 | 662 | |
|
661 | 663 | status = LFR_SUCCESSFUL; |
|
662 | 664 | |
|
663 | 665 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
664 | 666 | |
|
665 | 667 | return status; |
|
666 | 668 | } |
|
667 | 669 | |
|
668 | 670 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
669 | 671 | { |
|
670 | 672 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
671 | 673 | * |
|
672 | 674 | * @param TC points to the TeleCommand packet that is being processed |
|
673 | 675 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
674 | 676 | * |
|
675 | 677 | */ |
|
676 | 678 | |
|
677 | 679 | int status; |
|
678 | 680 | |
|
679 | 681 | status = LFR_SUCCESSFUL; |
|
680 | 682 | |
|
681 | 683 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
682 | 684 | |
|
683 | 685 | return status; |
|
684 | 686 | } |
|
685 | 687 | |
|
686 | 688 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
687 | 689 | { |
|
688 | 690 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
689 | 691 | * |
|
690 | 692 | * @param TC points to the TeleCommand packet that is being processed |
|
691 | 693 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
692 | 694 | * |
|
693 | 695 | */ |
|
694 | 696 | |
|
695 | 697 | int status; |
|
696 | 698 | |
|
697 | 699 | status = LFR_SUCCESSFUL; |
|
698 | 700 | |
|
699 | 701 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
700 | 702 | |
|
701 | 703 | return status; |
|
702 | 704 | } |
|
703 | 705 | |
|
704 | 706 | //********************** |
|
705 | 707 | // BURST MODE PARAMETERS |
|
706 | 708 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
707 | 709 | { |
|
708 | 710 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
709 | 711 | * |
|
710 | 712 | * @param TC points to the TeleCommand packet that is being processed |
|
711 | 713 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
712 | 714 | * |
|
713 | 715 | */ |
|
714 | 716 | |
|
715 | 717 | int status; |
|
716 | 718 | |
|
717 | 719 | status = LFR_SUCCESSFUL; |
|
718 | 720 | |
|
719 | 721 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
720 | 722 | |
|
721 | 723 | return status; |
|
722 | 724 | } |
|
723 | 725 | |
|
724 | 726 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
725 | 727 | { |
|
726 | 728 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
727 | 729 | * |
|
728 | 730 | * @param TC points to the TeleCommand packet that is being processed |
|
729 | 731 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
730 | 732 | * |
|
731 | 733 | */ |
|
732 | 734 | |
|
733 | 735 | int status; |
|
734 | 736 | |
|
735 | 737 | status = LFR_SUCCESSFUL; |
|
736 | 738 | |
|
737 | 739 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
738 | 740 | |
|
739 | 741 | return status; |
|
740 | 742 | } |
|
741 | 743 | |
|
742 | 744 | //********************* |
|
743 | 745 | // SBM1 MODE PARAMETERS |
|
744 | 746 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
745 | 747 | { |
|
746 | 748 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
747 | 749 | * |
|
748 | 750 | * @param TC points to the TeleCommand packet that is being processed |
|
749 | 751 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
750 | 752 | * |
|
751 | 753 | */ |
|
752 | 754 | |
|
753 | 755 | int status; |
|
754 | 756 | |
|
755 | 757 | status = LFR_SUCCESSFUL; |
|
756 | 758 | |
|
757 | 759 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
758 | 760 | |
|
759 | 761 | return status; |
|
760 | 762 | } |
|
761 | 763 | |
|
762 | 764 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
763 | 765 | { |
|
764 | 766 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
765 | 767 | * |
|
766 | 768 | * @param TC points to the TeleCommand packet that is being processed |
|
767 | 769 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
768 | 770 | * |
|
769 | 771 | */ |
|
770 | 772 | |
|
771 | 773 | int status; |
|
772 | 774 | |
|
773 | 775 | status = LFR_SUCCESSFUL; |
|
774 | 776 | |
|
775 | 777 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
776 | 778 | |
|
777 | 779 | return status; |
|
778 | 780 | } |
|
779 | 781 | |
|
780 | 782 | //********************* |
|
781 | 783 | // SBM2 MODE PARAMETERS |
|
782 | 784 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
783 | 785 | { |
|
784 | 786 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
785 | 787 | * |
|
786 | 788 | * @param TC points to the TeleCommand packet that is being processed |
|
787 | 789 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
788 | 790 | * |
|
789 | 791 | */ |
|
790 | 792 | |
|
791 | 793 | int status; |
|
792 | 794 | |
|
793 | 795 | status = LFR_SUCCESSFUL; |
|
794 | 796 | |
|
795 | 797 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
796 | 798 | |
|
797 | 799 | return status; |
|
798 | 800 | } |
|
799 | 801 | |
|
800 | 802 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
801 | 803 | { |
|
802 | 804 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
803 | 805 | * |
|
804 | 806 | * @param TC points to the TeleCommand packet that is being processed |
|
805 | 807 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
806 | 808 | * |
|
807 | 809 | */ |
|
808 | 810 | |
|
809 | 811 | int status; |
|
810 | 812 | |
|
811 | 813 | status = LFR_SUCCESSFUL; |
|
812 | 814 | |
|
813 | 815 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
814 | 816 | |
|
815 | 817 | return status; |
|
816 | 818 | } |
|
817 | 819 | |
|
818 | 820 | //******************* |
|
819 | 821 | // TC_LFR_UPDATE_INFO |
|
820 | 822 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
821 | 823 | { |
|
822 | 824 | unsigned int status; |
|
823 | 825 | |
|
824 | 826 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
825 | 827 | || (mode == LFR_MODE_BURST) |
|
826 | 828 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
827 | 829 | { |
|
828 | 830 | status = LFR_SUCCESSFUL; |
|
829 | 831 | } |
|
830 | 832 | else |
|
831 | 833 | { |
|
832 | 834 | status = LFR_DEFAULT; |
|
833 | 835 | } |
|
834 | 836 | |
|
835 | 837 | return status; |
|
836 | 838 | } |
|
837 | 839 | |
|
838 | 840 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
839 | 841 | { |
|
840 | 842 | unsigned int status; |
|
841 | 843 | |
|
842 | 844 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
843 | 845 | || (mode == TDS_MODE_BURST) |
|
844 | 846 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
845 | 847 | || (mode == TDS_MODE_LFM)) |
|
846 | 848 | { |
|
847 | 849 | status = LFR_SUCCESSFUL; |
|
848 | 850 | } |
|
849 | 851 | else |
|
850 | 852 | { |
|
851 | 853 | status = LFR_DEFAULT; |
|
852 | 854 | } |
|
853 | 855 | |
|
854 | 856 | return status; |
|
855 | 857 | } |
|
856 | 858 | |
|
857 | 859 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
858 | 860 | { |
|
859 | 861 | unsigned int status; |
|
860 | 862 | |
|
861 | 863 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
862 | 864 | || (mode == THR_MODE_BURST)) |
|
863 | 865 | { |
|
864 | 866 | status = LFR_SUCCESSFUL; |
|
865 | 867 | } |
|
866 | 868 | else |
|
867 | 869 | { |
|
868 | 870 | status = LFR_DEFAULT; |
|
869 | 871 | } |
|
870 | 872 | |
|
871 | 873 | return status; |
|
872 | 874 | } |
|
873 | 875 | |
|
874 | 876 | //*********** |
|
875 | 877 | // FBINS MASK |
|
876 | 878 | |
|
877 | 879 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
878 | 880 | { |
|
879 | 881 | int status; |
|
880 | 882 | unsigned int k; |
|
881 | 883 | unsigned char *fbins_mask_dump; |
|
882 | 884 | unsigned char *fbins_mask_TC; |
|
883 | 885 | |
|
884 | 886 | status = LFR_SUCCESSFUL; |
|
885 | 887 | |
|
886 | 888 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
887 | 889 | fbins_mask_TC = TC->dataAndCRC; |
|
888 | 890 | |
|
889 | 891 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
890 | 892 | { |
|
891 | 893 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
892 | 894 | } |
|
893 | 895 | for (k=0; k < NB_FBINS_MASKS; k++) |
|
894 | 896 | { |
|
895 | 897 | unsigned char *auxPtr; |
|
896 | 898 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; |
|
897 | 899 | printf("%x %x %x %x\n", auxPtr[0], auxPtr[1], auxPtr[2], auxPtr[3]); |
|
898 | 900 | } |
|
899 | 901 | |
|
900 | 902 | |
|
901 | 903 | return status; |
|
902 | 904 | } |
|
903 | 905 | |
|
904 | 906 | //************** |
|
905 | 907 | // KCOEFFICIENTS |
|
906 | 908 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
907 | 909 | { |
|
908 | 910 | unsigned int kcoeff; |
|
909 | 911 | unsigned short sy_lfr_kcoeff_frequency; |
|
910 | 912 | unsigned short bin; |
|
911 | 913 | unsigned short *freqPtr; |
|
912 | 914 | float *kcoeffPtr_norm; |
|
913 | 915 | float *kcoeffPtr_sbm; |
|
914 | 916 | int status; |
|
915 | 917 | unsigned char *kcoeffLoadPtr; |
|
916 | 918 | unsigned char *kcoeffNormPtr; |
|
917 | 919 | unsigned char *kcoeffSbmPtr_a; |
|
918 | 920 | unsigned char *kcoeffSbmPtr_b; |
|
919 | 921 | |
|
920 | 922 | status = LFR_SUCCESSFUL; |
|
921 | 923 | |
|
922 | 924 | kcoeffPtr_norm = NULL; |
|
923 | 925 | kcoeffPtr_sbm = NULL; |
|
924 | 926 | bin = 0; |
|
925 | 927 | |
|
926 | 928 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; |
|
927 | 929 | sy_lfr_kcoeff_frequency = *freqPtr; |
|
928 | 930 | |
|
929 | 931 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
930 | 932 | { |
|
931 | 933 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
932 | 934 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, |
|
933 | 935 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
934 | 936 | status = LFR_DEFAULT; |
|
935 | 937 | } |
|
936 | 938 | else |
|
937 | 939 | { |
|
938 | 940 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
939 | 941 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
940 | 942 | { |
|
941 | 943 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
942 | 944 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
943 | 945 | bin = sy_lfr_kcoeff_frequency; |
|
944 | 946 | } |
|
945 | 947 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
946 | 948 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
947 | 949 | { |
|
948 | 950 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
949 | 951 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
950 | 952 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
951 | 953 | } |
|
952 | 954 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
953 | 955 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
954 | 956 | { |
|
955 | 957 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
956 | 958 | kcoeffPtr_sbm = NULL; |
|
957 | 959 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
958 | 960 | } |
|
959 | 961 | } |
|
960 | 962 | |
|
961 | 963 | printf("in set_sy_lfr_kcoeff *** freq = %d, bin = %d\n", sy_lfr_kcoeff_frequency, bin); |
|
962 | 964 | |
|
963 | 965 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
964 | 966 | { |
|
965 | 967 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
966 | 968 | { |
|
967 | 969 | // destination |
|
968 | 970 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
969 | 971 | // source |
|
970 | 972 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
971 | 973 | // copy source to destination |
|
972 | 974 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
973 | 975 | } |
|
974 | 976 | } |
|
975 | 977 | |
|
976 | 978 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
977 | 979 | { |
|
978 | 980 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
979 | 981 | { |
|
980 | 982 | // destination |
|
981 | 983 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; |
|
982 | 984 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; |
|
983 | 985 | // source |
|
984 | 986 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
985 | 987 | // copy source to destination |
|
986 | 988 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
987 | 989 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
988 | 990 | } |
|
989 | 991 | } |
|
990 | 992 | |
|
991 | 993 | // print_k_coeff(); |
|
992 | 994 | |
|
993 | 995 | return status; |
|
994 | 996 | } |
|
995 | 997 | |
|
996 | 998 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
997 | 999 | { |
|
998 | 1000 | destination[0] = source[0]; |
|
999 | 1001 | destination[1] = source[1]; |
|
1000 | 1002 | destination[2] = source[2]; |
|
1001 | 1003 | destination[3] = source[3]; |
|
1002 | 1004 | } |
|
1003 | 1005 | |
|
1004 | 1006 | //********** |
|
1005 | 1007 | // init dump |
|
1006 | 1008 | |
|
1007 | 1009 | void init_parameter_dump( void ) |
|
1008 | 1010 | { |
|
1009 | 1011 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
1010 | 1012 | * |
|
1011 | 1013 | */ |
|
1012 | 1014 | |
|
1013 | 1015 | unsigned int k; |
|
1014 | 1016 | |
|
1015 | 1017 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1016 | 1018 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1017 | 1019 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
1018 | 1020 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1019 | 1021 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
1020 | 1022 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1021 | 1023 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1022 | 1024 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1023 | 1025 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
1024 | 1026 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1025 | 1027 | // DATA FIELD HEADER |
|
1026 | 1028 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1027 | 1029 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1028 | 1030 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1029 | 1031 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1030 | 1032 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1031 | 1033 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1032 | 1034 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1033 | 1035 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1034 | 1036 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1035 | 1037 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1036 | 1038 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1037 | 1039 | |
|
1038 | 1040 | //****************** |
|
1039 | 1041 | // COMMON PARAMETERS |
|
1040 | 1042 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1041 | 1043 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1042 | 1044 | |
|
1043 | 1045 | //****************** |
|
1044 | 1046 | // NORMAL PARAMETERS |
|
1045 | 1047 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); |
|
1046 | 1048 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1047 | 1049 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); |
|
1048 | 1050 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1049 | 1051 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); |
|
1050 | 1052 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1051 | 1053 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1052 | 1054 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1053 | 1055 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1054 | 1056 | |
|
1055 | 1057 | //***************** |
|
1056 | 1058 | // BURST PARAMETERS |
|
1057 | 1059 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1058 | 1060 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1059 | 1061 | |
|
1060 | 1062 | //**************** |
|
1061 | 1063 | // SBM1 PARAMETERS |
|
1062 | 1064 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period |
|
1063 | 1065 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1064 | 1066 | |
|
1065 | 1067 | //**************** |
|
1066 | 1068 | // SBM2 PARAMETERS |
|
1067 | 1069 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1068 | 1070 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1069 | 1071 | |
|
1070 | 1072 | //************ |
|
1071 | 1073 | // FBINS MASKS |
|
1072 | 1074 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1073 | 1075 | { |
|
1074 | 1076 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; |
|
1075 | 1077 | } |
|
1076 | 1078 | } |
|
1077 | 1079 | |
|
1078 | 1080 | void init_kcoefficients_dump( void ) |
|
1079 | 1081 | { |
|
1080 | 1082 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); |
|
1081 | 1083 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); |
|
1082 | 1084 | |
|
1083 | 1085 | kcoefficient_node_1.previous = NULL; |
|
1084 | 1086 | kcoefficient_node_1.next = NULL; |
|
1085 | 1087 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1086 | 1088 | kcoefficient_node_1.coarseTime = 0x00; |
|
1087 | 1089 | kcoefficient_node_1.fineTime = 0x00; |
|
1088 | 1090 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1089 | 1091 | kcoefficient_node_1.status = 0x00; |
|
1090 | 1092 | |
|
1091 | 1093 | kcoefficient_node_2.previous = NULL; |
|
1092 | 1094 | kcoefficient_node_2.next = NULL; |
|
1093 | 1095 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1094 | 1096 | kcoefficient_node_2.coarseTime = 0x00; |
|
1095 | 1097 | kcoefficient_node_2.fineTime = 0x00; |
|
1096 | 1098 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1097 | 1099 | kcoefficient_node_2.status = 0x00; |
|
1098 | 1100 | } |
|
1099 | 1101 | |
|
1100 | 1102 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1101 | 1103 | { |
|
1102 | 1104 | unsigned int k; |
|
1103 | 1105 | unsigned int packetLength; |
|
1104 | 1106 | |
|
1105 | 1107 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1106 | 1108 | |
|
1107 | 1109 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1108 | 1110 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1109 | 1111 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1110 | 1112 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1111 | 1113 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; |
|
1112 | 1114 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; |
|
1113 | 1115 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1114 | 1116 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1115 | 1117 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
1116 | 1118 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1117 | 1119 | // DATA FIELD HEADER |
|
1118 | 1120 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1119 | 1121 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1120 | 1122 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1121 | 1123 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1122 | 1124 | kcoefficients_dump->time[0] = 0x00; |
|
1123 | 1125 | kcoefficients_dump->time[1] = 0x00; |
|
1124 | 1126 | kcoefficients_dump->time[2] = 0x00; |
|
1125 | 1127 | kcoefficients_dump->time[3] = 0x00; |
|
1126 | 1128 | kcoefficients_dump->time[4] = 0x00; |
|
1127 | 1129 | kcoefficients_dump->time[5] = 0x00; |
|
1128 | 1130 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1129 | 1131 | |
|
1130 | 1132 | kcoefficients_dump->pkt_cnt = 2; |
|
1131 | 1133 | kcoefficients_dump->pkt_nr = pkt_nr; |
|
1132 | 1134 | kcoefficients_dump->blk_nr = blk_nr; |
|
1133 | 1135 | |
|
1134 | 1136 | //****************** |
|
1135 | 1137 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1136 | 1138 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1137 | 1139 | for (k=0; k<3900; k++) |
|
1138 | 1140 | { |
|
1139 | 1141 | kcoefficients_dump->kcoeff_blks[k] = 0x00; |
|
1140 | 1142 | } |
|
1141 | 1143 | } |
|
1142 | 1144 | |
|
1143 | 1145 | void print_k_coeff() |
|
1144 | 1146 | { |
|
1145 | 1147 | unsigned int kcoeff; |
|
1146 | 1148 | unsigned int bin; |
|
1147 | 1149 | |
|
1148 | 1150 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1149 | 1151 | { |
|
1150 | 1152 | printf("kcoeff = %d *** ", kcoeff); |
|
1151 | 1153 | for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++) |
|
1152 | 1154 | { |
|
1153 | 1155 | printf( "%f ", k_coeff_intercalib_f0_norm[bin*NB_K_COEFF_PER_BIN+kcoeff] ); |
|
1154 | 1156 | } |
|
1155 | 1157 | printf("\n"); |
|
1156 | 1158 | } |
|
1157 | 1159 | |
|
1158 | 1160 | printf("\n"); |
|
1159 | 1161 | |
|
1160 | 1162 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1161 | 1163 | { |
|
1162 | 1164 | printf("kcoeff = %d *** ", kcoeff); |
|
1163 | 1165 | for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++) |
|
1164 | 1166 | { |
|
1165 | 1167 | printf( "[%f, %f] ", |
|
1166 | 1168 | k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN )*2 + kcoeff], |
|
1167 | 1169 | k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN+1)*2 + kcoeff]); |
|
1168 | 1170 | } |
|
1169 | 1171 | printf("\n"); |
|
1170 | 1172 | } |
|
1171 | 1173 | } |
|
1172 | 1174 |
General Comments 0
You need to be logged in to leave comments.
Login now