##// END OF EJS Templates
Corrections:...
paul -
r107:c303d2da6108 VHDLib206
parent child
Show More
@@ -0,0 +1,41
1 #ifndef TIMEGEN_INIT_H_INCLUDED
2 #define TIMEGEN_INIT_H_INCLUDED
3
4 #include <rtems.h>
5 #include <leon.h>
6
7 #include "fsw_params.h"
8 #include "fsw_misc.h"
9 #include "fsw_processing.h"
10 #include "wf_handler.h"
11
12 #include "timegen_spacewire.h"
13 #include "timegen_misc.h"
14
15 extern rtems_name Task_name[20]; /* array of task names */
16 extern rtems_id Task_id[20]; /* array of task ids */
17
18 // RTEMS TASKS
19 rtems_task Init( rtems_task_argument argument);
20
21 // OTHER functions
22 void create_names( void );
23 int create_all_tasks( void );
24 int start_all_tasks( void );
25 //
26 rtems_status_code create_message_queues( void );
27 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
28 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
29 //
30 int start_recv_send_tasks( void );
31 //
32 void init_local_mode_parameters( void );
33 void reset_local_time( void );
34
35 extern int rtems_cpu_usage_report( void );
36 extern int rtems_cpu_usage_reset( void );
37 extern void rtems_stack_checker_report_usage( void );
38
39 extern int sched_yield( void );
40
41 #endif // TIMEGEN_INIT_H_INCLUDED
@@ -0,0 +1,39
1 #ifndef TIMEGEN_MISC_H_INCLUDED
2 #define TIMEGEN_MISC_H_INCLUDED
3
4 #include <rtems.h>
5 #include <leon.h>
6
7 #include "fsw_params.h"
8 #include "TC_types.h"
9 #include "tc_acceptance.h"
10 #include "timegen_init.h"
11
12 #define TASK_PRIORITY_UPDT 40
13
14 typedef struct {
15 unsigned char targetLogicalAddress;
16 unsigned char protocolIdentifier;
17 unsigned char reserved;
18 unsigned char userApplication;
19 // PACKET HEADER
20 Packet_TC_LFR_UPDATE_TIME_t update_time;
21 } Packet_TC_LFR_UPDATE_TIME_WITH_OVERHEAD_t;
22
23 unsigned int coarseTime;
24
25 rtems_name rtems_name_updt;
26 rtems_id rtems_id_updt;
27
28 void timegen_timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
29
30 void initCoarseTime( void );
31
32 rtems_task updt_task( rtems_task_argument unused );
33
34 int send_tc_lfr_update_time( rtems_id queue_id );
35
36 #endif // TIMEGEN_MISC_H_INCLUDED
37
38
39
@@ -0,0 +1,48
1 #ifndef TIMEGEN_SPACEWIRE_H_INCLUDED
2 #define TIMEGEN_SPACEWIRE_H_INCLUDED
3
4 #include <rtems.h>
5 #include <grspw.h>
6
7 #include <fcntl.h> // for O_RDWR
8 #include <unistd.h> // for the read call
9 #include <sys/ioctl.h> // for the ioctl call
10 #include <errno.h>
11
12 #include "fsw_params.h"
13 #include "tc_acceptance.h"
14 #include "timegen_tc_handler.h"
15
16 #define DESTINATION_ID_LFR 0xfe
17 #define DESTINATION_ID_DPU 0x01
18 #define SPACEWIRE_LINK_LFR 0x01
19 #define NODEADDR_TIMEGEN 0xfd
20
21 extern rtems_id Task_id[20]; /* array of task ids */
22 extern int fdSPW;
23
24 extern spw_stats spacewire_stats;
25 extern spw_stats spacewire_stats_backup;
26
27 // RTEMS TASK
28 rtems_task spiq_task( rtems_task_argument argument );
29 rtems_task recv_task( rtems_task_argument unused );
30 rtems_task send_task( rtems_task_argument argument );
31 rtems_task wtdg_task( rtems_task_argument argument );
32
33 int spacewire_open_link( void );
34 int spacewire_start_link( int fd );
35 int spacewire_stop_start_link( int fd );
36 int spacewire_configure_link(int fd );
37 int spacewire_reset_link( void );
38 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
39 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
40 void spacewire_compute_stats_offsets( void );
41 void spacewire_update_statistics( void );
42
43 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
44 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data );
45
46 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
47
48 #endif // TIMEGEN_SPACEWIRE_H_INCLUDED
@@ -0,0 +1,56
1 #ifndef TIMEGEN_TC_HANDLER_H_INCLUDED
2 #define TIMEGEN_TC_HANDLER_H_INCLUDED
3
4 #include <rtems.h>
5 #include <leon.h>
6
7 #include "tc_load_dump_parameters.h"
8 #include "tc_acceptance.h"
9 #include "tm_lfr_tc_exe.h"
10
11 // MODE PARAMETERS
12 extern unsigned int maxCount;
13
14 //****
15 // ISR
16 rtems_isr commutation_isr1( rtems_vector_number vector );
17 rtems_isr commutation_isr2( rtems_vector_number vector );
18
19 //***********
20 // RTEMS TASK
21 rtems_task actn_task( rtems_task_argument unused );
22
23 //***********
24 // TC ACTIONS
25 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
26 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
27 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
28 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
29 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
30 int action_update_time(ccsdsTelecommandPacket_t *TC);
31
32 // mode transition
33 int transition_validation(unsigned char requestedMode);
34 int stop_current_mode( void );
35 int enter_mode(unsigned char mode);
36 int restart_science_tasks();
37 int suspend_science_tasks();
38 void launch_waveform_picker( unsigned char mode );
39 void launch_spectral_matrix( unsigned char mode );
40 void set_irq_on_new_ready_matrix(unsigned char value );
41 void set_run_matrix_spectral( unsigned char value );
42 void launch_spectral_matrix_simu( unsigned char mode );
43
44 // other functions
45 void updateLFRCurrentMode();
46 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC );
47 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC );
48 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
49
50 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
51 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
52
53 #endif // TIMEGEN_TC_HANDLER_H_INCLUDED
54
55
56
@@ -0,0 +1,476
1 /** This is the RTEMS initialization module.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
10 */
11
12 //*************************
13 // GPL reminder to be added
14 //*************************
15
16 #include <rtems.h>
17
18 /* configuration information */
19
20 #define CONFIGURE_INIT
21
22 #include <bsp.h> /* for device driver prototypes */
23
24 /* configuration information */
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
39 #ifdef PRINT_STACK_REPORT
40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #endif
42
43 #include <rtems/confdefs.h>
44
45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef LEON3
48 /* Add Timer and UART Driver */
49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #endif
52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #endif
55 #endif
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #include <drvmgr/drvmgr_confdefs.h>
58 #endif
59
60 #include "timegen_init.h"
61 #include "fsw_config.c"
62
63 rtems_task Init( rtems_task_argument ignored )
64 {
65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 *
67 * @param unused is the starting argument of the RTEMS task
68 *
69 * The INIT task create and run all other RTEMS tasks.
70 *
71 */
72
73 rtems_status_code status;
74 rtems_status_code status_spw;
75
76 // initCoarseTime();
77
78 // UART settings
79 send_console_outputs_on_apbuart_port();
80 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
81 enable_apbuart_transmitter();
82 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
83
84 PRINTF("\n\n\n\n\n")
85 PRINTF("*************************\n")
86 PRINTF("** Time Generator **\n")
87 PRINTF1("** %d.", SW_VERSION_N1)
88 PRINTF1("%d.", SW_VERSION_N2)
89 PRINTF1("%d.", SW_VERSION_N3)
90 PRINTF1("%d **\n", SW_VERSION_N4)
91 PRINTF("*************************\n")
92 PRINTF("\n\n")
93
94 // init_local_mode_parameters();
95 // init_housekeeping_parameters();
96
97 // updateLFRCurrentMode();
98
99 // BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
100
101 create_names(); // create all names
102
103 status = create_message_queues(); // create message queues
104 if (status != RTEMS_SUCCESSFUL)
105 {
106 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
107 }
108
109 status = create_all_tasks(); // create all tasks
110 if (status != RTEMS_SUCCESSFUL)
111 {
112 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
113 }
114
115 // **************************
116 // <SPACEWIRE INITIALIZATION>
117 grspw_timecode_callback = &timegen_timecode_irq_handler;
118
119 status_spw = spacewire_open_link(); // (1) open the link
120 if ( status_spw != RTEMS_SUCCESSFUL )
121 {
122 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
123 }
124
125 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
126 {
127 status_spw = spacewire_configure_link( fdSPW );
128 if ( status_spw != RTEMS_SUCCESSFUL )
129 {
130 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
131 }
132 }
133
134 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
135 {
136 status_spw = spacewire_start_link( fdSPW );
137 if ( status_spw != RTEMS_SUCCESSFUL )
138 {
139 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
140 }
141 }
142 // </SPACEWIRE INITIALIZATION>
143 // ***************************
144
145 status = start_all_tasks(); // start all tasks
146 if (status != RTEMS_SUCCESSFUL)
147 {
148 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
149 }
150
151 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
152 status = start_recv_send_tasks();
153 if ( status != RTEMS_SUCCESSFUL )
154 {
155 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
156 }
157
158 // suspend science tasks. they will be restarted later depending on the mode
159 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
160 if (status != RTEMS_SUCCESSFUL)
161 {
162 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
163 }
164
165 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
166 if ( status_spw != RTEMS_SUCCESSFUL )
167 {
168 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
169 if ( status != RTEMS_SUCCESSFUL ) {
170 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
171 }
172 }
173
174 BOOT_PRINTF("delete INIT\n")
175
176 status = rtems_task_delete(RTEMS_SELF);
177
178 }
179
180 void init_local_mode_parameters( void )
181 {
182 /** This function initialize the param_local global variable with default values.
183 *
184 */
185
186 unsigned int i;
187
188 // LOCAL PARAMETERS
189 // set_local_nb_interrupt_f0_MAX();
190
191 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
192 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
193 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
194
195 // init sequence counters
196
197 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
198 {
199 sequenceCounters_TC_EXE[i] = 0x00;
200 }
201 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
202 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
203 }
204
205 void create_names( void ) // create all names for tasks and queues
206 {
207 /** This function creates all RTEMS names used in the software for tasks and queues.
208 *
209 * @return RTEMS directive status codes:
210 * - RTEMS_SUCCESSFUL - successful completion
211 *
212 */
213
214 // task names
215 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
216 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
217 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
218 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
219 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
220 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
221 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
222 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
223 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
224 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
225 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
226 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
227 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
228 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
229 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
230 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
231
232 // TIMEGEN
233 rtems_name_updt = rtems_build_name( 'U', 'P', 'D', 'T' );
234
235 // rate monotonic period names
236 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
237
238 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
239 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
240 }
241
242 int create_all_tasks( void ) // create all tasks which run in the software
243 {
244 /** This function creates all RTEMS tasks used in the software.
245 *
246 * @return RTEMS directive status codes:
247 * - RTEMS_SUCCESSFUL - task created successfully
248 * - RTEMS_INVALID_ADDRESS - id is NULL
249 * - RTEMS_INVALID_NAME - invalid task name
250 * - RTEMS_INVALID_PRIORITY - invalid task priority
251 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
252 * - RTEMS_TOO_MANY - too many tasks created
253 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
254 * - RTEMS_TOO_MANY - too many global objects
255 *
256 */
257
258 rtems_status_code status;
259
260 //**********
261 // SPACEWIRE
262 // RECV
263 status = rtems_task_create(
264 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
265 RTEMS_DEFAULT_MODES,
266 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
267 );
268 if (status == RTEMS_SUCCESSFUL) // SEND
269 {
270 status = rtems_task_create(
271 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
272 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
273 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
274 );
275 }
276 if (status == RTEMS_SUCCESSFUL) // WTDG
277 {
278 status = rtems_task_create(
279 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
280 RTEMS_DEFAULT_MODES,
281 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
282 );
283 }
284 if (status == RTEMS_SUCCESSFUL) // ACTN
285 {
286 status = rtems_task_create(
287 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
288 RTEMS_DEFAULT_MODES,
289 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
290 );
291 }
292 if (status == RTEMS_SUCCESSFUL) // SPIQ
293 {
294 status = rtems_task_create(
295 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
296 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
297 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
298 );
299 }
300
301 //*****
302 // MISC
303 if (status == RTEMS_SUCCESSFUL) // STAT
304 {
305 status = rtems_task_create(
306 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
307 RTEMS_DEFAULT_MODES,
308 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
309 );
310 }
311 if (status == RTEMS_SUCCESSFUL) // DUMB
312 {
313 status = rtems_task_create(
314 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
315 RTEMS_DEFAULT_MODES,
316 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
317 );
318 }
319 if (status == RTEMS_SUCCESSFUL) // UPDT
320 {
321 status = rtems_task_create(
322 rtems_name_updt, TASK_PRIORITY_UPDT, RTEMS_MINIMUM_STACK_SIZE,
323 RTEMS_DEFAULT_MODES,
324 RTEMS_DEFAULT_ATTRIBUTES, &rtems_id_updt
325 );
326 }
327
328 return status;
329 }
330
331 int start_recv_send_tasks( void )
332 {
333 rtems_status_code status;
334
335 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
336 if (status!=RTEMS_SUCCESSFUL) {
337 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
338 }
339
340 if (status == RTEMS_SUCCESSFUL) // SEND
341 {
342 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
343 if (status!=RTEMS_SUCCESSFUL) {
344 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
345 }
346 }
347
348 return status;
349 }
350
351 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
352 {
353 /** This function starts all RTEMS tasks used in the software.
354 *
355 * @return RTEMS directive status codes:
356 * - RTEMS_SUCCESSFUL - ask started successfully
357 * - RTEMS_INVALID_ADDRESS - invalid task entry point
358 * - RTEMS_INVALID_ID - invalid task id
359 * - RTEMS_INCORRECT_STATE - task not in the dormant state
360 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
361 *
362 */
363 // starts all the tasks fot eh flight software
364
365 rtems_status_code status;
366
367 //**********
368 // SPACEWIRE
369 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
370 if (status!=RTEMS_SUCCESSFUL) {
371 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
372 }
373
374 if (status == RTEMS_SUCCESSFUL) // WTDG
375 {
376 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
377 if (status!=RTEMS_SUCCESSFUL) {
378 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
379 }
380 }
381
382 if (status == RTEMS_SUCCESSFUL) // ACTN
383 {
384 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
385 if (status!=RTEMS_SUCCESSFUL) {
386 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
387 }
388 }
389
390 //*****
391 // MISC
392 if (status == RTEMS_SUCCESSFUL) // DUMB
393 {
394 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
395 if (status!=RTEMS_SUCCESSFUL) {
396 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
397 }
398 }
399
400 if (status == RTEMS_SUCCESSFUL) // STAT
401 {
402 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
403 if (status!=RTEMS_SUCCESSFUL) {
404 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
405 }
406 }
407
408 if (status == RTEMS_SUCCESSFUL) // UPDT
409 {
410 status = rtems_task_start( rtems_id_updt, updt_task, 1 );
411 if (status!=RTEMS_SUCCESSFUL) {
412 BOOT_PRINTF("in INIT *** Error starting TASK_UPDT\n")
413 }
414 }
415
416 return status;
417 }
418
419 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
420 {
421 rtems_status_code status_recv;
422 rtems_status_code status_send;
423 rtems_status_code ret;
424 rtems_id queue_id;
425
426 // create the queue for handling valid TCs
427 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
428 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
429 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
430 if ( status_recv != RTEMS_SUCCESSFUL ) {
431 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
432 }
433
434 // create the queue for handling TM packet sending
435 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
436 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
437 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
438 if ( status_send != RTEMS_SUCCESSFUL ) {
439 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
440 }
441
442 if ( status_recv != RTEMS_SUCCESSFUL )
443 {
444 ret = status_recv;
445 }
446 else
447 {
448 ret = status_send;
449 }
450
451 return ret;
452 }
453
454 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
455 {
456 rtems_status_code status;
457 rtems_name queue_name;
458
459 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
460
461 status = rtems_message_queue_ident( queue_name, 0, queue_id );
462
463 return status;
464 }
465
466 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
467 {
468 rtems_status_code status;
469 rtems_name queue_name;
470
471 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
472
473 status = rtems_message_queue_ident( queue_name, 0, queue_id );
474
475 return status;
476 }
@@ -0,0 +1,110
1 /** Functions and tasks related to TeleCommand handling.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
8 * TC parsing\n
9 * ...
10 *
11 */
12
13 #include "timegen_misc.h"
14 #include <stdio.h>
15
16 void timegen_timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
17 {
18 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
19
20 grgpio_regs->io_port_direction_register =
21 grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled
22
23 if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 )
24 {
25 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7;
26 }
27 else
28 {
29 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08;
30 }
31
32 rtems_event_send( rtems_id_updt, RTEMS_EVENT_0 );
33 }
34
35 void initCoarseTime()
36 {
37 coarseTime = 0x00;
38 }
39
40 rtems_task updt_task( rtems_task_argument unused )
41 {
42 rtems_event_set event_out;
43 rtems_id send_queue_id;
44
45 get_message_queue_id_send( &send_queue_id );
46
47 BOOT_PRINTF("in UPDT *** waiting for SpaceWire ticks\n")
48
49 while(1)
50 {
51 // wait for an RTEMS_EVENT
52 rtems_event_receive( RTEMS_EVENT_0,
53 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
54 // increment the coarse time
55 coarseTime = coarseTime + 1;
56 PRINTF2("next valid coarseTime = 0x%x *** %d s\n", coarseTime, coarseTime)
57 rtems_task_wake_after(70); // 10 ms * 70 = 700 ms
58 send_tc_lfr_update_time( send_queue_id );
59 }
60 }
61
62 int send_tc_lfr_update_time(rtems_id queue_id )
63 {
64
65 rtems_status_code status;
66 unsigned char messageSize;
67
68 Packet_TC_LFR_UPDATE_TIME_WITH_OVERHEAD_t packet;
69 unsigned char crcAsTwoBytes[2];
70
71 // OVERHEAD
72 packet.targetLogicalAddress = DESTINATION_ID_LFR;
73 packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
74 packet.reserved = DEFAULT_RESERVED;
75 packet.userApplication = CCSDS_USER_APP;
76
77 // TIME PACKET
78 packet.update_time.packetID[0] = (unsigned char) (TC_LFR_PACKET_ID >> 8);
79 packet.update_time.packetID[1] = (unsigned char) (TC_LFR_PACKET_ID );
80 packet.update_time.packetSequenceControl[0] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL >> 8);
81 packet.update_time.packetSequenceControl[1] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL );
82 packet.update_time.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_LFR_UPDATE_TIME >> 8);
83 packet.update_time.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_LFR_UPDATE_TIME );
84
85 packet.update_time.ccsdsSecHeaderFlag_pusVersion_ack = 0x19;
86 packet.update_time.serviceType = TC_TYPE_LFR_UPDATE_TIME;
87 packet.update_time.serviceSubType = TC_SUBTYPE_UPDATE_TIME;
88 packet.update_time.sourceID = SID_TC_RPW_INTERNAL;
89 packet.update_time.cp_rpw_time[0] = (unsigned char) (coarseTime >> 24);
90 packet.update_time.cp_rpw_time[1] = (unsigned char) (coarseTime >> 16);
91 packet.update_time.cp_rpw_time[2] = (unsigned char) (coarseTime >> 8);
92 packet.update_time.cp_rpw_time[3] = (unsigned char) (coarseTime);
93 packet.update_time.cp_rpw_time[4] = 0; // fine time MSB
94 packet.update_time.cp_rpw_time[5] = 0; // fine time LSB
95
96 GetCRCAsTwoBytes((unsigned char*) &packet.update_time, crcAsTwoBytes,
97 PACKET_LENGTH_TC_LFR_UPDATE_TIME + CCSDS_TC_TM_PACKET_OFFSET - 2);
98 packet.update_time.crc[0] = crcAsTwoBytes[0];
99 packet.update_time.crc[1] = crcAsTwoBytes[1];
100
101 messageSize = PACKET_LENGTH_TC_LFR_UPDATE_TIME + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
102
103 // SEND DATA
104 status = rtems_message_queue_send( queue_id, &packet, messageSize);
105 if (status != RTEMS_SUCCESSFUL) {
106 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
107 }
108
109 return status;
110 }
This diff has been collapsed as it changes many lines, (601 lines changed) Show them Hide them
@@ -0,0 +1,601
1 /** Functions related to the SpaceWire interface.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * A group of functions to handle SpaceWire transmissions:
7 * - configuration of the SpaceWire link
8 * - SpaceWire related interruption requests processing
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
11 *
12 */
13
14 #include "timegen_spacewire.h"
15
16 rtems_name semq_name;
17 rtems_id semq_id;
18
19 //***********
20 // RTEMS TASK
21 rtems_task spiq_task(rtems_task_argument unused)
22 {
23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
24 *
25 * @param unused is the starting argument of the RTEMS task
26 *
27 */
28
29 rtems_event_set event_out;
30 rtems_status_code status;
31 int linkStatus;
32
33 BOOT_PRINTF("in SPIQ *** \n")
34
35 while(true){
36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
38
39 // [0] SUSPEND RECV AND SEND TASKS
40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
41 if ( status != RTEMS_SUCCESSFUL ) {
42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
43 }
44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
45 if ( status != RTEMS_SUCCESSFUL ) {
46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
47 }
48
49 // [1] CHECK THE LINK
50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
51 if ( linkStatus != 5) {
52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
54 }
55
56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
59 {
60 spacewire_compute_stats_offsets();
61 status = spacewire_reset_link( );
62 }
63 else // [2.b] in run state, start the link
64 {
65 status = spacewire_stop_start_link( fdSPW ); // start the link
66 if ( status != RTEMS_SUCCESSFUL)
67 {
68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
69 }
70 }
71
72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
74 {
75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
76 if ( status != RTEMS_SUCCESSFUL ) {
77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
78 }
79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
80 if ( status != RTEMS_SUCCESSFUL ) {
81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
82 }
83 }
84 else // [3.b] the link is not in run state, go in STANDBY mode
85 {
86 status = stop_current_mode();
87 if ( status != RTEMS_SUCCESSFUL ) {
88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
89 }
90 status = enter_mode( LFR_MODE_STANDBY );
91 if ( status != RTEMS_SUCCESSFUL ) {
92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
93 }
94 // wake the WTDG task up to wait for the link recovery
95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
96 status = rtems_task_suspend( RTEMS_SELF );
97 }
98 }
99 }
100
101 rtems_task recv_task( rtems_task_argument unused )
102 {
103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
104 *
105 * @param unused is the starting argument of the RTEMS task
106 *
107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
108 * 1. It reads the incoming data.
109 * 2. Launches the acceptance procedure.
110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
111 *
112 */
113
114 int len;
115 ccsdsTelecommandPacket_t currentTC;
116 unsigned char computed_CRC[ 2 ];
117 unsigned char currentTC_LEN_RCV[ 2 ];
118 unsigned char destinationID;
119 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
120 unsigned int parserCode;
121 unsigned char time[6];
122 rtems_status_code status;
123 rtems_id queue_recv_id;
124 rtems_id queue_send_id;
125
126 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
127
128 status = get_message_queue_id_recv( &queue_recv_id );
129 if (status != RTEMS_SUCCESSFUL)
130 {
131 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
132 }
133
134 status = get_message_queue_id_send( &queue_send_id );
135 if (status != RTEMS_SUCCESSFUL)
136 {
137 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
138 }
139
140 BOOT_PRINTF("in RECV *** \n")
141
142 while(1)
143 {
144 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
145 if (len == -1){ // error during the read call
146 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
147 }
148 else {
149 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
150 PRINTF("in RECV *** packet lenght too short\n")
151 }
152 else {
153 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
154 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
155 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
156 // CHECK THE TC
157 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
158 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
159 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
160 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
161 || (parserCode == WRONG_SRC_ID) )
162 { // send TM_LFR_TC_EXE_CORRUPTED
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
164 &&
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
166 )
167 {
168 if ( parserCode == WRONG_SRC_ID )
169 {
170 destinationID = SID_TC_GROUND;
171 }
172 else
173 {
174 destinationID = currentTC.sourceID;
175 }
176 getTime( time );
177 close_action( &currentTC, LFR_DEFAULT, queue_send_id );
178 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
179 computed_CRC, currentTC_LEN_RCV,
180 destinationID );
181 }
182 }
183 else
184 { // send valid TC to the action launcher
185 status = rtems_message_queue_send( queue_recv_id, &currentTC,
186 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
187 }
188 }
189 }
190 }
191 }
192
193 rtems_task send_task( rtems_task_argument argument)
194 {
195 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
196 *
197 * @param unused is the starting argument of the RTEMS task
198 *
199 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
200 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
201 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
202 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
203 * data it contains.
204 *
205 */
206
207 rtems_status_code status; // RTEMS status code
208 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
209 size_t size; // size of the incoming TC packet
210 u_int32_t count;
211 rtems_id queue_id;
212
213 status = get_message_queue_id_send( &queue_id );
214 if (status != RTEMS_SUCCESSFUL)
215 {
216 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
217 }
218
219 BOOT_PRINTF("in SEND *** \n")
220
221 while(1)
222 {
223 status = rtems_message_queue_receive( queue_id, incomingData, &size,
224 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
225
226 if (status!=RTEMS_SUCCESSFUL)
227 {
228 PRINTF1("in SEND *** (1) ERR = %d\n", status)
229 }
230 else
231 {
232 status = write( fdSPW, incomingData, size );
233 if (status == -1){
234 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
235 }
236 }
237
238 status = rtems_message_queue_get_number_pending( queue_id, &count );
239 if (status != RTEMS_SUCCESSFUL)
240 {
241 PRINTF1("in SEND *** (3) ERR = %d\n", status)
242 }
243 else
244 {
245 if (count > maxCount)
246 {
247 maxCount = count;
248 }
249 }
250 }
251 }
252
253 rtems_task wtdg_task( rtems_task_argument argument )
254 {
255 rtems_event_set event_out;
256 rtems_status_code status;
257 int linkStatus;
258
259 BOOT_PRINTF("in WTDG ***\n")
260
261 while(1)
262 {
263 // wait for an RTEMS_EVENT
264 rtems_event_receive( RTEMS_EVENT_0,
265 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
266 PRINTF("in WTDG *** wait for the link\n")
267 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
268 while( linkStatus != 5) // wait for the link
269 {
270 rtems_task_wake_after( 10 );
271 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
272 }
273
274 status = spacewire_stop_start_link( fdSPW );
275
276 if (status != RTEMS_SUCCESSFUL)
277 {
278 PRINTF1("in WTDG *** ERR link not started %d\n", status)
279 }
280 else
281 {
282 PRINTF("in WTDG *** OK link started\n")
283 }
284
285 // restart the SPIQ task
286 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
287 if ( status != RTEMS_SUCCESSFUL ) {
288 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
289 }
290
291 // restart RECV and SEND
292 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
293 if ( status != RTEMS_SUCCESSFUL ) {
294 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
295 }
296 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
297 if ( status != RTEMS_SUCCESSFUL ) {
298 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
299 }
300 }
301 }
302
303 //****************
304 // OTHER FUNCTIONS
305 int spacewire_open_link( void )
306 {
307 /** This function opens the SpaceWire link.
308 *
309 * @return a valid file descriptor in case of success, -1 in case of a failure
310 *
311 */
312 rtems_status_code status;
313
314 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
315 if ( fdSPW < 0 ) {
316 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
317 }
318 else
319 {
320 status = RTEMS_SUCCESSFUL;
321 }
322
323 return status;
324 }
325
326 int spacewire_start_link( int fd )
327 {
328 rtems_status_code status;
329
330 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
331 // -1 default hardcoded driver timeout
332
333 return status;
334 }
335
336 int spacewire_stop_start_link( int fd )
337 {
338 rtems_status_code status;
339
340 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
341 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
342 // -1 default hardcoded driver timeout
343
344 return status;
345 }
346
347 int spacewire_configure_link( int fd )
348 {
349 /** This function configures the SpaceWire link.
350 *
351 * @return GR-RTEMS-DRIVER directive status codes:
352 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
353 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
354 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
355 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
356 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
357 * - 5 EIO - Error when writing to grswp hardware registers.
358 * - 2 ENOENT - No such file or directory
359 */
360
361 rtems_status_code status;
362
363 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
364 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
365
366 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
367 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
368 //
369 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
370 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
371 //
372 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
373 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
374 //
375 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
376 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
377 //
378 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
379 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
380 //
381 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
382 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
383 //
384 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
385 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL\n")
386
387 return status;
388 }
389
390 int spacewire_reset_link( void )
391 {
392 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
393 *
394 * @return RTEMS directive status code:
395 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
396 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
397 *
398 */
399
400 rtems_status_code status_spw;
401 int i;
402
403 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
404 {
405 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
406
407 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
408
409 status_spw = spacewire_stop_start_link( fdSPW );
410 if ( status_spw != RTEMS_SUCCESSFUL )
411 {
412 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
413 }
414
415 if ( status_spw == RTEMS_SUCCESSFUL)
416 {
417 break;
418 }
419 }
420
421 return status_spw;
422 }
423
424 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
425 {
426 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
427 *
428 * @param val is the value, 0 or 1, used to set the value of the NP bit.
429 * @param regAddr is the address of the GRSPW control register.
430 *
431 * NP is the bit 20 of the GRSPW control register.
432 *
433 */
434
435 unsigned int *spwptr = (unsigned int*) regAddr;
436
437 if (val == 1) {
438 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
439 }
440 if (val== 0) {
441 *spwptr = *spwptr & 0xffdfffff;
442 }
443 }
444
445 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
446 {
447 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
448 *
449 * @param val is the value, 0 or 1, used to set the value of the RE bit.
450 * @param regAddr is the address of the GRSPW control register.
451 *
452 * RE is the bit 16 of the GRSPW control register.
453 *
454 */
455
456 unsigned int *spwptr = (unsigned int*) regAddr;
457
458 if (val == 1)
459 {
460 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
461 }
462 if (val== 0)
463 {
464 *spwptr = *spwptr & 0xfffdffff;
465 }
466 }
467
468 void spacewire_compute_stats_offsets( void )
469 {
470 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
471 *
472 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
473 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
474 * during the open systel call).
475 *
476 */
477
478 spw_stats spacewire_stats_grspw;
479 rtems_status_code status;
480
481 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
482
483 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
484 + spacewire_stats.packets_received;
485 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
486 + spacewire_stats.packets_sent;
487 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
488 + spacewire_stats.parity_err;
489 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
490 + spacewire_stats.disconnect_err;
491 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
492 + spacewire_stats.escape_err;
493 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
494 + spacewire_stats.credit_err;
495 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
496 + spacewire_stats.write_sync_err;
497 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
498 + spacewire_stats.rx_rmap_header_crc_err;
499 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
500 + spacewire_stats.rx_rmap_data_crc_err;
501 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
502 + spacewire_stats.early_ep;
503 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
504 + spacewire_stats.invalid_address;
505 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
506 + spacewire_stats.rx_eep_err;
507 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
508 + spacewire_stats.rx_truncated;
509 }
510
511 void spacewire_update_statistics( void )
512 {
513 rtems_status_code status;
514 spw_stats spacewire_stats_grspw;
515
516 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
517
518 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
519 + spacewire_stats_grspw.packets_received;
520 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
521 + spacewire_stats_grspw.packets_sent;
522 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
523 + spacewire_stats_grspw.parity_err;
524 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
525 + spacewire_stats_grspw.disconnect_err;
526 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
527 + spacewire_stats_grspw.escape_err;
528 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
529 + spacewire_stats_grspw.credit_err;
530 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
531 + spacewire_stats_grspw.write_sync_err;
532 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
533 + spacewire_stats_grspw.rx_rmap_header_crc_err;
534 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
535 + spacewire_stats_grspw.rx_rmap_data_crc_err;
536 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
537 + spacewire_stats_grspw.early_ep;
538 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
539 + spacewire_stats_grspw.invalid_address;
540 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
541 + spacewire_stats_grspw.rx_eep_err;
542 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
543 + spacewire_stats_grspw.rx_truncated;
544 //spacewire_stats.tx_link_err;
545
546 //****************************
547 // DPU_SPACEWIRE_IF_STATISTICS
548 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
549 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
550 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
551 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
552 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
553 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
554
555 //******************************************
556 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
557 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
558 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
559 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
560 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
561 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
562
563 //*********************************************
564 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
565 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
566 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
567 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
568 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
569 }
570
571 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
572 {
573 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 );
574 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
575
576 grgpio_regs->io_port_direction_register =
577 grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled
578
579 if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 )
580 {
581 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7;
582 }
583 else
584 {
585 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08;
586 }
587
588 }
589
590 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
591 {
592 int linkStatus;
593 rtems_status_code status;
594
595 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
596
597 if ( linkStatus == 5) {
598 PRINTF("in spacewire_reset_link *** link is running\n")
599 status = RTEMS_SUCCESSFUL;
600 }
601 }
This diff has been collapsed as it changes many lines, (793 lines changed) Show them Hide them
@@ -0,0 +1,793
1 /** Functions and tasks related to TeleCommand handling.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
8 * TC parsing\n
9 * ...
10 *
11 */
12
13 #include "timegen_tc_handler.h"
14
15 //***********
16 // RTEMS TASK
17
18 rtems_task actn_task( rtems_task_argument unused )
19 {
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 *
22 * @param unused is the starting argument of the RTEMS task
23 *
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * on the incoming TeleCommand.
26 *
27 */
28
29 int result;
30 rtems_status_code status; // RTEMS status code
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 size_t size; // size of the incoming TC packet
33 unsigned char subtype; // subtype of the current TC packet
34 unsigned char time[6];
35 rtems_id queue_rcv_id;
36 rtems_id queue_snd_id;
37
38 status = get_message_queue_id_recv( &queue_rcv_id );
39 if (status != RTEMS_SUCCESSFUL)
40 {
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 }
43
44 status = get_message_queue_id_send( &queue_snd_id );
45 if (status != RTEMS_SUCCESSFUL)
46 {
47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 }
49
50 result = LFR_SUCCESSFUL;
51 subtype = 0; // subtype of the current TC packet
52
53 BOOT_PRINTF("in ACTN *** \n")
54
55 while(1)
56 {
57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 getTime( time ); // set time to the current time
60 if (status!=RTEMS_SUCCESSFUL)
61 {
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 }
64 else
65 {
66 subtype = TC.serviceSubType;
67 switch(subtype)
68 {
69 case TC_SUBTYPE_RESET:
70 // result = action_reset( &TC, queue_snd_id, time );
71 close_action( &TC, result, queue_snd_id );
72 break;
73 //
74 case TC_SUBTYPE_LOAD_COMM:
75 // result = action_load_common_par( &TC );
76 close_action( &TC, result, queue_snd_id );
77 break;
78 //
79 case TC_SUBTYPE_LOAD_NORM:
80 // result = action_load_normal_par( &TC, queue_snd_id, time );
81 close_action( &TC, result, queue_snd_id );
82 break;
83 //
84 case TC_SUBTYPE_LOAD_BURST:
85 // result = action_load_burst_par( &TC, queue_snd_id, time );
86 close_action( &TC, result, queue_snd_id );
87 break;
88 //
89 case TC_SUBTYPE_LOAD_SBM1:
90 // result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 close_action( &TC, result, queue_snd_id );
92 break;
93 //
94 case TC_SUBTYPE_LOAD_SBM2:
95 // result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 close_action( &TC, result, queue_snd_id );
97 break;
98 //
99 case TC_SUBTYPE_DUMP:
100 // result = action_dump_par( queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
102 break;
103 //
104 case TC_SUBTYPE_ENTER:
105 result = action_enter_mode( &TC, queue_snd_id, time );
106 close_action( &TC, result, queue_snd_id );
107 break;
108 //
109 case TC_SUBTYPE_UPDT_INFO:
110 // result = action_update_info( &TC, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
112 break;
113 //
114 case TC_SUBTYPE_EN_CAL:
115 // result = action_enable_calibration( &TC, queue_snd_id, time );
116 close_action( &TC, result, queue_snd_id );
117 break;
118 //
119 case TC_SUBTYPE_DIS_CAL:
120 // result = action_disable_calibration( &TC, queue_snd_id, time );
121 close_action( &TC, result, queue_snd_id );
122 break;
123 //
124 case TC_SUBTYPE_UPDT_TIME:
125 result = action_update_time( &TC );
126 close_action( &TC, result, queue_snd_id );
127 break;
128 //
129 default:
130 break;
131 }
132 }
133 }
134 }
135
136 //***********
137 // TC ACTIONS
138
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 {
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 *
143 * @param TC points to the TeleCommand packet that is being processed
144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 *
146 */
147
148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 return LFR_DEFAULT;
150 }
151
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
153 {
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 *
156 * @param TC points to the TeleCommand packet that is being processed
157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
158 *
159 */
160
161 rtems_status_code status;
162 unsigned char requestedMode;
163
164 requestedMode = TC->dataAndCRC[1];
165
166 if ( (requestedMode != LFR_MODE_STANDBY)
167 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
168 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
169 {
170 status = RTEMS_UNSATISFIED;
171 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
172 }
173 else
174 {
175 printf("in action_enter_mode *** enter mode %d\n", requestedMode);
176
177 status = transition_validation(requestedMode);
178
179 if ( status == LFR_SUCCESSFUL ) {
180 if ( lfrCurrentMode != LFR_MODE_STANDBY)
181 {
182 status = stop_current_mode();
183 }
184 if (status != RTEMS_SUCCESSFUL)
185 {
186 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
187 }
188 status = enter_mode( requestedMode );
189 }
190 else
191 {
192 PRINTF("ERR *** in action_enter *** transition rejected\n")
193 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
194 }
195 }
196
197 return status;
198 }
199
200 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
201 {
202 // /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
203 // *
204 // * @param TC points to the TeleCommand packet that is being processed
205 // * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
206 // *
207 // * @return LFR directive status code:
208 // * - LFR_DEFAULT
209 // * - LFR_SUCCESSFUL
210 // *
211 // */
212
213 // unsigned int val;
214 int result;
215
216 result = LFR_DEFAULT;
217 // unsigned int status;
218 // unsigned char mode;
219
220 // // check LFR MODE
221 // mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET5 ] & 0x1e) >> 1;
222 // status = check_update_info_hk_lfr_mode( mode );
223 // if (status != LFR_DEFAULT) // check TDS mode
224 // {
225 // mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0xf0) >> 4;
226 // status = check_update_info_hk_tds_mode( mode );
227 // }
228 // if (status != LFR_DEFAULT) // check THR mode
229 // {
230 // mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0x0f);
231 // status = check_update_info_hk_thr_mode( mode );
232 // }
233 // if (status != LFR_DEFAULT) // if the parameter check is successful
234 // {
235 // val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
236 // + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
237 // val++;
238 // housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
239 // housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
240 // }
241
242 // result = status;
243
244 return result;
245 }
246
247 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
248 {
249 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
250 *
251 * @param TC points to the TeleCommand packet that is being processed
252 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
253 *
254 */
255
256 int result;
257 unsigned char lfrMode;
258
259 result = LFR_DEFAULT;
260 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
261
262 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
263 result = LFR_DEFAULT;
264
265 return result;
266 }
267
268 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
269 {
270 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
271 *
272 * @param TC points to the TeleCommand packet that is being processed
273 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
274 *
275 */
276
277 int result;
278 unsigned char lfrMode;
279
280 result = LFR_DEFAULT;
281 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
282
283 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
284 result = LFR_DEFAULT;
285
286 return result;
287 }
288
289 int action_update_time(ccsdsTelecommandPacket_t *TC)
290 {
291 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
292 *
293 * @param TC points to the TeleCommand packet that is being processed
294 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
295 *
296 * @return LFR_SUCCESSFUL
297 *
298 */
299
300 unsigned int val;
301
302 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
303 + (TC->dataAndCRC[1] << 16)
304 + (TC->dataAndCRC[2] << 8)
305 + TC->dataAndCRC[3];
306 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
307 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
308 val++;
309 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
310 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
311 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
312
313 return LFR_SUCCESSFUL;
314 }
315
316 //*******************
317 // ENTERING THE MODES
318
319 int transition_validation(unsigned char requestedMode)
320 {
321 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
322 *
323 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
324 *
325 * @return LFR directive status codes:
326 * - LFR_SUCCESSFUL - the transition is authorized
327 * - LFR_DEFAULT - the transition is not authorized
328 *
329 */
330
331 int status;
332
333 switch (requestedMode)
334 {
335 case LFR_MODE_STANDBY:
336 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
337 status = LFR_DEFAULT;
338 }
339 else
340 {
341 status = LFR_SUCCESSFUL;
342 }
343 break;
344 case LFR_MODE_NORMAL:
345 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
346 status = LFR_DEFAULT;
347 }
348 else {
349 status = LFR_SUCCESSFUL;
350 }
351 break;
352 case LFR_MODE_BURST:
353 if ( lfrCurrentMode == LFR_MODE_BURST ) {
354 status = LFR_DEFAULT;
355 }
356 else {
357 status = LFR_SUCCESSFUL;
358 }
359 break;
360 case LFR_MODE_SBM1:
361 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
362 status = LFR_DEFAULT;
363 }
364 else {
365 status = LFR_SUCCESSFUL;
366 }
367 break;
368 case LFR_MODE_SBM2:
369 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
370 status = LFR_DEFAULT;
371 }
372 else {
373 status = LFR_SUCCESSFUL;
374 }
375 break;
376 default:
377 status = LFR_DEFAULT;
378 break;
379 }
380
381 return status;
382 }
383
384 int stop_current_mode(void)
385 {
386 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
387 *
388 * @return RTEMS directive status codes:
389 * - RTEMS_SUCCESSFUL - task restarted successfully
390 * - RTEMS_INVALID_ID - task id invalid
391 * - RTEMS_ALREADY_SUSPENDED - task already suspended
392 *
393 */
394
395 rtems_status_code status;
396
397 status = RTEMS_SUCCESSFUL;
398
399 // (1) mask interruptions
400 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
401 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
402
403 // (2) clear interruptions
404 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
405 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
406
407 // (3) reset registers
408 // waveform picker
409 // reset_wfp_burst_enable(); // reset burst and enable bits
410 // reset_wfp_status(); // reset all the status bits
411 // spectral matrices
412 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
413 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
414 // reset_extractSWF(); // reset the extractSWF flag to false
415
416 // <Spectral Matrices simulator>
417 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
418 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
419 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
420 // </Spectral Matrices simulator>
421
422 // suspend several tasks
423 if (lfrCurrentMode != LFR_MODE_STANDBY) {
424 status = suspend_science_tasks();
425 }
426
427 if (status != RTEMS_SUCCESSFUL)
428 {
429 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
430 }
431
432 return status;
433 }
434
435 int enter_mode(unsigned char mode )
436 {
437 /** This function is launched after a mode transition validation.
438 *
439 * @param mode is the mode in which LFR will be put.
440 *
441 * @return RTEMS directive status codes:
442 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
443 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
444 *
445 */
446
447 rtems_status_code status;
448
449 status = RTEMS_UNSATISFIED;
450
451 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
452 updateLFRCurrentMode();
453
454 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
455 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
456 {
457 #ifdef PRINT_TASK_STATISTICS
458 rtems_cpu_usage_reset();
459 maxCount = 0;
460 #endif
461 status = restart_science_tasks();
462 // launch_waveform_picker( mode );
463 // launch_spectral_matrix( mode );
464 }
465 else if ( mode == LFR_MODE_STANDBY )
466 {
467 #ifdef PRINT_TASK_STATISTICS
468 rtems_cpu_usage_report();
469 #endif
470
471 #ifdef PRINT_STACK_REPORT
472 rtems_stack_checker_report_usage();
473 #endif
474 status = stop_current_mode();
475 PRINTF1("maxCount = %d\n", maxCount)
476 }
477 else
478 {
479 status = RTEMS_UNSATISFIED;
480 }
481
482 if (status != RTEMS_SUCCESSFUL)
483 {
484 PRINTF1("in enter_mode *** ERR = %d\n", status)
485 status = RTEMS_UNSATISFIED;
486 }
487
488 return status;
489 }
490
491 int restart_science_tasks()
492 {
493 /** This function is used to restart all science tasks.
494 *
495 * @return RTEMS directive status codes:
496 * - RTEMS_SUCCESSFUL - task restarted successfully
497 * - RTEMS_INVALID_ID - task id invalid
498 * - RTEMS_INCORRECT_STATE - task never started
499 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
500 *
501 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
502 *
503 */
504
505 rtems_status_code status[6];
506 rtems_status_code ret;
507
508 ret = RTEMS_SUCCESSFUL;
509
510 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
511 if (status[0] != RTEMS_SUCCESSFUL)
512 {
513 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
514 }
515
516 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
517 if (status[2] != RTEMS_SUCCESSFUL)
518 {
519 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
520 }
521
522 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
523 if (status[3] != RTEMS_SUCCESSFUL)
524 {
525 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
526 }
527
528 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
529 if (status[4] != RTEMS_SUCCESSFUL)
530 {
531 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
532 }
533
534 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
535 if (status[5] != RTEMS_SUCCESSFUL)
536 {
537 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
538 }
539
540 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
541 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
542 {
543 ret = RTEMS_UNSATISFIED;
544 }
545
546 return ret;
547 }
548
549 int suspend_science_tasks()
550 {
551 /** This function suspends the science tasks.
552 *
553 * @return RTEMS directive status codes:
554 * - RTEMS_SUCCESSFUL - task restarted successfully
555 * - RTEMS_INVALID_ID - task id invalid
556 * - RTEMS_ALREADY_SUSPENDED - task already suspended
557 *
558 */
559
560 rtems_status_code status;
561
562 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
563 if (status != RTEMS_SUCCESSFUL)
564 {
565 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
566 }
567
568 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
569 {
570 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
571 if (status != RTEMS_SUCCESSFUL)
572 {
573 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
574 }
575 }
576
577 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
578 {
579 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
580 if (status != RTEMS_SUCCESSFUL)
581 {
582 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
583 }
584 }
585
586 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
587 {
588 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
589 if (status != RTEMS_SUCCESSFUL)
590 {
591 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
592 }
593 }
594
595 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
596 {
597 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
598 if (status != RTEMS_SUCCESSFUL)
599 {
600 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
601 }
602 }
603
604 return status;
605 }
606
607 void launch_waveform_picker( unsigned char mode )
608 {
609 // int startDate;
610
611 // reset_current_ring_nodes();
612 // reset_waveform_picker_regs();
613 // set_wfp_burst_enable_register( mode );
614
615 // LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
616 // LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
617
618 // startDate = time_management_regs->coarse_time + 2;
619 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
620 // waveform_picker_regs->start_date = startDate;
621 }
622
623 void launch_spectral_matrix( unsigned char mode )
624 {
625 // reset_nb_sm_f0();
626 // reset_current_sm_ring_nodes();
627 // reset_spectral_matrix_regs();
628
629 //#ifdef VHDL_DEV
630 // set_irq_on_new_ready_matrix( 1 );
631 // LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
632 // LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
633 // set_run_matrix_spectral( 1 );
634 //#else
635 // // Spectral Matrices simulator
636 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
637 // LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
638 // LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
639 //#endif
640 }
641
642 void set_irq_on_new_ready_matrix( unsigned char value )
643 {
644 if (value == 1)
645 {
646 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
647 }
648 else
649 {
650 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
651 }
652 }
653
654 void set_run_matrix_spectral( unsigned char value )
655 {
656 if (value == 1)
657 {
658 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // 0100 set run_matrix spectral to 1
659 }
660 else
661 {
662 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // 1011 set run_matrix spectral to 0
663 }
664 }
665
666 void launch_spectral_matrix_simu( unsigned char mode )
667 {
668 // reset_nb_sm_f0();
669 // reset_current_sm_ring_nodes();
670 // reset_spectral_matrix_regs();
671
672 // // Spectral Matrices simulator
673 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
674 // LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
675 // LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
676 // set_local_nb_interrupt_f0_MAX();
677 }
678
679 //****************
680 // CLOSING ACTIONS
681 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
682 {
683 /** This function is used to update the HK packets statistics after a successful TC execution.
684 *
685 * @param TC points to the TC being processed
686 * @param time is the time used to date the TC execution
687 *
688 */
689
690 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
691 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
692 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
693 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
694 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
695 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
696 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
697 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
698 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
699 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
700 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
701 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
702 }
703
704 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC )
705 {
706 /** This function is used to update the HK packets statistics after a TC rejection.
707 *
708 * @param TC points to the TC being processed
709 * @param time is the time used to date the TC rejection
710 *
711 */
712
713 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
714 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
715 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
716 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
717 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
718 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
719 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
720 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
721 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
722 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
723 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
724 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
725 }
726
727 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
728 {
729 /** This function is the last step of the TC execution workflow.
730 *
731 * @param TC points to the TC being processed
732 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
733 * @param queue_id is the id of the RTEMS message queue used to send TM packets
734 * @param time is the time used to date the TC execution
735 *
736 */
737
738 unsigned int val = 0;
739
740 if (result == LFR_SUCCESSFUL)
741 {
742 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
743 &&
744 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
745 )
746 {
747 send_tm_lfr_tc_exe_success( TC, queue_id );
748 }
749 update_last_TC_exe( TC );
750 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
751 val++;
752 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
753 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
754 }
755 else
756 {
757 update_last_TC_rej( TC );
758 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
759 val++;
760 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
761 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
762 }
763 }
764
765 //***************************
766 // Interrupt Service Routines
767 rtems_isr commutation_isr1( rtems_vector_number vector )
768 {
769 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
770 printf("In commutation_isr1 *** Error sending event to DUMB\n");
771 }
772 }
773
774 rtems_isr commutation_isr2( rtems_vector_number vector )
775 {
776 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
777 printf("In commutation_isr2 *** Error sending event to DUMB\n");
778 }
779 }
780
781 //****************
782 // OTHER FUNCTIONS
783 void updateLFRCurrentMode()
784 {
785 /** This function updates the value of the global variable lfrCurrentMode.
786 *
787 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
788 *
789 */
790 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
791 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
792 }
793
@@ -1,253 +1,253
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Mar 11 15:58:37 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Mar 25 09:47:02 2014
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 #############################################################################
7 #############################################################################
8
8
9 ####### Compiler, tools and options
9 ####### Compiler, tools and options
10
10
11 CC = sparc-rtems-gcc
11 CC = sparc-rtems-gcc
12 CXX = sparc-rtems-g++
12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=3 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=3 -DVHDL_DEV -DPRINT_MESSAGES_ON_CONSOLE
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters
17 LINK = sparc-rtems-g++
17 LINK = sparc-rtems-g++
18 LFLAGS =
18 LFLAGS =
19 LIBS = $(SUBLIBS)
19 LIBS = $(SUBLIBS)
20 AR = sparc-rtems-ar rcs
20 AR = sparc-rtems-ar rcs
21 RANLIB =
21 RANLIB =
22 QMAKE = /usr/bin/qmake-qt4
22 QMAKE = /usr/bin/qmake-qt4
23 TAR = tar -cf
23 TAR = tar -cf
24 COMPRESS = gzip -9f
24 COMPRESS = gzip -9f
25 COPY = cp -f
25 COPY = cp -f
26 SED = sed
26 SED = sed
27 COPY_FILE = $(COPY)
27 COPY_FILE = $(COPY)
28 COPY_DIR = $(COPY) -r
28 COPY_DIR = $(COPY) -r
29 STRIP = sparc-rtems-strip
29 STRIP = sparc-rtems-strip
30 INSTALL_FILE = install -m 644 -p
30 INSTALL_FILE = install -m 644 -p
31 INSTALL_DIR = $(COPY_DIR)
31 INSTALL_DIR = $(COPY_DIR)
32 INSTALL_PROGRAM = install -m 755 -p
32 INSTALL_PROGRAM = install -m 755 -p
33 DEL_FILE = rm -f
33 DEL_FILE = rm -f
34 SYMLINK = ln -f -s
34 SYMLINK = ln -f -s
35 DEL_DIR = rmdir
35 DEL_DIR = rmdir
36 MOVE = mv -f
36 MOVE = mv -f
37 CHK_DIR_EXISTS= test -d
37 CHK_DIR_EXISTS= test -d
38 MKDIR = mkdir -p
38 MKDIR = mkdir -p
39
39
40 ####### Output directory
40 ####### Output directory
41
41
42 OBJECTS_DIR = obj/
42 OBJECTS_DIR = obj/
43
43
44 ####### Files
44 ####### Files
45
45
46 SOURCES = ../src/wf_handler.c \
46 SOURCES = ../src/wf_handler.c \
47 ../src/tc_handler.c \
47 ../src/tc_handler.c \
48 ../src/fsw_processing.c \
48 ../src/fsw_processing.c \
49 ../src/fsw_misc.c \
49 ../src/fsw_misc.c \
50 ../src/fsw_init.c \
50 ../src/fsw_init.c \
51 ../src/fsw_globals.c \
51 ../src/fsw_globals.c \
52 ../src/fsw_spacewire.c \
52 ../src/fsw_spacewire.c \
53 ../src/tc_load_dump_parameters.c \
53 ../src/tc_load_dump_parameters.c \
54 ../src/tm_lfr_tc_exe.c \
54 ../src/tm_lfr_tc_exe.c \
55 ../src/tc_acceptance.c \
55 ../src/tc_acceptance.c \
56 ../../LFR_basic-parameters/basic_parameters.c
56 ../../LFR_basic-parameters/basic_parameters.c
57 OBJECTS = obj/wf_handler.o \
57 OBJECTS = obj/wf_handler.o \
58 obj/tc_handler.o \
58 obj/tc_handler.o \
59 obj/fsw_processing.o \
59 obj/fsw_processing.o \
60 obj/fsw_misc.o \
60 obj/fsw_misc.o \
61 obj/fsw_init.o \
61 obj/fsw_init.o \
62 obj/fsw_globals.o \
62 obj/fsw_globals.o \
63 obj/fsw_spacewire.o \
63 obj/fsw_spacewire.o \
64 obj/tc_load_dump_parameters.o \
64 obj/tc_load_dump_parameters.o \
65 obj/tm_lfr_tc_exe.o \
65 obj/tm_lfr_tc_exe.o \
66 obj/tc_acceptance.o \
66 obj/tc_acceptance.o \
67 obj/basic_parameters.o
67 obj/basic_parameters.o
68 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
68 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
69 /usr/lib64/qt4/mkspecs/common/linux.conf \
69 /usr/lib64/qt4/mkspecs/common/linux.conf \
70 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
70 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
71 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
71 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
72 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
72 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
73 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
73 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
74 /usr/lib64/qt4/mkspecs/qconfig.pri \
74 /usr/lib64/qt4/mkspecs/qconfig.pri \
75 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
75 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
76 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
76 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
77 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
77 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
78 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
78 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
79 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
79 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
80 sparc.pri \
80 sparc.pri \
81 /usr/lib64/qt4/mkspecs/features/release.prf \
81 /usr/lib64/qt4/mkspecs/features/release.prf \
82 /usr/lib64/qt4/mkspecs/features/default_post.prf \
82 /usr/lib64/qt4/mkspecs/features/default_post.prf \
83 /usr/lib64/qt4/mkspecs/features/shared.prf \
83 /usr/lib64/qt4/mkspecs/features/shared.prf \
84 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
84 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
85 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
85 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
86 /usr/lib64/qt4/mkspecs/features/resources.prf \
86 /usr/lib64/qt4/mkspecs/features/resources.prf \
87 /usr/lib64/qt4/mkspecs/features/uic.prf \
87 /usr/lib64/qt4/mkspecs/features/uic.prf \
88 /usr/lib64/qt4/mkspecs/features/yacc.prf \
88 /usr/lib64/qt4/mkspecs/features/yacc.prf \
89 /usr/lib64/qt4/mkspecs/features/lex.prf \
89 /usr/lib64/qt4/mkspecs/features/lex.prf \
90 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
90 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
91 fsw-qt.pro
91 fsw-qt.pro
92 QMAKE_TARGET = fsw
92 QMAKE_TARGET = fsw
93 DESTDIR = bin/
93 DESTDIR = bin/
94 TARGET = bin/fsw
94 TARGET = bin/fsw
95
95
96 first: all
96 first: all
97 ####### Implicit rules
97 ####### Implicit rules
98
98
99 .SUFFIXES: .o .c .cpp .cc .cxx .C
99 .SUFFIXES: .o .c .cpp .cc .cxx .C
100
100
101 .cpp.o:
101 .cpp.o:
102 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
102 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
103
103
104 .cc.o:
104 .cc.o:
105 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
105 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
106
106
107 .cxx.o:
107 .cxx.o:
108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
109
109
110 .C.o:
110 .C.o:
111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
112
112
113 .c.o:
113 .c.o:
114 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
114 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
115
115
116 ####### Build rules
116 ####### Build rules
117
117
118 all: Makefile $(TARGET)
118 all: Makefile $(TARGET)
119
119
120 $(TARGET): $(OBJECTS)
120 $(TARGET): $(OBJECTS)
121 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
121 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
122 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
122 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
123
123
124 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
124 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
125 /usr/lib64/qt4/mkspecs/common/linux.conf \
125 /usr/lib64/qt4/mkspecs/common/linux.conf \
126 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
126 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
127 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
127 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
128 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
128 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
129 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
129 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
130 /usr/lib64/qt4/mkspecs/qconfig.pri \
130 /usr/lib64/qt4/mkspecs/qconfig.pri \
131 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
131 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
132 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
132 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
133 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
133 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
134 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
134 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
135 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
135 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
136 sparc.pri \
136 sparc.pri \
137 /usr/lib64/qt4/mkspecs/features/release.prf \
137 /usr/lib64/qt4/mkspecs/features/release.prf \
138 /usr/lib64/qt4/mkspecs/features/default_post.prf \
138 /usr/lib64/qt4/mkspecs/features/default_post.prf \
139 /usr/lib64/qt4/mkspecs/features/shared.prf \
139 /usr/lib64/qt4/mkspecs/features/shared.prf \
140 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
140 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
141 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
141 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
142 /usr/lib64/qt4/mkspecs/features/resources.prf \
142 /usr/lib64/qt4/mkspecs/features/resources.prf \
143 /usr/lib64/qt4/mkspecs/features/uic.prf \
143 /usr/lib64/qt4/mkspecs/features/uic.prf \
144 /usr/lib64/qt4/mkspecs/features/yacc.prf \
144 /usr/lib64/qt4/mkspecs/features/yacc.prf \
145 /usr/lib64/qt4/mkspecs/features/lex.prf \
145 /usr/lib64/qt4/mkspecs/features/lex.prf \
146 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
146 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
147 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
147 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
148 /usr/lib64/qt4/mkspecs/common/unix.conf:
148 /usr/lib64/qt4/mkspecs/common/unix.conf:
149 /usr/lib64/qt4/mkspecs/common/linux.conf:
149 /usr/lib64/qt4/mkspecs/common/linux.conf:
150 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
150 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
151 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
151 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
152 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
152 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
153 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
153 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
154 /usr/lib64/qt4/mkspecs/qconfig.pri:
154 /usr/lib64/qt4/mkspecs/qconfig.pri:
155 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
155 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
156 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
156 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
157 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
157 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
158 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
158 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
159 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
159 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
160 sparc.pri:
160 sparc.pri:
161 /usr/lib64/qt4/mkspecs/features/release.prf:
161 /usr/lib64/qt4/mkspecs/features/release.prf:
162 /usr/lib64/qt4/mkspecs/features/default_post.prf:
162 /usr/lib64/qt4/mkspecs/features/default_post.prf:
163 /usr/lib64/qt4/mkspecs/features/shared.prf:
163 /usr/lib64/qt4/mkspecs/features/shared.prf:
164 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
164 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
165 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
165 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
166 /usr/lib64/qt4/mkspecs/features/resources.prf:
166 /usr/lib64/qt4/mkspecs/features/resources.prf:
167 /usr/lib64/qt4/mkspecs/features/uic.prf:
167 /usr/lib64/qt4/mkspecs/features/uic.prf:
168 /usr/lib64/qt4/mkspecs/features/yacc.prf:
168 /usr/lib64/qt4/mkspecs/features/yacc.prf:
169 /usr/lib64/qt4/mkspecs/features/lex.prf:
169 /usr/lib64/qt4/mkspecs/features/lex.prf:
170 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
170 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
171 qmake: FORCE
171 qmake: FORCE
172 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
172 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
173
173
174 dist:
174 dist:
175 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
175 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
176 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
176 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
177
177
178
178
179 clean:compiler_clean
179 clean:compiler_clean
180 -$(DEL_FILE) $(OBJECTS)
180 -$(DEL_FILE) $(OBJECTS)
181 -$(DEL_FILE) *~ core *.core
181 -$(DEL_FILE) *~ core *.core
182
182
183
183
184 ####### Sub-libraries
184 ####### Sub-libraries
185
185
186 distclean: clean
186 distclean: clean
187 -$(DEL_FILE) $(TARGET)
187 -$(DEL_FILE) $(TARGET)
188 -$(DEL_FILE) Makefile
188 -$(DEL_FILE) Makefile
189
189
190
190
191 grmon:
191 grmon:
192 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
192 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
193
193
194 check: first
194 check: first
195
195
196 compiler_rcc_make_all:
196 compiler_rcc_make_all:
197 compiler_rcc_clean:
197 compiler_rcc_clean:
198 compiler_uic_make_all:
198 compiler_uic_make_all:
199 compiler_uic_clean:
199 compiler_uic_clean:
200 compiler_image_collection_make_all: qmake_image_collection.cpp
200 compiler_image_collection_make_all: qmake_image_collection.cpp
201 compiler_image_collection_clean:
201 compiler_image_collection_clean:
202 -$(DEL_FILE) qmake_image_collection.cpp
202 -$(DEL_FILE) qmake_image_collection.cpp
203 compiler_yacc_decl_make_all:
203 compiler_yacc_decl_make_all:
204 compiler_yacc_decl_clean:
204 compiler_yacc_decl_clean:
205 compiler_yacc_impl_make_all:
205 compiler_yacc_impl_make_all:
206 compiler_yacc_impl_clean:
206 compiler_yacc_impl_clean:
207 compiler_lex_make_all:
207 compiler_lex_make_all:
208 compiler_lex_clean:
208 compiler_lex_clean:
209 compiler_clean:
209 compiler_clean:
210
210
211 ####### Compile
211 ####### Compile
212
212
213 obj/wf_handler.o: ../src/wf_handler.c
213 obj/wf_handler.o: ../src/wf_handler.c
214 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
214 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
215
215
216 obj/tc_handler.o: ../src/tc_handler.c
216 obj/tc_handler.o: ../src/tc_handler.c
217 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
217 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
218
218
219 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
219 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
221
221
222 obj/fsw_misc.o: ../src/fsw_misc.c
222 obj/fsw_misc.o: ../src/fsw_misc.c
223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
224
224
225 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
225 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
227
227
228 obj/fsw_globals.o: ../src/fsw_globals.c
228 obj/fsw_globals.o: ../src/fsw_globals.c
229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
230
230
231 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
231 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
233
233
234 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
234 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
236
236
237 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
237 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
239
239
240 obj/tc_acceptance.o: ../src/tc_acceptance.c
240 obj/tc_acceptance.o: ../src/tc_acceptance.c
241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
242
242
243 obj/basic_parameters.o: ../../LFR_basic-parameters/basic_parameters.c ../../LFR_basic-parameters/basic_parameters.h
243 obj/basic_parameters.o: ../../LFR_basic-parameters/basic_parameters.c ../../LFR_basic-parameters/basic_parameters.h
244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../../LFR_basic-parameters/basic_parameters.c
244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../../LFR_basic-parameters/basic_parameters.c
245
245
246 ####### Install
246 ####### Install
247
247
248 install: FORCE
248 install: FORCE
249
249
250 uninstall: FORCE
250 uninstall: FORCE
251
251
252 FORCE:
252 FORCE:
253
253
@@ -1,6 +1,9
1 #!/usr/bin/lppmon -e
1 #!/usr/bin/lppmon -e
2
2
3 RMAPPlugin0.setValueSpaceWireLinkNumber( 1 )
4 RMAPPlugin0.setValueTargetLogicalAddress( 254 )
5
3 dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw")
6 dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw")
4 dsu3plugin0.loadFile()
7 dsu3plugin0.loadFile()
5 dsu3plugin0.run()
8 dsu3plugin0.run()
6
9
@@ -1,81 +1,85
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 CONFIG += console verbose debug_messages
4 CONFIG += console verbose vhdl_dev
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
8
8
9 # flight software version
9 # flight software version
10 SWVERSION=-1-0
10 SWVERSION=-1-0
11 DEFINES += SW_VERSION_N1=1 # major
11 DEFINES += SW_VERSION_N1=1 # major
12 DEFINES += SW_VERSION_N2=0 # minor
12 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N3=0 # patch
13 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N4=3 # internal
14 DEFINES += SW_VERSION_N4=3 # internal
15
15
16 contains( CONFIG, debug_tch ) {
17 DEFINES += DEBUG_TCH
18 }
19
16 contains( CONFIG, vhdl_dev ) {
20 contains( CONFIG, vhdl_dev ) {
17 DEFINES += VHDL_DEV
21 DEFINES += VHDL_DEV
18 }
22 }
19
23
20 contains( CONFIG, verbose ) {
24 contains( CONFIG, verbose ) {
21 DEFINES += PRINT_MESSAGES_ON_CONSOLE
25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
22 }
26 }
23
27
24 contains( CONFIG, debug_messages ) {
28 contains( CONFIG, debug_messages ) {
25 DEFINES += DEBUG_MESSAGES
29 DEFINES += DEBUG_MESSAGES
26 }
30 }
27
31
28 contains( CONFIG, cpu_usage_report ) {
32 contains( CONFIG, cpu_usage_report ) {
29 DEFINES += PRINT_TASK_STATISTICS
33 DEFINES += PRINT_TASK_STATISTICS
30 }
34 }
31
35
32 contains( CONFIG, stack_report ) {
36 contains( CONFIG, stack_report ) {
33 DEFINES += PRINT_STACK_REPORT
37 DEFINES += PRINT_STACK_REPORT
34 }
38 }
35
39
36 contains( CONFIG, boot_messages ) {
40 contains( CONFIG, boot_messages ) {
37 DEFINES += BOOT_MESSAGES
41 DEFINES += BOOT_MESSAGES
38 }
42 }
39
43
40 #doxygen.target = doxygen
44 #doxygen.target = doxygen
41 #doxygen.commands = doxygen ../doc/Doxyfile
45 #doxygen.commands = doxygen ../doc/Doxyfile
42 #QMAKE_EXTRA_TARGETS += doxygen
46 #QMAKE_EXTRA_TARGETS += doxygen
43
47
44 TARGET = fsw
48 TARGET = fsw
45
49
46 INCLUDEPATH += \
50 INCLUDEPATH += \
47 ../src \
51 ../src \
48 ../header \
52 ../header \
49 ../../LFR_basic-parameters
53 ../../LFR_basic-parameters
50
54
51 SOURCES += \
55 SOURCES += \
52 ../src/wf_handler.c \
56 ../src/wf_handler.c \
53 ../src/tc_handler.c \
57 ../src/tc_handler.c \
54 ../src/fsw_processing.c \
58 ../src/fsw_processing.c \
55 ../src/fsw_misc.c \
59 ../src/fsw_misc.c \
56 ../src/fsw_init.c \
60 ../src/fsw_init.c \
57 ../src/fsw_globals.c \
61 ../src/fsw_globals.c \
58 ../src/fsw_spacewire.c \
62 ../src/fsw_spacewire.c \
59 ../src/tc_load_dump_parameters.c \
63 ../src/tc_load_dump_parameters.c \
60 ../src/tm_lfr_tc_exe.c \
64 ../src/tm_lfr_tc_exe.c \
61 ../src/tc_acceptance.c \
65 ../src/tc_acceptance.c \
62 ../../LFR_basic-parameters/basic_parameters.c
66 ../../LFR_basic-parameters/basic_parameters.c
63
67
64
68
65 HEADERS += \
69 HEADERS += \
66 ../header/wf_handler.h \
70 ../header/wf_handler.h \
67 ../header/tc_handler.h \
71 ../header/tc_handler.h \
68 ../header/grlib_regs.h \
72 ../header/grlib_regs.h \
69 ../header/fsw_processing.h \
73 ../header/fsw_processing.h \
70 ../header/fsw_params.h \
74 ../header/fsw_params.h \
71 ../header/fsw_misc.h \
75 ../header/fsw_misc.h \
72 ../header/fsw_init.h \
76 ../header/fsw_init.h \
73 ../header/ccsds_types.h \
77 ../header/ccsds_types.h \
74 ../header/fsw_params_processing.h \
78 ../header/fsw_params_processing.h \
75 ../header/fsw_spacewire.h \
79 ../header/fsw_spacewire.h \
76 ../header/tc_load_dump_parameters.h \
80 ../header/tc_load_dump_parameters.h \
77 ../header/tm_lfr_tc_exe.h \
81 ../header/tm_lfr_tc_exe.h \
78 ../header/tc_acceptance.h \
82 ../header/tc_acceptance.h \
79 ../header/fsw_params_nb_bytes.h \
83 ../header/fsw_params_nb_bytes.h \
80 ../../LFR_basic-parameters/basic_parameters.h
84 ../../LFR_basic-parameters/basic_parameters.h
81
85
@@ -1,339 +1,339
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-03-13T15:53:26. -->
3 <!-- Written by QtCreator 3.0.1, 2014-03-25T08:40:48. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 <value type="int">1</value>
7 <value type="int">1</value>
8 </data>
8 </data>
9 <data>
9 <data>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 <valuemap type="QVariantMap">
11 <valuemap type="QVariantMap">
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 <value type="QString" key="language">Cpp</value>
16 <value type="QString" key="language">Cpp</value>
17 <valuemap type="QVariantMap" key="value">
17 <valuemap type="QVariantMap" key="value">
18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 </valuemap>
19 </valuemap>
20 </valuemap>
20 </valuemap>
21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 <value type="QString" key="language">QmlJS</value>
22 <value type="QString" key="language">QmlJS</value>
23 <valuemap type="QVariantMap" key="value">
23 <valuemap type="QVariantMap" key="value">
24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 </valuemap>
25 </valuemap>
26 </valuemap>
26 </valuemap>
27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 <value type="int" key="EditorConfiguration.TabSize">8</value>
38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 </valuemap>
45 </valuemap>
46 </data>
46 </data>
47 <data>
47 <data>
48 <variable>ProjectExplorer.Project.PluginSettings</variable>
48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 <valuemap type="QVariantMap"/>
49 <valuemap type="QVariantMap"/>
50 </data>
50 </data>
51 <data>
51 <data>
52 <variable>ProjectExplorer.Project.Target.0</variable>
52 <variable>ProjectExplorer.Project.Target.0</variable>
53 <valuemap type="QVariantMap">
53 <valuemap type="QVariantMap">
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e04e3924-0bd8-4708-be18-f1474e45608e}</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e04e3924-0bd8-4708-be18-f1474e45608e}</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 </valuemap>
72 </valuemap>
73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 <value type="QString">-w</value>
79 <value type="QString">-w</value>
80 <value type="QString">-r</value>
80 <value type="QString">-r</value>
81 </valuelist>
81 </valuelist>
82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 </valuemap>
85 </valuemap>
86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 </valuemap>
90 </valuemap>
91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 <value type="QString">-w</value>
98 <value type="QString">-w</value>
99 <value type="QString">-r</value>
99 <value type="QString">-r</value>
100 </valuelist>
100 </valuelist>
101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 </valuemap>
104 </valuemap>
105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 </valuemap>
109 </valuemap>
110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118 </valuemap>
118 </valuemap>
119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
126 </valuemap>
126 </valuemap>
127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
131 </valuemap>
131 </valuemap>
132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
153 <value type="int">0</value>
153 <value type="int">0</value>
154 <value type="int">1</value>
154 <value type="int">1</value>
155 <value type="int">2</value>
155 <value type="int">2</value>
156 <value type="int">3</value>
156 <value type="int">3</value>
157 <value type="int">4</value>
157 <value type="int">4</value>
158 <value type="int">5</value>
158 <value type="int">5</value>
159 <value type="int">6</value>
159 <value type="int">6</value>
160 <value type="int">7</value>
160 <value type="int">7</value>
161 <value type="int">8</value>
161 <value type="int">8</value>
162 <value type="int">9</value>
162 <value type="int">9</value>
163 <value type="int">10</value>
163 <value type="int">10</value>
164 <value type="int">11</value>
164 <value type="int">11</value>
165 <value type="int">12</value>
165 <value type="int">12</value>
166 <value type="int">13</value>
166 <value type="int">13</value>
167 <value type="int">14</value>
167 <value type="int">14</value>
168 </valuelist>
168 </valuelist>
169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
180 <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
180 <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
185 </valuemap>
185 </valuemap>
186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
187 </valuemap>
187 </valuemap>
188 </data>
188 </data>
189 <data>
189 <data>
190 <variable>ProjectExplorer.Project.Target.1</variable>
190 <variable>ProjectExplorer.Project.Target.1</variable>
191 <valuemap type="QVariantMap">
191 <valuemap type="QVariantMap">
192 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
192 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
193 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
193 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
194 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
194 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
195 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
195 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
196 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
196 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
197 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
197 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
198 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
198 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
199 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
199 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
200 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
200 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
201 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
201 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
202 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
202 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
203 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
203 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
204 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
204 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
205 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
205 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
206 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
206 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
207 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
207 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
208 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
208 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
209 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
209 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
210 </valuemap>
210 </valuemap>
211 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
211 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
212 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
212 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
213 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
213 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
214 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
214 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
215 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
215 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
216 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
216 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
217 <value type="QString">-w</value>
217 <value type="QString">-w</value>
218 <value type="QString">-r</value>
218 <value type="QString">-r</value>
219 </valuelist>
219 </valuelist>
220 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
220 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
221 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
221 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
222 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
222 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
223 </valuemap>
223 </valuemap>
224 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
224 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
225 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
225 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
226 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
226 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
228 </valuemap>
228 </valuemap>
229 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
229 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
230 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
230 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
231 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
231 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
232 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
232 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
233 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
233 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
234 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
234 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
235 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
235 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
236 <value type="QString">-w</value>
236 <value type="QString">-w</value>
237 <value type="QString">-r</value>
237 <value type="QString">-r</value>
238 </valuelist>
238 </valuelist>
239 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
239 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
240 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
240 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
241 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
241 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
242 </valuemap>
242 </valuemap>
243 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
243 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
244 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
244 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
245 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
245 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
246 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
246 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
247 </valuemap>
247 </valuemap>
248 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
248 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
249 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
249 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
250 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
250 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
251 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
251 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
252 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
252 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
253 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
253 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
254 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
254 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
255 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
255 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
256 </valuemap>
256 </valuemap>
257 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
257 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
258 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
258 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
259 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
259 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
260 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
260 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
261 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
261 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
262 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
262 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
263 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
263 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
264 </valuemap>
264 </valuemap>
265 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
265 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
266 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
266 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
267 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
267 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
268 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
268 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
269 </valuemap>
269 </valuemap>
270 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
270 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
271 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
271 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
272 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
272 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
273 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
273 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
274 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
274 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
275 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
275 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
276 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
276 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
277 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
277 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
278 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
278 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
279 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
279 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
280 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
280 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
281 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
281 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
282 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
282 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
283 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
283 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
284 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
284 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
285 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
285 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
286 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
286 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
287 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
287 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
288 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
288 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
289 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
289 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
290 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
290 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
291 <value type="int">0</value>
291 <value type="int">0</value>
292 <value type="int">1</value>
292 <value type="int">1</value>
293 <value type="int">2</value>
293 <value type="int">2</value>
294 <value type="int">3</value>
294 <value type="int">3</value>
295 <value type="int">4</value>
295 <value type="int">4</value>
296 <value type="int">5</value>
296 <value type="int">5</value>
297 <value type="int">6</value>
297 <value type="int">6</value>
298 <value type="int">7</value>
298 <value type="int">7</value>
299 <value type="int">8</value>
299 <value type="int">8</value>
300 <value type="int">9</value>
300 <value type="int">9</value>
301 <value type="int">10</value>
301 <value type="int">10</value>
302 <value type="int">11</value>
302 <value type="int">11</value>
303 <value type="int">12</value>
303 <value type="int">12</value>
304 <value type="int">13</value>
304 <value type="int">13</value>
305 <value type="int">14</value>
305 <value type="int">14</value>
306 </valuelist>
306 </valuelist>
307 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
307 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
308 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
308 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
309 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
309 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
310 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
310 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
311 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
311 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
312 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
312 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
313 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
313 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
314 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
314 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
315 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
315 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
316 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
316 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
317 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
317 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
318 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
318 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
319 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
319 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
320 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
320 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
321 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
321 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
322 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
322 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
323 </valuemap>
323 </valuemap>
324 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
324 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
325 </valuemap>
325 </valuemap>
326 </data>
326 </data>
327 <data>
327 <data>
328 <variable>ProjectExplorer.Project.TargetCount</variable>
328 <variable>ProjectExplorer.Project.TargetCount</variable>
329 <value type="int">2</value>
329 <value type="int">2</value>
330 </data>
330 </data>
331 <data>
331 <data>
332 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
332 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
333 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
333 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
334 </data>
334 </data>
335 <data>
335 <data>
336 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
336 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
337 <value type="int">15</value>
337 <value type="int">15</value>
338 </data>
338 </data>
339 </qtcreator>
339 </qtcreator>
@@ -1,609 +1,610
1 #ifndef CCSDS_TYPES_H_INCLUDED
1 #ifndef CCSDS_TYPES_H_INCLUDED
2 #define CCSDS_TYPES_H_INCLUDED
2 #define CCSDS_TYPES_H_INCLUDED
3
3
4 #include "fsw_params_processing.h"
4 #include "fsw_params_processing.h"
5
5
6 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
6 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
7 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
7 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
8 #define CCSDS_TM_PKT_MAX_SIZE 4412
8 #define CCSDS_TM_PKT_MAX_SIZE 4412
9 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
9 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
10 #define CCSDS_TC_PKT_MAX_SIZE 256
10 #define CCSDS_TC_PKT_MAX_SIZE 256
11 #define CCSDS_TC_PKT_MIN_SIZE 16
11 #define CCSDS_TC_PKT_MIN_SIZE 16
12 #define CCSDS_TC_TM_PACKET_OFFSET 7
12 #define CCSDS_TC_TM_PACKET_OFFSET 7
13 #define CCSDS_PROCESS_ID 76
13 #define CCSDS_PROCESS_ID 76
14 #define CCSDS_PACKET_CATEGORY 12
14 #define CCSDS_PACKET_CATEGORY 12
15 #define CCSDS_NODE_ADDRESS 0xfe
15 #define CCSDS_NODE_ADDRESS 0xfe
16 #define CCSDS_USER_APP 0x00
16 #define CCSDS_USER_APP 0x00
17
17
18 #define DEFAULT_SPARE1_PUSVERSION_SPARE2 0x10
18 #define DEFAULT_SPARE1_PUSVERSION_SPARE2 0x10
19 #define DEFAULT_RESERVED 0x00
19 #define DEFAULT_RESERVED 0x00
20 #define DEFAULT_HKBIA 0x1e // 0001 1110
20 #define DEFAULT_HKBIA 0x1e // 0001 1110
21
21
22 // PACKET ID
22 // PACKET ID
23 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
23 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
24 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
24 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
25 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
25 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
26 #define TM_PACKET_ID_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
26 #define TM_PACKET_ID_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
27 #define TM_PACKET_ID_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
27 #define TM_PACKET_ID_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
28 #define TM_PACKET_PID_DEFAULT 76
28 #define TM_PACKET_PID_DEFAULT 76
29 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
29 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
30 #define TM_PACKET_CAT_TC_EXE 1
30 #define TM_PACKET_CAT_TC_EXE 1
31 #define TM_PACKET_CAT_HK 4
31 #define TM_PACKET_CAT_HK 4
32 #define TM_PACKET_CAT_PARAMETER_DUMP 9
32 #define TM_PACKET_CAT_PARAMETER_DUMP 9
33 #define TM_PACKET_CAT_SCIENCE 12
33 #define TM_PACKET_CAT_SCIENCE 12
34 #define TC_PACKET_CAT 12
34
35
35 // PACKET SEQUENCE CONTROL
36 // PACKET SEQUENCE CONTROL
36 #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000]
37 #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000]
37 #define TM_PACKET_SEQ_CTRL_FIRST 0x40 // [0100 0000]
38 #define TM_PACKET_SEQ_CTRL_FIRST 0x40 // [0100 0000]
38 #define TM_PACKET_SEQ_CTRL_LAST 0x80 // [1000 0000]
39 #define TM_PACKET_SEQ_CTRL_LAST 0x80 // [1000 0000]
39 #define TM_PACKET_SEQ_CTRL_STANDALONE 0xc0 // [1100 0000]
40 #define TM_PACKET_SEQ_CTRL_STANDALONE 0xc0 // [1100 0000]
40 #define TM_PACKET_SEQ_CNT_DEFAULT 0x00 // [0000 0000]
41 #define TM_PACKET_SEQ_CNT_DEFAULT 0x00 // [0000 0000]
41
42
42 // DESTINATION ID
43 // DESTINATION ID
43 #define TM_DESTINATION_ID_GROUND 0
44 #define TM_DESTINATION_ID_GROUND 0
44 #define TM_DESTINATION_ID_MISSION_TIMELINE 110
45 #define TM_DESTINATION_ID_MISSION_TIMELINE 110
45 #define TM_DESTINATION_ID_TC_SEQUENCES 111
46 #define TM_DESTINATION_ID_TC_SEQUENCES 111
46 #define TM_DESTINATION_ID_RECOVERY_ACTION_COMMAND 112
47 #define TM_DESTINATION_ID_RECOVERY_ACTION_COMMAND 112
47 #define TM_DESTINATION_ID_BACKUP_MISSION_TIMELINE 113
48 #define TM_DESTINATION_ID_BACKUP_MISSION_TIMELINE 113
48 #define TM_DESTINATION_ID_DIRECT_CMD 120
49 #define TM_DESTINATION_ID_DIRECT_CMD 120
49 #define TM_DESTINATION_ID_SPARE_GRD_SRC1 121
50 #define TM_DESTINATION_ID_SPARE_GRD_SRC1 121
50 #define TM_DESTINATION_ID_SPARE_GRD_SRC2 122
51 #define TM_DESTINATION_ID_SPARE_GRD_SRC2 122
51 #define TM_DESTINATION_ID_OBCP 15
52 #define TM_DESTINATION_ID_OBCP 15
52 #define TM_DESTINATION_ID_SYSTEM_CONTROL 14
53 #define TM_DESTINATION_ID_SYSTEM_CONTROL 14
53 #define TM_DESTINATION_ID_AOCS 11
54 #define TM_DESTINATION_ID_AOCS 11
54
55
55 #define CCSDS_DESTINATION_ID 0x01
56 #define CCSDS_DESTINATION_ID 0x01
56 #define CCSDS_PROTOCOLE_ID 0x02
57 #define CCSDS_PROTOCOLE_ID 0x02
57 #define CCSDS_RESERVED 0x00
58 #define CCSDS_RESERVED 0x00
58 #define CCSDS_USER_APP 0x00
59 #define CCSDS_USER_APP 0x00
59
60
60 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
61 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
61 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
62 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
62 #define SIZE_HK_PARAMETERS 112
63 #define SIZE_HK_PARAMETERS 112
63
64
64 // TC TYPES
65 // TC TYPES
65 #define TC_TYPE_GEN 181
66 #define TC_TYPE_GEN 181
66 #define TC_TYPE_TIME 9
67 #define TC_TYPE_TIME 9
67
68
68 // TC SUBTYPES
69 // TC SUBTYPES
69 #define TC_SUBTYPE_RESET 1
70 #define TC_SUBTYPE_RESET 1
70 #define TC_SUBTYPE_LOAD_COMM 11
71 #define TC_SUBTYPE_LOAD_COMM 11
71 #define TC_SUBTYPE_LOAD_NORM 13
72 #define TC_SUBTYPE_LOAD_NORM 13
72 #define TC_SUBTYPE_LOAD_BURST 19
73 #define TC_SUBTYPE_LOAD_BURST 19
73 #define TC_SUBTYPE_LOAD_SBM1 25
74 #define TC_SUBTYPE_LOAD_SBM1 25
74 #define TC_SUBTYPE_LOAD_SBM2 27
75 #define TC_SUBTYPE_LOAD_SBM2 27
75 #define TC_SUBTYPE_DUMP 31
76 #define TC_SUBTYPE_DUMP 31
76 #define TC_SUBTYPE_ENTER 41
77 #define TC_SUBTYPE_ENTER 41
77 #define TC_SUBTYPE_UPDT_INFO 51
78 #define TC_SUBTYPE_UPDT_INFO 51
78 #define TC_SUBTYPE_EN_CAL 61
79 #define TC_SUBTYPE_EN_CAL 61
79 #define TC_SUBTYPE_DIS_CAL 63
80 #define TC_SUBTYPE_DIS_CAL 63
80 #define TC_SUBTYPE_UPDT_TIME 129
81 #define TC_SUBTYPE_UPDT_TIME 129
81
82
82 // TC LEN
83 // TC LEN
83 #define TC_LEN_RESET 12
84 #define TC_LEN_RESET 12
84 #define TC_LEN_LOAD_COMM 14
85 #define TC_LEN_LOAD_COMM 14
85 #define TC_LEN_LOAD_NORM 22
86 #define TC_LEN_LOAD_NORM 22
86 #define TC_LEN_LOAD_BURST 14
87 #define TC_LEN_LOAD_BURST 14
87 #define TC_LEN_LOAD_SBM1 14
88 #define TC_LEN_LOAD_SBM1 14
88 #define TC_LEN_LOAD_SBM2 14
89 #define TC_LEN_LOAD_SBM2 14
89 #define TC_LEN_DUMP 12
90 #define TC_LEN_DUMP 12
90 #define TC_LEN_ENTER 20
91 #define TC_LEN_ENTER 20
91 #define TC_LEN_UPDT_INFO 46
92 #define TC_LEN_UPDT_INFO 46
92 #define TC_LEN_EN_CAL 12
93 #define TC_LEN_EN_CAL 12
93 #define TC_LEN_DIS_CAL 12
94 #define TC_LEN_DIS_CAL 12
94 #define TC_LEN_UPDT_TIME 18
95 #define TC_LEN_UPDT_TIME 18
95
96
96 // TM TYPES
97 // TM TYPES
97 #define TM_TYPE_TC_EXE 1
98 #define TM_TYPE_TC_EXE 1
98 #define TM_TYPE_HK 3
99 #define TM_TYPE_HK 3
99 #define TM_TYPE_PARAMETER_DUMP 3
100 #define TM_TYPE_PARAMETER_DUMP 3
100 #define TM_TYPE_LFR_SCIENCE 21
101 #define TM_TYPE_LFR_SCIENCE 21
101
102
102 // TM SUBTYPES
103 // TM SUBTYPES
103 #define TM_SUBTYPE_EXE_OK 7
104 #define TM_SUBTYPE_EXE_OK 7
104 #define TM_SUBTYPE_EXE_NOK 8
105 #define TM_SUBTYPE_EXE_NOK 8
105 #define TM_SUBTYPE_HK 25
106 #define TM_SUBTYPE_HK 25
106 #define TM_SUBTYPE_PARAMETER_DUMP 25
107 #define TM_SUBTYPE_PARAMETER_DUMP 25
107 #define TM_SUBTYPE_SCIENCE 3
108 #define TM_SUBTYPE_SCIENCE 3
108 #define TM_SUBTYPE_LFR_SCIENCE 3
109 #define TM_SUBTYPE_LFR_SCIENCE 3
109
110
110 // FAILURE CODES
111 // FAILURE CODES
111 #define ILLEGAL_APID 0
112 #define ILLEGAL_APID 0
112 #define WRONG_LEN_PKT 1
113 #define WRONG_LEN_PKT 1
113 #define INCOR_CHECKSUM 2
114 #define INCOR_CHECKSUM 2
114 #define ILL_TYPE 3
115 #define ILL_TYPE 3
115 #define ILL_SUBTYPE 4
116 #define ILL_SUBTYPE 4
116 #define WRONG_APP_DATA 5 // 0x00 0x05
117 #define WRONG_APP_DATA 5 // 0x00 0x05
117 #define TC_NOT_EXE 42000 // 0xa4 0x10
118 #define TC_NOT_EXE 42000 // 0xa4 0x10
118 #define WRONG_SRC_ID 42001 // 0xa4 0x11
119 #define WRONG_SRC_ID 42001 // 0xa4 0x11
119 #define FUNCT_NOT_IMPL 42002 // 0xa4 0x12
120 #define FUNCT_NOT_IMPL 42002 // 0xa4 0x12
120 #define FAIL_DETECTED 42003 // 0xa4 0x13
121 #define FAIL_DETECTED 42003 // 0xa4 0x13
121 #define NOT_ALLOWED 42004 // 0xa4 0x14
122 #define NOT_ALLOWED 42004 // 0xa4 0x14
122 #define CORRUPTED 42005 // 0xa4 0x15
123 #define CORRUPTED 42005 // 0xa4 0x15
123 #define CCSDS_TM_VALID 7
124 #define CCSDS_TM_VALID 7
124
125
125 // TC SID
126 // TC SID
126 #define SID_TC_GROUND 0
127 #define SID_TC_GROUND 0
127 #define SID_TC_MISSION_TIMELINE 110
128 #define SID_TC_MISSION_TIMELINE 110
128 #define SID_TC_TC_SEQUENCES 111
129 #define SID_TC_TC_SEQUENCES 111
129 #define SID_TC_RECOVERY_ACTION_CMD 112
130 #define SID_TC_RECOVERY_ACTION_CMD 112
130 #define SID_TC_BACKUP_MISSION_TIMELINE 113
131 #define SID_TC_BACKUP_MISSION_TIMELINE 113
131 #define SID_TC_DIRECT_CMD 120
132 #define SID_TC_DIRECT_CMD 120
132 #define SID_TC_SPARE_GRD_SRC1 121
133 #define SID_TC_SPARE_GRD_SRC1 121
133 #define SID_TC_SPARE_GRD_SRC2 122
134 #define SID_TC_SPARE_GRD_SRC2 122
134 #define SID_TC_OBCP 15
135 #define SID_TC_OBCP 15
135 #define SID_TC_SYSTEM_CONTROL 14
136 #define SID_TC_SYSTEM_CONTROL 14
136 #define SID_TC_AOCS 11
137 #define SID_TC_AOCS 11
137 #define SID_TC_RPW_INTERNAL 254
138 #define SID_TC_RPW_INTERNAL 254
138
139
139 enum apid_destid{
140 enum apid_destid{
140 GROUND,
141 GROUND,
141 MISSION_TIMELINE,
142 MISSION_TIMELINE,
142 TC_SEQUENCES,
143 TC_SEQUENCES,
143 RECOVERY_ACTION_CMD,
144 RECOVERY_ACTION_CMD,
144 BACKUP_MISSION_TIMELINE,
145 BACKUP_MISSION_TIMELINE,
145 DIRECT_CMD,
146 DIRECT_CMD,
146 SPARE_GRD_SRC1,
147 SPARE_GRD_SRC1,
147 SPARE_GRD_SRC2,
148 SPARE_GRD_SRC2,
148 OBCP,
149 OBCP,
149 SYSTEM_CONTROL,
150 SYSTEM_CONTROL,
150 AOCS,
151 AOCS,
151 RPW_INTERNAL
152 RPW_INTERNAL
152 };
153 };
153 // SEQUENCE COUNTERS
154 // SEQUENCE COUNTERS
154 #define SEQ_CNT_MAX 16383
155 #define SEQ_CNT_MAX 16383
155 #define SEQ_CNT_NB_DEST_ID 12
156 #define SEQ_CNT_NB_DEST_ID 12
156
157
157 // TM SID
158 // TM SID
158 #define SID_HK 1
159 #define SID_HK 1
159 #define SID_PARAMETER_DUMP 10
160 #define SID_PARAMETER_DUMP 10
160
161
161 #define SID_NORM_SWF_F0 3
162 #define SID_NORM_SWF_F0 3
162 #define SID_NORM_SWF_F1 4
163 #define SID_NORM_SWF_F1 4
163 #define SID_NORM_SWF_F2 5
164 #define SID_NORM_SWF_F2 5
164 #define SID_NORM_CWF_F3 1
165 #define SID_NORM_CWF_F3 1
165 #define SID_BURST_CWF_F2 2
166 #define SID_BURST_CWF_F2 2
166 #define SID_SBM1_CWF_F1 24
167 #define SID_SBM1_CWF_F1 24
167 #define SID_SBM2_CWF_F2 25
168 #define SID_SBM2_CWF_F2 25
168 #define SID_NORM_ASM_F0 11
169 #define SID_NORM_ASM_F0 11
169 #define SID_NORM_ASM_F1 12
170 #define SID_NORM_ASM_F1 12
170 #define SID_NORM_ASM_F2 13
171 #define SID_NORM_ASM_F2 13
171 #define SID_NORM_BP1_F0 14
172 #define SID_NORM_BP1_F0 14
172 #define SID_NORM_BP1_F1 15
173 #define SID_NORM_BP1_F1 15
173 #define SID_NORM_BP1_F2 16
174 #define SID_NORM_BP1_F2 16
174 #define SID_NORM_BP2_F0 19
175 #define SID_NORM_BP2_F0 19
175 #define SID_NORM_BP2_F1 20
176 #define SID_NORM_BP2_F1 20
176 #define SID_NORM_BP2_F2 21
177 #define SID_NORM_BP2_F2 21
177 #define SID_BURST_BP1_F0 17
178 #define SID_BURST_BP1_F0 17
178 #define SID_BURST_BP2_F0 22
179 #define SID_BURST_BP2_F0 22
179 #define SID_BURST_BP1_F1 18
180 #define SID_BURST_BP1_F1 18
180 #define SID_BURST_BP2_F1 23
181 #define SID_BURST_BP2_F1 23
181 #define SID_SBM1_BP1_F0 28
182 #define SID_SBM1_BP1_F0 28
182 #define SID_SBM1_BP2_F0 31
183 #define SID_SBM1_BP2_F0 31
183 #define SID_SBM2_BP1_F0 29
184 #define SID_SBM2_BP1_F0 29
184 #define SID_SBM2_BP2_F0 32
185 #define SID_SBM2_BP2_F0 32
185 #define SID_SBM2_BP1_F1 30
186 #define SID_SBM2_BP1_F1 30
186 #define SID_SBM2_BP2_F1 33
187 #define SID_SBM2_BP2_F1 33
187 #define SID_NORM_CWF_LONG_F3 34
188 #define SID_NORM_CWF_LONG_F3 34
188
189
189 // LENGTH (BYTES)
190 // LENGTH (BYTES)
190 #define LENGTH_TM_LFR_TC_EXE_MAX 32
191 #define LENGTH_TM_LFR_TC_EXE_MAX 32
191 #define LENGTH_TM_LFR_HK 126
192 #define LENGTH_TM_LFR_HK 126
192
193
193 // HEADER_LENGTH
194 // HEADER_LENGTH
194 #define TM_HEADER_LEN 16
195 #define TM_HEADER_LEN 16
195 #define HEADER_LENGTH_TM_LFR_SCIENCE_ASM 28
196 #define HEADER_LENGTH_TM_LFR_SCIENCE_ASM 28
196 // PACKET_LENGTH
197 // PACKET_LENGTH
197 #define PACKET_LENGTH_TC_EXE_SUCCESS (20 - CCSDS_TC_TM_PACKET_OFFSET)
198 #define PACKET_LENGTH_TC_EXE_SUCCESS (20 - CCSDS_TC_TM_PACKET_OFFSET)
198 #define PACKET_LENGTH_TC_EXE_INCONSISTENT (26 - CCSDS_TC_TM_PACKET_OFFSET)
199 #define PACKET_LENGTH_TC_EXE_INCONSISTENT (26 - CCSDS_TC_TM_PACKET_OFFSET)
199 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE (26 - CCSDS_TC_TM_PACKET_OFFSET)
200 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE (26 - CCSDS_TC_TM_PACKET_OFFSET)
200 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED (24 - CCSDS_TC_TM_PACKET_OFFSET)
201 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED (24 - CCSDS_TC_TM_PACKET_OFFSET)
201 #define PACKET_LENGTH_TC_EXE_ERROR (24 - CCSDS_TC_TM_PACKET_OFFSET)
202 #define PACKET_LENGTH_TC_EXE_ERROR (24 - CCSDS_TC_TM_PACKET_OFFSET)
202 #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET)
203 #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET)
203 #define PACKET_LENGTH_HK (124 - CCSDS_TC_TM_PACKET_OFFSET)
204 #define PACKET_LENGTH_HK (124 - CCSDS_TC_TM_PACKET_OFFSET)
204 #define PACKET_LENGTH_PARAMETER_DUMP (36 - CCSDS_TC_TM_PACKET_OFFSET)
205 #define PACKET_LENGTH_PARAMETER_DUMP (36 - CCSDS_TC_TM_PACKET_OFFSET)
205 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0 2221 // 44 * 25 * 2 + 28 - 7
206 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0 2221 // 44 * 25 * 2 + 28 - 7
206 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 2621 // 52 * 25 * 2 + 28 - 7
207 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 2621 // 52 * 25 * 2 + 28 - 7
207 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2 2421 // 48 * 25 * 2 + 28 - 7
208 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2 2421 // 48 * 25 * 2 + 28 - 7
208
209
209 #define SPARE1_PUSVERSION_SPARE2 0x10
210 #define SPARE1_PUSVERSION_SPARE2 0x10
210
211
211 // R1
212 // R1
212 #define TM_LEN_SCI_SWF_340 4101 // 340 * 12 + 10 + 12 - 1
213 #define TM_LEN_SCI_SWF_340 4101 // 340 * 12 + 10 + 12 - 1
213 #define TM_LEN_SCI_SWF_8 117 // 8 * 12 + 10 + 12 - 1
214 #define TM_LEN_SCI_SWF_8 117 // 8 * 12 + 10 + 12 - 1
214 #define TM_LEN_SCI_CWF_340 4099 // 340 * 12 + 10 + 10 - 1
215 #define TM_LEN_SCI_CWF_340 4099 // 340 * 12 + 10 + 10 - 1
215 #define TM_LEN_SCI_CWF_8 115 // 8 * 12 + 10 + 10 - 1
216 #define TM_LEN_SCI_CWF_8 115 // 8 * 12 + 10 + 10 - 1
216 #define TM_LEN_SCI_CWF3_LIGHT_340 2059 // 340 * 6 + 10 + 10 - 1
217 #define TM_LEN_SCI_CWF3_LIGHT_340 2059 // 340 * 6 + 10 + 10 - 1
217 #define TM_LEN_SCI_CWF3_LIGHT_8 67 // 8 * 6 + 10 + 10 - 1
218 #define TM_LEN_SCI_CWF3_LIGHT_8 67 // 8 * 6 + 10 + 10 - 1
218 // R2
219 // R2
219 #define TM_LEN_SCI_SWF_304 3669 // 304 * 12 + 10 + 12 - 1
220 #define TM_LEN_SCI_SWF_304 3669 // 304 * 12 + 10 + 12 - 1
220 #define TM_LEN_SCI_SWF_224 2709 // 224 * 12 + 10 + 12 - 1
221 #define TM_LEN_SCI_SWF_224 2709 // 224 * 12 + 10 + 12 - 1
221 #define TM_LEN_SCI_CWF_336 4051 // 336 * 12 + 10 + 10 - 1
222 #define TM_LEN_SCI_CWF_336 4051 // 336 * 12 + 10 + 10 - 1
222 #define TM_LEN_SCI_CWF_672 4051 // 672 * 6 + 10 + 10 - 1
223 #define TM_LEN_SCI_CWF_672 4051 // 672 * 6 + 10 + 10 - 1
223 //
224 //
224 #define DEFAULT_PKTCNT 0x07
225 #define DEFAULT_PKTCNT 0x07
225 #define BLK_NR_304 0x0130
226 #define BLK_NR_304 0x0130
226 #define BLK_NR_224 0x00e0
227 #define BLK_NR_224 0x00e0
227 #define BLK_NR_CWF 0x0150 // 336
228 #define BLK_NR_CWF 0x0150 // 336
228 #define BLK_NR_CWF_SHORT_F3 0x02a0 // 672
229 #define BLK_NR_CWF_SHORT_F3 0x02a0 // 672
229
230
230 enum TM_TYPE{
231 enum TM_TYPE{
231 TM_LFR_TC_EXE_OK,
232 TM_LFR_TC_EXE_OK,
232 TM_LFR_TC_EXE_ERR,
233 TM_LFR_TC_EXE_ERR,
233 TM_LFR_HK,
234 TM_LFR_HK,
234 TM_LFR_SCI,
235 TM_LFR_SCI,
235 TM_LFR_SCI_SBM,
236 TM_LFR_SCI_SBM,
236 TM_LFR_PAR_DUMP
237 TM_LFR_PAR_DUMP
237 };
238 };
238
239
239 typedef struct {
240 typedef struct {
240 unsigned char targetLogicalAddress;
241 unsigned char targetLogicalAddress;
241 unsigned char protocolIdentifier;
242 unsigned char protocolIdentifier;
242 unsigned char reserved;
243 unsigned char reserved;
243 unsigned char userApplication;
244 unsigned char userApplication;
244 // PACKET HEADER
245 // PACKET HEADER
245 unsigned char packetID[2];
246 unsigned char packetID[2];
246 unsigned char packetSequenceControl[2];
247 unsigned char packetSequenceControl[2];
247 unsigned char packetLength[2];
248 unsigned char packetLength[2];
248 // DATA FIELD HEADER
249 // DATA FIELD HEADER
249 unsigned char spare1_pusVersion_spare2;
250 unsigned char spare1_pusVersion_spare2;
250 unsigned char serviceType;
251 unsigned char serviceType;
251 unsigned char serviceSubType;
252 unsigned char serviceSubType;
252 unsigned char destinationID;
253 unsigned char destinationID;
253 unsigned char time[6];
254 unsigned char time[6];
254 //
255 //
255 unsigned char telecommand_pkt_id[2];
256 unsigned char telecommand_pkt_id[2];
256 unsigned char pkt_seq_control[2];
257 unsigned char pkt_seq_control[2];
257 } Packet_TM_LFR_TC_EXE_SUCCESS_t;
258 } Packet_TM_LFR_TC_EXE_SUCCESS_t;
258
259
259 typedef struct {
260 typedef struct {
260 unsigned char targetLogicalAddress;
261 unsigned char targetLogicalAddress;
261 unsigned char protocolIdentifier;
262 unsigned char protocolIdentifier;
262 unsigned char reserved;
263 unsigned char reserved;
263 unsigned char userApplication;
264 unsigned char userApplication;
264 // PACKET HEADER
265 // PACKET HEADER
265 unsigned char packetID[2];
266 unsigned char packetID[2];
266 unsigned char packetSequenceControl[2];
267 unsigned char packetSequenceControl[2];
267 unsigned char packetLength[2];
268 unsigned char packetLength[2];
268 // DATA FIELD HEADER
269 // DATA FIELD HEADER
269 unsigned char spare1_pusVersion_spare2;
270 unsigned char spare1_pusVersion_spare2;
270 unsigned char serviceType;
271 unsigned char serviceType;
271 unsigned char serviceSubType;
272 unsigned char serviceSubType;
272 unsigned char destinationID;
273 unsigned char destinationID;
273 unsigned char time[6];
274 unsigned char time[6];
274 //
275 //
275 unsigned char tc_failure_code[2];
276 unsigned char tc_failure_code[2];
276 unsigned char telecommand_pkt_id[2];
277 unsigned char telecommand_pkt_id[2];
277 unsigned char pkt_seq_control[2];
278 unsigned char pkt_seq_control[2];
278 unsigned char tc_service;
279 unsigned char tc_service;
279 unsigned char tc_subtype;
280 unsigned char tc_subtype;
280 unsigned char byte_position;
281 unsigned char byte_position;
281 unsigned char rcv_value;
282 unsigned char rcv_value;
282 } Packet_TM_LFR_TC_EXE_INCONSISTENT_t;
283 } Packet_TM_LFR_TC_EXE_INCONSISTENT_t;
283
284
284 typedef struct {
285 typedef struct {
285 unsigned char targetLogicalAddress;
286 unsigned char targetLogicalAddress;
286 unsigned char protocolIdentifier;
287 unsigned char protocolIdentifier;
287 unsigned char reserved;
288 unsigned char reserved;
288 unsigned char userApplication;
289 unsigned char userApplication;
289 // PACKET HEADER
290 // PACKET HEADER
290 unsigned char packetID[2];
291 unsigned char packetID[2];
291 unsigned char packetSequenceControl[2];
292 unsigned char packetSequenceControl[2];
292 unsigned char packetLength[2];
293 unsigned char packetLength[2];
293 // DATA FIELD HEADER
294 // DATA FIELD HEADER
294 unsigned char spare1_pusVersion_spare2;
295 unsigned char spare1_pusVersion_spare2;
295 unsigned char serviceType;
296 unsigned char serviceType;
296 unsigned char serviceSubType;
297 unsigned char serviceSubType;
297 unsigned char destinationID;
298 unsigned char destinationID;
298 unsigned char time[6];
299 unsigned char time[6];
299 //
300 //
300 unsigned char tc_failure_code[2];
301 unsigned char tc_failure_code[2];
301 unsigned char telecommand_pkt_id[2];
302 unsigned char telecommand_pkt_id[2];
302 unsigned char pkt_seq_control[2];
303 unsigned char pkt_seq_control[2];
303 unsigned char tc_service;
304 unsigned char tc_service;
304 unsigned char tc_subtype;
305 unsigned char tc_subtype;
305 unsigned char lfr_status_word[2];
306 unsigned char lfr_status_word[2];
306 } Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t;
307 } Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t;
307
308
308 typedef struct {
309 typedef struct {
309 unsigned char targetLogicalAddress;
310 unsigned char targetLogicalAddress;
310 unsigned char protocolIdentifier;
311 unsigned char protocolIdentifier;
311 unsigned char reserved;
312 unsigned char reserved;
312 unsigned char userApplication;
313 unsigned char userApplication;
313 // PACKET HEADER
314 // PACKET HEADER
314 unsigned char packetID[2];
315 unsigned char packetID[2];
315 unsigned char packetSequenceControl[2];
316 unsigned char packetSequenceControl[2];
316 unsigned char packetLength[2];
317 unsigned char packetLength[2];
317 // DATA FIELD HEADER
318 // DATA FIELD HEADER
318 unsigned char spare1_pusVersion_spare2;
319 unsigned char spare1_pusVersion_spare2;
319 unsigned char serviceType;
320 unsigned char serviceType;
320 unsigned char serviceSubType;
321 unsigned char serviceSubType;
321 unsigned char destinationID;
322 unsigned char destinationID;
322 unsigned char time[6];
323 unsigned char time[6];
323 //
324 //
324 unsigned char tc_failure_code[2];
325 unsigned char tc_failure_code[2];
325 unsigned char telecommand_pkt_id[2];
326 unsigned char telecommand_pkt_id[2];
326 unsigned char pkt_seq_control[2];
327 unsigned char pkt_seq_control[2];
327 unsigned char tc_service;
328 unsigned char tc_service;
328 unsigned char tc_subtype;
329 unsigned char tc_subtype;
329 } Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t;
330 } Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t;
330
331
331 typedef struct {
332 typedef struct {
332 unsigned char targetLogicalAddress;
333 unsigned char targetLogicalAddress;
333 unsigned char protocolIdentifier;
334 unsigned char protocolIdentifier;
334 unsigned char reserved;
335 unsigned char reserved;
335 unsigned char userApplication;
336 unsigned char userApplication;
336 // PACKET HEADER
337 // PACKET HEADER
337 unsigned char packetID[2];
338 unsigned char packetID[2];
338 unsigned char packetSequenceControl[2];
339 unsigned char packetSequenceControl[2];
339 unsigned char packetLength[2];
340 unsigned char packetLength[2];
340 // DATA FIELD HEADER
341 // DATA FIELD HEADER
341 unsigned char spare1_pusVersion_spare2;
342 unsigned char spare1_pusVersion_spare2;
342 unsigned char serviceType;
343 unsigned char serviceType;
343 unsigned char serviceSubType;
344 unsigned char serviceSubType;
344 unsigned char destinationID;
345 unsigned char destinationID;
345 unsigned char time[6];
346 unsigned char time[6];
346 //
347 //
347 unsigned char tc_failure_code[2];
348 unsigned char tc_failure_code[2];
348 unsigned char telecommand_pkt_id[2];
349 unsigned char telecommand_pkt_id[2];
349 unsigned char pkt_seq_control[2];
350 unsigned char pkt_seq_control[2];
350 unsigned char tc_service;
351 unsigned char tc_service;
351 unsigned char tc_subtype;
352 unsigned char tc_subtype;
352 } Packet_TM_LFR_TC_EXE_ERROR_t;
353 } Packet_TM_LFR_TC_EXE_ERROR_t;
353
354
354 typedef struct {
355 typedef struct {
355 unsigned char targetLogicalAddress;
356 unsigned char targetLogicalAddress;
356 unsigned char protocolIdentifier;
357 unsigned char protocolIdentifier;
357 unsigned char reserved;
358 unsigned char reserved;
358 unsigned char userApplication;
359 unsigned char userApplication;
359 // PACKET HEADER
360 // PACKET HEADER
360 unsigned char packetID[2];
361 unsigned char packetID[2];
361 unsigned char packetSequenceControl[2];
362 unsigned char packetSequenceControl[2];
362 unsigned char packetLength[2];
363 unsigned char packetLength[2];
363 // DATA FIELD HEADER
364 // DATA FIELD HEADER
364 unsigned char spare1_pusVersion_spare2;
365 unsigned char spare1_pusVersion_spare2;
365 unsigned char serviceType;
366 unsigned char serviceType;
366 unsigned char serviceSubType;
367 unsigned char serviceSubType;
367 unsigned char destinationID;
368 unsigned char destinationID;
368 unsigned char time[6];
369 unsigned char time[6];
369 //
370 //
370 unsigned char tc_failure_code[2];
371 unsigned char tc_failure_code[2];
371 unsigned char telecommand_pkt_id[2];
372 unsigned char telecommand_pkt_id[2];
372 unsigned char pkt_seq_control[2];
373 unsigned char pkt_seq_control[2];
373 unsigned char tc_service;
374 unsigned char tc_service;
374 unsigned char tc_subtype;
375 unsigned char tc_subtype;
375 unsigned char pkt_len_rcv_value[2];
376 unsigned char pkt_len_rcv_value[2];
376 unsigned char pkt_datafieldsize_cnt[2];
377 unsigned char pkt_datafieldsize_cnt[2];
377 unsigned char rcv_crc[2];
378 unsigned char rcv_crc[2];
378 unsigned char computed_crc[2];
379 unsigned char computed_crc[2];
379 } Packet_TM_LFR_TC_EXE_CORRUPTED_t;
380 } Packet_TM_LFR_TC_EXE_CORRUPTED_t;
380
381
381 typedef struct {
382 typedef struct {
382 unsigned char targetLogicalAddress;
383 unsigned char targetLogicalAddress;
383 unsigned char protocolIdentifier;
384 unsigned char protocolIdentifier;
384 unsigned char reserved;
385 unsigned char reserved;
385 unsigned char userApplication;
386 unsigned char userApplication;
386 unsigned char packetID[2];
387 unsigned char packetID[2];
387 unsigned char packetSequenceControl[2];
388 unsigned char packetSequenceControl[2];
388 unsigned char packetLength[2];
389 unsigned char packetLength[2];
389 // DATA FIELD HEADER
390 // DATA FIELD HEADER
390 unsigned char spare1_pusVersion_spare2;
391 unsigned char spare1_pusVersion_spare2;
391 unsigned char serviceType;
392 unsigned char serviceType;
392 unsigned char serviceSubType;
393 unsigned char serviceSubType;
393 unsigned char destinationID;
394 unsigned char destinationID;
394 unsigned char time[6];
395 unsigned char time[6];
395 // AUXILIARY HEADER
396 // AUXILIARY HEADER
396 unsigned char sid;
397 unsigned char sid;
397 unsigned char hkBIA;
398 unsigned char hkBIA;
398 unsigned char pktCnt;
399 unsigned char pktCnt;
399 unsigned char pktNr;
400 unsigned char pktNr;
400 unsigned char acquisitionTime[6];
401 unsigned char acquisitionTime[6];
401 unsigned char blkNr[2];
402 unsigned char blkNr[2];
402 } Header_TM_LFR_SCIENCE_SWF_t;
403 } Header_TM_LFR_SCIENCE_SWF_t;
403
404
404 typedef struct {
405 typedef struct {
405 unsigned char targetLogicalAddress;
406 unsigned char targetLogicalAddress;
406 unsigned char protocolIdentifier;
407 unsigned char protocolIdentifier;
407 unsigned char reserved;
408 unsigned char reserved;
408 unsigned char userApplication;
409 unsigned char userApplication;
409 unsigned char packetID[2];
410 unsigned char packetID[2];
410 unsigned char packetSequenceControl[2];
411 unsigned char packetSequenceControl[2];
411 unsigned char packetLength[2];
412 unsigned char packetLength[2];
412 // DATA FIELD HEADER
413 // DATA FIELD HEADER
413 unsigned char spare1_pusVersion_spare2;
414 unsigned char spare1_pusVersion_spare2;
414 unsigned char serviceType;
415 unsigned char serviceType;
415 unsigned char serviceSubType;
416 unsigned char serviceSubType;
416 unsigned char destinationID;
417 unsigned char destinationID;
417 unsigned char time[6];
418 unsigned char time[6];
418 // AUXILIARY DATA HEADER
419 // AUXILIARY DATA HEADER
419 unsigned char sid;
420 unsigned char sid;
420 unsigned char hkBIA;
421 unsigned char hkBIA;
421 unsigned char acquisitionTime[6];
422 unsigned char acquisitionTime[6];
422 unsigned char blkNr[2];
423 unsigned char blkNr[2];
423 } Header_TM_LFR_SCIENCE_CWF_t;
424 } Header_TM_LFR_SCIENCE_CWF_t;
424
425
425 typedef struct {
426 typedef struct {
426 unsigned char targetLogicalAddress;
427 unsigned char targetLogicalAddress;
427 unsigned char protocolIdentifier;
428 unsigned char protocolIdentifier;
428 unsigned char reserved;
429 unsigned char reserved;
429 unsigned char userApplication;
430 unsigned char userApplication;
430 unsigned char packetID[2];
431 unsigned char packetID[2];
431 unsigned char packetSequenceControl[2];
432 unsigned char packetSequenceControl[2];
432 unsigned char packetLength[2];
433 unsigned char packetLength[2];
433 // DATA FIELD HEADER
434 // DATA FIELD HEADER
434 unsigned char spare1_pusVersion_spare2;
435 unsigned char spare1_pusVersion_spare2;
435 unsigned char serviceType;
436 unsigned char serviceType;
436 unsigned char serviceSubType;
437 unsigned char serviceSubType;
437 unsigned char destinationID;
438 unsigned char destinationID;
438 unsigned char time[6];
439 unsigned char time[6];
439 // AUXILIARY HEADER
440 // AUXILIARY HEADER
440 unsigned char sid;
441 unsigned char sid;
441 unsigned char biaStatusInfo;
442 unsigned char biaStatusInfo;
442 unsigned char pa_lfr_pkt_cnt_asm;
443 unsigned char pa_lfr_pkt_cnt_asm;
443 unsigned char pa_lfr_pkt_nr_asm;
444 unsigned char pa_lfr_pkt_nr_asm;
444 unsigned char acquisitionTime[6];
445 unsigned char acquisitionTime[6];
445 unsigned char pa_lfr_asm_blk_nr[2];
446 unsigned char pa_lfr_asm_blk_nr[2];
446 } Header_TM_LFR_SCIENCE_ASM_t;
447 } Header_TM_LFR_SCIENCE_ASM_t;
447
448
448 typedef struct {
449 typedef struct {
449 //targetLogicalAddress is removed by the grspw module
450 //targetLogicalAddress is removed by the grspw module
450 unsigned char protocolIdentifier;
451 unsigned char protocolIdentifier;
451 unsigned char reserved;
452 unsigned char reserved;
452 unsigned char userApplication;
453 unsigned char userApplication;
453 unsigned char packetID[2];
454 unsigned char packetID[2];
454 unsigned char packetSequenceControl[2];
455 unsigned char packetSequenceControl[2];
455 unsigned char packetLength[2];
456 unsigned char packetLength[2];
456 // DATA FIELD HEADER
457 // DATA FIELD HEADER
457 unsigned char headerFlag_pusVersion_Ack;
458 unsigned char headerFlag_pusVersion_Ack;
458 unsigned char serviceType;
459 unsigned char serviceType;
459 unsigned char serviceSubType;
460 unsigned char serviceSubType;
460 unsigned char sourceID;
461 unsigned char sourceID;
461 unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
462 unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
462 } ccsdsTelecommandPacket_t;
463 } ccsdsTelecommandPacket_t;
463
464
464 typedef struct {
465 typedef struct {
465 unsigned char targetLogicalAddress;
466 unsigned char targetLogicalAddress;
466 unsigned char protocolIdentifier;
467 unsigned char protocolIdentifier;
467 unsigned char reserved;
468 unsigned char reserved;
468 unsigned char userApplication;
469 unsigned char userApplication;
469 unsigned char packetID[2];
470 unsigned char packetID[2];
470 unsigned char packetSequenceControl[2];
471 unsigned char packetSequenceControl[2];
471 unsigned char packetLength[2];
472 unsigned char packetLength[2];
472 unsigned char spare1_pusVersion_spare2;
473 unsigned char spare1_pusVersion_spare2;
473 unsigned char serviceType;
474 unsigned char serviceType;
474 unsigned char serviceSubType;
475 unsigned char serviceSubType;
475 unsigned char destinationID;
476 unsigned char destinationID;
476 unsigned char time[6];
477 unsigned char time[6];
477 unsigned char sid;
478 unsigned char sid;
478
479
479 //**************
480 //**************
480 // HK PARAMETERS
481 // HK PARAMETERS
481 unsigned char lfr_status_word[2];
482 unsigned char lfr_status_word[2];
482 unsigned char lfr_sw_version[4];
483 unsigned char lfr_sw_version[4];
483 unsigned char lfr_fpga_version[3];
484 unsigned char lfr_fpga_version[3];
484 // ressource statistics
485 // ressource statistics
485 unsigned char hk_lfr_cpu_load;
486 unsigned char hk_lfr_cpu_load;
486 unsigned char hk_lfr_load_max;
487 unsigned char hk_lfr_load_max;
487 unsigned char hk_lfr_load_aver;
488 unsigned char hk_lfr_load_aver;
488 // tc statistics
489 // tc statistics
489 unsigned char hk_lfr_update_info_tc_cnt[2];
490 unsigned char hk_lfr_update_info_tc_cnt[2];
490 unsigned char hk_lfr_update_time_tc_cnt[2];
491 unsigned char hk_lfr_update_time_tc_cnt[2];
491 unsigned char hk_lfr_exe_tc_cnt[2];
492 unsigned char hk_lfr_exe_tc_cnt[2];
492 unsigned char hk_lfr_rej_tc_cnt[2];
493 unsigned char hk_lfr_rej_tc_cnt[2];
493 unsigned char hk_lfr_last_exe_tc_id[2];
494 unsigned char hk_lfr_last_exe_tc_id[2];
494 unsigned char hk_lfr_last_exe_tc_type[2];
495 unsigned char hk_lfr_last_exe_tc_type[2];
495 unsigned char hk_lfr_last_exe_tc_subtype[2];
496 unsigned char hk_lfr_last_exe_tc_subtype[2];
496 unsigned char hk_lfr_last_exe_tc_time[6];
497 unsigned char hk_lfr_last_exe_tc_time[6];
497 unsigned char hk_lfr_last_rej_tc_id[2];
498 unsigned char hk_lfr_last_rej_tc_id[2];
498 unsigned char hk_lfr_last_rej_tc_type[2];
499 unsigned char hk_lfr_last_rej_tc_type[2];
499 unsigned char hk_lfr_last_rej_tc_subtype[2];
500 unsigned char hk_lfr_last_rej_tc_subtype[2];
500 unsigned char hk_lfr_last_rej_tc_time[6];
501 unsigned char hk_lfr_last_rej_tc_time[6];
501 // anomaly statistics
502 // anomaly statistics
502 unsigned char hk_lfr_le_cnt[2];
503 unsigned char hk_lfr_le_cnt[2];
503 unsigned char hk_lfr_me_cnt[2];
504 unsigned char hk_lfr_me_cnt[2];
504 unsigned char hk_lfr_he_cnt[2];
505 unsigned char hk_lfr_he_cnt[2];
505 unsigned char hk_lfr_last_er_rid[2];
506 unsigned char hk_lfr_last_er_rid[2];
506 unsigned char hk_lfr_last_er_code;
507 unsigned char hk_lfr_last_er_code;
507 unsigned char hk_lfr_last_er_time[6];
508 unsigned char hk_lfr_last_er_time[6];
508 // vhdl_blk_status
509 // vhdl_blk_status
509 unsigned char hk_lfr_vhdl_aa_sm;
510 unsigned char hk_lfr_vhdl_aa_sm;
510 unsigned char hk_lfr_vhdl_fft_sr;
511 unsigned char hk_lfr_vhdl_fft_sr;
511 unsigned char hk_lfr_vhdl_cic_hk;
512 unsigned char hk_lfr_vhdl_cic_hk;
512 unsigned char hk_lfr_vhdl_iir_cal;
513 unsigned char hk_lfr_vhdl_iir_cal;
513 // spacewire_if_statistics
514 // spacewire_if_statistics
514 unsigned char hk_lfr_dpu_spw_pkt_rcv_cnt[2];
515 unsigned char hk_lfr_dpu_spw_pkt_rcv_cnt[2];
515 unsigned char hk_lfr_dpu_spw_pkt_sent_cnt[2];
516 unsigned char hk_lfr_dpu_spw_pkt_sent_cnt[2];
516 unsigned char hk_lfr_dpu_spw_tick_out_cnt;
517 unsigned char hk_lfr_dpu_spw_tick_out_cnt;
517 unsigned char hk_lfr_dpu_spw_last_timc;
518 unsigned char hk_lfr_dpu_spw_last_timc;
518 // ahb error statistics
519 // ahb error statistics
519 unsigned int hk_lfr_last_fail_addr;
520 unsigned int hk_lfr_last_fail_addr;
520 // temperatures
521 // temperatures
521 unsigned char hk_lfr_temp_scm[2];
522 unsigned char hk_lfr_temp_scm[2];
522 unsigned char hk_lfr_temp_pcb[2];
523 unsigned char hk_lfr_temp_pcb[2];
523 unsigned char hk_lfr_temp_fpga[2];
524 unsigned char hk_lfr_temp_fpga[2];
524 // spacecraft potential
525 // spacecraft potential
525 unsigned char hk_lfr_sc_v_f3[2];
526 unsigned char hk_lfr_sc_v_f3[2];
526 unsigned char hk_lfr_sc_e1_f3[2];
527 unsigned char hk_lfr_sc_e1_f3[2];
527 unsigned char hk_lfr_sc_e2_f3[2];
528 unsigned char hk_lfr_sc_e2_f3[2];
528 // error counters
529 // error counters
529 unsigned char hk_lfr_dpu_spw_parity;
530 unsigned char hk_lfr_dpu_spw_parity;
530 unsigned char hk_lfr_dpu_spw_disconnect;
531 unsigned char hk_lfr_dpu_spw_disconnect;
531 unsigned char hk_lfr_dpu_spw_escape;
532 unsigned char hk_lfr_dpu_spw_escape;
532 unsigned char hk_lfr_dpu_spw_credit;
533 unsigned char hk_lfr_dpu_spw_credit;
533 unsigned char hk_lfr_dpu_spw_write_sync;
534 unsigned char hk_lfr_dpu_spw_write_sync;
534 unsigned char hk_lfr_dpu_spw_rx_ahb;
535 unsigned char hk_lfr_dpu_spw_rx_ahb;
535 unsigned char hk_lfr_dpu_spw_tx_ahb;
536 unsigned char hk_lfr_dpu_spw_tx_ahb;
536 unsigned char hk_lfr_dpu_spw_early_eop;
537 unsigned char hk_lfr_dpu_spw_early_eop;
537 unsigned char hk_lfr_dpu_spw_invalid_addr;
538 unsigned char hk_lfr_dpu_spw_invalid_addr;
538 unsigned char hk_lfr_dpu_spw_eep;
539 unsigned char hk_lfr_dpu_spw_eep;
539 unsigned char hk_lfr_dpu_spw_rx_too_big;
540 unsigned char hk_lfr_dpu_spw_rx_too_big;
540 // timecode
541 // timecode
541 unsigned char hk_lfr_timecode_erroneous;
542 unsigned char hk_lfr_timecode_erroneous;
542 unsigned char hk_lfr_timecode_missing;
543 unsigned char hk_lfr_timecode_missing;
543 unsigned char hk_lfr_timecode_invalid;
544 unsigned char hk_lfr_timecode_invalid;
544 // time
545 // time
545 unsigned char hk_lfr_time_timecode_it;
546 unsigned char hk_lfr_time_timecode_it;
546 unsigned char hk_lfr_time_not_synchro;
547 unsigned char hk_lfr_time_not_synchro;
547 unsigned char hk_lfr_time_timecode_ctr;
548 unsigned char hk_lfr_time_timecode_ctr;
548 // hk_lfr_buffer_dpu_
549 // hk_lfr_buffer_dpu_
549 unsigned char hk_lfr_buffer_dpu_tc_fifo;
550 unsigned char hk_lfr_buffer_dpu_tc_fifo;
550 unsigned char hk_lfr_buffer_dpu_tm_fifo;
551 unsigned char hk_lfr_buffer_dpu_tm_fifo;
551 // hk_lfr_ahb_
552 // hk_lfr_ahb_
552 unsigned char hk_lfr_ahb_correctable;
553 unsigned char hk_lfr_ahb_correctable;
553 unsigned char hk_lfr_ahb_uncorrectable;
554 unsigned char hk_lfr_ahb_uncorrectable;
554 // spare
555 // spare
555 unsigned char parameters_spare;
556 unsigned char parameters_spare;
556 } Packet_TM_LFR_HK_t;
557 } Packet_TM_LFR_HK_t;
557
558
558 typedef struct {
559 typedef struct {
559 unsigned char targetLogicalAddress;
560 unsigned char targetLogicalAddress;
560 unsigned char protocolIdentifier;
561 unsigned char protocolIdentifier;
561 unsigned char reserved;
562 unsigned char reserved;
562 unsigned char userApplication;
563 unsigned char userApplication;
563 unsigned char packetID[2];
564 unsigned char packetID[2];
564 unsigned char packetSequenceControl[2];
565 unsigned char packetSequenceControl[2];
565 unsigned char packetLength[2];
566 unsigned char packetLength[2];
566 // DATA FIELD HEADER
567 // DATA FIELD HEADER
567 unsigned char spare1_pusVersion_spare2;
568 unsigned char spare1_pusVersion_spare2;
568 unsigned char serviceType;
569 unsigned char serviceType;
569 unsigned char serviceSubType;
570 unsigned char serviceSubType;
570 unsigned char destinationID;
571 unsigned char destinationID;
571 unsigned char time[6];
572 unsigned char time[6];
572 unsigned char sid;
573 unsigned char sid;
573
574
574 //******************
575 //******************
575 // COMMON PARAMETERS
576 // COMMON PARAMETERS
576 unsigned char unused0;
577 unsigned char unused0;
577 unsigned char bw_sp0_sp1_r0_r1;
578 unsigned char bw_sp0_sp1_r0_r1;
578
579
579 //******************
580 //******************
580 // NORMAL PARAMETERS
581 // NORMAL PARAMETERS
581 unsigned char sy_lfr_n_swf_l[2];
582 unsigned char sy_lfr_n_swf_l[2];
582 unsigned char sy_lfr_n_swf_p[2];
583 unsigned char sy_lfr_n_swf_p[2];
583 unsigned char sy_lfr_n_asm_p[2];
584 unsigned char sy_lfr_n_asm_p[2];
584 unsigned char sy_lfr_n_bp_p0;
585 unsigned char sy_lfr_n_bp_p0;
585 unsigned char sy_lfr_n_bp_p1;
586 unsigned char sy_lfr_n_bp_p1;
586 unsigned char sy_lfr_n_cwf_long_f3;
587 unsigned char sy_lfr_n_cwf_long_f3;
587 unsigned char lfr_normal_parameters_spare;
588 unsigned char lfr_normal_parameters_spare;
588
589
589 //*****************
590 //*****************
590 // BURST PARAMETERS
591 // BURST PARAMETERS
591 unsigned char sy_lfr_b_bp_p0;
592 unsigned char sy_lfr_b_bp_p0;
592 unsigned char sy_lfr_b_bp_p1;
593 unsigned char sy_lfr_b_bp_p1;
593
594
594 //****************
595 //****************
595 // SBM1 PARAMETERS
596 // SBM1 PARAMETERS
596 unsigned char sy_lfr_s1_bp_p0;
597 unsigned char sy_lfr_s1_bp_p0;
597 unsigned char sy_lfr_s1_bp_p1;
598 unsigned char sy_lfr_s1_bp_p1;
598
599
599 //****************
600 //****************
600 // SBM2 PARAMETERS
601 // SBM2 PARAMETERS
601 unsigned char sy_lfr_s2_bp_p0;
602 unsigned char sy_lfr_s2_bp_p0;
602 unsigned char sy_lfr_s2_bp_p1;
603 unsigned char sy_lfr_s2_bp_p1;
603
604
604 // SPARE
605 // SPARE
605 unsigned char source_data_spare;
606 unsigned char source_data_spare;
606 } Packet_TM_LFR_PARAMETER_DUMP_t;
607 } Packet_TM_LFR_PARAMETER_DUMP_t;
607
608
608
609
609 #endif // CCSDS_TYPES_H_INCLUDED
610 #endif // CCSDS_TYPES_H_INCLUDED
@@ -1,229 +1,230
1 #ifndef FSW_PARAMS_H_INCLUDED
1 #ifndef FSW_PARAMS_H_INCLUDED
2 #define FSW_PARAMS_H_INCLUDED
2 #define FSW_PARAMS_H_INCLUDED
3
3
4 #include "grlib_regs.h"
4 #include "grlib_regs.h"
5 #include "fsw_params_processing.h"
5 #include "fsw_params_processing.h"
6 #include "fsw_params_nb_bytes.h"
6 #include "fsw_params_nb_bytes.h"
7 #include "tm_byte_positions.h"
7 #include "tm_byte_positions.h"
8 #include "ccsds_types.h"
8 #include "ccsds_types.h"
9
9
10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
11 #define UART_DEVICE_NAME "/dev/console"
11 #define UART_DEVICE_NAME "/dev/console"
12
12
13 typedef struct ring_node
13 typedef struct ring_node
14 {
14 {
15 struct ring_node *previous;
15 struct ring_node *previous;
16 int buffer_address;
16 int buffer_address;
17 struct ring_node *next;
17 struct ring_node *next;
18 unsigned int status;
18 unsigned int status;
19 } ring_node;
19 } ring_node;
20
20
21 //************************
21 //************************
22 // flight software version
22 // flight software version
23 // this parameters is handled by the Qt project options
23 // this parameters is handled by the Qt project options
24
24
25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
28 #define TIME_OFFSET 2
28 #define TIME_OFFSET 2
29 #define TIME_OFFSET_IN_BYTES 8
29 #define TIME_OFFSET_IN_BYTES 8
30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
31 #define NB_BYTES_SWF_BLK (2 * 6)
31 #define NB_BYTES_SWF_BLK (2 * 6)
32 #define NB_WORDS_SWF_BLK 3
32 #define NB_WORDS_SWF_BLK 3
33 #define NB_BYTES_CWF3_LIGHT_BLK 6
33 #define NB_BYTES_CWF3_LIGHT_BLK 6
34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
35 #define NB_RING_NODES_F0 3 // AT LEAST 3
35 #define NB_RING_NODES_F0 3 // AT LEAST 3
36 #define NB_RING_NODES_F1 5 // AT LEAST 3
36 #define NB_RING_NODES_F1 5 // AT LEAST 3
37 #define NB_RING_NODES_F2 5 // AT LEAST 3
37 #define NB_RING_NODES_F2 5 // AT LEAST 3
38
38
39 //**********
39 //**********
40 // LFR MODES
40 // LFR MODES
41 #define LFR_MODE_STANDBY 0
41 #define LFR_MODE_STANDBY 0
42 #define LFR_MODE_NORMAL 1
42 #define LFR_MODE_NORMAL 1
43 #define LFR_MODE_BURST 2
43 #define LFR_MODE_BURST 2
44 #define LFR_MODE_SBM1 3
44 #define LFR_MODE_SBM1 3
45 #define LFR_MODE_SBM2 4
45 #define LFR_MODE_SBM2 4
46
46
47 #define TDS_MODE_LFM 5
47 #define TDS_MODE_LFM 5
48 #define TDS_MODE_STANDBY 0
48 #define TDS_MODE_STANDBY 0
49 #define TDS_MODE_NORMAL 1
49 #define TDS_MODE_NORMAL 1
50 #define TDS_MODE_BURST 2
50 #define TDS_MODE_BURST 2
51 #define TDS_MODE_SBM1 3
51 #define TDS_MODE_SBM1 3
52 #define TDS_MODE_SBM2 4
52 #define TDS_MODE_SBM2 4
53
53
54 #define THR_MODE_STANDBY 0
54 #define THR_MODE_STANDBY 0
55 #define THR_MODE_NORMAL 1
55 #define THR_MODE_NORMAL 1
56 #define THR_MODE_BURST 2
56 #define THR_MODE_BURST 2
57
57
58 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
58 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
59 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
59 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
60 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
60 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
61 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
61 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
62 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
62 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
63 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
63 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
64 #define RTEMS_EVENT_MODE_NORMAL_SWF_F0 RTEMS_EVENT_6
64 #define RTEMS_EVENT_MODE_NORMAL_SWF_F0 RTEMS_EVENT_6
65 #define RTEMS_EVENT_MODE_NORMAL_SWF_F1 RTEMS_EVENT_7
65 #define RTEMS_EVENT_MODE_NORMAL_SWF_F1 RTEMS_EVENT_7
66 #define RTEMS_EVENT_MODE_NORMAL_SWF_F2 RTEMS_EVENT_8
66 #define RTEMS_EVENT_MODE_NORMAL_SWF_F2 RTEMS_EVENT_8
67
67
68 //****************************
68 //****************************
69 // LFR DEFAULT MODE PARAMETERS
69 // LFR DEFAULT MODE PARAMETERS
70 // COMMON
70 // COMMON
71 #define DEFAULT_SY_LFR_COMMON0 0x00
71 #define DEFAULT_SY_LFR_COMMON0 0x00
72 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
72 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
73 // NORM
73 // NORM
74 #define SY_LFR_N_SWF_L 2048 // nb sample
74 #define SY_LFR_N_SWF_L 2048 // nb sample
75 #define SY_LFR_N_SWF_P 300 // sec
75 #define SY_LFR_N_SWF_P 300 // sec
76 #define SY_LFR_N_ASM_P 3600 // sec
76 #define SY_LFR_N_ASM_P 3600 // sec
77 #define SY_LFR_N_BP_P0 4 // sec
77 #define SY_LFR_N_BP_P0 4 // sec
78 #define SY_LFR_N_BP_P1 20 // sec
78 #define SY_LFR_N_BP_P1 20 // sec
79 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
79 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
80 #define MIN_DELTA_SNAPSHOT 16 // sec
80 #define MIN_DELTA_SNAPSHOT 16 // sec
81 // BURST
81 // BURST
82 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
82 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
83 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
83 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
84 // SBM1
84 // SBM1
85 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
85 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
86 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
86 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
87 // SBM2
87 // SBM2
88 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
88 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
89 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
89 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
90 // ADDITIONAL PARAMETERS
90 // ADDITIONAL PARAMETERS
91 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
91 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
92 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
92 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
93 // STATUS WORD
93 // STATUS WORD
94 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
94 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
95 #define DEFAULT_STATUS_WORD_BYTE1 0x00
95 #define DEFAULT_STATUS_WORD_BYTE1 0x00
96 //
96 //
97 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
97 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
98 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
98 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
99 //****************************
99 //****************************
100
100
101 //*****************************
101 //*****************************
102 // APB REGISTERS BASE ADDRESSES
102 // APB REGISTERS BASE ADDRESSES
103 #define REGS_ADDR_APBUART 0x80000100
103 #define REGS_ADDR_APBUART 0x80000100
104 #define REGS_ADDR_GPTIMER 0x80000300
104 #define REGS_ADDR_GPTIMER 0x80000300
105 #define REGS_ADDR_GRSPW 0x80000500
105 #define REGS_ADDR_GRSPW 0x80000500
106 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
106 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
107 #define REGS_ADDR_GRGPIO 0x80000b00
107
108
108 #ifdef VHDL_DEV
109 #ifdef VHDL_DEV
109 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
110 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
110 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
111 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
111 #else
112 #else
112 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
113 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
113 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
114 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
114 #endif
115 #endif
115
116
116 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
117 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
117 #define APBUART_CTRL_REG_MASK_TE 0x00000002
118 #define APBUART_CTRL_REG_MASK_TE 0x00000002
118 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
119 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
119
120
120 //**********
121 //**********
121 // IRQ LINES
122 // IRQ LINES
122 #define IRQ_SM_SIMULATOR 9
123 #define IRQ_SM_SIMULATOR 9
123 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
124 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
124 #define IRQ_WAVEFORM_PICKER 14
125 #define IRQ_WAVEFORM_PICKER 14
125 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
126 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
126 #define IRQ_SPECTRAL_MATRIX 6
127 #define IRQ_SPECTRAL_MATRIX 6
127 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
128 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
128
129
129 //*****
130 //*****
130 // TIME
131 // TIME
131 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
132 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
132 #define TIMER_SM_SIMULATOR 1
133 #define TIMER_SM_SIMULATOR 1
133 #define HK_PERIOD 100 // 100 * 10ms => 1s
134 #define HK_PERIOD 100 // 100 * 10ms => 1s
134 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
135 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
135 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
136 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
136
137
137 //**********
138 //**********
138 // LPP CODES
139 // LPP CODES
139 #define LFR_SUCCESSFUL 0
140 #define LFR_SUCCESSFUL 0
140 #define LFR_DEFAULT 1
141 #define LFR_DEFAULT 1
141
142
142 //******
143 //******
143 // RTEMS
144 // RTEMS
144 #define TASKID_RECV 1
145 #define TASKID_RECV 1
145 #define TASKID_ACTN 2
146 #define TASKID_ACTN 2
146 #define TASKID_SPIQ 3
147 #define TASKID_SPIQ 3
147 #define TASKID_SMIQ 4
148 #define TASKID_SMIQ 4
148 #define TASKID_STAT 5
149 #define TASKID_STAT 5
149 #define TASKID_AVF0 6
150 #define TASKID_AVF0 6
150 #define TASKID_SWBD 7
151 #define TASKID_SWBD 7
151 #define TASKID_WFRM 8
152 #define TASKID_WFRM 8
152 #define TASKID_DUMB 9
153 #define TASKID_DUMB 9
153 #define TASKID_HOUS 10
154 #define TASKID_HOUS 10
154 #define TASKID_MATR 11
155 #define TASKID_MATR 11
155 #define TASKID_CWF3 12
156 #define TASKID_CWF3 12
156 #define TASKID_CWF2 13
157 #define TASKID_CWF2 13
157 #define TASKID_CWF1 14
158 #define TASKID_CWF1 14
158 #define TASKID_SEND 15
159 #define TASKID_SEND 15
159 #define TASKID_WTDG 16
160 #define TASKID_WTDG 16
160
161
161 #define TASK_PRIORITY_SPIQ 5
162 #define TASK_PRIORITY_SPIQ 5
162 #define TASK_PRIORITY_SMIQ 10
163 #define TASK_PRIORITY_SMIQ 10
163 #define TASK_PRIORITY_WTDG 20
164 #define TASK_PRIORITY_WTDG 20
164 #define TASK_PRIORITY_HOUS 30
165 #define TASK_PRIORITY_HOUS 30
165 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
166 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
166 #define TASK_PRIORITY_CWF2 35 //
167 #define TASK_PRIORITY_CWF2 35 //
167 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
168 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
168 #define TASK_PRIORITY_WFRM 40
169 #define TASK_PRIORITY_WFRM 40
169 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
170 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
170 #define TASK_PRIORITY_SEND 45
171 #define TASK_PRIORITY_SEND 45
171 #define TASK_PRIORITY_RECV 50
172 #define TASK_PRIORITY_RECV 50
172 #define TASK_PRIORITY_ACTN 50
173 #define TASK_PRIORITY_ACTN 50
173 #define TASK_PRIORITY_AVF0 60
174 #define TASK_PRIORITY_AVF0 60
174 #define TASK_PRIORITY_BPF0 60
175 #define TASK_PRIORITY_BPF0 60
175 #define TASK_PRIORITY_MATR 100
176 #define TASK_PRIORITY_MATR 100
176 #define TASK_PRIORITY_STAT 200
177 #define TASK_PRIORITY_STAT 200
177 #define TASK_PRIORITY_DUMB 200
178 #define TASK_PRIORITY_DUMB 200
178
179
179 #define ACTION_MSG_QUEUE_COUNT 10
180 #define ACTION_MSG_QUEUE_COUNT 10
180 #define ACTION_MSG_PKTS_COUNT 50
181 #define ACTION_MSG_PKTS_COUNT 50
181 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
182 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
182 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
183 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
183
184
184 #define QUEUE_RECV 0
185 #define QUEUE_RECV 0
185 #define QUEUE_SEND 1
186 #define QUEUE_SEND 1
186
187
187 //*******
188 //*******
188 // MACROS
189 // MACROS
189 #ifdef PRINT_MESSAGES_ON_CONSOLE
190 #ifdef PRINT_MESSAGES_ON_CONSOLE
190 #define PRINTF(x) printf(x);
191 #define PRINTF(x) printf(x);
191 #define PRINTF1(x,y) printf(x,y);
192 #define PRINTF1(x,y) printf(x,y);
192 #define PRINTF2(x,y,z) printf(x,y,z);
193 #define PRINTF2(x,y,z) printf(x,y,z);
193 #else
194 #else
194 #define PRINTF(x) ;
195 #define PRINTF(x) ;
195 #define PRINTF1(x,y) ;
196 #define PRINTF1(x,y) ;
196 #define PRINTF2(x,y,z) ;
197 #define PRINTF2(x,y,z) ;
197 #endif
198 #endif
198
199
199 #ifdef BOOT_MESSAGES
200 #ifdef BOOT_MESSAGES
200 #define BOOT_PRINTF(x) printf(x);
201 #define BOOT_PRINTF(x) printf(x);
201 #define BOOT_PRINTF1(x,y) printf(x,y);
202 #define BOOT_PRINTF1(x,y) printf(x,y);
202 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
203 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
203 #else
204 #else
204 #define BOOT_PRINTF(x) ;
205 #define BOOT_PRINTF(x) ;
205 #define BOOT_PRINTF1(x,y) ;
206 #define BOOT_PRINTF1(x,y) ;
206 #define BOOT_PRINTF2(x,y,z) ;
207 #define BOOT_PRINTF2(x,y,z) ;
207 #endif
208 #endif
208
209
209 #ifdef DEBUG_MESSAGES
210 #ifdef DEBUG_MESSAGES
210 #define DEBUG_PRINTF(x) printf(x);
211 #define DEBUG_PRINTF(x) printf(x);
211 #define DEBUG_PRINTF1(x,y) printf(x,y);
212 #define DEBUG_PRINTF1(x,y) printf(x,y);
212 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
213 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
213 #else
214 #else
214 #define DEBUG_PRINTF(x) ;
215 #define DEBUG_PRINTF(x) ;
215 #define DEBUG_PRINTF1(x,y) ;
216 #define DEBUG_PRINTF1(x,y) ;
216 #define DEBUG_PRINTF2(x,y,z) ;
217 #define DEBUG_PRINTF2(x,y,z) ;
217 #endif
218 #endif
218
219
219 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
220 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
220
221
221 struct param_local_str{
222 struct param_local_str{
222 unsigned int local_sbm1_nb_cwf_sent;
223 unsigned int local_sbm1_nb_cwf_sent;
223 unsigned int local_sbm1_nb_cwf_max;
224 unsigned int local_sbm1_nb_cwf_max;
224 unsigned int local_sbm2_nb_cwf_sent;
225 unsigned int local_sbm2_nb_cwf_sent;
225 unsigned int local_sbm2_nb_cwf_max;
226 unsigned int local_sbm2_nb_cwf_max;
226 unsigned int local_nb_interrupt_f0_MAX;
227 unsigned int local_nb_interrupt_f0_MAX;
227 };
228 };
228
229
229 #endif // FSW_PARAMS_H_INCLUDED
230 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,54 +1,57
1 #ifndef FSW_PARAMS_PROCESSING_H
1 #ifndef FSW_PARAMS_PROCESSING_H
2 #define FSW_PARAMS_PROCESSING_H
2 #define FSW_PARAMS_PROCESSING_H
3
3
4 #define NB_BINS_PER_SM 128
4 #define NB_BINS_PER_SM 128
5 #define NB_VALUES_PER_SM 25
5 #define NB_VALUES_PER_SM 25
6 #define TOTAL_SIZE_SM 3200 // 25 * 128
6 #define TOTAL_SIZE_SM 3200 // 25 * 128
7 #define TOTAL_SIZE_BP1_F0 99 // 11 * 9 = 99
8 #define TOTAL_SIZE_BP1_F1 117 // 13 * 9 = 117
9 #define TOTAL_SIZE_BP1_F2 108 // 12 * 9 = 108
7 //
10 //
8 #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3
11 #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3
9 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
12 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
10 #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3
13 #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3
11 //
14 //
12 #define NB_BINS_PER_ASM_F0 88
15 #define NB_BINS_PER_ASM_F0 88
13 #define NB_BINS_PER_PKT_ASM_F0 44
16 #define NB_BINS_PER_PKT_ASM_F0 44
14 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
17 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
15 #define ASM_F0_INDICE_START 17 // 88 bins
18 #define ASM_F0_INDICE_START 17 // 88 bins
16 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
19 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
17 //
20 //
18 #define NB_BINS_PER_ASM_F1 104
21 #define NB_BINS_PER_ASM_F1 104
19 #define NB_BINS_PER_PKT_ASM_F1 52
22 #define NB_BINS_PER_PKT_ASM_F1 52
20 #define TOTAL_SIZE_ASM_F1 2600 // 25 * 104
23 #define TOTAL_SIZE_ASM_F1 2600 // 25 * 104
21 #define ASM_F1_INDICE_START 6 // 104 bins
24 #define ASM_F1_INDICE_START 6 // 104 bins
22 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
25 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
23 //
26 //
24 #define NB_BINS_PER_ASM_F2 96
27 #define NB_BINS_PER_ASM_F2 96
25 #define NB_BINS_PER_PKT_ASM_F2 48
28 #define NB_BINS_PER_PKT_ASM_F2 48
26 #define TOTAL_SIZE_ASM_F2 2400 // 25 * 96
29 #define TOTAL_SIZE_ASM_F2 2400 // 25 * 96
27 #define ASM_F2_INDICE_START 7 // 96 bins
30 #define ASM_F2_INDICE_START 7 // 96 bins
28 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
31 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
29 //
32 //
30 #define NB_BINS_COMPRESSED_SM_F0 11
33 #define NB_BINS_COMPRESSED_SM_F0 11
31 #define NB_BINS_COMPRESSED_SM_F1 13
34 #define NB_BINS_COMPRESSED_SM_F1 13
32 #define NB_BINS_COMPRESSED_SM_F2 12
35 #define NB_BINS_COMPRESSED_SM_F2 12
33 //
36 //
34 #define NB_BINS_TO_AVERAGE_ASM_F0 8
37 #define NB_BINS_TO_AVERAGE_ASM_F0 8
35 #define NB_BINS_TO_AVERAGE_ASM_F1 8
38 #define NB_BINS_TO_AVERAGE_ASM_F1 8
36 #define NB_BINS_TO_AVERAGE_ASM_F2 8
39 #define NB_BINS_TO_AVERAGE_ASM_F2 8
37 //
40 //
38 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25
41 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25
39 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25
42 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25
40 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25
43 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25
41 #define NB_AVERAGE_NORMAL_f0 96*4
44 #define NB_AVERAGE_NORMAL_f0 96*4
42 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
45 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
43
46
44 typedef struct {
47 typedef struct {
45 volatile unsigned char PE[2];
48 volatile unsigned char PE[2];
46 volatile unsigned char PB[2];
49 volatile unsigned char PB[2];
47 volatile unsigned char V0;
50 volatile unsigned char V0;
48 volatile unsigned char V1;
51 volatile unsigned char V1;
49 volatile unsigned char V2_ELLIP_DOP;
52 volatile unsigned char V2_ELLIP_DOP;
50 volatile unsigned char SZ;
53 volatile unsigned char SZ;
51 volatile unsigned char VPHI;
54 volatile unsigned char VPHI;
52 } BP1_t;
55 } BP1_t;
53
56
54 #endif // FSW_PARAMS_PROCESSING_H
57 #endif // FSW_PARAMS_PROCESSING_H
@@ -1,55 +1,54
1 #ifndef FSW_PROCESSING_H_INCLUDED
1 #ifndef FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6 #include <math.h>
6 #include <math.h>
7 #include <stdlib.h> // abs() is in the stdlib
7 #include <stdlib.h> // abs() is in the stdlib
8 #include <stdio.h> // printf()
8 #include <stdio.h> // printf()
9 #include <math.h>
9 #include <math.h>
10
10
11 #include "fsw_params.h"
11 #include "fsw_params.h"
12 #include "fsw_spacewire.h"
12 #include "fsw_spacewire.h"
13 #include "basic_parameters.h"
14
13
15 extern volatile int sm_f0[ ];
14 extern volatile int sm_f0[ ];
16 extern volatile int sm_f1[ ];
15 extern volatile int sm_f1[ ];
17 extern volatile int sm_f2[ ];
16 extern volatile int sm_f2[ ];
18
17
19 // parameters
18 // parameters
20 extern struct param_local_str param_local;
19 extern struct param_local_str param_local;
21
20
22 // registers
21 // registers
23 extern time_management_regs_t *time_management_regs;
22 extern time_management_regs_t *time_management_regs;
24 extern spectral_matrix_regs_t *spectral_matrix_regs;
23 extern spectral_matrix_regs_t *spectral_matrix_regs;
25
24
26 extern rtems_name misc_name[5];
25 extern rtems_name misc_name[5];
27 extern rtems_id Task_id[20]; /* array of task ids */
26 extern rtems_id Task_id[20]; /* array of task ids */
28
27
29 void init_sm_rings( void );
28 void init_sm_rings( void );
30 void reset_current_sm_ring_nodes( void );
29 void reset_current_sm_ring_nodes( void );
31
30
32 // ISR
31 // ISR
33 void reset_nb_sm_f0( void );
32 void reset_nb_sm_f0( void );
34 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
33 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
35 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
34 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
36
35
37 // RTEMS TASKS
36 // RTEMS TASKS
38 rtems_task avf0_task(rtems_task_argument argument);
37 rtems_task avf0_task(rtems_task_argument argument);
39 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
38 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
40 rtems_task matr_task(rtems_task_argument argument);
39 rtems_task matr_task(rtems_task_argument argument);
41
40
42 void matrix_reset(volatile float *averaged_spec_mat);
41 void matrix_reset(volatile float *averaged_spec_mat);
43 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
42 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
44 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
43 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
45 //
44 //
46 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
45 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
47 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized );
46 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized );
48 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat );
47 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat );
49 void ASM_convert(volatile float *input_matrix, char *output_matrix);
48 void ASM_convert(volatile float *input_matrix, char *output_matrix);
50 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
49 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
51 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
50 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
52 void fill_averaged_spectral_matrix( void );
51 void fill_averaged_spectral_matrix( void );
53 void reset_spectral_matrix_regs();
52 void reset_spectral_matrix_regs();
54
53
55 #endif // FSW_PROCESSING_H_INCLUDED
54 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,95 +1,100
1 #ifndef GRLIB_REGS_H_INCLUDED
1 #ifndef GRLIB_REGS_H_INCLUDED
2 #define GRLIB_REGS_H_INCLUDED
2 #define GRLIB_REGS_H_INCLUDED
3
3
4 #define NB_GPTIMER 3
4 #define NB_GPTIMER 3
5
5
6 struct apbuart_regs_str{
6 struct apbuart_regs_str{
7 volatile unsigned int data;
7 volatile unsigned int data;
8 volatile unsigned int status;
8 volatile unsigned int status;
9 volatile unsigned int ctrl;
9 volatile unsigned int ctrl;
10 volatile unsigned int scaler;
10 volatile unsigned int scaler;
11 volatile unsigned int fifoDebug;
11 volatile unsigned int fifoDebug;
12 };
12 };
13
13
14 struct ahbuart_regs_str{
14 struct grgpio_regs_str{
15 volatile unsigned int unused;
15 volatile int io_port_data_register;
16 volatile unsigned int status;
16 int io_port_output_register;
17 volatile unsigned int ctrl;
17 int io_port_direction_register;
18 volatile unsigned int scaler;
18 int interrupt_mak_register;
19 int interrupt_polarity_register;
20 int interrupt_edge_register;
21 int bypass_register;
22 int reserved;
23 // 0x20-0x3c interrupt map register(s)
19 };
24 };
20
25
21 typedef struct {
26 typedef struct {
22 volatile unsigned int counter;
27 volatile unsigned int counter;
23 volatile unsigned int reload;
28 volatile unsigned int reload;
24 volatile unsigned int ctrl;
29 volatile unsigned int ctrl;
25 volatile unsigned int unused;
30 volatile unsigned int unused;
26 } timer_regs_t;
31 } timer_regs_t;
27
32
28 typedef struct {
33 typedef struct {
29 volatile unsigned int scaler_value;
34 volatile unsigned int scaler_value;
30 volatile unsigned int scaler_reload;
35 volatile unsigned int scaler_reload;
31 volatile unsigned int conf;
36 volatile unsigned int conf;
32 volatile unsigned int unused0;
37 volatile unsigned int unused0;
33 timer_regs_t timer[NB_GPTIMER];
38 timer_regs_t timer[NB_GPTIMER];
34 } gptimer_regs_t;
39 } gptimer_regs_t;
35
40
36 typedef struct {
41 typedef struct {
37 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
42 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
38 volatile int coarse_time_load;
43 volatile int coarse_time_load;
39 volatile int coarse_time;
44 volatile int coarse_time;
40 volatile int fine_time;
45 volatile int fine_time;
41 } time_management_regs_t;
46 } time_management_regs_t;
42
47
43 typedef struct {
48 typedef struct {
44 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
49 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
45 volatile int burst_enable; // 0x04 01 *** burst f2, f1, f0 enable f3, f2, f1, f0
50 volatile int burst_enable; // 0x04 01 *** burst f2, f1, f0 enable f3, f2, f1, f0
46 volatile int addr_data_f0; // 0x08 10 ***
51 volatile int addr_data_f0; // 0x08 10 ***
47 volatile int addr_data_f1; // 0x0c 11 ***
52 volatile int addr_data_f1; // 0x0c 11 ***
48 volatile int addr_data_f2; // 0x10 100 ***
53 volatile int addr_data_f2; // 0x10 100 ***
49 volatile int addr_data_f3; // 0x14 101 ***
54 volatile int addr_data_f3; // 0x14 101 ***
50 volatile int status; // 0x18 110 ***
55 volatile int status; // 0x18 110 ***
51 volatile int delta_snapshot; // 0x1c 111 ***
56 volatile int delta_snapshot; // 0x1c 111 ***
52 volatile int delta_f2_f1; // 0x20 0000 ***
57 volatile int delta_f2_f1; // 0x20 0000 ***
53 volatile int delta_f2_f0; // 0x24 0001 ***
58 volatile int delta_f2_f0; // 0x24 0001 ***
54 volatile int nb_burst_available;// 0x28 0010 ***
59 volatile int nb_burst_available;// 0x28 0010 ***
55 volatile int nb_snapshot_param; // 0x2c 0011 ***
60 volatile int nb_snapshot_param; // 0x2c 0011 ***
56 } waveform_picker_regs_t;
61 } waveform_picker_regs_t;
57
62
58 typedef struct{
63 typedef struct{
59 int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
64 int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
60 int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
65 int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
61 int addr_data_f0; // 0x08
66 int addr_data_f0; // 0x08
62 int addr_data_f1; // 0x0c
67 int addr_data_f1; // 0x0c
63 int addr_data_f2; // 0x10
68 int addr_data_f2; // 0x10
64 int addr_data_f3; // 0x14
69 int addr_data_f3; // 0x14
65 volatile int status; // 0x18
70 volatile int status; // 0x18
66 int delta_snapshot; // 0x1c
71 int delta_snapshot; // 0x1c
67 int delta_f0; // 0x20
72 int delta_f0; // 0x20
68 int delta_f0_2; // 0x24
73 int delta_f0_2; // 0x24
69 int delta_f1; // 0x28
74 int delta_f1; // 0x28
70 int delta_f2; // 0x2c
75 int delta_f2; // 0x2c
71 int nb_data_by_buffer; // 0x30
76 int nb_data_by_buffer; // 0x30
72 int snapshot_param; // 0x34
77 int snapshot_param; // 0x34
73 int start_date; // 0x38
78 int start_date; // 0x38
74 int nb_word_in_buffer; // 0x3c
79 int nb_word_in_buffer; // 0x3c
75 } waveform_picker_regs_new_t;
80 } waveform_picker_regs_new_t;
76
81
77 typedef struct {
82 typedef struct {
78 volatile int config;
83 volatile int config;
79 volatile int status;
84 volatile int status;
80 volatile int matrixF0_Address0;
85 volatile int matrixF0_Address0;
81 volatile int matrixFO_Address1;
86 volatile int matrixFO_Address1;
82 volatile int matrixF1_Address;
87 volatile int matrixF1_Address;
83 volatile int matrixF2_Address;
88 volatile int matrixF2_Address;
84 volatile int coarse_time_F0_0;
89 volatile int coarse_time_F0_0;
85 volatile int coarse_time_F0_1;
90 volatile int coarse_time_F0_1;
86 volatile int coarse_time_F1;
91 volatile int coarse_time_F1;
87 volatile int coarse_time_F2;
92 volatile int coarse_time_F2;
88 volatile int fine_time_FO_0;
93 volatile int fine_time_FO_0;
89 volatile int fine_time_F0_1;
94 volatile int fine_time_F0_1;
90 volatile int fine_time_F1;
95 volatile int fine_time_F1;
91 volatile int fine_time_F2;
96 volatile int fine_time_F2;
92 volatile int debug;
97 volatile int debug;
93 } spectral_matrix_regs_t;
98 } spectral_matrix_regs_t;
94
99
95 #endif // GRLIB_REGS_H_INCLUDED
100 #endif // GRLIB_REGS_H_INCLUDED
@@ -1,58 +1,58
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "tc_load_dump_parameters.h"
7 #include "tc_load_dump_parameters.h"
8 #include "tc_acceptance.h"
8 #include "tc_acceptance.h"
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11 #include "fsw_processing.h"
11 #include "fsw_processing.h"
12
12
13 // MODE PARAMETERS
13 // MODE PARAMETERS
14 extern unsigned int maxCount;
14 extern unsigned int maxCount;
15
15
16 //****
16 //****
17 // ISR
17 // ISR
18 rtems_isr commutation_isr1( rtems_vector_number vector );
18 rtems_isr commutation_isr1( rtems_vector_number vector );
19 rtems_isr commutation_isr2( rtems_vector_number vector );
19 rtems_isr commutation_isr2( rtems_vector_number vector );
20
20
21 //***********
21 //***********
22 // RTEMS TASK
22 // RTEMS TASK
23 rtems_task actn_task( rtems_task_argument unused );
23 rtems_task actn_task( rtems_task_argument unused );
24
24
25 //***********
25 //***********
26 // TC ACTIONS
26 // TC ACTIONS
27 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
27 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
28 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
28 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
29 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
29 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
30 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
30 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
31 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
31 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
32 int action_update_time(ccsdsTelecommandPacket_t *TC);
32 int action_update_time(ccsdsTelecommandPacket_t *TC);
33
33
34 // mode transition
34 // mode transition
35 int transition_validation(unsigned char requestedMode);
35 int transition_validation(unsigned char requestedMode);
36 int stop_current_mode( void );
36 int stop_current_mode( void );
37 int enter_mode(unsigned char mode);
37 int enter_mode(unsigned char mode);
38 int restart_science_tasks();
38 int restart_science_tasks();
39 int suspend_science_tasks();
39 int suspend_science_tasks();
40 void launch_waveform_picker( unsigned char mode );
40 void launch_waveform_picker( unsigned char mode );
41 void launch_spectral_matrix( unsigned char mode );
41 void launch_spectral_matrix( unsigned char mode );
42 void set_irq_on_new_ready_matrix(unsigned char value );
42 void set_irq_on_new_ready_matrix(unsigned char value );
43 void set_run_matrix_spectral( unsigned char value );
43 void set_run_matrix_spectral( unsigned char value );
44 void launch_spectral_matrix_simu( unsigned char mode );
44 void launch_spectral_matrix_simu( unsigned char mode );
45
45
46 // other functions
46 // other functions
47 void updateLFRCurrentMode();
47 void updateLFRCurrentMode();
48 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC );
48 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
49 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC );
49 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
50 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
50 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
51
51
52 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
52 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
53 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
53 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
54
54
55 #endif // TC_HANDLER_H_INCLUDED
55 #endif // TC_HANDLER_H_INCLUDED
56
56
57
57
58
58
@@ -1,760 +1,766
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include <fsw_processing.h>
10 #include <fsw_processing.h>
11
11
12 #include "fsw_processing_globals.c"
12 #include "fsw_processing_globals.c"
13
13
14 //************************
14 //************************
15 // spectral matrices rings
15 // spectral matrices rings
16 ring_node sm_ring_f0[NB_RING_NODES_ASM_F0];
16 ring_node sm_ring_f0[NB_RING_NODES_ASM_F0];
17 ring_node sm_ring_f1[NB_RING_NODES_ASM_F1];
17 ring_node sm_ring_f1[NB_RING_NODES_ASM_F1];
18 ring_node sm_ring_f2[NB_RING_NODES_ASM_F2];
18 ring_node sm_ring_f2[NB_RING_NODES_ASM_F2];
19 ring_node *current_ring_node_sm_f0;
19 ring_node *current_ring_node_sm_f0;
20 ring_node *ring_node_for_averaging_sm_f0;
20 ring_node *ring_node_for_averaging_sm_f0;
21 ring_node *current_ring_node_sm_f1;
21 ring_node *current_ring_node_sm_f1;
22 ring_node *current_ring_node_sm_f2;
22 ring_node *current_ring_node_sm_f2;
23
23
24 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
24 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
25 float averaged_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
25 float averaged_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
26 float averaged_sm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
26 float averaged_sm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
27 char averaged_sm_f0_char [ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_SM * 2 ];
27 char averaged_sm_f0_char [ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_SM ];
28 float compressed_sm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_F0 ];
28 float compressed_sm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_F0 ];
29
29
30 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F0 * 2 ];
31 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F1 ];
32 unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F2 ];
33
30 unsigned int nb_sm_f0;
34 unsigned int nb_sm_f0;
31
35
32 void init_sm_rings( void )
36 void init_sm_rings( void )
33 {
37 {
34 unsigned char i;
38 unsigned char i;
35
39
36 // F0 RING
40 // F0 RING
37 sm_ring_f0[0].next = (ring_node*) &sm_ring_f0[1];
41 sm_ring_f0[0].next = (ring_node*) &sm_ring_f0[1];
38 sm_ring_f0[0].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-1];
42 sm_ring_f0[0].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-1];
39 sm_ring_f0[0].buffer_address =
43 sm_ring_f0[0].buffer_address =
40 (int) &sm_f0[ 0 ];
44 (int) &sm_f0[ 0 ];
41
45
42 sm_ring_f0[NB_RING_NODES_ASM_F0-1].next = (ring_node*) &sm_ring_f0[0];
46 sm_ring_f0[NB_RING_NODES_ASM_F0-1].next = (ring_node*) &sm_ring_f0[0];
43 sm_ring_f0[NB_RING_NODES_ASM_F0-1].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-2];
47 sm_ring_f0[NB_RING_NODES_ASM_F0-1].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-2];
44 sm_ring_f0[NB_RING_NODES_ASM_F0-1].buffer_address =
48 sm_ring_f0[NB_RING_NODES_ASM_F0-1].buffer_address =
45 (int) &sm_f0[ (NB_RING_NODES_ASM_F0-1) * TOTAL_SIZE_SM ];
49 (int) &sm_f0[ (NB_RING_NODES_ASM_F0-1) * TOTAL_SIZE_SM ];
46
50
47 for(i=1; i<NB_RING_NODES_ASM_F0-1; i++)
51 for(i=1; i<NB_RING_NODES_ASM_F0-1; i++)
48 {
52 {
49 sm_ring_f0[i].next = (ring_node*) &sm_ring_f0[i+1];
53 sm_ring_f0[i].next = (ring_node*) &sm_ring_f0[i+1];
50 sm_ring_f0[i].previous = (ring_node*) &sm_ring_f0[i-1];
54 sm_ring_f0[i].previous = (ring_node*) &sm_ring_f0[i-1];
51 sm_ring_f0[i].buffer_address =
55 sm_ring_f0[i].buffer_address =
52 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
56 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
53 }
57 }
54
58
55 // F1 RING
59 // F1 RING
56 sm_ring_f1[0].next = (ring_node*) &sm_ring_f1[1];
60 sm_ring_f1[0].next = (ring_node*) &sm_ring_f1[1];
57 sm_ring_f1[0].previous = (ring_node*) &sm_ring_f1[NB_RING_NODES_ASM_F1-1];
61 sm_ring_f1[0].previous = (ring_node*) &sm_ring_f1[NB_RING_NODES_ASM_F1-1];
58 sm_ring_f1[0].buffer_address =
62 sm_ring_f1[0].buffer_address =
59 (int) &sm_f1[ 0 ];
63 (int) &sm_f1[ 0 ];
60
64
61 sm_ring_f1[NB_RING_NODES_ASM_F1-1].next = (ring_node*) &sm_ring_f1[0];
65 sm_ring_f1[NB_RING_NODES_ASM_F1-1].next = (ring_node*) &sm_ring_f1[0];
62 sm_ring_f1[NB_RING_NODES_ASM_F1-1].previous = (ring_node*) &sm_ring_f1[NB_RING_NODES_ASM_F1-2];
66 sm_ring_f1[NB_RING_NODES_ASM_F1-1].previous = (ring_node*) &sm_ring_f1[NB_RING_NODES_ASM_F1-2];
63 sm_ring_f1[NB_RING_NODES_ASM_F1-1].buffer_address =
67 sm_ring_f1[NB_RING_NODES_ASM_F1-1].buffer_address =
64 (int) &sm_f1[ (NB_RING_NODES_ASM_F1-1) * TOTAL_SIZE_SM ];
68 (int) &sm_f1[ (NB_RING_NODES_ASM_F1-1) * TOTAL_SIZE_SM ];
65
69
66 for(i=1; i<NB_RING_NODES_ASM_F1-1; i++)
70 for(i=1; i<NB_RING_NODES_ASM_F1-1; i++)
67 {
71 {
68 sm_ring_f1[i].next = (ring_node*) &sm_ring_f1[i+1];
72 sm_ring_f1[i].next = (ring_node*) &sm_ring_f1[i+1];
69 sm_ring_f1[i].previous = (ring_node*) &sm_ring_f1[i-1];
73 sm_ring_f1[i].previous = (ring_node*) &sm_ring_f1[i-1];
70 sm_ring_f1[i].buffer_address =
74 sm_ring_f1[i].buffer_address =
71 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
75 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
72 }
76 }
73
77
74 // F2 RING
78 // F2 RING
75 sm_ring_f2[0].next = (ring_node*) &sm_ring_f2[1];
79 sm_ring_f2[0].next = (ring_node*) &sm_ring_f2[1];
76 sm_ring_f2[0].previous = (ring_node*) &sm_ring_f2[NB_RING_NODES_ASM_F2-1];
80 sm_ring_f2[0].previous = (ring_node*) &sm_ring_f2[NB_RING_NODES_ASM_F2-1];
77 sm_ring_f2[0].buffer_address =
81 sm_ring_f2[0].buffer_address =
78 (int) &sm_f2[ 0 ];
82 (int) &sm_f2[ 0 ];
79
83
80 sm_ring_f2[NB_RING_NODES_ASM_F2-1].next = (ring_node*) &sm_ring_f2[0];
84 sm_ring_f2[NB_RING_NODES_ASM_F2-1].next = (ring_node*) &sm_ring_f2[0];
81 sm_ring_f2[NB_RING_NODES_ASM_F2-1].previous = (ring_node*) &sm_ring_f2[NB_RING_NODES_ASM_F2-2];
85 sm_ring_f2[NB_RING_NODES_ASM_F2-1].previous = (ring_node*) &sm_ring_f2[NB_RING_NODES_ASM_F2-2];
82 sm_ring_f2[NB_RING_NODES_ASM_F2-1].buffer_address =
86 sm_ring_f2[NB_RING_NODES_ASM_F2-1].buffer_address =
83 (int) &sm_f2[ (NB_RING_NODES_ASM_F2-1) * TOTAL_SIZE_SM ];
87 (int) &sm_f2[ (NB_RING_NODES_ASM_F2-1) * TOTAL_SIZE_SM ];
84
88
85 for(i=1; i<NB_RING_NODES_ASM_F2-1; i++)
89 for(i=1; i<NB_RING_NODES_ASM_F2-1; i++)
86 {
90 {
87 sm_ring_f2[i].next = (ring_node*) &sm_ring_f2[i+1];
91 sm_ring_f2[i].next = (ring_node*) &sm_ring_f2[i+1];
88 sm_ring_f2[i].previous = (ring_node*) &sm_ring_f2[i-1];
92 sm_ring_f2[i].previous = (ring_node*) &sm_ring_f2[i-1];
89 sm_ring_f2[i].buffer_address =
93 sm_ring_f2[i].buffer_address =
90 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
94 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
91 }
95 }
92
96
93 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
97 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
94 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
98 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
95 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
99 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
96
100
97 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
101 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
98 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
102 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
99 }
103 }
100
104
101 void reset_current_sm_ring_nodes( void )
105 void reset_current_sm_ring_nodes( void )
102 {
106 {
103 current_ring_node_sm_f0 = sm_ring_f0;
107 current_ring_node_sm_f0 = sm_ring_f0;
104 current_ring_node_sm_f1 = sm_ring_f1;
108 current_ring_node_sm_f1 = sm_ring_f1;
105 current_ring_node_sm_f2 = sm_ring_f2;
109 current_ring_node_sm_f2 = sm_ring_f2;
106
110
107 ring_node_for_averaging_sm_f0 = sm_ring_f0;
111 ring_node_for_averaging_sm_f0 = sm_ring_f0;
108 }
112 }
109
113
110 //***********************************************************
114 //***********************************************************
111 // Interrupt Service Routine for spectral matrices processing
115 // Interrupt Service Routine for spectral matrices processing
112 void reset_nb_sm_f0( void )
116 void reset_nb_sm_f0( void )
113 {
117 {
114 nb_sm_f0 = 0;
118 nb_sm_f0 = 0;
115 }
119 }
116
120
117 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
121 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
118 {
122 {
119 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
123 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
120
124
121 if ( (spectral_matrix_regs->status & 0x1) == 0x01)
125 if ( (spectral_matrix_regs->status & 0x1) == 0x01)
122 {
126 {
123 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
127 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
124 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
128 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
125 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
129 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
126 nb_sm_f0 = nb_sm_f0 + 1;
130 nb_sm_f0 = nb_sm_f0 + 1;
127 }
131 }
128 else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
132 else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
129 {
133 {
130 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
134 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
131 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
135 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
132 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
136 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
133 nb_sm_f0 = nb_sm_f0 + 1;
137 nb_sm_f0 = nb_sm_f0 + 1;
134 }
138 }
135
139
136 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
140 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
137 {
141 {
138 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
139 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
143 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
140 }
144 }
141
145
142 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
146 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
143
147
144 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
148 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
145 {
149 {
146 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
150 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
147 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
151 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
148 {
152 {
149 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
153 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
150 }
154 }
151 nb_sm_f0 = 0;
155 nb_sm_f0 = 0;
152 }
156 }
153 else
157 else
154 {
158 {
155 nb_sm_f0 = nb_sm_f0 + 1;
159 nb_sm_f0 = nb_sm_f0 + 1;
156 }
160 }
157 }
161 }
158
162
159 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
163 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
160 {
164 {
161 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
165 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
162 {
166 {
163 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
167 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
164 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
168 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
165 {
169 {
166 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
170 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
167 }
171 }
168 nb_sm_f0 = 0;
172 nb_sm_f0 = 0;
169 }
173 }
170 else
174 else
171 {
175 {
172 nb_sm_f0 = nb_sm_f0 + 1;
176 nb_sm_f0 = nb_sm_f0 + 1;
173 }
177 }
174 }
178 }
175
179
176 //************
180 //************
177 // RTEMS TASKS
181 // RTEMS TASKS
178
182
179 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
183 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
180 {
184 {
181 rtems_event_set event_out;
185 rtems_event_set event_out;
182
186
183 BOOT_PRINTF("in SMIQ *** \n")
187 BOOT_PRINTF("in SMIQ *** \n")
184
188
185 while(1){
189 while(1){
186 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
190 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
187 }
191 }
188 }
192 }
189
193
190 rtems_task avf0_task(rtems_task_argument argument)
194 rtems_task avf0_task(rtems_task_argument argument)
191 {
195 {
192 int i;
196 int i;
193 static int nb_average;
197 static int nb_average;
194 rtems_event_set event_out;
198 rtems_event_set event_out;
195 rtems_status_code status;
199 rtems_status_code status;
196 ring_node *ring_node_tab[8];
200 ring_node *ring_node_tab[8];
197
201
198 nb_average = 0;
202 nb_average = 0;
199
203
200 BOOT_PRINTF("in AVFO *** \n")
204 BOOT_PRINTF("in AVFO *** \n")
201
205
202 while(1){
206 while(1){
203 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
207 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
204 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
208 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
205 for (i=2; i<NB_SM_TO_RECEIVE_BEFORE_AVF0+1; i++)
209 for (i=2; i<NB_SM_TO_RECEIVE_BEFORE_AVF0+1; i++)
206 {
210 {
207 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
211 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
208 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
212 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
209 }
213 }
210
214
211 averaged_sm_f0[0] = ( (int *) (ring_node_tab[7]->buffer_address) ) [0];
215 averaged_sm_f0[0] = ( (int *) (ring_node_tab[7]->buffer_address) ) [0];
212 averaged_sm_f0[1] = ( (int *) (ring_node_tab[7]->buffer_address) ) [1];
216 averaged_sm_f0[1] = ( (int *) (ring_node_tab[7]->buffer_address) ) [1];
213 for(i=0; i<TOTAL_SIZE_SM; i++)
217 for(i=0; i<TOTAL_SIZE_SM; i++)
214 {
218 {
215 averaged_sm_f0[i] = ( (int *) (ring_node_tab[0]->buffer_address) ) [i + TIME_OFFSET]
219 averaged_sm_f0[i] = ( (int *) (ring_node_tab[0]->buffer_address) ) [i + TIME_OFFSET]
216 + ( (int *) (ring_node_tab[1]->buffer_address) ) [i + TIME_OFFSET]
220 + ( (int *) (ring_node_tab[1]->buffer_address) ) [i + TIME_OFFSET]
217 + ( (int *) (ring_node_tab[2]->buffer_address) ) [i + TIME_OFFSET]
221 + ( (int *) (ring_node_tab[2]->buffer_address) ) [i + TIME_OFFSET]
218 + ( (int *) (ring_node_tab[3]->buffer_address) ) [i + TIME_OFFSET]
222 + ( (int *) (ring_node_tab[3]->buffer_address) ) [i + TIME_OFFSET]
219 + ( (int *) (ring_node_tab[4]->buffer_address) ) [i + TIME_OFFSET]
223 + ( (int *) (ring_node_tab[4]->buffer_address) ) [i + TIME_OFFSET]
220 + ( (int *) (ring_node_tab[5]->buffer_address) ) [i + TIME_OFFSET]
224 + ( (int *) (ring_node_tab[5]->buffer_address) ) [i + TIME_OFFSET]
221 + ( (int *) (ring_node_tab[6]->buffer_address) ) [i + TIME_OFFSET]
225 + ( (int *) (ring_node_tab[6]->buffer_address) ) [i + TIME_OFFSET]
222 + ( (int *) (ring_node_tab[7]->buffer_address) ) [i + TIME_OFFSET];
226 + ( (int *) (ring_node_tab[7]->buffer_address) ) [i + TIME_OFFSET];
223 }
227 }
224
228
225 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
229 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
226 if (nb_average == NB_AVERAGE_NORMAL_f0) {
230 if (nb_average == NB_AVERAGE_NORMAL_f0) {
227 nb_average = 0;
231 nb_average = 0;
228 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
232 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
229 if (status != RTEMS_SUCCESSFUL) {
233 if (status != RTEMS_SUCCESSFUL) {
230 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
234 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
231 }
235 }
232 }
236 }
233 }
237 }
234 }
238 }
235
239
236 rtems_task matr_task(rtems_task_argument argument)
240 rtems_task matr_task(rtems_task_argument argument)
237 {
241 {
238 spw_ioctl_pkt_send spw_ioctl_send_ASM;
242 spw_ioctl_pkt_send spw_ioctl_send_ASM;
239 rtems_event_set event_out;
243 rtems_event_set event_out;
240 rtems_status_code status;
244 rtems_status_code status;
241 rtems_id queue_id;
245 rtems_id queue_id;
242 Header_TM_LFR_SCIENCE_ASM_t headerASM;
246 Header_TM_LFR_SCIENCE_ASM_t headerASM;
243
247
244 init_header_asm( &headerASM );
248 init_header_asm( &headerASM );
245
249
246 status = get_message_queue_id_send( &queue_id );
250 status = get_message_queue_id_send( &queue_id );
247 if (status != RTEMS_SUCCESSFUL)
251 if (status != RTEMS_SUCCESSFUL)
248 {
252 {
249 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
253 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
250 }
254 }
251
255
252 BOOT_PRINTF("in MATR *** \n")
256 BOOT_PRINTF("in MATR *** \n")
253
257
254 fill_averaged_spectral_matrix( );
258 fill_averaged_spectral_matrix( );
255
259
256 while(1){
260 while(1){
257 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
261 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
258 // 1) compress the matrix for Basic Parameters calculation
262 // 1) compress the matrix for Basic Parameters calculation
259 ASM_compress( averaged_sm_f0, 0, compressed_sm_f0 );
263 ASM_compress( averaged_sm_f0, 0, compressed_sm_f0 );
260 // 2)
264 // 2)
261 //BP1_set(compressed_sm_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0);
265 // BP1_set( (float *) &compressed_sm_f0[TIME_OFFSET], NB_BINS_COMPRESSED_SM_F0, (unsigned char *) &LFR_BP1_F0[TIME_OFFSET_IN_BYTES] );
262 // 3) convert the float array in a char array
266 // 3) convert the float array in a char array
263 ASM_reorganize( averaged_sm_f0, averaged_sm_f0_reorganized );
267 ASM_reorganize( averaged_sm_f0, averaged_sm_f0_reorganized );
264 ASM_convert( averaged_sm_f0_reorganized, averaged_sm_f0_char);
268 ASM_convert( averaged_sm_f0_reorganized, averaged_sm_f0_char);
265 // 4) send the spectral matrix packets
269 // 4) send the spectral matrix packets
266 ASM_send( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
270 ASM_send( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
267 }
271 }
268 }
272 }
269
273
270 //*****************************
274 //*****************************
271 // Spectral matrices processing
275 // Spectral matrices processing
272
276
273 void matrix_reset(volatile float *averaged_spec_mat)
277 void matrix_reset(volatile float *averaged_spec_mat)
274 {
278 {
275 int i;
279 int i;
276 for(i=0; i<TOTAL_SIZE_SM; i++){
280 for(i=0; i<TOTAL_SIZE_SM; i++){
277 averaged_spec_mat[i] = 0;
281 averaged_spec_mat[i] = 0;
278 }
282 }
279 }
283 }
280
284
281 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized )
285 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized )
282 {
286 {
283 int frequencyBin;
287 int frequencyBin;
284 int asmComponent;
288 int asmComponent;
285
289
286 // copy the time information
290 // copy the time information
287 averaged_spec_mat_reorganized[ 0 ] = averaged_spec_mat[ 0 ];
291 averaged_spec_mat_reorganized[ 0 ] = averaged_spec_mat[ 0 ];
288 averaged_spec_mat_reorganized[ 1 ] = averaged_spec_mat[ 1 ];
292 averaged_spec_mat_reorganized[ 1 ] = averaged_spec_mat[ 1 ];
289
293
290 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
294 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
291 {
295 {
292 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
296 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
293 {
297 {
294 averaged_spec_mat_reorganized[ frequencyBin * NB_VALUES_PER_SM + asmComponent + TIME_OFFSET ] =
298 averaged_spec_mat_reorganized[ frequencyBin * NB_VALUES_PER_SM + asmComponent + TIME_OFFSET ] =
295 averaged_spec_mat[ asmComponent * NB_BINS_PER_SM + frequencyBin + TIME_OFFSET];
299 averaged_spec_mat[ asmComponent * NB_BINS_PER_SM + frequencyBin + TIME_OFFSET];
296 }
300 }
297 }
301 }
298 }
302 }
299
303
300 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat )
304 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat )
301 {
305 {
302 int frequencyBin;
306 int frequencyBin;
303 int asmComponent;
307 int asmComponent;
304 int offsetASM;
308 int offsetASM;
305 int offsetCompressed;
309 int offsetCompressed;
306 int k;
310 int k;
307
311
308 switch (fChannel){
312 switch (fChannel){
309 case 0:
313 case 0:
310 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
314 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
311 {
315 {
312 for( frequencyBin = 0; frequencyBin < NB_BINS_COMPRESSED_SM_F0; frequencyBin++ )
316 for( frequencyBin = 0; frequencyBin < NB_BINS_COMPRESSED_SM_F0; frequencyBin++ )
313 {
317 {
314 offsetASM = asmComponent * NB_BINS_PER_SM
318 offsetCompressed = TIME_OFFSET
319 + frequencyBin * NB_VALUES_PER_SM
320 + asmComponent;
321 offsetASM = TIME_OFFSET
322 + asmComponent * NB_BINS_PER_SM
315 + ASM_F0_INDICE_START
323 + ASM_F0_INDICE_START
316 + frequencyBin * NB_BINS_TO_AVERAGE_ASM_F0;
324 + frequencyBin * NB_BINS_TO_AVERAGE_ASM_F0;
317 offsetCompressed = frequencyBin * NB_VALUES_PER_SM
318 + asmComponent;
319 compressed_spec_mat[ offsetCompressed ] = 0;
325 compressed_spec_mat[ offsetCompressed ] = 0;
320 for ( k = 0; k < NB_BINS_TO_AVERAGE_ASM_F0; k++ )
326 for ( k = 0; k < NB_BINS_TO_AVERAGE_ASM_F0; k++ )
321 {
327 {
322 compressed_spec_mat[offsetCompressed ] =
328 compressed_spec_mat[offsetCompressed ] =
323 compressed_spec_mat[ offsetCompressed ]
329 compressed_spec_mat[ offsetCompressed ]
324 + averaged_spec_mat[ offsetASM + k ];
330 + averaged_spec_mat[ offsetASM + k ];
325 }
331 }
326 }
332 }
327 }
333 }
328 break;
334 break;
329
335
330 case 1:
336 case 1:
331 // case fChannel = f1 to be completed later
337 // case fChannel = f1 to be completed later
332 break;
338 break;
333
339
334 case 2:
340 case 2:
335 // case fChannel = f1 to be completed later
341 // case fChannel = f1 to be completed later
336 break;
342 break;
337
343
338 default:
344 default:
339 break;
345 break;
340 }
346 }
341 }
347 }
342
348
343 void ASM_convert( volatile float *input_matrix, char *output_matrix)
349 void ASM_convert( volatile float *input_matrix, char *output_matrix)
344 {
350 {
345 unsigned int i;
351 unsigned int i;
346 unsigned int frequencyBin;
352 unsigned int frequencyBin;
347 unsigned int asmComponent;
353 unsigned int asmComponent;
348 char * pt_char_input;
354 char * pt_char_input;
349 char * pt_char_output;
355 char * pt_char_output;
350
356
351 pt_char_input = (char*) &input_matrix;
357 pt_char_input = (char*) &input_matrix;
352 pt_char_output = (char*) &output_matrix;
358 pt_char_output = (char*) &output_matrix;
353
359
354 // copy the time information
360 // copy the time information
355 for (i=0; i<TIME_OFFSET_IN_BYTES; i++)
361 for (i=0; i<TIME_OFFSET_IN_BYTES; i++)
356 {
362 {
357 pt_char_output[ i ] = pt_char_output[ i ];
363 pt_char_output[ i ] = pt_char_output[ i ];
358 }
364 }
359
365
360 // convert all other data
366 // convert all other data
361 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
367 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
362 {
368 {
363 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
369 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
364 {
370 {
365 pt_char_input = (char*) &input_matrix [ (frequencyBin*NB_VALUES_PER_SM) + asmComponent + TIME_OFFSET ];
371 pt_char_input = (char*) &input_matrix [ (frequencyBin*NB_VALUES_PER_SM) + asmComponent + TIME_OFFSET ];
366 pt_char_output = (char*) &output_matrix[ 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) + TIME_OFFSET_IN_BYTES ];
372 pt_char_output = (char*) &output_matrix[ 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) + TIME_OFFSET_IN_BYTES ];
367 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
373 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
368 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
374 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
369 }
375 }
370 }
376 }
371 }
377 }
372
378
373 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
379 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
374 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
380 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
375 {
381 {
376 unsigned int i;
382 unsigned int i;
377 unsigned int length = 0;
383 unsigned int length = 0;
378 rtems_status_code status;
384 rtems_status_code status;
379
385
380 for (i=0; i<2; i++)
386 for (i=0; i<2; i++)
381 {
387 {
382 // (1) BUILD THE DATA
388 // (1) BUILD THE DATA
383 switch(sid)
389 switch(sid)
384 {
390 {
385 case SID_NORM_ASM_F0:
391 case SID_NORM_ASM_F0:
386 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2;
392 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2;
387 spw_ioctl_send->data = &spectral_matrix[
393 spw_ioctl_send->data = &spectral_matrix[
388 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
394 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
389 + TIME_OFFSET_IN_BYTES
395 + TIME_OFFSET_IN_BYTES
390 ];
396 ];
391 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
397 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
392 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
398 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
393 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
399 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
394 break;
400 break;
395 case SID_NORM_ASM_F1:
401 case SID_NORM_ASM_F1:
396 break;
402 break;
397 case SID_NORM_ASM_F2:
403 case SID_NORM_ASM_F2:
398 break;
404 break;
399 default:
405 default:
400 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
406 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
401 break;
407 break;
402 }
408 }
403 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
409 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
404 spw_ioctl_send->hdr = (char *) header;
410 spw_ioctl_send->hdr = (char *) header;
405 spw_ioctl_send->options = 0;
411 spw_ioctl_send->options = 0;
406
412
407 // (2) BUILD THE HEADER
413 // (2) BUILD THE HEADER
408 header->packetLength[0] = (unsigned char) (length>>8);
414 header->packetLength[0] = (unsigned char) (length>>8);
409 header->packetLength[1] = (unsigned char) (length);
415 header->packetLength[1] = (unsigned char) (length);
410 header->sid = (unsigned char) sid; // SID
416 header->sid = (unsigned char) sid; // SID
411 header->pa_lfr_pkt_cnt_asm = 2;
417 header->pa_lfr_pkt_cnt_asm = 2;
412 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
418 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
413
419
414 // (3) SET PACKET TIME
420 // (3) SET PACKET TIME
415 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
421 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
416 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
422 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
417 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
423 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
418 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
424 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
419 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
425 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
420 header->time[5] = (unsigned char) (time_management_regs->fine_time);
426 header->time[5] = (unsigned char) (time_management_regs->fine_time);
421 //
427 //
422 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
428 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
423 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
429 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
424 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
430 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
425 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
431 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
426 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
432 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
427 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
433 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
428
434
429 // (4) SEND PACKET
435 // (4) SEND PACKET
430 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
436 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
431 if (status != RTEMS_SUCCESSFUL) {
437 if (status != RTEMS_SUCCESSFUL) {
432 printf("in ASM_send *** ERR %d\n", (int) status);
438 printf("in ASM_send *** ERR %d\n", (int) status);
433 }
439 }
434 }
440 }
435 }
441 }
436
442
437 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
443 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
438 int i;
444 int i;
439 int j;
445 int j;
440 unsigned char tmp_u_char;
446 unsigned char tmp_u_char;
441 unsigned char * pt_char = NULL;
447 unsigned char * pt_char = NULL;
442 float PSDB, PSDE;
448 float PSDB, PSDE;
443 float NVEC_V0;
449 float NVEC_V0;
444 float NVEC_V1;
450 float NVEC_V1;
445 float NVEC_V2;
451 float NVEC_V2;
446 //float significand;
452 //float significand;
447 //int exponent;
453 //int exponent;
448 float aux;
454 float aux;
449 float tr_SB_SB;
455 float tr_SB_SB;
450 float tmp;
456 float tmp;
451 float sx_re;
457 float sx_re;
452 float sx_im;
458 float sx_im;
453 float nebx_re = 0;
459 float nebx_re = 0;
454 float nebx_im = 0;
460 float nebx_im = 0;
455 float ny = 0;
461 float ny = 0;
456 float nz = 0;
462 float nz = 0;
457 float bx_bx_star = 0;
463 float bx_bx_star = 0;
458 for(i=0; i<nb_bins_compressed_spec_mat; i++){
464 for(i=0; i<nb_bins_compressed_spec_mat; i++){
459 //==============================================
465 //==============================================
460 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
466 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
461 PSDB = compressed_spec_mat[i*30] // S11
467 PSDB = compressed_spec_mat[i*30] // S11
462 + compressed_spec_mat[(i*30) + 10] // S22
468 + compressed_spec_mat[(i*30) + 10] // S22
463 + compressed_spec_mat[(i*30) + 18]; // S33
469 + compressed_spec_mat[(i*30) + 18]; // S33
464 //significand = frexp(PSDB, &exponent);
470 //significand = frexp(PSDB, &exponent);
465 pt_char = (unsigned char*) &PSDB;
471 pt_char = (unsigned char*) &PSDB;
466 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
472 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
467 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
473 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
468 //==============================================
474 //==============================================
469 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
475 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
470 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
476 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
471 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
477 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
472 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
478 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
473 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
479 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
474 pt_char = (unsigned char*) &PSDE;
480 pt_char = (unsigned char*) &PSDE;
475 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
481 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
476 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
482 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
477 //==============================================================================
483 //==============================================================================
478 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
484 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
479 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
485 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
480 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
486 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
481 tmp = sqrt(
487 tmp = sqrt(
482 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
488 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
483 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
489 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
484 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
490 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
485 );
491 );
486 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
492 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
487 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
493 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
488 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
494 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
489 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
495 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
490 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
496 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
491 pt_char = (unsigned char*) &NVEC_V2;
497 pt_char = (unsigned char*) &NVEC_V2;
492 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
498 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
493 //=======================================================
499 //=======================================================
494 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
500 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
495 aux = 2*tmp / PSDB; // compute the ellipticity
501 aux = 2*tmp / PSDB; // compute the ellipticity
496 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
502 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
497 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
503 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
498 //==============================================================
504 //==============================================================
499 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
505 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
500 for(j = 0; j<NB_VALUES_PER_SM;j++){
506 for(j = 0; j<NB_VALUES_PER_SM;j++){
501 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
507 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
502 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
508 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
503 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
509 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
504 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
510 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
505 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
511 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
506 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
512 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
507 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
513 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
508 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
514 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
509 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
515 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
510 }
516 }
511 aux = PSDB*PSDB;
517 aux = PSDB*PSDB;
512 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
518 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
513 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
519 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
514 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
520 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
515 //=======================================================================================
521 //=======================================================================================
516 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
522 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
517 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
523 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
518 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
524 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
519 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
525 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
520 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
526 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
521 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
527 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
522 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
528 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
523 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
529 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
524 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
530 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
525 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
531 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
526 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
532 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
527 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
533 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
528 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
534 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
529 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
535 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
530 if ( abs(sx_re) > abs(sx_im) ) {
536 if ( abs(sx_re) > abs(sx_im) ) {
531 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
537 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
532 }
538 }
533 else {
539 else {
534 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
540 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
535 }
541 }
536 //======================================================================
542 //======================================================================
537 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
543 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
538 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
544 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
539 nz = NVEC_V0;
545 nz = NVEC_V0;
540 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
546 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
541 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
547 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
542 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
548 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
543 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
549 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
544 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
550 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
545 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
551 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
546 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
552 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
547 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
553 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
548 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
554 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
549 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
555 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
550 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
556 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
551 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
557 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
552 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
558 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
553 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
559 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
554 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
560 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
555 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
561 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
556 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
562 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
557 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
563 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
558 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
564 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
559 tmp = nebx_re / bx_bx_star;
565 tmp = nebx_re / bx_bx_star;
560 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
566 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
561 if ( abs(nebx_re) > abs(nebx_im) ) {
567 if ( abs(nebx_re) > abs(nebx_im) ) {
562 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
568 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
563 }
569 }
564 else {
570 else {
565 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
571 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
566 }
572 }
567 }
573 }
568
574
569 }
575 }
570
576
571 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
577 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
572 // BP2 autocorrelation
578 // BP2 autocorrelation
573 int i;
579 int i;
574 int aux = 0;
580 int aux = 0;
575
581
576 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
582 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
577 // S12
583 // S12
578 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
584 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
579 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
585 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
580 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
586 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
581 // S13
587 // S13
582 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
588 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
583 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
589 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
584 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
590 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
585 // S23
591 // S23
586 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
592 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
587 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
593 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
588 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
594 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
589 // S45
595 // S45
590 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
596 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
591 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
597 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
592 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
598 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
593 // S14
599 // S14
594 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
600 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
595 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
601 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
596 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
602 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
597 // S15
603 // S15
598 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
604 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
599 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
605 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
600 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
606 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
601 // S24
607 // S24
602 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
608 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
603 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
609 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
604 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
610 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
605 // S25
611 // S25
606 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
612 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
607 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
613 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
608 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
614 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
609 // S34
615 // S34
610 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
616 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
611 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
617 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
612 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
618 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
613 // S35
619 // S35
614 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
620 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
615 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
621 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
616 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
622 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
617 }
623 }
618 }
624 }
619
625
620 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header)
626 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header)
621 {
627 {
622 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
628 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
623 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
629 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
624 header->reserved = 0x00;
630 header->reserved = 0x00;
625 header->userApplication = CCSDS_USER_APP;
631 header->userApplication = CCSDS_USER_APP;
626 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
632 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
627 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
633 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
628 header->packetSequenceControl[0] = 0xc0;
634 header->packetSequenceControl[0] = 0xc0;
629 header->packetSequenceControl[1] = 0x00;
635 header->packetSequenceControl[1] = 0x00;
630 header->packetLength[0] = 0x00;
636 header->packetLength[0] = 0x00;
631 header->packetLength[1] = 0x00;
637 header->packetLength[1] = 0x00;
632 // DATA FIELD HEADER
638 // DATA FIELD HEADER
633 header->spare1_pusVersion_spare2 = 0x10;
639 header->spare1_pusVersion_spare2 = 0x10;
634 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
640 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
635 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
641 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
636 header->destinationID = TM_DESTINATION_ID_GROUND;
642 header->destinationID = TM_DESTINATION_ID_GROUND;
637 // AUXILIARY DATA HEADER
643 // AUXILIARY DATA HEADER
638 header->sid = 0x00;
644 header->sid = 0x00;
639 header->biaStatusInfo = 0x00;
645 header->biaStatusInfo = 0x00;
640 header->pa_lfr_pkt_cnt_asm = 0x00;
646 header->pa_lfr_pkt_cnt_asm = 0x00;
641 header->pa_lfr_pkt_nr_asm = 0x00;
647 header->pa_lfr_pkt_nr_asm = 0x00;
642 header->time[0] = 0x00;
648 header->time[0] = 0x00;
643 header->time[0] = 0x00;
649 header->time[0] = 0x00;
644 header->time[0] = 0x00;
650 header->time[0] = 0x00;
645 header->time[0] = 0x00;
651 header->time[0] = 0x00;
646 header->time[0] = 0x00;
652 header->time[0] = 0x00;
647 header->time[0] = 0x00;
653 header->time[0] = 0x00;
648 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
654 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
649 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
655 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
650 }
656 }
651
657
652 void fill_averaged_spectral_matrix(void)
658 void fill_averaged_spectral_matrix(void)
653 {
659 {
654 /** This function fills spectral matrices related buffers with arbitrary data.
660 /** This function fills spectral matrices related buffers with arbitrary data.
655 *
661 *
656 * This function is for testing purpose only.
662 * This function is for testing purpose only.
657 *
663 *
658 */
664 */
659
665
660 float offset;
666 float offset;
661 float coeff;
667 float coeff;
662
668
663 offset = 10.;
669 offset = 10.;
664 coeff = 100000.;
670 coeff = 100000.;
665 averaged_sm_f0[ 0 + 25 * 0 ] = 0. + offset;
671 averaged_sm_f0[ 0 + 25 * 0 ] = 0. + offset;
666 averaged_sm_f0[ 0 + 25 * 1 ] = 1. + offset;
672 averaged_sm_f0[ 0 + 25 * 1 ] = 1. + offset;
667 averaged_sm_f0[ 0 + 25 * 2 ] = 2. + offset;
673 averaged_sm_f0[ 0 + 25 * 2 ] = 2. + offset;
668 averaged_sm_f0[ 0 + 25 * 3 ] = 3. + offset;
674 averaged_sm_f0[ 0 + 25 * 3 ] = 3. + offset;
669 averaged_sm_f0[ 0 + 25 * 4 ] = 4. + offset;
675 averaged_sm_f0[ 0 + 25 * 4 ] = 4. + offset;
670 averaged_sm_f0[ 0 + 25 * 5 ] = 5. + offset;
676 averaged_sm_f0[ 0 + 25 * 5 ] = 5. + offset;
671 averaged_sm_f0[ 0 + 25 * 6 ] = 6. + offset;
677 averaged_sm_f0[ 0 + 25 * 6 ] = 6. + offset;
672 averaged_sm_f0[ 0 + 25 * 7 ] = 7. + offset;
678 averaged_sm_f0[ 0 + 25 * 7 ] = 7. + offset;
673 averaged_sm_f0[ 0 + 25 * 8 ] = 8. + offset;
679 averaged_sm_f0[ 0 + 25 * 8 ] = 8. + offset;
674 averaged_sm_f0[ 0 + 25 * 9 ] = 9. + offset;
680 averaged_sm_f0[ 0 + 25 * 9 ] = 9. + offset;
675 averaged_sm_f0[ 0 + 25 * 10 ] = 10. + offset;
681 averaged_sm_f0[ 0 + 25 * 10 ] = 10. + offset;
676 averaged_sm_f0[ 0 + 25 * 11 ] = 11. + offset;
682 averaged_sm_f0[ 0 + 25 * 11 ] = 11. + offset;
677 averaged_sm_f0[ 0 + 25 * 12 ] = 12. + offset;
683 averaged_sm_f0[ 0 + 25 * 12 ] = 12. + offset;
678 averaged_sm_f0[ 0 + 25 * 13 ] = 13. + offset;
684 averaged_sm_f0[ 0 + 25 * 13 ] = 13. + offset;
679 averaged_sm_f0[ 0 + 25 * 14 ] = 14. + offset;
685 averaged_sm_f0[ 0 + 25 * 14 ] = 14. + offset;
680 averaged_sm_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff;
686 averaged_sm_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff;
681 averaged_sm_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff;
687 averaged_sm_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff;
682 averaged_sm_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff;
688 averaged_sm_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff;
683 averaged_sm_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff;
689 averaged_sm_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff;
684 averaged_sm_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff;
690 averaged_sm_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff;
685 averaged_sm_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff;
691 averaged_sm_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff;
686 averaged_sm_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff;
692 averaged_sm_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff;
687 averaged_sm_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff;
693 averaged_sm_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff;
688 averaged_sm_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff;
694 averaged_sm_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff;
689 averaged_sm_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff;
695 averaged_sm_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff;
690 averaged_sm_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff;
696 averaged_sm_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff;
691 averaged_sm_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff;
697 averaged_sm_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff;
692 averaged_sm_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff;
698 averaged_sm_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff;
693 averaged_sm_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff;
699 averaged_sm_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff;
694 averaged_sm_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff;
700 averaged_sm_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff;
695
701
696 offset = 10000000;
702 offset = 10000000;
697 averaged_sm_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff;
703 averaged_sm_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff;
698 averaged_sm_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff;
704 averaged_sm_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff;
699 averaged_sm_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff;
705 averaged_sm_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff;
700 averaged_sm_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff;
706 averaged_sm_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff;
701 averaged_sm_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff;
707 averaged_sm_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff;
702 averaged_sm_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff;
708 averaged_sm_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff;
703 averaged_sm_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff;
709 averaged_sm_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff;
704 averaged_sm_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff;
710 averaged_sm_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff;
705 averaged_sm_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff;
711 averaged_sm_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff;
706 averaged_sm_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff;
712 averaged_sm_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff;
707 averaged_sm_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff;
713 averaged_sm_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff;
708 averaged_sm_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff;
714 averaged_sm_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff;
709 averaged_sm_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff;
715 averaged_sm_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff;
710 averaged_sm_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff;
716 averaged_sm_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff;
711 averaged_sm_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff;
717 averaged_sm_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff;
712
718
713 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_sm_f0[ 0 ];
719 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_sm_f0[ 0 ];
714 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_sm_f0[ 1 ];
720 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_sm_f0[ 1 ];
715 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_sm_f0[ 2 ];
721 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_sm_f0[ 2 ];
716 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_sm_f0[ 3 ];
722 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_sm_f0[ 3 ];
717 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_sm_f0[ 4 ];
723 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_sm_f0[ 4 ];
718 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_sm_f0[ 5 ];
724 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_sm_f0[ 5 ];
719 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_sm_f0[ 6 ];
725 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_sm_f0[ 6 ];
720 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_sm_f0[ 7 ];
726 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_sm_f0[ 7 ];
721 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_sm_f0[ 8 ];
727 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_sm_f0[ 8 ];
722 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_sm_f0[ 9 ];
728 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_sm_f0[ 9 ];
723 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_sm_f0[ 10 ];
729 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_sm_f0[ 10 ];
724 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_sm_f0[ 11 ];
730 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_sm_f0[ 11 ];
725 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_sm_f0[ 12 ];
731 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_sm_f0[ 12 ];
726 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_sm_f0[ 13 ];
732 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_sm_f0[ 13 ];
727 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_sm_f0[ 14 ];
733 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_sm_f0[ 14 ];
728 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_sm_f0[ 15 ];
734 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_sm_f0[ 15 ];
729 }
735 }
730
736
731 void reset_spectral_matrix_regs()
737 void reset_spectral_matrix_regs()
732 {
738 {
733 /** This function resets the spectral matrices module registers.
739 /** This function resets the spectral matrices module registers.
734 *
740 *
735 * The registers affected by this function are located at the following offset addresses:
741 * The registers affected by this function are located at the following offset addresses:
736 *
742 *
737 * - 0x00 config
743 * - 0x00 config
738 * - 0x04 status
744 * - 0x04 status
739 * - 0x08 matrixF0_Address0
745 * - 0x08 matrixF0_Address0
740 * - 0x10 matrixFO_Address1
746 * - 0x10 matrixFO_Address1
741 * - 0x14 matrixF1_Address
747 * - 0x14 matrixF1_Address
742 * - 0x18 matrixF2_Address
748 * - 0x18 matrixF2_Address
743 *
749 *
744 */
750 */
745
751
746 spectral_matrix_regs->config = 0x00;
752 spectral_matrix_regs->config = 0x00;
747 spectral_matrix_regs->status = 0x00;
753 spectral_matrix_regs->status = 0x00;
748
754
749 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
755 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
750 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
756 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
751 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
757 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
752 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
758 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
753 }
759 }
754
760
755 //******************
761 //******************
756 // general functions
762 // general functions
757
763
758
764
759
765
760
766
@@ -1,601 +1,611
1 /** Functions related to the SpaceWire interface.
1 /** Functions related to the SpaceWire interface.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle SpaceWire transmissions:
6 * A group of functions to handle SpaceWire transmissions:
7 * - configuration of the SpaceWire link
7 * - configuration of the SpaceWire link
8 * - SpaceWire related interruption requests processing
8 * - SpaceWire related interruption requests processing
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
11 *
11 *
12 */
12 */
13
13
14 #include "fsw_spacewire.h"
14 #include "fsw_spacewire.h"
15
15
16 rtems_name semq_name;
16 rtems_name semq_name;
17 rtems_id semq_id;
17 rtems_id semq_id;
18
18
19 //***********
19 //***********
20 // RTEMS TASK
20 // RTEMS TASK
21 rtems_task spiq_task(rtems_task_argument unused)
21 rtems_task spiq_task(rtems_task_argument unused)
22 {
22 {
23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
24 *
24 *
25 * @param unused is the starting argument of the RTEMS task
25 * @param unused is the starting argument of the RTEMS task
26 *
26 *
27 */
27 */
28
28
29 rtems_event_set event_out;
29 rtems_event_set event_out;
30 rtems_status_code status;
30 rtems_status_code status;
31 int linkStatus;
31 int linkStatus;
32
32
33 BOOT_PRINTF("in SPIQ *** \n")
33 BOOT_PRINTF("in SPIQ *** \n")
34
34
35 while(true){
35 while(true){
36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
38
38
39 // [0] SUSPEND RECV AND SEND TASKS
39 // [0] SUSPEND RECV AND SEND TASKS
40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
41 if ( status != RTEMS_SUCCESSFUL ) {
41 if ( status != RTEMS_SUCCESSFUL ) {
42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
43 }
43 }
44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
45 if ( status != RTEMS_SUCCESSFUL ) {
45 if ( status != RTEMS_SUCCESSFUL ) {
46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
47 }
47 }
48
48
49 // [1] CHECK THE LINK
49 // [1] CHECK THE LINK
50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
51 if ( linkStatus != 5) {
51 if ( linkStatus != 5) {
52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
54 }
54 }
55
55
56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
59 {
59 {
60 spacewire_compute_stats_offsets();
60 spacewire_compute_stats_offsets();
61 status = spacewire_reset_link( );
61 status = spacewire_reset_link( );
62 }
62 }
63 else // [2.b] in run state, start the link
63 else // [2.b] in run state, start the link
64 {
64 {
65 status = spacewire_stop_start_link( fdSPW ); // start the link
65 status = spacewire_stop_start_link( fdSPW ); // start the link
66 if ( status != RTEMS_SUCCESSFUL)
66 if ( status != RTEMS_SUCCESSFUL)
67 {
67 {
68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
69 }
69 }
70 }
70 }
71
71
72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
74 {
74 {
75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
76 if ( status != RTEMS_SUCCESSFUL ) {
76 if ( status != RTEMS_SUCCESSFUL ) {
77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
78 }
78 }
79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
80 if ( status != RTEMS_SUCCESSFUL ) {
80 if ( status != RTEMS_SUCCESSFUL ) {
81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
82 }
82 }
83 }
83 }
84 else // [3.b] the link is not in run state, go in STANDBY mode
84 else // [3.b] the link is not in run state, go in STANDBY mode
85 {
85 {
86 status = stop_current_mode();
86 status = stop_current_mode();
87 if ( status != RTEMS_SUCCESSFUL ) {
87 if ( status != RTEMS_SUCCESSFUL ) {
88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
89 }
89 }
90 status = enter_mode( LFR_MODE_STANDBY );
90 status = enter_mode( LFR_MODE_STANDBY );
91 if ( status != RTEMS_SUCCESSFUL ) {
91 if ( status != RTEMS_SUCCESSFUL ) {
92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
93 }
93 }
94 // wake the WTDG task up to wait for the link recovery
94 // wake the WTDG task up to wait for the link recovery
95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
96 status = rtems_task_suspend( RTEMS_SELF );
96 status = rtems_task_suspend( RTEMS_SELF );
97 }
97 }
98 }
98 }
99 }
99 }
100
100
101 rtems_task recv_task( rtems_task_argument unused )
101 rtems_task recv_task( rtems_task_argument unused )
102 {
102 {
103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
104 *
104 *
105 * @param unused is the starting argument of the RTEMS task
105 * @param unused is the starting argument of the RTEMS task
106 *
106 *
107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
108 * 1. It reads the incoming data.
108 * 1. It reads the incoming data.
109 * 2. Launches the acceptance procedure.
109 * 2. Launches the acceptance procedure.
110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
111 *
111 *
112 */
112 */
113
113
114 int len;
114 int len;
115 ccsdsTelecommandPacket_t currentTC;
115 ccsdsTelecommandPacket_t currentTC;
116 unsigned char computed_CRC[ 2 ];
116 unsigned char computed_CRC[ 2 ];
117 unsigned char currentTC_LEN_RCV[ 2 ];
117 unsigned char currentTC_LEN_RCV[ 2 ];
118 unsigned char destinationID;
118 unsigned char destinationID;
119 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
119 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
120 unsigned int parserCode;
120 unsigned int parserCode;
121 unsigned char time[6];
122 rtems_status_code status;
121 rtems_status_code status;
123 rtems_id queue_recv_id;
122 rtems_id queue_recv_id;
124 rtems_id queue_send_id;
123 rtems_id queue_send_id;
125
124
126 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
125 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
127
126
128 status = get_message_queue_id_recv( &queue_recv_id );
127 status = get_message_queue_id_recv( &queue_recv_id );
129 if (status != RTEMS_SUCCESSFUL)
128 if (status != RTEMS_SUCCESSFUL)
130 {
129 {
131 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
130 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
132 }
131 }
133
132
134 status = get_message_queue_id_send( &queue_send_id );
133 status = get_message_queue_id_send( &queue_send_id );
135 if (status != RTEMS_SUCCESSFUL)
134 if (status != RTEMS_SUCCESSFUL)
136 {
135 {
137 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
136 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
138 }
137 }
139
138
140 BOOT_PRINTF("in RECV *** \n")
139 BOOT_PRINTF("in RECV *** \n")
141
140
142 while(1)
141 while(1)
143 {
142 {
144 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
143 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
145 if (len == -1){ // error during the read call
144 if (len == -1){ // error during the read call
146 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
145 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
147 }
146 }
148 else {
147 else {
149 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
148 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
150 PRINTF("in RECV *** packet lenght too short\n")
149 PRINTF("in RECV *** packet lenght too short\n")
151 }
150 }
152 else {
151 else {
153 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
152 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
154 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
153 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
155 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
154 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
156 // CHECK THE TC
155 // CHECK THE TC
157 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
156 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
158 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
157 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
159 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
158 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
160 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
159 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
161 || (parserCode == WRONG_SRC_ID) )
160 || (parserCode == WRONG_SRC_ID) )
162 { // send TM_LFR_TC_EXE_CORRUPTED
161 { // send TM_LFR_TC_EXE_CORRUPTED
162 PRINTF1("TC corrupted received, with code: %d\n", parserCode)
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
164 &&
164 &&
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
166 )
166 )
167 {
167 {
168 if ( parserCode == WRONG_SRC_ID )
168 if ( parserCode == WRONG_SRC_ID )
169 {
169 {
170 destinationID = SID_TC_GROUND;
170 destinationID = SID_TC_GROUND;
171 }
171 }
172 else
172 else
173 {
173 {
174 destinationID = currentTC.sourceID;
174 destinationID = currentTC.sourceID;
175 }
175 }
176 getTime( time );
177 close_action( &currentTC, LFR_DEFAULT, queue_send_id );
178 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
176 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
179 computed_CRC, currentTC_LEN_RCV,
177 computed_CRC, currentTC_LEN_RCV,
180 destinationID );
178 destinationID );
181 }
179 }
182 }
180 }
183 else
181 else
184 { // send valid TC to the action launcher
182 { // send valid TC to the action launcher
185 status = rtems_message_queue_send( queue_recv_id, &currentTC,
183 status = rtems_message_queue_send( queue_recv_id, &currentTC,
186 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
184 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
187 }
185 }
188 }
186 }
189 }
187 }
190 }
188 }
191 }
189 }
192
190
193 rtems_task send_task( rtems_task_argument argument)
191 rtems_task send_task( rtems_task_argument argument)
194 {
192 {
195 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
193 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
196 *
194 *
197 * @param unused is the starting argument of the RTEMS task
195 * @param unused is the starting argument of the RTEMS task
198 *
196 *
199 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
197 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
200 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
198 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
201 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
199 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
202 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
200 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
203 * data it contains.
201 * data it contains.
204 *
202 *
205 */
203 */
206
204
207 rtems_status_code status; // RTEMS status code
205 rtems_status_code status; // RTEMS status code
208 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
206 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
209 spw_ioctl_pkt_send *spw_ioctl_send;
207 spw_ioctl_pkt_send *spw_ioctl_send;
210 size_t size; // size of the incoming TC packet
208 size_t size; // size of the incoming TC packet
211 u_int32_t count;
209 u_int32_t count;
212 rtems_id queue_id;
210 rtems_id queue_id;
213
211
214 status = get_message_queue_id_send( &queue_id );
212 status = get_message_queue_id_send( &queue_id );
215 if (status != RTEMS_SUCCESSFUL)
213 if (status != RTEMS_SUCCESSFUL)
216 {
214 {
217 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
215 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
218 }
216 }
219
217
220 BOOT_PRINTF("in SEND *** \n")
218 BOOT_PRINTF("in SEND *** \n")
221
219
222 while(1)
220 while(1)
223 {
221 {
224 status = rtems_message_queue_receive( queue_id, incomingData, &size,
222 status = rtems_message_queue_receive( queue_id, incomingData, &size,
225 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
223 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
226
224
227 if (status!=RTEMS_SUCCESSFUL)
225 if (status!=RTEMS_SUCCESSFUL)
228 {
226 {
229 PRINTF1("in SEND *** (1) ERR = %d\n", status)
227 PRINTF1("in SEND *** (1) ERR = %d\n", status)
230 }
228 }
231 else
229 else
232 {
230 {
233 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
231 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
234 {
232 {
235 status = write( fdSPW, incomingData, size );
233 status = write( fdSPW, incomingData, size );
236 if (status == -1){
234 if (status == -1){
237 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
235 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
238 }
236 }
239 }
237 }
240 else // the incoming message is a spw_ioctl_pkt_send structure
238 else // the incoming message is a spw_ioctl_pkt_send structure
241 {
239 {
242 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
240 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
243 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
241 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
244 if (status == -1){
242 if (status == -1){
245 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
243 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
246 }
244 }
247 }
245 }
248 }
246 }
249
247
250 status = rtems_message_queue_get_number_pending( queue_id, &count );
248 status = rtems_message_queue_get_number_pending( queue_id, &count );
251 if (status != RTEMS_SUCCESSFUL)
249 if (status != RTEMS_SUCCESSFUL)
252 {
250 {
253 PRINTF1("in SEND *** (3) ERR = %d\n", status)
251 PRINTF1("in SEND *** (3) ERR = %d\n", status)
254 }
252 }
255 else
253 else
256 {
254 {
257 if (count > maxCount)
255 if (count > maxCount)
258 {
256 {
259 maxCount = count;
257 maxCount = count;
260 }
258 }
261 }
259 }
262 }
260 }
263 }
261 }
264
262
265 rtems_task wtdg_task( rtems_task_argument argument )
263 rtems_task wtdg_task( rtems_task_argument argument )
266 {
264 {
267 rtems_event_set event_out;
265 rtems_event_set event_out;
268 rtems_status_code status;
266 rtems_status_code status;
269 int linkStatus;
267 int linkStatus;
270
268
271 BOOT_PRINTF("in WTDG ***\n")
269 BOOT_PRINTF("in WTDG ***\n")
272
270
273 while(1)
271 while(1)
274 {
272 {
275 // wait for an RTEMS_EVENT
273 // wait for an RTEMS_EVENT
276 rtems_event_receive( RTEMS_EVENT_0,
274 rtems_event_receive( RTEMS_EVENT_0,
277 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
275 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
278 PRINTF("in WTDG *** wait for the link\n")
276 PRINTF("in WTDG *** wait for the link\n")
279 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
277 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
280 while( linkStatus != 5) // wait for the link
278 while( linkStatus != 5) // wait for the link
281 {
279 {
282 rtems_task_wake_after( 10 );
280 rtems_task_wake_after( 10 );
283 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
281 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
284 }
282 }
285
283
286 status = spacewire_stop_start_link( fdSPW );
284 status = spacewire_stop_start_link( fdSPW );
287
285
288 if (status != RTEMS_SUCCESSFUL)
286 if (status != RTEMS_SUCCESSFUL)
289 {
287 {
290 PRINTF1("in WTDG *** ERR link not started %d\n", status)
288 PRINTF1("in WTDG *** ERR link not started %d\n", status)
291 }
289 }
292 else
290 else
293 {
291 {
294 PRINTF("in WTDG *** OK link started\n")
292 PRINTF("in WTDG *** OK link started\n")
295 }
293 }
296
294
297 // restart the SPIQ task
295 // restart the SPIQ task
298 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
296 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
299 if ( status != RTEMS_SUCCESSFUL ) {
297 if ( status != RTEMS_SUCCESSFUL ) {
300 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
298 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
301 }
299 }
302
300
303 // restart RECV and SEND
301 // restart RECV and SEND
304 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
302 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
305 if ( status != RTEMS_SUCCESSFUL ) {
303 if ( status != RTEMS_SUCCESSFUL ) {
306 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
304 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
307 }
305 }
308 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
306 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
309 if ( status != RTEMS_SUCCESSFUL ) {
307 if ( status != RTEMS_SUCCESSFUL ) {
310 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
308 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
311 }
309 }
312 }
310 }
313 }
311 }
314
312
315 //****************
313 //****************
316 // OTHER FUNCTIONS
314 // OTHER FUNCTIONS
317 int spacewire_open_link( void )
315 int spacewire_open_link( void )
318 {
316 {
319 /** This function opens the SpaceWire link.
317 /** This function opens the SpaceWire link.
320 *
318 *
321 * @return a valid file descriptor in case of success, -1 in case of a failure
319 * @return a valid file descriptor in case of success, -1 in case of a failure
322 *
320 *
323 */
321 */
324 rtems_status_code status;
322 rtems_status_code status;
325
323
326 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
324 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
327 if ( fdSPW < 0 ) {
325 if ( fdSPW < 0 ) {
328 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
326 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
329 }
327 }
330 else
328 else
331 {
329 {
332 status = RTEMS_SUCCESSFUL;
330 status = RTEMS_SUCCESSFUL;
333 }
331 }
334
332
335 return status;
333 return status;
336 }
334 }
337
335
338 int spacewire_start_link( int fd )
336 int spacewire_start_link( int fd )
339 {
337 {
340 rtems_status_code status;
338 rtems_status_code status;
341
339
342 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
340 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
343 // -1 default hardcoded driver timeout
341 // -1 default hardcoded driver timeout
344
342
345 return status;
343 return status;
346 }
344 }
347
345
348 int spacewire_stop_start_link( int fd )
346 int spacewire_stop_start_link( int fd )
349 {
347 {
350 rtems_status_code status;
348 rtems_status_code status;
351
349
352 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
350 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
353 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
351 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
354 // -1 default hardcoded driver timeout
352 // -1 default hardcoded driver timeout
355
353
356 return status;
354 return status;
357 }
355 }
358
356
359 int spacewire_configure_link( int fd )
357 int spacewire_configure_link( int fd )
360 {
358 {
361 /** This function configures the SpaceWire link.
359 /** This function configures the SpaceWire link.
362 *
360 *
363 * @return GR-RTEMS-DRIVER directive status codes:
361 * @return GR-RTEMS-DRIVER directive status codes:
364 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
362 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
365 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
363 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
366 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
364 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
367 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
365 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
368 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
366 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
369 * - 5 EIO - Error when writing to grswp hardware registers.
367 * - 5 EIO - Error when writing to grswp hardware registers.
370 * - 2 ENOENT - No such file or directory
368 * - 2 ENOENT - No such file or directory
371 */
369 */
372
370
373 rtems_status_code status;
371 rtems_status_code status;
374
372
375 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
373 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
376 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
374 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
377
375
378 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
376 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
379 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
377 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
380 //
378 //
381 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
379 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
382 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
380 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
383 //
381 //
384 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
382 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
385 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
383 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
386 //
384 //
387 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
385 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
388 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
386 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
389 //
387 //
390 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
388 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
391 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
389 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
392 //
390 //
393 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
391 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
394 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
392 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
395 //
393 //
396 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
394 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
397 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
395 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
398
396
399 return status;
397 return status;
400 }
398 }
401
399
402 int spacewire_reset_link( void )
400 int spacewire_reset_link( void )
403 {
401 {
404 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
402 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
405 *
403 *
406 * @return RTEMS directive status code:
404 * @return RTEMS directive status code:
407 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
405 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
408 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
406 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
409 *
407 *
410 */
408 */
411
409
412 rtems_status_code status_spw;
410 rtems_status_code status_spw;
413 int i;
411 int i;
414
412
415 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
413 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
416 {
414 {
417 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
415 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
418
416
419 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
417 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
420
418
421 status_spw = spacewire_stop_start_link( fdSPW );
419 status_spw = spacewire_stop_start_link( fdSPW );
422 if ( status_spw != RTEMS_SUCCESSFUL )
420 if ( status_spw != RTEMS_SUCCESSFUL )
423 {
421 {
424 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
422 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
425 }
423 }
426
424
427 if ( status_spw == RTEMS_SUCCESSFUL)
425 if ( status_spw == RTEMS_SUCCESSFUL)
428 {
426 {
429 break;
427 break;
430 }
428 }
431 }
429 }
432
430
433 return status_spw;
431 return status_spw;
434 }
432 }
435
433
436 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
434 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
437 {
435 {
438 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
436 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
439 *
437 *
440 * @param val is the value, 0 or 1, used to set the value of the NP bit.
438 * @param val is the value, 0 or 1, used to set the value of the NP bit.
441 * @param regAddr is the address of the GRSPW control register.
439 * @param regAddr is the address of the GRSPW control register.
442 *
440 *
443 * NP is the bit 20 of the GRSPW control register.
441 * NP is the bit 20 of the GRSPW control register.
444 *
442 *
445 */
443 */
446
444
447 unsigned int *spwptr = (unsigned int*) regAddr;
445 unsigned int *spwptr = (unsigned int*) regAddr;
448
446
449 if (val == 1) {
447 if (val == 1) {
450 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
448 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
451 }
449 }
452 if (val== 0) {
450 if (val== 0) {
453 *spwptr = *spwptr & 0xffdfffff;
451 *spwptr = *spwptr & 0xffdfffff;
454 }
452 }
455 }
453 }
456
454
457 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
455 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
458 {
456 {
459 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
457 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
460 *
458 *
461 * @param val is the value, 0 or 1, used to set the value of the RE bit.
459 * @param val is the value, 0 or 1, used to set the value of the RE bit.
462 * @param regAddr is the address of the GRSPW control register.
460 * @param regAddr is the address of the GRSPW control register.
463 *
461 *
464 * RE is the bit 16 of the GRSPW control register.
462 * RE is the bit 16 of the GRSPW control register.
465 *
463 *
466 */
464 */
467
465
468 unsigned int *spwptr = (unsigned int*) regAddr;
466 unsigned int *spwptr = (unsigned int*) regAddr;
469
467
470 if (val == 1)
468 if (val == 1)
471 {
469 {
472 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
470 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
473 }
471 }
474 if (val== 0)
472 if (val== 0)
475 {
473 {
476 *spwptr = *spwptr & 0xfffdffff;
474 *spwptr = *spwptr & 0xfffdffff;
477 }
475 }
478 }
476 }
479
477
480 void spacewire_compute_stats_offsets( void )
478 void spacewire_compute_stats_offsets( void )
481 {
479 {
482 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
480 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
483 *
481 *
484 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
482 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
485 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
483 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
486 * during the open systel call).
484 * during the open systel call).
487 *
485 *
488 */
486 */
489
487
490 spw_stats spacewire_stats_grspw;
488 spw_stats spacewire_stats_grspw;
491 rtems_status_code status;
489 rtems_status_code status;
492
490
493 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
491 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
494
492
495 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
493 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
496 + spacewire_stats.packets_received;
494 + spacewire_stats.packets_received;
497 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
495 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
498 + spacewire_stats.packets_sent;
496 + spacewire_stats.packets_sent;
499 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
497 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
500 + spacewire_stats.parity_err;
498 + spacewire_stats.parity_err;
501 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
499 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
502 + spacewire_stats.disconnect_err;
500 + spacewire_stats.disconnect_err;
503 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
501 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
504 + spacewire_stats.escape_err;
502 + spacewire_stats.escape_err;
505 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
503 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
506 + spacewire_stats.credit_err;
504 + spacewire_stats.credit_err;
507 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
505 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
508 + spacewire_stats.write_sync_err;
506 + spacewire_stats.write_sync_err;
509 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
507 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
510 + spacewire_stats.rx_rmap_header_crc_err;
508 + spacewire_stats.rx_rmap_header_crc_err;
511 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
509 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
512 + spacewire_stats.rx_rmap_data_crc_err;
510 + spacewire_stats.rx_rmap_data_crc_err;
513 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
511 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
514 + spacewire_stats.early_ep;
512 + spacewire_stats.early_ep;
515 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
513 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
516 + spacewire_stats.invalid_address;
514 + spacewire_stats.invalid_address;
517 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
515 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
518 + spacewire_stats.rx_eep_err;
516 + spacewire_stats.rx_eep_err;
519 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
517 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
520 + spacewire_stats.rx_truncated;
518 + spacewire_stats.rx_truncated;
521 }
519 }
522
520
523 void spacewire_update_statistics( void )
521 void spacewire_update_statistics( void )
524 {
522 {
525 rtems_status_code status;
523 rtems_status_code status;
526 spw_stats spacewire_stats_grspw;
524 spw_stats spacewire_stats_grspw;
527
525
528 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
526 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
529
527
530 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
528 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
531 + spacewire_stats_grspw.packets_received;
529 + spacewire_stats_grspw.packets_received;
532 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
530 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
533 + spacewire_stats_grspw.packets_sent;
531 + spacewire_stats_grspw.packets_sent;
534 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
532 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
535 + spacewire_stats_grspw.parity_err;
533 + spacewire_stats_grspw.parity_err;
536 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
534 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
537 + spacewire_stats_grspw.disconnect_err;
535 + spacewire_stats_grspw.disconnect_err;
538 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
536 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
539 + spacewire_stats_grspw.escape_err;
537 + spacewire_stats_grspw.escape_err;
540 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
538 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
541 + spacewire_stats_grspw.credit_err;
539 + spacewire_stats_grspw.credit_err;
542 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
540 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
543 + spacewire_stats_grspw.write_sync_err;
541 + spacewire_stats_grspw.write_sync_err;
544 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
542 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
545 + spacewire_stats_grspw.rx_rmap_header_crc_err;
543 + spacewire_stats_grspw.rx_rmap_header_crc_err;
546 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
544 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
547 + spacewire_stats_grspw.rx_rmap_data_crc_err;
545 + spacewire_stats_grspw.rx_rmap_data_crc_err;
548 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
546 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
549 + spacewire_stats_grspw.early_ep;
547 + spacewire_stats_grspw.early_ep;
550 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
548 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
551 + spacewire_stats_grspw.invalid_address;
549 + spacewire_stats_grspw.invalid_address;
552 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
550 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
553 + spacewire_stats_grspw.rx_eep_err;
551 + spacewire_stats_grspw.rx_eep_err;
554 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
552 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
555 + spacewire_stats_grspw.rx_truncated;
553 + spacewire_stats_grspw.rx_truncated;
556 //spacewire_stats.tx_link_err;
554 //spacewire_stats.tx_link_err;
557
555
558 //****************************
556 //****************************
559 // DPU_SPACEWIRE_IF_STATISTICS
557 // DPU_SPACEWIRE_IF_STATISTICS
560 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
558 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
561 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
559 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
562 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
560 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
563 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
561 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
564 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
562 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
565 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
563 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
566
564
567 //******************************************
565 //******************************************
568 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
566 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
569 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
567 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
570 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
568 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
571 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
569 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
572 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
570 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
573 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
571 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
574
572
575 //*********************************************
573 //*********************************************
576 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
574 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
577 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
575 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
578 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
576 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
579 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
577 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
580 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
578 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
581 }
579 }
582
580
583 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
581 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
584 {
582 {
585 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
583 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 );
586 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
584 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
587 //}
585
586 grgpio_regs->io_port_direction_register =
587 grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled
588
589 if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 )
590 {
591 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7;
592 }
593 else
594 {
595 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08;
596 }
597
588 }
598 }
589
599
590 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
600 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
591 {
601 {
592 int linkStatus;
602 int linkStatus;
593 rtems_status_code status;
603 rtems_status_code status;
594
604
595 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
605 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
596
606
597 if ( linkStatus == 5) {
607 if ( linkStatus == 5) {
598 PRINTF("in spacewire_reset_link *** link is running\n")
608 PRINTF("in spacewire_reset_link *** link is running\n")
599 status = RTEMS_SUCCESSFUL;
609 status = RTEMS_SUCCESSFUL;
600 }
610 }
601 }
611 }
@@ -1,791 +1,790
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
14
15 //***********
15 //***********
16 // RTEMS TASK
16 // RTEMS TASK
17
17
18 rtems_task actn_task( rtems_task_argument unused )
18 rtems_task actn_task( rtems_task_argument unused )
19 {
19 {
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 *
21 *
22 * @param unused is the starting argument of the RTEMS task
22 * @param unused is the starting argument of the RTEMS task
23 *
23 *
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * on the incoming TeleCommand.
25 * on the incoming TeleCommand.
26 *
26 *
27 */
27 */
28
28
29 int result;
29 int result;
30 rtems_status_code status; // RTEMS status code
30 rtems_status_code status; // RTEMS status code
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 size_t size; // size of the incoming TC packet
32 size_t size; // size of the incoming TC packet
33 unsigned char subtype; // subtype of the current TC packet
33 unsigned char subtype; // subtype of the current TC packet
34 unsigned char time[6];
34 unsigned char time[6];
35 rtems_id queue_rcv_id;
35 rtems_id queue_rcv_id;
36 rtems_id queue_snd_id;
36 rtems_id queue_snd_id;
37
37
38 status = get_message_queue_id_recv( &queue_rcv_id );
38 status = get_message_queue_id_recv( &queue_rcv_id );
39 if (status != RTEMS_SUCCESSFUL)
39 if (status != RTEMS_SUCCESSFUL)
40 {
40 {
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 }
42 }
43
43
44 status = get_message_queue_id_send( &queue_snd_id );
44 status = get_message_queue_id_send( &queue_snd_id );
45 if (status != RTEMS_SUCCESSFUL)
45 if (status != RTEMS_SUCCESSFUL)
46 {
46 {
47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 }
48 }
49
49
50 result = LFR_SUCCESSFUL;
50 result = LFR_SUCCESSFUL;
51 subtype = 0; // subtype of the current TC packet
51 subtype = 0; // subtype of the current TC packet
52
52
53 BOOT_PRINTF("in ACTN *** \n")
53 BOOT_PRINTF("in ACTN *** \n")
54
54
55 while(1)
55 while(1)
56 {
56 {
57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 getTime( time ); // set time to the current time
59 getTime( time ); // set time to the current time
60 if (status!=RTEMS_SUCCESSFUL)
60 if (status!=RTEMS_SUCCESSFUL)
61 {
61 {
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 }
63 }
64 else
64 else
65 {
65 {
66 subtype = TC.serviceSubType;
66 subtype = TC.serviceSubType;
67 switch(subtype)
67 switch(subtype)
68 {
68 {
69 case TC_SUBTYPE_RESET:
69 case TC_SUBTYPE_RESET:
70 result = action_reset( &TC, queue_snd_id, time );
70 result = action_reset( &TC, queue_snd_id, time );
71 close_action( &TC, result, queue_snd_id );
71 close_action( &TC, result, queue_snd_id );
72 break;
72 break;
73 //
73 //
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 //
78 //
79 case TC_SUBTYPE_LOAD_NORM:
79 case TC_SUBTYPE_LOAD_NORM:
80 result = action_load_normal_par( &TC, queue_snd_id, time );
80 result = action_load_normal_par( &TC, queue_snd_id, time );
81 close_action( &TC, result, queue_snd_id );
81 close_action( &TC, result, queue_snd_id );
82 break;
82 break;
83 //
83 //
84 case TC_SUBTYPE_LOAD_BURST:
84 case TC_SUBTYPE_LOAD_BURST:
85 result = action_load_burst_par( &TC, queue_snd_id, time );
85 result = action_load_burst_par( &TC, queue_snd_id, time );
86 close_action( &TC, result, queue_snd_id );
86 close_action( &TC, result, queue_snd_id );
87 break;
87 break;
88 //
88 //
89 case TC_SUBTYPE_LOAD_SBM1:
89 case TC_SUBTYPE_LOAD_SBM1:
90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 close_action( &TC, result, queue_snd_id );
91 close_action( &TC, result, queue_snd_id );
92 break;
92 break;
93 //
93 //
94 case TC_SUBTYPE_LOAD_SBM2:
94 case TC_SUBTYPE_LOAD_SBM2:
95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 close_action( &TC, result, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
97 break;
97 break;
98 //
98 //
99 case TC_SUBTYPE_DUMP:
99 case TC_SUBTYPE_DUMP:
100 result = action_dump_par( queue_snd_id );
100 result = action_dump_par( queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
102 break;
102 break;
103 //
103 //
104 case TC_SUBTYPE_ENTER:
104 case TC_SUBTYPE_ENTER:
105 result = action_enter_mode( &TC, queue_snd_id, time );
105 result = action_enter_mode( &TC, queue_snd_id, time );
106 close_action( &TC, result, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
107 break;
107 break;
108 //
108 //
109 case TC_SUBTYPE_UPDT_INFO:
109 case TC_SUBTYPE_UPDT_INFO:
110 result = action_update_info( &TC, queue_snd_id );
110 result = action_update_info( &TC, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
112 break;
112 break;
113 //
113 //
114 case TC_SUBTYPE_EN_CAL:
114 case TC_SUBTYPE_EN_CAL:
115 result = action_enable_calibration( &TC, queue_snd_id, time );
115 result = action_enable_calibration( &TC, queue_snd_id, time );
116 close_action( &TC, result, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
117 break;
117 break;
118 //
118 //
119 case TC_SUBTYPE_DIS_CAL:
119 case TC_SUBTYPE_DIS_CAL:
120 result = action_disable_calibration( &TC, queue_snd_id, time );
120 result = action_disable_calibration( &TC, queue_snd_id, time );
121 close_action( &TC, result, queue_snd_id );
121 close_action( &TC, result, queue_snd_id );
122 break;
122 break;
123 //
123 //
124 case TC_SUBTYPE_UPDT_TIME:
124 case TC_SUBTYPE_UPDT_TIME:
125 result = action_update_time( &TC );
125 result = action_update_time( &TC );
126 close_action( &TC, result, queue_snd_id );
126 close_action( &TC, result, queue_snd_id );
127 break;
127 break;
128 //
128 //
129 default:
129 default:
130 break;
130 break;
131 }
131 }
132 }
132 }
133 }
133 }
134 }
134 }
135
135
136 //***********
136 //***********
137 // TC ACTIONS
137 // TC ACTIONS
138
138
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 {
140 {
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 *
142 *
143 * @param TC points to the TeleCommand packet that is being processed
143 * @param TC points to the TeleCommand packet that is being processed
144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 *
145 *
146 */
146 */
147
147
148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 return LFR_DEFAULT;
149 return LFR_DEFAULT;
150 }
150 }
151
151
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
153 {
153 {
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 *
155 *
156 * @param TC points to the TeleCommand packet that is being processed
156 * @param TC points to the TeleCommand packet that is being processed
157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
158 *
158 *
159 */
159 */
160
160
161 rtems_status_code status;
161 rtems_status_code status;
162 unsigned char requestedMode;
162 unsigned char requestedMode;
163
163
164 requestedMode = TC->dataAndCRC[1];
164 requestedMode = TC->dataAndCRC[1];
165
165
166 if ( (requestedMode != LFR_MODE_STANDBY)
166 if ( (requestedMode != LFR_MODE_STANDBY)
167 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
167 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
168 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
168 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
169 {
169 {
170 status = RTEMS_UNSATISFIED;
170 status = RTEMS_UNSATISFIED;
171 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
171 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
172 }
172 }
173 else
173 else
174 {
174 {
175 printf("in action_enter_mode *** enter mode %d\n", requestedMode);
175 printf("in action_enter_mode *** enter mode %d\n", requestedMode);
176
176
177 status = transition_validation(requestedMode);
177 status = transition_validation(requestedMode);
178
178
179 if ( status == LFR_SUCCESSFUL ) {
179 if ( status == LFR_SUCCESSFUL ) {
180 if ( lfrCurrentMode != LFR_MODE_STANDBY)
180 if ( lfrCurrentMode != LFR_MODE_STANDBY)
181 {
181 {
182 status = stop_current_mode();
182 status = stop_current_mode();
183 }
183 }
184 if (status != RTEMS_SUCCESSFUL)
184 if (status != RTEMS_SUCCESSFUL)
185 {
185 {
186 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
186 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
187 }
187 }
188 status = enter_mode( requestedMode );
188 status = enter_mode( requestedMode );
189 }
189 }
190 else
190 else
191 {
191 {
192 PRINTF("ERR *** in action_enter *** transition rejected\n")
192 PRINTF("ERR *** in action_enter *** transition rejected\n")
193 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
193 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
194 }
194 }
195 }
195 }
196
196
197 return status;
197 return status;
198 }
198 }
199
199
200 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
200 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
201 {
201 {
202 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
202 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
203 *
203 *
204 * @param TC points to the TeleCommand packet that is being processed
204 * @param TC points to the TeleCommand packet that is being processed
205 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
205 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
206 *
206 *
207 * @return LFR directive status code:
207 * @return LFR directive status code:
208 * - LFR_DEFAULT
208 * - LFR_DEFAULT
209 * - LFR_SUCCESSFUL
209 * - LFR_SUCCESSFUL
210 *
210 *
211 */
211 */
212
212
213 unsigned int val;
213 unsigned int val;
214 int result;
214 int result;
215 unsigned int status;
215 unsigned int status;
216 unsigned char mode;
216 unsigned char mode;
217
217
218 // check LFR MODE
218 // check LFR mode
219 mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET5 ] & 0x1e) >> 1;
219 mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET5 ] & 0x1e) >> 1;
220 status = check_update_info_hk_lfr_mode( mode );
220 status = check_update_info_hk_lfr_mode( mode );
221 if (status != LFR_DEFAULT) // check TDS mode
221 if (status == LFR_SUCCESSFUL) // check TDS mode
222 {
222 {
223 mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0xf0) >> 4;
223 mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0xf0) >> 4;
224 status = check_update_info_hk_tds_mode( mode );
224 status = check_update_info_hk_tds_mode( mode );
225 }
225 }
226 if (status != LFR_DEFAULT) // check THR mode
226 if (status == LFR_SUCCESSFUL) // check THR mode
227 {
227 {
228 mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0x0f);
228 mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0x0f);
229 status = check_update_info_hk_thr_mode( mode );
229 status = check_update_info_hk_thr_mode( mode );
230 }
230 }
231 if (status != LFR_DEFAULT) // if the parameter check is successful
231 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
232 {
232 {
233 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
233 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
234 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
234 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
235 val++;
235 val++;
236 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
236 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
237 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
237 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
238 }
238 }
239
239
240 result = status;
240 result = status;
241
241
242 return result;
242 return result;
243 }
243 }
244
244
245 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
245 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
246 {
246 {
247 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
247 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
248 *
248 *
249 * @param TC points to the TeleCommand packet that is being processed
249 * @param TC points to the TeleCommand packet that is being processed
250 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
250 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
251 *
251 *
252 */
252 */
253
253
254 int result;
254 int result;
255 unsigned char lfrMode;
255 unsigned char lfrMode;
256
256
257 result = LFR_DEFAULT;
257 result = LFR_DEFAULT;
258 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
258 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
259
259
260 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
260 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
261 result = LFR_DEFAULT;
261 result = LFR_DEFAULT;
262
262
263 return result;
263 return result;
264 }
264 }
265
265
266 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
266 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
267 {
267 {
268 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
268 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
269 *
269 *
270 * @param TC points to the TeleCommand packet that is being processed
270 * @param TC points to the TeleCommand packet that is being processed
271 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
271 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
272 *
272 *
273 */
273 */
274
274
275 int result;
275 int result;
276 unsigned char lfrMode;
276 unsigned char lfrMode;
277
277
278 result = LFR_DEFAULT;
278 result = LFR_DEFAULT;
279 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
279 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
280
280
281 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
281 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
282 result = LFR_DEFAULT;
282 result = LFR_DEFAULT;
283
283
284 return result;
284 return result;
285 }
285 }
286
286
287 int action_update_time(ccsdsTelecommandPacket_t *TC)
287 int action_update_time(ccsdsTelecommandPacket_t *TC)
288 {
288 {
289 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
289 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
290 *
290 *
291 * @param TC points to the TeleCommand packet that is being processed
291 * @param TC points to the TeleCommand packet that is being processed
292 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
292 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
293 *
293 *
294 * @return LFR_SUCCESSFUL
294 * @return LFR_SUCCESSFUL
295 *
295 *
296 */
296 */
297
297
298 unsigned int val;
298 unsigned int val;
299
299
300 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
300 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
301 + (TC->dataAndCRC[1] << 16)
301 + (TC->dataAndCRC[1] << 16)
302 + (TC->dataAndCRC[2] << 8)
302 + (TC->dataAndCRC[2] << 8)
303 + TC->dataAndCRC[3];
303 + TC->dataAndCRC[3];
304 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
304 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
305 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
305 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
306 val++;
306 val++;
307 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
307 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
308 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
308 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
309 time_management_regs->ctrl = time_management_regs->ctrl | 1;
309 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
310
310
311 return LFR_SUCCESSFUL;
311 return LFR_SUCCESSFUL;
312 }
312 }
313
313
314 //*******************
314 //*******************
315 // ENTERING THE MODES
315 // ENTERING THE MODES
316
316
317 int transition_validation(unsigned char requestedMode)
317 int transition_validation(unsigned char requestedMode)
318 {
318 {
319 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
319 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
320 *
320 *
321 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
321 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
322 *
322 *
323 * @return LFR directive status codes:
323 * @return LFR directive status codes:
324 * - LFR_SUCCESSFUL - the transition is authorized
324 * - LFR_SUCCESSFUL - the transition is authorized
325 * - LFR_DEFAULT - the transition is not authorized
325 * - LFR_DEFAULT - the transition is not authorized
326 *
326 *
327 */
327 */
328
328
329 int status;
329 int status;
330
330
331 switch (requestedMode)
331 switch (requestedMode)
332 {
332 {
333 case LFR_MODE_STANDBY:
333 case LFR_MODE_STANDBY:
334 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
334 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
335 status = LFR_DEFAULT;
335 status = LFR_DEFAULT;
336 }
336 }
337 else
337 else
338 {
338 {
339 status = LFR_SUCCESSFUL;
339 status = LFR_SUCCESSFUL;
340 }
340 }
341 break;
341 break;
342 case LFR_MODE_NORMAL:
342 case LFR_MODE_NORMAL:
343 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
343 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
344 status = LFR_DEFAULT;
344 status = LFR_DEFAULT;
345 }
345 }
346 else {
346 else {
347 status = LFR_SUCCESSFUL;
347 status = LFR_SUCCESSFUL;
348 }
348 }
349 break;
349 break;
350 case LFR_MODE_BURST:
350 case LFR_MODE_BURST:
351 if ( lfrCurrentMode == LFR_MODE_BURST ) {
351 if ( lfrCurrentMode == LFR_MODE_BURST ) {
352 status = LFR_DEFAULT;
352 status = LFR_DEFAULT;
353 }
353 }
354 else {
354 else {
355 status = LFR_SUCCESSFUL;
355 status = LFR_SUCCESSFUL;
356 }
356 }
357 break;
357 break;
358 case LFR_MODE_SBM1:
358 case LFR_MODE_SBM1:
359 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
359 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
360 status = LFR_DEFAULT;
360 status = LFR_DEFAULT;
361 }
361 }
362 else {
362 else {
363 status = LFR_SUCCESSFUL;
363 status = LFR_SUCCESSFUL;
364 }
364 }
365 break;
365 break;
366 case LFR_MODE_SBM2:
366 case LFR_MODE_SBM2:
367 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
367 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
368 status = LFR_DEFAULT;
368 status = LFR_DEFAULT;
369 }
369 }
370 else {
370 else {
371 status = LFR_SUCCESSFUL;
371 status = LFR_SUCCESSFUL;
372 }
372 }
373 break;
373 break;
374 default:
374 default:
375 status = LFR_DEFAULT;
375 status = LFR_DEFAULT;
376 break;
376 break;
377 }
377 }
378
378
379 return status;
379 return status;
380 }
380 }
381
381
382 int stop_current_mode(void)
382 int stop_current_mode(void)
383 {
383 {
384 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
384 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
385 *
385 *
386 * @return RTEMS directive status codes:
386 * @return RTEMS directive status codes:
387 * - RTEMS_SUCCESSFUL - task restarted successfully
387 * - RTEMS_SUCCESSFUL - task restarted successfully
388 * - RTEMS_INVALID_ID - task id invalid
388 * - RTEMS_INVALID_ID - task id invalid
389 * - RTEMS_ALREADY_SUSPENDED - task already suspended
389 * - RTEMS_ALREADY_SUSPENDED - task already suspended
390 *
390 *
391 */
391 */
392
392
393 rtems_status_code status;
393 rtems_status_code status;
394
394
395 status = RTEMS_SUCCESSFUL;
395 status = RTEMS_SUCCESSFUL;
396
396
397 // (1) mask interruptions
397 // (1) mask interruptions
398 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
398 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
399 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
399 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
400
400
401 // (2) clear interruptions
401 // (2) clear interruptions
402 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
402 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
403 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
403 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
404
404
405 // (3) reset registers
405 // (3) reset registers
406 // waveform picker
406 // waveform picker
407 reset_wfp_burst_enable(); // reset burst and enable bits
407 reset_wfp_burst_enable(); // reset burst and enable bits
408 reset_wfp_status(); // reset all the status bits
408 reset_wfp_status(); // reset all the status bits
409 // spectral matrices
409 // spectral matrices
410 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
410 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
411 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
411 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
412 reset_extractSWF(); // reset the extractSWF flag to false
412 reset_extractSWF(); // reset the extractSWF flag to false
413
413
414 // <Spectral Matrices simulator>
414 // <Spectral Matrices simulator>
415 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
415 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
416 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
416 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
417 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
417 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
418 // </Spectral Matrices simulator>
418 // </Spectral Matrices simulator>
419
419
420 // suspend several tasks
420 // suspend several tasks
421 if (lfrCurrentMode != LFR_MODE_STANDBY) {
421 if (lfrCurrentMode != LFR_MODE_STANDBY) {
422 status = suspend_science_tasks();
422 status = suspend_science_tasks();
423 }
423 }
424
424
425 if (status != RTEMS_SUCCESSFUL)
425 if (status != RTEMS_SUCCESSFUL)
426 {
426 {
427 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
427 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
428 }
428 }
429
429
430 return status;
430 return status;
431 }
431 }
432
432
433 int enter_mode(unsigned char mode )
433 int enter_mode(unsigned char mode )
434 {
434 {
435 /** This function is launched after a mode transition validation.
435 /** This function is launched after a mode transition validation.
436 *
436 *
437 * @param mode is the mode in which LFR will be put.
437 * @param mode is the mode in which LFR will be put.
438 *
438 *
439 * @return RTEMS directive status codes:
439 * @return RTEMS directive status codes:
440 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
440 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
441 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
441 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
442 *
442 *
443 */
443 */
444
444
445 rtems_status_code status;
445 rtems_status_code status;
446
446
447 status = RTEMS_UNSATISFIED;
447 status = RTEMS_UNSATISFIED;
448
448
449 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
449 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
450 updateLFRCurrentMode();
450 updateLFRCurrentMode();
451
451
452 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
452 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
453 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
453 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
454 {
454 {
455 #ifdef PRINT_TASK_STATISTICS
455 #ifdef PRINT_TASK_STATISTICS
456 rtems_cpu_usage_reset();
456 rtems_cpu_usage_reset();
457 maxCount = 0;
457 maxCount = 0;
458 #endif
458 #endif
459 status = restart_science_tasks();
459 status = restart_science_tasks();
460 launch_waveform_picker( mode );
460 launch_waveform_picker( mode );
461 launch_spectral_matrix( mode );
461 launch_spectral_matrix( mode );
462 }
462 }
463 else if ( mode == LFR_MODE_STANDBY )
463 else if ( mode == LFR_MODE_STANDBY )
464 {
464 {
465 #ifdef PRINT_TASK_STATISTICS
465 #ifdef PRINT_TASK_STATISTICS
466 rtems_cpu_usage_report();
466 rtems_cpu_usage_report();
467 #endif
467 #endif
468
468
469 #ifdef PRINT_STACK_REPORT
469 #ifdef PRINT_STACK_REPORT
470 rtems_stack_checker_report_usage();
470 rtems_stack_checker_report_usage();
471 #endif
471 #endif
472 status = stop_current_mode();
472 status = stop_current_mode();
473 PRINTF1("maxCount = %d\n", maxCount)
473 PRINTF1("maxCount = %d\n", maxCount)
474 }
474 }
475 else
475 else
476 {
476 {
477 status = RTEMS_UNSATISFIED;
477 status = RTEMS_UNSATISFIED;
478 }
478 }
479
479
480 if (status != RTEMS_SUCCESSFUL)
480 if (status != RTEMS_SUCCESSFUL)
481 {
481 {
482 PRINTF1("in enter_mode *** ERR = %d\n", status)
482 PRINTF1("in enter_mode *** ERR = %d\n", status)
483 status = RTEMS_UNSATISFIED;
483 status = RTEMS_UNSATISFIED;
484 }
484 }
485
485
486 return status;
486 return status;
487 }
487 }
488
488
489 int restart_science_tasks()
489 int restart_science_tasks()
490 {
490 {
491 /** This function is used to restart all science tasks.
491 /** This function is used to restart all science tasks.
492 *
492 *
493 * @return RTEMS directive status codes:
493 * @return RTEMS directive status codes:
494 * - RTEMS_SUCCESSFUL - task restarted successfully
494 * - RTEMS_SUCCESSFUL - task restarted successfully
495 * - RTEMS_INVALID_ID - task id invalid
495 * - RTEMS_INVALID_ID - task id invalid
496 * - RTEMS_INCORRECT_STATE - task never started
496 * - RTEMS_INCORRECT_STATE - task never started
497 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
497 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
498 *
498 *
499 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
499 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
500 *
500 *
501 */
501 */
502
502
503 rtems_status_code status[6];
503 rtems_status_code status[6];
504 rtems_status_code ret;
504 rtems_status_code ret;
505
505
506 ret = RTEMS_SUCCESSFUL;
506 ret = RTEMS_SUCCESSFUL;
507
507
508 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
508 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
509 if (status[0] != RTEMS_SUCCESSFUL)
509 if (status[0] != RTEMS_SUCCESSFUL)
510 {
510 {
511 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
511 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
512 }
512 }
513
513
514 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
514 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
515 if (status[2] != RTEMS_SUCCESSFUL)
515 if (status[2] != RTEMS_SUCCESSFUL)
516 {
516 {
517 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
517 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
518 }
518 }
519
519
520 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
520 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
521 if (status[3] != RTEMS_SUCCESSFUL)
521 if (status[3] != RTEMS_SUCCESSFUL)
522 {
522 {
523 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
523 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
524 }
524 }
525
525
526 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
526 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
527 if (status[4] != RTEMS_SUCCESSFUL)
527 if (status[4] != RTEMS_SUCCESSFUL)
528 {
528 {
529 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
529 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
530 }
530 }
531
531
532 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
532 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
533 if (status[5] != RTEMS_SUCCESSFUL)
533 if (status[5] != RTEMS_SUCCESSFUL)
534 {
534 {
535 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
535 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
536 }
536 }
537
537
538 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
538 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
539 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
539 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
540 {
540 {
541 ret = RTEMS_UNSATISFIED;
541 ret = RTEMS_UNSATISFIED;
542 }
542 }
543
543
544 return ret;
544 return ret;
545 }
545 }
546
546
547 int suspend_science_tasks()
547 int suspend_science_tasks()
548 {
548 {
549 /** This function suspends the science tasks.
549 /** This function suspends the science tasks.
550 *
550 *
551 * @return RTEMS directive status codes:
551 * @return RTEMS directive status codes:
552 * - RTEMS_SUCCESSFUL - task restarted successfully
552 * - RTEMS_SUCCESSFUL - task restarted successfully
553 * - RTEMS_INVALID_ID - task id invalid
553 * - RTEMS_INVALID_ID - task id invalid
554 * - RTEMS_ALREADY_SUSPENDED - task already suspended
554 * - RTEMS_ALREADY_SUSPENDED - task already suspended
555 *
555 *
556 */
556 */
557
557
558 rtems_status_code status;
558 rtems_status_code status;
559
559
560 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
560 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
561 if (status != RTEMS_SUCCESSFUL)
561 if (status != RTEMS_SUCCESSFUL)
562 {
562 {
563 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
563 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
564 }
564 }
565
565
566 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
566 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
567 {
567 {
568 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
568 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
569 if (status != RTEMS_SUCCESSFUL)
569 if (status != RTEMS_SUCCESSFUL)
570 {
570 {
571 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
571 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
572 }
572 }
573 }
573 }
574
574
575 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
575 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
576 {
576 {
577 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
577 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
578 if (status != RTEMS_SUCCESSFUL)
578 if (status != RTEMS_SUCCESSFUL)
579 {
579 {
580 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
580 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
581 }
581 }
582 }
582 }
583
583
584 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
584 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
585 {
585 {
586 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
586 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
587 if (status != RTEMS_SUCCESSFUL)
587 if (status != RTEMS_SUCCESSFUL)
588 {
588 {
589 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
589 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
590 }
590 }
591 }
591 }
592
592
593 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
593 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
594 {
594 {
595 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
595 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
596 if (status != RTEMS_SUCCESSFUL)
596 if (status != RTEMS_SUCCESSFUL)
597 {
597 {
598 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
598 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
599 }
599 }
600 }
600 }
601
601
602 return status;
602 return status;
603 }
603 }
604
604
605 void launch_waveform_picker( unsigned char mode )
605 void launch_waveform_picker( unsigned char mode )
606 {
606 {
607 int startDate;
607 int startDate;
608
608
609 reset_current_ring_nodes();
609 reset_current_ring_nodes();
610 reset_waveform_picker_regs();
610 reset_waveform_picker_regs();
611 set_wfp_burst_enable_register( mode );
611 set_wfp_burst_enable_register( mode );
612
612
613 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
613 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
614 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
614 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
615
615
616 startDate = time_management_regs->coarse_time + 2;
616 startDate = time_management_regs->coarse_time + 2;
617 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
617 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
618 waveform_picker_regs->start_date = startDate;
618 waveform_picker_regs->start_date = startDate;
619 }
619 }
620
620
621 void launch_spectral_matrix( unsigned char mode )
621 void launch_spectral_matrix( unsigned char mode )
622 {
622 {
623 reset_nb_sm_f0();
623 reset_nb_sm_f0();
624 reset_current_sm_ring_nodes();
624 reset_current_sm_ring_nodes();
625 reset_spectral_matrix_regs();
625 reset_spectral_matrix_regs();
626
626
627 #ifdef VHDL_DEV
627 #ifdef VHDL_DEV
628 set_irq_on_new_ready_matrix( 1 );
628 set_irq_on_new_ready_matrix( 1 );
629 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
629 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
630 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
630 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
631 set_run_matrix_spectral( 1 );
631 set_run_matrix_spectral( 1 );
632 #else
632 #else
633 // Spectral Matrices simulator
633 // Spectral Matrices simulator
634 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
634 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
635 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
635 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
636 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
636 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
637 #endif
637 #endif
638 }
638 }
639
639
640 void set_irq_on_new_ready_matrix( unsigned char value )
640 void set_irq_on_new_ready_matrix( unsigned char value )
641 {
641 {
642 if (value == 1)
642 if (value == 1)
643 {
643 {
644 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
644 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
645 }
645 }
646 else
646 else
647 {
647 {
648 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
648 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
649 }
649 }
650 }
650 }
651
651
652 void set_run_matrix_spectral( unsigned char value )
652 void set_run_matrix_spectral( unsigned char value )
653 {
653 {
654 if (value == 1)
654 if (value == 1)
655 {
655 {
656 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // 0100 set run_matrix spectral to 1
656 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
657 }
657 }
658 else
658 else
659 {
659 {
660 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // 1011 set run_matrix spectral to 0
660 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
661 }
661 }
662 }
662 }
663
663
664 void launch_spectral_matrix_simu( unsigned char mode )
664 void launch_spectral_matrix_simu( unsigned char mode )
665 {
665 {
666 reset_nb_sm_f0();
666 reset_nb_sm_f0();
667 reset_current_sm_ring_nodes();
667 reset_current_sm_ring_nodes();
668 reset_spectral_matrix_regs();
668 reset_spectral_matrix_regs();
669
669
670 // Spectral Matrices simulator
670 // Spectral Matrices simulator
671 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
671 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
672 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
672 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
673 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
673 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
674 set_local_nb_interrupt_f0_MAX();
674 set_local_nb_interrupt_f0_MAX();
675 }
675 }
676
676
677 //****************
677 //****************
678 // CLOSING ACTIONS
678 // CLOSING ACTIONS
679 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
679 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
680 {
680 {
681 /** This function is used to update the HK packets statistics after a successful TC execution.
681 /** This function is used to update the HK packets statistics after a successful TC execution.
682 *
682 *
683 * @param TC points to the TC being processed
683 * @param TC points to the TC being processed
684 * @param time is the time used to date the TC execution
684 * @param time is the time used to date the TC execution
685 *
685 *
686 */
686 */
687
687
688 unsigned int val;
689
688 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
690 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
689 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
691 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
690 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
692 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
691 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
693 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
692 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
694 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
693 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
695 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
694 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
696 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
695 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
697 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
696 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
698 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
697 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
699 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
698 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
700 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
699 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
701 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
702
703 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
704 val++;
705 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
706 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
700 }
707 }
701
708
702 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC )
709 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
703 {
710 {
704 /** This function is used to update the HK packets statistics after a TC rejection.
711 /** This function is used to update the HK packets statistics after a TC rejection.
705 *
712 *
706 * @param TC points to the TC being processed
713 * @param TC points to the TC being processed
707 * @param time is the time used to date the TC rejection
714 * @param time is the time used to date the TC rejection
708 *
715 *
709 */
716 */
710
717
718 unsigned int val;
719
711 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
720 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
712 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
721 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
713 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
722 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
714 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
723 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
715 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
724 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
716 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
725 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
717 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
726 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
718 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
727 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
719 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
728 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
720 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
729 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
721 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
730 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
722 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
731 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
732
733 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
734 val++;
735 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
736 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
723 }
737 }
724
738
725 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
739 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
726 {
740 {
727 /** This function is the last step of the TC execution workflow.
741 /** This function is the last step of the TC execution workflow.
728 *
742 *
729 * @param TC points to the TC being processed
743 * @param TC points to the TC being processed
730 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
744 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
731 * @param queue_id is the id of the RTEMS message queue used to send TM packets
745 * @param queue_id is the id of the RTEMS message queue used to send TM packets
732 * @param time is the time used to date the TC execution
746 * @param time is the time used to date the TC execution
733 *
747 *
734 */
748 */
735
749
736 unsigned int val = 0;
737
738 if (result == LFR_SUCCESSFUL)
750 if (result == LFR_SUCCESSFUL)
739 {
751 {
740 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
752 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
741 &&
753 &
742 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
754 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
743 )
755 )
744 {
756 {
745 send_tm_lfr_tc_exe_success( TC, queue_id );
757 send_tm_lfr_tc_exe_success( TC, queue_id );
746 }
758 }
747 update_last_TC_exe( TC );
748 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
749 val++;
750 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
751 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
752 }
753 else
754 {
755 update_last_TC_rej( TC );
756 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
757 val++;
758 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
759 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
760 }
759 }
761 }
760 }
762
761
763 //***************************
762 //***************************
764 // Interrupt Service Routines
763 // Interrupt Service Routines
765 rtems_isr commutation_isr1( rtems_vector_number vector )
764 rtems_isr commutation_isr1( rtems_vector_number vector )
766 {
765 {
767 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
766 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
768 printf("In commutation_isr1 *** Error sending event to DUMB\n");
767 printf("In commutation_isr1 *** Error sending event to DUMB\n");
769 }
768 }
770 }
769 }
771
770
772 rtems_isr commutation_isr2( rtems_vector_number vector )
771 rtems_isr commutation_isr2( rtems_vector_number vector )
773 {
772 {
774 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
773 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
775 printf("In commutation_isr2 *** Error sending event to DUMB\n");
774 printf("In commutation_isr2 *** Error sending event to DUMB\n");
776 }
775 }
777 }
776 }
778
777
779 //****************
778 //****************
780 // OTHER FUNCTIONS
779 // OTHER FUNCTIONS
781 void updateLFRCurrentMode()
780 void updateLFRCurrentMode()
782 {
781 {
783 /** This function updates the value of the global variable lfrCurrentMode.
782 /** This function updates the value of the global variable lfrCurrentMode.
784 *
783 *
785 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
784 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
786 *
785 *
787 */
786 */
788 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
787 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
789 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
788 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
790 }
789 }
791
790
@@ -1,539 +1,539
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 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 {
18 {
19 /** This function updates the LFR registers with the incoming common parameters.
19 /** This function updates the LFR registers with the incoming common parameters.
20 *
20 *
21 * @param TC points to the TeleCommand packet that is being processed
21 * @param TC points to the TeleCommand packet that is being processed
22 *
22 *
23 *
23 *
24 */
24 */
25
25
26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
28 set_wfp_data_shaping( );
28 set_wfp_data_shaping( );
29 return LFR_SUCCESSFUL;
29 return LFR_SUCCESSFUL;
30 }
30 }
31
31
32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
33 {
33 {
34 /** This function updates the LFR registers with the incoming normal parameters.
34 /** This function updates the LFR registers with the incoming normal parameters.
35 *
35 *
36 * @param TC points to the TeleCommand packet that is being processed
36 * @param TC points to the TeleCommand packet that is being processed
37 * @param queue_id is the id of the queue which handles TM related to this execution step
37 * @param queue_id is the id of the queue which handles TM related to this execution step
38 *
38 *
39 */
39 */
40
40
41 int result;
41 int result;
42 int flag;
42 int flag;
43 rtems_status_code status;
43 rtems_status_code status;
44
44
45 flag = LFR_SUCCESSFUL;
45 flag = LFR_SUCCESSFUL;
46
46
47 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
47 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
48 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
48 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
49 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
49 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
50 flag = LFR_DEFAULT;
50 flag = LFR_DEFAULT;
51 }
51 }
52
52
53 //***************
53 //***************
54 // sy_lfr_n_swf_l
54 // sy_lfr_n_swf_l
55 if (flag == LFR_SUCCESSFUL)
55 if (flag == LFR_SUCCESSFUL)
56 {
56 {
57 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
57 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
58 if (result != LFR_SUCCESSFUL)
58 if (result != LFR_SUCCESSFUL)
59 {
59 {
60 flag = LFR_DEFAULT;
60 flag = LFR_DEFAULT;
61 }
61 }
62 }
62 }
63
63
64 //***************
64 //***************
65 // sy_lfr_n_swf_p
65 // sy_lfr_n_swf_p
66 if (flag == LFR_SUCCESSFUL)
66 if (flag == LFR_SUCCESSFUL)
67 {
67 {
68 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
68 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
69 if (result != LFR_SUCCESSFUL)
69 if (result != LFR_SUCCESSFUL)
70 {
70 {
71 flag = LFR_DEFAULT;
71 flag = LFR_DEFAULT;
72 }
72 }
73 }
73 }
74
74
75 //***************
75 //***************
76 // sy_lfr_n_asm_p
76 // sy_lfr_n_asm_p
77 if (flag == LFR_SUCCESSFUL)
77 if (flag == LFR_SUCCESSFUL)
78 {
78 {
79 result = set_sy_lfr_n_asm_p( TC, queue_id );
79 result = set_sy_lfr_n_asm_p( TC, queue_id );
80 if (result != LFR_SUCCESSFUL)
80 if (result != LFR_SUCCESSFUL)
81 {
81 {
82 flag = LFR_DEFAULT;
82 flag = LFR_DEFAULT;
83 }
83 }
84 }
84 }
85
85
86 //***************
86 //***************
87 // sy_lfr_n_bp_p0
87 // sy_lfr_n_bp_p0
88 if (flag == LFR_SUCCESSFUL)
88 if (flag == LFR_SUCCESSFUL)
89 {
89 {
90 result = set_sy_lfr_n_bp_p0( TC, queue_id );
90 result = set_sy_lfr_n_bp_p0( TC, queue_id );
91 if (result != LFR_SUCCESSFUL)
91 if (result != LFR_SUCCESSFUL)
92 {
92 {
93 flag = LFR_DEFAULT;
93 flag = LFR_DEFAULT;
94 }
94 }
95 }
95 }
96
96
97 //***************
97 //***************
98 // sy_lfr_n_bp_p1
98 // sy_lfr_n_bp_p1
99 if (flag == LFR_SUCCESSFUL)
99 if (flag == LFR_SUCCESSFUL)
100 {
100 {
101 result = set_sy_lfr_n_bp_p1( TC, queue_id );
101 result = set_sy_lfr_n_bp_p1( TC, queue_id );
102 if (result != LFR_SUCCESSFUL)
102 if (result != LFR_SUCCESSFUL)
103 {
103 {
104 flag = LFR_DEFAULT;
104 flag = LFR_DEFAULT;
105 }
105 }
106 }
106 }
107
107
108 //*********************
108 //*********************
109 // sy_lfr_n_cwf_long_f3
109 // sy_lfr_n_cwf_long_f3
110 if (flag == LFR_SUCCESSFUL)
110 if (flag == LFR_SUCCESSFUL)
111 {
111 {
112 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
112 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
113 if (result != LFR_SUCCESSFUL)
113 if (result != LFR_SUCCESSFUL)
114 {
114 {
115 flag = LFR_DEFAULT;
115 flag = LFR_DEFAULT;
116 }
116 }
117 }
117 }
118
118
119 return flag;
119 return flag;
120 }
120 }
121
121
122 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
122 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
123 {
123 {
124 /** This function updates the LFR registers with the incoming burst parameters.
124 /** This function updates the LFR registers with the incoming burst parameters.
125 *
125 *
126 * @param TC points to the TeleCommand packet that is being processed
126 * @param TC points to the TeleCommand packet that is being processed
127 * @param queue_id is the id of the queue which handles TM related to this execution step
127 * @param queue_id is the id of the queue which handles TM related to this execution step
128 *
128 *
129 */
129 */
130
130
131 int result;
131 int result;
132 unsigned char lfrMode;
132 unsigned char lfrMode;
133 rtems_status_code status;
133 rtems_status_code status;
134
134
135 result = LFR_DEFAULT;
135 result = LFR_DEFAULT;
136 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
136 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
137
137
138 if ( lfrMode == LFR_MODE_BURST ) {
138 if ( lfrMode == LFR_MODE_BURST ) {
139 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
139 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
140 result = LFR_DEFAULT;
140 result = LFR_DEFAULT;
141 }
141 }
142 else {
142 else {
143 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
143 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
144 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
144 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
145
145
146 result = LFR_SUCCESSFUL;
146 result = LFR_SUCCESSFUL;
147 }
147 }
148
148
149 return result;
149 return result;
150 }
150 }
151
151
152 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
152 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
153 {
153 {
154 /** This function updates the LFR registers with the incoming sbm1 parameters.
154 /** This function updates the LFR registers with the incoming sbm1 parameters.
155 *
155 *
156 * @param TC points to the TeleCommand packet that is being processed
156 * @param TC points to the TeleCommand packet that is being processed
157 * @param queue_id is the id of the queue which handles TM related to this execution step
157 * @param queue_id is the id of the queue which handles TM related to this execution step
158 *
158 *
159 */
159 */
160 int result;
160 int result;
161 unsigned char lfrMode;
161 unsigned char lfrMode;
162 rtems_status_code status;
162 rtems_status_code status;
163
163
164 result = LFR_DEFAULT;
164 result = LFR_DEFAULT;
165 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
165 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
166
166
167 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
167 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
168 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
168 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
169 result = LFR_DEFAULT;
169 result = LFR_DEFAULT;
170 }
170 }
171 else {
171 else {
172 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
172 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
173 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
173 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
174
174
175 result = LFR_SUCCESSFUL;
175 result = LFR_SUCCESSFUL;
176 }
176 }
177
177
178 return result;
178 return result;
179 }
179 }
180
180
181 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
181 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
182 {
182 {
183 /** This function updates the LFR registers with the incoming sbm2 parameters.
183 /** This function updates the LFR registers with the incoming sbm2 parameters.
184 *
184 *
185 * @param TC points to the TeleCommand packet that is being processed
185 * @param TC points to the TeleCommand packet that is being processed
186 * @param queue_id is the id of the queue which handles TM related to this execution step
186 * @param queue_id is the id of the queue which handles TM related to this execution step
187 *
187 *
188 */
188 */
189
189
190 int result;
190 int result;
191 unsigned char lfrMode;
191 unsigned char lfrMode;
192 rtems_status_code status;
192 rtems_status_code status;
193
193
194 result = LFR_DEFAULT;
194 result = LFR_DEFAULT;
195 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
195 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
196
196
197 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
197 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
198 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
198 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
199 result = LFR_DEFAULT;
199 result = LFR_DEFAULT;
200 }
200 }
201 else {
201 else {
202 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
202 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
203 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
203 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
204
204
205 result = LFR_SUCCESSFUL;
205 result = LFR_SUCCESSFUL;
206 }
206 }
207
207
208 return result;
208 return result;
209 }
209 }
210
210
211 int action_dump_par( rtems_id queue_id )
211 int action_dump_par( rtems_id queue_id )
212 {
212 {
213 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
213 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
214 *
214 *
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 * @return RTEMS directive status codes:
217 * @return RTEMS directive status codes:
218 * - RTEMS_SUCCESSFUL - message sent successfully
218 * - RTEMS_SUCCESSFUL - message sent successfully
219 * - RTEMS_INVALID_ID - invalid queue id
219 * - RTEMS_INVALID_ID - invalid queue id
220 * - RTEMS_INVALID_SIZE - invalid message size
220 * - RTEMS_INVALID_SIZE - invalid message size
221 * - RTEMS_INVALID_ADDRESS - buffer is NULL
221 * - RTEMS_INVALID_ADDRESS - buffer is NULL
222 * - RTEMS_UNSATISFIED - out of message buffers
222 * - RTEMS_UNSATISFIED - out of message buffers
223 * - RTEMS_TOO_MANY - queue s limit has been reached
223 * - RTEMS_TOO_MANY - queue s limit has been reached
224 *
224 *
225 */
225 */
226
226
227 int status;
227 int status;
228
228
229 // UPDATE TIME
229 // UPDATE TIME
230 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
230 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
231 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
231 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
232 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
232 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
233 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
233 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
234 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
234 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
235 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
235 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
236 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
236 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
237 // SEND DATA
237 // SEND DATA
238 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
238 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
239 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
239 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
240 if (status != RTEMS_SUCCESSFUL) {
240 if (status != RTEMS_SUCCESSFUL) {
241 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
241 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
242 }
242 }
243
243
244 return status;
244 return status;
245 }
245 }
246
246
247 //***********************
247 //***********************
248 // NORMAL MODE PARAMETERS
248 // NORMAL MODE PARAMETERS
249
249
250 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
250 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
251 {
251 {
252 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
252 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
253 *
253 *
254 * @param TC points to the TeleCommand packet that is being processed
254 * @param TC points to the TeleCommand packet that is being processed
255 * @param queue_id is the id of the queue which handles TM related to this execution step
255 * @param queue_id is the id of the queue which handles TM related to this execution step
256 *
256 *
257 */
257 */
258
258
259 unsigned int tmp;
259 unsigned int tmp;
260 int result;
260 int result;
261 unsigned char msb;
261 unsigned char msb;
262 unsigned char lsb;
262 unsigned char lsb;
263 rtems_status_code status;
263 rtems_status_code status;
264
264
265 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ];
265 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ];
266 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ];
266 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ];
267
267
268 tmp = ( unsigned int ) floor(
268 tmp = ( unsigned int ) floor(
269 ( ( msb*256 ) + lsb ) / 16
269 ( ( msb*256 ) + lsb ) / 16
270 ) * 16;
270 ) * 16;
271
271
272 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
272 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
273 { // 2048 is the maximum limit due to the size of the buffers
273 { // 2048 is the maximum limit due to the size of the buffers
274 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb );
274 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb );
275 result = WRONG_APP_DATA;
275 result = WRONG_APP_DATA;
276 }
276 }
277 else if (tmp != 2048)
277 else if (tmp != 2048)
278 {
278 {
279 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
279 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
280 result = FUNCT_NOT_IMPL;
280 result = FUNCT_NOT_IMPL;
281 }
281 }
282 else
282 else
283 {
283 {
284 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
284 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
285 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
285 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
286 result = LFR_SUCCESSFUL;
286 result = LFR_SUCCESSFUL;
287 }
287 }
288
288
289 return result;
289 return result;
290 }
290 }
291
291
292 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
292 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
293 {
293 {
294 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
294 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
295 *
295 *
296 * @param TC points to the TeleCommand packet that is being processed
296 * @param TC points to the TeleCommand packet that is being processed
297 * @param queue_id is the id of the queue which handles TM related to this execution step
297 * @param queue_id is the id of the queue which handles TM related to this execution step
298 *
298 *
299 */
299 */
300
300
301 unsigned int tmp;
301 unsigned int tmp;
302 int result;
302 int result;
303 unsigned char msb;
303 unsigned char msb;
304 unsigned char lsb;
304 unsigned char lsb;
305 rtems_status_code status;
305 rtems_status_code status;
306
306
307 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ];
307 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ];
308 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ];
308 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ];
309
309
310 tmp = msb * 256 + lsb;
310 tmp = msb * 256 + lsb;
311
311
312 if ( tmp < 16 )
312 if ( tmp < 16 )
313 {
313 {
314 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb );
314 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb );
315 result = WRONG_APP_DATA;
315 result = WRONG_APP_DATA;
316 }
316 }
317 else
317 else
318 {
318 {
319 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
319 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
320 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
320 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
321 result = LFR_SUCCESSFUL;
321 result = LFR_SUCCESSFUL;
322 }
322 }
323
323
324 return result;
324 return result;
325 }
325 }
326
326
327 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
327 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
328 {
328 {
329 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
329 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
330 *
330 *
331 * @param TC points to the TeleCommand packet that is being processed
331 * @param TC points to the TeleCommand packet that is being processed
332 * @param queue_id is the id of the queue which handles TM related to this execution step
332 * @param queue_id is the id of the queue which handles TM related to this execution step
333 *
333 *
334 */
334 */
335
335
336 int result;
336 int result;
337 unsigned char msb;
337 unsigned char msb;
338 unsigned char lsb;
338 unsigned char lsb;
339
339
340 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ];
340 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ];
341 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ];
341 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ];
342
342
343 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
343 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
344 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
344 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
345 result = LFR_SUCCESSFUL;
345 result = LFR_SUCCESSFUL;
346
346
347 return result;
347 return result;
348 }
348 }
349
349
350 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
350 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
351 {
351 {
352 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
352 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
353 *
353 *
354 * @param TC points to the TeleCommand packet that is being processed
354 * @param TC points to the TeleCommand packet that is being processed
355 * @param queue_id is the id of the queue which handles TM related to this execution step
355 * @param queue_id is the id of the queue which handles TM related to this execution step
356 *
356 *
357 */
357 */
358
358
359 int status;
359 int status;
360
360
361 status = LFR_SUCCESSFUL;
361 status = LFR_SUCCESSFUL;
362
362
363 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ];
363 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ];
364
364
365 return status;
365 return status;
366 }
366 }
367
367
368 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
368 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
369 {
369 {
370 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
370 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
371 *
371 *
372 * @param TC points to the TeleCommand packet that is being processed
372 * @param TC points to the TeleCommand packet that is being processed
373 * @param queue_id is the id of the queue which handles TM related to this execution step
373 * @param queue_id is the id of the queue which handles TM related to this execution step
374 *
374 *
375 */
375 */
376
376
377 int status;
377 int status;
378
378
379 status = LFR_SUCCESSFUL;
379 status = LFR_SUCCESSFUL;
380
380
381 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ];
381 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ];
382
382
383 return status;
383 return status;
384 }
384 }
385
385
386 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
386 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
387 {
387 {
388 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
388 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
389 *
389 *
390 * @param TC points to the TeleCommand packet that is being processed
390 * @param TC points to the TeleCommand packet that is being processed
391 * @param queue_id is the id of the queue which handles TM related to this execution step
391 * @param queue_id is the id of the queue which handles TM related to this execution step
392 *
392 *
393 */
393 */
394
394
395 int status;
395 int status;
396
396
397 status = LFR_SUCCESSFUL;
397 status = LFR_SUCCESSFUL;
398
398
399 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_CWF_LONG_F3 ];
399 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_CWF_LONG_F3 ];
400
400
401 return status;
401 return status;
402 }
402 }
403
403
404 //**********************
404 //**********************
405 // BURST MODE PARAMETERS
405 // BURST MODE PARAMETERS
406
406
407 //*********************
407 //*********************
408 // SBM1 MODE PARAMETERS
408 // SBM1 MODE PARAMETERS
409
409
410 //*********************
410 //*********************
411 // SBM2 MODE PARAMETERS
411 // SBM2 MODE PARAMETERS
412
412
413 //*******************
413 //*******************
414 // TC_LFR_UPDATE_INFO
414 // TC_LFR_UPDATE_INFO
415 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
415 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
416 {
416 {
417 unsigned int status;
417 unsigned int status;
418
418
419 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
419 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
420 || (mode = LFR_MODE_BURST)
420 || (mode == LFR_MODE_BURST)
421 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
421 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
422 {
422 {
423 status = LFR_SUCCESSFUL;
423 status = LFR_SUCCESSFUL;
424 }
424 }
425 else
425 else
426 {
426 {
427 status = LFR_DEFAULT;
427 status = LFR_DEFAULT;
428 }
428 }
429
429
430 return status;
430 return status;
431 }
431 }
432
432
433 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
433 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
434 {
434 {
435 unsigned int status;
435 unsigned int status;
436
436
437 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
437 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
438 || (mode = TDS_MODE_BURST)
438 || (mode == TDS_MODE_BURST)
439 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
439 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
440 || (mode == TDS_MODE_LFM))
440 || (mode == TDS_MODE_LFM))
441 {
441 {
442 status = LFR_SUCCESSFUL;
442 status = LFR_SUCCESSFUL;
443 }
443 }
444 else
444 else
445 {
445 {
446 status = LFR_DEFAULT;
446 status = LFR_DEFAULT;
447 }
447 }
448
448
449 return status;
449 return status;
450 }
450 }
451
451
452 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
452 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
453 {
453 {
454 unsigned int status;
454 unsigned int status;
455
455
456 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
456 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
457 || (mode = THR_MODE_BURST))
457 || (mode == THR_MODE_BURST))
458 {
458 {
459 status = LFR_SUCCESSFUL;
459 status = LFR_SUCCESSFUL;
460 }
460 }
461 else
461 else
462 {
462 {
463 status = LFR_DEFAULT;
463 status = LFR_DEFAULT;
464 }
464 }
465
465
466 return status;
466 return status;
467 }
467 }
468
468
469 //**********
469 //**********
470 // init dump
470 // init dump
471
471
472 void init_parameter_dump( void )
472 void init_parameter_dump( void )
473 {
473 {
474 /** This function initialize the parameter_dump_packet global variable with default values.
474 /** This function initialize the parameter_dump_packet global variable with default values.
475 *
475 *
476 */
476 */
477
477
478 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
478 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
479 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
479 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
480 parameter_dump_packet.reserved = CCSDS_RESERVED;
480 parameter_dump_packet.reserved = CCSDS_RESERVED;
481 parameter_dump_packet.userApplication = CCSDS_USER_APP;
481 parameter_dump_packet.userApplication = CCSDS_USER_APP;
482 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
482 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
483 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
483 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
484 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
484 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
485 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
485 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
486 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
486 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
487 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
487 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
488 // DATA FIELD HEADER
488 // DATA FIELD HEADER
489 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
489 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
490 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
490 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
491 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
491 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
492 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
492 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
493 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
493 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
494 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
494 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
495 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
495 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
496 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
496 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
497 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
497 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
498 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
498 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
499 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
499 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
500
500
501 //******************
501 //******************
502 // COMMON PARAMETERS
502 // COMMON PARAMETERS
503 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
503 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
504 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
504 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
505
505
506 //******************
506 //******************
507 // NORMAL PARAMETERS
507 // NORMAL PARAMETERS
508 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
508 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
509 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
509 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
510 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
510 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
511 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
511 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
512 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
512 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
513 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
513 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
514 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
514 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
515 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
515 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
516 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
516 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
517
517
518 //*****************
518 //*****************
519 // BURST PARAMETERS
519 // BURST PARAMETERS
520 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
520 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
521 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
521 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
522
522
523 //****************
523 //****************
524 // SBM1 PARAMETERS
524 // SBM1 PARAMETERS
525 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
525 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
526 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
526 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
527
527
528 //****************
528 //****************
529 // SBM2 PARAMETERS
529 // SBM2 PARAMETERS
530 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
530 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
531 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
531 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
532 }
532 }
533
533
534
534
535
535
536
536
537
537
538
538
539
539
@@ -1,493 +1,511
1 /** Functions to send TM packets related to TC parsing and execution.
1 /** Functions to send TM packets related to TC parsing and execution.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to send appropriate TM packets after parsing and execution:
6 * A group of functions to send appropriate TM packets after parsing and execution:
7 * - TM_LFR_TC_EXE_SUCCESS
7 * - TM_LFR_TC_EXE_SUCCESS
8 * - TM_LFR_TC_EXE_INCONSISTENT
8 * - TM_LFR_TC_EXE_INCONSISTENT
9 * - TM_LFR_TC_EXE_NOT_EXECUTABLE
9 * - TM_LFR_TC_EXE_NOT_EXECUTABLE
10 * - TM_LFR_TC_EXE_NOT_IMPLEMENTED
10 * - TM_LFR_TC_EXE_NOT_IMPLEMENTED
11 * - TM_LFR_TC_EXE_ERROR
11 * - TM_LFR_TC_EXE_ERROR
12 * - TM_LFR_TC_EXE_CORRUPTED
12 * - TM_LFR_TC_EXE_CORRUPTED
13 *
13 *
14 */
14 */
15
15
16 #include "tm_lfr_tc_exe.h"
16 #include "tm_lfr_tc_exe.h"
17
17
18 int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
18 int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
19 {
19 {
20 /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue.
20 /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue.
21 *
21 *
22 * @param TC points to the TeleCommand packet that is being processed
22 * @param TC points to the TeleCommand packet that is being processed
23 * @param queue_id is the id of the queue which handles TM
23 * @param queue_id is the id of the queue which handles TM
24 *
24 *
25 * @return RTEMS directive status code:
25 * @return RTEMS directive status code:
26 * - RTEMS_SUCCESSFUL - message sent successfully
26 * - RTEMS_SUCCESSFUL - message sent successfully
27 * - RTEMS_INVALID_ID - invalid queue id
27 * - RTEMS_INVALID_ID - invalid queue id
28 * - RTEMS_INVALID_SIZE - invalid message size
28 * - RTEMS_INVALID_SIZE - invalid message size
29 * - RTEMS_INVALID_ADDRESS - buffer is NULL
29 * - RTEMS_INVALID_ADDRESS - buffer is NULL
30 * - RTEMS_UNSATISFIED - out of message buffers
30 * - RTEMS_UNSATISFIED - out of message buffers
31 * - RTEMS_TOO_MANY - queue s limit has been reached
31 * - RTEMS_TOO_MANY - queue s limit has been reached
32 *
32 *
33 */
33 */
34
34
35 rtems_status_code status;
35 rtems_status_code status;
36 Packet_TM_LFR_TC_EXE_SUCCESS_t TM;
36 Packet_TM_LFR_TC_EXE_SUCCESS_t TM;
37 unsigned char messageSize;
37 unsigned char messageSize;
38
38
39 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
39 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
40 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
40 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
41 TM.reserved = DEFAULT_RESERVED;
41 TM.reserved = DEFAULT_RESERVED;
42 TM.userApplication = CCSDS_USER_APP;
42 TM.userApplication = CCSDS_USER_APP;
43 // PACKET HEADER
43 // PACKET HEADER
44 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
44 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
45 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
45 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
46 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
46 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
47 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
47 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
48 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
48 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
49 // DATA FIELD HEADER
49 // DATA FIELD HEADER
50 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
50 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
51 TM.serviceType = TM_TYPE_TC_EXE;
51 TM.serviceType = TM_TYPE_TC_EXE;
52 TM.serviceSubType = TM_SUBTYPE_EXE_OK;
52 TM.serviceSubType = TM_SUBTYPE_EXE_OK;
53 TM.destinationID = TC->sourceID;
53 TM.destinationID = TC->sourceID;
54 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
54 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
55 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
55 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
56 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
56 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
57 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
57 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
58 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
58 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
59 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
59 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
60 //
60 //
61 TM.telecommand_pkt_id[0] = TC->packetID[0];
61 TM.telecommand_pkt_id[0] = TC->packetID[0];
62 TM.telecommand_pkt_id[1] = TC->packetID[1];
62 TM.telecommand_pkt_id[1] = TC->packetID[1];
63 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
63 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
64 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
64 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
65
65
66 messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
66 messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
67
67
68 // SEND DATA
68 // SEND DATA
69 status = rtems_message_queue_send( queue_id, &TM, messageSize);
69 status = rtems_message_queue_send( queue_id, &TM, messageSize);
70 if (status != RTEMS_SUCCESSFUL) {
70 if (status != RTEMS_SUCCESSFUL) {
71 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
71 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
72 }
72 }
73
73
74 // UPDATE HK FIELDS
75 update_last_TC_exe( TC, TM.time );
76
74 return status;
77 return status;
75 }
78 }
76
79
77 int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
80 int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
78 unsigned char byte_position, unsigned char rcv_value )
81 unsigned char byte_position, unsigned char rcv_value )
79 {
82 {
80 /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue.
83 /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue.
81 *
84 *
82 * @param TC points to the TeleCommand packet that is being processed
85 * @param TC points to the TeleCommand packet that is being processed
83 * @param queue_id is the id of the queue which handles TM
86 * @param queue_id is the id of the queue which handles TM
84 * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent
87 * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent
85 * @param rcv_value is the value of the LSB of the parameter that has been deteced as inconsistent
88 * @param rcv_value is the value of the LSB of the parameter that has been deteced as inconsistent
86 *
89 *
87 * @return RTEMS directive status code:
90 * @return RTEMS directive status code:
88 * - RTEMS_SUCCESSFUL - message sent successfully
91 * - RTEMS_SUCCESSFUL - message sent successfully
89 * - RTEMS_INVALID_ID - invalid queue id
92 * - RTEMS_INVALID_ID - invalid queue id
90 * - RTEMS_INVALID_SIZE - invalid message size
93 * - RTEMS_INVALID_SIZE - invalid message size
91 * - RTEMS_INVALID_ADDRESS - buffer is NULL
94 * - RTEMS_INVALID_ADDRESS - buffer is NULL
92 * - RTEMS_UNSATISFIED - out of message buffers
95 * - RTEMS_UNSATISFIED - out of message buffers
93 * - RTEMS_TOO_MANY - queue s limit has been reached
96 * - RTEMS_TOO_MANY - queue s limit has been reached
94 *
97 *
95 */
98 */
96
99
97 rtems_status_code status;
100 rtems_status_code status;
98 Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
101 Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
99 unsigned char messageSize;
102 unsigned char messageSize;
100
103
101 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
104 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
102 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
105 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
103 TM.reserved = DEFAULT_RESERVED;
106 TM.reserved = DEFAULT_RESERVED;
104 TM.userApplication = CCSDS_USER_APP;
107 TM.userApplication = CCSDS_USER_APP;
105 // PACKET HEADER
108 // PACKET HEADER
106 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
109 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
107 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
110 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
108 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
111 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
109 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
112 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
110 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
113 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
111 // DATA FIELD HEADER
114 // DATA FIELD HEADER
112 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
115 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
113 TM.serviceType = TM_TYPE_TC_EXE;
116 TM.serviceType = TM_TYPE_TC_EXE;
114 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
117 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
115 TM.destinationID = TC->sourceID;
118 TM.destinationID = TC->sourceID;
116 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
119 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
117 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
120 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
118 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
121 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
119 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
122 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
120 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
123 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
121 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
124 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
122 //
125 //
123 TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> 8);
126 TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> 8);
124 TM.tc_failure_code[1] = (char) (WRONG_APP_DATA );
127 TM.tc_failure_code[1] = (char) (WRONG_APP_DATA );
125 TM.telecommand_pkt_id[0] = TC->packetID[0];
128 TM.telecommand_pkt_id[0] = TC->packetID[0];
126 TM.telecommand_pkt_id[1] = TC->packetID[1];
129 TM.telecommand_pkt_id[1] = TC->packetID[1];
127 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
130 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
128 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
131 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
129 TM.tc_service = TC->serviceType; // type of the rejected TC
132 TM.tc_service = TC->serviceType; // type of the rejected TC
130 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
133 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
131 TM.byte_position = byte_position;
134 TM.byte_position = byte_position;
132 TM.rcv_value = rcv_value;
135 TM.rcv_value = rcv_value;
133
136
134 messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
137 messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
135
138
136 // SEND DATA
139 // SEND DATA
137 status = rtems_message_queue_send( queue_id, &TM, messageSize);
140 status = rtems_message_queue_send( queue_id, &TM, messageSize);
138 if (status != RTEMS_SUCCESSFUL) {
141 if (status != RTEMS_SUCCESSFUL) {
139 PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n")
142 PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n")
140 }
143 }
141
144
145 // UPDATE HK FIELDS
146 update_last_TC_rej( TC, TM.time );
147
142 return status;
148 return status;
143 }
149 }
144
150
145 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
151 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
146 {
152 {
147 /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue.
153 /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue.
148 *
154 *
149 * @param TC points to the TeleCommand packet that is being processed
155 * @param TC points to the TeleCommand packet that is being processed
150 * @param queue_id is the id of the queue which handles TM
156 * @param queue_id is the id of the queue which handles TM
151 *
157 *
152 * @return RTEMS directive status code:
158 * @return RTEMS directive status code:
153 * - RTEMS_SUCCESSFUL - message sent successfully
159 * - RTEMS_SUCCESSFUL - message sent successfully
154 * - RTEMS_INVALID_ID - invalid queue id
160 * - RTEMS_INVALID_ID - invalid queue id
155 * - RTEMS_INVALID_SIZE - invalid message size
161 * - RTEMS_INVALID_SIZE - invalid message size
156 * - RTEMS_INVALID_ADDRESS - buffer is NULL
162 * - RTEMS_INVALID_ADDRESS - buffer is NULL
157 * - RTEMS_UNSATISFIED - out of message buffers
163 * - RTEMS_UNSATISFIED - out of message buffers
158 * - RTEMS_TOO_MANY - queue s limit has been reached
164 * - RTEMS_TOO_MANY - queue s limit has been reached
159 *
165 *
160 */
166 */
161
167
162 rtems_status_code status;
168 rtems_status_code status;
163 Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
169 Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
164 unsigned char messageSize;
170 unsigned char messageSize;
165
171
166 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
172 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
167 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
173 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
168 TM.reserved = DEFAULT_RESERVED;
174 TM.reserved = DEFAULT_RESERVED;
169 TM.userApplication = CCSDS_USER_APP;
175 TM.userApplication = CCSDS_USER_APP;
170 // PACKET HEADER
176 // PACKET HEADER
171 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
177 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
172 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
178 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
173 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
179 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
174 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
180 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
175 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
181 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
176 // DATA FIELD HEADER
182 // DATA FIELD HEADER
177 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
183 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
178 TM.serviceType = TM_TYPE_TC_EXE;
184 TM.serviceType = TM_TYPE_TC_EXE;
179 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
185 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
180 TM.destinationID = TC->sourceID; // default destination id
186 TM.destinationID = TC->sourceID; // default destination id
181 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
187 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
182 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
188 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
183 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
189 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
184 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
190 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
185 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
191 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
186 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
192 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
187 //
193 //
188 TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> 8);
194 TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> 8);
189 TM.tc_failure_code[1] = (char) (TC_NOT_EXE );
195 TM.tc_failure_code[1] = (char) (TC_NOT_EXE );
190 TM.telecommand_pkt_id[0] = TC->packetID[0];
196 TM.telecommand_pkt_id[0] = TC->packetID[0];
191 TM.telecommand_pkt_id[1] = TC->packetID[1];
197 TM.telecommand_pkt_id[1] = TC->packetID[1];
192 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
198 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
193 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
199 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
194 TM.tc_service = TC->serviceType; // type of the rejected TC
200 TM.tc_service = TC->serviceType; // type of the rejected TC
195 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
201 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
196 TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
202 TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
197 TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
203 TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
198
204
199 messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
205 messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
200
206
201 // SEND DATA
207 // SEND DATA
202 status = rtems_message_queue_send( queue_id, &TM, messageSize);
208 status = rtems_message_queue_send( queue_id, &TM, messageSize);
203 if (status != RTEMS_SUCCESSFUL) {
209 if (status != RTEMS_SUCCESSFUL) {
204 PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n")
210 PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n")
205 }
211 }
206
212
213 // UPDATE HK FIELDS
214 update_last_TC_rej( TC, TM.time );
215
207 return status;
216 return status;
208 }
217 }
209
218
210 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
219 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
211 {
220 {
212 /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue.
221 /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue.
213 *
222 *
214 * @param TC points to the TeleCommand packet that is being processed
223 * @param TC points to the TeleCommand packet that is being processed
215 * @param queue_id is the id of the queue which handles TM
224 * @param queue_id is the id of the queue which handles TM
216 *
225 *
217 * @return RTEMS directive status code:
226 * @return RTEMS directive status code:
218 * - RTEMS_SUCCESSFUL - message sent successfully
227 * - RTEMS_SUCCESSFUL - message sent successfully
219 * - RTEMS_INVALID_ID - invalid queue id
228 * - RTEMS_INVALID_ID - invalid queue id
220 * - RTEMS_INVALID_SIZE - invalid message size
229 * - RTEMS_INVALID_SIZE - invalid message size
221 * - RTEMS_INVALID_ADDRESS - buffer is NULL
230 * - RTEMS_INVALID_ADDRESS - buffer is NULL
222 * - RTEMS_UNSATISFIED - out of message buffers
231 * - RTEMS_UNSATISFIED - out of message buffers
223 * - RTEMS_TOO_MANY - queue s limit has been reached
232 * - RTEMS_TOO_MANY - queue s limit has been reached
224 *
233 *
225 */
234 */
226
235
227 rtems_status_code status;
236 rtems_status_code status;
228 Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM;
237 Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM;
229 unsigned char messageSize;
238 unsigned char messageSize;
230
239
231 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
240 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
232 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
241 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
233 TM.reserved = DEFAULT_RESERVED;
242 TM.reserved = DEFAULT_RESERVED;
234 TM.userApplication = CCSDS_USER_APP;
243 TM.userApplication = CCSDS_USER_APP;
235 // PACKET HEADER
244 // PACKET HEADER
236 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
245 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
237 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
246 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
238 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
247 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
239 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
248 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
240 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
249 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
241 // DATA FIELD HEADER
250 // DATA FIELD HEADER
242 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
251 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
243 TM.serviceType = TM_TYPE_TC_EXE;
252 TM.serviceType = TM_TYPE_TC_EXE;
244 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
253 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
245 TM.destinationID = TC->sourceID; // default destination id
254 TM.destinationID = TC->sourceID; // default destination id
246 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
255 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
247 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
256 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
248 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
257 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
249 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
258 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
250 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
259 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
251 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
260 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
252 //
261 //
253 TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> 8);
262 TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> 8);
254 TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL );
263 TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL );
255 TM.telecommand_pkt_id[0] = TC->packetID[0];
264 TM.telecommand_pkt_id[0] = TC->packetID[0];
256 TM.telecommand_pkt_id[1] = TC->packetID[1];
265 TM.telecommand_pkt_id[1] = TC->packetID[1];
257 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
266 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
258 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
267 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
259 TM.tc_service = TC->serviceType; // type of the rejected TC
268 TM.tc_service = TC->serviceType; // type of the rejected TC
260 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
269 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
261
270
262 messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
271 messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
263
272
264 // SEND DATA
273 // SEND DATA
265 status = rtems_message_queue_send( queue_id, &TM, messageSize);
274 status = rtems_message_queue_send( queue_id, &TM, messageSize);
266 if (status != RTEMS_SUCCESSFUL) {
275 if (status != RTEMS_SUCCESSFUL) {
267 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
276 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
268 }
277 }
269
278
279 // UPDATE HK FIELDS
280 update_last_TC_rej( TC, TM.time );
281
270 return status;
282 return status;
271 }
283 }
272
284
273 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
285 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
274 {
286 {
275 /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue.
287 /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue.
276 *
288 *
277 * @param TC points to the TeleCommand packet that is being processed
289 * @param TC points to the TeleCommand packet that is being processed
278 * @param queue_id is the id of the queue which handles TM
290 * @param queue_id is the id of the queue which handles TM
279 *
291 *
280 * @return RTEMS directive status code:
292 * @return RTEMS directive status code:
281 * - RTEMS_SUCCESSFUL - message sent successfully
293 * - RTEMS_SUCCESSFUL - message sent successfully
282 * - RTEMS_INVALID_ID - invalid queue id
294 * - RTEMS_INVALID_ID - invalid queue id
283 * - RTEMS_INVALID_SIZE - invalid message size
295 * - RTEMS_INVALID_SIZE - invalid message size
284 * - RTEMS_INVALID_ADDRESS - buffer is NULL
296 * - RTEMS_INVALID_ADDRESS - buffer is NULL
285 * - RTEMS_UNSATISFIED - out of message buffers
297 * - RTEMS_UNSATISFIED - out of message buffers
286 * - RTEMS_TOO_MANY - queue s limit has been reached
298 * - RTEMS_TOO_MANY - queue s limit has been reached
287 *
299 *
288 */
300 */
289
301
290 rtems_status_code status;
302 rtems_status_code status;
291 Packet_TM_LFR_TC_EXE_ERROR_t TM;
303 Packet_TM_LFR_TC_EXE_ERROR_t TM;
292 unsigned char messageSize;
304 unsigned char messageSize;
293
305
294 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
306 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
295 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
307 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
296 TM.reserved = DEFAULT_RESERVED;
308 TM.reserved = DEFAULT_RESERVED;
297 TM.userApplication = CCSDS_USER_APP;
309 TM.userApplication = CCSDS_USER_APP;
298 // PACKET HEADER
310 // PACKET HEADER
299 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
311 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
300 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
312 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
301 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
313 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
302 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
314 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
303 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
315 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
304 // DATA FIELD HEADER
316 // DATA FIELD HEADER
305 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
317 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
306 TM.serviceType = TM_TYPE_TC_EXE;
318 TM.serviceType = TM_TYPE_TC_EXE;
307 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
319 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
308 TM.destinationID = TC->sourceID; // default destination id
320 TM.destinationID = TC->sourceID; // default destination id
309 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
321 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
310 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
322 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
311 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
323 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
312 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
324 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
313 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
325 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
314 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
326 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
315 //
327 //
316 TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> 8);
328 TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> 8);
317 TM.tc_failure_code[1] = (char) (FAIL_DETECTED );
329 TM.tc_failure_code[1] = (char) (FAIL_DETECTED );
318 TM.telecommand_pkt_id[0] = TC->packetID[0];
330 TM.telecommand_pkt_id[0] = TC->packetID[0];
319 TM.telecommand_pkt_id[1] = TC->packetID[1];
331 TM.telecommand_pkt_id[1] = TC->packetID[1];
320 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
332 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
321 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
333 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
322 TM.tc_service = TC->serviceType; // type of the rejected TC
334 TM.tc_service = TC->serviceType; // type of the rejected TC
323 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
335 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
324
336
325 messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
337 messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
326
338
327 // SEND DATA
339 // SEND DATA
328 status = rtems_message_queue_send( queue_id, &TM, messageSize);
340 status = rtems_message_queue_send( queue_id, &TM, messageSize);
329 if (status != RTEMS_SUCCESSFUL) {
341 if (status != RTEMS_SUCCESSFUL) {
330 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
342 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
331 }
343 }
332
344
345 // UPDATE HK FIELDS
346 update_last_TC_rej( TC, TM.time );
347
333 return status;
348 return status;
334 }
349 }
335
350
336 int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
351 int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
337 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV,
352 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV,
338 unsigned char destinationID )
353 unsigned char destinationID )
339 {
354 {
340 /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue.
355 /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue.
341 *
356 *
342 * @param TC points to the TeleCommand packet that is being processed
357 * @param TC points to the TeleCommand packet that is being processed
343 * @param queue_id is the id of the queue which handles TM
358 * @param queue_id is the id of the queue which handles TM
344 * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand
359 * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand
345 * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data
360 * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data
346 *
361 *
347 * @return RTEMS directive status code:
362 * @return RTEMS directive status code:
348 * - RTEMS_SUCCESSFUL - message sent successfully
363 * - RTEMS_SUCCESSFUL - message sent successfully
349 * - RTEMS_INVALID_ID - invalid queue id
364 * - RTEMS_INVALID_ID - invalid queue id
350 * - RTEMS_INVALID_SIZE - invalid message size
365 * - RTEMS_INVALID_SIZE - invalid message size
351 * - RTEMS_INVALID_ADDRESS - buffer is NULL
366 * - RTEMS_INVALID_ADDRESS - buffer is NULL
352 * - RTEMS_UNSATISFIED - out of message buffers
367 * - RTEMS_UNSATISFIED - out of message buffers
353 * - RTEMS_TOO_MANY - queue s limit has been reached
368 * - RTEMS_TOO_MANY - queue s limit has been reached
354 *
369 *
355 */
370 */
356
371
357 rtems_status_code status;
372 rtems_status_code status;
358 Packet_TM_LFR_TC_EXE_CORRUPTED_t TM;
373 Packet_TM_LFR_TC_EXE_CORRUPTED_t TM;
359 unsigned char messageSize;
374 unsigned char messageSize;
360 unsigned int packetLength;
375 unsigned int packetLength;
361 unsigned char *packetDataField;
376 unsigned char *packetDataField;
362
377
363 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter
378 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter
364 packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
379 packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
365
380
366 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
381 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
367 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
382 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
368 TM.reserved = DEFAULT_RESERVED;
383 TM.reserved = DEFAULT_RESERVED;
369 TM.userApplication = CCSDS_USER_APP;
384 TM.userApplication = CCSDS_USER_APP;
370 // PACKET HEADER
385 // PACKET HEADER
371 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
386 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
372 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
387 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
373 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
388 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
374 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
389 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
375 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
390 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
376 // DATA FIELD HEADER
391 // DATA FIELD HEADER
377 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
392 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
378 TM.serviceType = TM_TYPE_TC_EXE;
393 TM.serviceType = TM_TYPE_TC_EXE;
379 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
394 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
380 TM.destinationID = destinationID;
395 TM.destinationID = destinationID;
381 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
396 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
382 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
397 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
383 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
398 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
384 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
399 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
385 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
400 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
386 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
401 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
387 //
402 //
388 TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> 8);
403 TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> 8);
389 TM.tc_failure_code[1] = (unsigned char) (CORRUPTED );
404 TM.tc_failure_code[1] = (unsigned char) (CORRUPTED );
390 TM.telecommand_pkt_id[0] = TC->packetID[0];
405 TM.telecommand_pkt_id[0] = TC->packetID[0];
391 TM.telecommand_pkt_id[1] = TC->packetID[1];
406 TM.telecommand_pkt_id[1] = TC->packetID[1];
392 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
407 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
393 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
408 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
394 TM.tc_service = TC->serviceType; // type of the rejected TC
409 TM.tc_service = TC->serviceType; // type of the rejected TC
395 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
410 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
396 TM.pkt_len_rcv_value[0] = TC->packetLength[0];
411 TM.pkt_len_rcv_value[0] = TC->packetLength[0];
397 TM.pkt_len_rcv_value[1] = TC->packetLength[1];
412 TM.pkt_len_rcv_value[1] = TC->packetLength[1];
398 TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
413 TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
399 TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
414 TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
400 TM.rcv_crc[0] = packetDataField[ packetLength - 1 ];
415 TM.rcv_crc[0] = packetDataField[ packetLength - 1 ];
401 TM.rcv_crc[1] = packetDataField[ packetLength ];
416 TM.rcv_crc[1] = packetDataField[ packetLength ];
402 TM.computed_crc[0] = computed_CRC[0];
417 TM.computed_crc[0] = computed_CRC[0];
403 TM.computed_crc[1] = computed_CRC[1];
418 TM.computed_crc[1] = computed_CRC[1];
404
419
405 messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
420 messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
406
421
407 // SEND DATA
422 // SEND DATA
408 status = rtems_message_queue_send( queue_id, &TM, messageSize);
423 status = rtems_message_queue_send( queue_id, &TM, messageSize);
409 if (status != RTEMS_SUCCESSFUL) {
424 if (status != RTEMS_SUCCESSFUL) {
410 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
425 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
411 }
426 }
412
427
428 // UPDATE HK FIELDS
429 update_last_TC_rej( TC, TM.time );
430
413 return status;
431 return status;
414 }
432 }
415
433
416 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id )
434 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id )
417 {
435 {
418 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
436 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
419 *
437 *
420 * @param packet_sequence_control points to the packet sequence control which will be incremented
438 * @param packet_sequence_control points to the packet sequence control which will be incremented
421 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
439 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
422 *
440 *
423 * If the destination ID is not known, a dedicated counter is incremented.
441 * If the destination ID is not known, a dedicated counter is incremented.
424 *
442 *
425 */
443 */
426
444
427 unsigned short sequence_cnt;
445 unsigned short sequence_cnt;
428 unsigned short segmentation_grouping_flag;
446 unsigned short segmentation_grouping_flag;
429 unsigned short new_packet_sequence_control;
447 unsigned short new_packet_sequence_control;
430 unsigned char i;
448 unsigned char i;
431
449
432 switch (destination_id)
450 switch (destination_id)
433 {
451 {
434 case SID_TC_GROUND:
452 case SID_TC_GROUND:
435 i = GROUND;
453 i = GROUND;
436 break;
454 break;
437 case SID_TC_MISSION_TIMELINE:
455 case SID_TC_MISSION_TIMELINE:
438 i = MISSION_TIMELINE;
456 i = MISSION_TIMELINE;
439 break;
457 break;
440 case SID_TC_TC_SEQUENCES:
458 case SID_TC_TC_SEQUENCES:
441 i = TC_SEQUENCES;
459 i = TC_SEQUENCES;
442 break;
460 break;
443 case SID_TC_RECOVERY_ACTION_CMD:
461 case SID_TC_RECOVERY_ACTION_CMD:
444 i = RECOVERY_ACTION_CMD;
462 i = RECOVERY_ACTION_CMD;
445 break;
463 break;
446 case SID_TC_BACKUP_MISSION_TIMELINE:
464 case SID_TC_BACKUP_MISSION_TIMELINE:
447 i = BACKUP_MISSION_TIMELINE;
465 i = BACKUP_MISSION_TIMELINE;
448 break;
466 break;
449 case SID_TC_DIRECT_CMD:
467 case SID_TC_DIRECT_CMD:
450 i = DIRECT_CMD;
468 i = DIRECT_CMD;
451 break;
469 break;
452 case SID_TC_SPARE_GRD_SRC1:
470 case SID_TC_SPARE_GRD_SRC1:
453 i = SPARE_GRD_SRC1;
471 i = SPARE_GRD_SRC1;
454 break;
472 break;
455 case SID_TC_SPARE_GRD_SRC2:
473 case SID_TC_SPARE_GRD_SRC2:
456 i = SPARE_GRD_SRC2;
474 i = SPARE_GRD_SRC2;
457 break;
475 break;
458 case SID_TC_OBCP:
476 case SID_TC_OBCP:
459 i = OBCP;
477 i = OBCP;
460 break;
478 break;
461 case SID_TC_SYSTEM_CONTROL:
479 case SID_TC_SYSTEM_CONTROL:
462 i = SYSTEM_CONTROL;
480 i = SYSTEM_CONTROL;
463 break;
481 break;
464 case SID_TC_AOCS:
482 case SID_TC_AOCS:
465 i = AOCS;
483 i = AOCS;
466 break;
484 break;
467 case SID_TC_RPW_INTERNAL:
485 case SID_TC_RPW_INTERNAL:
468 i = RPW_INTERNAL;
486 i = RPW_INTERNAL;
469 break;
487 break;
470 default:
488 default:
471 i = GROUND;
489 i = GROUND;
472 break;
490 break;
473 }
491 }
474
492
475 // increment the sequence counter
493 // increment the sequence counter
476 if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX )
494 if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX )
477 {
495 {
478 sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1;
496 sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1;
479 }
497 }
480 else
498 else
481 {
499 {
482 sequenceCounters_TC_EXE[ i ] = 0;
500 sequenceCounters_TC_EXE[ i ] = 0;
483 }
501 }
484
502
485 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
503 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
486 sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff;
504 sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff;
487
505
488 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
506 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
489
507
490 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
508 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
491 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
509 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
492
510
493 }
511 }
@@ -1,1363 +1,1358
1 /** Functions and tasks related to waveform packet generation.
1 /** Functions and tasks related to waveform packet generation.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 *
7 *
8 */
8 */
9
9
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11
11
12 //*****************
12 //*****************
13 // waveform headers
13 // waveform headers
14 // SWF
14 // SWF
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 // CWF
18 // CWF
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24
24
25 //**************
25 //**************
26 // waveform ring
26 // waveform ring
27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
30 ring_node *current_ring_node_f0;
30 ring_node *current_ring_node_f0;
31 ring_node *ring_node_to_send_swf_f0;
31 ring_node *ring_node_to_send_swf_f0;
32 ring_node *current_ring_node_f1;
32 ring_node *current_ring_node_f1;
33 ring_node *ring_node_to_send_swf_f1;
33 ring_node *ring_node_to_send_swf_f1;
34 ring_node *ring_node_to_send_cwf_f1;
34 ring_node *ring_node_to_send_cwf_f1;
35 ring_node *current_ring_node_f2;
35 ring_node *current_ring_node_f2;
36 ring_node *ring_node_to_send_swf_f2;
36 ring_node *ring_node_to_send_swf_f2;
37 ring_node *ring_node_to_send_cwf_f2;
37 ring_node *ring_node_to_send_cwf_f2;
38
38
39 bool extractSWF = false;
39 bool extractSWF = false;
40 bool swf_f0_ready = false;
40 bool swf_f0_ready = false;
41 bool swf_f1_ready = false;
41 bool swf_f1_ready = false;
42 bool swf_f2_ready = false;
42 bool swf_f2_ready = false;
43
43
44 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
44 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
45
45
46 //*********************
46 //*********************
47 // Interrupt SubRoutine
47 // Interrupt SubRoutine
48
48
49 void reset_extractSWF( void )
49 void reset_extractSWF( void )
50 {
50 {
51 extractSWF = false;
51 extractSWF = false;
52 swf_f0_ready = false;
52 swf_f0_ready = false;
53 swf_f1_ready = false;
53 swf_f1_ready = false;
54 swf_f2_ready = false;
54 swf_f2_ready = false;
55 }
55 }
56
56
57 rtems_isr waveforms_isr( rtems_vector_number vector )
57 rtems_isr waveforms_isr( rtems_vector_number vector )
58 {
58 {
59 /** This is the interrupt sub routine called by the waveform picker core.
59 /** This is the interrupt sub routine called by the waveform picker core.
60 *
60 *
61 * This ISR launch different actions depending mainly on two pieces of information:
61 * This ISR launch different actions depending mainly on two pieces of information:
62 * 1. the values read in the registers of the waveform picker.
62 * 1. the values read in the registers of the waveform picker.
63 * 2. the current LFR mode.
63 * 2. the current LFR mode.
64 *
64 *
65 */
65 */
66
66
67 rtems_status_code status;
67 rtems_status_code status;
68 static unsigned char nb_swf = 0;
68 static unsigned char nb_swf = 0;
69
69
70 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
70 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
71 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
71 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
72 { // in modes other than STANDBY and BURST, send the CWF_F3 data
72 { // in modes other than STANDBY and BURST, send the CWF_F3 data
73 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
73 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
74 // (1) change the receiving buffer for the waveform picker
74 // (1) change the receiving buffer for the waveform picker
75 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
75 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
76 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
76 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
77 }
77 }
78 else {
78 else {
79 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
79 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
80 }
80 }
81 // (2) send an event for the waveforms transmission
81 // (2) send an event for the waveforms transmission
82 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
82 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
84 }
84 }
85 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
85 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
86 }
86 }
87 }
87 }
88
88
89 switch(lfrCurrentMode)
89 switch(lfrCurrentMode)
90 {
90 {
91 //********
91 //********
92 // STANDBY
92 // STANDBY
93 case(LFR_MODE_STANDBY):
93 case(LFR_MODE_STANDBY):
94 break;
94 break;
95
95
96 //******
96 //******
97 // NORMAL
97 // NORMAL
98 case(LFR_MODE_NORMAL):
98 case(LFR_MODE_NORMAL):
99 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
99 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
100 {
100 {
101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
102 }
102 }
103 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
103 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
104 {
104 {
105 // change F0 ring node
105 // change F0 ring node
106 ring_node_to_send_swf_f0 = current_ring_node_f0;
106 ring_node_to_send_swf_f0 = current_ring_node_f0;
107 current_ring_node_f0 = current_ring_node_f0->next;
107 current_ring_node_f0 = current_ring_node_f0->next;
108 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
108 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
109 // change F1 ring node
109 // change F1 ring node
110 ring_node_to_send_swf_f1 = current_ring_node_f1;
110 ring_node_to_send_swf_f1 = current_ring_node_f1;
111 current_ring_node_f1 = current_ring_node_f1->next;
111 current_ring_node_f1 = current_ring_node_f1->next;
112 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
112 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
113 // change F2 ring node
113 // change F2 ring node
114 ring_node_to_send_swf_f2 = current_ring_node_f2;
114 ring_node_to_send_swf_f2 = current_ring_node_f2;
115 current_ring_node_f2 = current_ring_node_f2->next;
115 current_ring_node_f2 = current_ring_node_f2->next;
116 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
116 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
117 //
117 //
118 // if (nb_swf < 2)
118 // if (nb_swf < 2)
119 if (true)
119 if (true)
120 {
120 {
121 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
121 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
122 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
122 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
123 }
123 }
124 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
124 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
125 nb_swf = nb_swf + 1;
125 nb_swf = nb_swf + 1;
126 }
126 }
127 else
127 else
128 {
128 {
129 reset_wfp_burst_enable();
129 reset_wfp_burst_enable();
130 nb_swf = 0;
130 nb_swf = 0;
131 }
131 }
132
132
133 }
133 }
134
134
135 break;
135 break;
136
136
137 //******
137 //******
138 // BURST
138 // BURST
139 case(LFR_MODE_BURST):
139 case(LFR_MODE_BURST):
140 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
140 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
141 // (1) change the receiving buffer for the waveform picker
141 // (1) change the receiving buffer for the waveform picker
142 ring_node_to_send_cwf_f2 = current_ring_node_f2;
142 ring_node_to_send_cwf_f2 = current_ring_node_f2;
143 current_ring_node_f2 = current_ring_node_f2->next;
143 current_ring_node_f2 = current_ring_node_f2->next;
144 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
144 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
145 // (2) send an event for the waveforms transmission
145 // (2) send an event for the waveforms transmission
146 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
146 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
147 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
147 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
148 }
148 }
149 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
149 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
150 }
150 }
151 break;
151 break;
152
152
153 //*****
153 //*****
154 // SBM1
154 // SBM1
155 case(LFR_MODE_SBM1):
155 case(LFR_MODE_SBM1):
156 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
156 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
157 // (0) launch snapshot extraction if needed
157 // (0) launch snapshot extraction if needed
158 if (extractSWF == true)
158 if (extractSWF == true)
159 {
159 {
160 ring_node_to_send_swf_f1 = current_ring_node_f1;
160 ring_node_to_send_swf_f1 = current_ring_node_f1;
161 // extract the snapshot
161 // extract the snapshot
162 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
162 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
163 extractSWF = false;
163 extractSWF = false;
164 swf_f1_ready = true;
164 swf_f1_ready = true;
165 }
165 }
166 // (1) change the receiving buffer for the waveform picker
166 // (1) change the receiving buffer for the waveform picker
167 ring_node_to_send_cwf_f1 = current_ring_node_f1;
167 ring_node_to_send_cwf_f1 = current_ring_node_f1;
168 current_ring_node_f1 = current_ring_node_f1->next;
168 current_ring_node_f1 = current_ring_node_f1->next;
169 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
169 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
170 // (2) send an event for the the CWF1 task for transmission
170 // (2) send an event for the the CWF1 task for transmission
171 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
171 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
172 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
172 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
173 if (swf_f0_ready == true)
173 if (swf_f0_ready == true)
174 {
174 {
175 extractSWF = true;
175 extractSWF = true;
176 swf_f0_ready = false;
176 swf_f0_ready = false;
177 }
177 }
178 if ((swf_f1_ready == true) && (swf_f2_ready == true))
178 if ((swf_f1_ready == true) && (swf_f2_ready == true))
179 {
179 {
180 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
180 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
181 swf_f1_ready = false;
181 swf_f1_ready = false;
182 swf_f2_ready = false;
182 swf_f2_ready = false;
183 }
183 }
184 }
184 }
185 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
185 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
186 swf_f0_ready = true;
186 swf_f0_ready = true;
187 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
187 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
188 }
188 }
189 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
189 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
190 swf_f2_ready = true;
190 swf_f2_ready = true;
191 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
191 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
192 }
192 }
193 break;
193 break;
194
194
195 //*****
195 //*****
196 // SBM2
196 // SBM2
197 case(LFR_MODE_SBM2):
197 case(LFR_MODE_SBM2):
198 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
198 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
199 // (0) launch snapshot extraction if needed
199 // (0) launch snapshot extraction if needed
200 if (extractSWF == true)
200 if (extractSWF == true)
201 {
201 {
202 ring_node_to_send_swf_f2 = current_ring_node_f2;
202 ring_node_to_send_swf_f2 = current_ring_node_f2;
203 // extract the snapshot
203 // extract the snapshot
204 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM2 );
204 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM2 );
205 // send the snapshot when build, SWBD priority < WFRM priority
205 // send the snapshot when build, SWBD priority < WFRM priority
206 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
206 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
207 extractSWF = false;
207 extractSWF = false;
208 }
208 }
209 // (1) change the receiving buffer for the waveform picker
209 // (1) change the receiving buffer for the waveform picker
210 ring_node_to_send_cwf_f2 = current_ring_node_f2;
210 ring_node_to_send_cwf_f2 = current_ring_node_f2;
211 current_ring_node_f2 = current_ring_node_f2->next;
211 current_ring_node_f2 = current_ring_node_f2->next;
212 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
212 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
213 // (2) send an event for the waveforms transmission
213 // (2) send an event for the waveforms transmission
214 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
214 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
215 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
215 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
216 // (3) check whether swf_fo and swf_f& are ready or not
216 // (3) check whether swf_fo and swf_f& are ready or not
217 if (swf_f0_ready && swf_f1_ready)
217 if (swf_f0_ready && swf_f1_ready)
218 {
218 {
219 extractSWF = true;
219 extractSWF = true;
220 swf_f0_ready = false;
220 swf_f0_ready = false;
221 swf_f1_ready = false;
221 swf_f1_ready = false;
222 }
222 }
223 }
223 }
224 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
224 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
225 swf_f0_ready = true;
225 swf_f0_ready = true;
226 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
226 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
227 }
227 }
228 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
228 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
229 swf_f1_ready = true;
229 swf_f1_ready = true;
230 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
230 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
231 }
231 }
232 break;
232 break;
233
233
234 //********
234 //********
235 // DEFAULT
235 // DEFAULT
236 default:
236 default:
237 break;
237 break;
238 }
238 }
239 }
239 }
240
240
241 //************
241 //************
242 // RTEMS TASKS
242 // RTEMS TASKS
243
243
244 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
244 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
245 {
245 {
246 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
246 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
247 *
247 *
248 * @param unused is the starting argument of the RTEMS task
248 * @param unused is the starting argument of the RTEMS task
249 *
249 *
250 * The following data packets are sent by this task:
250 * The following data packets are sent by this task:
251 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
251 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
252 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
252 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
253 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
253 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
254 *
254 *
255 */
255 */
256
256
257 rtems_event_set event_out;
257 rtems_event_set event_out;
258 rtems_id queue_id;
258 rtems_id queue_id;
259 rtems_status_code status;
259 rtems_status_code status;
260
260
261 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
261 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
262 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
262 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
263 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
263 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
264
264
265 init_waveforms();
265 init_waveforms();
266
266
267 status = get_message_queue_id_send( &queue_id );
267 status = get_message_queue_id_send( &queue_id );
268 if (status != RTEMS_SUCCESSFUL)
268 if (status != RTEMS_SUCCESSFUL)
269 {
269 {
270 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
270 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
271 }
271 }
272
272
273 BOOT_PRINTF("in WFRM ***\n")
273 BOOT_PRINTF("in WFRM ***\n")
274
274
275 while(1){
275 while(1){
276 // wait for an RTEMS_EVENT
276 // wait for an RTEMS_EVENT
277 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
277 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
278 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
278 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
279 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
279 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
280 if (event_out == RTEMS_EVENT_MODE_NORMAL)
280 if (event_out == RTEMS_EVENT_MODE_NORMAL)
281 {
281 {
282 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
282 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
283 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
283 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
284 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
284 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
285 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
285 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
286 }
286 }
287 if (event_out == RTEMS_EVENT_MODE_SBM1)
287 if (event_out == RTEMS_EVENT_MODE_SBM1)
288 {
288 {
289 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
289 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
290 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
290 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
291 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
291 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
292 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
292 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
293 }
293 }
294 if (event_out == RTEMS_EVENT_MODE_SBM2)
294 if (event_out == RTEMS_EVENT_MODE_SBM2)
295 {
295 {
296 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
296 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
297 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
297 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
298 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
298 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
299 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
299 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
300 }
300 }
301 }
301 }
302 }
302 }
303
303
304 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
304 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
305 {
305 {
306 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
306 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
307 *
307 *
308 * @param unused is the starting argument of the RTEMS task
308 * @param unused is the starting argument of the RTEMS task
309 *
309 *
310 * The following data packet is sent by this task:
310 * The following data packet is sent by this task:
311 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
311 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
312 *
312 *
313 */
313 */
314
314
315 rtems_event_set event_out;
315 rtems_event_set event_out;
316 rtems_id queue_id;
316 rtems_id queue_id;
317 rtems_status_code status;
317 rtems_status_code status;
318
318
319 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
319 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
320 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
320 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
321
321
322 status = get_message_queue_id_send( &queue_id );
322 status = get_message_queue_id_send( &queue_id );
323 if (status != RTEMS_SUCCESSFUL)
323 if (status != RTEMS_SUCCESSFUL)
324 {
324 {
325 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
325 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
326 }
326 }
327
327
328 BOOT_PRINTF("in CWF3 ***\n")
328 BOOT_PRINTF("in CWF3 ***\n")
329
329
330 while(1){
330 while(1){
331 // wait for an RTEMS_EVENT
331 // wait for an RTEMS_EVENT
332 rtems_event_receive( RTEMS_EVENT_0,
332 rtems_event_receive( RTEMS_EVENT_0,
333 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
333 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
334 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
334 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
335 {
335 {
336 PRINTF("send CWF_LONG_F3\n")
336 PRINTF("send CWF_LONG_F3\n")
337 }
337 }
338 else
338 else
339 {
339 {
340 PRINTF("send CWF_F3 (light)\n")
340 PRINTF("send CWF_F3 (light)\n")
341 }
341 }
342 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
342 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
343 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
343 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
344 {
344 {
345 send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
345 send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
346 }
346 }
347 else
347 else
348 {
348 {
349 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
349 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
350 }
350 }
351 }
351 }
352 else
352 else
353 {
353 {
354 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
354 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
355 {
355 {
356 send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
356 send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
357 }
357 }
358 else
358 else
359 {
359 {
360 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
360 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
361 }
361 }
362
362
363 }
363 }
364 }
364 }
365 }
365 }
366
366
367 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
367 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
368 {
368 {
369 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
369 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
370 *
370 *
371 * @param unused is the starting argument of the RTEMS task
371 * @param unused is the starting argument of the RTEMS task
372 *
372 *
373 * The following data packet is sent by this function:
373 * The following data packet is sent by this function:
374 * - TM_LFR_SCIENCE_BURST_CWF_F2
374 * - TM_LFR_SCIENCE_BURST_CWF_F2
375 * - TM_LFR_SCIENCE_SBM2_CWF_F2
375 * - TM_LFR_SCIENCE_SBM2_CWF_F2
376 *
376 *
377 */
377 */
378
378
379 rtems_event_set event_out;
379 rtems_event_set event_out;
380 rtems_id queue_id;
380 rtems_id queue_id;
381 rtems_status_code status;
381 rtems_status_code status;
382
382
383 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
383 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
384 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
384 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
385
385
386 status = get_message_queue_id_send( &queue_id );
386 status = get_message_queue_id_send( &queue_id );
387 if (status != RTEMS_SUCCESSFUL)
387 if (status != RTEMS_SUCCESSFUL)
388 {
388 {
389 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
389 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
390 }
390 }
391
391
392 BOOT_PRINTF("in CWF2 ***\n")
392 BOOT_PRINTF("in CWF2 ***\n")
393
393
394 while(1){
394 while(1){
395 // wait for an RTEMS_EVENT
395 // wait for an RTEMS_EVENT
396 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
396 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
397 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
397 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
398 if (event_out == RTEMS_EVENT_MODE_BURST)
398 if (event_out == RTEMS_EVENT_MODE_BURST)
399 {
399 {
400 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
400 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
401 }
401 }
402 if (event_out == RTEMS_EVENT_MODE_SBM2)
402 if (event_out == RTEMS_EVENT_MODE_SBM2)
403 {
403 {
404 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
404 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
405 }
405 }
406 }
406 }
407 }
407 }
408
408
409 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
409 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
410 {
410 {
411 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
411 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
412 *
412 *
413 * @param unused is the starting argument of the RTEMS task
413 * @param unused is the starting argument of the RTEMS task
414 *
414 *
415 * The following data packet is sent by this function:
415 * The following data packet is sent by this function:
416 * - TM_LFR_SCIENCE_SBM1_CWF_F1
416 * - TM_LFR_SCIENCE_SBM1_CWF_F1
417 *
417 *
418 */
418 */
419
419
420 rtems_event_set event_out;
420 rtems_event_set event_out;
421 rtems_id queue_id;
421 rtems_id queue_id;
422 rtems_status_code status;
422 rtems_status_code status;
423
423
424 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
424 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
425
425
426 status = get_message_queue_id_send( &queue_id );
426 status = get_message_queue_id_send( &queue_id );
427 if (status != RTEMS_SUCCESSFUL)
427 if (status != RTEMS_SUCCESSFUL)
428 {
428 {
429 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
429 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
430 }
430 }
431
431
432 BOOT_PRINTF("in CWF1 ***\n")
432 BOOT_PRINTF("in CWF1 ***\n")
433
433
434 while(1){
434 while(1){
435 // wait for an RTEMS_EVENT
435 // wait for an RTEMS_EVENT
436 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
436 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
437 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
437 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
438 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
438 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
439 }
439 }
440 }
440 }
441
441
442 rtems_task swbd_task(rtems_task_argument argument)
442 rtems_task swbd_task(rtems_task_argument argument)
443 {
443 {
444 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
444 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
445 *
445 *
446 * @param unused is the starting argument of the RTEMS task
446 * @param unused is the starting argument of the RTEMS task
447 *
447 *
448 */
448 */
449
449
450 rtems_event_set event_out;
450 rtems_event_set event_out;
451
451
452 BOOT_PRINTF("in SWBD ***\n")
452 BOOT_PRINTF("in SWBD ***\n")
453
453
454 while(1){
454 while(1){
455 // wait for an RTEMS_EVENT
455 // wait for an RTEMS_EVENT
456 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
456 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
457 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
457 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
458 if (event_out == RTEMS_EVENT_MODE_SBM1)
458 if (event_out == RTEMS_EVENT_MODE_SBM1)
459 {
459 {
460 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
460 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
461 }
461 }
462 else if (event_out == RTEMS_EVENT_MODE_SBM2)
462 else if (event_out == RTEMS_EVENT_MODE_SBM2)
463 {
463 {
464 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
464 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
465 }
465 }
466 else
466 else
467 {
467 {
468 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
468 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
469 }
469 }
470 }
470 }
471 }
471 }
472
472
473 //******************
473 //******************
474 // general functions
474 // general functions
475 void init_waveforms( void )
475 void init_waveforms( void )
476 {
476 {
477 int i = 0;
477 int i = 0;
478
478
479 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
479 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
480 {
480 {
481 //***
481 //***
482 // F0
482 // F0
483 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
483 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
484 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
484 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
485 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
485 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
486
486
487 //***
487 //***
488 // F1
488 // F1
489 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
489 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
490 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
490 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
491 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
491 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
492
492
493 //***
493 //***
494 // F2
494 // F2
495 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
495 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
496 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
496 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
497 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
497 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
498
498
499 //***
499 //***
500 // F3
500 // F3
501 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
501 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
502 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
502 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
503 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
503 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
504 }
504 }
505 }
505 }
506
506
507 void init_waveform_rings( void )
507 void init_waveform_rings( void )
508 {
508 {
509 unsigned char i;
509 unsigned char i;
510
510
511 // F0 RING
511 // F0 RING
512 waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1];
512 waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1];
513 waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1];
513 waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1];
514 waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0];
514 waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0];
515
515
516 waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0];
516 waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0];
517 waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2];
517 waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2];
518 waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0];
518 waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0];
519
519
520 for(i=1; i<NB_RING_NODES_F0-1; i++)
520 for(i=1; i<NB_RING_NODES_F0-1; i++)
521 {
521 {
522 waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1];
522 waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1];
523 waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1];
523 waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1];
524 waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0];
524 waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0];
525 }
525 }
526
526
527 // F1 RING
527 // F1 RING
528 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
528 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
529 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
529 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
530 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
530 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
531
531
532 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
532 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
533 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
533 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
534 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
534 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
535
535
536 for(i=1; i<NB_RING_NODES_F1-1; i++)
536 for(i=1; i<NB_RING_NODES_F1-1; i++)
537 {
537 {
538 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
538 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
539 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
539 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
540 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
540 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
541 }
541 }
542
542
543 // F2 RING
543 // F2 RING
544 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
544 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
545 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
545 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
546 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
546 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
547
547
548 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
548 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
549 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
549 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
550 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
550 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
551
551
552 for(i=1; i<NB_RING_NODES_F2-1; i++)
552 for(i=1; i<NB_RING_NODES_F2-1; i++)
553 {
553 {
554 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
554 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
555 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
555 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
556 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
556 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
557 }
557 }
558
558
559 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
559 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
560 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
560 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
561 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
561 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
562
562
563 }
563 }
564
564
565 void reset_current_ring_nodes( void )
565 void reset_current_ring_nodes( void )
566 {
566 {
567 current_ring_node_f0 = waveform_ring_f0;
567 current_ring_node_f0 = waveform_ring_f0;
568 ring_node_to_send_swf_f0 = waveform_ring_f0;
568 ring_node_to_send_swf_f0 = waveform_ring_f0;
569
569
570 current_ring_node_f1 = waveform_ring_f1;
570 current_ring_node_f1 = waveform_ring_f1;
571 ring_node_to_send_cwf_f1 = waveform_ring_f1;
571 ring_node_to_send_cwf_f1 = waveform_ring_f1;
572 ring_node_to_send_swf_f1 = waveform_ring_f1;
572 ring_node_to_send_swf_f1 = waveform_ring_f1;
573
573
574 current_ring_node_f2 = waveform_ring_f2;
574 current_ring_node_f2 = waveform_ring_f2;
575 ring_node_to_send_cwf_f2 = waveform_ring_f2;
575 ring_node_to_send_cwf_f2 = waveform_ring_f2;
576 ring_node_to_send_swf_f2 = waveform_ring_f2;
576 ring_node_to_send_swf_f2 = waveform_ring_f2;
577 }
577 }
578
578
579 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
579 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
580 {
580 {
581 unsigned char i;
581 unsigned char i;
582
582
583 for (i=0; i<7; i++)
583 for (i=0; i<7; i++)
584 {
584 {
585 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
585 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
586 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
586 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
587 headerSWF[ i ].reserved = DEFAULT_RESERVED;
587 headerSWF[ i ].reserved = DEFAULT_RESERVED;
588 headerSWF[ i ].userApplication = CCSDS_USER_APP;
588 headerSWF[ i ].userApplication = CCSDS_USER_APP;
589 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
589 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
590 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
590 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
591 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
591 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
592 if (i == 6)
592 if (i == 6)
593 {
593 {
594 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
594 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
595 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
595 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
596 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
596 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
597 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
597 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
598 }
598 }
599 else
599 else
600 {
600 {
601 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
601 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
602 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
602 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
603 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
603 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
604 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
604 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
605 }
605 }
606 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
606 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
607 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
607 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
608 headerSWF[ i ].pktNr = i+1; // PKT_NR
608 headerSWF[ i ].pktNr = i+1; // PKT_NR
609 // DATA FIELD HEADER
609 // DATA FIELD HEADER
610 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
610 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
611 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
611 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
612 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
612 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
613 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
613 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
614 // AUXILIARY DATA HEADER
614 // AUXILIARY DATA HEADER
615 headerSWF[ i ].time[0] = 0x00;
615 headerSWF[ i ].time[0] = 0x00;
616 headerSWF[ i ].time[0] = 0x00;
616 headerSWF[ i ].time[0] = 0x00;
617 headerSWF[ i ].time[0] = 0x00;
617 headerSWF[ i ].time[0] = 0x00;
618 headerSWF[ i ].time[0] = 0x00;
618 headerSWF[ i ].time[0] = 0x00;
619 headerSWF[ i ].time[0] = 0x00;
619 headerSWF[ i ].time[0] = 0x00;
620 headerSWF[ i ].time[0] = 0x00;
620 headerSWF[ i ].time[0] = 0x00;
621 headerSWF[ i ].sid = sid;
621 headerSWF[ i ].sid = sid;
622 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
622 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
623 }
623 }
624 return LFR_SUCCESSFUL;
624 return LFR_SUCCESSFUL;
625 }
625 }
626
626
627 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
627 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
628 {
628 {
629 unsigned int i;
629 unsigned int i;
630
630
631 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
631 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
632 {
632 {
633 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
633 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
634 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
634 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
635 headerCWF[ i ].reserved = DEFAULT_RESERVED;
635 headerCWF[ i ].reserved = DEFAULT_RESERVED;
636 headerCWF[ i ].userApplication = CCSDS_USER_APP;
636 headerCWF[ i ].userApplication = CCSDS_USER_APP;
637 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
637 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
638 {
638 {
639 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
639 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
640 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
640 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
641 }
641 }
642 else
642 else
643 {
643 {
644 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
644 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
645 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
645 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
646 }
646 }
647 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
647 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
648 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
648 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
649 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
649 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
650 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
650 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
651 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
651 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
652 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
652 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
653 // DATA FIELD HEADER
653 // DATA FIELD HEADER
654 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
654 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
655 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
655 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
656 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
656 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
657 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
657 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
658 // AUXILIARY DATA HEADER
658 // AUXILIARY DATA HEADER
659 headerCWF[ i ].sid = sid;
659 headerCWF[ i ].sid = sid;
660 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
660 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
661 headerCWF[ i ].time[0] = 0x00;
661 headerCWF[ i ].time[0] = 0x00;
662 headerCWF[ i ].time[0] = 0x00;
662 headerCWF[ i ].time[0] = 0x00;
663 headerCWF[ i ].time[0] = 0x00;
663 headerCWF[ i ].time[0] = 0x00;
664 headerCWF[ i ].time[0] = 0x00;
664 headerCWF[ i ].time[0] = 0x00;
665 headerCWF[ i ].time[0] = 0x00;
665 headerCWF[ i ].time[0] = 0x00;
666 headerCWF[ i ].time[0] = 0x00;
666 headerCWF[ i ].time[0] = 0x00;
667 }
667 }
668 return LFR_SUCCESSFUL;
668 return LFR_SUCCESSFUL;
669 }
669 }
670
670
671 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
671 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
672 {
672 {
673 unsigned int i;
673 unsigned int i;
674
674
675 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
675 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
676 {
676 {
677 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
677 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
678 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
678 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
679 headerCWF[ i ].reserved = DEFAULT_RESERVED;
679 headerCWF[ i ].reserved = DEFAULT_RESERVED;
680 headerCWF[ i ].userApplication = CCSDS_USER_APP;
680 headerCWF[ i ].userApplication = CCSDS_USER_APP;
681
681
682 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
682 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
683 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
683 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
684
684
685 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
685 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
686 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
686 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
687 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
687 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
688 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
688 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
689 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
689 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
690
690
691 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
691 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
692 // DATA FIELD HEADER
692 // DATA FIELD HEADER
693 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
693 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
694 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
694 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
695 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
695 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
696 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
696 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
697 // AUXILIARY DATA HEADER
697 // AUXILIARY DATA HEADER
698 headerCWF[ i ].sid = SID_NORM_CWF_F3;
698 headerCWF[ i ].sid = SID_NORM_CWF_F3;
699 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
699 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
700 headerCWF[ i ].time[0] = 0x00;
700 headerCWF[ i ].time[0] = 0x00;
701 headerCWF[ i ].time[0] = 0x00;
701 headerCWF[ i ].time[0] = 0x00;
702 headerCWF[ i ].time[0] = 0x00;
702 headerCWF[ i ].time[0] = 0x00;
703 headerCWF[ i ].time[0] = 0x00;
703 headerCWF[ i ].time[0] = 0x00;
704 headerCWF[ i ].time[0] = 0x00;
704 headerCWF[ i ].time[0] = 0x00;
705 headerCWF[ i ].time[0] = 0x00;
705 headerCWF[ i ].time[0] = 0x00;
706 }
706 }
707 return LFR_SUCCESSFUL;
707 return LFR_SUCCESSFUL;
708 }
708 }
709
709
710 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
710 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
711 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
711 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
712 {
712 {
713 /** This function sends SWF CCSDS packets (F2, F1 or F0).
713 /** This function sends SWF CCSDS packets (F2, F1 or F0).
714 *
714 *
715 * @param waveform points to the buffer containing the data that will be send.
715 * @param waveform points to the buffer containing the data that will be send.
716 * @param sid is the source identifier of the data that will be sent.
716 * @param sid is the source identifier of the data that will be sent.
717 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
717 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
718 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
718 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
719 * contain information to setup the transmission of the data packets.
719 * contain information to setup the transmission of the data packets.
720 *
720 *
721 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
721 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
722 *
722 *
723 */
723 */
724
724
725 unsigned int i;
725 unsigned int i;
726 int ret;
726 int ret;
727 unsigned int coarseTime;
727 unsigned int coarseTime;
728 unsigned int fineTime;
728 unsigned int fineTime;
729 rtems_status_code status;
729 rtems_status_code status;
730 spw_ioctl_pkt_send spw_ioctl_send_SWF;
730 spw_ioctl_pkt_send spw_ioctl_send_SWF;
731
731
732 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
732 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
733 spw_ioctl_send_SWF.options = 0;
733 spw_ioctl_send_SWF.options = 0;
734
734
735 ret = LFR_DEFAULT;
735 ret = LFR_DEFAULT;
736
736
737 coarseTime = waveform[0];
737 coarseTime = waveform[0];
738 fineTime = waveform[1];
738 fineTime = waveform[1];
739
739
740 for (i=0; i<7; i++) // send waveform
740 for (i=0; i<7; i++) // send waveform
741 {
741 {
742 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
742 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
743 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
743 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
744 // BUILD THE DATA
744 // BUILD THE DATA
745 if (i==6) {
745 if (i==6) {
746 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
746 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
747 }
747 }
748 else {
748 else {
749 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
749 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
750 }
750 }
751 // SET PACKET SEQUENCE COUNTER
751 // SET PACKET SEQUENCE COUNTER
752 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
752 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
753 // SET PACKET TIME
753 // SET PACKET TIME
754 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
754 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
755 //
755 //
756 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
756 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
757 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
757 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
758 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
758 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
759 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
759 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
760 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
760 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
761 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
761 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
762 // SEND PACKET
762 // SEND PACKET
763 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
763 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
764 if (status != RTEMS_SUCCESSFUL) {
764 if (status != RTEMS_SUCCESSFUL) {
765 printf("%d-%d, ERR %d\n", sid, i, (int) status);
765 printf("%d-%d, ERR %d\n", sid, i, (int) status);
766 ret = LFR_DEFAULT;
766 ret = LFR_DEFAULT;
767 }
767 }
768 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
768 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
769 }
769 }
770
770
771 return ret;
771 return ret;
772 }
772 }
773
773
774 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
774 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
775 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
775 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
776 {
776 {
777 /** This function sends CWF CCSDS packets (F2, F1 or F0).
777 /** This function sends CWF CCSDS packets (F2, F1 or F0).
778 *
778 *
779 * @param waveform points to the buffer containing the data that will be send.
779 * @param waveform points to the buffer containing the data that will be send.
780 * @param sid is the source identifier of the data that will be sent.
780 * @param sid is the source identifier of the data that will be sent.
781 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
781 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
782 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
782 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
783 * contain information to setup the transmission of the data packets.
783 * contain information to setup the transmission of the data packets.
784 *
784 *
785 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
785 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
786 *
786 *
787 */
787 */
788
788
789 unsigned int i;
789 unsigned int i;
790 int ret;
790 int ret;
791 unsigned int coarseTime;
791 unsigned int coarseTime;
792 unsigned int fineTime;
792 unsigned int fineTime;
793 rtems_status_code status;
793 rtems_status_code status;
794 spw_ioctl_pkt_send spw_ioctl_send_CWF;
794 spw_ioctl_pkt_send spw_ioctl_send_CWF;
795
795
796 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
796 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
797 spw_ioctl_send_CWF.options = 0;
797 spw_ioctl_send_CWF.options = 0;
798
798
799 ret = LFR_DEFAULT;
799 ret = LFR_DEFAULT;
800
800
801 coarseTime = waveform[0];
801 coarseTime = waveform[0];
802 fineTime = waveform[1];
802 fineTime = waveform[1];
803
803
804 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
804 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
805 {
805 {
806 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
806 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
807 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
807 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
808 // BUILD THE DATA
808 // BUILD THE DATA
809 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
809 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
810 // SET PACKET SEQUENCE COUNTER
810 // SET PACKET SEQUENCE COUNTER
811 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
811 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
812 // SET PACKET TIME
812 // SET PACKET TIME
813 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
813 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
814 //
814 //
815 headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
815 headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
816 headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
816 headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
817 headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
817 headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
818 headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
818 headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
819 headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
819 headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
820 headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
820 headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
821 // SEND PACKET
821 // SEND PACKET
822 if (sid == SID_NORM_CWF_LONG_F3)
822 if (sid == SID_NORM_CWF_LONG_F3)
823 {
823 {
824 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
824 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
825 if (status != RTEMS_SUCCESSFUL) {
825 if (status != RTEMS_SUCCESSFUL) {
826 printf("%d-%d, ERR %d\n", sid, i, (int) status);
826 printf("%d-%d, ERR %d\n", sid, i, (int) status);
827 ret = LFR_DEFAULT;
827 ret = LFR_DEFAULT;
828 }
828 }
829 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
829 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
830 }
830 }
831 else
831 else
832 {
832 {
833 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
833 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
834 if (status != RTEMS_SUCCESSFUL) {
834 if (status != RTEMS_SUCCESSFUL) {
835 printf("%d-%d, ERR %d\n", sid, i, (int) status);
835 printf("%d-%d, ERR %d\n", sid, i, (int) status);
836 ret = LFR_DEFAULT;
836 ret = LFR_DEFAULT;
837 }
837 }
838 }
838 }
839 }
839 }
840
840
841 return ret;
841 return ret;
842 }
842 }
843
843
844 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
844 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
845 {
845 {
846 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
846 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
847 *
847 *
848 * @param waveform points to the buffer containing the data that will be send.
848 * @param waveform points to the buffer containing the data that will be send.
849 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
849 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
850 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
850 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
851 * contain information to setup the transmission of the data packets.
851 * contain information to setup the transmission of the data packets.
852 *
852 *
853 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
853 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
854 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
854 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
855 *
855 *
856 */
856 */
857
857
858 unsigned int i;
858 unsigned int i;
859 int ret;
859 int ret;
860 unsigned int coarseTime;
860 unsigned int coarseTime;
861 unsigned int fineTime;
861 unsigned int fineTime;
862 rtems_status_code status;
862 rtems_status_code status;
863 spw_ioctl_pkt_send spw_ioctl_send_CWF;
863 spw_ioctl_pkt_send spw_ioctl_send_CWF;
864 char *sample;
864 char *sample;
865
865
866 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
866 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
867 spw_ioctl_send_CWF.options = 0;
867 spw_ioctl_send_CWF.options = 0;
868
868
869 ret = LFR_DEFAULT;
869 ret = LFR_DEFAULT;
870
870
871 //**********************
871 //**********************
872 // BUILD CWF3_light DATA
872 // BUILD CWF3_light DATA
873 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
873 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
874 {
874 {
875 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
875 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
876 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
876 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
877 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
877 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
878 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
878 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
879 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
879 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
880 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
880 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
881 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
881 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
882 }
882 }
883
883
884 coarseTime = waveform[0];
884 coarseTime = waveform[0];
885 fineTime = waveform[1];
885 fineTime = waveform[1];
886
886
887 //*********************
887 //*********************
888 // SEND CWF3_light DATA
888 // SEND CWF3_light DATA
889 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
889 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
890 {
890 {
891 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
891 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
892 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
892 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
893 // BUILD THE DATA
893 // BUILD THE DATA
894 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
894 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
895 // SET PACKET SEQUENCE COUNTER
895 // SET PACKET SEQUENCE COUNTER
896 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
896 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
897 // SET PACKET TIME
897 // SET PACKET TIME
898 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
898 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
899 //
899 //
900 headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
900 headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
901 headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
901 headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
902 headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
902 headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
903 headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
903 headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
904 headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
904 headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
905 headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
905 headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
906 // SEND PACKET
906 // SEND PACKET
907 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
907 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
908 if (status != RTEMS_SUCCESSFUL) {
908 if (status != RTEMS_SUCCESSFUL) {
909 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
909 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
910 ret = LFR_DEFAULT;
910 ret = LFR_DEFAULT;
911 }
911 }
912 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
912 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
913 }
913 }
914
914
915 return ret;
915 return ret;
916 }
916 }
917
917
918 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
918 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
919 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
919 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
920 {
920 {
921 unsigned long long int acquisitionTimeAsLong;
921 unsigned long long int acquisitionTimeAsLong;
922 unsigned char localAcquisitionTime[6];
922 unsigned char localAcquisitionTime[6];
923 double deltaT;
923 double deltaT;
924
924
925 deltaT = 0.;
925 deltaT = 0.;
926
926
927 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 );
927 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 );
928 localAcquisitionTime[1] = (unsigned char) ( coarseTime );
928 localAcquisitionTime[1] = (unsigned char) ( coarseTime );
929 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 );
929 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 );
930 localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 );
930 localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 );
931 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 );
931 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 );
932 localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 );
932 localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 );
933
933
934 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
934 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
935 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
935 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
936 + ( localAcquisitionTime[2] << 24 )
936 + ( localAcquisitionTime[2] << 24 )
937 + ( localAcquisitionTime[3] << 16 )
937 + ( localAcquisitionTime[3] << 16 )
938 + ( localAcquisitionTime[4] << 8 )
938 + ( localAcquisitionTime[4] << 8 )
939 + ( localAcquisitionTime[5] );
939 + ( localAcquisitionTime[5] );
940
940
941 switch( sid )
941 switch( sid )
942 {
942 {
943 case SID_NORM_SWF_F0:
943 case SID_NORM_SWF_F0:
944 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
944 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
945 break;
945 break;
946
946
947 case SID_NORM_SWF_F1:
947 case SID_NORM_SWF_F1:
948 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
948 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
949 break;
949 break;
950
950
951 case SID_NORM_SWF_F2:
951 case SID_NORM_SWF_F2:
952 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
952 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
953 break;
953 break;
954
954
955 case SID_SBM1_CWF_F1:
955 case SID_SBM1_CWF_F1:
956 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
956 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
957 break;
957 break;
958
958
959 case SID_SBM2_CWF_F2:
959 case SID_SBM2_CWF_F2:
960 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
960 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
961 break;
961 break;
962
962
963 case SID_BURST_CWF_F2:
963 case SID_BURST_CWF_F2:
964 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
964 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
965 break;
965 break;
966
966
967 case SID_NORM_CWF_F3:
967 case SID_NORM_CWF_F3:
968 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
968 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
969 break;
969 break;
970
970
971 case SID_NORM_CWF_LONG_F3:
971 case SID_NORM_CWF_LONG_F3:
972 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
972 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
973 break;
973 break;
974
974
975 default:
975 default:
976 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
976 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
977 deltaT = 0.;
977 deltaT = 0.;
978 break;
978 break;
979 }
979 }
980
980
981 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
981 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
982 //
982 //
983 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
983 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
984 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
984 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
985 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
985 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
986 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
986 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
987 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
987 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
988 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
988 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
989
989
990 }
990 }
991
991
992 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
992 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
993 {
993 {
994 unsigned int i;
994 unsigned int i;
995 unsigned long long int centerTime_asLong;
995 unsigned long long int centerTime_asLong;
996 unsigned long long int acquisitionTimeF0_asLong;
996 unsigned long long int acquisitionTimeF0_asLong;
997 unsigned long long int acquisitionTime_asLong;
997 unsigned long long int acquisitionTime_asLong;
998 unsigned long long int bufferAcquisitionTime_asLong;
998 unsigned long long int bufferAcquisitionTime_asLong;
999 unsigned char *ptr1;
999 unsigned char *ptr1;
1000 unsigned char *ptr2;
1000 unsigned char *ptr2;
1001 unsigned char nb_ring_nodes;
1001 unsigned char nb_ring_nodes;
1002 unsigned long long int frequency_asLong;
1002 unsigned long long int frequency_asLong;
1003 unsigned long long int nbTicksPerSample_asLong;
1003 unsigned long long int nbTicksPerSample_asLong;
1004 unsigned long long int nbSamplesPart1_asLong;
1004 unsigned long long int nbSamplesPart1_asLong;
1005 unsigned long long int sampleOffset_asLong;
1005 unsigned long long int sampleOffset_asLong;
1006
1006
1007 unsigned int deltaT_F0;
1007 unsigned int deltaT_F0;
1008 unsigned int deltaT_F1;
1008 unsigned int deltaT_F1;
1009 unsigned long long int deltaT_F2;
1009 unsigned long long int deltaT_F2;
1010
1010
1011 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1011 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1012 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
1012 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
1013 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
1013 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
1014 sampleOffset_asLong = 0x00;
1014 sampleOffset_asLong = 0x00;
1015
1015
1016 // get the f0 acquisition time
1016 // get the f0 acquisition time
1017 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1017 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1018 PRINTF1("acquisitionTimeF0_asLong %llx \n", acquisitionTimeF0_asLong)
1019
1018
1020 // compute the central reference time
1019 // compute the central reference time
1021 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1020 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1022 PRINTF1("centerTime_asLong %llx \n", centerTime_asLong)
1023
1021
1024 // compute the acquisition time of the current snapshot
1022 // compute the acquisition time of the current snapshot
1025 switch(frequencyChannel)
1023 switch(frequencyChannel)
1026 {
1024 {
1027 case 1: // 1 is for F1 = 4096 Hz
1025 case 1: // 1 is for F1 = 4096 Hz
1028 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1026 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1029 nb_ring_nodes = NB_RING_NODES_F1;
1027 nb_ring_nodes = NB_RING_NODES_F1;
1030 frequency_asLong = 4096;
1028 frequency_asLong = 4096;
1031 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1029 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1032 break;
1030 break;
1033 case 2: // 2 is for F2 = 256 Hz
1031 case 2: // 2 is for F2 = 256 Hz
1034 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1032 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1035 nb_ring_nodes = NB_RING_NODES_F2;
1033 nb_ring_nodes = NB_RING_NODES_F2;
1036 frequency_asLong = 256;
1034 frequency_asLong = 256;
1037 nbTicksPerSample_asLong = 256; // 65536 / 256;
1035 nbTicksPerSample_asLong = 256; // 65536 / 256;
1038 break;
1036 break;
1039 default:
1037 default:
1040 acquisitionTime_asLong = centerTime_asLong;
1038 acquisitionTime_asLong = centerTime_asLong;
1041 frequency_asLong = 256;
1039 frequency_asLong = 256;
1042 nbTicksPerSample_asLong = 256;
1040 nbTicksPerSample_asLong = 256;
1043 break;
1041 break;
1044 }
1042 }
1045 PRINTF1("acquisitionTime_asLong %llx\n", acquisitionTime_asLong)
1046
1043
1047 //****************************************************************************
1044 //****************************************************************************
1048 // 1) search the ring_node with the acquisition time <= acquisitionTime_asLong
1045 // 1) search the ring_node with the acquisition time <= acquisitionTime_asLong
1049 for (i=0; i<nb_ring_nodes; i++)
1046 for (i=0; i<nb_ring_nodes; i++)
1050 {
1047 {
1051 PRINTF1("%d ... ", i)
1048 PRINTF1("%d ... ", i)
1052 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1049 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1053 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1050 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1054 {
1051 {
1055 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1052 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1056 break;
1053 break;
1057 }
1054 }
1058 ring_node_to_send = ring_node_to_send->previous;
1055 ring_node_to_send = ring_node_to_send->previous;
1059 }
1056 }
1060
1057
1061 //*************************************************
1058 //*************************************************
1062 // (2) once the buffer is found, build the snapshot
1059 // (2) once the buffer is found, build the snapshot
1063
1060
1064 // compute the number of samples to take in the current buffer
1061 // compute the number of samples to take in the current buffer
1065 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1062 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1066 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1063 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1067 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1 = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1068
1064
1069 // compute the final acquisition time
1065 // compute the final acquisition time
1070 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1066 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1071 sampleOffset_asLong * nbTicksPerSample_asLong;
1067 sampleOffset_asLong * nbTicksPerSample_asLong;
1072 PRINTF1("FINAL acquisitionTime_asLong %llx\n\n", acquisitionTime_asLong)
1073
1068
1074 // copy the acquisition time at the beginning of the extrated snapshot
1069 // copy the acquisition time at the beginning of the extrated snapshot
1075 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1070 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1076 ptr2 = (unsigned char*) wf_snap_extracted;
1071 ptr2 = (unsigned char*) wf_snap_extracted;
1077 ptr2[0] = ptr1[ 2 + 2 ];
1072 ptr2[0] = ptr1[ 2 + 2 ];
1078 ptr2[1] = ptr1[ 3 + 2 ];
1073 ptr2[1] = ptr1[ 3 + 2 ];
1079 ptr2[2] = ptr1[ 0 + 2 ];
1074 ptr2[2] = ptr1[ 0 + 2 ];
1080 ptr2[3] = ptr1[ 1 + 2 ];
1075 ptr2[3] = ptr1[ 1 + 2 ];
1081 ptr2[4] = ptr1[ 4 + 2 ];
1076 ptr2[4] = ptr1[ 4 + 2 ];
1082 ptr2[5] = ptr1[ 5 + 2 ];
1077 ptr2[5] = ptr1[ 5 + 2 ];
1083
1078
1084 // re set the synchronization bit
1079 // re set the synchronization bit
1085
1080
1086
1081
1087 // copy the part 1 of the snapshot in the extracted buffer
1082 // copy the part 1 of the snapshot in the extracted buffer
1088 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1083 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1089 {
1084 {
1090 wf_snap_extracted[i + TIME_OFFSET] =
1085 wf_snap_extracted[i + TIME_OFFSET] =
1091 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1086 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1092 }
1087 }
1093 // copy the part 2 of the snapshot in the extracted buffer
1088 // copy the part 2 of the snapshot in the extracted buffer
1094 ring_node_to_send = ring_node_to_send->next;
1089 ring_node_to_send = ring_node_to_send->next;
1095 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1090 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1096 {
1091 {
1097 wf_snap_extracted[i + TIME_OFFSET] =
1092 wf_snap_extracted[i + TIME_OFFSET] =
1098 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1093 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1099 }
1094 }
1100 }
1095 }
1101
1096
1102 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1097 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1103 {
1098 {
1104 unsigned char *acquisitionTimeCharPtr;
1099 unsigned char *acquisitionTimeCharPtr;
1105
1100
1106 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1101 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1107
1102
1108 *acquisitionTimeAslong = 0x00;
1103 *acquisitionTimeAslong = 0x00;
1109 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1104 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1110 + ( acquisitionTimeCharPtr[1] << 16 )
1105 + ( acquisitionTimeCharPtr[1] << 16 )
1111 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1106 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1112 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1107 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1113 + ( acquisitionTimeCharPtr[4] << 8 )
1108 + ( acquisitionTimeCharPtr[4] << 8 )
1114 + ( acquisitionTimeCharPtr[5] );
1109 + ( acquisitionTimeCharPtr[5] );
1115 }
1110 }
1116
1111
1117 //**************
1112 //**************
1118 // wfp registers
1113 // wfp registers
1119 void reset_wfp_burst_enable(void)
1114 void reset_wfp_burst_enable(void)
1120 {
1115 {
1121 /** This function resets the waveform picker burst_enable register.
1116 /** This function resets the waveform picker burst_enable register.
1122 *
1117 *
1123 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1118 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1124 *
1119 *
1125 */
1120 */
1126
1121
1127 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1122 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1128 }
1123 }
1129
1124
1130 void reset_wfp_status( void )
1125 void reset_wfp_status( void )
1131 {
1126 {
1132 /** This function resets the waveform picker status register.
1127 /** This function resets the waveform picker status register.
1133 *
1128 *
1134 * All status bits are set to 0 [new_err full_err full].
1129 * All status bits are set to 0 [new_err full_err full].
1135 *
1130 *
1136 */
1131 */
1137
1132
1138 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1133 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1139 }
1134 }
1140
1135
1141 void reset_waveform_picker_regs(void)
1136 void reset_waveform_picker_regs(void)
1142 {
1137 {
1143 /** This function resets the waveform picker module registers.
1138 /** This function resets the waveform picker module registers.
1144 *
1139 *
1145 * The registers affected by this function are located at the following offset addresses:
1140 * The registers affected by this function are located at the following offset addresses:
1146 * - 0x00 data_shaping
1141 * - 0x00 data_shaping
1147 * - 0x04 run_burst_enable
1142 * - 0x04 run_burst_enable
1148 * - 0x08 addr_data_f0
1143 * - 0x08 addr_data_f0
1149 * - 0x0C addr_data_f1
1144 * - 0x0C addr_data_f1
1150 * - 0x10 addr_data_f2
1145 * - 0x10 addr_data_f2
1151 * - 0x14 addr_data_f3
1146 * - 0x14 addr_data_f3
1152 * - 0x18 status
1147 * - 0x18 status
1153 * - 0x1C delta_snapshot
1148 * - 0x1C delta_snapshot
1154 * - 0x20 delta_f0
1149 * - 0x20 delta_f0
1155 * - 0x24 delta_f0_2
1150 * - 0x24 delta_f0_2
1156 * - 0x28 delta_f1
1151 * - 0x28 delta_f1
1157 * - 0x2c delta_f2
1152 * - 0x2c delta_f2
1158 * - 0x30 nb_data_by_buffer
1153 * - 0x30 nb_data_by_buffer
1159 * - 0x34 nb_snapshot_param
1154 * - 0x34 nb_snapshot_param
1160 * - 0x38 start_date
1155 * - 0x38 start_date
1161 * - 0x3c nb_word_in_buffer
1156 * - 0x3c nb_word_in_buffer
1162 *
1157 *
1163 */
1158 */
1164
1159
1165 waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1160 // waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1166 waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1161 waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1167 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1162 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1168 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1163 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1169 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1164 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1170 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1165 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1171 waveform_picker_regs->status = 0x00; // 0x18
1166 waveform_picker_regs->status = 0x00; // 0x18
1172 //
1167 //
1173 set_wfp_delta_snapshot(); // 0x1c
1168 set_wfp_delta_snapshot(); // 0x1c
1174 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1169 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1175 set_wfp_delta_f1(); // 0x28
1170 set_wfp_delta_f1(); // 0x28
1176 set_wfp_delta_f2(); // 0x2c
1171 set_wfp_delta_f2(); // 0x2c
1177 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1172 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1178 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1173 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1179 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1174 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1180 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1175 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1181 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1176 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1182 // 2688 = 8 * 336
1177 // 2688 = 8 * 336
1183 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1178 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1184 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1179 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1185 waveform_picker_regs->start_date = 0x00; // 0x38
1180 waveform_picker_regs->start_date = 0x00; // 0x38
1186 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1181 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1187 }
1182 }
1188
1183
1189 void set_wfp_data_shaping( void )
1184 void set_wfp_data_shaping( void )
1190 {
1185 {
1191 /** This function sets the data_shaping register of the waveform picker module.
1186 /** This function sets the data_shaping register of the waveform picker module.
1192 *
1187 *
1193 * The value is read from one field of the parameter_dump_packet structure:\n
1188 * The value is read from one field of the parameter_dump_packet structure:\n
1194 * bw_sp0_sp1_r0_r1
1189 * bw_sp0_sp1_r0_r1
1195 *
1190 *
1196 */
1191 */
1197
1192
1198 unsigned char data_shaping;
1193 unsigned char data_shaping;
1199
1194
1200 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1195 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1201 // waveform picker : [R1 R0 SP1 SP0 BW]
1196 // waveform picker : [R1 R0 SP1 SP0 BW]
1202
1197
1203 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1198 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1204
1199
1205 waveform_picker_regs->data_shaping =
1200 waveform_picker_regs->data_shaping =
1206 ( (data_shaping & 0x10) >> 4 ) // BW
1201 ( (data_shaping & 0x10) >> 4 ) // BW
1207 + ( (data_shaping & 0x08) >> 2 ) // SP0
1202 + ( (data_shaping & 0x08) >> 2 ) // SP0
1208 + ( (data_shaping & 0x04) ) // SP1
1203 + ( (data_shaping & 0x04) ) // SP1
1209 + ( (data_shaping & 0x02) << 2 ) // R0
1204 + ( (data_shaping & 0x02) << 2 ) // R0
1210 + ( (data_shaping & 0x01) << 4 ); // R1
1205 + ( (data_shaping & 0x01) << 4 ); // R1
1211 }
1206 }
1212
1207
1213 void set_wfp_burst_enable_register( unsigned char mode )
1208 void set_wfp_burst_enable_register( unsigned char mode )
1214 {
1209 {
1215 /** This function sets the waveform picker burst_enable register depending on the mode.
1210 /** This function sets the waveform picker burst_enable register depending on the mode.
1216 *
1211 *
1217 * @param mode is the LFR mode to launch.
1212 * @param mode is the LFR mode to launch.
1218 *
1213 *
1219 * The burst bits shall be before the enable bits.
1214 * The burst bits shall be before the enable bits.
1220 *
1215 *
1221 */
1216 */
1222
1217
1223 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1218 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1224 // the burst bits shall be set first, before the enable bits
1219 // the burst bits shall be set first, before the enable bits
1225 switch(mode) {
1220 switch(mode) {
1226 case(LFR_MODE_NORMAL):
1221 case(LFR_MODE_NORMAL):
1227 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1222 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1228 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1223 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1229 break;
1224 break;
1230 case(LFR_MODE_BURST):
1225 case(LFR_MODE_BURST):
1231 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1226 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1232 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1227 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1233 break;
1228 break;
1234 case(LFR_MODE_SBM1):
1229 case(LFR_MODE_SBM1):
1235 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1230 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1236 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1231 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1237 break;
1232 break;
1238 case(LFR_MODE_SBM2):
1233 case(LFR_MODE_SBM2):
1239 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1234 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1240 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1235 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1241 break;
1236 break;
1242 default:
1237 default:
1243 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1238 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1244 break;
1239 break;
1245 }
1240 }
1246 }
1241 }
1247
1242
1248 void set_wfp_delta_snapshot( void )
1243 void set_wfp_delta_snapshot( void )
1249 {
1244 {
1250 /** This function sets the delta_snapshot register of the waveform picker module.
1245 /** This function sets the delta_snapshot register of the waveform picker module.
1251 *
1246 *
1252 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1247 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1253 * - sy_lfr_n_swf_p[0]
1248 * - sy_lfr_n_swf_p[0]
1254 * - sy_lfr_n_swf_p[1]
1249 * - sy_lfr_n_swf_p[1]
1255 *
1250 *
1256 */
1251 */
1257
1252
1258 unsigned int delta_snapshot;
1253 unsigned int delta_snapshot;
1259 unsigned int delta_snapshot_in_T2;
1254 unsigned int delta_snapshot_in_T2;
1260
1255
1261 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1256 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1262 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1257 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1263
1258
1264 delta_snapshot_in_T2 = delta_snapshot * 256;
1259 delta_snapshot_in_T2 = delta_snapshot * 256;
1265 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes
1260 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes
1266 }
1261 }
1267
1262
1268 void set_wfp_delta_f0_f0_2( void )
1263 void set_wfp_delta_f0_f0_2( void )
1269 {
1264 {
1270 unsigned int delta_snapshot;
1265 unsigned int delta_snapshot;
1271 unsigned int nb_samples_per_snapshot;
1266 unsigned int nb_samples_per_snapshot;
1272 float delta_f0_in_float;
1267 float delta_f0_in_float;
1273
1268
1274 delta_snapshot = waveform_picker_regs->delta_snapshot;
1269 delta_snapshot = waveform_picker_regs->delta_snapshot;
1275 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1270 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1276 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1271 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1277
1272
1278 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1273 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1279 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1274 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1280 }
1275 }
1281
1276
1282 void set_wfp_delta_f1( void )
1277 void set_wfp_delta_f1( void )
1283 {
1278 {
1284 unsigned int delta_snapshot;
1279 unsigned int delta_snapshot;
1285 unsigned int nb_samples_per_snapshot;
1280 unsigned int nb_samples_per_snapshot;
1286 float delta_f1_in_float;
1281 float delta_f1_in_float;
1287
1282
1288 delta_snapshot = waveform_picker_regs->delta_snapshot;
1283 delta_snapshot = waveform_picker_regs->delta_snapshot;
1289 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1284 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1290 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1285 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1291
1286
1292 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1287 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1293 }
1288 }
1294
1289
1295 void set_wfp_delta_f2()
1290 void set_wfp_delta_f2()
1296 {
1291 {
1297 unsigned int delta_snapshot;
1292 unsigned int delta_snapshot;
1298 unsigned int nb_samples_per_snapshot;
1293 unsigned int nb_samples_per_snapshot;
1299
1294
1300 delta_snapshot = waveform_picker_regs->delta_snapshot;
1295 delta_snapshot = waveform_picker_regs->delta_snapshot;
1301 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1296 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1302
1297
1303 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1298 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1304 }
1299 }
1305
1300
1306 //*****************
1301 //*****************
1307 // local parameters
1302 // local parameters
1308 void set_local_nb_interrupt_f0_MAX( void )
1303 void set_local_nb_interrupt_f0_MAX( void )
1309 {
1304 {
1310 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1305 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1311 *
1306 *
1312 * This parameter is used for the SM validation only.\n
1307 * This parameter is used for the SM validation only.\n
1313 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1308 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1314 * module before launching a basic processing.
1309 * module before launching a basic processing.
1315 *
1310 *
1316 */
1311 */
1317
1312
1318 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1313 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1319 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1314 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1320 }
1315 }
1321
1316
1322 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1317 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1323 {
1318 {
1324 unsigned short *sequence_cnt;
1319 unsigned short *sequence_cnt;
1325 unsigned short segmentation_grouping_flag;
1320 unsigned short segmentation_grouping_flag;
1326 unsigned short new_packet_sequence_control;
1321 unsigned short new_packet_sequence_control;
1327
1322
1328 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1323 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1329 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1324 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1330 {
1325 {
1331 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1326 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1332 }
1327 }
1333 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1328 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1334 {
1329 {
1335 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1330 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1336 }
1331 }
1337 else
1332 else
1338 {
1333 {
1339 sequence_cnt = NULL;
1334 sequence_cnt = NULL;
1340 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1335 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1341 }
1336 }
1342
1337
1343 if (sequence_cnt != NULL)
1338 if (sequence_cnt != NULL)
1344 {
1339 {
1345 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1340 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1346 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1341 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1347
1342
1348 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1343 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1349
1344
1350 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1345 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1351 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1346 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1352
1347
1353 // increment the sequence counter for the next packet
1348 // increment the sequence counter for the next packet
1354 if ( *sequence_cnt < SEQ_CNT_MAX)
1349 if ( *sequence_cnt < SEQ_CNT_MAX)
1355 {
1350 {
1356 *sequence_cnt = *sequence_cnt + 1;
1351 *sequence_cnt = *sequence_cnt + 1;
1357 }
1352 }
1358 else
1353 else
1359 {
1354 {
1360 *sequence_cnt = 0;
1355 *sequence_cnt = 0;
1361 }
1356 }
1362 }
1357 }
1363 }
1358 }
General Comments 0
You need to be logged in to leave comments. Login now