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