@@ -1,82 +1,83 | |||||
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H | |
2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
2 | #define TC_LOAD_DUMP_PARAMETERS_H | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 |
|
6 | |||
7 | #include "fsw_params.h" |
|
7 | #include "fsw_params.h" | |
8 | #include "wf_handler.h" |
|
8 | #include "wf_handler.h" | |
9 | #include "tm_lfr_tc_exe.h" |
|
9 | #include "tm_lfr_tc_exe.h" | |
10 | #include "fsw_misc.h" |
|
10 | #include "fsw_misc.h" | |
11 | #include "basic_parameters_params.h" |
|
11 | #include "basic_parameters_params.h" | |
12 | #include "avf0_prc0.h" |
|
12 | #include "avf0_prc0.h" | |
13 |
|
13 | |||
14 | #define FLOAT_EQUAL_ZERO 0.001 |
|
14 | #define FLOAT_EQUAL_ZERO 0.001 | |
15 |
|
15 | |||
16 | extern unsigned short sequenceCounterParameterDump; |
|
16 | extern unsigned short sequenceCounterParameterDump; | |
17 | extern unsigned short sequenceCounters_TM_DUMP[]; |
|
17 | extern unsigned short sequenceCounters_TM_DUMP[]; | |
18 | extern float k_coeff_intercalib_f0_norm[ ]; |
|
18 | extern float k_coeff_intercalib_f0_norm[ ]; | |
19 | extern float k_coeff_intercalib_f0_sbm[ ]; |
|
19 | extern float k_coeff_intercalib_f0_sbm[ ]; | |
20 | extern float k_coeff_intercalib_f1_norm[ ]; |
|
20 | extern float k_coeff_intercalib_f1_norm[ ]; | |
21 | extern float k_coeff_intercalib_f1_sbm[ ]; |
|
21 | extern float k_coeff_intercalib_f1_sbm[ ]; | |
22 | extern float k_coeff_intercalib_f2[ ]; |
|
22 | extern float k_coeff_intercalib_f2[ ]; | |
23 | extern fbins_masks_t fbins_masks; |
|
23 | extern fbins_masks_t fbins_masks; | |
24 |
|
24 | |||
25 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
25 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); | |
26 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
26 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
27 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
27 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
28 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
28 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
29 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
29 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
30 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
30 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
31 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
31 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
32 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
32 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
33 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
33 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
34 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
34 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
35 |
|
35 | |||
36 | // NORMAL |
|
36 | // NORMAL | |
37 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
37 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
38 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
38 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); | |
39 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
39 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); | |
40 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
40 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); | |
41 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
41 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
42 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
42 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
43 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
43 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); | |
44 |
|
44 | |||
45 | // BURST |
|
45 | // BURST | |
46 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
46 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
47 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
47 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
48 |
|
48 | |||
49 | // SBM1 |
|
49 | // SBM1 | |
50 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
50 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
51 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
51 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
52 |
|
52 | |||
53 | // SBM2 |
|
53 | // SBM2 | |
54 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
54 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
55 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
55 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
56 |
|
56 | |||
57 | // TC_LFR_UPDATE_INFO |
|
57 | // TC_LFR_UPDATE_INFO | |
58 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
58 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); | |
59 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
59 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); | |
60 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); |
|
60 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); | |
61 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ); |
|
61 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ); | |
62 | void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag ); |
|
62 | void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag ); | |
63 | void build_sy_lfr_rw_mask( unsigned int channel ); |
|
63 | void build_sy_lfr_rw_mask( unsigned int channel ); | |
64 | void build_sy_lfr_rw_masks(); |
|
64 | void build_sy_lfr_rw_masks(); | |
65 | void merge_fbins_masks( void ); |
|
65 | void merge_fbins_masks( void ); | |
66 |
|
66 | |||
67 | // FBINS_MASK |
|
67 | // FBINS_MASK | |
68 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); |
|
68 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); | |
69 |
|
69 | |||
70 | // TC_LFR_LOAD_PARS_FILTER_PAR |
|
70 | // TC_LFR_LOAD_PARS_FILTER_PAR | |
71 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
71 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
72 |
|
72 | |||
73 | // KCOEFFICIENTS |
|
73 | // KCOEFFICIENTS | |
74 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); |
|
74 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); | |
75 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); |
|
75 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); | |
|
76 | void floatToChar( float value, unsigned char* ptr); | |||
76 |
|
77 | |||
77 | void init_parameter_dump( void ); |
|
78 | void init_parameter_dump( void ); | |
78 | void init_kcoefficients_dump( void ); |
|
79 | void init_kcoefficients_dump( void ); | |
79 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); |
|
80 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); | |
80 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); |
|
81 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); | |
81 |
|
82 | |||
82 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
|
83 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,1540 +1,1566 | |||||
1 | /** Functions to load and dump parameters in the LFR registers. |
|
1 | /** Functions to load and dump parameters in the LFR registers. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
6 | * A group of functions to handle TC related to parameter loading and dumping.\n | |
7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
7 | * TC_LFR_LOAD_COMMON_PAR\n | |
8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
8 | * TC_LFR_LOAD_NORMAL_PAR\n | |
9 | * TC_LFR_LOAD_BURST_PAR\n |
|
9 | * TC_LFR_LOAD_BURST_PAR\n | |
10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
10 | * TC_LFR_LOAD_SBM1_PAR\n | |
11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
11 | * TC_LFR_LOAD_SBM2_PAR\n | |
12 | * |
|
12 | * | |
13 | */ |
|
13 | */ | |
14 |
|
14 | |||
15 | #include "tc_load_dump_parameters.h" |
|
15 | #include "tc_load_dump_parameters.h" | |
16 |
|
16 | |||
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; |
|
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; | |
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; |
|
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; | |
19 | ring_node kcoefficient_node_1; |
|
19 | ring_node kcoefficient_node_1; | |
20 | ring_node kcoefficient_node_2; |
|
20 | ring_node kcoefficient_node_2; | |
21 |
|
21 | |||
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) | |
23 | { |
|
23 | { | |
24 | /** This function updates the LFR registers with the incoming common parameters. |
|
24 | /** This function updates the LFR registers with the incoming common parameters. | |
25 | * |
|
25 | * | |
26 | * @param TC points to the TeleCommand packet that is being processed |
|
26 | * @param TC points to the TeleCommand packet that is being processed | |
27 | * |
|
27 | * | |
28 | * |
|
28 | * | |
29 | */ |
|
29 | */ | |
30 |
|
30 | |||
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; |
|
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; | |
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; |
|
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; | |
33 | set_wfp_data_shaping( ); |
|
33 | set_wfp_data_shaping( ); | |
34 | return LFR_SUCCESSFUL; |
|
34 | return LFR_SUCCESSFUL; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
38 | { |
|
38 | { | |
39 | /** This function updates the LFR registers with the incoming normal parameters. |
|
39 | /** This function updates the LFR registers with the incoming normal parameters. | |
40 | * |
|
40 | * | |
41 | * @param TC points to the TeleCommand packet that is being processed |
|
41 | * @param TC points to the TeleCommand packet that is being processed | |
42 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
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 | int result; |
|
46 | int result; | |
47 | int flag; |
|
47 | int flag; | |
48 | rtems_status_code status; |
|
48 | rtems_status_code status; | |
49 |
|
49 | |||
50 | flag = LFR_SUCCESSFUL; |
|
50 | flag = LFR_SUCCESSFUL; | |
51 |
|
51 | |||
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || | |
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { | |
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
55 | flag = LFR_DEFAULT; |
|
55 | flag = LFR_DEFAULT; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | // CHECK THE PARAMETERS SET CONSISTENCY |
|
58 | // CHECK THE PARAMETERS SET CONSISTENCY | |
59 | if (flag == LFR_SUCCESSFUL) |
|
59 | if (flag == LFR_SUCCESSFUL) | |
60 | { |
|
60 | { | |
61 | flag = check_normal_par_consistency( TC, queue_id ); |
|
61 | flag = check_normal_par_consistency( TC, queue_id ); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT |
|
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT | |
65 | if (flag == LFR_SUCCESSFUL) |
|
65 | if (flag == LFR_SUCCESSFUL) | |
66 | { |
|
66 | { | |
67 | result = set_sy_lfr_n_swf_l( TC ); |
|
67 | result = set_sy_lfr_n_swf_l( TC ); | |
68 | result = set_sy_lfr_n_swf_p( TC ); |
|
68 | result = set_sy_lfr_n_swf_p( TC ); | |
69 | result = set_sy_lfr_n_bp_p0( TC ); |
|
69 | result = set_sy_lfr_n_bp_p0( TC ); | |
70 | result = set_sy_lfr_n_bp_p1( TC ); |
|
70 | result = set_sy_lfr_n_bp_p1( TC ); | |
71 | result = set_sy_lfr_n_asm_p( TC ); |
|
71 | result = set_sy_lfr_n_asm_p( TC ); | |
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); |
|
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | return flag; |
|
75 | return flag; | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
79 | { |
|
79 | { | |
80 | /** This function updates the LFR registers with the incoming burst parameters. |
|
80 | /** This function updates the LFR registers with the incoming burst parameters. | |
81 | * |
|
81 | * | |
82 | * @param TC points to the TeleCommand packet that is being processed |
|
82 | * @param TC points to the TeleCommand packet that is being processed | |
83 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
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 | int flag; |
|
87 | int flag; | |
88 | rtems_status_code status; |
|
88 | rtems_status_code status; | |
89 | unsigned char sy_lfr_b_bp_p0; |
|
89 | unsigned char sy_lfr_b_bp_p0; | |
90 | unsigned char sy_lfr_b_bp_p1; |
|
90 | unsigned char sy_lfr_b_bp_p1; | |
91 | float aux; |
|
91 | float aux; | |
92 |
|
92 | |||
93 | flag = LFR_SUCCESSFUL; |
|
93 | flag = LFR_SUCCESSFUL; | |
94 |
|
94 | |||
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
97 | flag = LFR_DEFAULT; |
|
97 | flag = LFR_DEFAULT; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
102 |
|
102 | |||
103 | // sy_lfr_b_bp_p0 shall not be lower than its default value |
|
103 | // sy_lfr_b_bp_p0 shall not be lower than its default value | |
104 | if (flag == LFR_SUCCESSFUL) |
|
104 | if (flag == LFR_SUCCESSFUL) | |
105 | { |
|
105 | { | |
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) |
|
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) | |
107 | { |
|
107 | { | |
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
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 | flag = WRONG_APP_DATA; |
|
109 | flag = WRONG_APP_DATA; | |
110 | } |
|
110 | } | |
111 | } |
|
111 | } | |
112 | // sy_lfr_b_bp_p1 shall not be lower than its default value |
|
112 | // sy_lfr_b_bp_p1 shall not be lower than its default value | |
113 | if (flag == LFR_SUCCESSFUL) |
|
113 | if (flag == LFR_SUCCESSFUL) | |
114 | { |
|
114 | { | |
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) |
|
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) | |
116 | { |
|
116 | { | |
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); |
|
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 | flag = WRONG_APP_DATA; |
|
118 | flag = WRONG_APP_DATA; | |
119 | } |
|
119 | } | |
120 | } |
|
120 | } | |
121 | //**************************************************************** |
|
121 | //**************************************************************** | |
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 | |
123 | if (flag == LFR_SUCCESSFUL) |
|
123 | if (flag == LFR_SUCCESSFUL) | |
124 | { |
|
124 | { | |
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); |
|
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 | if (aux > FLOAT_EQUAL_ZERO) |
|
128 | if (aux > FLOAT_EQUAL_ZERO) | |
129 | { |
|
129 | { | |
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
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 | flag = LFR_DEFAULT; |
|
131 | flag = LFR_DEFAULT; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | // SET THE PARAMETERS |
|
135 | // SET THE PARAMETERS | |
136 | if (flag == LFR_SUCCESSFUL) |
|
136 | if (flag == LFR_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | flag = set_sy_lfr_b_bp_p0( TC ); |
|
138 | flag = set_sy_lfr_b_bp_p0( TC ); | |
139 | flag = set_sy_lfr_b_bp_p1( TC ); |
|
139 | flag = set_sy_lfr_b_bp_p1( TC ); | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | return flag; |
|
142 | return flag; | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
146 | { |
|
146 | { | |
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. | |
148 | * |
|
148 | * | |
149 | * @param TC points to the TeleCommand packet that is being processed |
|
149 | * @param TC points to the TeleCommand packet that is being processed | |
150 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
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 | int flag; |
|
154 | int flag; | |
155 | rtems_status_code status; |
|
155 | rtems_status_code status; | |
156 | unsigned char sy_lfr_s1_bp_p0; |
|
156 | unsigned char sy_lfr_s1_bp_p0; | |
157 | unsigned char sy_lfr_s1_bp_p1; |
|
157 | unsigned char sy_lfr_s1_bp_p1; | |
158 | float aux; |
|
158 | float aux; | |
159 |
|
159 | |||
160 | flag = LFR_SUCCESSFUL; |
|
160 | flag = LFR_SUCCESSFUL; | |
161 |
|
161 | |||
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
164 | flag = LFR_DEFAULT; |
|
164 | flag = LFR_DEFAULT; | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
169 |
|
169 | |||
170 | // sy_lfr_s1_bp_p0 |
|
170 | // sy_lfr_s1_bp_p0 | |
171 | if (flag == LFR_SUCCESSFUL) |
|
171 | if (flag == LFR_SUCCESSFUL) | |
172 | { |
|
172 | { | |
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) |
|
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) | |
174 | { |
|
174 | { | |
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
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 | flag = WRONG_APP_DATA; |
|
176 | flag = WRONG_APP_DATA; | |
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 | // sy_lfr_s1_bp_p1 |
|
179 | // sy_lfr_s1_bp_p1 | |
180 | if (flag == LFR_SUCCESSFUL) |
|
180 | if (flag == LFR_SUCCESSFUL) | |
181 | { |
|
181 | { | |
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) |
|
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) | |
183 | { |
|
183 | { | |
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); |
|
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 | flag = WRONG_APP_DATA; |
|
185 | flag = WRONG_APP_DATA; | |
186 | } |
|
186 | } | |
187 | } |
|
187 | } | |
188 | //****************************************************************** |
|
188 | //****************************************************************** | |
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 | |
190 | if (flag == LFR_SUCCESSFUL) |
|
190 | if (flag == LFR_SUCCESSFUL) | |
191 | { |
|
191 | { | |
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)); |
|
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 | if (aux > FLOAT_EQUAL_ZERO) |
|
193 | if (aux > FLOAT_EQUAL_ZERO) | |
194 | { |
|
194 | { | |
195 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
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 | flag = LFR_DEFAULT; |
|
196 | flag = LFR_DEFAULT; | |
197 | } |
|
197 | } | |
198 | } |
|
198 | } | |
199 |
|
199 | |||
200 | // SET THE PARAMETERS |
|
200 | // SET THE PARAMETERS | |
201 | if (flag == LFR_SUCCESSFUL) |
|
201 | if (flag == LFR_SUCCESSFUL) | |
202 | { |
|
202 | { | |
203 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
203 | flag = set_sy_lfr_s1_bp_p0( TC ); | |
204 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
204 | flag = set_sy_lfr_s1_bp_p1( TC ); | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | return flag; |
|
207 | return flag; | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
211 | { |
|
211 | { | |
212 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
212 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
213 | * |
|
213 | * | |
214 | * @param TC points to the TeleCommand packet that is being processed |
|
214 | * @param TC points to the TeleCommand packet that is being processed | |
215 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
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 | int flag; |
|
219 | int flag; | |
220 | rtems_status_code status; |
|
220 | rtems_status_code status; | |
221 | unsigned char sy_lfr_s2_bp_p0; |
|
221 | unsigned char sy_lfr_s2_bp_p0; | |
222 | unsigned char sy_lfr_s2_bp_p1; |
|
222 | unsigned char sy_lfr_s2_bp_p1; | |
223 | float aux; |
|
223 | float aux; | |
224 |
|
224 | |||
225 | flag = LFR_SUCCESSFUL; |
|
225 | flag = LFR_SUCCESSFUL; | |
226 |
|
226 | |||
227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
229 | flag = LFR_DEFAULT; |
|
229 | flag = LFR_DEFAULT; | |
230 | } |
|
230 | } | |
231 |
|
231 | |||
232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
234 |
|
234 | |||
235 | // sy_lfr_s2_bp_p0 |
|
235 | // sy_lfr_s2_bp_p0 | |
236 | if (flag == LFR_SUCCESSFUL) |
|
236 | if (flag == LFR_SUCCESSFUL) | |
237 | { |
|
237 | { | |
238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) | |
239 | { |
|
239 | { | |
240 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
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 | flag = WRONG_APP_DATA; |
|
241 | flag = WRONG_APP_DATA; | |
242 | } |
|
242 | } | |
243 | } |
|
243 | } | |
244 | // sy_lfr_s2_bp_p1 |
|
244 | // sy_lfr_s2_bp_p1 | |
245 | if (flag == LFR_SUCCESSFUL) |
|
245 | if (flag == LFR_SUCCESSFUL) | |
246 | { |
|
246 | { | |
247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) | |
248 | { |
|
248 | { | |
249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); |
|
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 | flag = WRONG_APP_DATA; |
|
250 | flag = WRONG_APP_DATA; | |
251 | } |
|
251 | } | |
252 | } |
|
252 | } | |
253 | //****************************************************************** |
|
253 | //****************************************************************** | |
254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 | |
255 | if (flag == LFR_SUCCESSFUL) |
|
255 | if (flag == LFR_SUCCESSFUL) | |
256 | { |
|
256 | { | |
257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
259 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
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 | if (aux > FLOAT_EQUAL_ZERO) |
|
260 | if (aux > FLOAT_EQUAL_ZERO) | |
261 | { |
|
261 | { | |
262 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
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 | flag = LFR_DEFAULT; |
|
263 | flag = LFR_DEFAULT; | |
264 | } |
|
264 | } | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | // SET THE PARAMETERS |
|
267 | // SET THE PARAMETERS | |
268 | if (flag == LFR_SUCCESSFUL) |
|
268 | if (flag == LFR_SUCCESSFUL) | |
269 | { |
|
269 | { | |
270 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
270 | flag = set_sy_lfr_s2_bp_p0( TC ); | |
271 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
271 | flag = set_sy_lfr_s2_bp_p1( TC ); | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | return flag; |
|
274 | return flag; | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
278 | { |
|
278 | { | |
279 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
279 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
280 | * |
|
280 | * | |
281 | * @param TC points to the TeleCommand packet that is being processed |
|
281 | * @param TC points to the TeleCommand packet that is being processed | |
282 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
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 | int flag; |
|
286 | int flag; | |
287 |
|
287 | |||
288 | flag = LFR_DEFAULT; |
|
288 | flag = LFR_DEFAULT; | |
289 |
|
289 | |||
290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); |
|
290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); | |
291 |
|
291 | |||
292 | return flag; |
|
292 | return flag; | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
296 | { |
|
296 | { | |
297 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
297 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
298 | * |
|
298 | * | |
299 | * @param TC points to the TeleCommand packet that is being processed |
|
299 | * @param TC points to the TeleCommand packet that is being processed | |
300 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
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 | int flag; |
|
304 | int flag; | |
305 |
|
305 | |||
306 | flag = LFR_DEFAULT; |
|
306 | flag = LFR_DEFAULT; | |
307 |
|
307 | |||
308 | flag = set_sy_lfr_fbins( TC ); |
|
308 | flag = set_sy_lfr_fbins( TC ); | |
309 |
|
309 | |||
310 | return flag; |
|
310 | return flag; | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
313 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
314 | { |
|
314 | { | |
315 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
315 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
316 | * |
|
316 | * | |
317 | * @param TC points to the TeleCommand packet that is being processed |
|
317 | * @param TC points to the TeleCommand packet that is being processed | |
318 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
318 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
319 | * |
|
319 | * | |
320 | */ |
|
320 | */ | |
321 |
|
321 | |||
322 | int flag; |
|
322 | int flag; | |
323 |
|
323 | |||
324 | flag = LFR_DEFAULT; |
|
324 | flag = LFR_DEFAULT; | |
325 |
|
325 | |||
326 | flag = check_sy_lfr_filter_parameters( TC, queue_id ); |
|
326 | flag = check_sy_lfr_filter_parameters( TC, queue_id ); | |
327 |
|
327 | |||
328 | if (flag == LFR_SUCCESSFUL) |
|
328 | if (flag == LFR_SUCCESSFUL) | |
329 | { |
|
329 | { | |
330 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ]; |
|
330 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ]; | |
331 | parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
331 | parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; | |
332 | parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ]; |
|
332 | parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ]; | |
333 | parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ]; |
|
333 | parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ]; | |
334 | parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ]; |
|
334 | parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ]; | |
335 | parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ]; |
|
335 | parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ]; | |
336 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
336 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |
337 | parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ]; |
|
337 | parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ]; | |
338 | parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ]; |
|
338 | parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ]; | |
339 | parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ]; |
|
339 | parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ]; | |
340 | parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ]; |
|
340 | parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ]; | |
341 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ]; |
|
341 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ]; | |
342 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ]; |
|
342 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ]; | |
343 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ]; |
|
343 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ]; | |
344 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ]; |
|
344 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ]; | |
345 |
|
345 | |||
346 | //**************************** |
|
346 | //**************************** | |
347 | // store PAS filter parameters |
|
347 | // store PAS filter parameters | |
348 | // sy_lfr_pas_filter_enabled |
|
348 | // sy_lfr_pas_filter_enabled | |
349 | filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled; |
|
349 | filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled; | |
350 | // sy_lfr_pas_filter_modulus |
|
350 | // sy_lfr_pas_filter_modulus | |
351 | filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus; |
|
351 | filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus; | |
352 | // sy_lfr_pas_filter_tbad |
|
352 | // sy_lfr_pas_filter_tbad | |
353 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad, |
|
353 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad, | |
354 | parameter_dump_packet.sy_lfr_pas_filter_tbad ); |
|
354 | parameter_dump_packet.sy_lfr_pas_filter_tbad ); | |
355 | // sy_lfr_pas_filter_offset |
|
355 | // sy_lfr_pas_filter_offset | |
356 | filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset; |
|
356 | filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset; | |
357 | // sy_lfr_pas_filter_shift |
|
357 | // sy_lfr_pas_filter_shift | |
358 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift, |
|
358 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift, | |
359 | parameter_dump_packet.sy_lfr_pas_filter_shift ); |
|
359 | parameter_dump_packet.sy_lfr_pas_filter_shift ); | |
360 |
|
360 | |||
361 | //**************************************************** |
|
361 | //**************************************************** | |
362 | // store the parameter sy_lfr_sc_rw_delta_f as a float |
|
362 | // store the parameter sy_lfr_sc_rw_delta_f as a float | |
363 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f, |
|
363 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f, | |
364 | parameter_dump_packet.sy_lfr_sc_rw_delta_f ); |
|
364 | parameter_dump_packet.sy_lfr_sc_rw_delta_f ); | |
365 | } |
|
365 | } | |
366 |
|
366 | |||
367 | return flag; |
|
367 | return flag; | |
368 | } |
|
368 | } | |
369 |
|
369 | |||
370 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
370 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
371 | { |
|
371 | { | |
372 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
372 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
373 | * |
|
373 | * | |
374 | * @param TC points to the TeleCommand packet that is being processed |
|
374 | * @param TC points to the TeleCommand packet that is being processed | |
375 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
375 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
376 | * |
|
376 | * | |
377 | */ |
|
377 | */ | |
378 |
|
378 | |||
379 | unsigned int address; |
|
379 | unsigned int address; | |
380 | rtems_status_code status; |
|
380 | rtems_status_code status; | |
381 | unsigned int freq; |
|
381 | unsigned int freq; | |
382 | unsigned int bin; |
|
382 | unsigned int bin; | |
383 | unsigned int coeff; |
|
383 | unsigned int coeff; | |
384 | unsigned char *kCoeffPtr; |
|
384 | unsigned char *kCoeffPtr; | |
385 | unsigned char *kCoeffDumpPtr; |
|
385 | unsigned char *kCoeffDumpPtr; | |
386 |
|
386 | |||
387 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
387 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff | |
388 | // F0 => 11 bins |
|
388 | // F0 => 11 bins | |
389 | // F1 => 13 bins |
|
389 | // F1 => 13 bins | |
390 | // F2 => 12 bins |
|
390 | // F2 => 12 bins | |
391 | // 36 bins to dump in two packets (30 bins max per packet) |
|
391 | // 36 bins to dump in two packets (30 bins max per packet) | |
392 |
|
392 | |||
393 | //********* |
|
393 | //********* | |
394 | // PACKET 1 |
|
394 | // PACKET 1 | |
395 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
395 | // 11 F0 bins, 13 F1 bins and 6 F2 bins | |
396 | kcoefficients_dump_1.destinationID = TC->sourceID; |
|
396 | kcoefficients_dump_1.destinationID = TC->sourceID; | |
397 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); |
|
397 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); | |
398 | for( freq=0; |
|
398 | for( freq=0; | |
399 | freq<NB_BINS_COMPRESSED_SM_F0; |
|
399 | freq<NB_BINS_COMPRESSED_SM_F0; | |
400 | freq++ ) |
|
400 | freq++ ) | |
401 | { |
|
401 | { | |
402 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; |
|
402 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; | |
403 | bin = freq; |
|
403 | bin = freq; | |
404 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
404 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); | |
405 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
405 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
406 | { |
|
406 | { | |
407 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
407 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
408 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
408 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
409 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
409 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
410 | } |
|
410 | } | |
411 | } |
|
411 | } | |
412 | for( freq=NB_BINS_COMPRESSED_SM_F0; |
|
412 | for( freq=NB_BINS_COMPRESSED_SM_F0; | |
413 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
413 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
414 | freq++ ) |
|
414 | freq++ ) | |
415 | { |
|
415 | { | |
416 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
416 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
417 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
417 | bin = freq - NB_BINS_COMPRESSED_SM_F0; | |
418 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
418 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); | |
419 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
419 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
420 | { |
|
420 | { | |
421 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
421 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
422 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
422 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
423 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
423 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
424 | } |
|
424 | } | |
425 | } |
|
425 | } | |
426 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
426 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
427 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); |
|
427 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); | |
428 | freq++ ) |
|
428 | freq++ ) | |
429 | { |
|
429 | { | |
430 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
430 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
431 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
431 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
432 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
432 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
433 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
433 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
434 | { |
|
434 | { | |
435 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
435 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
436 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
436 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
437 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
437 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
438 | } |
|
438 | } | |
439 | } |
|
439 | } | |
440 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
440 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
441 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
441 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
442 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
442 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
443 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
443 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
444 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
444 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
445 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
445 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); | |
446 | // SEND DATA |
|
446 | // SEND DATA | |
447 | kcoefficient_node_1.status = 1; |
|
447 | kcoefficient_node_1.status = 1; | |
448 | address = (unsigned int) &kcoefficient_node_1; |
|
448 | address = (unsigned int) &kcoefficient_node_1; | |
449 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
449 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
450 | if (status != RTEMS_SUCCESSFUL) { |
|
450 | if (status != RTEMS_SUCCESSFUL) { | |
451 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
451 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) | |
452 | } |
|
452 | } | |
453 |
|
453 | |||
454 | //******** |
|
454 | //******** | |
455 | // PACKET 2 |
|
455 | // PACKET 2 | |
456 | // 6 F2 bins |
|
456 | // 6 F2 bins | |
457 | kcoefficients_dump_2.destinationID = TC->sourceID; |
|
457 | kcoefficients_dump_2.destinationID = TC->sourceID; | |
458 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); |
|
458 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); | |
459 | for( freq=0; freq<6; freq++ ) |
|
459 | for( freq=0; freq<6; freq++ ) | |
460 | { |
|
460 | { | |
461 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; |
|
461 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; | |
462 | bin = freq + 6; |
|
462 | bin = freq + 6; | |
463 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
463 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
464 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
464 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
465 | { |
|
465 | { | |
466 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
466 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
467 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
467 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
468 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
468 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
469 | } |
|
469 | } | |
470 | } |
|
470 | } | |
471 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
471 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
472 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
472 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
473 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
473 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
474 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
474 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
475 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
475 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
476 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
476 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); | |
477 | // SEND DATA |
|
477 | // SEND DATA | |
478 | kcoefficient_node_2.status = 1; |
|
478 | kcoefficient_node_2.status = 1; | |
479 | address = (unsigned int) &kcoefficient_node_2; |
|
479 | address = (unsigned int) &kcoefficient_node_2; | |
480 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
480 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
481 | if (status != RTEMS_SUCCESSFUL) { |
|
481 | if (status != RTEMS_SUCCESSFUL) { | |
482 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
482 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) | |
483 | } |
|
483 | } | |
484 |
|
484 | |||
485 | return status; |
|
485 | return status; | |
486 | } |
|
486 | } | |
487 |
|
487 | |||
488 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
488 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
489 | { |
|
489 | { | |
490 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
490 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
491 | * |
|
491 | * | |
492 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
492 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
493 | * |
|
493 | * | |
494 | * @return RTEMS directive status codes: |
|
494 | * @return RTEMS directive status codes: | |
495 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
495 | * - RTEMS_SUCCESSFUL - message sent successfully | |
496 | * - RTEMS_INVALID_ID - invalid queue id |
|
496 | * - RTEMS_INVALID_ID - invalid queue id | |
497 | * - RTEMS_INVALID_SIZE - invalid message size |
|
497 | * - RTEMS_INVALID_SIZE - invalid message size | |
498 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
498 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
499 | * - RTEMS_UNSATISFIED - out of message buffers |
|
499 | * - RTEMS_UNSATISFIED - out of message buffers | |
500 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
500 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
501 | * |
|
501 | * | |
502 | */ |
|
502 | */ | |
503 |
|
503 | |||
504 | int status; |
|
504 | int status; | |
505 |
|
505 | |||
506 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); |
|
506 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); | |
507 | parameter_dump_packet.destinationID = TC->sourceID; |
|
507 | parameter_dump_packet.destinationID = TC->sourceID; | |
508 |
|
508 | |||
509 | // UPDATE TIME |
|
509 | // UPDATE TIME | |
510 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
510 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
511 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
511 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
512 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
512 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
513 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
513 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
514 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
514 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
515 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
515 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
516 | // SEND DATA |
|
516 | // SEND DATA | |
517 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
517 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
518 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
518 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
519 | if (status != RTEMS_SUCCESSFUL) { |
|
519 | if (status != RTEMS_SUCCESSFUL) { | |
520 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
520 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
521 | } |
|
521 | } | |
522 |
|
522 | |||
523 | return status; |
|
523 | return status; | |
524 | } |
|
524 | } | |
525 |
|
525 | |||
526 | //*********************** |
|
526 | //*********************** | |
527 | // NORMAL MODE PARAMETERS |
|
527 | // NORMAL MODE PARAMETERS | |
528 |
|
528 | |||
529 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
529 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
530 | { |
|
530 | { | |
531 | unsigned char msb; |
|
531 | unsigned char msb; | |
532 | unsigned char lsb; |
|
532 | unsigned char lsb; | |
533 | int flag; |
|
533 | int flag; | |
534 | float aux; |
|
534 | float aux; | |
535 | rtems_status_code status; |
|
535 | rtems_status_code status; | |
536 |
|
536 | |||
537 | unsigned int sy_lfr_n_swf_l; |
|
537 | unsigned int sy_lfr_n_swf_l; | |
538 | unsigned int sy_lfr_n_swf_p; |
|
538 | unsigned int sy_lfr_n_swf_p; | |
539 | unsigned int sy_lfr_n_asm_p; |
|
539 | unsigned int sy_lfr_n_asm_p; | |
540 | unsigned char sy_lfr_n_bp_p0; |
|
540 | unsigned char sy_lfr_n_bp_p0; | |
541 | unsigned char sy_lfr_n_bp_p1; |
|
541 | unsigned char sy_lfr_n_bp_p1; | |
542 | unsigned char sy_lfr_n_cwf_long_f3; |
|
542 | unsigned char sy_lfr_n_cwf_long_f3; | |
543 |
|
543 | |||
544 | flag = LFR_SUCCESSFUL; |
|
544 | flag = LFR_SUCCESSFUL; | |
545 |
|
545 | |||
546 | //*************** |
|
546 | //*************** | |
547 | // get parameters |
|
547 | // get parameters | |
548 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
548 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
549 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
549 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
550 | sy_lfr_n_swf_l = msb * 256 + lsb; |
|
550 | sy_lfr_n_swf_l = msb * 256 + lsb; | |
551 |
|
551 | |||
552 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
552 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
553 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
553 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
554 | sy_lfr_n_swf_p = msb * 256 + lsb; |
|
554 | sy_lfr_n_swf_p = msb * 256 + lsb; | |
555 |
|
555 | |||
556 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
556 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
557 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
557 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
558 | sy_lfr_n_asm_p = msb * 256 + lsb; |
|
558 | sy_lfr_n_asm_p = msb * 256 + lsb; | |
559 |
|
559 | |||
560 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
560 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
561 |
|
561 | |||
562 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
562 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
563 |
|
563 | |||
564 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
564 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
565 |
|
565 | |||
566 | //****************** |
|
566 | //****************** | |
567 | // check consistency |
|
567 | // check consistency | |
568 | // sy_lfr_n_swf_l |
|
568 | // sy_lfr_n_swf_l | |
569 | if (sy_lfr_n_swf_l != 2048) |
|
569 | if (sy_lfr_n_swf_l != 2048) | |
570 | { |
|
570 | { | |
571 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); |
|
571 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); | |
572 | flag = WRONG_APP_DATA; |
|
572 | flag = WRONG_APP_DATA; | |
573 | } |
|
573 | } | |
574 | // sy_lfr_n_swf_p |
|
574 | // sy_lfr_n_swf_p | |
575 | if (flag == LFR_SUCCESSFUL) |
|
575 | if (flag == LFR_SUCCESSFUL) | |
576 | { |
|
576 | { | |
577 | if ( sy_lfr_n_swf_p < 22 ) |
|
577 | if ( sy_lfr_n_swf_p < 22 ) | |
578 | { |
|
578 | { | |
579 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); |
|
579 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); | |
580 | flag = WRONG_APP_DATA; |
|
580 | flag = WRONG_APP_DATA; | |
581 | } |
|
581 | } | |
582 | } |
|
582 | } | |
583 | // sy_lfr_n_bp_p0 |
|
583 | // sy_lfr_n_bp_p0 | |
584 | if (flag == LFR_SUCCESSFUL) |
|
584 | if (flag == LFR_SUCCESSFUL) | |
585 | { |
|
585 | { | |
586 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
586 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) | |
587 | { |
|
587 | { | |
588 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
588 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); | |
589 | flag = WRONG_APP_DATA; |
|
589 | flag = WRONG_APP_DATA; | |
590 | } |
|
590 | } | |
591 | } |
|
591 | } | |
592 | // sy_lfr_n_asm_p |
|
592 | // sy_lfr_n_asm_p | |
593 | if (flag == LFR_SUCCESSFUL) |
|
593 | if (flag == LFR_SUCCESSFUL) | |
594 | { |
|
594 | { | |
595 | if (sy_lfr_n_asm_p == 0) |
|
595 | if (sy_lfr_n_asm_p == 0) | |
596 | { |
|
596 | { | |
597 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
597 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
598 | flag = WRONG_APP_DATA; |
|
598 | flag = WRONG_APP_DATA; | |
599 | } |
|
599 | } | |
600 | } |
|
600 | } | |
601 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
601 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 | |
602 | if (flag == LFR_SUCCESSFUL) |
|
602 | if (flag == LFR_SUCCESSFUL) | |
603 | { |
|
603 | { | |
604 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
604 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); | |
605 | if (aux > FLOAT_EQUAL_ZERO) |
|
605 | if (aux > FLOAT_EQUAL_ZERO) | |
606 | { |
|
606 | { | |
607 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
607 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
608 | flag = WRONG_APP_DATA; |
|
608 | flag = WRONG_APP_DATA; | |
609 | } |
|
609 | } | |
610 | } |
|
610 | } | |
611 | // sy_lfr_n_bp_p1 |
|
611 | // sy_lfr_n_bp_p1 | |
612 | if (flag == LFR_SUCCESSFUL) |
|
612 | if (flag == LFR_SUCCESSFUL) | |
613 | { |
|
613 | { | |
614 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
614 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) | |
615 | { |
|
615 | { | |
616 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
616 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
617 | flag = WRONG_APP_DATA; |
|
617 | flag = WRONG_APP_DATA; | |
618 | } |
|
618 | } | |
619 | } |
|
619 | } | |
620 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
620 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 | |
621 | if (flag == LFR_SUCCESSFUL) |
|
621 | if (flag == LFR_SUCCESSFUL) | |
622 | { |
|
622 | { | |
623 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
623 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); | |
624 | if (aux > FLOAT_EQUAL_ZERO) |
|
624 | if (aux > FLOAT_EQUAL_ZERO) | |
625 | { |
|
625 | { | |
626 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
626 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
627 | flag = LFR_DEFAULT; |
|
627 | flag = LFR_DEFAULT; | |
628 | } |
|
628 | } | |
629 | } |
|
629 | } | |
630 | // sy_lfr_n_cwf_long_f3 |
|
630 | // sy_lfr_n_cwf_long_f3 | |
631 |
|
631 | |||
632 | return flag; |
|
632 | return flag; | |
633 | } |
|
633 | } | |
634 |
|
634 | |||
635 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
635 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) | |
636 | { |
|
636 | { | |
637 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
637 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
638 | * |
|
638 | * | |
639 | * @param TC points to the TeleCommand packet that is being processed |
|
639 | * @param TC points to the TeleCommand packet that is being processed | |
640 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
640 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
641 | * |
|
641 | * | |
642 | */ |
|
642 | */ | |
643 |
|
643 | |||
644 | int result; |
|
644 | int result; | |
645 |
|
645 | |||
646 | result = LFR_SUCCESSFUL; |
|
646 | result = LFR_SUCCESSFUL; | |
647 |
|
647 | |||
648 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
648 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
649 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
649 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
650 |
|
650 | |||
651 | return result; |
|
651 | return result; | |
652 | } |
|
652 | } | |
653 |
|
653 | |||
654 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
654 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) | |
655 | { |
|
655 | { | |
656 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
656 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
657 | * |
|
657 | * | |
658 | * @param TC points to the TeleCommand packet that is being processed |
|
658 | * @param TC points to the TeleCommand packet that is being processed | |
659 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
659 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
660 | * |
|
660 | * | |
661 | */ |
|
661 | */ | |
662 |
|
662 | |||
663 | int result; |
|
663 | int result; | |
664 |
|
664 | |||
665 | result = LFR_SUCCESSFUL; |
|
665 | result = LFR_SUCCESSFUL; | |
666 |
|
666 | |||
667 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
667 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
668 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
668 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
669 |
|
669 | |||
670 | return result; |
|
670 | return result; | |
671 | } |
|
671 | } | |
672 |
|
672 | |||
673 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
673 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) | |
674 | { |
|
674 | { | |
675 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
675 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). | |
676 | * |
|
676 | * | |
677 | * @param TC points to the TeleCommand packet that is being processed |
|
677 | * @param TC points to the TeleCommand packet that is being processed | |
678 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
678 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
679 | * |
|
679 | * | |
680 | */ |
|
680 | */ | |
681 |
|
681 | |||
682 | int result; |
|
682 | int result; | |
683 |
|
683 | |||
684 | result = LFR_SUCCESSFUL; |
|
684 | result = LFR_SUCCESSFUL; | |
685 |
|
685 | |||
686 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
686 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
687 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
687 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
688 |
|
688 | |||
689 | return result; |
|
689 | return result; | |
690 | } |
|
690 | } | |
691 |
|
691 | |||
692 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
692 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
693 | { |
|
693 | { | |
694 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
694 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). | |
695 | * |
|
695 | * | |
696 | * @param TC points to the TeleCommand packet that is being processed |
|
696 | * @param TC points to the TeleCommand packet that is being processed | |
697 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
697 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
698 | * |
|
698 | * | |
699 | */ |
|
699 | */ | |
700 |
|
700 | |||
701 | int status; |
|
701 | int status; | |
702 |
|
702 | |||
703 | status = LFR_SUCCESSFUL; |
|
703 | status = LFR_SUCCESSFUL; | |
704 |
|
704 | |||
705 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
705 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
706 |
|
706 | |||
707 | return status; |
|
707 | return status; | |
708 | } |
|
708 | } | |
709 |
|
709 | |||
710 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
710 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) | |
711 | { |
|
711 | { | |
712 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
712 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
713 | * |
|
713 | * | |
714 | * @param TC points to the TeleCommand packet that is being processed |
|
714 | * @param TC points to the TeleCommand packet that is being processed | |
715 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
715 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
716 | * |
|
716 | * | |
717 | */ |
|
717 | */ | |
718 |
|
718 | |||
719 | int status; |
|
719 | int status; | |
720 |
|
720 | |||
721 | status = LFR_SUCCESSFUL; |
|
721 | status = LFR_SUCCESSFUL; | |
722 |
|
722 | |||
723 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
723 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
724 |
|
724 | |||
725 | return status; |
|
725 | return status; | |
726 | } |
|
726 | } | |
727 |
|
727 | |||
728 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
728 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) | |
729 | { |
|
729 | { | |
730 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
730 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. | |
731 | * |
|
731 | * | |
732 | * @param TC points to the TeleCommand packet that is being processed |
|
732 | * @param TC points to the TeleCommand packet that is being processed | |
733 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
733 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
734 | * |
|
734 | * | |
735 | */ |
|
735 | */ | |
736 |
|
736 | |||
737 | int status; |
|
737 | int status; | |
738 |
|
738 | |||
739 | status = LFR_SUCCESSFUL; |
|
739 | status = LFR_SUCCESSFUL; | |
740 |
|
740 | |||
741 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
741 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
742 |
|
742 | |||
743 | return status; |
|
743 | return status; | |
744 | } |
|
744 | } | |
745 |
|
745 | |||
746 | //********************** |
|
746 | //********************** | |
747 | // BURST MODE PARAMETERS |
|
747 | // BURST MODE PARAMETERS | |
748 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
748 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) | |
749 | { |
|
749 | { | |
750 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
750 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). | |
751 | * |
|
751 | * | |
752 | * @param TC points to the TeleCommand packet that is being processed |
|
752 | * @param TC points to the TeleCommand packet that is being processed | |
753 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
753 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
754 | * |
|
754 | * | |
755 | */ |
|
755 | */ | |
756 |
|
756 | |||
757 | int status; |
|
757 | int status; | |
758 |
|
758 | |||
759 | status = LFR_SUCCESSFUL; |
|
759 | status = LFR_SUCCESSFUL; | |
760 |
|
760 | |||
761 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
761 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
762 |
|
762 | |||
763 | return status; |
|
763 | return status; | |
764 | } |
|
764 | } | |
765 |
|
765 | |||
766 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
766 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
767 | { |
|
767 | { | |
768 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
768 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). | |
769 | * |
|
769 | * | |
770 | * @param TC points to the TeleCommand packet that is being processed |
|
770 | * @param TC points to the TeleCommand packet that is being processed | |
771 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
771 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
772 | * |
|
772 | * | |
773 | */ |
|
773 | */ | |
774 |
|
774 | |||
775 | int status; |
|
775 | int status; | |
776 |
|
776 | |||
777 | status = LFR_SUCCESSFUL; |
|
777 | status = LFR_SUCCESSFUL; | |
778 |
|
778 | |||
779 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
779 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
780 |
|
780 | |||
781 | return status; |
|
781 | return status; | |
782 | } |
|
782 | } | |
783 |
|
783 | |||
784 | //********************* |
|
784 | //********************* | |
785 | // SBM1 MODE PARAMETERS |
|
785 | // SBM1 MODE PARAMETERS | |
786 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
786 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
787 | { |
|
787 | { | |
788 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
788 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). | |
789 | * |
|
789 | * | |
790 | * @param TC points to the TeleCommand packet that is being processed |
|
790 | * @param TC points to the TeleCommand packet that is being processed | |
791 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
791 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
792 | * |
|
792 | * | |
793 | */ |
|
793 | */ | |
794 |
|
794 | |||
795 | int status; |
|
795 | int status; | |
796 |
|
796 | |||
797 | status = LFR_SUCCESSFUL; |
|
797 | status = LFR_SUCCESSFUL; | |
798 |
|
798 | |||
799 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
799 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
800 |
|
800 | |||
801 | return status; |
|
801 | return status; | |
802 | } |
|
802 | } | |
803 |
|
803 | |||
804 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
804 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
805 | { |
|
805 | { | |
806 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
806 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). | |
807 | * |
|
807 | * | |
808 | * @param TC points to the TeleCommand packet that is being processed |
|
808 | * @param TC points to the TeleCommand packet that is being processed | |
809 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
809 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
810 | * |
|
810 | * | |
811 | */ |
|
811 | */ | |
812 |
|
812 | |||
813 | int status; |
|
813 | int status; | |
814 |
|
814 | |||
815 | status = LFR_SUCCESSFUL; |
|
815 | status = LFR_SUCCESSFUL; | |
816 |
|
816 | |||
817 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
817 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
818 |
|
818 | |||
819 | return status; |
|
819 | return status; | |
820 | } |
|
820 | } | |
821 |
|
821 | |||
822 | //********************* |
|
822 | //********************* | |
823 | // SBM2 MODE PARAMETERS |
|
823 | // SBM2 MODE PARAMETERS | |
824 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
824 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
825 | { |
|
825 | { | |
826 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
826 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). | |
827 | * |
|
827 | * | |
828 | * @param TC points to the TeleCommand packet that is being processed |
|
828 | * @param TC points to the TeleCommand packet that is being processed | |
829 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
829 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
830 | * |
|
830 | * | |
831 | */ |
|
831 | */ | |
832 |
|
832 | |||
833 | int status; |
|
833 | int status; | |
834 |
|
834 | |||
835 | status = LFR_SUCCESSFUL; |
|
835 | status = LFR_SUCCESSFUL; | |
836 |
|
836 | |||
837 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
837 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
838 |
|
838 | |||
839 | return status; |
|
839 | return status; | |
840 | } |
|
840 | } | |
841 |
|
841 | |||
842 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
842 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
843 | { |
|
843 | { | |
844 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
844 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). | |
845 | * |
|
845 | * | |
846 | * @param TC points to the TeleCommand packet that is being processed |
|
846 | * @param TC points to the TeleCommand packet that is being processed | |
847 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
847 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
848 | * |
|
848 | * | |
849 | */ |
|
849 | */ | |
850 |
|
850 | |||
851 | int status; |
|
851 | int status; | |
852 |
|
852 | |||
853 | status = LFR_SUCCESSFUL; |
|
853 | status = LFR_SUCCESSFUL; | |
854 |
|
854 | |||
855 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
855 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
856 |
|
856 | |||
857 | return status; |
|
857 | return status; | |
858 | } |
|
858 | } | |
859 |
|
859 | |||
860 | //******************* |
|
860 | //******************* | |
861 | // TC_LFR_UPDATE_INFO |
|
861 | // TC_LFR_UPDATE_INFO | |
862 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
862 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) | |
863 | { |
|
863 | { | |
864 | unsigned int status; |
|
864 | unsigned int status; | |
865 |
|
865 | |||
866 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
866 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) | |
867 | || (mode == LFR_MODE_BURST) |
|
867 | || (mode == LFR_MODE_BURST) | |
868 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
868 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) | |
869 | { |
|
869 | { | |
870 | status = LFR_SUCCESSFUL; |
|
870 | status = LFR_SUCCESSFUL; | |
871 | } |
|
871 | } | |
872 | else |
|
872 | else | |
873 | { |
|
873 | { | |
874 | status = LFR_DEFAULT; |
|
874 | status = LFR_DEFAULT; | |
875 | } |
|
875 | } | |
876 |
|
876 | |||
877 | return status; |
|
877 | return status; | |
878 | } |
|
878 | } | |
879 |
|
879 | |||
880 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
880 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) | |
881 | { |
|
881 | { | |
882 | unsigned int status; |
|
882 | unsigned int status; | |
883 |
|
883 | |||
884 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
884 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) | |
885 | || (mode == TDS_MODE_BURST) |
|
885 | || (mode == TDS_MODE_BURST) | |
886 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
886 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) | |
887 | || (mode == TDS_MODE_LFM)) |
|
887 | || (mode == TDS_MODE_LFM)) | |
888 | { |
|
888 | { | |
889 | status = LFR_SUCCESSFUL; |
|
889 | status = LFR_SUCCESSFUL; | |
890 | } |
|
890 | } | |
891 | else |
|
891 | else | |
892 | { |
|
892 | { | |
893 | status = LFR_DEFAULT; |
|
893 | status = LFR_DEFAULT; | |
894 | } |
|
894 | } | |
895 |
|
895 | |||
896 | return status; |
|
896 | return status; | |
897 | } |
|
897 | } | |
898 |
|
898 | |||
899 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
899 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) | |
900 | { |
|
900 | { | |
901 | unsigned int status; |
|
901 | unsigned int status; | |
902 |
|
902 | |||
903 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
903 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) | |
904 | || (mode == THR_MODE_BURST)) |
|
904 | || (mode == THR_MODE_BURST)) | |
905 | { |
|
905 | { | |
906 | status = LFR_SUCCESSFUL; |
|
906 | status = LFR_SUCCESSFUL; | |
907 | } |
|
907 | } | |
908 | else |
|
908 | else | |
909 | { |
|
909 | { | |
910 | status = LFR_DEFAULT; |
|
910 | status = LFR_DEFAULT; | |
911 | } |
|
911 | } | |
912 |
|
912 | |||
913 | return status; |
|
913 | return status; | |
914 | } |
|
914 | } | |
915 |
|
915 | |||
916 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ) |
|
916 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ) | |
917 | { |
|
917 | { | |
918 | /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally. |
|
918 | /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally. | |
919 | * |
|
919 | * | |
920 | * @param TC points to the TeleCommand packet that is being processed |
|
920 | * @param TC points to the TeleCommand packet that is being processed | |
921 | * |
|
921 | * | |
922 | */ |
|
922 | */ | |
923 |
|
923 | |||
924 | unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet |
|
924 | unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet | |
925 |
|
925 | |||
926 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
926 | bytePosPtr = (unsigned char *) &TC->packetID; | |
927 |
|
927 | |||
928 | // cp_rpw_sc_rw1_f1 |
|
928 | // cp_rpw_sc_rw1_f1 | |
929 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1, |
|
929 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1, | |
930 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] ); |
|
930 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] ); | |
931 |
|
931 | |||
932 | // cp_rpw_sc_rw1_f2 |
|
932 | // cp_rpw_sc_rw1_f2 | |
933 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2, |
|
933 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2, | |
934 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] ); |
|
934 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] ); | |
935 |
|
935 | |||
936 | // cp_rpw_sc_rw2_f1 |
|
936 | // cp_rpw_sc_rw2_f1 | |
937 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1, |
|
937 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1, | |
938 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] ); |
|
938 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] ); | |
939 |
|
939 | |||
940 | // cp_rpw_sc_rw2_f2 |
|
940 | // cp_rpw_sc_rw2_f2 | |
941 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2, |
|
941 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2, | |
942 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] ); |
|
942 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] ); | |
943 |
|
943 | |||
944 | // cp_rpw_sc_rw3_f1 |
|
944 | // cp_rpw_sc_rw3_f1 | |
945 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1, |
|
945 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1, | |
946 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] ); |
|
946 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] ); | |
947 |
|
947 | |||
948 | // cp_rpw_sc_rw3_f2 |
|
948 | // cp_rpw_sc_rw3_f2 | |
949 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2, |
|
949 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2, | |
950 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] ); |
|
950 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] ); | |
951 |
|
951 | |||
952 | // cp_rpw_sc_rw4_f1 |
|
952 | // cp_rpw_sc_rw4_f1 | |
953 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1, |
|
953 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1, | |
954 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] ); |
|
954 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] ); | |
955 |
|
955 | |||
956 | // cp_rpw_sc_rw4_f2 |
|
956 | // cp_rpw_sc_rw4_f2 | |
957 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2, |
|
957 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2, | |
958 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] ); |
|
958 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] ); | |
959 | } |
|
959 | } | |
960 |
|
960 | |||
961 | void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag ) |
|
961 | void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag ) | |
962 | { |
|
962 | { | |
963 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
963 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
964 | * |
|
964 | * | |
965 | * @param fbins_mask |
|
965 | * @param fbins_mask | |
966 | * @param rw_f is the reaction wheel frequency to filter |
|
966 | * @param rw_f is the reaction wheel frequency to filter | |
967 | * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel |
|
967 | * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel | |
968 | * @param flag [true] filtering enabled [false] filtering disabled |
|
968 | * @param flag [true] filtering enabled [false] filtering disabled | |
969 | * |
|
969 | * | |
970 | * @return void |
|
970 | * @return void | |
971 | * |
|
971 | * | |
972 | */ |
|
972 | */ | |
973 |
|
973 | |||
974 | float fmin; |
|
974 | float fmin; | |
975 | float fMAX; |
|
975 | float fMAX; | |
976 | int binBelow; |
|
976 | int binBelow; | |
977 | int binAbove; |
|
977 | int binAbove; | |
978 | unsigned int whichByte; |
|
978 | unsigned int whichByte; | |
979 | unsigned char selectedByte; |
|
979 | unsigned char selectedByte; | |
980 | int bin; |
|
980 | int bin; | |
981 |
|
981 | |||
982 | whichByte = 0; |
|
982 | whichByte = 0; | |
983 | bin = 0; |
|
983 | bin = 0; | |
984 |
|
984 | |||
985 | // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ] |
|
985 | // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ] | |
986 | fmin = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.; |
|
986 | fmin = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.; | |
987 | fMAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.; |
|
987 | fMAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.; | |
988 |
|
988 | |||
989 | // compute the index of the frequency bin immediately below fmin |
|
989 | // compute the index of the frequency bin immediately below fmin | |
990 | binBelow = (int) ( floor( ((double) fmin) / ((double) deltaFreq)) ); |
|
990 | binBelow = (int) ( floor( ((double) fmin) / ((double) deltaFreq)) ); | |
991 |
|
991 | |||
992 | // compute the index of the frequency bin immediately above fMAX |
|
992 | // compute the index of the frequency bin immediately above fMAX | |
993 | binAbove = (int) ( floor( ((double) fMAX) / ((double) deltaFreq)) ); |
|
993 | binAbove = (int) ( floor( ((double) fMAX) / ((double) deltaFreq)) ); | |
994 |
|
994 | |||
995 | for (bin = binBelow; bin <= binAbove; bin++) |
|
995 | for (bin = binBelow; bin <= binAbove; bin++) | |
996 | { |
|
996 | { | |
997 | if ( (bin >= 0) && (bin<=127) ) |
|
997 | if ( (bin >= 0) && (bin<=127) ) | |
998 | { |
|
998 | { | |
999 | if (flag == 1) |
|
999 | if (flag == 1) | |
1000 | { |
|
1000 | { | |
1001 | whichByte = bin >> 3; // division by 8 |
|
1001 | whichByte = bin >> 3; // division by 8 | |
1002 | selectedByte = (unsigned char) ( 1 << (bin - (whichByte * 8)) ); |
|
1002 | selectedByte = (unsigned char) ( 1 << (bin - (whichByte * 8)) ); | |
1003 | fbins_mask[whichByte] = fbins_mask[whichByte] & (~selectedByte); |
|
1003 | fbins_mask[whichByte] = fbins_mask[whichByte] & (~selectedByte); | |
1004 | } |
|
1004 | } | |
1005 | } |
|
1005 | } | |
1006 | } |
|
1006 | } | |
1007 | } |
|
1007 | } | |
1008 |
|
1008 | |||
1009 | void build_sy_lfr_rw_mask( unsigned int channel ) |
|
1009 | void build_sy_lfr_rw_mask( unsigned int channel ) | |
1010 | { |
|
1010 | { | |
1011 | unsigned char local_rw_fbins_mask[16]; |
|
1011 | unsigned char local_rw_fbins_mask[16]; | |
1012 | unsigned char *maskPtr; |
|
1012 | unsigned char *maskPtr; | |
1013 | double deltaF; |
|
1013 | double deltaF; | |
1014 | unsigned k; |
|
1014 | unsigned k; | |
1015 |
|
1015 | |||
1016 | k = 0; |
|
1016 | k = 0; | |
1017 |
|
1017 | |||
1018 | maskPtr = NULL; |
|
1018 | maskPtr = NULL; | |
1019 | deltaF = 1.; |
|
1019 | deltaF = 1.; | |
1020 |
|
1020 | |||
1021 | switch (channel) |
|
1021 | switch (channel) | |
1022 | { |
|
1022 | { | |
1023 | case 0: |
|
1023 | case 0: | |
1024 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1024 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; | |
1025 | deltaF = 96.; |
|
1025 | deltaF = 96.; | |
1026 | break; |
|
1026 | break; | |
1027 | case 1: |
|
1027 | case 1: | |
1028 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1028 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; | |
1029 | deltaF = 16.; |
|
1029 | deltaF = 16.; | |
1030 | break; |
|
1030 | break; | |
1031 | case 2: |
|
1031 | case 2: | |
1032 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1032 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; | |
1033 | deltaF = 1.; |
|
1033 | deltaF = 1.; | |
1034 | break; |
|
1034 | break; | |
1035 | default: |
|
1035 | default: | |
1036 | break; |
|
1036 | break; | |
1037 | } |
|
1037 | } | |
1038 |
|
1038 | |||
1039 | for (k = 0; k < 16; k++) |
|
1039 | for (k = 0; k < 16; k++) | |
1040 | { |
|
1040 | { | |
1041 | local_rw_fbins_mask[k] = 0xff; |
|
1041 | local_rw_fbins_mask[k] = 0xff; | |
1042 | } |
|
1042 | } | |
1043 |
|
1043 | |||
1044 | // RW1 F1 |
|
1044 | // RW1 F1 | |
1045 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000] |
|
1045 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000] | |
1046 |
|
1046 | |||
1047 | // RW1 F2 |
|
1047 | // RW1 F2 | |
1048 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000] |
|
1048 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000] | |
1049 |
|
1049 | |||
1050 | // RW2 F1 |
|
1050 | // RW2 F1 | |
1051 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000] |
|
1051 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000] | |
1052 |
|
1052 | |||
1053 | // RW2 F2 |
|
1053 | // RW2 F2 | |
1054 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000] |
|
1054 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000] | |
1055 |
|
1055 | |||
1056 | // RW3 F1 |
|
1056 | // RW3 F1 | |
1057 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000] |
|
1057 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000] | |
1058 |
|
1058 | |||
1059 | // RW3 F2 |
|
1059 | // RW3 F2 | |
1060 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100] |
|
1060 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100] | |
1061 |
|
1061 | |||
1062 | // RW4 F1 |
|
1062 | // RW4 F1 | |
1063 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010] |
|
1063 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010] | |
1064 |
|
1064 | |||
1065 | // RW4 F2 |
|
1065 | // RW4 F2 | |
1066 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001] |
|
1066 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001] | |
1067 |
|
1067 | |||
1068 | // update the value of the fbins related to reaction wheels frequency filtering |
|
1068 | // update the value of the fbins related to reaction wheels frequency filtering | |
1069 | if (maskPtr != NULL) |
|
1069 | if (maskPtr != NULL) | |
1070 | { |
|
1070 | { | |
1071 | for (k = 0; k < 16; k++) |
|
1071 | for (k = 0; k < 16; k++) | |
1072 | { |
|
1072 | { | |
1073 | maskPtr[k] = local_rw_fbins_mask[k]; |
|
1073 | maskPtr[k] = local_rw_fbins_mask[k]; | |
1074 | } |
|
1074 | } | |
1075 | } |
|
1075 | } | |
1076 | } |
|
1076 | } | |
1077 |
|
1077 | |||
1078 | void build_sy_lfr_rw_masks( void ) |
|
1078 | void build_sy_lfr_rw_masks( void ) | |
1079 | { |
|
1079 | { | |
1080 | build_sy_lfr_rw_mask( 0 ); |
|
1080 | build_sy_lfr_rw_mask( 0 ); | |
1081 | build_sy_lfr_rw_mask( 1 ); |
|
1081 | build_sy_lfr_rw_mask( 1 ); | |
1082 | build_sy_lfr_rw_mask( 2 ); |
|
1082 | build_sy_lfr_rw_mask( 2 ); | |
1083 |
|
1083 | |||
1084 | merge_fbins_masks(); |
|
1084 | merge_fbins_masks(); | |
1085 | } |
|
1085 | } | |
1086 |
|
1086 | |||
1087 | void merge_fbins_masks( void ) |
|
1087 | void merge_fbins_masks( void ) | |
1088 | { |
|
1088 | { | |
1089 | unsigned char k; |
|
1089 | unsigned char k; | |
1090 |
|
1090 | |||
1091 | unsigned char *fbins_f0; |
|
1091 | unsigned char *fbins_f0; | |
1092 | unsigned char *fbins_f1; |
|
1092 | unsigned char *fbins_f1; | |
1093 | unsigned char *fbins_f2; |
|
1093 | unsigned char *fbins_f2; | |
1094 | unsigned char *rw_mask_f0; |
|
1094 | unsigned char *rw_mask_f0; | |
1095 | unsigned char *rw_mask_f1; |
|
1095 | unsigned char *rw_mask_f1; | |
1096 | unsigned char *rw_mask_f2; |
|
1096 | unsigned char *rw_mask_f2; | |
1097 |
|
1097 | |||
1098 | fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1098 | fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
1099 | fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; |
|
1099 | fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; | |
1100 | fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1; |
|
1100 | fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1; | |
1101 | rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1101 | rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; | |
1102 | rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1102 | rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; | |
1103 | rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1103 | rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; | |
1104 |
|
1104 | |||
1105 | for( k=0; k < 16; k++ ) |
|
1105 | for( k=0; k < 16; k++ ) | |
1106 | { |
|
1106 | { | |
1107 | fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k]; |
|
1107 | fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k]; | |
1108 | fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k]; |
|
1108 | fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k]; | |
1109 | fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k]; |
|
1109 | fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k]; | |
1110 | } |
|
1110 | } | |
1111 | } |
|
1111 | } | |
1112 |
|
1112 | |||
1113 | //*********** |
|
1113 | //*********** | |
1114 | // FBINS MASK |
|
1114 | // FBINS MASK | |
1115 |
|
1115 | |||
1116 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
1116 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) | |
1117 | { |
|
1117 | { | |
1118 | int status; |
|
1118 | int status; | |
1119 | unsigned int k; |
|
1119 | unsigned int k; | |
1120 | unsigned char *fbins_mask_dump; |
|
1120 | unsigned char *fbins_mask_dump; | |
1121 | unsigned char *fbins_mask_TC; |
|
1121 | unsigned char *fbins_mask_TC; | |
1122 |
|
1122 | |||
1123 | status = LFR_SUCCESSFUL; |
|
1123 | status = LFR_SUCCESSFUL; | |
1124 |
|
1124 | |||
1125 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1125 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
1126 | fbins_mask_TC = TC->dataAndCRC; |
|
1126 | fbins_mask_TC = TC->dataAndCRC; | |
1127 |
|
1127 | |||
1128 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1128 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
1129 | { |
|
1129 | { | |
1130 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
1130 | fbins_mask_dump[k] = fbins_mask_TC[k]; | |
1131 | } |
|
1131 | } | |
1132 |
|
1132 | |||
1133 | return status; |
|
1133 | return status; | |
1134 | } |
|
1134 | } | |
1135 |
|
1135 | |||
1136 | //*************************** |
|
1136 | //*************************** | |
1137 | // TC_LFR_LOAD_PAS_FILTER_PAR |
|
1137 | // TC_LFR_LOAD_PAS_FILTER_PAR | |
1138 |
|
1138 | |||
1139 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
1139 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
1140 | { |
|
1140 | { | |
1141 | int flag; |
|
1141 | int flag; | |
1142 | rtems_status_code status; |
|
1142 | rtems_status_code status; | |
1143 |
|
1143 | |||
1144 | unsigned char sy_lfr_pas_filter_enabled; |
|
1144 | unsigned char sy_lfr_pas_filter_enabled; | |
1145 | unsigned char sy_lfr_pas_filter_modulus; |
|
1145 | unsigned char sy_lfr_pas_filter_modulus; | |
1146 | float sy_lfr_pas_filter_tbad; |
|
1146 | float sy_lfr_pas_filter_tbad; | |
1147 | unsigned char sy_lfr_pas_filter_offset; |
|
1147 | unsigned char sy_lfr_pas_filter_offset; | |
1148 | float sy_lfr_pas_filter_shift; |
|
1148 | float sy_lfr_pas_filter_shift; | |
1149 | float sy_lfr_sc_rw_delta_f; |
|
1149 | float sy_lfr_sc_rw_delta_f; | |
1150 | char *parPtr; |
|
1150 | char *parPtr; | |
1151 |
|
1151 | |||
1152 | flag = LFR_SUCCESSFUL; |
|
1152 | flag = LFR_SUCCESSFUL; | |
1153 | sy_lfr_pas_filter_tbad = 0.0; |
|
1153 | sy_lfr_pas_filter_tbad = 0.0; | |
1154 | sy_lfr_pas_filter_shift = 0.0; |
|
1154 | sy_lfr_pas_filter_shift = 0.0; | |
1155 | sy_lfr_sc_rw_delta_f = 0.0; |
|
1155 | sy_lfr_sc_rw_delta_f = 0.0; | |
1156 | parPtr = NULL; |
|
1156 | parPtr = NULL; | |
1157 |
|
1157 | |||
1158 | //*************** |
|
1158 | //*************** | |
1159 | // get parameters |
|
1159 | // get parameters | |
1160 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001] |
|
1160 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001] | |
1161 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
1161 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; | |
1162 | copyFloatByChar( |
|
1162 | copyFloatByChar( | |
1163 | (unsigned char*) &sy_lfr_pas_filter_tbad, |
|
1163 | (unsigned char*) &sy_lfr_pas_filter_tbad, | |
1164 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ] |
|
1164 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ] | |
1165 | ); |
|
1165 | ); | |
1166 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
1166 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |
1167 | copyFloatByChar( |
|
1167 | copyFloatByChar( | |
1168 | (unsigned char*) &sy_lfr_pas_filter_shift, |
|
1168 | (unsigned char*) &sy_lfr_pas_filter_shift, | |
1169 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ] |
|
1169 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ] | |
1170 | ); |
|
1170 | ); | |
1171 | copyFloatByChar( |
|
1171 | copyFloatByChar( | |
1172 | (unsigned char*) &sy_lfr_sc_rw_delta_f, |
|
1172 | (unsigned char*) &sy_lfr_sc_rw_delta_f, | |
1173 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ] |
|
1173 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ] | |
1174 | ); |
|
1174 | ); | |
1175 |
|
1175 | |||
1176 | //****************** |
|
1176 | //****************** | |
1177 | // CHECK CONSISTENCY |
|
1177 | // CHECK CONSISTENCY | |
1178 |
|
1178 | |||
1179 | //************************** |
|
1179 | //************************** | |
1180 | // sy_lfr_pas_filter_enabled |
|
1180 | // sy_lfr_pas_filter_enabled | |
1181 | // nothing to check, value is 0 or 1 |
|
1181 | // nothing to check, value is 0 or 1 | |
1182 |
|
1182 | |||
1183 | //************************** |
|
1183 | //************************** | |
1184 | // sy_lfr_pas_filter_modulus |
|
1184 | // sy_lfr_pas_filter_modulus | |
1185 | if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) ) |
|
1185 | if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) ) | |
1186 | { |
|
1186 | { | |
1187 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus ); |
|
1187 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus ); | |
1188 | flag = WRONG_APP_DATA; |
|
1188 | flag = WRONG_APP_DATA; | |
1189 | } |
|
1189 | } | |
1190 |
|
1190 | |||
1191 | //*********************** |
|
1191 | //*********************** | |
1192 | // sy_lfr_pas_filter_tbad |
|
1192 | // sy_lfr_pas_filter_tbad | |
1193 | if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) ) |
|
1193 | if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) ) | |
1194 | { |
|
1194 | { | |
1195 | parPtr = (char*) &sy_lfr_pas_filter_tbad; |
|
1195 | parPtr = (char*) &sy_lfr_pas_filter_tbad; | |
1196 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] ); |
|
1196 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] ); | |
1197 | flag = WRONG_APP_DATA; |
|
1197 | flag = WRONG_APP_DATA; | |
1198 | } |
|
1198 | } | |
1199 |
|
1199 | |||
1200 | //************************* |
|
1200 | //************************* | |
1201 | // sy_lfr_pas_filter_offset |
|
1201 | // sy_lfr_pas_filter_offset | |
1202 | if (flag == LFR_SUCCESSFUL) |
|
1202 | if (flag == LFR_SUCCESSFUL) | |
1203 | { |
|
1203 | { | |
1204 | if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) ) |
|
1204 | if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) ) | |
1205 | { |
|
1205 | { | |
1206 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset ); |
|
1206 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset ); | |
1207 | flag = WRONG_APP_DATA; |
|
1207 | flag = WRONG_APP_DATA; | |
1208 | } |
|
1208 | } | |
1209 | } |
|
1209 | } | |
1210 |
|
1210 | |||
1211 | //************************ |
|
1211 | //************************ | |
1212 | // sy_lfr_pas_filter_shift |
|
1212 | // sy_lfr_pas_filter_shift | |
1213 | if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) ) |
|
1213 | if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) ) | |
1214 | { |
|
1214 | { | |
1215 | parPtr = (char*) &sy_lfr_pas_filter_shift; |
|
1215 | parPtr = (char*) &sy_lfr_pas_filter_shift; | |
1216 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] ); |
|
1216 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] ); | |
1217 | flag = WRONG_APP_DATA; |
|
1217 | flag = WRONG_APP_DATA; | |
1218 | } |
|
1218 | } | |
1219 |
|
1219 | |||
1220 | //********************* |
|
1220 | //********************* | |
1221 | // sy_lfr_sc_rw_delta_f |
|
1221 | // sy_lfr_sc_rw_delta_f | |
1222 | // nothing to check, no default value in the ICD |
|
1222 | // nothing to check, no default value in the ICD | |
1223 |
|
1223 | |||
1224 | return flag; |
|
1224 | return flag; | |
1225 | } |
|
1225 | } | |
1226 |
|
1226 | |||
1227 | //************** |
|
1227 | //************** | |
1228 | // KCOEFFICIENTS |
|
1228 | // KCOEFFICIENTS | |
1229 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
1229 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) | |
1230 | { |
|
1230 | { | |
1231 | unsigned int kcoeff; |
|
1231 | unsigned int kcoeff; | |
1232 | unsigned short sy_lfr_kcoeff_frequency; |
|
1232 | unsigned short sy_lfr_kcoeff_frequency; | |
1233 | unsigned short bin; |
|
1233 | unsigned short bin; | |
1234 | unsigned short *freqPtr; |
|
1234 | unsigned short *freqPtr; | |
1235 | float *kcoeffPtr_norm; |
|
1235 | float *kcoeffPtr_norm; | |
1236 | float *kcoeffPtr_sbm; |
|
1236 | float *kcoeffPtr_sbm; | |
1237 | int status; |
|
1237 | int status; | |
1238 | unsigned char *kcoeffLoadPtr; |
|
1238 | unsigned char *kcoeffLoadPtr; | |
1239 | unsigned char *kcoeffNormPtr; |
|
1239 | unsigned char *kcoeffNormPtr; | |
1240 | unsigned char *kcoeffSbmPtr_a; |
|
1240 | unsigned char *kcoeffSbmPtr_a; | |
1241 | unsigned char *kcoeffSbmPtr_b; |
|
1241 | unsigned char *kcoeffSbmPtr_b; | |
1242 |
|
1242 | |||
1243 | status = LFR_SUCCESSFUL; |
|
1243 | status = LFR_SUCCESSFUL; | |
1244 |
|
1244 | |||
1245 | kcoeffPtr_norm = NULL; |
|
1245 | kcoeffPtr_norm = NULL; | |
1246 | kcoeffPtr_sbm = NULL; |
|
1246 | kcoeffPtr_sbm = NULL; | |
1247 | bin = 0; |
|
1247 | bin = 0; | |
1248 |
|
1248 | |||
1249 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; |
|
1249 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; | |
1250 | sy_lfr_kcoeff_frequency = *freqPtr; |
|
1250 | sy_lfr_kcoeff_frequency = *freqPtr; | |
1251 |
|
1251 | |||
1252 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
1252 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) | |
1253 | { |
|
1253 | { | |
1254 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
1254 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) | |
1255 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, |
|
1255 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, | |
1256 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
1256 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB | |
1257 | status = LFR_DEFAULT; |
|
1257 | status = LFR_DEFAULT; | |
1258 | } |
|
1258 | } | |
1259 | else |
|
1259 | else | |
1260 | { |
|
1260 | { | |
1261 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
1261 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) | |
1262 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
1262 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) | |
1263 | { |
|
1263 | { | |
1264 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
1264 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; | |
1265 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
1265 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; | |
1266 | bin = sy_lfr_kcoeff_frequency; |
|
1266 | bin = sy_lfr_kcoeff_frequency; | |
1267 | } |
|
1267 | } | |
1268 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
1268 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) | |
1269 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
1269 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) | |
1270 | { |
|
1270 | { | |
1271 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
1271 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; | |
1272 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
1272 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; | |
1273 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
1273 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; | |
1274 | } |
|
1274 | } | |
1275 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
1275 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) | |
1276 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
1276 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) | |
1277 | { |
|
1277 | { | |
1278 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
1278 | kcoeffPtr_norm = k_coeff_intercalib_f2; | |
1279 | kcoeffPtr_sbm = NULL; |
|
1279 | kcoeffPtr_sbm = NULL; | |
1280 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
1280 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
1281 | } |
|
1281 | } | |
1282 | } |
|
1282 | } | |
1283 |
|
1283 | |||
1284 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
1284 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products | |
1285 | { |
|
1285 | { | |
1286 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1286 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1287 | { |
|
1287 | { | |
1288 | // destination |
|
1288 | // destination | |
1289 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
1289 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; | |
1290 | // source |
|
1290 | // source | |
1291 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
1291 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
1292 | // copy source to destination |
|
1292 | // copy source to destination | |
1293 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
1293 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); | |
1294 | } |
|
1294 | } | |
1295 | } |
|
1295 | } | |
1296 |
|
1296 | |||
1297 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
1297 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products | |
1298 | { |
|
1298 | { | |
1299 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1299 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1300 | { |
|
1300 | { | |
1301 | // destination |
|
1301 | // destination | |
1302 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; |
|
1302 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; | |
1303 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; |
|
1303 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; | |
1304 | // source |
|
1304 | // source | |
1305 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
1305 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
1306 | // copy source to destination |
|
1306 | // copy source to destination | |
1307 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
1307 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); | |
1308 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
1308 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); | |
1309 | } |
|
1309 | } | |
1310 | } |
|
1310 | } | |
1311 |
|
1311 | |||
1312 | // print_k_coeff(); |
|
1312 | // print_k_coeff(); | |
1313 |
|
1313 | |||
1314 | return status; |
|
1314 | return status; | |
1315 | } |
|
1315 | } | |
1316 |
|
1316 | |||
1317 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
1317 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) | |
1318 | { |
|
1318 | { | |
1319 | destination[0] = source[0]; |
|
1319 | destination[0] = source[0]; | |
1320 | destination[1] = source[1]; |
|
1320 | destination[1] = source[1]; | |
1321 | destination[2] = source[2]; |
|
1321 | destination[2] = source[2]; | |
1322 | destination[3] = source[3]; |
|
1322 | destination[3] = source[3]; | |
1323 | } |
|
1323 | } | |
1324 |
|
1324 | |||
|
1325 | void floatToChar( float value, unsigned char* ptr) | |||
|
1326 | { | |||
|
1327 | unsigned char* valuePtr; | |||
|
1328 | ||||
|
1329 | valuePtr = (unsigned char*) &value; | |||
|
1330 | ptr[0] = valuePtr[0]; | |||
|
1331 | ptr[1] = valuePtr[0]; | |||
|
1332 | ptr[2] = valuePtr[0]; | |||
|
1333 | ptr[3] = valuePtr[0]; | |||
|
1334 | } | |||
|
1335 | ||||
1325 | //********** |
|
1336 | //********** | |
1326 | // init dump |
|
1337 | // init dump | |
1327 |
|
1338 | |||
1328 | void init_parameter_dump( void ) |
|
1339 | void init_parameter_dump( void ) | |
1329 | { |
|
1340 | { | |
1330 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
1341 | /** This function initialize the parameter_dump_packet global variable with default values. | |
1331 | * |
|
1342 | * | |
1332 | */ |
|
1343 | */ | |
1333 |
|
1344 | |||
1334 | unsigned int k; |
|
1345 | unsigned int k; | |
1335 |
|
1346 | |||
1336 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1347 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1337 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1348 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1338 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
1349 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
1339 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1350 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
1340 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
1351 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); | |
1341 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1352 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1342 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1353 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1343 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1354 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1344 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
1355 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); | |
1345 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1356 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
1346 | // DATA FIELD HEADER |
|
1357 | // DATA FIELD HEADER | |
1347 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1358 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1348 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1359 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
1349 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1360 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
1350 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1361 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
1351 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1362 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
1352 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1363 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
1353 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1364 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
1354 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1365 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
1355 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1366 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
1356 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1367 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
1357 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1368 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
1358 |
|
1369 | |||
1359 | //****************** |
|
1370 | //****************** | |
1360 | // COMMON PARAMETERS |
|
1371 | // COMMON PARAMETERS | |
1361 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1372 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; | |
1362 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1373 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; | |
1363 |
|
1374 | |||
1364 | //****************** |
|
1375 | //****************** | |
1365 | // NORMAL PARAMETERS |
|
1376 | // NORMAL PARAMETERS | |
1366 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); |
|
1377 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); | |
1367 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1378 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); | |
1368 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); |
|
1379 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); | |
1369 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1380 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); | |
1370 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); |
|
1381 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); | |
1371 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1382 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); | |
1372 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1383 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; | |
1373 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1384 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; | |
1374 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1385 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; | |
1375 |
|
1386 | |||
1376 | //***************** |
|
1387 | //***************** | |
1377 | // BURST PARAMETERS |
|
1388 | // BURST PARAMETERS | |
1378 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1389 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
1379 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1390 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
1380 |
|
1391 | |||
1381 | //**************** |
|
1392 | //**************** | |
1382 | // SBM1 PARAMETERS |
|
1393 | // SBM1 PARAMETERS | |
1383 | 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 |
|
1394 | 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 | |
1384 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1395 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
1385 |
|
1396 | |||
1386 | //**************** |
|
1397 | //**************** | |
1387 | // SBM2 PARAMETERS |
|
1398 | // SBM2 PARAMETERS | |
1388 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1399 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
1389 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1400 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
1390 |
|
1401 | |||
1391 | //************ |
|
1402 | //************ | |
1392 | // FBINS MASKS |
|
1403 | // FBINS MASKS | |
1393 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1404 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
1394 | { |
|
1405 | { | |
1395 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; |
|
1406 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; | |
1396 | } |
|
1407 | } | |
|
1408 | ||||
|
1409 | // PAS FILTER PARAMETERS | |||
|
1410 | parameter_dump_packet.pa_rpw_spare8_2 = 0x00; | |||
|
1411 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00; | |||
|
1412 | parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; | |||
|
1413 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad ); | |||
|
1414 | parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; | |||
|
1415 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift ); | |||
|
1416 | floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f ); | |||
|
1417 | ||||
|
1418 | // LFR_RW_MASK | |||
|
1419 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |||
|
1420 | { | |||
|
1421 | parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = 0xff; | |||
|
1422 | } | |||
1397 | } |
|
1423 | } | |
1398 |
|
1424 | |||
1399 | void init_kcoefficients_dump( void ) |
|
1425 | void init_kcoefficients_dump( void ) | |
1400 | { |
|
1426 | { | |
1401 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); |
|
1427 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); | |
1402 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); |
|
1428 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); | |
1403 |
|
1429 | |||
1404 | kcoefficient_node_1.previous = NULL; |
|
1430 | kcoefficient_node_1.previous = NULL; | |
1405 | kcoefficient_node_1.next = NULL; |
|
1431 | kcoefficient_node_1.next = NULL; | |
1406 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1432 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; | |
1407 | kcoefficient_node_1.coarseTime = 0x00; |
|
1433 | kcoefficient_node_1.coarseTime = 0x00; | |
1408 | kcoefficient_node_1.fineTime = 0x00; |
|
1434 | kcoefficient_node_1.fineTime = 0x00; | |
1409 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1435 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; | |
1410 | kcoefficient_node_1.status = 0x00; |
|
1436 | kcoefficient_node_1.status = 0x00; | |
1411 |
|
1437 | |||
1412 | kcoefficient_node_2.previous = NULL; |
|
1438 | kcoefficient_node_2.previous = NULL; | |
1413 | kcoefficient_node_2.next = NULL; |
|
1439 | kcoefficient_node_2.next = NULL; | |
1414 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1440 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; | |
1415 | kcoefficient_node_2.coarseTime = 0x00; |
|
1441 | kcoefficient_node_2.coarseTime = 0x00; | |
1416 | kcoefficient_node_2.fineTime = 0x00; |
|
1442 | kcoefficient_node_2.fineTime = 0x00; | |
1417 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1443 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; | |
1418 | kcoefficient_node_2.status = 0x00; |
|
1444 | kcoefficient_node_2.status = 0x00; | |
1419 | } |
|
1445 | } | |
1420 |
|
1446 | |||
1421 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1447 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) | |
1422 | { |
|
1448 | { | |
1423 | unsigned int k; |
|
1449 | unsigned int k; | |
1424 | unsigned int packetLength; |
|
1450 | unsigned int packetLength; | |
1425 |
|
1451 | |||
1426 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1452 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header | |
1427 |
|
1453 | |||
1428 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1454 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1429 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1455 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1430 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1456 | kcoefficients_dump->reserved = CCSDS_RESERVED; | |
1431 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1457 | kcoefficients_dump->userApplication = CCSDS_USER_APP; | |
1432 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; |
|
1458 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; | |
1433 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; |
|
1459 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; | |
1434 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1460 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1435 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1461 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1436 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
1462 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); | |
1437 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1463 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; | |
1438 | // DATA FIELD HEADER |
|
1464 | // DATA FIELD HEADER | |
1439 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1465 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1440 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1466 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; | |
1441 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1467 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; | |
1442 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1468 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; | |
1443 | kcoefficients_dump->time[0] = 0x00; |
|
1469 | kcoefficients_dump->time[0] = 0x00; | |
1444 | kcoefficients_dump->time[1] = 0x00; |
|
1470 | kcoefficients_dump->time[1] = 0x00; | |
1445 | kcoefficients_dump->time[2] = 0x00; |
|
1471 | kcoefficients_dump->time[2] = 0x00; | |
1446 | kcoefficients_dump->time[3] = 0x00; |
|
1472 | kcoefficients_dump->time[3] = 0x00; | |
1447 | kcoefficients_dump->time[4] = 0x00; |
|
1473 | kcoefficients_dump->time[4] = 0x00; | |
1448 | kcoefficients_dump->time[5] = 0x00; |
|
1474 | kcoefficients_dump->time[5] = 0x00; | |
1449 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1475 | kcoefficients_dump->sid = SID_K_DUMP; | |
1450 |
|
1476 | |||
1451 | kcoefficients_dump->pkt_cnt = 2; |
|
1477 | kcoefficients_dump->pkt_cnt = 2; | |
1452 | kcoefficients_dump->pkt_nr = pkt_nr; |
|
1478 | kcoefficients_dump->pkt_nr = pkt_nr; | |
1453 | kcoefficients_dump->blk_nr = blk_nr; |
|
1479 | kcoefficients_dump->blk_nr = blk_nr; | |
1454 |
|
1480 | |||
1455 | //****************** |
|
1481 | //****************** | |
1456 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1482 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] | |
1457 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1483 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) | |
1458 | for (k=0; k<3900; k++) |
|
1484 | for (k=0; k<3900; k++) | |
1459 | { |
|
1485 | { | |
1460 | kcoefficients_dump->kcoeff_blks[k] = 0x00; |
|
1486 | kcoefficients_dump->kcoeff_blks[k] = 0x00; | |
1461 | } |
|
1487 | } | |
1462 | } |
|
1488 | } | |
1463 |
|
1489 | |||
1464 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) |
|
1490 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) | |
1465 | { |
|
1491 | { | |
1466 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. |
|
1492 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. | |
1467 | * |
|
1493 | * | |
1468 | * @param packet_sequence_control points to the packet sequence control which will be incremented |
|
1494 | * @param packet_sequence_control points to the packet sequence control which will be incremented | |
1469 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID |
|
1495 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID | |
1470 | * |
|
1496 | * | |
1471 | * If the destination ID is not known, a dedicated counter is incremented. |
|
1497 | * If the destination ID is not known, a dedicated counter is incremented. | |
1472 | * |
|
1498 | * | |
1473 | */ |
|
1499 | */ | |
1474 |
|
1500 | |||
1475 | unsigned short sequence_cnt; |
|
1501 | unsigned short sequence_cnt; | |
1476 | unsigned short segmentation_grouping_flag; |
|
1502 | unsigned short segmentation_grouping_flag; | |
1477 | unsigned short new_packet_sequence_control; |
|
1503 | unsigned short new_packet_sequence_control; | |
1478 | unsigned char i; |
|
1504 | unsigned char i; | |
1479 |
|
1505 | |||
1480 | switch (destination_id) |
|
1506 | switch (destination_id) | |
1481 | { |
|
1507 | { | |
1482 | case SID_TC_GROUND: |
|
1508 | case SID_TC_GROUND: | |
1483 | i = GROUND; |
|
1509 | i = GROUND; | |
1484 | break; |
|
1510 | break; | |
1485 | case SID_TC_MISSION_TIMELINE: |
|
1511 | case SID_TC_MISSION_TIMELINE: | |
1486 | i = MISSION_TIMELINE; |
|
1512 | i = MISSION_TIMELINE; | |
1487 | break; |
|
1513 | break; | |
1488 | case SID_TC_TC_SEQUENCES: |
|
1514 | case SID_TC_TC_SEQUENCES: | |
1489 | i = TC_SEQUENCES; |
|
1515 | i = TC_SEQUENCES; | |
1490 | break; |
|
1516 | break; | |
1491 | case SID_TC_RECOVERY_ACTION_CMD: |
|
1517 | case SID_TC_RECOVERY_ACTION_CMD: | |
1492 | i = RECOVERY_ACTION_CMD; |
|
1518 | i = RECOVERY_ACTION_CMD; | |
1493 | break; |
|
1519 | break; | |
1494 | case SID_TC_BACKUP_MISSION_TIMELINE: |
|
1520 | case SID_TC_BACKUP_MISSION_TIMELINE: | |
1495 | i = BACKUP_MISSION_TIMELINE; |
|
1521 | i = BACKUP_MISSION_TIMELINE; | |
1496 | break; |
|
1522 | break; | |
1497 | case SID_TC_DIRECT_CMD: |
|
1523 | case SID_TC_DIRECT_CMD: | |
1498 | i = DIRECT_CMD; |
|
1524 | i = DIRECT_CMD; | |
1499 | break; |
|
1525 | break; | |
1500 | case SID_TC_SPARE_GRD_SRC1: |
|
1526 | case SID_TC_SPARE_GRD_SRC1: | |
1501 | i = SPARE_GRD_SRC1; |
|
1527 | i = SPARE_GRD_SRC1; | |
1502 | break; |
|
1528 | break; | |
1503 | case SID_TC_SPARE_GRD_SRC2: |
|
1529 | case SID_TC_SPARE_GRD_SRC2: | |
1504 | i = SPARE_GRD_SRC2; |
|
1530 | i = SPARE_GRD_SRC2; | |
1505 | break; |
|
1531 | break; | |
1506 | case SID_TC_OBCP: |
|
1532 | case SID_TC_OBCP: | |
1507 | i = OBCP; |
|
1533 | i = OBCP; | |
1508 | break; |
|
1534 | break; | |
1509 | case SID_TC_SYSTEM_CONTROL: |
|
1535 | case SID_TC_SYSTEM_CONTROL: | |
1510 | i = SYSTEM_CONTROL; |
|
1536 | i = SYSTEM_CONTROL; | |
1511 | break; |
|
1537 | break; | |
1512 | case SID_TC_AOCS: |
|
1538 | case SID_TC_AOCS: | |
1513 | i = AOCS; |
|
1539 | i = AOCS; | |
1514 | break; |
|
1540 | break; | |
1515 | case SID_TC_RPW_INTERNAL: |
|
1541 | case SID_TC_RPW_INTERNAL: | |
1516 | i = RPW_INTERNAL; |
|
1542 | i = RPW_INTERNAL; | |
1517 | break; |
|
1543 | break; | |
1518 | default: |
|
1544 | default: | |
1519 | i = GROUND; |
|
1545 | i = GROUND; | |
1520 | break; |
|
1546 | break; | |
1521 | } |
|
1547 | } | |
1522 |
|
1548 | |||
1523 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1549 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
1524 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff; |
|
1550 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff; | |
1525 |
|
1551 | |||
1526 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; |
|
1552 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; | |
1527 |
|
1553 | |||
1528 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1554 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
1529 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1555 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1530 |
|
1556 | |||
1531 | // increment the sequence counter |
|
1557 | // increment the sequence counter | |
1532 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) |
|
1558 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) | |
1533 | { |
|
1559 | { | |
1534 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; |
|
1560 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; | |
1535 | } |
|
1561 | } | |
1536 | else |
|
1562 | else | |
1537 | { |
|
1563 | { | |
1538 | sequenceCounters_TM_DUMP[ i ] = 0; |
|
1564 | sequenceCounters_TM_DUMP[ i ] = 0; | |
1539 | } |
|
1565 | } | |
1540 | } |
|
1566 | } |
General Comments 0
You need to be logged in to leave comments.
Login now