##// END OF EJS Templates
Bug 1085...
paul -
r370:18e20227b986 R3++ draft
parent child
Show More
@@ -1,2068 +1,2068
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 unsigned char k;
327 unsigned char k;
328
328
329 flag = LFR_DEFAULT;
329 flag = LFR_DEFAULT;
330 k = INIT_CHAR;
330 k = INIT_CHAR;
331
331
332 flag = check_sy_lfr_filter_parameters( TC, queue_id );
332 flag = check_sy_lfr_filter_parameters( TC, queue_id );
333
333
334 if (flag == LFR_SUCCESSFUL)
334 if (flag == LFR_SUCCESSFUL)
335 {
335 {
336 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
336 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
337 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
337 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
338 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_0 ];
338 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_0 ];
339 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_1 ];
339 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_1 ];
340 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_2 ];
340 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_2 ];
341 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_3 ];
341 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_3 ];
342 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
342 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
343 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_0 ];
343 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_0 ];
344 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_1 ];
344 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_1 ];
345 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_2 ];
345 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_2 ];
346 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_3 ];
346 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_3 ];
347 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_0 ];
347 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_0 ];
348 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_1 ];
348 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_1 ];
349 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_2 ];
349 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_2 ];
350 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_3 ];
350 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_3 ];
351
351
352 //****************************
352 //****************************
353 // store PAS filter parameters
353 // store PAS filter parameters
354
354
355 // sy_lfr_pas_filter_enabled
355 // sy_lfr_pas_filter_enabled
356 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
356 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
357 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & BIT_PAS_FILTER_ENABLED );
357 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & BIT_PAS_FILTER_ENABLED );
358
358
359 // sy_lfr_pas_filter_modulus
359 // sy_lfr_pas_filter_modulus
360 filterPar.modulus_in_finetime = ((uint64_t) parameter_dump_packet.sy_lfr_pas_filter_modulus) * CONST_65536;
360 filterPar.modulus_in_finetime = ((uint64_t) parameter_dump_packet.sy_lfr_pas_filter_modulus) * CONST_65536;
361
361
362 // sy_lfr_pas_filter_tbad
362 // sy_lfr_pas_filter_tbad
363 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
363 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
364 parameter_dump_packet.sy_lfr_pas_filter_tbad );
364 parameter_dump_packet.sy_lfr_pas_filter_tbad );
365 filterPar.tbad_in_finetime = (uint64_t) (filterPar.sy_lfr_pas_filter_tbad * CONST_65536);
365 filterPar.tbad_in_finetime = (uint64_t) (filterPar.sy_lfr_pas_filter_tbad * CONST_65536);
366
366
367 // sy_lfr_pas_filter_offset
367 // sy_lfr_pas_filter_offset
368 filterPar.offset_in_finetime = ((uint64_t) parameter_dump_packet.sy_lfr_pas_filter_offset) * CONST_65536;
368 filterPar.offset_in_finetime = ((uint64_t) parameter_dump_packet.sy_lfr_pas_filter_offset) * CONST_65536;
369
369
370 // sy_lfr_pas_filter_shift
370 // sy_lfr_pas_filter_shift
371 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
371 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
372 parameter_dump_packet.sy_lfr_pas_filter_shift );
372 parameter_dump_packet.sy_lfr_pas_filter_shift );
373 filterPar.shift_in_finetime = (uint64_t) (filterPar.sy_lfr_pas_filter_shift * CONST_65536);
373 filterPar.shift_in_finetime = (uint64_t) (filterPar.sy_lfr_pas_filter_shift * CONST_65536);
374
374
375 //****************************************************
375 //****************************************************
376 // store the parameter sy_lfr_sc_rw_delta_f as a float
376 // store the parameter sy_lfr_sc_rw_delta_f as a float
377 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
377 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
378 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
378 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
379
379
380 // copy rw.._k.. from the incoming TC to the local parameter_dump_packet
380 // copy rw.._k.. from the incoming TC to the local parameter_dump_packet
381 for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++)
381 for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++)
382 {
382 {
383 parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ];
383 parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ];
384 }
384 }
385
385
386 //***********************************************
386 //***********************************************
387 // store the parameter sy_lfr_rw.._k.. as a float
387 // store the parameter sy_lfr_rw.._k.. as a float
388 // rw1_k
388 // rw1_k
389 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 );
389 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 );
390 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 );
390 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 );
391 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 );
391 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 );
392 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 );
392 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 );
393 // rw2_k
393 // rw2_k
394 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 );
394 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 );
395 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 );
395 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 );
396 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 );
396 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 );
397 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 );
397 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 );
398 // rw3_k
398 // rw3_k
399 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 );
399 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 );
400 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 );
400 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 );
401 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 );
401 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 );
402 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 );
402 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 );
403 // rw4_k
403 // rw4_k
404 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 );
404 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 );
405 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 );
405 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 );
406 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 );
406 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 );
407 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 );
407 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 );
408
408
409 }
409 }
410
410
411 return flag;
411 return flag;
412 }
412 }
413
413
414 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
414 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
415 {
415 {
416 /** This function updates the LFR registers with the incoming sbm2 parameters.
416 /** This function updates the LFR registers with the incoming sbm2 parameters.
417 *
417 *
418 * @param TC points to the TeleCommand packet that is being processed
418 * @param TC points to the TeleCommand packet that is being processed
419 * @param queue_id is the id of the queue which handles TM related to this execution step
419 * @param queue_id is the id of the queue which handles TM related to this execution step
420 *
420 *
421 */
421 */
422
422
423 unsigned int address;
423 unsigned int address;
424 rtems_status_code status;
424 rtems_status_code status;
425 unsigned int freq;
425 unsigned int freq;
426 unsigned int bin;
426 unsigned int bin;
427 unsigned int coeff;
427 unsigned int coeff;
428 unsigned char *kCoeffPtr;
428 unsigned char *kCoeffPtr;
429 unsigned char *kCoeffDumpPtr;
429 unsigned char *kCoeffDumpPtr;
430
430
431 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
431 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
432 // F0 => 11 bins
432 // F0 => 11 bins
433 // F1 => 13 bins
433 // F1 => 13 bins
434 // F2 => 12 bins
434 // F2 => 12 bins
435 // 36 bins to dump in two packets (30 bins max per packet)
435 // 36 bins to dump in two packets (30 bins max per packet)
436
436
437 //*********
437 //*********
438 // PACKET 1
438 // PACKET 1
439 // 11 F0 bins, 13 F1 bins and 6 F2 bins
439 // 11 F0 bins, 13 F1 bins and 6 F2 bins
440 kcoefficients_dump_1.destinationID = TC->sourceID;
440 kcoefficients_dump_1.destinationID = TC->sourceID;
441 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
441 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
442 for( freq = 0;
442 for( freq = 0;
443 freq < NB_BINS_COMPRESSED_SM_F0;
443 freq < NB_BINS_COMPRESSED_SM_F0;
444 freq++ )
444 freq++ )
445 {
445 {
446 kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq;
446 kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq;
447 bin = freq;
447 bin = freq;
448 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
448 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
449 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
449 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
450 {
450 {
451 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[
451 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[
452 (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ
452 (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ
453 ]; // 2 for the kcoeff_frequency
453 ]; // 2 for the kcoeff_frequency
454 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
454 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
455 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
455 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
456 }
456 }
457 }
457 }
458 for( freq = NB_BINS_COMPRESSED_SM_F0;
458 for( freq = NB_BINS_COMPRESSED_SM_F0;
459 freq < ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 );
459 freq < ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 );
460 freq++ )
460 freq++ )
461 {
461 {
462 kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = freq;
462 kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = freq;
463 bin = freq - NB_BINS_COMPRESSED_SM_F0;
463 bin = freq - NB_BINS_COMPRESSED_SM_F0;
464 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
464 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
465 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
465 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
466 {
466 {
467 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[
467 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[
468 (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ
468 (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ
469 ]; // 2 for the kcoeff_frequency
469 ]; // 2 for the kcoeff_frequency
470 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
470 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
471 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
471 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
472 }
472 }
473 }
473 }
474 for( freq = ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 );
474 for( freq = ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 );
475 freq < KCOEFF_BLK_NR_PKT1 ;
475 freq < KCOEFF_BLK_NR_PKT1 ;
476 freq++ )
476 freq++ )
477 {
477 {
478 kcoefficients_dump_1.kcoeff_blks[ (freq * KCOEFF_BLK_SIZE) + 1 ] = freq;
478 kcoefficients_dump_1.kcoeff_blks[ (freq * KCOEFF_BLK_SIZE) + 1 ] = freq;
479 bin = freq - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
479 bin = freq - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
480 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
480 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
481 for ( coeff = 0; coeff <NB_K_COEFF_PER_BIN; coeff++ )
481 for ( coeff = 0; coeff <NB_K_COEFF_PER_BIN; coeff++ )
482 {
482 {
483 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[
483 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[
484 (freq * KCOEFF_BLK_SIZE) + (coeff * NB_BYTES_PER_FLOAT) + KCOEFF_FREQ
484 (freq * KCOEFF_BLK_SIZE) + (coeff * NB_BYTES_PER_FLOAT) + KCOEFF_FREQ
485 ]; // 2 for the kcoeff_frequency
485 ]; // 2 for the kcoeff_frequency
486 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
486 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
487 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
487 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
488 }
488 }
489 }
489 }
490 kcoefficients_dump_1.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
490 kcoefficients_dump_1.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
491 kcoefficients_dump_1.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
491 kcoefficients_dump_1.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
492 kcoefficients_dump_1.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
492 kcoefficients_dump_1.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
493 kcoefficients_dump_1.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
493 kcoefficients_dump_1.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
494 kcoefficients_dump_1.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
494 kcoefficients_dump_1.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
495 kcoefficients_dump_1.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
495 kcoefficients_dump_1.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
496 // SEND DATA
496 // SEND DATA
497 kcoefficient_node_1.status = 1;
497 kcoefficient_node_1.status = 1;
498 address = (unsigned int) &kcoefficient_node_1;
498 address = (unsigned int) &kcoefficient_node_1;
499 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
499 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
500 if (status != RTEMS_SUCCESSFUL) {
500 if (status != RTEMS_SUCCESSFUL) {
501 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
501 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
502 }
502 }
503
503
504 //********
504 //********
505 // PACKET 2
505 // PACKET 2
506 // 6 F2 bins
506 // 6 F2 bins
507 kcoefficients_dump_2.destinationID = TC->sourceID;
507 kcoefficients_dump_2.destinationID = TC->sourceID;
508 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
508 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
509 for( freq = 0;
509 for( freq = 0;
510 freq < KCOEFF_BLK_NR_PKT2;
510 freq < KCOEFF_BLK_NR_PKT2;
511 freq++ )
511 freq++ )
512 {
512 {
513 kcoefficients_dump_2.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = KCOEFF_BLK_NR_PKT1 + freq;
513 kcoefficients_dump_2.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = KCOEFF_BLK_NR_PKT1 + freq;
514 bin = freq + KCOEFF_BLK_NR_PKT2;
514 bin = freq + KCOEFF_BLK_NR_PKT2;
515 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
515 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
516 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
516 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
517 {
517 {
518 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[
518 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[
519 (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ ]; // 2 for the kcoeff_frequency
519 (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ ]; // 2 for the kcoeff_frequency
520 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
520 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
521 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
521 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
522 }
522 }
523 }
523 }
524 kcoefficients_dump_2.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
524 kcoefficients_dump_2.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
525 kcoefficients_dump_2.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
525 kcoefficients_dump_2.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
526 kcoefficients_dump_2.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
526 kcoefficients_dump_2.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
527 kcoefficients_dump_2.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
527 kcoefficients_dump_2.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
528 kcoefficients_dump_2.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
528 kcoefficients_dump_2.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
529 kcoefficients_dump_2.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
529 kcoefficients_dump_2.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
530 // SEND DATA
530 // SEND DATA
531 kcoefficient_node_2.status = 1;
531 kcoefficient_node_2.status = 1;
532 address = (unsigned int) &kcoefficient_node_2;
532 address = (unsigned int) &kcoefficient_node_2;
533 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
533 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
534 if (status != RTEMS_SUCCESSFUL) {
534 if (status != RTEMS_SUCCESSFUL) {
535 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
535 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
536 }
536 }
537
537
538 return status;
538 return status;
539 }
539 }
540
540
541 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
541 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
542 {
542 {
543 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
543 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
544 *
544 *
545 * @param queue_id is the id of the queue which handles TM related to this execution step.
545 * @param queue_id is the id of the queue which handles TM related to this execution step.
546 *
546 *
547 * @return RTEMS directive status codes:
547 * @return RTEMS directive status codes:
548 * - RTEMS_SUCCESSFUL - message sent successfully
548 * - RTEMS_SUCCESSFUL - message sent successfully
549 * - RTEMS_INVALID_ID - invalid queue id
549 * - RTEMS_INVALID_ID - invalid queue id
550 * - RTEMS_INVALID_SIZE - invalid message size
550 * - RTEMS_INVALID_SIZE - invalid message size
551 * - RTEMS_INVALID_ADDRESS - buffer is NULL
551 * - RTEMS_INVALID_ADDRESS - buffer is NULL
552 * - RTEMS_UNSATISFIED - out of message buffers
552 * - RTEMS_UNSATISFIED - out of message buffers
553 * - RTEMS_TOO_MANY - queue s limit has been reached
553 * - RTEMS_TOO_MANY - queue s limit has been reached
554 *
554 *
555 */
555 */
556
556
557 int status;
557 int status;
558
558
559 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
559 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
560 parameter_dump_packet.destinationID = TC->sourceID;
560 parameter_dump_packet.destinationID = TC->sourceID;
561
561
562 // UPDATE TIME
562 // UPDATE TIME
563 parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
563 parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
564 parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
564 parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
565 parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
565 parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
566 parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
566 parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
567 parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
567 parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
568 parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
568 parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
569 // SEND DATA
569 // SEND DATA
570 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
570 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
571 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
571 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
572 if (status != RTEMS_SUCCESSFUL) {
572 if (status != RTEMS_SUCCESSFUL) {
573 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
573 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
574 }
574 }
575
575
576 return status;
576 return status;
577 }
577 }
578
578
579 //***********************
579 //***********************
580 // NORMAL MODE PARAMETERS
580 // NORMAL MODE PARAMETERS
581
581
582 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
582 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
583 {
583 {
584 unsigned char msb;
584 unsigned char msb;
585 unsigned char lsb;
585 unsigned char lsb;
586 int flag;
586 int flag;
587 float aux;
587 float aux;
588 rtems_status_code status;
588 rtems_status_code status;
589
589
590 unsigned int sy_lfr_n_swf_l;
590 unsigned int sy_lfr_n_swf_l;
591 unsigned int sy_lfr_n_swf_p;
591 unsigned int sy_lfr_n_swf_p;
592 unsigned int sy_lfr_n_asm_p;
592 unsigned int sy_lfr_n_asm_p;
593 unsigned char sy_lfr_n_bp_p0;
593 unsigned char sy_lfr_n_bp_p0;
594 unsigned char sy_lfr_n_bp_p1;
594 unsigned char sy_lfr_n_bp_p1;
595 unsigned char sy_lfr_n_cwf_long_f3;
595 unsigned char sy_lfr_n_cwf_long_f3;
596
596
597 flag = LFR_SUCCESSFUL;
597 flag = LFR_SUCCESSFUL;
598
598
599 //***************
599 //***************
600 // get parameters
600 // get parameters
601 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
601 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
602 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
602 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
603 sy_lfr_n_swf_l = (msb * CONST_256) + lsb;
603 sy_lfr_n_swf_l = (msb * CONST_256) + lsb;
604
604
605 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
605 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
606 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
606 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
607 sy_lfr_n_swf_p = (msb * CONST_256) + lsb;
607 sy_lfr_n_swf_p = (msb * CONST_256) + lsb;
608
608
609 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
609 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
610 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
610 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
611 sy_lfr_n_asm_p = (msb * CONST_256) + lsb;
611 sy_lfr_n_asm_p = (msb * CONST_256) + lsb;
612
612
613 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
613 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
614
614
615 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
615 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
616
616
617 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
617 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
618
618
619 //******************
619 //******************
620 // check consistency
620 // check consistency
621 // sy_lfr_n_swf_l
621 // sy_lfr_n_swf_l
622 if (sy_lfr_n_swf_l != DFLT_SY_LFR_N_SWF_L)
622 if (sy_lfr_n_swf_l != DFLT_SY_LFR_N_SWF_L)
623 {
623 {
624 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L + DATAFIELD_OFFSET, sy_lfr_n_swf_l );
624 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L + DATAFIELD_OFFSET, sy_lfr_n_swf_l );
625 flag = WRONG_APP_DATA;
625 flag = WRONG_APP_DATA;
626 }
626 }
627 // sy_lfr_n_swf_p
627 // sy_lfr_n_swf_p
628 if (flag == LFR_SUCCESSFUL)
628 if (flag == LFR_SUCCESSFUL)
629 {
629 {
630 if ( sy_lfr_n_swf_p < MIN_SY_LFR_N_SWF_P )
630 if ( sy_lfr_n_swf_p < MIN_SY_LFR_N_SWF_P )
631 {
631 {
632 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P + DATAFIELD_OFFSET, sy_lfr_n_swf_p );
632 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P + DATAFIELD_OFFSET, sy_lfr_n_swf_p );
633 flag = WRONG_APP_DATA;
633 flag = WRONG_APP_DATA;
634 }
634 }
635 }
635 }
636 // sy_lfr_n_bp_p0
636 // sy_lfr_n_bp_p0
637 if (flag == LFR_SUCCESSFUL)
637 if (flag == LFR_SUCCESSFUL)
638 {
638 {
639 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
639 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
640 {
640 {
641 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0 + DATAFIELD_OFFSET, sy_lfr_n_bp_p0 );
641 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0 + DATAFIELD_OFFSET, sy_lfr_n_bp_p0 );
642 flag = WRONG_APP_DATA;
642 flag = WRONG_APP_DATA;
643 }
643 }
644 }
644 }
645 // sy_lfr_n_asm_p
645 // sy_lfr_n_asm_p
646 if (flag == LFR_SUCCESSFUL)
646 if (flag == LFR_SUCCESSFUL)
647 {
647 {
648 if (sy_lfr_n_asm_p == 0)
648 if (sy_lfr_n_asm_p == 0)
649 {
649 {
650 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p );
650 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p );
651 flag = WRONG_APP_DATA;
651 flag = WRONG_APP_DATA;
652 }
652 }
653 }
653 }
654 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
654 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
655 if (flag == LFR_SUCCESSFUL)
655 if (flag == LFR_SUCCESSFUL)
656 {
656 {
657 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
657 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
658 if (aux > FLOAT_EQUAL_ZERO)
658 if (aux > FLOAT_EQUAL_ZERO)
659 {
659 {
660 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p );
660 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p );
661 flag = WRONG_APP_DATA;
661 flag = WRONG_APP_DATA;
662 }
662 }
663 }
663 }
664 // sy_lfr_n_bp_p1
664 // sy_lfr_n_bp_p1
665 if (flag == LFR_SUCCESSFUL)
665 if (flag == LFR_SUCCESSFUL)
666 {
666 {
667 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
667 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
668 {
668 {
669 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 );
669 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 );
670 flag = WRONG_APP_DATA;
670 flag = WRONG_APP_DATA;
671 }
671 }
672 }
672 }
673 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
673 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
674 if (flag == LFR_SUCCESSFUL)
674 if (flag == LFR_SUCCESSFUL)
675 {
675 {
676 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
676 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
677 if (aux > FLOAT_EQUAL_ZERO)
677 if (aux > FLOAT_EQUAL_ZERO)
678 {
678 {
679 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 );
679 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 );
680 flag = LFR_DEFAULT;
680 flag = LFR_DEFAULT;
681 }
681 }
682 }
682 }
683 // sy_lfr_n_cwf_long_f3
683 // sy_lfr_n_cwf_long_f3
684
684
685 return flag;
685 return flag;
686 }
686 }
687
687
688 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
688 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
689 {
689 {
690 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
690 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
691 *
691 *
692 * @param TC points to the TeleCommand packet that is being processed
692 * @param TC points to the TeleCommand packet that is being processed
693 * @param queue_id is the id of the queue which handles TM related to this execution step
693 * @param queue_id is the id of the queue which handles TM related to this execution step
694 *
694 *
695 */
695 */
696
696
697 int result;
697 int result;
698
698
699 result = LFR_SUCCESSFUL;
699 result = LFR_SUCCESSFUL;
700
700
701 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
701 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
702 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
702 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
703
703
704 return result;
704 return result;
705 }
705 }
706
706
707 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
707 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
708 {
708 {
709 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
709 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
710 *
710 *
711 * @param TC points to the TeleCommand packet that is being processed
711 * @param TC points to the TeleCommand packet that is being processed
712 * @param queue_id is the id of the queue which handles TM related to this execution step
712 * @param queue_id is the id of the queue which handles TM related to this execution step
713 *
713 *
714 */
714 */
715
715
716 int result;
716 int result;
717
717
718 result = LFR_SUCCESSFUL;
718 result = LFR_SUCCESSFUL;
719
719
720 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
720 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
721 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
721 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
722
722
723 return result;
723 return result;
724 }
724 }
725
725
726 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
726 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
727 {
727 {
728 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
728 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
729 *
729 *
730 * @param TC points to the TeleCommand packet that is being processed
730 * @param TC points to the TeleCommand packet that is being processed
731 * @param queue_id is the id of the queue which handles TM related to this execution step
731 * @param queue_id is the id of the queue which handles TM related to this execution step
732 *
732 *
733 */
733 */
734
734
735 int result;
735 int result;
736
736
737 result = LFR_SUCCESSFUL;
737 result = LFR_SUCCESSFUL;
738
738
739 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
739 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
740 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
740 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
741
741
742 return result;
742 return result;
743 }
743 }
744
744
745 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
745 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
746 {
746 {
747 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
747 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
748 *
748 *
749 * @param TC points to the TeleCommand packet that is being processed
749 * @param TC points to the TeleCommand packet that is being processed
750 * @param queue_id is the id of the queue which handles TM related to this execution step
750 * @param queue_id is the id of the queue which handles TM related to this execution step
751 *
751 *
752 */
752 */
753
753
754 int status;
754 int status;
755
755
756 status = LFR_SUCCESSFUL;
756 status = LFR_SUCCESSFUL;
757
757
758 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
758 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
759
759
760 return status;
760 return status;
761 }
761 }
762
762
763 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
763 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
764 {
764 {
765 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
765 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
766 *
766 *
767 * @param TC points to the TeleCommand packet that is being processed
767 * @param TC points to the TeleCommand packet that is being processed
768 * @param queue_id is the id of the queue which handles TM related to this execution step
768 * @param queue_id is the id of the queue which handles TM related to this execution step
769 *
769 *
770 */
770 */
771
771
772 int status;
772 int status;
773
773
774 status = LFR_SUCCESSFUL;
774 status = LFR_SUCCESSFUL;
775
775
776 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
776 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
777
777
778 return status;
778 return status;
779 }
779 }
780
780
781 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
781 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
782 {
782 {
783 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
783 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
784 *
784 *
785 * @param TC points to the TeleCommand packet that is being processed
785 * @param TC points to the TeleCommand packet that is being processed
786 * @param queue_id is the id of the queue which handles TM related to this execution step
786 * @param queue_id is the id of the queue which handles TM related to this execution step
787 *
787 *
788 */
788 */
789
789
790 int status;
790 int status;
791
791
792 status = LFR_SUCCESSFUL;
792 status = LFR_SUCCESSFUL;
793
793
794 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
794 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
795
795
796 return status;
796 return status;
797 }
797 }
798
798
799 //**********************
799 //**********************
800 // BURST MODE PARAMETERS
800 // BURST MODE PARAMETERS
801
801
802 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
802 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
803 {
803 {
804 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
804 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
805 *
805 *
806 * @param TC points to the TeleCommand packet that is being processed
806 * @param TC points to the TeleCommand packet that is being processed
807 * @param queue_id is the id of the queue which handles TM related to this execution step
807 * @param queue_id is the id of the queue which handles TM related to this execution step
808 *
808 *
809 */
809 */
810
810
811 int status;
811 int status;
812
812
813 status = LFR_SUCCESSFUL;
813 status = LFR_SUCCESSFUL;
814
814
815 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
815 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
816
816
817 return status;
817 return status;
818 }
818 }
819
819
820 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
820 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
821 {
821 {
822 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
822 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
823 *
823 *
824 * @param TC points to the TeleCommand packet that is being processed
824 * @param TC points to the TeleCommand packet that is being processed
825 * @param queue_id is the id of the queue which handles TM related to this execution step
825 * @param queue_id is the id of the queue which handles TM related to this execution step
826 *
826 *
827 */
827 */
828
828
829 int status;
829 int status;
830
830
831 status = LFR_SUCCESSFUL;
831 status = LFR_SUCCESSFUL;
832
832
833 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
833 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
834
834
835 return status;
835 return status;
836 }
836 }
837
837
838 //*********************
838 //*********************
839 // SBM1 MODE PARAMETERS
839 // SBM1 MODE PARAMETERS
840
840
841 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
841 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
842 {
842 {
843 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
843 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
844 *
844 *
845 * @param TC points to the TeleCommand packet that is being processed
845 * @param TC points to the TeleCommand packet that is being processed
846 * @param queue_id is the id of the queue which handles TM related to this execution step
846 * @param queue_id is the id of the queue which handles TM related to this execution step
847 *
847 *
848 */
848 */
849
849
850 int status;
850 int status;
851
851
852 status = LFR_SUCCESSFUL;
852 status = LFR_SUCCESSFUL;
853
853
854 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
854 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
855
855
856 return status;
856 return status;
857 }
857 }
858
858
859 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
859 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
860 {
860 {
861 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
861 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
862 *
862 *
863 * @param TC points to the TeleCommand packet that is being processed
863 * @param TC points to the TeleCommand packet that is being processed
864 * @param queue_id is the id of the queue which handles TM related to this execution step
864 * @param queue_id is the id of the queue which handles TM related to this execution step
865 *
865 *
866 */
866 */
867
867
868 int status;
868 int status;
869
869
870 status = LFR_SUCCESSFUL;
870 status = LFR_SUCCESSFUL;
871
871
872 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
872 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
873
873
874 return status;
874 return status;
875 }
875 }
876
876
877 //*********************
877 //*********************
878 // SBM2 MODE PARAMETERS
878 // SBM2 MODE PARAMETERS
879
879
880 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
880 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
881 {
881 {
882 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
882 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
883 *
883 *
884 * @param TC points to the TeleCommand packet that is being processed
884 * @param TC points to the TeleCommand packet that is being processed
885 * @param queue_id is the id of the queue which handles TM related to this execution step
885 * @param queue_id is the id of the queue which handles TM related to this execution step
886 *
886 *
887 */
887 */
888
888
889 int status;
889 int status;
890
890
891 status = LFR_SUCCESSFUL;
891 status = LFR_SUCCESSFUL;
892
892
893 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
893 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
894
894
895 return status;
895 return status;
896 }
896 }
897
897
898 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
898 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
899 {
899 {
900 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
900 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
901 *
901 *
902 * @param TC points to the TeleCommand packet that is being processed
902 * @param TC points to the TeleCommand packet that is being processed
903 * @param queue_id is the id of the queue which handles TM related to this execution step
903 * @param queue_id is the id of the queue which handles TM related to this execution step
904 *
904 *
905 */
905 */
906
906
907 int status;
907 int status;
908
908
909 status = LFR_SUCCESSFUL;
909 status = LFR_SUCCESSFUL;
910
910
911 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
911 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
912
912
913 return status;
913 return status;
914 }
914 }
915
915
916 //*******************
916 //*******************
917 // TC_LFR_UPDATE_INFO
917 // TC_LFR_UPDATE_INFO
918
918
919 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
919 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
920 {
920 {
921 unsigned int status;
921 unsigned int status;
922
922
923 status = LFR_DEFAULT;
923 status = LFR_DEFAULT;
924
924
925 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
925 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
926 || (mode == LFR_MODE_BURST)
926 || (mode == LFR_MODE_BURST)
927 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
927 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
928 {
928 {
929 status = LFR_SUCCESSFUL;
929 status = LFR_SUCCESSFUL;
930 }
930 }
931 else
931 else
932 {
932 {
933 status = LFR_DEFAULT;
933 status = LFR_DEFAULT;
934 }
934 }
935
935
936 return status;
936 return status;
937 }
937 }
938
938
939 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
939 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
940 {
940 {
941 unsigned int status;
941 unsigned int status;
942
942
943 status = LFR_DEFAULT;
943 status = LFR_DEFAULT;
944
944
945 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
945 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
946 || (mode == TDS_MODE_BURST)
946 || (mode == TDS_MODE_BURST)
947 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
947 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
948 || (mode == TDS_MODE_LFM))
948 || (mode == TDS_MODE_LFM))
949 {
949 {
950 status = LFR_SUCCESSFUL;
950 status = LFR_SUCCESSFUL;
951 }
951 }
952 else
952 else
953 {
953 {
954 status = LFR_DEFAULT;
954 status = LFR_DEFAULT;
955 }
955 }
956
956
957 return status;
957 return status;
958 }
958 }
959
959
960 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
960 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
961 {
961 {
962 unsigned int status;
962 unsigned int status;
963
963
964 status = LFR_DEFAULT;
964 status = LFR_DEFAULT;
965
965
966 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
966 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
967 || (mode == THR_MODE_BURST))
967 || (mode == THR_MODE_BURST))
968 {
968 {
969 status = LFR_SUCCESSFUL;
969 status = LFR_SUCCESSFUL;
970 }
970 }
971 else
971 else
972 {
972 {
973 status = LFR_DEFAULT;
973 status = LFR_DEFAULT;
974 }
974 }
975
975
976 return status;
976 return status;
977 }
977 }
978
978
979 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value )
979 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value )
980 {
980 {
981 unsigned char flag;
981 unsigned char flag;
982 unsigned char flagPosInByte;
982 unsigned char flagPosInByte;
983 unsigned char newFlag;
983 unsigned char newFlag;
984 unsigned char flagMask;
984 unsigned char flagMask;
985
985
986 // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered
986 // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered
987 if (isnan(value))
987 if (isnan(value))
988 {
988 {
989 flag = FLAG_NAN;
989 flag = FLAG_NAN;
990 }
990 }
991 else
991 else
992 {
992 {
993 flag = FLAG_IAN;
993 flag = FLAG_IAN;
994 }
994 }
995
995
996 switch(wheel)
996 switch(wheel)
997 {
997 {
998 case WHEEL_1:
998 case WHEEL_1:
999 flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq;
999 flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq;
1000 flagMask = ~(1 << flagPosInByte);
1000 flagMask = ~(1 << flagPosInByte);
1001 newFlag = flag << flagPosInByte;
1001 newFlag = flag << flagPosInByte;
1002 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
1002 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
1003 break;
1003 break;
1004 case WHEEL_2:
1004 case WHEEL_2:
1005 flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq;
1005 flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq;
1006 flagMask = ~(1 << flagPosInByte);
1006 flagMask = ~(1 << flagPosInByte);
1007 newFlag = flag << flagPosInByte;
1007 newFlag = flag << flagPosInByte;
1008 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
1008 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
1009 break;
1009 break;
1010 case WHEEL_3:
1010 case WHEEL_3:
1011 flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq;
1011 flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq;
1012 flagMask = ~(1 << flagPosInByte);
1012 flagMask = ~(1 << flagPosInByte);
1013 newFlag = flag << flagPosInByte;
1013 newFlag = flag << flagPosInByte;
1014 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
1014 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
1015 break;
1015 break;
1016 case WHEEL_4:
1016 case WHEEL_4:
1017 flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq;
1017 flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq;
1018 flagMask = ~(1 << flagPosInByte);
1018 flagMask = ~(1 << flagPosInByte);
1019 newFlag = flag << flagPosInByte;
1019 newFlag = flag << flagPosInByte;
1020 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
1020 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
1021 break;
1021 break;
1022 default:
1022 default:
1023 break;
1023 break;
1024 }
1024 }
1025 }
1025 }
1026
1026
1027 void set_hk_lfr_sc_rw_f_flags( void )
1027 void set_hk_lfr_sc_rw_f_flags( void )
1028 {
1028 {
1029 // RW1
1029 // RW1
1030 set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_1, rw_f.cp_rpw_sc_rw1_f1 );
1030 set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_1, rw_f.cp_rpw_sc_rw1_f1 );
1031 set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_2, rw_f.cp_rpw_sc_rw1_f2 );
1031 set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_2, rw_f.cp_rpw_sc_rw1_f2 );
1032 set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_3, rw_f.cp_rpw_sc_rw1_f3 );
1032 set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_3, rw_f.cp_rpw_sc_rw1_f3 );
1033 set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_4, rw_f.cp_rpw_sc_rw1_f4 );
1033 set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_4, rw_f.cp_rpw_sc_rw1_f4 );
1034
1034
1035 // RW2
1035 // RW2
1036 set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_1, rw_f.cp_rpw_sc_rw2_f1 );
1036 set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_1, rw_f.cp_rpw_sc_rw2_f1 );
1037 set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_2, rw_f.cp_rpw_sc_rw2_f2 );
1037 set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_2, rw_f.cp_rpw_sc_rw2_f2 );
1038 set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_3, rw_f.cp_rpw_sc_rw2_f3 );
1038 set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_3, rw_f.cp_rpw_sc_rw2_f3 );
1039 set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_4, rw_f.cp_rpw_sc_rw2_f4 );
1039 set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_4, rw_f.cp_rpw_sc_rw2_f4 );
1040
1040
1041 // RW3
1041 // RW3
1042 set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_1, rw_f.cp_rpw_sc_rw3_f1 );
1042 set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_1, rw_f.cp_rpw_sc_rw3_f1 );
1043 set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_2, rw_f.cp_rpw_sc_rw3_f2 );
1043 set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_2, rw_f.cp_rpw_sc_rw3_f2 );
1044 set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_3, rw_f.cp_rpw_sc_rw3_f3 );
1044 set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_3, rw_f.cp_rpw_sc_rw3_f3 );
1045 set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_4, rw_f.cp_rpw_sc_rw3_f4 );
1045 set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_4, rw_f.cp_rpw_sc_rw3_f4 );
1046
1046
1047 // RW4
1047 // RW4
1048 set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_1, rw_f.cp_rpw_sc_rw4_f1 );
1048 set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_1, rw_f.cp_rpw_sc_rw4_f1 );
1049 set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_2, rw_f.cp_rpw_sc_rw4_f2 );
1049 set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_2, rw_f.cp_rpw_sc_rw4_f2 );
1050 set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_3, rw_f.cp_rpw_sc_rw4_f3 );
1050 set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_3, rw_f.cp_rpw_sc_rw4_f3 );
1051 set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_4, rw_f.cp_rpw_sc_rw4_f4 );
1051 set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_4, rw_f.cp_rpw_sc_rw4_f4 );
1052 }
1052 }
1053
1053
1054 int check_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value )
1054 int check_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value )
1055 {
1055 {
1056 float rw_k;
1056 float rw_k;
1057 int ret;
1057 int ret;
1058
1058
1059 ret = LFR_SUCCESSFUL;
1059 ret = LFR_SUCCESSFUL;
1060 rw_k = INIT_FLOAT;
1060 rw_k = INIT_FLOAT;
1061
1061
1062 copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->packetID[ offset ] );
1062 copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->packetID[ offset ] );
1063
1063
1064 *pos = offset;
1064 *pos = offset;
1065 *value = rw_k;
1065 *value = rw_k;
1066
1066
1067 if (rw_k < MIN_SY_LFR_RW_F)
1067 if (rw_k < MIN_SY_LFR_RW_F)
1068 {
1068 {
1069 ret = WRONG_APP_DATA;
1069 ret = WRONG_APP_DATA;
1070 }
1070 }
1071
1071
1072 return ret;
1072 return ret;
1073 }
1073 }
1074
1074
1075 int check_all_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int *pos, float*value )
1075 int check_all_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int *pos, float*value )
1076 {
1076 {
1077 int ret;
1077 int ret;
1078
1078
1079 ret = LFR_SUCCESSFUL;
1079 ret = LFR_SUCCESSFUL;
1080
1080
1081 //****
1081 //****
1082 //****
1082 //****
1083 // RW1
1083 // RW1
1084 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1, pos, value ); // F1
1084 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1, pos, value ); // F1
1085 if (ret == LFR_SUCCESSFUL) // F2
1085 if (ret == LFR_SUCCESSFUL) // F2
1086 {
1086 {
1087 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2, pos, value );
1087 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2, pos, value );
1088 }
1088 }
1089 if (ret == LFR_SUCCESSFUL) // F3
1089 if (ret == LFR_SUCCESSFUL) // F3
1090 {
1090 {
1091 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3, pos, value );
1091 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3, pos, value );
1092 }
1092 }
1093 if (ret == LFR_SUCCESSFUL) // F4
1093 if (ret == LFR_SUCCESSFUL) // F4
1094 {
1094 {
1095 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4, pos, value );
1095 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4, pos, value );
1096 }
1096 }
1097
1097
1098 //****
1098 //****
1099 //****
1099 //****
1100 // RW2
1100 // RW2
1101 if (ret == LFR_SUCCESSFUL) // F1
1101 if (ret == LFR_SUCCESSFUL) // F1
1102 {
1102 {
1103 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1, pos, value );
1103 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1, pos, value );
1104 }
1104 }
1105 if (ret == LFR_SUCCESSFUL) // F2
1105 if (ret == LFR_SUCCESSFUL) // F2
1106 {
1106 {
1107 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2, pos, value );
1107 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2, pos, value );
1108 }
1108 }
1109 if (ret == LFR_SUCCESSFUL) // F3
1109 if (ret == LFR_SUCCESSFUL) // F3
1110 {
1110 {
1111 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3, pos, value );
1111 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3, pos, value );
1112 }
1112 }
1113 if (ret == LFR_SUCCESSFUL) // F4
1113 if (ret == LFR_SUCCESSFUL) // F4
1114 {
1114 {
1115 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4, pos, value );
1115 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4, pos, value );
1116 }
1116 }
1117
1117
1118 //****
1118 //****
1119 //****
1119 //****
1120 // RW3
1120 // RW3
1121 if (ret == LFR_SUCCESSFUL) // F1
1121 if (ret == LFR_SUCCESSFUL) // F1
1122 {
1122 {
1123 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1, pos, value );
1123 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1, pos, value );
1124 }
1124 }
1125 if (ret == LFR_SUCCESSFUL) // F2
1125 if (ret == LFR_SUCCESSFUL) // F2
1126 {
1126 {
1127 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2, pos, value );
1127 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2, pos, value );
1128 }
1128 }
1129 if (ret == LFR_SUCCESSFUL) // F3
1129 if (ret == LFR_SUCCESSFUL) // F3
1130 {
1130 {
1131 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3, pos, value );
1131 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3, pos, value );
1132 }
1132 }
1133 if (ret == LFR_SUCCESSFUL) // F4
1133 if (ret == LFR_SUCCESSFUL) // F4
1134 {
1134 {
1135 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4, pos, value );
1135 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4, pos, value );
1136 }
1136 }
1137
1137
1138 //****
1138 //****
1139 //****
1139 //****
1140 // RW4
1140 // RW4
1141 if (ret == LFR_SUCCESSFUL) // F1
1141 if (ret == LFR_SUCCESSFUL) // F1
1142 {
1142 {
1143 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1, pos, value );
1143 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1, pos, value );
1144 }
1144 }
1145 if (ret == LFR_SUCCESSFUL) // F2
1145 if (ret == LFR_SUCCESSFUL) // F2
1146 {
1146 {
1147 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2, pos, value );
1147 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2, pos, value );
1148 }
1148 }
1149 if (ret == LFR_SUCCESSFUL) // F3
1149 if (ret == LFR_SUCCESSFUL) // F3
1150 {
1150 {
1151 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3, pos, value );
1151 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3, pos, value );
1152 }
1152 }
1153 if (ret == LFR_SUCCESSFUL) // F4
1153 if (ret == LFR_SUCCESSFUL) // F4
1154 {
1154 {
1155 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4, pos, value );
1155 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4, pos, value );
1156 }
1156 }
1157
1157
1158 return ret;
1158 return ret;
1159 }
1159 }
1160
1160
1161 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
1161 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
1162 {
1162 {
1163 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
1163 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
1164 *
1164 *
1165 * @param TC points to the TeleCommand packet that is being processed
1165 * @param TC points to the TeleCommand packet that is being processed
1166 *
1166 *
1167 */
1167 */
1168
1168
1169 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
1169 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
1170
1170
1171 bytePosPtr = (unsigned char *) &TC->packetID;
1171 bytePosPtr = (unsigned char *) &TC->packetID;
1172
1172
1173 // rw1_f
1173 // rw1_f
1174 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
1174 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
1175 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
1175 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
1176 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] );
1176 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] );
1177 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] );
1177 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] );
1178
1178
1179 // rw2_f
1179 // rw2_f
1180 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
1180 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
1181 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
1181 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
1182 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] );
1182 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] );
1183 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] );
1183 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] );
1184
1184
1185 // rw3_f
1185 // rw3_f
1186 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
1186 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
1187 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
1187 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
1188 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] );
1188 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] );
1189 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] );
1189 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] );
1190
1190
1191 // rw4_f
1191 // rw4_f
1192 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
1192 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
1193 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
1193 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
1194 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] );
1194 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] );
1195 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] );
1195 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] );
1196
1196
1197 // test each reaction wheel frequency value. NaN means that the frequency is not filtered
1197 // test each reaction wheel frequency value. NaN means that the frequency is not filtered
1198
1198
1199 }
1199 }
1200
1200
1201 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k )
1201 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k )
1202 {
1202 {
1203 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
1203 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
1204 *
1204 *
1205 * @param fbins_mask
1205 * @param fbins_mask
1206 * @param rw_f is the reaction wheel frequency to filter
1206 * @param rw_f is the reaction wheel frequency to filter
1207 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
1207 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
1208 * @param flag [true] filtering enabled [false] filtering disabled
1208 * @param flag [true] filtering enabled [false] filtering disabled
1209 *
1209 *
1210 * @return void
1210 * @return void
1211 *
1211 *
1212 */
1212 */
1213
1213
1214 float f_RW_min;
1214 float f_RW_min;
1215 float f_RW_MAX;
1215 float f_RW_MAX;
1216 float fi_min;
1216 float fi_min;
1217 float fi_MAX;
1217 float fi_MAX;
1218 float fi;
1218 float fi;
1219 float deltaBelow;
1219 float deltaBelow;
1220 float deltaAbove;
1220 float deltaAbove;
1221 float freqToFilterOut;
1221 float freqToFilterOut;
1222 int binBelow;
1222 int binBelow;
1223 int binAbove;
1223 int binAbove;
1224 int closestBin;
1224 int closestBin;
1225 unsigned int whichByte;
1225 unsigned int whichByte;
1226 int selectedByte;
1226 int selectedByte;
1227 int bin;
1227 int bin;
1228 int binToRemove[NB_BINS_TO_REMOVE];
1228 int binToRemove[NB_BINS_TO_REMOVE];
1229 int k;
1229 int k;
1230 bool filteringSet;
1230 bool filteringSet;
1231
1231
1232 closestBin = 0;
1232 closestBin = 0;
1233 whichByte = 0;
1233 whichByte = 0;
1234 bin = 0;
1234 bin = 0;
1235 filteringSet = false;
1235 filteringSet = false;
1236
1236
1237 for (k = 0; k < NB_BINS_TO_REMOVE; k++)
1237 for (k = 0; k < NB_BINS_TO_REMOVE; k++)
1238 {
1238 {
1239 binToRemove[k] = -1;
1239 binToRemove[k] = -1;
1240 }
1240 }
1241
1241
1242 if (!isnan(rw_f))
1242 if (!isnan(rw_f))
1243 {
1243 {
1244 // compute the frequency range to filter [ rw_f - delta_f; rw_f + delta_f ]
1244 // compute the frequency range to filter [ rw_f - delta_f; rw_f + delta_f ]
1245 f_RW_min = rw_f - ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k);
1245 f_RW_min = rw_f - ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k);
1246 f_RW_MAX = rw_f + ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k);
1246 f_RW_MAX = rw_f + ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k);
1247
1247
1248 freqToFilterOut = f_RW_min;
1248 freqToFilterOut = f_RW_min;
1249 while ( filteringSet == false )
1249 while ( filteringSet == false )
1250 {
1250 {
1251 // compute the index of the frequency bin immediately below rw_f
1251 // compute the index of the frequency bin immediately below rw_f
1252 binBelow = (int) ( floor( ((double) freqToFilterOut) / ((double) deltaFreq)) );
1252 binBelow = (int) ( floor( ((double) freqToFilterOut) / ((double) deltaFreq)) );
1253 deltaBelow = freqToFilterOut - binBelow * deltaFreq;
1253 deltaBelow = freqToFilterOut - binBelow * deltaFreq;
1254
1254
1255 // compute the index of the frequency bin immediately above rw_f
1255 // compute the index of the frequency bin immediately above rw_f
1256 binAbove = (int) ( ceil( ((double) freqToFilterOut) / ((double) deltaFreq)) );
1256 binAbove = (int) ( ceil( ((double) freqToFilterOut) / ((double) deltaFreq)) );
1257 deltaAbove = binAbove * deltaFreq - freqToFilterOut;
1257 deltaAbove = binAbove * deltaFreq - freqToFilterOut;
1258
1258
1259 // search the closest bin
1259 // search the closest bin
1260 if (deltaAbove > deltaBelow)
1260 if (deltaAbove > deltaBelow)
1261 {
1261 {
1262 closestBin = binBelow;
1262 closestBin = binBelow;
1263 }
1263 }
1264 else
1264 else
1265 {
1265 {
1266 closestBin = binAbove;
1266 closestBin = binAbove;
1267 }
1267 }
1268
1268
1269 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1269 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1270 fi = closestBin * deltaFreq;
1270 fi = closestBin * deltaFreq;
1271 fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF);
1271 fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF);
1272 fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF);
1272 fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF);
1273
1273
1274 //**************************************************************************************
1274 //**************************************************************************************
1275 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
1275 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
1276 // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum
1276 // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum
1277 //**************************************************************************************
1277 //**************************************************************************************
1278
1278
1279 // 1. IF freqToFilterOut is included in [ fi_min; fi_MAX ]
1279 // 1. IF freqToFilterOut is included in [ fi_min; fi_MAX ]
1280 // => remove f_(i), f_(i-1) and f_(i+1)
1280 // => remove f_(i), f_(i-1) and f_(i+1)
1281 if ( ( freqToFilterOut > fi_min ) && ( freqToFilterOut < fi_MAX ) )
1281 if ( ( freqToFilterOut > fi_min ) && ( freqToFilterOut < fi_MAX ) )
1282 {
1282 {
1283 binToRemove[0] = (closestBin - 1) - 1;
1283 binToRemove[0] = (closestBin - 1) - 1;
1284 binToRemove[1] = (closestBin) - 1;
1284 binToRemove[1] = (closestBin) - 1;
1285 binToRemove[2] = (closestBin + 1) - 1;
1285 binToRemove[2] = (closestBin + 1) - 1;
1286 }
1286 }
1287 // 2. ELSE
1287 // 2. ELSE
1288 // => remove the two f_(i) which are around f_RW
1288 // => remove the two f_(i) which are around f_RW
1289 else
1289 else
1290 {
1290 {
1291 binToRemove[0] = (binBelow) - 1;
1291 binToRemove[0] = (binBelow) - 1;
1292 binToRemove[1] = (binAbove) - 1;
1292 binToRemove[1] = (binAbove) - 1;
1293 binToRemove[2] = (-1);
1293 binToRemove[2] = (-1);
1294 }
1294 }
1295
1295
1296 for (k = 0; k < NB_BINS_TO_REMOVE; k++)
1296 for (k = 0; k < NB_BINS_TO_REMOVE; k++)
1297 {
1297 {
1298 bin = binToRemove[k];
1298 bin = binToRemove[k];
1299 if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) )
1299 if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) )
1300 {
1300 {
1301 whichByte = (bin >> SHIFT_3_BITS); // division by 8
1301 whichByte = (bin >> SHIFT_3_BITS); // division by 8
1302 selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) );
1302 selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) );
1303 fbins_mask[BYTES_PER_MASK - 1 - whichByte] =
1303 fbins_mask[BYTES_PER_MASK - 1 - whichByte] =
1304 fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1304 fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1305
1305
1306 }
1306 }
1307 }
1307 }
1308
1308
1309 // update freqToFilterOut
1309 // update freqToFilterOut
1310 if ( freqToFilterOut == f_RW_MAX )
1310 if ( freqToFilterOut == f_RW_MAX )
1311 {
1311 {
1312 filteringSet = true; // end of the loop
1312 filteringSet = true; // end of the loop
1313 }
1313 }
1314 else
1314 else
1315 {
1315 {
1316 freqToFilterOut = freqToFilterOut + deltaFreq;
1316 freqToFilterOut = freqToFilterOut + deltaFreq;
1317 }
1317 }
1318
1318
1319 if ( freqToFilterOut > f_RW_MAX)
1319 if ( freqToFilterOut > f_RW_MAX)
1320 {
1320 {
1321 freqToFilterOut = f_RW_MAX;
1321 freqToFilterOut = f_RW_MAX;
1322 }
1322 }
1323 }
1323 }
1324 }
1324 }
1325 }
1325 }
1326
1326
1327 void build_sy_lfr_rw_mask( unsigned int channel )
1327 void build_sy_lfr_rw_mask( unsigned int channel )
1328 {
1328 {
1329 unsigned char local_rw_fbins_mask[BYTES_PER_MASK];
1329 unsigned char local_rw_fbins_mask[BYTES_PER_MASK];
1330 unsigned char *maskPtr;
1330 unsigned char *maskPtr;
1331 double deltaF;
1331 double deltaF;
1332 unsigned k;
1332 unsigned k;
1333
1333
1334 maskPtr = NULL;
1334 maskPtr = NULL;
1335 deltaF = DELTAF_F2;
1335 deltaF = DELTAF_F2;
1336
1336
1337 switch (channel)
1337 switch (channel)
1338 {
1338 {
1339 case CHANNELF0:
1339 case CHANNELF0:
1340 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1340 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1341 deltaF = DELTAF_F0;
1341 deltaF = DELTAF_F0;
1342 break;
1342 break;
1343 case CHANNELF1:
1343 case CHANNELF1:
1344 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1344 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1345 deltaF = DELTAF_F1;
1345 deltaF = DELTAF_F1;
1346 break;
1346 break;
1347 case CHANNELF2:
1347 case CHANNELF2:
1348 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1348 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1349 deltaF = DELTAF_F2;
1349 deltaF = DELTAF_F2;
1350 break;
1350 break;
1351 default:
1351 default:
1352 break;
1352 break;
1353 }
1353 }
1354
1354
1355 for (k = 0; k < BYTES_PER_MASK; k++)
1355 for (k = 0; k < BYTES_PER_MASK; k++)
1356 {
1356 {
1357 local_rw_fbins_mask[k] = INT8_ALL_F;
1357 local_rw_fbins_mask[k] = INT8_ALL_F;
1358 }
1358 }
1359
1359
1360 // RW1
1360 // RW1
1361 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 );
1361 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 );
1362 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 );
1362 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 );
1363 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 );
1363 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 );
1364 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 );
1364 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 );
1365
1365
1366 // RW2
1366 // RW2
1367 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 );
1367 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 );
1368 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 );
1368 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 );
1369 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 );
1369 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 );
1370 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 );
1370 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 );
1371
1371
1372 // RW3
1372 // RW3
1373 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 );
1373 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 );
1374 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 );
1374 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 );
1375 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 );
1375 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 );
1376 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 );
1376 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 );
1377
1377
1378 // RW4
1378 // RW4
1379 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 );
1379 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 );
1380 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 );
1380 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 );
1381 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 );
1381 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 );
1382 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 );
1382 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 );
1383
1383
1384 // update the value of the fbins related to reaction wheels frequency filtering
1384 // update the value of the fbins related to reaction wheels frequency filtering
1385 if (maskPtr != NULL)
1385 if (maskPtr != NULL)
1386 {
1386 {
1387 for (k = 0; k < BYTES_PER_MASK; k++)
1387 for (k = 0; k < BYTES_PER_MASK; k++)
1388 {
1388 {
1389 maskPtr[k] = local_rw_fbins_mask[k];
1389 maskPtr[k] = local_rw_fbins_mask[k];
1390 }
1390 }
1391 }
1391 }
1392 }
1392 }
1393
1393
1394 void build_sy_lfr_rw_masks( void )
1394 void build_sy_lfr_rw_masks( void )
1395 {
1395 {
1396 build_sy_lfr_rw_mask( CHANNELF0 );
1396 build_sy_lfr_rw_mask( CHANNELF0 );
1397 build_sy_lfr_rw_mask( CHANNELF1 );
1397 build_sy_lfr_rw_mask( CHANNELF1 );
1398 build_sy_lfr_rw_mask( CHANNELF2 );
1398 build_sy_lfr_rw_mask( CHANNELF2 );
1399 }
1399 }
1400
1400
1401 void merge_fbins_masks( void )
1401 void merge_fbins_masks( void )
1402 {
1402 {
1403 unsigned char k;
1403 unsigned char k;
1404
1404
1405 unsigned char *fbins_f0;
1405 unsigned char *fbins_f0;
1406 unsigned char *fbins_f1;
1406 unsigned char *fbins_f1;
1407 unsigned char *fbins_f2;
1407 unsigned char *fbins_f2;
1408 unsigned char *rw_mask_f0;
1408 unsigned char *rw_mask_f0;
1409 unsigned char *rw_mask_f1;
1409 unsigned char *rw_mask_f1;
1410 unsigned char *rw_mask_f2;
1410 unsigned char *rw_mask_f2;
1411
1411
1412 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1412 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1413 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1413 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1414 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1414 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1415 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1415 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1416 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1416 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1417 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1417 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1418
1418
1419 for( k=0; k < BYTES_PER_MASK; k++ )
1419 for( k=0; k < BYTES_PER_MASK; k++ )
1420 {
1420 {
1421 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1421 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1422 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1422 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1423 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1423 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1424 }
1424 }
1425 }
1425 }
1426
1426
1427 //***********
1427 //***********
1428 // FBINS MASK
1428 // FBINS MASK
1429
1429
1430 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1430 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1431 {
1431 {
1432 int status;
1432 int status;
1433 unsigned int k;
1433 unsigned int k;
1434 unsigned char *fbins_mask_dump;
1434 unsigned char *fbins_mask_dump;
1435 unsigned char *fbins_mask_TC;
1435 unsigned char *fbins_mask_TC;
1436
1436
1437 status = LFR_SUCCESSFUL;
1437 status = LFR_SUCCESSFUL;
1438
1438
1439 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1439 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1440 fbins_mask_TC = TC->dataAndCRC;
1440 fbins_mask_TC = TC->dataAndCRC;
1441
1441
1442 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1442 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1443 {
1443 {
1444 fbins_mask_dump[k] = fbins_mask_TC[k];
1444 fbins_mask_dump[k] = fbins_mask_TC[k];
1445 }
1445 }
1446
1446
1447 return status;
1447 return status;
1448 }
1448 }
1449
1449
1450 //***************************
1450 //***************************
1451 // TC_LFR_LOAD_PAS_FILTER_PAR
1451 // TC_LFR_LOAD_PAS_FILTER_PAR
1452
1452
1453 int check_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value )
1453 int check_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value )
1454 {
1454 {
1455 float rw_k;
1455 float rw_k;
1456 int ret;
1456 int ret;
1457
1457
1458 ret = LFR_SUCCESSFUL;
1458 ret = LFR_SUCCESSFUL;
1459 rw_k = INIT_FLOAT;
1459 rw_k = INIT_FLOAT;
1460
1460
1461 copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->dataAndCRC[ offset ] );
1461 copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->dataAndCRC[ offset ] );
1462
1462
1463 *pos = offset;
1463 *pos = offset;
1464 *value = rw_k;
1464 *value = rw_k;
1465
1465
1466 if (rw_k < MIN_SY_LFR_RW_F)
1466 if (rw_k < MIN_SY_LFR_RW_F)
1467 {
1467 {
1468 ret = WRONG_APP_DATA;
1468 ret = WRONG_APP_DATA;
1469 }
1469 }
1470
1470
1471 return ret;
1471 return ret;
1472 }
1472 }
1473
1473
1474 int check_all_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int *pos, float *value )
1474 int check_all_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int *pos, float *value )
1475 {
1475 {
1476 int ret;
1476 int ret;
1477
1477
1478 ret = LFR_SUCCESSFUL;
1478 ret = LFR_SUCCESSFUL;
1479
1479
1480 //****
1480 //****
1481 //****
1481 //****
1482 // RW1
1482 // RW1
1483 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K1, pos, value ); // K1
1483 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K1, pos, value ); // K1
1484 if (ret == LFR_SUCCESSFUL) // K2
1484 if (ret == LFR_SUCCESSFUL) // K2
1485 {
1485 {
1486 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K2, pos, value );
1486 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K2, pos, value );
1487 }
1487 }
1488 if (ret == LFR_SUCCESSFUL) // K3
1488 if (ret == LFR_SUCCESSFUL) // K3
1489 {
1489 {
1490 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K3, pos, value );
1490 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K3, pos, value );
1491 }
1491 }
1492 if (ret == LFR_SUCCESSFUL) // K4
1492 if (ret == LFR_SUCCESSFUL) // K4
1493 {
1493 {
1494 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K4, pos, value );
1494 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K4, pos, value );
1495 }
1495 }
1496
1496
1497 //****
1497 //****
1498 //****
1498 //****
1499 // RW2
1499 // RW2
1500 if (ret == LFR_SUCCESSFUL) // K1
1500 if (ret == LFR_SUCCESSFUL) // K1
1501 {
1501 {
1502 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K1, pos, value );
1502 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K1, pos, value );
1503 }
1503 }
1504 if (ret == LFR_SUCCESSFUL) // K2
1504 if (ret == LFR_SUCCESSFUL) // K2
1505 {
1505 {
1506 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K2, pos, value );
1506 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K2, pos, value );
1507 }
1507 }
1508 if (ret == LFR_SUCCESSFUL) // K3
1508 if (ret == LFR_SUCCESSFUL) // K3
1509 {
1509 {
1510 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K3, pos, value );
1510 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K3, pos, value );
1511 }
1511 }
1512 if (ret == LFR_SUCCESSFUL) // K4
1512 if (ret == LFR_SUCCESSFUL) // K4
1513 {
1513 {
1514 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K4, pos, value );
1514 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K4, pos, value );
1515 }
1515 }
1516
1516
1517 //****
1517 //****
1518 //****
1518 //****
1519 // RW3
1519 // RW3
1520 if (ret == LFR_SUCCESSFUL) // K1
1520 if (ret == LFR_SUCCESSFUL) // K1
1521 {
1521 {
1522 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K1, pos, value );
1522 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K1, pos, value );
1523 }
1523 }
1524 if (ret == LFR_SUCCESSFUL) // K2
1524 if (ret == LFR_SUCCESSFUL) // K2
1525 {
1525 {
1526 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K2, pos, value );
1526 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K2, pos, value );
1527 }
1527 }
1528 if (ret == LFR_SUCCESSFUL) // K3
1528 if (ret == LFR_SUCCESSFUL) // K3
1529 {
1529 {
1530 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K3, pos, value );
1530 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K3, pos, value );
1531 }
1531 }
1532 if (ret == LFR_SUCCESSFUL) // K4
1532 if (ret == LFR_SUCCESSFUL) // K4
1533 {
1533 {
1534 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K4, pos, value );
1534 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K4, pos, value );
1535 }
1535 }
1536
1536
1537 //****
1537 //****
1538 //****
1538 //****
1539 // RW4
1539 // RW4
1540 if (ret == LFR_SUCCESSFUL) // K1
1540 if (ret == LFR_SUCCESSFUL) // K1
1541 {
1541 {
1542 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K1, pos, value );
1542 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K1, pos, value );
1543 }
1543 }
1544 if (ret == LFR_SUCCESSFUL) // K2
1544 if (ret == LFR_SUCCESSFUL) // K2
1545 {
1545 {
1546 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K2, pos, value );
1546 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K2, pos, value );
1547 }
1547 }
1548 if (ret == LFR_SUCCESSFUL) // K3
1548 if (ret == LFR_SUCCESSFUL) // K3
1549 {
1549 {
1550 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K3, pos, value );
1550 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K3, pos, value );
1551 }
1551 }
1552 if (ret == LFR_SUCCESSFUL) // K4
1552 if (ret == LFR_SUCCESSFUL) // K4
1553 {
1553 {
1554 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K4, pos, value );
1554 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K4, pos, value );
1555 }
1555 }
1556
1556
1557 return ret;
1557 return ret;
1558 }
1558 }
1559
1559
1560 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1560 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1561 {
1561 {
1562 int flag;
1562 int flag;
1563 rtems_status_code status;
1563 rtems_status_code status;
1564
1564
1565 unsigned char sy_lfr_pas_filter_enabled;
1565 unsigned char sy_lfr_pas_filter_enabled;
1566 unsigned char sy_lfr_pas_filter_modulus;
1566 unsigned char sy_lfr_pas_filter_modulus;
1567 float sy_lfr_pas_filter_tbad;
1567 float sy_lfr_pas_filter_tbad;
1568 unsigned char sy_lfr_pas_filter_offset;
1568 unsigned char sy_lfr_pas_filter_offset;
1569 float sy_lfr_pas_filter_shift;
1569 float sy_lfr_pas_filter_shift;
1570 float sy_lfr_sc_rw_delta_f;
1570 float sy_lfr_sc_rw_delta_f;
1571 char *parPtr;
1571 char *parPtr;
1572 int datafield_pos;
1572 int datafield_pos;
1573 float rw_k;
1573 float rw_k;
1574
1574
1575 flag = LFR_SUCCESSFUL;
1575 flag = LFR_SUCCESSFUL;
1576 sy_lfr_pas_filter_tbad = INIT_FLOAT;
1576 sy_lfr_pas_filter_tbad = INIT_FLOAT;
1577 sy_lfr_pas_filter_shift = INIT_FLOAT;
1577 sy_lfr_pas_filter_shift = INIT_FLOAT;
1578 sy_lfr_sc_rw_delta_f = INIT_FLOAT;
1578 sy_lfr_sc_rw_delta_f = INIT_FLOAT;
1579 parPtr = NULL;
1579 parPtr = NULL;
1580 datafield_pos = INIT_INT;
1580 datafield_pos = INIT_INT;
1581 rw_k = INIT_FLOAT;
1581 rw_k = INIT_FLOAT;
1582
1582
1583 //***************
1583 //***************
1584 // get parameters
1584 // get parameters
1585 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001]
1585 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001]
1586 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1586 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1587 copyFloatByChar(
1587 copyFloatByChar(
1588 (unsigned char*) &sy_lfr_pas_filter_tbad,
1588 (unsigned char*) &sy_lfr_pas_filter_tbad,
1589 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1589 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1590 );
1590 );
1591 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1591 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1592 copyFloatByChar(
1592 copyFloatByChar(
1593 (unsigned char*) &sy_lfr_pas_filter_shift,
1593 (unsigned char*) &sy_lfr_pas_filter_shift,
1594 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1594 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1595 );
1595 );
1596 copyFloatByChar(
1596 copyFloatByChar(
1597 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1597 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1598 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1598 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1599 );
1599 );
1600
1600
1601 //******************
1601 //******************
1602 // CHECK CONSISTENCY
1602 // CHECK CONSISTENCY
1603
1603
1604 //**************************
1604 //**************************
1605 // sy_lfr_pas_filter_enabled
1605 // sy_lfr_pas_filter_enabled
1606 // nothing to check, value is 0 or 1
1606 // nothing to check, value is 0 or 1
1607
1607
1608 //**************************
1608 //**************************
1609 // sy_lfr_pas_filter_modulus
1609 // sy_lfr_pas_filter_modulus
1610 if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) )
1610 if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) )
1611 {
1611 {
1612 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1612 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1613 flag = WRONG_APP_DATA;
1613 flag = WRONG_APP_DATA;
1614 }
1614 }
1615
1615
1616 //***********************
1616 //***********************
1617 // sy_lfr_pas_filter_tbad
1617 // sy_lfr_pas_filter_tbad
1618 if (flag == LFR_SUCCESSFUL)
1618 if (flag == LFR_SUCCESSFUL)
1619 {
1619 {
1620 if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) )
1620 if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) )
1621 {
1621 {
1622 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1622 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1623 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1623 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1624 flag = WRONG_APP_DATA;
1624 flag = WRONG_APP_DATA;
1625 }
1625 }
1626 }
1626 }
1627
1627
1628 //*************************
1628 //*************************
1629 // sy_lfr_pas_filter_offset
1629 // sy_lfr_pas_filter_offset
1630 if (flag == LFR_SUCCESSFUL)
1630 if (flag == LFR_SUCCESSFUL)
1631 {
1631 {
1632 if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) )
1632 if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) )
1633 {
1633 {
1634 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset );
1634 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset );
1635 flag = WRONG_APP_DATA;
1635 flag = WRONG_APP_DATA;
1636 }
1636 }
1637 }
1637 }
1638
1638
1639 //************************
1639 //************************
1640 // sy_lfr_pas_filter_shift
1640 // sy_lfr_pas_filter_shift
1641 if (flag == LFR_SUCCESSFUL)
1641 if (flag == LFR_SUCCESSFUL)
1642 {
1642 {
1643 if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) )
1643 if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) )
1644 {
1644 {
1645 parPtr = (char*) &sy_lfr_pas_filter_shift;
1645 parPtr = (char*) &sy_lfr_pas_filter_shift;
1646 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1646 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1647 flag = WRONG_APP_DATA;
1647 flag = WRONG_APP_DATA;
1648 }
1648 }
1649 }
1649 }
1650
1650
1651 //*************************************
1651 //*************************************
1652 // check global coherency of the values
1652 // check global coherency of the values
1653 if (flag == LFR_SUCCESSFUL)
1653 if (flag == LFR_SUCCESSFUL)
1654 {
1654 {
1655 if ( (sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) >= sy_lfr_pas_filter_modulus )
1655 if ( (sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) >= sy_lfr_pas_filter_modulus )
1656 {
1656 {
1657 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1657 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1658 flag = WRONG_APP_DATA;
1658 flag = WRONG_APP_DATA;
1659 }
1659 }
1660 }
1660 }
1661
1661
1662 //*********************
1662 //*********************
1663 // sy_lfr_sc_rw_delta_f
1663 // sy_lfr_sc_rw_delta_f
1664 if (flag == LFR_SUCCESSFUL)
1664 if (flag == LFR_SUCCESSFUL)
1665 {
1665 {
1666 if ( sy_lfr_sc_rw_delta_f < MIN_SY_LFR_SC_RW_DELTA_F )
1666 if ( sy_lfr_sc_rw_delta_f < MIN_SY_LFR_SC_RW_DELTA_F )
1667 {
1667 {
1668 parPtr = (char*) &sy_lfr_pas_filter_shift;
1668 parPtr = (char*) &sy_lfr_sc_rw_delta_f;
1669 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + DATAFIELD_OFFSET, sy_lfr_sc_rw_delta_f );
1669 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1670 flag = WRONG_APP_DATA;
1670 flag = WRONG_APP_DATA;
1671 }
1671 }
1672 }
1672 }
1673
1673
1674 //************
1674 //************
1675 // sy_lfr_rw_k
1675 // sy_lfr_rw_k
1676 if (flag == LFR_SUCCESSFUL)
1676 if (flag == LFR_SUCCESSFUL)
1677 {
1677 {
1678 flag = check_all_sy_lfr_rw_k( TC, &datafield_pos, &rw_k );
1678 flag = check_all_sy_lfr_rw_k( TC, &datafield_pos, &rw_k );
1679 if (flag != LFR_SUCCESSFUL)
1679 if (flag != LFR_SUCCESSFUL)
1680 {
1680 {
1681 parPtr = (char*) &sy_lfr_pas_filter_shift;
1681 parPtr = (char*) &sy_lfr_pas_filter_shift;
1682 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, datafield_pos + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1682 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, datafield_pos + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1683 }
1683 }
1684 }
1684 }
1685
1685
1686 return flag;
1686 return flag;
1687 }
1687 }
1688
1688
1689 //**************
1689 //**************
1690 // KCOEFFICIENTS
1690 // KCOEFFICIENTS
1691 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1691 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1692 {
1692 {
1693 unsigned int kcoeff;
1693 unsigned int kcoeff;
1694 unsigned short sy_lfr_kcoeff_frequency;
1694 unsigned short sy_lfr_kcoeff_frequency;
1695 unsigned short bin;
1695 unsigned short bin;
1696 float *kcoeffPtr_norm;
1696 float *kcoeffPtr_norm;
1697 float *kcoeffPtr_sbm;
1697 float *kcoeffPtr_sbm;
1698 int status;
1698 int status;
1699 unsigned char *kcoeffLoadPtr;
1699 unsigned char *kcoeffLoadPtr;
1700 unsigned char *kcoeffNormPtr;
1700 unsigned char *kcoeffNormPtr;
1701 unsigned char *kcoeffSbmPtr_a;
1701 unsigned char *kcoeffSbmPtr_a;
1702 unsigned char *kcoeffSbmPtr_b;
1702 unsigned char *kcoeffSbmPtr_b;
1703
1703
1704 sy_lfr_kcoeff_frequency = 0;
1704 sy_lfr_kcoeff_frequency = 0;
1705 bin = 0;
1705 bin = 0;
1706 kcoeffPtr_norm = NULL;
1706 kcoeffPtr_norm = NULL;
1707 kcoeffPtr_sbm = NULL;
1707 kcoeffPtr_sbm = NULL;
1708 status = LFR_SUCCESSFUL;
1708 status = LFR_SUCCESSFUL;
1709
1709
1710 // copy the value of the frequency byte by byte DO NOT USE A SHORT* POINTER
1710 // copy the value of the frequency byte by byte DO NOT USE A SHORT* POINTER
1711 copyInt16ByChar( (unsigned char*) &sy_lfr_kcoeff_frequency, &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] );
1711 copyInt16ByChar( (unsigned char*) &sy_lfr_kcoeff_frequency, &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] );
1712
1712
1713
1713
1714 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1714 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1715 {
1715 {
1716 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1716 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1717 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET,
1717 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET,
1718 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1718 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1719 status = LFR_DEFAULT;
1719 status = LFR_DEFAULT;
1720 }
1720 }
1721 else
1721 else
1722 {
1722 {
1723 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1723 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1724 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1724 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1725 {
1725 {
1726 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1726 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1727 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1727 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1728 bin = sy_lfr_kcoeff_frequency;
1728 bin = sy_lfr_kcoeff_frequency;
1729 }
1729 }
1730 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1730 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1731 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1731 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1732 {
1732 {
1733 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1733 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1734 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1734 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1735 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1735 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1736 }
1736 }
1737 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1737 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1738 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1738 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1739 {
1739 {
1740 kcoeffPtr_norm = k_coeff_intercalib_f2;
1740 kcoeffPtr_norm = k_coeff_intercalib_f2;
1741 kcoeffPtr_sbm = NULL;
1741 kcoeffPtr_sbm = NULL;
1742 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1742 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1743 }
1743 }
1744 }
1744 }
1745
1745
1746 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1746 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1747 {
1747 {
1748 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1748 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1749 {
1749 {
1750 // destination
1750 // destination
1751 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1751 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1752 // source
1752 // source
1753 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1753 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1754 // copy source to destination
1754 // copy source to destination
1755 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1755 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1756 }
1756 }
1757 }
1757 }
1758
1758
1759 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1759 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1760 {
1760 {
1761 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1761 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1762 {
1762 {
1763 // destination
1763 // destination
1764 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ];
1764 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ];
1765 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ];
1765 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ];
1766 // source
1766 // source
1767 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1767 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1768 // copy source to destination
1768 // copy source to destination
1769 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1769 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1770 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1770 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1771 }
1771 }
1772 }
1772 }
1773
1773
1774 // print_k_coeff();
1774 // print_k_coeff();
1775
1775
1776 return status;
1776 return status;
1777 }
1777 }
1778
1778
1779 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1779 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1780 {
1780 {
1781 destination[BYTE_0] = source[BYTE_0];
1781 destination[BYTE_0] = source[BYTE_0];
1782 destination[BYTE_1] = source[BYTE_1];
1782 destination[BYTE_1] = source[BYTE_1];
1783 destination[BYTE_2] = source[BYTE_2];
1783 destination[BYTE_2] = source[BYTE_2];
1784 destination[BYTE_3] = source[BYTE_3];
1784 destination[BYTE_3] = source[BYTE_3];
1785 }
1785 }
1786
1786
1787 void copyInt32ByChar( unsigned char *destination, unsigned char *source )
1787 void copyInt32ByChar( unsigned char *destination, unsigned char *source )
1788 {
1788 {
1789 destination[BYTE_0] = source[BYTE_0];
1789 destination[BYTE_0] = source[BYTE_0];
1790 destination[BYTE_1] = source[BYTE_1];
1790 destination[BYTE_1] = source[BYTE_1];
1791 destination[BYTE_2] = source[BYTE_2];
1791 destination[BYTE_2] = source[BYTE_2];
1792 destination[BYTE_3] = source[BYTE_3];
1792 destination[BYTE_3] = source[BYTE_3];
1793 }
1793 }
1794
1794
1795 void copyInt16ByChar( unsigned char *destination, unsigned char *source )
1795 void copyInt16ByChar( unsigned char *destination, unsigned char *source )
1796 {
1796 {
1797 destination[BYTE_0] = source[BYTE_0];
1797 destination[BYTE_0] = source[BYTE_0];
1798 destination[BYTE_1] = source[BYTE_1];
1798 destination[BYTE_1] = source[BYTE_1];
1799 }
1799 }
1800
1800
1801 void floatToChar( float value, unsigned char* ptr)
1801 void floatToChar( float value, unsigned char* ptr)
1802 {
1802 {
1803 unsigned char* valuePtr;
1803 unsigned char* valuePtr;
1804
1804
1805 valuePtr = (unsigned char*) &value;
1805 valuePtr = (unsigned char*) &value;
1806
1806
1807 ptr[BYTE_0] = valuePtr[BYTE_0];
1807 ptr[BYTE_0] = valuePtr[BYTE_0];
1808 ptr[BYTE_1] = valuePtr[BYTE_1];
1808 ptr[BYTE_1] = valuePtr[BYTE_1];
1809 ptr[BYTE_2] = valuePtr[BYTE_2];
1809 ptr[BYTE_2] = valuePtr[BYTE_2];
1810 ptr[BYTE_3] = valuePtr[BYTE_3];
1810 ptr[BYTE_3] = valuePtr[BYTE_3];
1811 }
1811 }
1812
1812
1813 //**********
1813 //**********
1814 // init dump
1814 // init dump
1815
1815
1816 void init_parameter_dump( void )
1816 void init_parameter_dump( void )
1817 {
1817 {
1818 /** This function initialize the parameter_dump_packet global variable with default values.
1818 /** This function initialize the parameter_dump_packet global variable with default values.
1819 *
1819 *
1820 */
1820 */
1821
1821
1822 unsigned int k;
1822 unsigned int k;
1823
1823
1824 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1824 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1825 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1825 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1826 parameter_dump_packet.reserved = CCSDS_RESERVED;
1826 parameter_dump_packet.reserved = CCSDS_RESERVED;
1827 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1827 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1828 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1828 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1829 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1829 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1830 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1830 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1831 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1831 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1832 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE);
1832 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE);
1833 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1833 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1834 // DATA FIELD HEADER
1834 // DATA FIELD HEADER
1835 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1835 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1836 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1836 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1837 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1837 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1838 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1838 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1839 parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
1839 parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
1840 parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
1840 parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
1841 parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
1841 parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
1842 parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
1842 parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
1843 parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
1843 parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
1844 parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
1844 parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
1845 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1845 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1846
1846
1847 //******************
1847 //******************
1848 // COMMON PARAMETERS
1848 // COMMON PARAMETERS
1849 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1849 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1850 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1850 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1851
1851
1852 //******************
1852 //******************
1853 // NORMAL PARAMETERS
1853 // NORMAL PARAMETERS
1854 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE);
1854 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE);
1855 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1855 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1856 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE);
1856 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE);
1857 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1857 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1858 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE);
1858 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE);
1859 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1859 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1860 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1860 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1861 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1861 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1862 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1862 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1863
1863
1864 //*****************
1864 //*****************
1865 // BURST PARAMETERS
1865 // BURST PARAMETERS
1866 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1866 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1867 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1867 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1868
1868
1869 //****************
1869 //****************
1870 // SBM1 PARAMETERS
1870 // SBM1 PARAMETERS
1871 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
1871 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
1872 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1872 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1873
1873
1874 //****************
1874 //****************
1875 // SBM2 PARAMETERS
1875 // SBM2 PARAMETERS
1876 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1876 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1877 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1877 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1878
1878
1879 //************
1879 //************
1880 // FBINS MASKS
1880 // FBINS MASKS
1881 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1881 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1882 {
1882 {
1883 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F;
1883 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F;
1884 }
1884 }
1885
1885
1886 // PAS FILTER PARAMETERS
1886 // PAS FILTER PARAMETERS
1887 parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR;
1887 parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR;
1888 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR;
1888 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR;
1889 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1889 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1890 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1890 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1891 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1891 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1892 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1892 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1893 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1893 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1894
1894
1895 // RW1_K
1895 // RW1_K
1896 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1);
1896 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1);
1897 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2);
1897 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2);
1898 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3);
1898 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3);
1899 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4);
1899 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4);
1900 // RW2_K
1900 // RW2_K
1901 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1);
1901 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1);
1902 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2);
1902 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2);
1903 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3);
1903 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3);
1904 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4);
1904 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4);
1905 // RW3_K
1905 // RW3_K
1906 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1);
1906 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1);
1907 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2);
1907 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2);
1908 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3);
1908 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3);
1909 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4);
1909 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4);
1910 // RW4_K
1910 // RW4_K
1911 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1);
1911 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1);
1912 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2);
1912 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2);
1913 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3);
1913 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3);
1914 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4);
1914 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4);
1915
1915
1916 // LFR_RW_MASK
1916 // LFR_RW_MASK
1917 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1917 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1918 {
1918 {
1919 parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F;
1919 parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F;
1920 }
1920 }
1921
1921
1922 // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks
1922 // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks
1923 merge_fbins_masks();
1923 merge_fbins_masks();
1924 }
1924 }
1925
1925
1926 void init_kcoefficients_dump( void )
1926 void init_kcoefficients_dump( void )
1927 {
1927 {
1928 init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 );
1928 init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 );
1929 init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 );
1929 init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 );
1930
1930
1931 kcoefficient_node_1.previous = NULL;
1931 kcoefficient_node_1.previous = NULL;
1932 kcoefficient_node_1.next = NULL;
1932 kcoefficient_node_1.next = NULL;
1933 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1933 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1934 kcoefficient_node_1.coarseTime = INIT_CHAR;
1934 kcoefficient_node_1.coarseTime = INIT_CHAR;
1935 kcoefficient_node_1.fineTime = INIT_CHAR;
1935 kcoefficient_node_1.fineTime = INIT_CHAR;
1936 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1936 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1937 kcoefficient_node_1.status = INIT_CHAR;
1937 kcoefficient_node_1.status = INIT_CHAR;
1938
1938
1939 kcoefficient_node_2.previous = NULL;
1939 kcoefficient_node_2.previous = NULL;
1940 kcoefficient_node_2.next = NULL;
1940 kcoefficient_node_2.next = NULL;
1941 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1941 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1942 kcoefficient_node_2.coarseTime = INIT_CHAR;
1942 kcoefficient_node_2.coarseTime = INIT_CHAR;
1943 kcoefficient_node_2.fineTime = INIT_CHAR;
1943 kcoefficient_node_2.fineTime = INIT_CHAR;
1944 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1944 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1945 kcoefficient_node_2.status = INIT_CHAR;
1945 kcoefficient_node_2.status = INIT_CHAR;
1946 }
1946 }
1947
1947
1948 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1948 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1949 {
1949 {
1950 unsigned int k;
1950 unsigned int k;
1951 unsigned int packetLength;
1951 unsigned int packetLength;
1952
1952
1953 packetLength =
1953 packetLength =
1954 ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1954 ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1955
1955
1956 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1956 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1957 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1957 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1958 kcoefficients_dump->reserved = CCSDS_RESERVED;
1958 kcoefficients_dump->reserved = CCSDS_RESERVED;
1959 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1959 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1960 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1960 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1961 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1961 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1962 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1962 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1963 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1963 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1964 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE);
1964 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE);
1965 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1965 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1966 // DATA FIELD HEADER
1966 // DATA FIELD HEADER
1967 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1967 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1968 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1968 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1969 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1969 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1970 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1970 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1971 kcoefficients_dump->time[BYTE_0] = INIT_CHAR;
1971 kcoefficients_dump->time[BYTE_0] = INIT_CHAR;
1972 kcoefficients_dump->time[BYTE_1] = INIT_CHAR;
1972 kcoefficients_dump->time[BYTE_1] = INIT_CHAR;
1973 kcoefficients_dump->time[BYTE_2] = INIT_CHAR;
1973 kcoefficients_dump->time[BYTE_2] = INIT_CHAR;
1974 kcoefficients_dump->time[BYTE_3] = INIT_CHAR;
1974 kcoefficients_dump->time[BYTE_3] = INIT_CHAR;
1975 kcoefficients_dump->time[BYTE_4] = INIT_CHAR;
1975 kcoefficients_dump->time[BYTE_4] = INIT_CHAR;
1976 kcoefficients_dump->time[BYTE_5] = INIT_CHAR;
1976 kcoefficients_dump->time[BYTE_5] = INIT_CHAR;
1977 kcoefficients_dump->sid = SID_K_DUMP;
1977 kcoefficients_dump->sid = SID_K_DUMP;
1978
1978
1979 kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT;
1979 kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT;
1980 kcoefficients_dump->pkt_nr = PKTNR_1;
1980 kcoefficients_dump->pkt_nr = PKTNR_1;
1981 kcoefficients_dump->blk_nr = blk_nr;
1981 kcoefficients_dump->blk_nr = blk_nr;
1982
1982
1983 //******************
1983 //******************
1984 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1984 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1985 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1985 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1986 for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++)
1986 for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++)
1987 {
1987 {
1988 kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR;
1988 kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR;
1989 }
1989 }
1990 }
1990 }
1991
1991
1992 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1992 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1993 {
1993 {
1994 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1994 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1995 *
1995 *
1996 * @param packet_sequence_control points to the packet sequence control which will be incremented
1996 * @param packet_sequence_control points to the packet sequence control which will be incremented
1997 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1997 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1998 *
1998 *
1999 * If the destination ID is not known, a dedicated counter is incremented.
1999 * If the destination ID is not known, a dedicated counter is incremented.
2000 *
2000 *
2001 */
2001 */
2002
2002
2003 unsigned short sequence_cnt;
2003 unsigned short sequence_cnt;
2004 unsigned short segmentation_grouping_flag;
2004 unsigned short segmentation_grouping_flag;
2005 unsigned short new_packet_sequence_control;
2005 unsigned short new_packet_sequence_control;
2006 unsigned char i;
2006 unsigned char i;
2007
2007
2008 switch (destination_id)
2008 switch (destination_id)
2009 {
2009 {
2010 case SID_TC_GROUND:
2010 case SID_TC_GROUND:
2011 i = GROUND;
2011 i = GROUND;
2012 break;
2012 break;
2013 case SID_TC_MISSION_TIMELINE:
2013 case SID_TC_MISSION_TIMELINE:
2014 i = MISSION_TIMELINE;
2014 i = MISSION_TIMELINE;
2015 break;
2015 break;
2016 case SID_TC_TC_SEQUENCES:
2016 case SID_TC_TC_SEQUENCES:
2017 i = TC_SEQUENCES;
2017 i = TC_SEQUENCES;
2018 break;
2018 break;
2019 case SID_TC_RECOVERY_ACTION_CMD:
2019 case SID_TC_RECOVERY_ACTION_CMD:
2020 i = RECOVERY_ACTION_CMD;
2020 i = RECOVERY_ACTION_CMD;
2021 break;
2021 break;
2022 case SID_TC_BACKUP_MISSION_TIMELINE:
2022 case SID_TC_BACKUP_MISSION_TIMELINE:
2023 i = BACKUP_MISSION_TIMELINE;
2023 i = BACKUP_MISSION_TIMELINE;
2024 break;
2024 break;
2025 case SID_TC_DIRECT_CMD:
2025 case SID_TC_DIRECT_CMD:
2026 i = DIRECT_CMD;
2026 i = DIRECT_CMD;
2027 break;
2027 break;
2028 case SID_TC_SPARE_GRD_SRC1:
2028 case SID_TC_SPARE_GRD_SRC1:
2029 i = SPARE_GRD_SRC1;
2029 i = SPARE_GRD_SRC1;
2030 break;
2030 break;
2031 case SID_TC_SPARE_GRD_SRC2:
2031 case SID_TC_SPARE_GRD_SRC2:
2032 i = SPARE_GRD_SRC2;
2032 i = SPARE_GRD_SRC2;
2033 break;
2033 break;
2034 case SID_TC_OBCP:
2034 case SID_TC_OBCP:
2035 i = OBCP;
2035 i = OBCP;
2036 break;
2036 break;
2037 case SID_TC_SYSTEM_CONTROL:
2037 case SID_TC_SYSTEM_CONTROL:
2038 i = SYSTEM_CONTROL;
2038 i = SYSTEM_CONTROL;
2039 break;
2039 break;
2040 case SID_TC_AOCS:
2040 case SID_TC_AOCS:
2041 i = AOCS;
2041 i = AOCS;
2042 break;
2042 break;
2043 case SID_TC_RPW_INTERNAL:
2043 case SID_TC_RPW_INTERNAL:
2044 i = RPW_INTERNAL;
2044 i = RPW_INTERNAL;
2045 break;
2045 break;
2046 default:
2046 default:
2047 i = GROUND;
2047 i = GROUND;
2048 break;
2048 break;
2049 }
2049 }
2050
2050
2051 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
2051 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
2052 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK;
2052 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK;
2053
2053
2054 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
2054 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
2055
2055
2056 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE);
2056 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE);
2057 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
2057 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
2058
2058
2059 // increment the sequence counter
2059 // increment the sequence counter
2060 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
2060 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
2061 {
2061 {
2062 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
2062 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
2063 }
2063 }
2064 else
2064 else
2065 {
2065 {
2066 sequenceCounters_TM_DUMP[ i ] = 0;
2066 sequenceCounters_TM_DUMP[ i ] = 0;
2067 }
2067 }
2068 }
2068 }
General Comments 0
You need to be logged in to leave comments. Login now