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