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