##// END OF EJS Templates
bug corrected TC_LFR_LOAD_KCOEFFICIENTS with sy_lfr_kcoeff_frequency >= 24
paul -
r207:8a50b41b6c0c R3
parent child
Show More
@@ -1,1175 +1,1174
1 /** Functions and tasks related to TeleCommand handling.
1 /** Functions and tasks related to TeleCommand handling.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TeleCommands:\n
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
7 * action launching\n
8 * TC parsing\n
8 * TC parsing\n
9 * ...
9 * ...
10 *
10 *
11 */
11 */
12
12
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14 #include "math.h"
14 #include "math.h"
15
15
16 //***********
16 //***********
17 // RTEMS TASK
17 // RTEMS TASK
18
18
19 rtems_task actn_task( rtems_task_argument unused )
19 rtems_task actn_task( rtems_task_argument unused )
20 {
20 {
21 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
22 *
22 *
23 * @param unused is the starting argument of the RTEMS task
23 * @param unused is the starting argument of the RTEMS task
24 *
24 *
25 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
26 * on the incoming TeleCommand.
26 * on the incoming TeleCommand.
27 *
27 *
28 */
28 */
29
29
30 int result;
30 int result;
31 rtems_status_code status; // RTEMS status code
31 rtems_status_code status; // RTEMS status code
32 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
33 size_t size; // size of the incoming TC packet
33 size_t size; // size of the incoming TC packet
34 unsigned char subtype; // subtype of the current TC packet
34 unsigned char subtype; // subtype of the current TC packet
35 unsigned char time[6];
35 unsigned char time[6];
36 rtems_id queue_rcv_id;
36 rtems_id queue_rcv_id;
37 rtems_id queue_snd_id;
37 rtems_id queue_snd_id;
38
38
39 status = get_message_queue_id_recv( &queue_rcv_id );
39 status = get_message_queue_id_recv( &queue_rcv_id );
40 if (status != RTEMS_SUCCESSFUL)
40 if (status != RTEMS_SUCCESSFUL)
41 {
41 {
42 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
43 }
43 }
44
44
45 status = get_message_queue_id_send( &queue_snd_id );
45 status = get_message_queue_id_send( &queue_snd_id );
46 if (status != RTEMS_SUCCESSFUL)
46 if (status != RTEMS_SUCCESSFUL)
47 {
47 {
48 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
49 }
49 }
50
50
51 result = LFR_SUCCESSFUL;
51 result = LFR_SUCCESSFUL;
52 subtype = 0; // subtype of the current TC packet
52 subtype = 0; // subtype of the current TC packet
53
53
54 BOOT_PRINTF("in ACTN *** \n")
54 BOOT_PRINTF("in ACTN *** \n")
55
55
56 while(1)
56 while(1)
57 {
57 {
58 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
59 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
60 getTime( time ); // set time to the current time
60 getTime( time ); // set time to the current time
61 if (status!=RTEMS_SUCCESSFUL)
61 if (status!=RTEMS_SUCCESSFUL)
62 {
62 {
63 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
64 }
64 }
65 else
65 else
66 {
66 {
67 subtype = TC.serviceSubType;
67 subtype = TC.serviceSubType;
68 switch(subtype)
68 switch(subtype)
69 {
69 {
70 case TC_SUBTYPE_RESET:
70 case TC_SUBTYPE_RESET:
71 result = action_reset( &TC, queue_snd_id, time );
71 result = action_reset( &TC, queue_snd_id, time );
72 close_action( &TC, result, queue_snd_id );
72 close_action( &TC, result, queue_snd_id );
73 break;
73 break;
74 case TC_SUBTYPE_LOAD_COMM:
74 case TC_SUBTYPE_LOAD_COMM:
75 result = action_load_common_par( &TC );
75 result = action_load_common_par( &TC );
76 close_action( &TC, result, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
77 break;
77 break;
78 case TC_SUBTYPE_LOAD_NORM:
78 case TC_SUBTYPE_LOAD_NORM:
79 result = action_load_normal_par( &TC, queue_snd_id, time );
79 result = action_load_normal_par( &TC, queue_snd_id, time );
80 close_action( &TC, result, queue_snd_id );
80 close_action( &TC, result, queue_snd_id );
81 break;
81 break;
82 case TC_SUBTYPE_LOAD_BURST:
82 case TC_SUBTYPE_LOAD_BURST:
83 result = action_load_burst_par( &TC, queue_snd_id, time );
83 result = action_load_burst_par( &TC, queue_snd_id, time );
84 close_action( &TC, result, queue_snd_id );
84 close_action( &TC, result, queue_snd_id );
85 break;
85 break;
86 case TC_SUBTYPE_LOAD_SBM1:
86 case TC_SUBTYPE_LOAD_SBM1:
87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
88 close_action( &TC, result, queue_snd_id );
88 close_action( &TC, result, queue_snd_id );
89 break;
89 break;
90 case TC_SUBTYPE_LOAD_SBM2:
90 case TC_SUBTYPE_LOAD_SBM2:
91 result = action_load_sbm2_par( &TC, queue_snd_id, time );
91 result = action_load_sbm2_par( &TC, queue_snd_id, time );
92 close_action( &TC, result, queue_snd_id );
92 close_action( &TC, result, queue_snd_id );
93 break;
93 break;
94 case TC_SUBTYPE_DUMP:
94 case TC_SUBTYPE_DUMP:
95 result = action_dump_par( queue_snd_id );
95 result = action_dump_par( queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
97 break;
97 break;
98 case TC_SUBTYPE_ENTER:
98 case TC_SUBTYPE_ENTER:
99 result = action_enter_mode( &TC, queue_snd_id );
99 result = action_enter_mode( &TC, queue_snd_id );
100 close_action( &TC, result, queue_snd_id );
100 close_action( &TC, result, queue_snd_id );
101 break;
101 break;
102 case TC_SUBTYPE_UPDT_INFO:
102 case TC_SUBTYPE_UPDT_INFO:
103 result = action_update_info( &TC, queue_snd_id );
103 result = action_update_info( &TC, queue_snd_id );
104 close_action( &TC, result, queue_snd_id );
104 close_action( &TC, result, queue_snd_id );
105 break;
105 break;
106 case TC_SUBTYPE_EN_CAL:
106 case TC_SUBTYPE_EN_CAL:
107 result = action_enable_calibration( &TC, queue_snd_id, time );
107 result = action_enable_calibration( &TC, queue_snd_id, time );
108 close_action( &TC, result, queue_snd_id );
108 close_action( &TC, result, queue_snd_id );
109 break;
109 break;
110 case TC_SUBTYPE_DIS_CAL:
110 case TC_SUBTYPE_DIS_CAL:
111 result = action_disable_calibration( &TC, queue_snd_id, time );
111 result = action_disable_calibration( &TC, queue_snd_id, time );
112 close_action( &TC, result, queue_snd_id );
112 close_action( &TC, result, queue_snd_id );
113 break;
113 break;
114 case TC_SUBTYPE_LOAD_K:
114 case TC_SUBTYPE_LOAD_K:
115 printf("TC_SUBTYPE_LOAD_K\n");
116 result = action_load_kcoefficients( &TC, queue_snd_id, time );
115 result = action_load_kcoefficients( &TC, queue_snd_id, time );
117 close_action( &TC, result, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
118 break;
117 break;
119 case TC_SUBTYPE_DUMP_K:
118 case TC_SUBTYPE_DUMP_K:
120 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
119 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
121 close_action( &TC, result, queue_snd_id );
120 close_action( &TC, result, queue_snd_id );
122 break;
121 break;
123 case TC_SUBTYPE_LOAD_FBINS:
122 case TC_SUBTYPE_LOAD_FBINS:
124 result = action_load_fbins_mask( &TC, queue_snd_id, time );
123 result = action_load_fbins_mask( &TC, queue_snd_id, time );
125 close_action( &TC, result, queue_snd_id );
124 close_action( &TC, result, queue_snd_id );
126 break;
125 break;
127 case TC_SUBTYPE_UPDT_TIME:
126 case TC_SUBTYPE_UPDT_TIME:
128 result = action_update_time( &TC );
127 result = action_update_time( &TC );
129 close_action( &TC, result, queue_snd_id );
128 close_action( &TC, result, queue_snd_id );
130 break;
129 break;
131 default:
130 default:
132 break;
131 break;
133 }
132 }
134 }
133 }
135 }
134 }
136 }
135 }
137
136
138 //***********
137 //***********
139 // TC ACTIONS
138 // TC ACTIONS
140
139
141 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
142 {
141 {
143 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
144 *
143 *
145 * @param TC points to the TeleCommand packet that is being processed
144 * @param TC points to the TeleCommand packet that is being processed
146 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
147 *
146 *
148 */
147 */
149
148
150 printf("this is the end!!!\n");
149 printf("this is the end!!!\n");
151 exit(0);
150 exit(0);
152 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
151 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
153 return LFR_DEFAULT;
152 return LFR_DEFAULT;
154 }
153 }
155
154
156 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
155 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
157 {
156 {
158 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
157 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
159 *
158 *
160 * @param TC points to the TeleCommand packet that is being processed
159 * @param TC points to the TeleCommand packet that is being processed
161 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
160 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
162 *
161 *
163 */
162 */
164
163
165 rtems_status_code status;
164 rtems_status_code status;
166 unsigned char requestedMode;
165 unsigned char requestedMode;
167 unsigned int *transitionCoarseTime_ptr;
166 unsigned int *transitionCoarseTime_ptr;
168 unsigned int transitionCoarseTime;
167 unsigned int transitionCoarseTime;
169 unsigned char * bytePosPtr;
168 unsigned char * bytePosPtr;
170
169
171 bytePosPtr = (unsigned char *) &TC->packetID;
170 bytePosPtr = (unsigned char *) &TC->packetID;
172
171
173 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
172 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
174 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
173 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
175 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
174 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
176
175
177 status = check_mode_value( requestedMode );
176 status = check_mode_value( requestedMode );
178
177
179 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
178 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
180 {
179 {
181 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
180 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
182 }
181 }
183 else // the mode value is consistent, check the transition
182 else // the mode value is consistent, check the transition
184 {
183 {
185 status = check_mode_transition(requestedMode);
184 status = check_mode_transition(requestedMode);
186 if (status != LFR_SUCCESSFUL)
185 if (status != LFR_SUCCESSFUL)
187 {
186 {
188 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
187 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
189 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
188 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
190 }
189 }
191 }
190 }
192
191
193 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
192 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
194 {
193 {
195 status = check_transition_date( transitionCoarseTime );
194 status = check_transition_date( transitionCoarseTime );
196 if (status != LFR_SUCCESSFUL)
195 if (status != LFR_SUCCESSFUL)
197 {
196 {
198 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
197 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
199 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
198 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
200 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
199 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
201 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
200 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
202 }
201 }
203 }
202 }
204
203
205 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
204 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
206 {
205 {
207 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
206 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
208 status = enter_mode( requestedMode, transitionCoarseTime );
207 status = enter_mode( requestedMode, transitionCoarseTime );
209 }
208 }
210
209
211 return status;
210 return status;
212 }
211 }
213
212
214 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
213 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
215 {
214 {
216 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
215 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
217 *
216 *
218 * @param TC points to the TeleCommand packet that is being processed
217 * @param TC points to the TeleCommand packet that is being processed
219 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
218 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
220 *
219 *
221 * @return LFR directive status code:
220 * @return LFR directive status code:
222 * - LFR_DEFAULT
221 * - LFR_DEFAULT
223 * - LFR_SUCCESSFUL
222 * - LFR_SUCCESSFUL
224 *
223 *
225 */
224 */
226
225
227 unsigned int val;
226 unsigned int val;
228 int result;
227 int result;
229 unsigned int status;
228 unsigned int status;
230 unsigned char mode;
229 unsigned char mode;
231 unsigned char * bytePosPtr;
230 unsigned char * bytePosPtr;
232
231
233 bytePosPtr = (unsigned char *) &TC->packetID;
232 bytePosPtr = (unsigned char *) &TC->packetID;
234
233
235 // check LFR mode
234 // check LFR mode
236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
235 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
237 status = check_update_info_hk_lfr_mode( mode );
236 status = check_update_info_hk_lfr_mode( mode );
238 if (status == LFR_SUCCESSFUL) // check TDS mode
237 if (status == LFR_SUCCESSFUL) // check TDS mode
239 {
238 {
240 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
239 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
241 status = check_update_info_hk_tds_mode( mode );
240 status = check_update_info_hk_tds_mode( mode );
242 }
241 }
243 if (status == LFR_SUCCESSFUL) // check THR mode
242 if (status == LFR_SUCCESSFUL) // check THR mode
244 {
243 {
245 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
244 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
246 status = check_update_info_hk_thr_mode( mode );
245 status = check_update_info_hk_thr_mode( mode );
247 }
246 }
248 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
247 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
249 {
248 {
250 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
249 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
251 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
250 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
252 val++;
251 val++;
253 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
252 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
254 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
253 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
255 }
254 }
256
255
257 result = status;
256 result = status;
258
257
259 return result;
258 return result;
260 }
259 }
261
260
262 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
261 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
263 {
262 {
264 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
263 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
265 *
264 *
266 * @param TC points to the TeleCommand packet that is being processed
265 * @param TC points to the TeleCommand packet that is being processed
267 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
266 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
268 *
267 *
269 */
268 */
270
269
271 int result;
270 int result;
272
271
273 result = LFR_DEFAULT;
272 result = LFR_DEFAULT;
274
273
275 setCalibration( true );
274 setCalibration( true );
276
275
277 result = LFR_SUCCESSFUL;
276 result = LFR_SUCCESSFUL;
278
277
279 return result;
278 return result;
280 }
279 }
281
280
282 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
281 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
283 {
282 {
284 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
283 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
285 *
284 *
286 * @param TC points to the TeleCommand packet that is being processed
285 * @param TC points to the TeleCommand packet that is being processed
287 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
286 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
288 *
287 *
289 */
288 */
290
289
291 int result;
290 int result;
292
291
293 result = LFR_DEFAULT;
292 result = LFR_DEFAULT;
294
293
295 setCalibration( false );
294 setCalibration( false );
296
295
297 result = LFR_SUCCESSFUL;
296 result = LFR_SUCCESSFUL;
298
297
299 return result;
298 return result;
300 }
299 }
301
300
302 int action_update_time(ccsdsTelecommandPacket_t *TC)
301 int action_update_time(ccsdsTelecommandPacket_t *TC)
303 {
302 {
304 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
303 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
305 *
304 *
306 * @param TC points to the TeleCommand packet that is being processed
305 * @param TC points to the TeleCommand packet that is being processed
307 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
306 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
308 *
307 *
309 * @return LFR_SUCCESSFUL
308 * @return LFR_SUCCESSFUL
310 *
309 *
311 */
310 */
312
311
313 unsigned int val;
312 unsigned int val;
314
313
315 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
314 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
316 + (TC->dataAndCRC[1] << 16)
315 + (TC->dataAndCRC[1] << 16)
317 + (TC->dataAndCRC[2] << 8)
316 + (TC->dataAndCRC[2] << 8)
318 + TC->dataAndCRC[3];
317 + TC->dataAndCRC[3];
319
318
320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
319 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
320 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
322 val++;
321 val++;
323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
322 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
323 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
325
324
326 return LFR_SUCCESSFUL;
325 return LFR_SUCCESSFUL;
327 }
326 }
328
327
329 //*******************
328 //*******************
330 // ENTERING THE MODES
329 // ENTERING THE MODES
331 int check_mode_value( unsigned char requestedMode )
330 int check_mode_value( unsigned char requestedMode )
332 {
331 {
333 int status;
332 int status;
334
333
335 if ( (requestedMode != LFR_MODE_STANDBY)
334 if ( (requestedMode != LFR_MODE_STANDBY)
336 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
335 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
337 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
336 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
338 {
337 {
339 status = LFR_DEFAULT;
338 status = LFR_DEFAULT;
340 }
339 }
341 else
340 else
342 {
341 {
343 status = LFR_SUCCESSFUL;
342 status = LFR_SUCCESSFUL;
344 }
343 }
345
344
346 return status;
345 return status;
347 }
346 }
348
347
349 int check_mode_transition( unsigned char requestedMode )
348 int check_mode_transition( unsigned char requestedMode )
350 {
349 {
351 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
350 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
352 *
351 *
353 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
352 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
354 *
353 *
355 * @return LFR directive status codes:
354 * @return LFR directive status codes:
356 * - LFR_SUCCESSFUL - the transition is authorized
355 * - LFR_SUCCESSFUL - the transition is authorized
357 * - LFR_DEFAULT - the transition is not authorized
356 * - LFR_DEFAULT - the transition is not authorized
358 *
357 *
359 */
358 */
360
359
361 int status;
360 int status;
362
361
363 switch (requestedMode)
362 switch (requestedMode)
364 {
363 {
365 case LFR_MODE_STANDBY:
364 case LFR_MODE_STANDBY:
366 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
365 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
367 status = LFR_DEFAULT;
366 status = LFR_DEFAULT;
368 }
367 }
369 else
368 else
370 {
369 {
371 status = LFR_SUCCESSFUL;
370 status = LFR_SUCCESSFUL;
372 }
371 }
373 break;
372 break;
374 case LFR_MODE_NORMAL:
373 case LFR_MODE_NORMAL:
375 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
374 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
376 status = LFR_DEFAULT;
375 status = LFR_DEFAULT;
377 }
376 }
378 else {
377 else {
379 status = LFR_SUCCESSFUL;
378 status = LFR_SUCCESSFUL;
380 }
379 }
381 break;
380 break;
382 case LFR_MODE_BURST:
381 case LFR_MODE_BURST:
383 if ( lfrCurrentMode == LFR_MODE_BURST ) {
382 if ( lfrCurrentMode == LFR_MODE_BURST ) {
384 status = LFR_DEFAULT;
383 status = LFR_DEFAULT;
385 }
384 }
386 else {
385 else {
387 status = LFR_SUCCESSFUL;
386 status = LFR_SUCCESSFUL;
388 }
387 }
389 break;
388 break;
390 case LFR_MODE_SBM1:
389 case LFR_MODE_SBM1:
391 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
390 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
392 status = LFR_DEFAULT;
391 status = LFR_DEFAULT;
393 }
392 }
394 else {
393 else {
395 status = LFR_SUCCESSFUL;
394 status = LFR_SUCCESSFUL;
396 }
395 }
397 break;
396 break;
398 case LFR_MODE_SBM2:
397 case LFR_MODE_SBM2:
399 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
398 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
400 status = LFR_DEFAULT;
399 status = LFR_DEFAULT;
401 }
400 }
402 else {
401 else {
403 status = LFR_SUCCESSFUL;
402 status = LFR_SUCCESSFUL;
404 }
403 }
405 break;
404 break;
406 default:
405 default:
407 status = LFR_DEFAULT;
406 status = LFR_DEFAULT;
408 break;
407 break;
409 }
408 }
410
409
411 return status;
410 return status;
412 }
411 }
413
412
414 int check_transition_date( unsigned int transitionCoarseTime )
413 int check_transition_date( unsigned int transitionCoarseTime )
415 {
414 {
416 int status;
415 int status;
417 unsigned int localCoarseTime;
416 unsigned int localCoarseTime;
418 unsigned int deltaCoarseTime;
417 unsigned int deltaCoarseTime;
419
418
420 status = LFR_SUCCESSFUL;
419 status = LFR_SUCCESSFUL;
421
420
422 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
421 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
423 {
422 {
424 status = LFR_SUCCESSFUL;
423 status = LFR_SUCCESSFUL;
425 }
424 }
426 else
425 else
427 {
426 {
428 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
427 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
429
428
430 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime)
429 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime)
431
430
432 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
433 {
432 {
434 status = LFR_DEFAULT;
433 status = LFR_DEFAULT;
435 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n")
434 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n")
436 }
435 }
437
436
438 if (status == LFR_SUCCESSFUL)
437 if (status == LFR_SUCCESSFUL)
439 {
438 {
440 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
441 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
442 {
441 {
443 status = LFR_DEFAULT;
442 status = LFR_DEFAULT;
444 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
445 }
444 }
446 }
445 }
447 }
446 }
448
447
449 return status;
448 return status;
450 }
449 }
451
450
452 int stop_current_mode( void )
451 int stop_current_mode( void )
453 {
452 {
454 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
455 *
454 *
456 * @return RTEMS directive status codes:
455 * @return RTEMS directive status codes:
457 * - RTEMS_SUCCESSFUL - task restarted successfully
456 * - RTEMS_SUCCESSFUL - task restarted successfully
458 * - RTEMS_INVALID_ID - task id invalid
457 * - RTEMS_INVALID_ID - task id invalid
459 * - RTEMS_ALREADY_SUSPENDED - task already suspended
458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
460 *
459 *
461 */
460 */
462
461
463 rtems_status_code status;
462 rtems_status_code status;
464
463
465 status = RTEMS_SUCCESSFUL;
464 status = RTEMS_SUCCESSFUL;
466
465
467 // (1) mask interruptions
466 // (1) mask interruptions
468 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
469 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
470
469
471 // (2) reset waveform picker registers
470 // (2) reset waveform picker registers
472 reset_wfp_burst_enable(); // reset burst and enable bits
471 reset_wfp_burst_enable(); // reset burst and enable bits
473 reset_wfp_status(); // reset all the status bits
472 reset_wfp_status(); // reset all the status bits
474
473
475 // (3) reset spectral matrices registers
474 // (3) reset spectral matrices registers
476 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
475 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
477 reset_sm_status();
476 reset_sm_status();
478
477
479 // reset lfr VHDL module
478 // reset lfr VHDL module
480 reset_lfr();
479 reset_lfr();
481
480
482 reset_extractSWF(); // reset the extractSWF flag to false
481 reset_extractSWF(); // reset the extractSWF flag to false
483
482
484 // (4) clear interruptions
483 // (4) clear interruptions
485 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
484 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
486 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
485 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
487
486
488 // <Spectral Matrices simulator>
487 // <Spectral Matrices simulator>
489 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
488 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
490 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
489 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
491 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
490 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
492 // </Spectral Matrices simulator>
491 // </Spectral Matrices simulator>
493
492
494 // suspend several tasks
493 // suspend several tasks
495 if (lfrCurrentMode != LFR_MODE_STANDBY) {
494 if (lfrCurrentMode != LFR_MODE_STANDBY) {
496 status = suspend_science_tasks();
495 status = suspend_science_tasks();
497 }
496 }
498
497
499 if (status != RTEMS_SUCCESSFUL)
498 if (status != RTEMS_SUCCESSFUL)
500 {
499 {
501 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
500 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
502 }
501 }
503
502
504 return status;
503 return status;
505 }
504 }
506
505
507 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
506 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
508 {
507 {
509 /** This function is launched after a mode transition validation.
508 /** This function is launched after a mode transition validation.
510 *
509 *
511 * @param mode is the mode in which LFR will be put.
510 * @param mode is the mode in which LFR will be put.
512 *
511 *
513 * @return RTEMS directive status codes:
512 * @return RTEMS directive status codes:
514 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
513 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
515 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
514 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
516 *
515 *
517 */
516 */
518
517
519 rtems_status_code status;
518 rtems_status_code status;
520
519
521 //**********************
520 //**********************
522 // STOP THE CURRENT MODE
521 // STOP THE CURRENT MODE
523 status = stop_current_mode();
522 status = stop_current_mode();
524 if (status != RTEMS_SUCCESSFUL)
523 if (status != RTEMS_SUCCESSFUL)
525 {
524 {
526 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
525 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
527 }
526 }
528
527
529 //*************************
528 //*************************
530 // ENTER THE REQUESTED MODE
529 // ENTER THE REQUESTED MODE
531 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
530 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
532 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
531 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
533 {
532 {
534 #ifdef PRINT_TASK_STATISTICS
533 #ifdef PRINT_TASK_STATISTICS
535 rtems_cpu_usage_reset();
534 rtems_cpu_usage_reset();
536 #endif
535 #endif
537 status = restart_science_tasks( mode );
536 status = restart_science_tasks( mode );
538 launch_spectral_matrix( );
537 launch_spectral_matrix( );
539 launch_waveform_picker( mode, transitionCoarseTime );
538 launch_waveform_picker( mode, transitionCoarseTime );
540 // launch_spectral_matrix_simu( );
539 // launch_spectral_matrix_simu( );
541 }
540 }
542 else if ( mode == LFR_MODE_STANDBY )
541 else if ( mode == LFR_MODE_STANDBY )
543 {
542 {
544 #ifdef PRINT_TASK_STATISTICS
543 #ifdef PRINT_TASK_STATISTICS
545 rtems_cpu_usage_report();
544 rtems_cpu_usage_report();
546 #endif
545 #endif
547
546
548 #ifdef PRINT_STACK_REPORT
547 #ifdef PRINT_STACK_REPORT
549 PRINTF("stack report selected\n")
548 PRINTF("stack report selected\n")
550 rtems_stack_checker_report_usage();
549 rtems_stack_checker_report_usage();
551 #endif
550 #endif
552 }
551 }
553 else
552 else
554 {
553 {
555 status = RTEMS_UNSATISFIED;
554 status = RTEMS_UNSATISFIED;
556 }
555 }
557
556
558 if (status != RTEMS_SUCCESSFUL)
557 if (status != RTEMS_SUCCESSFUL)
559 {
558 {
560 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
559 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
561 status = RTEMS_UNSATISFIED;
560 status = RTEMS_UNSATISFIED;
562 }
561 }
563
562
564 return status;
563 return status;
565 }
564 }
566
565
567 int restart_science_tasks(unsigned char lfrRequestedMode )
566 int restart_science_tasks(unsigned char lfrRequestedMode )
568 {
567 {
569 /** This function is used to restart all science tasks.
568 /** This function is used to restart all science tasks.
570 *
569 *
571 * @return RTEMS directive status codes:
570 * @return RTEMS directive status codes:
572 * - RTEMS_SUCCESSFUL - task restarted successfully
571 * - RTEMS_SUCCESSFUL - task restarted successfully
573 * - RTEMS_INVALID_ID - task id invalid
572 * - RTEMS_INVALID_ID - task id invalid
574 * - RTEMS_INCORRECT_STATE - task never started
573 * - RTEMS_INCORRECT_STATE - task never started
575 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
574 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
576 *
575 *
577 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
576 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
578 *
577 *
579 */
578 */
580
579
581 rtems_status_code status[10];
580 rtems_status_code status[10];
582 rtems_status_code ret;
581 rtems_status_code ret;
583
582
584 ret = RTEMS_SUCCESSFUL;
583 ret = RTEMS_SUCCESSFUL;
585
584
586 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
585 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
587 if (status[0] != RTEMS_SUCCESSFUL)
586 if (status[0] != RTEMS_SUCCESSFUL)
588 {
587 {
589 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
588 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
590 }
589 }
591
590
592 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
591 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
593 if (status[1] != RTEMS_SUCCESSFUL)
592 if (status[1] != RTEMS_SUCCESSFUL)
594 {
593 {
595 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
594 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
596 }
595 }
597
596
598 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
597 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
599 if (status[2] != RTEMS_SUCCESSFUL)
598 if (status[2] != RTEMS_SUCCESSFUL)
600 {
599 {
601 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
600 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
602 }
601 }
603
602
604 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
603 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
605 if (status[3] != RTEMS_SUCCESSFUL)
604 if (status[3] != RTEMS_SUCCESSFUL)
606 {
605 {
607 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
606 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
608 }
607 }
609
608
610 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
609 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
611 if (status[4] != RTEMS_SUCCESSFUL)
610 if (status[4] != RTEMS_SUCCESSFUL)
612 {
611 {
613 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
612 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
614 }
613 }
615
614
616 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
615 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
617 if (status[5] != RTEMS_SUCCESSFUL)
616 if (status[5] != RTEMS_SUCCESSFUL)
618 {
617 {
619 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
618 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
620 }
619 }
621
620
622 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
621 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
623 if (status[6] != RTEMS_SUCCESSFUL)
622 if (status[6] != RTEMS_SUCCESSFUL)
624 {
623 {
625 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
624 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
626 }
625 }
627
626
628 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
627 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
629 if (status[7] != RTEMS_SUCCESSFUL)
628 if (status[7] != RTEMS_SUCCESSFUL)
630 {
629 {
631 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
630 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
632 }
631 }
633
632
634 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
633 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
635 if (status[8] != RTEMS_SUCCESSFUL)
634 if (status[8] != RTEMS_SUCCESSFUL)
636 {
635 {
637 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
636 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
638 }
637 }
639
638
640 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
639 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
641 if (status[9] != RTEMS_SUCCESSFUL)
640 if (status[9] != RTEMS_SUCCESSFUL)
642 {
641 {
643 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
642 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
644 }
643 }
645
644
646 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
645 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
647 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
646 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
648 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
647 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
649 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
648 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
650 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
649 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
651 {
650 {
652 ret = RTEMS_UNSATISFIED;
651 ret = RTEMS_UNSATISFIED;
653 }
652 }
654
653
655 return ret;
654 return ret;
656 }
655 }
657
656
658 int suspend_science_tasks()
657 int suspend_science_tasks()
659 {
658 {
660 /** This function suspends the science tasks.
659 /** This function suspends the science tasks.
661 *
660 *
662 * @return RTEMS directive status codes:
661 * @return RTEMS directive status codes:
663 * - RTEMS_SUCCESSFUL - task restarted successfully
662 * - RTEMS_SUCCESSFUL - task restarted successfully
664 * - RTEMS_INVALID_ID - task id invalid
663 * - RTEMS_INVALID_ID - task id invalid
665 * - RTEMS_ALREADY_SUSPENDED - task already suspended
664 * - RTEMS_ALREADY_SUSPENDED - task already suspended
666 *
665 *
667 */
666 */
668
667
669 rtems_status_code status;
668 rtems_status_code status;
670
669
671 printf("in suspend_science_tasks\n");
670 printf("in suspend_science_tasks\n");
672
671
673 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
672 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
674 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
673 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
675 {
674 {
676 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
675 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
677 }
676 }
678 else
677 else
679 {
678 {
680 status = RTEMS_SUCCESSFUL;
679 status = RTEMS_SUCCESSFUL;
681 }
680 }
682 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
681 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
683 {
682 {
684 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
683 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
685 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
684 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
686 {
685 {
687 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
686 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
688 }
687 }
689 else
688 else
690 {
689 {
691 status = RTEMS_SUCCESSFUL;
690 status = RTEMS_SUCCESSFUL;
692 }
691 }
693 }
692 }
694 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
693 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
695 {
694 {
696 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
695 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
697 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
696 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
698 {
697 {
699 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
698 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
700 }
699 }
701 else
700 else
702 {
701 {
703 status = RTEMS_SUCCESSFUL;
702 status = RTEMS_SUCCESSFUL;
704 }
703 }
705 }
704 }
706 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
705 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
707 {
706 {
708 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
707 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
709 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
708 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
710 {
709 {
711 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
710 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
712 }
711 }
713 else
712 else
714 {
713 {
715 status = RTEMS_SUCCESSFUL;
714 status = RTEMS_SUCCESSFUL;
716 }
715 }
717 }
716 }
718 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
717 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
719 {
718 {
720 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
719 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
721 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
720 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
722 {
721 {
723 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
722 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
724 }
723 }
725 else
724 else
726 {
725 {
727 status = RTEMS_SUCCESSFUL;
726 status = RTEMS_SUCCESSFUL;
728 }
727 }
729 }
728 }
730 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
729 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
731 {
730 {
732 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
731 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
733 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
732 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
734 {
733 {
735 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
734 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
736 }
735 }
737 else
736 else
738 {
737 {
739 status = RTEMS_SUCCESSFUL;
738 status = RTEMS_SUCCESSFUL;
740 }
739 }
741 }
740 }
742 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
741 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
743 {
742 {
744 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
743 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
745 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
744 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
746 {
745 {
747 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
746 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
748 }
747 }
749 else
748 else
750 {
749 {
751 status = RTEMS_SUCCESSFUL;
750 status = RTEMS_SUCCESSFUL;
752 }
751 }
753 }
752 }
754 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
753 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
755 {
754 {
756 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
755 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
757 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
756 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
758 {
757 {
759 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
758 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
760 }
759 }
761 else
760 else
762 {
761 {
763 status = RTEMS_SUCCESSFUL;
762 status = RTEMS_SUCCESSFUL;
764 }
763 }
765 }
764 }
766 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
765 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
767 {
766 {
768 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
767 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
769 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
768 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
770 {
769 {
771 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
770 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
772 }
771 }
773 else
772 else
774 {
773 {
775 status = RTEMS_SUCCESSFUL;
774 status = RTEMS_SUCCESSFUL;
776 }
775 }
777 }
776 }
778 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
777 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
779 {
778 {
780 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
779 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
781 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
780 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
782 {
781 {
783 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
782 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
784 }
783 }
785 else
784 else
786 {
785 {
787 status = RTEMS_SUCCESSFUL;
786 status = RTEMS_SUCCESSFUL;
788 }
787 }
789 }
788 }
790
789
791 return status;
790 return status;
792 }
791 }
793
792
794 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
793 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
795 {
794 {
796 WFP_reset_current_ring_nodes();
795 WFP_reset_current_ring_nodes();
797
796
798 reset_waveform_picker_regs();
797 reset_waveform_picker_regs();
799
798
800 set_wfp_burst_enable_register( mode );
799 set_wfp_burst_enable_register( mode );
801
800
802 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
801 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
803 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
802 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
804
803
805 if (transitionCoarseTime == 0)
804 if (transitionCoarseTime == 0)
806 {
805 {
807 waveform_picker_regs->start_date = time_management_regs->coarse_time;
806 waveform_picker_regs->start_date = time_management_regs->coarse_time;
808 }
807 }
809 else
808 else
810 {
809 {
811 waveform_picker_regs->start_date = transitionCoarseTime;
810 waveform_picker_regs->start_date = transitionCoarseTime;
812 }
811 }
813
812
814 }
813 }
815
814
816 void launch_spectral_matrix( void )
815 void launch_spectral_matrix( void )
817 {
816 {
818 SM_reset_current_ring_nodes();
817 SM_reset_current_ring_nodes();
819
818
820 reset_spectral_matrix_regs();
819 reset_spectral_matrix_regs();
821
820
822 reset_nb_sm();
821 reset_nb_sm();
823
822
824 set_sm_irq_onNewMatrix( 1 );
823 set_sm_irq_onNewMatrix( 1 );
825
824
826 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
825 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
827 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
826 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
828
827
829 }
828 }
830
829
831 void launch_spectral_matrix_simu( void )
830 void launch_spectral_matrix_simu( void )
832 {
831 {
833 SM_reset_current_ring_nodes();
832 SM_reset_current_ring_nodes();
834 reset_spectral_matrix_regs();
833 reset_spectral_matrix_regs();
835 reset_nb_sm();
834 reset_nb_sm();
836
835
837 // Spectral Matrices simulator
836 // Spectral Matrices simulator
838 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
837 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
839 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
838 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
840 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
839 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
841 }
840 }
842
841
843 void set_sm_irq_onNewMatrix( unsigned char value )
842 void set_sm_irq_onNewMatrix( unsigned char value )
844 {
843 {
845 if (value == 1)
844 if (value == 1)
846 {
845 {
847 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
846 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
848 }
847 }
849 else
848 else
850 {
849 {
851 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
850 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
852 }
851 }
853 }
852 }
854
853
855 void set_sm_irq_onError( unsigned char value )
854 void set_sm_irq_onError( unsigned char value )
856 {
855 {
857 if (value == 1)
856 if (value == 1)
858 {
857 {
859 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
858 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
860 }
859 }
861 else
860 else
862 {
861 {
863 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
862 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
864 }
863 }
865 }
864 }
866
865
867 //*****************************
866 //*****************************
868 // CONFIGURE CALIBRATION SIGNAL
867 // CONFIGURE CALIBRATION SIGNAL
869 void setCalibrationPrescaler( unsigned int prescaler )
868 void setCalibrationPrescaler( unsigned int prescaler )
870 {
869 {
871 // prescaling of the master clock (25 MHz)
870 // prescaling of the master clock (25 MHz)
872 // master clock is divided by 2^prescaler
871 // master clock is divided by 2^prescaler
873 time_management_regs->calPrescaler = prescaler;
872 time_management_regs->calPrescaler = prescaler;
874 }
873 }
875
874
876 void setCalibrationDivisor( unsigned int divisionFactor )
875 void setCalibrationDivisor( unsigned int divisionFactor )
877 {
876 {
878 // division of the prescaled clock by the division factor
877 // division of the prescaled clock by the division factor
879 time_management_regs->calDivisor = divisionFactor;
878 time_management_regs->calDivisor = divisionFactor;
880 }
879 }
881
880
882 void setCalibrationData( void ){
881 void setCalibrationData( void ){
883 unsigned int k;
882 unsigned int k;
884 unsigned short data;
883 unsigned short data;
885 float val;
884 float val;
886 float f0;
885 float f0;
887 float f1;
886 float f1;
888 float fs;
887 float fs;
889 float Ts;
888 float Ts;
890 float scaleFactor;
889 float scaleFactor;
891
890
892 f0 = 625;
891 f0 = 625;
893 f1 = 10000;
892 f1 = 10000;
894 fs = 160256.410;
893 fs = 160256.410;
895 Ts = 1. / fs;
894 Ts = 1. / fs;
896 scaleFactor = 0.125 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 250 mVpp each, amplitude = 125 mV
895 scaleFactor = 0.125 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 250 mVpp each, amplitude = 125 mV
897
896
898 time_management_regs->calDataPtr = 0x00;
897 time_management_regs->calDataPtr = 0x00;
899
898
900 // build the signal for the SCM calibration
899 // build the signal for the SCM calibration
901 for (k=0; k<256; k++)
900 for (k=0; k<256; k++)
902 {
901 {
903 val = sin( 2 * pi * f0 * k * Ts )
902 val = sin( 2 * pi * f0 * k * Ts )
904 + sin( 2 * pi * f1 * k * Ts );
903 + sin( 2 * pi * f1 * k * Ts );
905 data = (unsigned short) ((val * scaleFactor) + 2048);
904 data = (unsigned short) ((val * scaleFactor) + 2048);
906 time_management_regs->calData = data & 0xfff;
905 time_management_regs->calData = data & 0xfff;
907 }
906 }
908 }
907 }
909
908
910 void setCalibrationDataInterleaved( void ){
909 void setCalibrationDataInterleaved( void ){
911 unsigned int k;
910 unsigned int k;
912 float val;
911 float val;
913 float f0;
912 float f0;
914 float f1;
913 float f1;
915 float fs;
914 float fs;
916 float Ts;
915 float Ts;
917 unsigned short data[384];
916 unsigned short data[384];
918 unsigned char *dataPtr;
917 unsigned char *dataPtr;
919
918
920 f0 = 625;
919 f0 = 625;
921 f1 = 10000;
920 f1 = 10000;
922 fs = 240384.615;
921 fs = 240384.615;
923 Ts = 1. / fs;
922 Ts = 1. / fs;
924
923
925 time_management_regs->calDataPtr = 0x00;
924 time_management_regs->calDataPtr = 0x00;
926
925
927 // build the signal for the SCM calibration
926 // build the signal for the SCM calibration
928 for (k=0; k<384; k++)
927 for (k=0; k<384; k++)
929 {
928 {
930 val = sin( 2 * pi * f0 * k * Ts )
929 val = sin( 2 * pi * f0 * k * Ts )
931 + sin( 2 * pi * f1 * k * Ts );
930 + sin( 2 * pi * f1 * k * Ts );
932 data[k] = (unsigned short) (val * 512 + 2048);
931 data[k] = (unsigned short) (val * 512 + 2048);
933 }
932 }
934
933
935 // write the signal in interleaved mode
934 // write the signal in interleaved mode
936 for (k=0; k<128; k++)
935 for (k=0; k<128; k++)
937 {
936 {
938 dataPtr = (unsigned char*) &data[k*3 + 2];
937 dataPtr = (unsigned char*) &data[k*3 + 2];
939 time_management_regs->calData = (data[k*3] & 0xfff)
938 time_management_regs->calData = (data[k*3] & 0xfff)
940 + ( (dataPtr[0] & 0x3f) << 12);
939 + ( (dataPtr[0] & 0x3f) << 12);
941 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
940 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
942 + ( (dataPtr[1] & 0x3f) << 12);
941 + ( (dataPtr[1] & 0x3f) << 12);
943 }
942 }
944 }
943 }
945
944
946 void setCalibrationReload( bool state)
945 void setCalibrationReload( bool state)
947 {
946 {
948 if (state == true)
947 if (state == true)
949 {
948 {
950 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
949 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
951 }
950 }
952 else
951 else
953 {
952 {
954 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
953 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
955 }
954 }
956 }
955 }
957
956
958 void setCalibrationEnable( bool state )
957 void setCalibrationEnable( bool state )
959 {
958 {
960 // this bit drives the multiplexer
959 // this bit drives the multiplexer
961 if (state == true)
960 if (state == true)
962 {
961 {
963 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
962 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
964 }
963 }
965 else
964 else
966 {
965 {
967 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
966 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
968 }
967 }
969 }
968 }
970
969
971 void setCalibrationInterleaved( bool state )
970 void setCalibrationInterleaved( bool state )
972 {
971 {
973 // this bit drives the multiplexer
972 // this bit drives the multiplexer
974 if (state == true)
973 if (state == true)
975 {
974 {
976 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
975 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
977 }
976 }
978 else
977 else
979 {
978 {
980 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
979 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
981 }
980 }
982 }
981 }
983
982
984 void setCalibration( bool state )
983 void setCalibration( bool state )
985 {
984 {
986 if (state == true)
985 if (state == true)
987 {
986 {
988 setCalibrationEnable( true );
987 setCalibrationEnable( true );
989 setCalibrationReload( false );
988 setCalibrationReload( false );
990 set_hk_lfr_calib_enable( true );
989 set_hk_lfr_calib_enable( true );
991 }
990 }
992 else
991 else
993 {
992 {
994 setCalibrationEnable( false );
993 setCalibrationEnable( false );
995 setCalibrationReload( true );
994 setCalibrationReload( true );
996 set_hk_lfr_calib_enable( false );
995 set_hk_lfr_calib_enable( false );
997 }
996 }
998 }
997 }
999
998
1000 void set_hk_lfr_calib_enable( bool state )
999 void set_hk_lfr_calib_enable( bool state )
1001 {
1000 {
1002 if (state == true)
1001 if (state == true)
1003 {
1002 {
1004 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000]
1003 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000]
1005 }
1004 }
1006 else
1005 else
1007 {
1006 {
1008 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111]
1007 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111]
1009 }
1008 }
1010 }
1009 }
1011
1010
1012 void configureCalibration( bool interleaved )
1011 void configureCalibration( bool interleaved )
1013 {
1012 {
1014 setCalibration( false );
1013 setCalibration( false );
1015 if ( interleaved == true )
1014 if ( interleaved == true )
1016 {
1015 {
1017 setCalibrationInterleaved( true );
1016 setCalibrationInterleaved( true );
1018 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1017 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1019 setCalibrationDivisor( 26 ); // => 240 384
1018 setCalibrationDivisor( 26 ); // => 240 384
1020 setCalibrationDataInterleaved();
1019 setCalibrationDataInterleaved();
1021 }
1020 }
1022 else
1021 else
1023 {
1022 {
1024 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1023 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1025 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1024 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1026 setCalibrationData();
1025 setCalibrationData();
1027 }
1026 }
1028 }
1027 }
1029
1028
1030 //****************
1029 //****************
1031 // CLOSING ACTIONS
1030 // CLOSING ACTIONS
1032 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1031 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1033 {
1032 {
1034 /** This function is used to update the HK packets statistics after a successful TC execution.
1033 /** This function is used to update the HK packets statistics after a successful TC execution.
1035 *
1034 *
1036 * @param TC points to the TC being processed
1035 * @param TC points to the TC being processed
1037 * @param time is the time used to date the TC execution
1036 * @param time is the time used to date the TC execution
1038 *
1037 *
1039 */
1038 */
1040
1039
1041 unsigned int val;
1040 unsigned int val;
1042
1041
1043 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1042 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1044 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1043 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1045 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1044 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1046 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1045 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1047 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1046 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1048 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1047 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1049 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1048 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1050 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1049 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1051 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1050 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1052 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1051 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1053 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1052 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1054 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1053 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1055
1054
1056 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1055 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1057 val++;
1056 val++;
1058 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1057 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1059 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1058 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1060 }
1059 }
1061
1060
1062 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1061 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1063 {
1062 {
1064 /** This function is used to update the HK packets statistics after a TC rejection.
1063 /** This function is used to update the HK packets statistics after a TC rejection.
1065 *
1064 *
1066 * @param TC points to the TC being processed
1065 * @param TC points to the TC being processed
1067 * @param time is the time used to date the TC rejection
1066 * @param time is the time used to date the TC rejection
1068 *
1067 *
1069 */
1068 */
1070
1069
1071 unsigned int val;
1070 unsigned int val;
1072
1071
1073 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1072 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1074 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1073 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1075 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1074 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1076 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1075 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1077 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1076 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1078 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1077 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1079 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1078 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1080 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1079 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1081 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1080 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1082 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1081 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1083 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1082 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1084 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1083 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1085
1084
1086 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1085 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1087 val++;
1086 val++;
1088 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1087 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1089 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1088 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1090 }
1089 }
1091
1090
1092 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1091 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1093 {
1092 {
1094 /** This function is the last step of the TC execution workflow.
1093 /** This function is the last step of the TC execution workflow.
1095 *
1094 *
1096 * @param TC points to the TC being processed
1095 * @param TC points to the TC being processed
1097 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1096 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1098 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1097 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1099 * @param time is the time used to date the TC execution
1098 * @param time is the time used to date the TC execution
1100 *
1099 *
1101 */
1100 */
1102
1101
1103 unsigned char requestedMode;
1102 unsigned char requestedMode;
1104
1103
1105 if (result == LFR_SUCCESSFUL)
1104 if (result == LFR_SUCCESSFUL)
1106 {
1105 {
1107 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1106 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1108 &
1107 &
1109 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1108 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1110 )
1109 )
1111 {
1110 {
1112 send_tm_lfr_tc_exe_success( TC, queue_id );
1111 send_tm_lfr_tc_exe_success( TC, queue_id );
1113 }
1112 }
1114 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1113 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1115 {
1114 {
1116 //**********************************
1115 //**********************************
1117 // UPDATE THE LFRMODE LOCAL VARIABLE
1116 // UPDATE THE LFRMODE LOCAL VARIABLE
1118 requestedMode = TC->dataAndCRC[1];
1117 requestedMode = TC->dataAndCRC[1];
1119 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1118 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1120 updateLFRCurrentMode();
1119 updateLFRCurrentMode();
1121 }
1120 }
1122 }
1121 }
1123 else if (result == LFR_EXE_ERROR)
1122 else if (result == LFR_EXE_ERROR)
1124 {
1123 {
1125 send_tm_lfr_tc_exe_error( TC, queue_id );
1124 send_tm_lfr_tc_exe_error( TC, queue_id );
1126 }
1125 }
1127 }
1126 }
1128
1127
1129 //***************************
1128 //***************************
1130 // Interrupt Service Routines
1129 // Interrupt Service Routines
1131 rtems_isr commutation_isr1( rtems_vector_number vector )
1130 rtems_isr commutation_isr1( rtems_vector_number vector )
1132 {
1131 {
1133 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1132 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1134 printf("In commutation_isr1 *** Error sending event to DUMB\n");
1133 printf("In commutation_isr1 *** Error sending event to DUMB\n");
1135 }
1134 }
1136 }
1135 }
1137
1136
1138 rtems_isr commutation_isr2( rtems_vector_number vector )
1137 rtems_isr commutation_isr2( rtems_vector_number vector )
1139 {
1138 {
1140 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1139 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1141 printf("In commutation_isr2 *** Error sending event to DUMB\n");
1140 printf("In commutation_isr2 *** Error sending event to DUMB\n");
1142 }
1141 }
1143 }
1142 }
1144
1143
1145 //****************
1144 //****************
1146 // OTHER FUNCTIONS
1145 // OTHER FUNCTIONS
1147 void updateLFRCurrentMode()
1146 void updateLFRCurrentMode()
1148 {
1147 {
1149 /** This function updates the value of the global variable lfrCurrentMode.
1148 /** This function updates the value of the global variable lfrCurrentMode.
1150 *
1149 *
1151 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1150 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1152 *
1151 *
1153 */
1152 */
1154 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1153 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1155 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
1154 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
1156 }
1155 }
1157
1156
1158 void set_lfr_soft_reset( unsigned char value )
1157 void set_lfr_soft_reset( unsigned char value )
1159 {
1158 {
1160 if (value == 1)
1159 if (value == 1)
1161 {
1160 {
1162 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1161 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1163 }
1162 }
1164 else
1163 else
1165 {
1164 {
1166 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1165 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1167 }
1166 }
1168 }
1167 }
1169
1168
1170 void reset_lfr( void )
1169 void reset_lfr( void )
1171 {
1170 {
1172 set_lfr_soft_reset( 1 );
1171 set_lfr_soft_reset( 1 );
1173
1172
1174 set_lfr_soft_reset( 0 );
1173 set_lfr_soft_reset( 0 );
1175 }
1174 }
@@ -1,1127 +1,1139
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 );
290 flag = set_sy_lfr_kcoeff( TC );
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 )
906 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC )
907 {
907 {
908 unsigned int i;
908 unsigned int i;
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 }
932 }
933 else
933 else
934 {
934 {
935 if ( ( sy_lfr_kcoeff_frequency >= 0 )
935 if ( ( sy_lfr_kcoeff_frequency >= 0 )
936 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
936 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
937 {
937 {
938 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
938 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
939 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
939 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
940 bin = sy_lfr_kcoeff_frequency;
940 bin = sy_lfr_kcoeff_frequency;
941 }
941 }
942 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
942 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
943 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
943 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
944 {
944 {
945 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
945 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
946 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
946 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
947 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
947 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
948 }
948 }
949 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
949 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
950 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
950 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
951 {
951 {
952 kcoeffPtr_norm = k_coeff_intercalib_f2;
952 kcoeffPtr_norm = k_coeff_intercalib_f2;
953 kcoeffPtr_sbm = NULL;
953 kcoeffPtr_sbm = NULL;
954 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
954 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
955 }
955 }
956 }
956 }
957
957
958 if (kcoeffPtr_norm != NULL )
958 printf("in set_sy_lfr_kcoeff *** freq = %d, bin = %d\n", sy_lfr_kcoeff_frequency, bin);
959
960 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
959 {
961 {
960 printf("freq = %d, bin = %d\n", sy_lfr_kcoeff_frequency, bin);
961 for (i=0; i<NB_K_COEFF_PER_BIN; i++)
962 for (i=0; i<NB_K_COEFF_PER_BIN; i++)
962 {
963 {
963 // destination
964 // destination
964 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + i ];
965 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + i ];
966 // source
967 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * i];
968 // copy source to destination
969 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
970 }
971 }
972
973 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
974 {
975 for (i=0; i<NB_K_COEFF_PER_BIN; i++)
976 {
977 // destination
965 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + i) * 2 ];
978 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + i) * 2 ];
966 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + i) * 2 + 1 ];
979 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + i) * 2 + 1 ];
967 // source
980 // source
968 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * i];
981 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * i];
969 // copy source to destination
982 // copy source to destination
970 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
971 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
983 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
972 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
984 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
973 }
985 }
974 }
986 }
975
987
976 return status;
988 return status;
977 }
989 }
978
990
979 void copyFloatByChar( unsigned char *destination, unsigned char *source )
991 void copyFloatByChar( unsigned char *destination, unsigned char *source )
980 {
992 {
981 destination[0] = source[0];
993 destination[0] = source[0];
982 destination[1] = source[1];
994 destination[1] = source[1];
983 destination[2] = source[2];
995 destination[2] = source[2];
984 destination[3] = source[3];
996 destination[3] = source[3];
985 }
997 }
986
998
987 //**********
999 //**********
988 // init dump
1000 // init dump
989
1001
990 void init_parameter_dump( void )
1002 void init_parameter_dump( void )
991 {
1003 {
992 /** This function initialize the parameter_dump_packet global variable with default values.
1004 /** This function initialize the parameter_dump_packet global variable with default values.
993 *
1005 *
994 */
1006 */
995
1007
996 unsigned int k;
1008 unsigned int k;
997
1009
998 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1010 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
999 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1011 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1000 parameter_dump_packet.reserved = CCSDS_RESERVED;
1012 parameter_dump_packet.reserved = CCSDS_RESERVED;
1001 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1013 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1002 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1014 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1003 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1015 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1004 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1016 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1005 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1017 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1006 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1018 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1007 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1019 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1008 // DATA FIELD HEADER
1020 // DATA FIELD HEADER
1009 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1021 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1010 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1022 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1011 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1023 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1012 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1024 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1013 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1025 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1014 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1026 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1015 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1027 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1016 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1028 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1017 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1029 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1018 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1030 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1019 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1031 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1020
1032
1021 //******************
1033 //******************
1022 // COMMON PARAMETERS
1034 // COMMON PARAMETERS
1023 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1035 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1024 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1036 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1025
1037
1026 //******************
1038 //******************
1027 // NORMAL PARAMETERS
1039 // NORMAL PARAMETERS
1028 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1040 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1029 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1041 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1030 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1042 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1031 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1043 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1032 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1044 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1033 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1045 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1034 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1046 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1035 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1047 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1036 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1048 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1037
1049
1038 //*****************
1050 //*****************
1039 // BURST PARAMETERS
1051 // BURST PARAMETERS
1040 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1052 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1041 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1053 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1042
1054
1043 //****************
1055 //****************
1044 // SBM1 PARAMETERS
1056 // SBM1 PARAMETERS
1045 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
1057 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
1046 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1058 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1047
1059
1048 //****************
1060 //****************
1049 // SBM2 PARAMETERS
1061 // SBM2 PARAMETERS
1050 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1062 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1051 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1063 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1052
1064
1053 //************
1065 //************
1054 // FBINS MASKS
1066 // FBINS MASKS
1055 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1067 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1056 {
1068 {
1057 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1069 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1058 }
1070 }
1059 }
1071 }
1060
1072
1061 void init_kcoefficients_dump( void )
1073 void init_kcoefficients_dump( void )
1062 {
1074 {
1063 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1075 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1064 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1076 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1065
1077
1066 kcoefficient_node_1.previous = NULL;
1078 kcoefficient_node_1.previous = NULL;
1067 kcoefficient_node_1.next = NULL;
1079 kcoefficient_node_1.next = NULL;
1068 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1080 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1069 kcoefficient_node_1.coarseTime = 0x00;
1081 kcoefficient_node_1.coarseTime = 0x00;
1070 kcoefficient_node_1.fineTime = 0x00;
1082 kcoefficient_node_1.fineTime = 0x00;
1071 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1083 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1072 kcoefficient_node_1.status = 0x00;
1084 kcoefficient_node_1.status = 0x00;
1073
1085
1074 kcoefficient_node_2.previous = NULL;
1086 kcoefficient_node_2.previous = NULL;
1075 kcoefficient_node_2.next = NULL;
1087 kcoefficient_node_2.next = NULL;
1076 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1088 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1077 kcoefficient_node_2.coarseTime = 0x00;
1089 kcoefficient_node_2.coarseTime = 0x00;
1078 kcoefficient_node_2.fineTime = 0x00;
1090 kcoefficient_node_2.fineTime = 0x00;
1079 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1091 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1080 kcoefficient_node_2.status = 0x00;
1092 kcoefficient_node_2.status = 0x00;
1081 }
1093 }
1082
1094
1083 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1095 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1084 {
1096 {
1085 unsigned int k;
1097 unsigned int k;
1086 unsigned int packetLength;
1098 unsigned int packetLength;
1087
1099
1088 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1100 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1089
1101
1090 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1102 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1091 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1103 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1092 kcoefficients_dump->reserved = CCSDS_RESERVED;
1104 kcoefficients_dump->reserved = CCSDS_RESERVED;
1093 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1105 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1094 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1106 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1095 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1107 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1096 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1108 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1097 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1109 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1098 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1110 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1099 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1111 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1100 // DATA FIELD HEADER
1112 // DATA FIELD HEADER
1101 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1113 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1102 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1114 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1103 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1115 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1104 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1116 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1105 kcoefficients_dump->time[0] = 0x00;
1117 kcoefficients_dump->time[0] = 0x00;
1106 kcoefficients_dump->time[1] = 0x00;
1118 kcoefficients_dump->time[1] = 0x00;
1107 kcoefficients_dump->time[2] = 0x00;
1119 kcoefficients_dump->time[2] = 0x00;
1108 kcoefficients_dump->time[3] = 0x00;
1120 kcoefficients_dump->time[3] = 0x00;
1109 kcoefficients_dump->time[4] = 0x00;
1121 kcoefficients_dump->time[4] = 0x00;
1110 kcoefficients_dump->time[5] = 0x00;
1122 kcoefficients_dump->time[5] = 0x00;
1111 kcoefficients_dump->sid = SID_K_DUMP;
1123 kcoefficients_dump->sid = SID_K_DUMP;
1112
1124
1113 kcoefficients_dump->pkt_cnt = 2;
1125 kcoefficients_dump->pkt_cnt = 2;
1114 kcoefficients_dump->pkt_nr = pkt_nr;
1126 kcoefficients_dump->pkt_nr = pkt_nr;
1115 kcoefficients_dump->blk_nr = blk_nr;
1127 kcoefficients_dump->blk_nr = blk_nr;
1116
1128
1117 //******************
1129 //******************
1118 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1130 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1119 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1131 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1120 for (k=0; k<3900; k++)
1132 for (k=0; k<3900; k++)
1121 {
1133 {
1122 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1134 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1123 }
1135 }
1124 }
1136 }
1125
1137
1126
1138
1127
1139
General Comments 0
You need to be logged in to leave comments. Login now