##// END OF EJS Templates
bug 426 corrected
paul -
r215:04c08c9a88ab R3
parent child
Show More
@@ -1,2 +1,2
1 b054211408845ff1f92ddeaae6e651e90d996ffb LFR_basic-parameters
1 d2dd915411c7cd1bf4405441d644c6be1cc84e7f LFR_basic-parameters
2 bb9afa759d57093f7646d3be18f4a9923a4cbf84 header/lfr_common_headers
2 bb9afa759d57093f7646d3be18f4a9923a4cbf84 header/lfr_common_headers
@@ -1,1172 +1,1172
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_common_par_consistency( TC, queue_id );
61 flag = check_common_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
103 // sy_lfr_b_bp_p0
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
112 // sy_lfr_b_bp_p1
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 HTE PARAMETERS
135 // SET HTE 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 void printKCoefficients(unsigned int freq, unsigned int bin, float *k_coeff)
313 void printKCoefficients(unsigned int freq, unsigned int bin, float *k_coeff)
314 {
314 {
315 printf("freq = %d *** bin = %d *** (0) %f *** (1) %f *** (2) %f *** (3) %f *** (4) %f\n",
315 printf("freq = %d *** bin = %d *** (0) %f *** (1) %f *** (2) %f *** (3) %f *** (4) %f\n",
316 freq,
316 freq,
317 bin,
317 bin,
318 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 0 ],
318 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 0 ],
319 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 1 ],
319 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 1 ],
320 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 2 ],
320 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 2 ],
321 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 3 ],
321 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 3 ],
322 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 4 ]);
322 k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 4 ]);
323 }
323 }
324
324
325 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
325 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
326 {
326 {
327 /** This function updates the LFR registers with the incoming sbm2 parameters.
327 /** This function updates the LFR registers with the incoming sbm2 parameters.
328 *
328 *
329 * @param TC points to the TeleCommand packet that is being processed
329 * @param TC points to the TeleCommand packet that is being processed
330 * @param queue_id is the id of the queue which handles TM related to this execution step
330 * @param queue_id is the id of the queue which handles TM related to this execution step
331 *
331 *
332 */
332 */
333
333
334 unsigned int address;
334 unsigned int address;
335 rtems_status_code status;
335 rtems_status_code status;
336 unsigned int freq;
336 unsigned int freq;
337 unsigned int bin;
337 unsigned int bin;
338 unsigned int coeff;
338 unsigned int coeff;
339 unsigned char *kCoeffPtr;
339 unsigned char *kCoeffPtr;
340 unsigned char *kCoeffDumpPtr;
340 unsigned char *kCoeffDumpPtr;
341
341
342 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
342 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
343 // F0 => 11 bins
343 // F0 => 11 bins
344 // F1 => 13 bins
344 // F1 => 13 bins
345 // F2 => 12 bins
345 // F2 => 12 bins
346 // 36 bins to dump in two packets (30 bins max per packet)
346 // 36 bins to dump in two packets (30 bins max per packet)
347
347
348 //*********
348 //*********
349 // PACKET 1
349 // PACKET 1
350 // 11 F0 bins, 13 F1 bins and 6 F2 bins
350 // 11 F0 bins, 13 F1 bins and 6 F2 bins
351 kcoefficients_dump_1.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8);
351 kcoefficients_dump_1.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8);
352 kcoefficients_dump_1.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump );
352 kcoefficients_dump_1.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump );
353 increment_seq_counter( &sequenceCounterParameterDump );
353 increment_seq_counter( &sequenceCounterParameterDump );
354 for( freq=0;
354 for( freq=0;
355 freq<NB_BINS_COMPRESSED_SM_F0;
355 freq<NB_BINS_COMPRESSED_SM_F0;
356 freq++ )
356 freq++ )
357 {
357 {
358 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
358 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
359 bin = freq;
359 bin = freq;
360 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
360 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
361 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
361 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
362 {
362 {
363 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
363 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
364 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
364 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
365 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
365 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
366 }
366 }
367 }
367 }
368 for( freq=NB_BINS_COMPRESSED_SM_F0;
368 for( freq=NB_BINS_COMPRESSED_SM_F0;
369 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
369 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
370 freq++ )
370 freq++ )
371 {
371 {
372 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
372 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
373 bin = freq - NB_BINS_COMPRESSED_SM_F0;
373 bin = freq - NB_BINS_COMPRESSED_SM_F0;
374 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
374 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
375 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
375 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
376 {
376 {
377 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
377 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
378 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
378 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
379 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
379 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
380 }
380 }
381 }
381 }
382 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
382 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
383 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
383 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
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 - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
387 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
388 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
388 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
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_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
392 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
393 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
393 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
394 }
394 }
395 }
395 }
396 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
396 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
397 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
397 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
398 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
398 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
399 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
399 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
400 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
400 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
401 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
401 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
402 // SEND DATA
402 // SEND DATA
403 kcoefficient_node_1.status = 1;
403 kcoefficient_node_1.status = 1;
404 address = (unsigned int) &kcoefficient_node_1;
404 address = (unsigned int) &kcoefficient_node_1;
405 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
405 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
406 if (status != RTEMS_SUCCESSFUL) {
406 if (status != RTEMS_SUCCESSFUL) {
407 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
407 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
408 }
408 }
409
409
410 //********
410 //********
411 // PACKET 2
411 // PACKET 2
412 // 6 F2 bins
412 // 6 F2 bins
413 kcoefficients_dump_2.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8);
413 kcoefficients_dump_2.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8);
414 kcoefficients_dump_2.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump );
414 kcoefficients_dump_2.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump );
415 increment_seq_counter( &sequenceCounterParameterDump );
415 increment_seq_counter( &sequenceCounterParameterDump );
416 for( freq=0; freq<6; freq++ )
416 for( freq=0; freq<6; freq++ )
417 {
417 {
418 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
418 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
419 bin = freq + 6;
419 bin = freq + 6;
420 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
420 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
421 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
421 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
422 {
422 {
423 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
423 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
424 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
424 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
425 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
425 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
426 }
426 }
427 }
427 }
428 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
428 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
429 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
429 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
430 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
430 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
431 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
431 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
432 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
432 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
433 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
433 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
434 // SEND DATA
434 // SEND DATA
435 kcoefficient_node_2.status = 1;
435 kcoefficient_node_2.status = 1;
436 address = (unsigned int) &kcoefficient_node_2;
436 address = (unsigned int) &kcoefficient_node_2;
437 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
437 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
438 if (status != RTEMS_SUCCESSFUL) {
438 if (status != RTEMS_SUCCESSFUL) {
439 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
439 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
440 }
440 }
441
441
442 return status;
442 return status;
443 }
443 }
444
444
445 int action_dump_par( rtems_id queue_id )
445 int action_dump_par( rtems_id queue_id )
446 {
446 {
447 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
447 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
448 *
448 *
449 * @param queue_id is the id of the queue which handles TM related to this execution step.
449 * @param queue_id is the id of the queue which handles TM related to this execution step.
450 *
450 *
451 * @return RTEMS directive status codes:
451 * @return RTEMS directive status codes:
452 * - RTEMS_SUCCESSFUL - message sent successfully
452 * - RTEMS_SUCCESSFUL - message sent successfully
453 * - RTEMS_INVALID_ID - invalid queue id
453 * - RTEMS_INVALID_ID - invalid queue id
454 * - RTEMS_INVALID_SIZE - invalid message size
454 * - RTEMS_INVALID_SIZE - invalid message size
455 * - RTEMS_INVALID_ADDRESS - buffer is NULL
455 * - RTEMS_INVALID_ADDRESS - buffer is NULL
456 * - RTEMS_UNSATISFIED - out of message buffers
456 * - RTEMS_UNSATISFIED - out of message buffers
457 * - RTEMS_TOO_MANY - queue s limit has been reached
457 * - RTEMS_TOO_MANY - queue s limit has been reached
458 *
458 *
459 */
459 */
460
460
461 int status;
461 int status;
462
462
463 // UPDATE TIME
463 // UPDATE TIME
464 parameter_dump_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8);
464 parameter_dump_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8);
465 parameter_dump_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump );
465 parameter_dump_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump );
466 increment_seq_counter( &sequenceCounterParameterDump );
466 increment_seq_counter( &sequenceCounterParameterDump );
467
467
468 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
468 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
469 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
469 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
470 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
470 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
471 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
471 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
472 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
472 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
473 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
473 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
474 // SEND DATA
474 // SEND DATA
475 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
475 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
476 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
476 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
477 if (status != RTEMS_SUCCESSFUL) {
477 if (status != RTEMS_SUCCESSFUL) {
478 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
478 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
479 }
479 }
480
480
481 return status;
481 return status;
482 }
482 }
483
483
484 //***********************
484 //***********************
485 // NORMAL MODE PARAMETERS
485 // NORMAL MODE PARAMETERS
486
486
487 int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
487 int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
488 {
488 {
489 unsigned char msb;
489 unsigned char msb;
490 unsigned char lsb;
490 unsigned char lsb;
491 int flag;
491 int flag;
492 float aux;
492 float aux;
493 rtems_status_code status;
493 rtems_status_code status;
494
494
495 unsigned int sy_lfr_n_swf_l;
495 unsigned int sy_lfr_n_swf_l;
496 unsigned int sy_lfr_n_swf_p;
496 unsigned int sy_lfr_n_swf_p;
497 unsigned int sy_lfr_n_asm_p;
497 unsigned int sy_lfr_n_asm_p;
498 unsigned char sy_lfr_n_bp_p0;
498 unsigned char sy_lfr_n_bp_p0;
499 unsigned char sy_lfr_n_bp_p1;
499 unsigned char sy_lfr_n_bp_p1;
500 unsigned char sy_lfr_n_cwf_long_f3;
500 unsigned char sy_lfr_n_cwf_long_f3;
501
501
502 flag = LFR_SUCCESSFUL;
502 flag = LFR_SUCCESSFUL;
503
503
504 //***************
504 //***************
505 // get parameters
505 // get parameters
506 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
506 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
507 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
507 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
508 sy_lfr_n_swf_l = msb * 256 + lsb;
508 sy_lfr_n_swf_l = msb * 256 + lsb;
509
509
510 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
510 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
511 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
511 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
512 sy_lfr_n_swf_p = msb * 256 + lsb;
512 sy_lfr_n_swf_p = msb * 256 + lsb;
513
513
514 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
514 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
515 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
515 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
516 sy_lfr_n_asm_p = msb * 256 + lsb;
516 sy_lfr_n_asm_p = msb * 256 + lsb;
517
517
518 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
518 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
519
519
520 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
520 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
521
521
522 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
522 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
523
523
524 //******************
524 //******************
525 // check consistency
525 // check consistency
526 // sy_lfr_n_swf_l
526 // sy_lfr_n_swf_l
527 if (sy_lfr_n_swf_l != 2048)
527 if (sy_lfr_n_swf_l != 2048)
528 {
528 {
529 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
529 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
530 flag = WRONG_APP_DATA;
530 flag = WRONG_APP_DATA;
531 }
531 }
532 // sy_lfr_n_swf_p
532 // sy_lfr_n_swf_p
533 if (flag == LFR_SUCCESSFUL)
533 if (flag == LFR_SUCCESSFUL)
534 {
534 {
535 if ( sy_lfr_n_swf_p < 16 )
535 if ( sy_lfr_n_swf_p < 16 )
536 {
536 {
537 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
537 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
538 flag = WRONG_APP_DATA;
538 flag = WRONG_APP_DATA;
539 }
539 }
540 }
540 }
541 // sy_lfr_n_bp_p0
541 // sy_lfr_n_bp_p0
542 if (flag == LFR_SUCCESSFUL)
542 if (flag == LFR_SUCCESSFUL)
543 {
543 {
544 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
544 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
545 {
545 {
546 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
546 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
547 flag = WRONG_APP_DATA;
547 flag = WRONG_APP_DATA;
548 }
548 }
549 }
549 }
550 // sy_lfr_n_asm_p
550 // sy_lfr_n_asm_p
551 if (flag == LFR_SUCCESSFUL)
551 if (flag == LFR_SUCCESSFUL)
552 {
552 {
553 if (sy_lfr_n_asm_p == 0)
553 if (sy_lfr_n_asm_p == 0)
554 {
554 {
555 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
555 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
556 flag = WRONG_APP_DATA;
556 flag = WRONG_APP_DATA;
557 }
557 }
558 }
558 }
559 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
559 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
560 if (flag == LFR_SUCCESSFUL)
560 if (flag == LFR_SUCCESSFUL)
561 {
561 {
562 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
562 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
563 if (aux > FLOAT_EQUAL_ZERO)
563 if (aux > FLOAT_EQUAL_ZERO)
564 {
564 {
565 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
565 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
566 flag = WRONG_APP_DATA;
566 flag = WRONG_APP_DATA;
567 }
567 }
568 }
568 }
569 // sy_lfr_n_bp_p1
569 // sy_lfr_n_bp_p1
570 if (flag == LFR_SUCCESSFUL)
570 if (flag == LFR_SUCCESSFUL)
571 {
571 {
572 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
572 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
573 {
573 {
574 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
574 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
575 flag = WRONG_APP_DATA;
575 flag = WRONG_APP_DATA;
576 }
576 }
577 }
577 }
578 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
578 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
579 if (flag == LFR_SUCCESSFUL)
579 if (flag == LFR_SUCCESSFUL)
580 {
580 {
581 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
581 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
582 if (aux > FLOAT_EQUAL_ZERO)
582 if (aux > FLOAT_EQUAL_ZERO)
583 {
583 {
584 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
584 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
585 flag = LFR_DEFAULT;
585 flag = LFR_DEFAULT;
586 }
586 }
587 }
587 }
588 // sy_lfr_n_cwf_long_f3
588 // sy_lfr_n_cwf_long_f3
589
589
590 return flag;
590 return flag;
591 }
591 }
592
592
593 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
593 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
594 {
594 {
595 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
595 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
596 *
596 *
597 * @param TC points to the TeleCommand packet that is being processed
597 * @param TC points to the TeleCommand packet that is being processed
598 * @param queue_id is the id of the queue which handles TM related to this execution step
598 * @param queue_id is the id of the queue which handles TM related to this execution step
599 *
599 *
600 */
600 */
601
601
602 int result;
602 int result;
603
603
604 result = LFR_SUCCESSFUL;
604 result = LFR_SUCCESSFUL;
605
605
606 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
606 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
607 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
607 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
608
608
609 return result;
609 return result;
610 }
610 }
611
611
612 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
612 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
613 {
613 {
614 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
614 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
615 *
615 *
616 * @param TC points to the TeleCommand packet that is being processed
616 * @param TC points to the TeleCommand packet that is being processed
617 * @param queue_id is the id of the queue which handles TM related to this execution step
617 * @param queue_id is the id of the queue which handles TM related to this execution step
618 *
618 *
619 */
619 */
620
620
621 int result;
621 int result;
622
622
623 result = LFR_SUCCESSFUL;
623 result = LFR_SUCCESSFUL;
624
624
625 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
625 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
626 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
626 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
627
627
628 return result;
628 return result;
629 }
629 }
630
630
631 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
631 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
632 {
632 {
633 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
633 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
634 *
634 *
635 * @param TC points to the TeleCommand packet that is being processed
635 * @param TC points to the TeleCommand packet that is being processed
636 * @param queue_id is the id of the queue which handles TM related to this execution step
636 * @param queue_id is the id of the queue which handles TM related to this execution step
637 *
637 *
638 */
638 */
639
639
640 int result;
640 int result;
641
641
642 result = LFR_SUCCESSFUL;
642 result = LFR_SUCCESSFUL;
643
643
644 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
644 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
645 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
645 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
646
646
647 return result;
647 return result;
648 }
648 }
649
649
650 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
650 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
651 {
651 {
652 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
652 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
653 *
653 *
654 * @param TC points to the TeleCommand packet that is being processed
654 * @param TC points to the TeleCommand packet that is being processed
655 * @param queue_id is the id of the queue which handles TM related to this execution step
655 * @param queue_id is the id of the queue which handles TM related to this execution step
656 *
656 *
657 */
657 */
658
658
659 int status;
659 int status;
660
660
661 status = LFR_SUCCESSFUL;
661 status = LFR_SUCCESSFUL;
662
662
663 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
663 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
664
664
665 return status;
665 return status;
666 }
666 }
667
667
668 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
668 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
669 {
669 {
670 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
670 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
671 *
671 *
672 * @param TC points to the TeleCommand packet that is being processed
672 * @param TC points to the TeleCommand packet that is being processed
673 * @param queue_id is the id of the queue which handles TM related to this execution step
673 * @param queue_id is the id of the queue which handles TM related to this execution step
674 *
674 *
675 */
675 */
676
676
677 int status;
677 int status;
678
678
679 status = LFR_SUCCESSFUL;
679 status = LFR_SUCCESSFUL;
680
680
681 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
681 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
682
682
683 return status;
683 return status;
684 }
684 }
685
685
686 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
686 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
687 {
687 {
688 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
688 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
689 *
689 *
690 * @param TC points to the TeleCommand packet that is being processed
690 * @param TC points to the TeleCommand packet that is being processed
691 * @param queue_id is the id of the queue which handles TM related to this execution step
691 * @param queue_id is the id of the queue which handles TM related to this execution step
692 *
692 *
693 */
693 */
694
694
695 int status;
695 int status;
696
696
697 status = LFR_SUCCESSFUL;
697 status = LFR_SUCCESSFUL;
698
698
699 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
699 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
700
700
701 return status;
701 return status;
702 }
702 }
703
703
704 //**********************
704 //**********************
705 // BURST MODE PARAMETERS
705 // BURST MODE PARAMETERS
706 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
706 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
707 {
707 {
708 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
708 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
709 *
709 *
710 * @param TC points to the TeleCommand packet that is being processed
710 * @param TC points to the TeleCommand packet that is being processed
711 * @param queue_id is the id of the queue which handles TM related to this execution step
711 * @param queue_id is the id of the queue which handles TM related to this execution step
712 *
712 *
713 */
713 */
714
714
715 int status;
715 int status;
716
716
717 status = LFR_SUCCESSFUL;
717 status = LFR_SUCCESSFUL;
718
718
719 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
719 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
720
720
721 return status;
721 return status;
722 }
722 }
723
723
724 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
724 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
725 {
725 {
726 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
726 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
727 *
727 *
728 * @param TC points to the TeleCommand packet that is being processed
728 * @param TC points to the TeleCommand packet that is being processed
729 * @param queue_id is the id of the queue which handles TM related to this execution step
729 * @param queue_id is the id of the queue which handles TM related to this execution step
730 *
730 *
731 */
731 */
732
732
733 int status;
733 int status;
734
734
735 status = LFR_SUCCESSFUL;
735 status = LFR_SUCCESSFUL;
736
736
737 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
737 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
738
738
739 return status;
739 return status;
740 }
740 }
741
741
742 //*********************
742 //*********************
743 // SBM1 MODE PARAMETERS
743 // SBM1 MODE PARAMETERS
744 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
744 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
745 {
745 {
746 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
746 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
747 *
747 *
748 * @param TC points to the TeleCommand packet that is being processed
748 * @param TC points to the TeleCommand packet that is being processed
749 * @param queue_id is the id of the queue which handles TM related to this execution step
749 * @param queue_id is the id of the queue which handles TM related to this execution step
750 *
750 *
751 */
751 */
752
752
753 int status;
753 int status;
754
754
755 status = LFR_SUCCESSFUL;
755 status = LFR_SUCCESSFUL;
756
756
757 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
757 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
758
758
759 return status;
759 return status;
760 }
760 }
761
761
762 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
762 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
763 {
763 {
764 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
764 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
765 *
765 *
766 * @param TC points to the TeleCommand packet that is being processed
766 * @param TC points to the TeleCommand packet that is being processed
767 * @param queue_id is the id of the queue which handles TM related to this execution step
767 * @param queue_id is the id of the queue which handles TM related to this execution step
768 *
768 *
769 */
769 */
770
770
771 int status;
771 int status;
772
772
773 status = LFR_SUCCESSFUL;
773 status = LFR_SUCCESSFUL;
774
774
775 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
775 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
776
776
777 return status;
777 return status;
778 }
778 }
779
779
780 //*********************
780 //*********************
781 // SBM2 MODE PARAMETERS
781 // SBM2 MODE PARAMETERS
782 int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC)
782 int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC)
783 {
783 {
784 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
784 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
785 *
785 *
786 * @param TC points to the TeleCommand packet that is being processed
786 * @param TC points to the TeleCommand packet that is being processed
787 * @param queue_id is the id of the queue which handles TM related to this execution step
787 * @param queue_id is the id of the queue which handles TM related to this execution step
788 *
788 *
789 */
789 */
790
790
791 int status;
791 int status;
792
792
793 status = LFR_SUCCESSFUL;
793 status = LFR_SUCCESSFUL;
794
794
795 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
795 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
796
796
797 return status;
797 return status;
798 }
798 }
799
799
800 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
800 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
801 {
801 {
802 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
802 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
803 *
803 *
804 * @param TC points to the TeleCommand packet that is being processed
804 * @param TC points to the TeleCommand packet that is being processed
805 * @param queue_id is the id of the queue which handles TM related to this execution step
805 * @param queue_id is the id of the queue which handles TM related to this execution step
806 *
806 *
807 */
807 */
808
808
809 int status;
809 int status;
810
810
811 status = LFR_SUCCESSFUL;
811 status = LFR_SUCCESSFUL;
812
812
813 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
813 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
814
814
815 return status;
815 return status;
816 }
816 }
817
817
818 //*******************
818 //*******************
819 // TC_LFR_UPDATE_INFO
819 // TC_LFR_UPDATE_INFO
820 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
820 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
821 {
821 {
822 unsigned int status;
822 unsigned int status;
823
823
824 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
824 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
825 || (mode == LFR_MODE_BURST)
825 || (mode == LFR_MODE_BURST)
826 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
826 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
827 {
827 {
828 status = LFR_SUCCESSFUL;
828 status = LFR_SUCCESSFUL;
829 }
829 }
830 else
830 else
831 {
831 {
832 status = LFR_DEFAULT;
832 status = LFR_DEFAULT;
833 }
833 }
834
834
835 return status;
835 return status;
836 }
836 }
837
837
838 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
838 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
839 {
839 {
840 unsigned int status;
840 unsigned int status;
841
841
842 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
842 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
843 || (mode == TDS_MODE_BURST)
843 || (mode == TDS_MODE_BURST)
844 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
844 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
845 || (mode == TDS_MODE_LFM))
845 || (mode == TDS_MODE_LFM))
846 {
846 {
847 status = LFR_SUCCESSFUL;
847 status = LFR_SUCCESSFUL;
848 }
848 }
849 else
849 else
850 {
850 {
851 status = LFR_DEFAULT;
851 status = LFR_DEFAULT;
852 }
852 }
853
853
854 return status;
854 return status;
855 }
855 }
856
856
857 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
857 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
858 {
858 {
859 unsigned int status;
859 unsigned int status;
860
860
861 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
861 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
862 || (mode == THR_MODE_BURST))
862 || (mode == THR_MODE_BURST))
863 {
863 {
864 status = LFR_SUCCESSFUL;
864 status = LFR_SUCCESSFUL;
865 }
865 }
866 else
866 else
867 {
867 {
868 status = LFR_DEFAULT;
868 status = LFR_DEFAULT;
869 }
869 }
870
870
871 return status;
871 return status;
872 }
872 }
873
873
874 //***********
874 //***********
875 // FBINS MASK
875 // FBINS MASK
876
876
877 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
877 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
878 {
878 {
879 int status;
879 int status;
880 unsigned int k;
880 unsigned int k;
881 unsigned char *fbins_mask_dump;
881 unsigned char *fbins_mask_dump;
882 unsigned char *fbins_mask_TC;
882 unsigned char *fbins_mask_TC;
883
883
884 status = LFR_SUCCESSFUL;
884 status = LFR_SUCCESSFUL;
885
885
886 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
886 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
887 fbins_mask_TC = TC->dataAndCRC;
887 fbins_mask_TC = TC->dataAndCRC;
888
888
889 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
889 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
890 {
890 {
891 fbins_mask_dump[k] = fbins_mask_TC[k];
891 fbins_mask_dump[k] = fbins_mask_TC[k];
892 }
892 }
893 for (k=0; k < NB_FBINS_MASKS; k++)
893 for (k=0; k < NB_FBINS_MASKS; k++)
894 {
894 {
895 unsigned char *auxPtr;
895 unsigned char *auxPtr;
896 auxPtr = &parameter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK];
896 auxPtr = &parameter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK];
897 printf("%x %x %x %x\n", auxPtr[0], auxPtr[1], auxPtr[2], auxPtr[3]);
897 printf("%x %x %x %x\n", auxPtr[0], auxPtr[1], auxPtr[2], auxPtr[3]);
898 }
898 }
899
899
900
900
901 return status;
901 return status;
902 }
902 }
903
903
904 //**************
904 //**************
905 // KCOEFFICIENTS
905 // KCOEFFICIENTS
906 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
906 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
907 {
907 {
908 unsigned int kcoeff;
908 unsigned int kcoeff;
909 unsigned short sy_lfr_kcoeff_frequency;
909 unsigned short sy_lfr_kcoeff_frequency;
910 unsigned short bin;
910 unsigned short bin;
911 unsigned short *freqPtr;
911 unsigned short *freqPtr;
912 float *kcoeffPtr_norm;
912 float *kcoeffPtr_norm;
913 float *kcoeffPtr_sbm;
913 float *kcoeffPtr_sbm;
914 int status;
914 int status;
915 unsigned char *kcoeffLoadPtr;
915 unsigned char *kcoeffLoadPtr;
916 unsigned char *kcoeffNormPtr;
916 unsigned char *kcoeffNormPtr;
917 unsigned char *kcoeffSbmPtr_a;
917 unsigned char *kcoeffSbmPtr_a;
918 unsigned char *kcoeffSbmPtr_b;
918 unsigned char *kcoeffSbmPtr_b;
919
919
920 status = LFR_SUCCESSFUL;
920 status = LFR_SUCCESSFUL;
921
921
922 kcoeffPtr_norm = NULL;
922 kcoeffPtr_norm = NULL;
923 kcoeffPtr_sbm = NULL;
923 kcoeffPtr_sbm = NULL;
924 bin = 0;
924 bin = 0;
925
925
926 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
926 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
927 sy_lfr_kcoeff_frequency = *freqPtr;
927 sy_lfr_kcoeff_frequency = *freqPtr;
928
928
929 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
929 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
930 {
930 {
931 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
931 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
932 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10,
932 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
933 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] );
933 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
934 status = LFR_DEFAULT;
934 status = LFR_DEFAULT;
935 }
935 }
936 else
936 else
937 {
937 {
938 if ( ( sy_lfr_kcoeff_frequency >= 0 )
938 if ( ( sy_lfr_kcoeff_frequency >= 0 )
939 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
939 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
940 {
940 {
941 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
941 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
942 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
942 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
943 bin = sy_lfr_kcoeff_frequency;
943 bin = sy_lfr_kcoeff_frequency;
944 }
944 }
945 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
945 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
946 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
946 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
947 {
947 {
948 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
948 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
949 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
949 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
950 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
950 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
951 }
951 }
952 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
952 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
953 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
953 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
954 {
954 {
955 kcoeffPtr_norm = k_coeff_intercalib_f2;
955 kcoeffPtr_norm = k_coeff_intercalib_f2;
956 kcoeffPtr_sbm = NULL;
956 kcoeffPtr_sbm = NULL;
957 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
957 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
958 }
958 }
959 }
959 }
960
960
961 printf("in set_sy_lfr_kcoeff *** freq = %d, bin = %d\n", sy_lfr_kcoeff_frequency, bin);
961 printf("in set_sy_lfr_kcoeff *** freq = %d, bin = %d\n", sy_lfr_kcoeff_frequency, bin);
962
962
963 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
963 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
964 {
964 {
965 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
965 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
966 {
966 {
967 // destination
967 // destination
968 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
968 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
969 // source
969 // source
970 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
970 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
971 // copy source to destination
971 // copy source to destination
972 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
972 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
973 }
973 }
974 }
974 }
975
975
976 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
976 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
977 {
977 {
978 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
978 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
979 {
979 {
980 // destination
980 // destination
981 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
981 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
982 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
982 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
983 // source
983 // source
984 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
984 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
985 // copy source to destination
985 // copy source to destination
986 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
986 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
987 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
987 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
988 }
988 }
989 }
989 }
990
990
991 // print_k_coeff();
991 // print_k_coeff();
992
992
993 return status;
993 return status;
994 }
994 }
995
995
996 void copyFloatByChar( unsigned char *destination, unsigned char *source )
996 void copyFloatByChar( unsigned char *destination, unsigned char *source )
997 {
997 {
998 destination[0] = source[0];
998 destination[0] = source[0];
999 destination[1] = source[1];
999 destination[1] = source[1];
1000 destination[2] = source[2];
1000 destination[2] = source[2];
1001 destination[3] = source[3];
1001 destination[3] = source[3];
1002 }
1002 }
1003
1003
1004 //**********
1004 //**********
1005 // init dump
1005 // init dump
1006
1006
1007 void init_parameter_dump( void )
1007 void init_parameter_dump( void )
1008 {
1008 {
1009 /** This function initialize the parameter_dump_packet global variable with default values.
1009 /** This function initialize the parameter_dump_packet global variable with default values.
1010 *
1010 *
1011 */
1011 */
1012
1012
1013 unsigned int k;
1013 unsigned int k;
1014
1014
1015 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1015 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1016 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1016 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1017 parameter_dump_packet.reserved = CCSDS_RESERVED;
1017 parameter_dump_packet.reserved = CCSDS_RESERVED;
1018 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1018 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1019 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1019 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1020 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1020 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1021 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1021 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1022 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1022 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1023 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1023 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1024 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1024 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1025 // DATA FIELD HEADER
1025 // DATA FIELD HEADER
1026 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1026 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1027 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1027 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1028 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1028 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1029 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1029 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1030 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1030 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1031 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1031 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1032 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1032 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1033 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1033 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1034 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1034 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1035 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1035 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1036 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1036 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1037
1037
1038 //******************
1038 //******************
1039 // COMMON PARAMETERS
1039 // COMMON PARAMETERS
1040 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1040 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1041 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1041 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1042
1042
1043 //******************
1043 //******************
1044 // NORMAL PARAMETERS
1044 // NORMAL PARAMETERS
1045 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1045 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1046 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1046 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1047 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1047 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1048 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1048 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1049 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1049 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1050 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1050 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1051 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1051 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1052 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1052 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1053 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1053 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1054
1054
1055 //*****************
1055 //*****************
1056 // BURST PARAMETERS
1056 // BURST PARAMETERS
1057 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1057 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1058 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1058 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1059
1059
1060 //****************
1060 //****************
1061 // SBM1 PARAMETERS
1061 // SBM1 PARAMETERS
1062 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
1062 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
1063 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1063 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1064
1064
1065 //****************
1065 //****************
1066 // SBM2 PARAMETERS
1066 // SBM2 PARAMETERS
1067 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1067 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1068 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1068 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1069
1069
1070 //************
1070 //************
1071 // FBINS MASKS
1071 // FBINS MASKS
1072 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1072 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1073 {
1073 {
1074 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1074 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1075 }
1075 }
1076 }
1076 }
1077
1077
1078 void init_kcoefficients_dump( void )
1078 void init_kcoefficients_dump( void )
1079 {
1079 {
1080 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1080 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1081 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1081 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1082
1082
1083 kcoefficient_node_1.previous = NULL;
1083 kcoefficient_node_1.previous = NULL;
1084 kcoefficient_node_1.next = NULL;
1084 kcoefficient_node_1.next = NULL;
1085 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1085 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1086 kcoefficient_node_1.coarseTime = 0x00;
1086 kcoefficient_node_1.coarseTime = 0x00;
1087 kcoefficient_node_1.fineTime = 0x00;
1087 kcoefficient_node_1.fineTime = 0x00;
1088 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1088 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1089 kcoefficient_node_1.status = 0x00;
1089 kcoefficient_node_1.status = 0x00;
1090
1090
1091 kcoefficient_node_2.previous = NULL;
1091 kcoefficient_node_2.previous = NULL;
1092 kcoefficient_node_2.next = NULL;
1092 kcoefficient_node_2.next = NULL;
1093 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1093 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1094 kcoefficient_node_2.coarseTime = 0x00;
1094 kcoefficient_node_2.coarseTime = 0x00;
1095 kcoefficient_node_2.fineTime = 0x00;
1095 kcoefficient_node_2.fineTime = 0x00;
1096 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1096 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1097 kcoefficient_node_2.status = 0x00;
1097 kcoefficient_node_2.status = 0x00;
1098 }
1098 }
1099
1099
1100 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1100 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1101 {
1101 {
1102 unsigned int k;
1102 unsigned int k;
1103 unsigned int packetLength;
1103 unsigned int packetLength;
1104
1104
1105 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1105 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1106
1106
1107 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1107 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1108 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1108 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1109 kcoefficients_dump->reserved = CCSDS_RESERVED;
1109 kcoefficients_dump->reserved = CCSDS_RESERVED;
1110 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1110 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1111 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1111 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1112 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1112 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1113 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1113 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1114 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1114 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1115 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1115 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1116 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1116 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1117 // DATA FIELD HEADER
1117 // DATA FIELD HEADER
1118 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1118 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1119 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1119 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1120 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1120 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1121 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1121 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1122 kcoefficients_dump->time[0] = 0x00;
1122 kcoefficients_dump->time[0] = 0x00;
1123 kcoefficients_dump->time[1] = 0x00;
1123 kcoefficients_dump->time[1] = 0x00;
1124 kcoefficients_dump->time[2] = 0x00;
1124 kcoefficients_dump->time[2] = 0x00;
1125 kcoefficients_dump->time[3] = 0x00;
1125 kcoefficients_dump->time[3] = 0x00;
1126 kcoefficients_dump->time[4] = 0x00;
1126 kcoefficients_dump->time[4] = 0x00;
1127 kcoefficients_dump->time[5] = 0x00;
1127 kcoefficients_dump->time[5] = 0x00;
1128 kcoefficients_dump->sid = SID_K_DUMP;
1128 kcoefficients_dump->sid = SID_K_DUMP;
1129
1129
1130 kcoefficients_dump->pkt_cnt = 2;
1130 kcoefficients_dump->pkt_cnt = 2;
1131 kcoefficients_dump->pkt_nr = pkt_nr;
1131 kcoefficients_dump->pkt_nr = pkt_nr;
1132 kcoefficients_dump->blk_nr = blk_nr;
1132 kcoefficients_dump->blk_nr = blk_nr;
1133
1133
1134 //******************
1134 //******************
1135 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1135 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1136 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1136 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1137 for (k=0; k<3900; k++)
1137 for (k=0; k<3900; k++)
1138 {
1138 {
1139 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1139 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1140 }
1140 }
1141 }
1141 }
1142
1142
1143 void print_k_coeff()
1143 void print_k_coeff()
1144 {
1144 {
1145 unsigned int kcoeff;
1145 unsigned int kcoeff;
1146 unsigned int bin;
1146 unsigned int bin;
1147
1147
1148 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1148 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1149 {
1149 {
1150 printf("kcoeff = %d *** ", kcoeff);
1150 printf("kcoeff = %d *** ", kcoeff);
1151 for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++)
1151 for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++)
1152 {
1152 {
1153 printf( "%f ", k_coeff_intercalib_f0_norm[bin*NB_K_COEFF_PER_BIN+kcoeff] );
1153 printf( "%f ", k_coeff_intercalib_f0_norm[bin*NB_K_COEFF_PER_BIN+kcoeff] );
1154 }
1154 }
1155 printf("\n");
1155 printf("\n");
1156 }
1156 }
1157
1157
1158 printf("\n");
1158 printf("\n");
1159
1159
1160 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1160 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1161 {
1161 {
1162 printf("kcoeff = %d *** ", kcoeff);
1162 printf("kcoeff = %d *** ", kcoeff);
1163 for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++)
1163 for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++)
1164 {
1164 {
1165 printf( "[%f, %f] ",
1165 printf( "[%f, %f] ",
1166 k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN )*2 + kcoeff],
1166 k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN )*2 + kcoeff],
1167 k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN+1)*2 + kcoeff]);
1167 k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN+1)*2 + kcoeff]);
1168 }
1168 }
1169 printf("\n");
1169 printf("\n");
1170 }
1170 }
1171 }
1171 }
1172
1172
General Comments 0
You need to be logged in to leave comments. Login now