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