##// END OF EJS Templates
Bug 85
paul -
r146:7dc1808bbf1e VHDLib206
parent child
Show More
@@ -1,812 +1,878
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 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 18 {
19 19 /** This function updates the LFR registers with the incoming common parameters.
20 20 *
21 21 * @param TC points to the TeleCommand packet that is being processed
22 22 *
23 23 *
24 24 */
25 25
26 26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
27 27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
28 28 set_wfp_data_shaping( );
29 29 return LFR_SUCCESSFUL;
30 30 }
31 31
32 32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
33 33 {
34 34 /** This function updates the LFR registers with the incoming normal parameters.
35 35 *
36 36 * @param TC points to the TeleCommand packet that is being processed
37 37 * @param queue_id is the id of the queue which handles TM related to this execution step
38 38 *
39 39 */
40 40
41 41 int result;
42 42 int flag;
43 43 rtems_status_code status;
44 44 unsigned char sy_lfr_n_bp_p0;
45 45 unsigned char sy_lfr_n_bp_p1;
46 46 unsigned int sy_lfr_n_asm_p;
47 47 float aux;
48 48
49 49 flag = LFR_SUCCESSFUL;
50 50
51 51 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
52 52 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
53 53 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
54 54 flag = LFR_DEFAULT;
55 55 }
56 56
57 57 //***************
58 58 // sy_lfr_n_swf_l
59 59 if (flag == LFR_SUCCESSFUL)
60 60 {
61 61 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
62 62 if (result != LFR_SUCCESSFUL)
63 63 {
64 64 flag = LFR_DEFAULT;
65 65 }
66 66 }
67 67
68 68 //***************
69 69 // sy_lfr_n_swf_p
70 70 if (flag == LFR_SUCCESSFUL)
71 71 {
72 72 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
73 73 if (result != LFR_SUCCESSFUL)
74 74 {
75 75 flag = LFR_DEFAULT;
76 76 }
77 77 }
78 78
79 79 //****************************************************************
80 80 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
81 81 if (flag == LFR_SUCCESSFUL)
82 82 {
83 83 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
84 84 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
85 85 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
86 86 if (aux != 0)
87 87 {
88 88 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
89 89 flag = LFR_DEFAULT;
90 90 }
91 91 }
92 92
93 93 //***************
94 94 // sy_lfr_n_bp_p0
95 95 if (flag == LFR_SUCCESSFUL)
96 96 {
97 97 result = set_sy_lfr_n_bp_p0( TC, queue_id );
98 98 if (result != LFR_SUCCESSFUL)
99 99 {
100 100 flag = LFR_DEFAULT;
101 101 }
102 102 }
103 103
104 104 //****************************************************************
105 105 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
106 106 if (flag == LFR_SUCCESSFUL)
107 107 {
108 108 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
109 109 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
110 110 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
111 111 if (aux != 0)
112 112 {
113 113 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
114 114 flag = LFR_DEFAULT;
115 115 }
116 116 }
117 117
118 118 //***************
119 119 // sy_lfr_n_bp_p1
120 120 if (flag == LFR_SUCCESSFUL)
121 121 {
122 122 result = set_sy_lfr_n_bp_p1( TC, queue_id );
123 123 if (result != LFR_SUCCESSFUL)
124 124 {
125 125 flag = LFR_DEFAULT;
126 126 }
127 127 }
128 128
129 129 //****************************************************************
130 130 // check the consistency between sy_lfr_n_asm_p and sy_lfr_n_bp_p0
131 131 if (flag == LFR_SUCCESSFUL)
132 132 {
133 133 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
134 134 sy_lfr_n_asm_p =
135 135 TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ] * 256
136 136 + TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P + 1 ];
137 137 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
138 138 if (aux != 0)
139 139 {
140 140 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
141 141 flag = LFR_DEFAULT;
142 142 }
143 143 }
144 144
145 145 //***************
146 146 // sy_lfr_n_asm_p
147 147 if (flag == LFR_SUCCESSFUL)
148 148 {
149 149 result = set_sy_lfr_n_asm_p( TC, queue_id );
150 150 if (result != LFR_SUCCESSFUL)
151 151 {
152 152 flag = LFR_DEFAULT;
153 153 }
154 154 }
155 155
156 156 //*********************
157 157 // sy_lfr_n_cwf_long_f3
158 158 if (flag == LFR_SUCCESSFUL)
159 159 {
160 160 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
161 161 if (result != LFR_SUCCESSFUL)
162 162 {
163 163 flag = LFR_DEFAULT;
164 164 }
165 165 }
166 166
167 167 return flag;
168 168 }
169 169
170 170 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
171 171 {
172 172 /** This function updates the LFR registers with the incoming burst parameters.
173 173 *
174 174 * @param TC points to the TeleCommand packet that is being processed
175 175 * @param queue_id is the id of the queue which handles TM related to this execution step
176 176 *
177 177 */
178 178
179 179 int result;
180 180 int flag;
181 181 rtems_status_code status;
182 182 unsigned char sy_lfr_b_bp_p0;
183 183 unsigned char sy_lfr_b_bp_p1;
184 184 float aux;
185 185
186 186 flag = LFR_SUCCESSFUL;
187 187
188 188 if ( lfrCurrentMode == LFR_MODE_BURST ) {
189 189 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
190 190 result = LFR_DEFAULT;
191 191 }
192 192
193 193 //****************************************************************
194 194 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
195 195 if (flag == LFR_SUCCESSFUL)
196 196 {
197 197 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
198 198 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
199 199 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
200 200 if (aux != 0)
201 201 {
202 202 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
203 203 flag = LFR_DEFAULT;
204 204 }
205 205 }
206 206
207 207 //***************
208 208 // sy_lfr_b_bp_p0
209 209 if (flag == LFR_SUCCESSFUL)
210 210 {
211 211 result = set_sy_lfr_b_bp_p0( TC, queue_id );
212 212 if (result != LFR_SUCCESSFUL)
213 213 {
214 214 flag = LFR_DEFAULT;
215 215 }
216 216 }
217 217
218 218 //***************
219 219 // sy_lfr_b_bp_p1
220 220 if (flag == LFR_SUCCESSFUL)
221 221 {
222 222 result = set_sy_lfr_b_bp_p1( TC, queue_id );
223 223 if (result != LFR_SUCCESSFUL)
224 224 {
225 225 flag = LFR_DEFAULT;
226 226 }
227 227 }
228 228
229 229 return flag;
230 230 }
231 231
232 232 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
233 233 {
234 234 /** This function updates the LFR registers with the incoming sbm1 parameters.
235 235 *
236 236 * @param TC points to the TeleCommand packet that is being processed
237 237 * @param queue_id is the id of the queue which handles TM related to this execution step
238 238 *
239 239 */
240 240
241 241 int result;
242 242 int flag;
243 243 rtems_status_code status;
244 244 unsigned char sy_lfr_s1_bp_p0;
245 245 unsigned char sy_lfr_s1_bp_p1;
246 246 float aux;
247 247
248 248 flag = LFR_SUCCESSFUL;
249 249
250 250 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
251 251 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
252 252 result = LFR_DEFAULT;
253 253 }
254 254
255 255 //******************************************************************
256 256 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
257 257 if (flag == LFR_SUCCESSFUL)
258 258 {
259 259 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
260 260 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
261 261 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));
262 262 if (aux != 0)
263 263 {
264 264 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
265 265 flag = LFR_DEFAULT;
266 266 }
267 267 }
268 268
269 269 //***************
270 270 // sy_lfr_s1_bp_p0
271 271 if (flag == LFR_SUCCESSFUL)
272 272 {
273 273 result = set_sy_lfr_s1_bp_p0( TC, queue_id );
274 274 if (result != LFR_SUCCESSFUL)
275 275 {
276 276 flag = LFR_DEFAULT;
277 277 }
278 278 }
279 279
280 280 //***************
281 281 // sy_lfr_s1_bp_p1
282 282 if (flag == LFR_SUCCESSFUL)
283 283 {
284 284 result = set_sy_lfr_s1_bp_p1( TC, queue_id );
285 285 if (result != LFR_SUCCESSFUL)
286 286 {
287 287 flag = LFR_DEFAULT;
288 288 }
289 289 }
290 290
291 291 return flag;
292 292 }
293 293
294 294 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
295 295 {
296 296 /** This function updates the LFR registers with the incoming sbm2 parameters.
297 297 *
298 298 * @param TC points to the TeleCommand packet that is being processed
299 299 * @param queue_id is the id of the queue which handles TM related to this execution step
300 300 *
301 301 */
302 302
303 303 int result;
304 304 int flag;
305 305 rtems_status_code status;
306 306 unsigned char sy_lfr_s2_bp_p0;
307 307 unsigned char sy_lfr_s2_bp_p1;
308 308 float aux;
309 309
310 310 flag = LFR_SUCCESSFUL;
311 311
312 312 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
313 313 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
314 314 result = LFR_DEFAULT;
315 315 }
316 316
317 317 //******************************************************************
318 318 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
319 319 if (flag == LFR_SUCCESSFUL)
320 320 {
321 321 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
322 322 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
323 323 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
324 324 if (aux != 0)
325 325 {
326 326 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
327 327 flag = LFR_DEFAULT;
328 328 }
329 329 }
330 330
331 331 //***************
332 332 // sy_lfr_s2_bp_p0
333 333 if (flag == LFR_SUCCESSFUL)
334 334 {
335 335 result = set_sy_lfr_s2_bp_p0( TC, queue_id );
336 336 if (result != LFR_SUCCESSFUL)
337 337 {
338 338 flag = LFR_DEFAULT;
339 339 }
340 340 }
341 341
342 342 //***************
343 343 // sy_lfr_s2_bp_p1
344 344 if (flag == LFR_SUCCESSFUL)
345 345 {
346 346 result = set_sy_lfr_s2_bp_p1( TC, queue_id );
347 347 if (result != LFR_SUCCESSFUL)
348 348 {
349 349 flag = LFR_DEFAULT;
350 350 }
351 351 }
352 352
353 353 return flag;
354 354 }
355 355
356 356 int action_dump_par( rtems_id queue_id )
357 357 {
358 358 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
359 359 *
360 360 * @param queue_id is the id of the queue which handles TM related to this execution step.
361 361 *
362 362 * @return RTEMS directive status codes:
363 363 * - RTEMS_SUCCESSFUL - message sent successfully
364 364 * - RTEMS_INVALID_ID - invalid queue id
365 365 * - RTEMS_INVALID_SIZE - invalid message size
366 366 * - RTEMS_INVALID_ADDRESS - buffer is NULL
367 367 * - RTEMS_UNSATISFIED - out of message buffers
368 368 * - RTEMS_TOO_MANY - queue s limit has been reached
369 369 *
370 370 */
371 371
372 372 int status;
373 373
374 374 // UPDATE TIME
375 375 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
376 376 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
377 377 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
378 378 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
379 379 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
380 380 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
381 381 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
382 382 // SEND DATA
383 383 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
384 384 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
385 385 if (status != RTEMS_SUCCESSFUL) {
386 386 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
387 387 }
388 388
389 389 return status;
390 390 }
391 391
392 392 //***********************
393 393 // NORMAL MODE PARAMETERS
394 394
395 395 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
396 396 {
397 397 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
398 398 *
399 399 * @param TC points to the TeleCommand packet that is being processed
400 400 * @param queue_id is the id of the queue which handles TM related to this execution step
401 401 *
402 402 */
403 403
404 404 unsigned int tmp;
405 405 int result;
406 406 unsigned char msb;
407 407 unsigned char lsb;
408 408 rtems_status_code status;
409 409
410 410 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
411 411 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
412 412
413 413 tmp = ( unsigned int ) floor(
414 414 ( ( msb*256 ) + lsb ) / 16
415 415 ) * 16;
416 416
417 417 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
418 418 { // 2048 is the maximum limit due to the size of the buffers
419 419 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
420 420 result = WRONG_APP_DATA;
421 421 }
422 422 else if (tmp != 2048)
423 423 {
424 424 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
425 425 result = FUNCT_NOT_IMPL;
426 426 }
427 427 else
428 428 {
429 429 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
430 430 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
431 431 result = LFR_SUCCESSFUL;
432 432 }
433 433
434 434 return result;
435 435 }
436 436
437 437 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
438 438 {
439 439 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
440 440 *
441 441 * @param TC points to the TeleCommand packet that is being processed
442 442 * @param queue_id is the id of the queue which handles TM related to this execution step
443 443 *
444 444 */
445 445
446 446 unsigned int tmp;
447 447 int result;
448 448 unsigned char msb;
449 449 unsigned char lsb;
450 450 rtems_status_code status;
451 451
452 452 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
453 453 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
454 454
455 455 tmp = msb * 256 + lsb;
456 456
457 457 if ( tmp < 16 )
458 458 {
459 459 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
460 460 result = WRONG_APP_DATA;
461 461 }
462 462 else
463 463 {
464 464 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
465 465 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
466 466 result = LFR_SUCCESSFUL;
467 467 }
468 468
469 469 return result;
470 470 }
471 471
472 472 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
473 473 {
474 474 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
475 475 *
476 476 * @param TC points to the TeleCommand packet that is being processed
477 477 * @param queue_id is the id of the queue which handles TM related to this execution step
478 478 *
479 479 */
480 480
481 481 int result;
482 482 unsigned char msb;
483 483 unsigned char lsb;
484 484
485 485 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
486 486 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
487 487
488 488 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
489 489 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
490 490 result = LFR_SUCCESSFUL;
491 491
492 492 return result;
493 493 }
494 494
495 495 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
496 496 {
497 497 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
498 498 *
499 499 * @param TC points to the TeleCommand packet that is being processed
500 500 * @param queue_id is the id of the queue which handles TM related to this execution step
501 501 *
502 502 */
503 503
504 504 int status;
505 505 unsigned char val;
506 506
507 507 status = LFR_SUCCESSFUL;
508 508
509 509 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
510 510
511 511 if (val < SY_LFR_N_BP_P0)
512 512 {
513 513 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, val );
514 514 status = WRONG_APP_DATA;
515 515 }
516 516 else
517 517 {
518 518 parameter_dump_packet.sy_lfr_n_bp_p0 = val;
519 519 }
520 520
521 521 return status;
522 522 }
523 523
524 524 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
525 525 {
526 526 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
527 527 *
528 528 * @param TC points to the TeleCommand packet that is being processed
529 529 * @param queue_id is the id of the queue which handles TM related to this execution step
530 530 *
531 531 */
532 532
533 533 int status;
534 534 unsigned char val;
535 535
536 536 status = LFR_SUCCESSFUL;
537 537
538 538 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
539 539
540 540 if (val < SY_LFR_N_BP_P1)
541 541 {
542 542 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, val );
543 543 status = WRONG_APP_DATA;
544 544 }
545 545 else
546 546 {
547 547 parameter_dump_packet.sy_lfr_n_bp_p1 = val;
548 548 }
549 549
550 550 return status;
551 551 }
552 552
553 553 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
554 554 {
555 555 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
556 556 *
557 557 * @param TC points to the TeleCommand packet that is being processed
558 558 * @param queue_id is the id of the queue which handles TM related to this execution step
559 559 *
560 560 */
561 561
562 562 int status;
563 563
564 564 status = LFR_SUCCESSFUL;
565 565
566 566 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
567 567
568 568 return status;
569 569 }
570 570
571 571 //**********************
572 572 // BURST MODE PARAMETERS
573 573 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
574 574 {
575 575 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
576 576 *
577 577 * @param TC points to the TeleCommand packet that is being processed
578 578 * @param queue_id is the id of the queue which handles TM related to this execution step
579 579 *
580 580 */
581 581
582 582 int status;
583 unsigned char val;
583 584
584 585 status = LFR_SUCCESSFUL;
585 586
586 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
587 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
588
589 if (val < DEFAULT_SY_LFR_B_BP_P0 )
590 {
591 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, val );
592 status = WRONG_APP_DATA;
593 }
594 else
595 {
596 parameter_dump_packet.sy_lfr_b_bp_p0 = val;
597 }
587 598
588 599 return status;
589 600 }
590 601
591 602 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
592 603 {
593 604 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
594 605 *
595 606 * @param TC points to the TeleCommand packet that is being processed
596 607 * @param queue_id is the id of the queue which handles TM related to this execution step
597 608 *
598 609 */
599 610
600 611 int status;
612 unsigned char val;
601 613
602 614 status = LFR_SUCCESSFUL;
603 615
604 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
616 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
617
618 if (val < DEFAULT_SY_LFR_B_BP_P1 )
619 {
620 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, val );
621 status = WRONG_APP_DATA;
622 }
623 else
624 {
625 parameter_dump_packet.sy_lfr_b_bp_p1 = val;
626 }
605 627
606 628 return status;
607 629 }
608 630
609 631 //*********************
610 632 // SBM1 MODE PARAMETERS
611 633 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
612 634 {
613 635 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
614 636 *
615 637 * @param TC points to the TeleCommand packet that is being processed
616 638 * @param queue_id is the id of the queue which handles TM related to this execution step
617 639 *
618 640 */
619 641
620 642 int status;
643 unsigned char val;
621 644
622 645 status = LFR_SUCCESSFUL;
623 646
624 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
647 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
648
649 if (val < DEFAULT_SY_LFR_S1_BP_P0 )
650 {
651 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, val );
652 status = WRONG_APP_DATA;
653 }
654 else
655 {
656 parameter_dump_packet.sy_lfr_s1_bp_p0 = val;
657 }
625 658
626 659 return status;
627 660 }
628 661
629 662 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
630 663 {
631 664 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
632 665 *
633 666 * @param TC points to the TeleCommand packet that is being processed
634 667 * @param queue_id is the id of the queue which handles TM related to this execution step
635 668 *
636 669 */
637 670
638 671 int status;
672 unsigned char val;
639 673
640 674 status = LFR_SUCCESSFUL;
641 675
642 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
676 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
677
678 if (val < DEFAULT_SY_LFR_S1_BP_P1 )
679 {
680 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, val );
681 status = WRONG_APP_DATA;
682 }
683 else
684 {
685 parameter_dump_packet.sy_lfr_s1_bp_p1 = val;
686 }
643 687
644 688 return status;
645 689 }
646 690
647 691 //*********************
648 692 // SBM2 MODE PARAMETERS
649 693 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
650 694 {
651 695 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
652 696 *
653 697 * @param TC points to the TeleCommand packet that is being processed
654 698 * @param queue_id is the id of the queue which handles TM related to this execution step
655 699 *
656 700 */
657 701
658 702 int status;
703 unsigned char val;
659 704
660 705 status = LFR_SUCCESSFUL;
661 706
662 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
707 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
708
709 if (val < DEFAULT_SY_LFR_S2_BP_P0 )
710 {
711 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, val );
712 status = WRONG_APP_DATA;
713 }
714 else
715 {
716 parameter_dump_packet.sy_lfr_s2_bp_p0 = val;
717 }
663 718
664 719 return status;
665 720 }
666 721
667 722 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
668 723 {
669 724 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
670 725 *
671 726 * @param TC points to the TeleCommand packet that is being processed
672 727 * @param queue_id is the id of the queue which handles TM related to this execution step
673 728 *
674 729 */
675 730
676 731 int status;
732 unsigned char val;
677 733
678 734 status = LFR_SUCCESSFUL;
679 735
680 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
736 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
737
738 if (val < DEFAULT_SY_LFR_S2_BP_P1 )
739 {
740 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, val );
741 status = WRONG_APP_DATA;
742 }
743 else
744 {
745 parameter_dump_packet.sy_lfr_s2_bp_p1 = val;
746 }
681 747
682 748 return status;
683 749 }
684 750
685 751
686 752 //*******************
687 753 // TC_LFR_UPDATE_INFO
688 754 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
689 755 {
690 756 unsigned int status;
691 757
692 758 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
693 759 || (mode == LFR_MODE_BURST)
694 760 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
695 761 {
696 762 status = LFR_SUCCESSFUL;
697 763 }
698 764 else
699 765 {
700 766 status = LFR_DEFAULT;
701 767 }
702 768
703 769 return status;
704 770 }
705 771
706 772 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
707 773 {
708 774 unsigned int status;
709 775
710 776 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
711 777 || (mode == TDS_MODE_BURST)
712 778 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
713 779 || (mode == TDS_MODE_LFM))
714 780 {
715 781 status = LFR_SUCCESSFUL;
716 782 }
717 783 else
718 784 {
719 785 status = LFR_DEFAULT;
720 786 }
721 787
722 788 return status;
723 789 }
724 790
725 791 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
726 792 {
727 793 unsigned int status;
728 794
729 795 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
730 796 || (mode == THR_MODE_BURST))
731 797 {
732 798 status = LFR_SUCCESSFUL;
733 799 }
734 800 else
735 801 {
736 802 status = LFR_DEFAULT;
737 803 }
738 804
739 805 return status;
740 806 }
741 807
742 808 //**********
743 809 // init dump
744 810
745 811 void init_parameter_dump( void )
746 812 {
747 813 /** This function initialize the parameter_dump_packet global variable with default values.
748 814 *
749 815 */
750 816
751 817 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
752 818 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
753 819 parameter_dump_packet.reserved = CCSDS_RESERVED;
754 820 parameter_dump_packet.userApplication = CCSDS_USER_APP;
755 821 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
756 822 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
757 823 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
758 824 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
759 825 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
760 826 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
761 827 // DATA FIELD HEADER
762 828 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
763 829 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
764 830 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
765 831 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
766 832 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
767 833 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
768 834 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
769 835 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
770 836 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
771 837 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
772 838 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
773 839
774 840 //******************
775 841 // COMMON PARAMETERS
776 842 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
777 843 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
778 844
779 845 //******************
780 846 // NORMAL PARAMETERS
781 847 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
782 848 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
783 849 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
784 850 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
785 851 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
786 852 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
787 853 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
788 854 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
789 855 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
790 856
791 857 //*****************
792 858 // BURST PARAMETERS
793 859 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
794 860 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
795 861
796 862 //****************
797 863 // SBM1 PARAMETERS
798 864 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
799 865 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
800 866
801 867 //****************
802 868 // SBM2 PARAMETERS
803 869 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
804 870 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
805 871 }
806 872
807 873
808 874
809 875
810 876
811 877
812 878
General Comments 0
You need to be logged in to leave comments. Login now