##// END OF EJS Templates
setFBinMask corrected...
paul -
r313:972ae9f0eb8f R3_plus draft
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 94f0f2fccbcb8030d9437ffbb69ee0eefaaea188 header/lfr_common_headers
2 57edc38eadba4601cf0b1e2fa1eeab85082e9f41 header/lfr_common_headers
@@ -1,106 +1,108
1 cmake_minimum_required (VERSION 2.6)
1 cmake_minimum_required (VERSION 2.6)
2 project (fsw)
2 project (fsw)
3
3
4 include(sparc-rtems)
4 include(sparc-rtems)
5 include(cppcheck)
5 include(cppcheck)
6
6
7 include_directories("../header"
7 include_directories("../header"
8 "../header/lfr_common_headers"
8 "../header/lfr_common_headers"
9 "../header/processing"
9 "../header/processing"
10 "../LFR_basic-parameters"
10 "../LFR_basic-parameters"
11 "../src")
11 "../src")
12
12
13 set(SOURCES wf_handler.c
13 set(SOURCES wf_handler.c
14 tc_handler.c
14 tc_handler.c
15 fsw_misc.c
15 fsw_misc.c
16 fsw_init.c
16 fsw_init.c
17 fsw_globals.c
17 fsw_globals.c
18 fsw_spacewire.c
18 fsw_spacewire.c
19 tc_load_dump_parameters.c
19 tc_load_dump_parameters.c
20 tm_lfr_tc_exe.c
20 tm_lfr_tc_exe.c
21 tc_acceptance.c
21 tc_acceptance.c
22 processing/fsw_processing.c
22 processing/fsw_processing.c
23 processing/avf0_prc0.c
23 processing/avf0_prc0.c
24 processing/avf1_prc1.c
24 processing/avf1_prc1.c
25 processing/avf2_prc2.c
25 processing/avf2_prc2.c
26 lfr_cpu_usage_report.c
26 lfr_cpu_usage_report.c
27 ${LFR_BP_SRC}
27 ${LFR_BP_SRC}
28 ../header/wf_handler.h
28 ../header/wf_handler.h
29 ../header/tc_handler.h
29 ../header/tc_handler.h
30 ../header/grlib_regs.h
30 ../header/grlib_regs.h
31 ../header/fsw_misc.h
31 ../header/fsw_misc.h
32 ../header/fsw_init.h
32 ../header/fsw_init.h
33 ../header/fsw_spacewire.h
33 ../header/fsw_spacewire.h
34 ../header/tc_load_dump_parameters.h
34 ../header/tc_load_dump_parameters.h
35 ../header/tm_lfr_tc_exe.h
35 ../header/tm_lfr_tc_exe.h
36 ../header/tc_acceptance.h
36 ../header/tc_acceptance.h
37 ../header/processing/fsw_processing.h
37 ../header/processing/fsw_processing.h
38 ../header/processing/avf0_prc0.h
38 ../header/processing/avf0_prc0.h
39 ../header/processing/avf1_prc1.h
39 ../header/processing/avf1_prc1.h
40 ../header/processing/avf2_prc2.h
40 ../header/processing/avf2_prc2.h
41 ../header/fsw_params_wf_handler.h
41 ../header/fsw_params_wf_handler.h
42 ../header/lfr_cpu_usage_report.h
42 ../header/lfr_cpu_usage_report.h
43 ../header/lfr_common_headers/ccsds_types.h
43 ../header/lfr_common_headers/ccsds_types.h
44 ../header/lfr_common_headers/fsw_params.h
44 ../header/lfr_common_headers/fsw_params.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
46 ../header/lfr_common_headers/fsw_params_processing.h
46 ../header/lfr_common_headers/fsw_params_processing.h
47 ../header/lfr_common_headers/tm_byte_positions.h
47 ../header/lfr_common_headers/tm_byte_positions.h
48 ../LFR_basic-parameters/basic_parameters.h
48 ../LFR_basic-parameters/basic_parameters.h
49 ../LFR_basic-parameters/basic_parameters_params.h
49 ../LFR_basic-parameters/basic_parameters_params.h
50 ../header/GscMemoryLPP.hpp
50 ../header/GscMemoryLPP.hpp
51 )
51 )
52
52
53
53
54 option(FSW_verbose "Enable verbose LFR" ON)
54 option(FSW_verbose "Enable verbose LFR" ON)
55 option(FSW_boot_messages "Enable LFR boot messages" ON)
55 option(FSW_boot_messages "Enable LFR boot messages" ON)
56 option(FSW_debug_messages "Enable LFR debug messages" ON)
56 option(FSW_debug_messages "Enable LFR debug messages" ON)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)
59 option(FSW_vhdl_dev "?" OFF)
59 option(FSW_vhdl_dev "?" OFF)
60 option(FSW_lpp_dpu_destid "Set to debug at LPP" ON)
60 option(FSW_lpp_dpu_destid "Set to debug at LPP" ON)
61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
62 option(FSW_debug_tch "?" OFF)
62 option(FSW_debug_tch "?" OFF)
63
63
64 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
64 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
65 set(SW_VERSION_N2 "1" CACHE STRING "Choose N2 FSW Version." FORCE)
65 set(SW_VERSION_N2 "1" CACHE STRING "Choose N2 FSW Version." FORCE)
66 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
66 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
67 set(SW_VERSION_N4 "4" CACHE STRING "Choose N4 FSW Version." FORCE)
67 set(SW_VERSION_N4 "4" CACHE STRING "Choose N4 FSW Version." FORCE)
68
68
69
69
70 if(FSW_verbose)
70 if(FSW_verbose)
71 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
71 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
72 endif()
72 endif()
73 if(FSW_boot_messages)
73 if(FSW_boot_messages)
74 add_definitions(-DBOOT_MESSAGES)
74 add_definitions(-DBOOT_MESSAGES)
75 endif()
75 endif()
76 if(FSW_debug_messages)
76 if(FSW_debug_messages)
77 add_definitions(-DDEBUG_MESSAGES)
77 add_definitions(-DDEBUG_MESSAGES)
78 endif()
78 endif()
79 if(FSW_cpu_usage_report)
79 if(FSW_cpu_usage_report)
80 add_definitions(-DPRINT_TASK_STATISTICS)
80 add_definitions(-DPRINT_TASK_STATISTICS)
81 endif()
81 endif()
82 if(FSW_stack_report)
82 if(FSW_stack_report)
83 add_definitions(-DPRINT_STACK_REPORT)
83 add_definitions(-DPRINT_STACK_REPORT)
84 endif()
84 endif()
85 if(FSW_vhdl_dev)
85 if(FSW_vhdl_dev)
86 add_definitions(-DVHDL_DEV)
86 add_definitions(-DVHDL_DEV)
87 endif()
87 endif()
88 if(FSW_lpp_dpu_destid)
88 if(FSW_lpp_dpu_destid)
89 add_definitions(-DLPP_DPU_DESTID)
89 add_definitions(-DLPP_DPU_DESTID)
90 endif()
90 endif()
91 if(FSW_debug_watchdog)
91 if(FSW_debug_watchdog)
92 add_definitions(-DDEBUG_WATCHDOG)
92 add_definitions(-DDEBUG_WATCHDOG)
93 endif()
93 endif()
94 if(FSW_debug_tch)
94 if(FSW_debug_tch)
95 add_definitions(-DDEBUG_TCH)
95 add_definitions(-DDEBUG_TCH)
96 endif()
96 endif()
97
97
98 add_definitions(-DMSB_FIRST_TCH)
98 add_definitions(-DMSB_FIRST_TCH)
99
99
100 add_definitions(-DSWVERSION=-1-0)
100 add_definitions(-DSWVERSION=-1-0)
101 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
101 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
102 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
102 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
103 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
103 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
104 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
104 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
105
105
106 add_executable(FSW ${SOURCES})
106 add_executable(FSW ${SOURCES})
107 add_test_cppcheck(FSW STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE)
108
@@ -1,786 +1,786
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 #include "fsw_processing_globals.c"
11 #include "fsw_processing_globals.c"
12 #include "fsw_init.h"
12 #include "fsw_init.h"
13
13
14 unsigned int nb_sm_f0;
14 unsigned int nb_sm_f0;
15 unsigned int nb_sm_f0_aux_f1;
15 unsigned int nb_sm_f0_aux_f1;
16 unsigned int nb_sm_f1;
16 unsigned int nb_sm_f1;
17 unsigned int nb_sm_f0_aux_f2;
17 unsigned int nb_sm_f0_aux_f2;
18
18
19 typedef enum restartState_t
19 typedef enum restartState_t
20 {
20 {
21 WAIT_FOR_F2,
21 WAIT_FOR_F2,
22 WAIT_FOR_F1,
22 WAIT_FOR_F1,
23 WAIT_FOR_F0
23 WAIT_FOR_F0
24 } restartState;
24 } restartState;
25
25
26 //************************
26 //************************
27 // spectral matrices rings
27 // spectral matrices rings
28 ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ];
28 ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ];
29 ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ];
29 ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ];
30 ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ];
30 ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ];
31 ring_node *current_ring_node_sm_f0;
31 ring_node *current_ring_node_sm_f0;
32 ring_node *current_ring_node_sm_f1;
32 ring_node *current_ring_node_sm_f1;
33 ring_node *current_ring_node_sm_f2;
33 ring_node *current_ring_node_sm_f2;
34 ring_node *ring_node_for_averaging_sm_f0;
34 ring_node *ring_node_for_averaging_sm_f0;
35 ring_node *ring_node_for_averaging_sm_f1;
35 ring_node *ring_node_for_averaging_sm_f1;
36 ring_node *ring_node_for_averaging_sm_f2;
36 ring_node *ring_node_for_averaging_sm_f2;
37
37
38 //
38 //
39 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel)
39 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel)
40 {
40 {
41 ring_node *node;
41 ring_node *node;
42
42
43 node = NULL;
43 node = NULL;
44 switch ( frequencyChannel ) {
44 switch ( frequencyChannel ) {
45 case 0:
45 case 0:
46 node = ring_node_for_averaging_sm_f0;
46 node = ring_node_for_averaging_sm_f0;
47 break;
47 break;
48 case 1:
48 case 1:
49 node = ring_node_for_averaging_sm_f1;
49 node = ring_node_for_averaging_sm_f1;
50 break;
50 break;
51 case 2:
51 case 2:
52 node = ring_node_for_averaging_sm_f2;
52 node = ring_node_for_averaging_sm_f2;
53 break;
53 break;
54 default:
54 default:
55 break;
55 break;
56 }
56 }
57
57
58 return node;
58 return node;
59 }
59 }
60
60
61 //***********************************************************
61 //***********************************************************
62 // Interrupt Service Routine for spectral matrices processing
62 // Interrupt Service Routine for spectral matrices processing
63
63
64 void spectral_matrices_isr_f0( int statusReg )
64 void spectral_matrices_isr_f0( int statusReg )
65 {
65 {
66 unsigned char status;
66 unsigned char status;
67 rtems_status_code status_code;
67 rtems_status_code status_code;
68 ring_node *full_ring_node;
68 ring_node *full_ring_node;
69
69
70 status = (unsigned char) (statusReg & 0x03); // [0011] get the status_ready_matrix_f0_x bits
70 status = (unsigned char) (statusReg & 0x03); // [0011] get the status_ready_matrix_f0_x bits
71
71
72 switch(status)
72 switch(status)
73 {
73 {
74 case 0:
74 case 0:
75 break;
75 break;
76 case 3:
76 case 3:
77 // UNEXPECTED VALUE
77 // UNEXPECTED VALUE
78 spectral_matrix_regs->status = 0x03; // [0011]
78 spectral_matrix_regs->status = 0x03; // [0011]
79 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
79 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
80 break;
80 break;
81 case 1:
81 case 1:
82 full_ring_node = current_ring_node_sm_f0->previous;
82 full_ring_node = current_ring_node_sm_f0->previous;
83 full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time;
83 full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time;
84 full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time;
84 full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time;
85 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
85 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
86 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
86 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
87 // if there are enough ring nodes ready, wake up an AVFx task
87 // if there are enough ring nodes ready, wake up an AVFx task
88 nb_sm_f0 = nb_sm_f0 + 1;
88 nb_sm_f0 = nb_sm_f0 + 1;
89 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
89 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
90 {
90 {
91 ring_node_for_averaging_sm_f0 = full_ring_node;
91 ring_node_for_averaging_sm_f0 = full_ring_node;
92 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
92 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
93 {
93 {
94 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
94 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
95 }
95 }
96 nb_sm_f0 = 0;
96 nb_sm_f0 = 0;
97 }
97 }
98 spectral_matrix_regs->status = 0x01; // [0000 0001]
98 spectral_matrix_regs->status = 0x01; // [0000 0001]
99 break;
99 break;
100 case 2:
100 case 2:
101 full_ring_node = current_ring_node_sm_f0->previous;
101 full_ring_node = current_ring_node_sm_f0->previous;
102 full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time;
102 full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time;
103 full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time;
103 full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time;
104 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
104 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
105 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
105 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
106 // if there are enough ring nodes ready, wake up an AVFx task
106 // if there are enough ring nodes ready, wake up an AVFx task
107 nb_sm_f0 = nb_sm_f0 + 1;
107 nb_sm_f0 = nb_sm_f0 + 1;
108 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
108 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
109 {
109 {
110 ring_node_for_averaging_sm_f0 = full_ring_node;
110 ring_node_for_averaging_sm_f0 = full_ring_node;
111 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
111 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
112 {
112 {
113 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
113 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
114 }
114 }
115 nb_sm_f0 = 0;
115 nb_sm_f0 = 0;
116 }
116 }
117 spectral_matrix_regs->status = 0x02; // [0000 0010]
117 spectral_matrix_regs->status = 0x02; // [0000 0010]
118 break;
118 break;
119 }
119 }
120 }
120 }
121
121
122 void spectral_matrices_isr_f1( int statusReg )
122 void spectral_matrices_isr_f1( int statusReg )
123 {
123 {
124 rtems_status_code status_code;
124 rtems_status_code status_code;
125 unsigned char status;
125 unsigned char status;
126 ring_node *full_ring_node;
126 ring_node *full_ring_node;
127
127
128 status = (unsigned char) ((statusReg & 0x0c) >> 2); // [1100] get the status_ready_matrix_f1_x bits
128 status = (unsigned char) ((statusReg & 0x0c) >> 2); // [1100] get the status_ready_matrix_f1_x bits
129
129
130 switch(status)
130 switch(status)
131 {
131 {
132 case 0:
132 case 0:
133 break;
133 break;
134 case 3:
134 case 3:
135 // UNEXPECTED VALUE
135 // UNEXPECTED VALUE
136 spectral_matrix_regs->status = 0xc0; // [1100]
136 spectral_matrix_regs->status = 0xc0; // [1100]
137 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
137 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
138 break;
138 break;
139 case 1:
139 case 1:
140 full_ring_node = current_ring_node_sm_f1->previous;
140 full_ring_node = current_ring_node_sm_f1->previous;
141 full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time;
141 full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time;
142 full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time;
142 full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time;
143 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
143 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
144 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
144 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
145 // if there are enough ring nodes ready, wake up an AVFx task
145 // if there are enough ring nodes ready, wake up an AVFx task
146 nb_sm_f1 = nb_sm_f1 + 1;
146 nb_sm_f1 = nb_sm_f1 + 1;
147 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
147 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
148 {
148 {
149 ring_node_for_averaging_sm_f1 = full_ring_node;
149 ring_node_for_averaging_sm_f1 = full_ring_node;
150 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
150 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
151 {
151 {
152 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
152 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
153 }
153 }
154 nb_sm_f1 = 0;
154 nb_sm_f1 = 0;
155 }
155 }
156 spectral_matrix_regs->status = 0x04; // [0000 0100]
156 spectral_matrix_regs->status = 0x04; // [0000 0100]
157 break;
157 break;
158 case 2:
158 case 2:
159 full_ring_node = current_ring_node_sm_f1->previous;
159 full_ring_node = current_ring_node_sm_f1->previous;
160 full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time;
160 full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time;
161 full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time;
161 full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time;
162 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
162 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
163 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
163 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
164 // if there are enough ring nodes ready, wake up an AVFx task
164 // if there are enough ring nodes ready, wake up an AVFx task
165 nb_sm_f1 = nb_sm_f1 + 1;
165 nb_sm_f1 = nb_sm_f1 + 1;
166 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
166 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
167 {
167 {
168 ring_node_for_averaging_sm_f1 = full_ring_node;
168 ring_node_for_averaging_sm_f1 = full_ring_node;
169 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
169 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
170 {
170 {
171 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
171 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
172 }
172 }
173 nb_sm_f1 = 0;
173 nb_sm_f1 = 0;
174 }
174 }
175 spectral_matrix_regs->status = 0x08; // [1000 0000]
175 spectral_matrix_regs->status = 0x08; // [1000 0000]
176 break;
176 break;
177 }
177 }
178 }
178 }
179
179
180 void spectral_matrices_isr_f2( int statusReg )
180 void spectral_matrices_isr_f2( int statusReg )
181 {
181 {
182 unsigned char status;
182 unsigned char status;
183 rtems_status_code status_code;
183 rtems_status_code status_code;
184
184
185 status = (unsigned char) ((statusReg & 0x30) >> 4); // [0011 0000] get the status_ready_matrix_f2_x bits
185 status = (unsigned char) ((statusReg & 0x30) >> 4); // [0011 0000] get the status_ready_matrix_f2_x bits
186
186
187 switch(status)
187 switch(status)
188 {
188 {
189 case 0:
189 case 0:
190 break;
190 break;
191 case 3:
191 case 3:
192 // UNEXPECTED VALUE
192 // UNEXPECTED VALUE
193 spectral_matrix_regs->status = 0x30; // [0011 0000]
193 spectral_matrix_regs->status = 0x30; // [0011 0000]
194 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
194 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
195 break;
195 break;
196 case 1:
196 case 1:
197 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
197 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
198 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
198 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
199 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
199 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
200 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
200 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
201 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
201 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
202 spectral_matrix_regs->status = 0x10; // [0001 0000]
202 spectral_matrix_regs->status = 0x10; // [0001 0000]
203 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
203 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
204 {
204 {
205 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
205 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
206 }
206 }
207 break;
207 break;
208 case 2:
208 case 2:
209 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
209 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
210 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
210 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
211 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
211 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
212 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
212 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
213 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
213 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
214 spectral_matrix_regs->status = 0x20; // [0010 0000]
214 spectral_matrix_regs->status = 0x20; // [0010 0000]
215 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
215 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
216 {
216 {
217 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
217 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
218 }
218 }
219 break;
219 break;
220 }
220 }
221 }
221 }
222
222
223 void spectral_matrix_isr_error_handler( int statusReg )
223 void spectral_matrix_isr_error_handler( int statusReg )
224 {
224 {
225 // STATUS REGISTER
225 // STATUS REGISTER
226 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
226 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
227 // 10 9 8
227 // 10 9 8
228 // buffer_full ** [bad_component_err] ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
228 // buffer_full ** [bad_component_err] ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
229 // 7 6 5 4 3 2 1 0
229 // 7 6 5 4 3 2 1 0
230 // [bad_component_err] not defined in the last version of the VHDL code
230 // [bad_component_err] not defined in the last version of the VHDL code
231
231
232 rtems_status_code status_code;
232 rtems_status_code status_code;
233
233
234 //***************************************************
234 //***************************************************
235 // the ASM status register is copied in the HK packet
235 // the ASM status register is copied in the HK packet
236 housekeeping_packet.hk_lfr_vhdl_aa_sm = (unsigned char) (statusReg & 0x780 >> 7); // [0111 1000 0000]
236 housekeeping_packet.hk_lfr_vhdl_aa_sm = (unsigned char) (statusReg & 0x780 >> 7); // [0111 1000 0000]
237
237
238 if (statusReg & 0x7c0) // [0111 1100 0000]
238 if (statusReg & 0x7c0) // [0111 1100 0000]
239 {
239 {
240 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
240 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
241 }
241 }
242
242
243 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
243 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
244
244
245 }
245 }
246
246
247 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
247 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
248 {
248 {
249 // STATUS REGISTER
249 // STATUS REGISTER
250 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
250 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
251 // 10 9 8
251 // 10 9 8
252 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
252 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
253 // 7 6 5 4 3 2 1 0
253 // 7 6 5 4 3 2 1 0
254
254
255 int statusReg;
255 int statusReg;
256
256
257 static restartState state = WAIT_FOR_F2;
257 static restartState state = WAIT_FOR_F2;
258
258
259 statusReg = spectral_matrix_regs->status;
259 statusReg = spectral_matrix_regs->status;
260
260
261 if (thisIsAnASMRestart == 0)
261 if (thisIsAnASMRestart == 0)
262 { // this is not a restart sequence, process incoming matrices normally
262 { // this is not a restart sequence, process incoming matrices normally
263 spectral_matrices_isr_f0( statusReg );
263 spectral_matrices_isr_f0( statusReg );
264
264
265 spectral_matrices_isr_f1( statusReg );
265 spectral_matrices_isr_f1( statusReg );
266
266
267 spectral_matrices_isr_f2( statusReg );
267 spectral_matrices_isr_f2( statusReg );
268 }
268 }
269 else
269 else
270 { // a restart sequence has to be launched
270 { // a restart sequence has to be launched
271 switch (state) {
271 switch (state) {
272 case WAIT_FOR_F2:
272 case WAIT_FOR_F2:
273 if ((statusReg & 0x30) != 0x00) // [0011 0000] check the status_ready_matrix_f2_x bits
273 if ((statusReg & 0x30) != 0x00) // [0011 0000] check the status_ready_matrix_f2_x bits
274 {
274 {
275 state = WAIT_FOR_F1;
275 state = WAIT_FOR_F1;
276 }
276 }
277 break;
277 break;
278 case WAIT_FOR_F1:
278 case WAIT_FOR_F1:
279 if ((statusReg & 0x0c) != 0x00) // [0000 1100] check the status_ready_matrix_f1_x bits
279 if ((statusReg & 0x0c) != 0x00) // [0000 1100] check the status_ready_matrix_f1_x bits
280 {
280 {
281 state = WAIT_FOR_F0;
281 state = WAIT_FOR_F0;
282 }
282 }
283 break;
283 break;
284 case WAIT_FOR_F0:
284 case WAIT_FOR_F0:
285 if ((statusReg & 0x03) != 0x00) // [0000 0011] check the status_ready_matrix_f0_x bits
285 if ((statusReg & 0x03) != 0x00) // [0000 0011] check the status_ready_matrix_f0_x bits
286 {
286 {
287 state = WAIT_FOR_F2;
287 state = WAIT_FOR_F2;
288 thisIsAnASMRestart = 0;
288 thisIsAnASMRestart = 0;
289 }
289 }
290 break;
290 break;
291 default:
291 default:
292 break;
292 break;
293 }
293 }
294 reset_sm_status();
294 reset_sm_status();
295 }
295 }
296
296
297 spectral_matrix_isr_error_handler( statusReg );
297 spectral_matrix_isr_error_handler( statusReg );
298
298
299 }
299 }
300
300
301 //******************
301 //******************
302 // Spectral Matrices
302 // Spectral Matrices
303
303
304 void reset_nb_sm( void )
304 void reset_nb_sm( void )
305 {
305 {
306 nb_sm_f0 = 0;
306 nb_sm_f0 = 0;
307 nb_sm_f0_aux_f1 = 0;
307 nb_sm_f0_aux_f1 = 0;
308 nb_sm_f0_aux_f2 = 0;
308 nb_sm_f0_aux_f2 = 0;
309
309
310 nb_sm_f1 = 0;
310 nb_sm_f1 = 0;
311 }
311 }
312
312
313 void SM_init_rings( void )
313 void SM_init_rings( void )
314 {
314 {
315 init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM );
315 init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM );
316 init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM );
316 init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM );
317 init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM );
317 init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM );
318
318
319 DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
319 DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
320 DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
320 DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
321 DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
321 DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
322 DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0)
322 DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0)
323 DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1)
323 DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1)
324 DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2)
324 DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2)
325 }
325 }
326
326
327 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
327 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
328 {
328 {
329 unsigned char i;
329 unsigned char i;
330
330
331 ring[ nbNodes - 1 ].next
331 ring[ nbNodes - 1 ].next
332 = (ring_node_asm*) &ring[ 0 ];
332 = (ring_node_asm*) &ring[ 0 ];
333
333
334 for(i=0; i<nbNodes-1; i++)
334 for(i=0; i<nbNodes-1; i++)
335 {
335 {
336 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
336 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
337 }
337 }
338 }
338 }
339
339
340 void SM_reset_current_ring_nodes( void )
340 void SM_reset_current_ring_nodes( void )
341 {
341 {
342 current_ring_node_sm_f0 = sm_ring_f0[0].next;
342 current_ring_node_sm_f0 = sm_ring_f0[0].next;
343 current_ring_node_sm_f1 = sm_ring_f1[0].next;
343 current_ring_node_sm_f1 = sm_ring_f1[0].next;
344 current_ring_node_sm_f2 = sm_ring_f2[0].next;
344 current_ring_node_sm_f2 = sm_ring_f2[0].next;
345
345
346 ring_node_for_averaging_sm_f0 = NULL;
346 ring_node_for_averaging_sm_f0 = NULL;
347 ring_node_for_averaging_sm_f1 = NULL;
347 ring_node_for_averaging_sm_f1 = NULL;
348 ring_node_for_averaging_sm_f2 = NULL;
348 ring_node_for_averaging_sm_f2 = NULL;
349 }
349 }
350
350
351 //*****************
351 //*****************
352 // Basic Parameters
352 // Basic Parameters
353
353
354 void BP_init_header( bp_packet *packet,
354 void BP_init_header( bp_packet *packet,
355 unsigned int apid, unsigned char sid,
355 unsigned int apid, unsigned char sid,
356 unsigned int packetLength, unsigned char blkNr )
356 unsigned int packetLength, unsigned char blkNr )
357 {
357 {
358 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
358 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
359 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
359 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
360 packet->reserved = 0x00;
360 packet->reserved = 0x00;
361 packet->userApplication = CCSDS_USER_APP;
361 packet->userApplication = CCSDS_USER_APP;
362 packet->packetID[0] = (unsigned char) (apid >> 8);
362 packet->packetID[0] = (unsigned char) (apid >> 8);
363 packet->packetID[1] = (unsigned char) (apid);
363 packet->packetID[1] = (unsigned char) (apid);
364 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
364 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
365 packet->packetSequenceControl[1] = 0x00;
365 packet->packetSequenceControl[1] = 0x00;
366 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
366 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
367 packet->packetLength[1] = (unsigned char) (packetLength);
367 packet->packetLength[1] = (unsigned char) (packetLength);
368 // DATA FIELD HEADER
368 // DATA FIELD HEADER
369 packet->spare1_pusVersion_spare2 = 0x10;
369 packet->spare1_pusVersion_spare2 = 0x10;
370 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
370 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
371 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
371 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
372 packet->destinationID = TM_DESTINATION_ID_GROUND;
372 packet->destinationID = TM_DESTINATION_ID_GROUND;
373 packet->time[0] = 0x00;
373 packet->time[0] = 0x00;
374 packet->time[1] = 0x00;
374 packet->time[1] = 0x00;
375 packet->time[2] = 0x00;
375 packet->time[2] = 0x00;
376 packet->time[3] = 0x00;
376 packet->time[3] = 0x00;
377 packet->time[4] = 0x00;
377 packet->time[4] = 0x00;
378 packet->time[5] = 0x00;
378 packet->time[5] = 0x00;
379 // AUXILIARY DATA HEADER
379 // AUXILIARY DATA HEADER
380 packet->sid = sid;
380 packet->sid = sid;
381 packet->pa_bia_status_info = 0x00;
381 packet->pa_bia_status_info = 0x00;
382 packet->sy_lfr_common_parameters_spare = 0x00;
382 packet->sy_lfr_common_parameters_spare = 0x00;
383 packet->sy_lfr_common_parameters = 0x00;
383 packet->sy_lfr_common_parameters = 0x00;
384 packet->acquisitionTime[0] = 0x00;
384 packet->acquisitionTime[0] = 0x00;
385 packet->acquisitionTime[1] = 0x00;
385 packet->acquisitionTime[1] = 0x00;
386 packet->acquisitionTime[2] = 0x00;
386 packet->acquisitionTime[2] = 0x00;
387 packet->acquisitionTime[3] = 0x00;
387 packet->acquisitionTime[3] = 0x00;
388 packet->acquisitionTime[4] = 0x00;
388 packet->acquisitionTime[4] = 0x00;
389 packet->acquisitionTime[5] = 0x00;
389 packet->acquisitionTime[5] = 0x00;
390 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
390 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
391 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
391 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
392 }
392 }
393
393
394 void BP_init_header_with_spare( bp_packet_with_spare *packet,
394 void BP_init_header_with_spare( bp_packet_with_spare *packet,
395 unsigned int apid, unsigned char sid,
395 unsigned int apid, unsigned char sid,
396 unsigned int packetLength , unsigned char blkNr)
396 unsigned int packetLength , unsigned char blkNr)
397 {
397 {
398 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
398 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
399 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
399 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
400 packet->reserved = 0x00;
400 packet->reserved = 0x00;
401 packet->userApplication = CCSDS_USER_APP;
401 packet->userApplication = CCSDS_USER_APP;
402 packet->packetID[0] = (unsigned char) (apid >> 8);
402 packet->packetID[0] = (unsigned char) (apid >> 8);
403 packet->packetID[1] = (unsigned char) (apid);
403 packet->packetID[1] = (unsigned char) (apid);
404 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
404 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
405 packet->packetSequenceControl[1] = 0x00;
405 packet->packetSequenceControl[1] = 0x00;
406 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
406 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
407 packet->packetLength[1] = (unsigned char) (packetLength);
407 packet->packetLength[1] = (unsigned char) (packetLength);
408 // DATA FIELD HEADER
408 // DATA FIELD HEADER
409 packet->spare1_pusVersion_spare2 = 0x10;
409 packet->spare1_pusVersion_spare2 = 0x10;
410 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
410 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
411 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
411 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
412 packet->destinationID = TM_DESTINATION_ID_GROUND;
412 packet->destinationID = TM_DESTINATION_ID_GROUND;
413 // AUXILIARY DATA HEADER
413 // AUXILIARY DATA HEADER
414 packet->sid = sid;
414 packet->sid = sid;
415 packet->pa_bia_status_info = 0x00;
415 packet->pa_bia_status_info = 0x00;
416 packet->sy_lfr_common_parameters_spare = 0x00;
416 packet->sy_lfr_common_parameters_spare = 0x00;
417 packet->sy_lfr_common_parameters = 0x00;
417 packet->sy_lfr_common_parameters = 0x00;
418 packet->time[0] = 0x00;
418 packet->time[0] = 0x00;
419 packet->time[0] = 0x00;
419 packet->time[0] = 0x00;
420 packet->time[0] = 0x00;
420 packet->time[0] = 0x00;
421 packet->time[0] = 0x00;
421 packet->time[0] = 0x00;
422 packet->time[0] = 0x00;
422 packet->time[0] = 0x00;
423 packet->time[0] = 0x00;
423 packet->time[0] = 0x00;
424 packet->source_data_spare = 0x00;
424 packet->source_data_spare = 0x00;
425 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
425 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
426 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
426 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
427 }
427 }
428
428
429 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
429 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
430 {
430 {
431 rtems_status_code status;
431 rtems_status_code status;
432
432
433 // SEND PACKET
433 // SEND PACKET
434 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
434 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
435 if (status != RTEMS_SUCCESSFUL)
435 if (status != RTEMS_SUCCESSFUL)
436 {
436 {
437 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
437 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
438 }
438 }
439 }
439 }
440
440
441 void BP_send_s1_s2(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
441 void BP_send_s1_s2(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
442 {
442 {
443 /** This function is used to send the BP paquets when needed.
443 /** This function is used to send the BP paquets when needed.
444 *
444 *
445 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
445 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
446 *
446 *
447 * @return void
447 * @return void
448 *
448 *
449 * SBM1 and SBM2 paquets are sent depending on the type of the LFR mode transition.
449 * SBM1 and SBM2 paquets are sent depending on the type of the LFR mode transition.
450 * BURST paquets are sent everytime.
450 * BURST paquets are sent everytime.
451 *
451 *
452 */
452 */
453
453
454 rtems_status_code status;
454 rtems_status_code status;
455
455
456 // SEND PACKET
456 // SEND PACKET
457 // before lastValidTransitionDate, the data are drops even if they are ready
457 // before lastValidTransitionDate, the data are drops even if they are ready
458 // this guarantees that no SBM packets will be received before the requested enter mode time
458 // this guarantees that no SBM packets will be received before the requested enter mode time
459 if ( time_management_regs->coarse_time >= lastValidEnterModeTime)
459 if ( time_management_regs->coarse_time >= lastValidEnterModeTime)
460 {
460 {
461 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
461 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
462 if (status != RTEMS_SUCCESSFUL)
462 if (status != RTEMS_SUCCESSFUL)
463 {
463 {
464 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
464 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
465 }
465 }
466 }
466 }
467 }
467 }
468
468
469 //******************
469 //******************
470 // general functions
470 // general functions
471
471
472 void reset_sm_status( void )
472 void reset_sm_status( void )
473 {
473 {
474 // error
474 // error
475 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
475 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
476 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
476 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
477 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
477 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
478 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
478 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
479
479
480 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
480 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
481 }
481 }
482
482
483 void reset_spectral_matrix_regs( void )
483 void reset_spectral_matrix_regs( void )
484 {
484 {
485 /** This function resets the spectral matrices module registers.
485 /** This function resets the spectral matrices module registers.
486 *
486 *
487 * The registers affected by this function are located at the following offset addresses:
487 * The registers affected by this function are located at the following offset addresses:
488 *
488 *
489 * - 0x00 config
489 * - 0x00 config
490 * - 0x04 status
490 * - 0x04 status
491 * - 0x08 matrixF0_Address0
491 * - 0x08 matrixF0_Address0
492 * - 0x10 matrixFO_Address1
492 * - 0x10 matrixFO_Address1
493 * - 0x14 matrixF1_Address
493 * - 0x14 matrixF1_Address
494 * - 0x18 matrixF2_Address
494 * - 0x18 matrixF2_Address
495 *
495 *
496 */
496 */
497
497
498 set_sm_irq_onError( 0 );
498 set_sm_irq_onError( 0 );
499
499
500 set_sm_irq_onNewMatrix( 0 );
500 set_sm_irq_onNewMatrix( 0 );
501
501
502 reset_sm_status();
502 reset_sm_status();
503
503
504 // F1
504 // F1
505 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
505 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
506 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
506 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
507 // F2
507 // F2
508 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
508 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
509 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
509 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
510 // F3
510 // F3
511 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
511 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
512 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
512 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
513
513
514 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
514 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
515 }
515 }
516
516
517 void set_time( unsigned char *time, unsigned char * timeInBuffer )
517 void set_time( unsigned char *time, unsigned char * timeInBuffer )
518 {
518 {
519 time[0] = timeInBuffer[0];
519 time[0] = timeInBuffer[0];
520 time[1] = timeInBuffer[1];
520 time[1] = timeInBuffer[1];
521 time[2] = timeInBuffer[2];
521 time[2] = timeInBuffer[2];
522 time[3] = timeInBuffer[3];
522 time[3] = timeInBuffer[3];
523 time[4] = timeInBuffer[6];
523 time[4] = timeInBuffer[6];
524 time[5] = timeInBuffer[7];
524 time[5] = timeInBuffer[7];
525 }
525 }
526
526
527 unsigned long long int get_acquisition_time( unsigned char *timePtr )
527 unsigned long long int get_acquisition_time( unsigned char *timePtr )
528 {
528 {
529 unsigned long long int acquisitionTimeAslong;
529 unsigned long long int acquisitionTimeAslong;
530 acquisitionTimeAslong = 0x00;
530 acquisitionTimeAslong = 0x00;
531 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
531 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
532 + ( (unsigned long long int) timePtr[1] << 32 )
532 + ( (unsigned long long int) timePtr[1] << 32 )
533 + ( (unsigned long long int) timePtr[2] << 24 )
533 + ( (unsigned long long int) timePtr[2] << 24 )
534 + ( (unsigned long long int) timePtr[3] << 16 )
534 + ( (unsigned long long int) timePtr[3] << 16 )
535 + ( (unsigned long long int) timePtr[6] << 8 )
535 + ( (unsigned long long int) timePtr[6] << 8 )
536 + ( (unsigned long long int) timePtr[7] );
536 + ( (unsigned long long int) timePtr[7] );
537 return acquisitionTimeAslong;
537 return acquisitionTimeAslong;
538 }
538 }
539
539
540 unsigned char getSID( rtems_event_set event )
540 unsigned char getSID( rtems_event_set event )
541 {
541 {
542 unsigned char sid;
542 unsigned char sid;
543
543
544 rtems_event_set eventSetBURST;
544 rtems_event_set eventSetBURST;
545 rtems_event_set eventSetSBM;
545 rtems_event_set eventSetSBM;
546
546
547 //******
547 //******
548 // BURST
548 // BURST
549 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
549 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
550 | RTEMS_EVENT_BURST_BP1_F1
550 | RTEMS_EVENT_BURST_BP1_F1
551 | RTEMS_EVENT_BURST_BP2_F0
551 | RTEMS_EVENT_BURST_BP2_F0
552 | RTEMS_EVENT_BURST_BP2_F1;
552 | RTEMS_EVENT_BURST_BP2_F1;
553
553
554 //****
554 //****
555 // SBM
555 // SBM
556 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
556 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
557 | RTEMS_EVENT_SBM_BP1_F1
557 | RTEMS_EVENT_SBM_BP1_F1
558 | RTEMS_EVENT_SBM_BP2_F0
558 | RTEMS_EVENT_SBM_BP2_F0
559 | RTEMS_EVENT_SBM_BP2_F1;
559 | RTEMS_EVENT_SBM_BP2_F1;
560
560
561 if (event & eventSetBURST)
561 if (event & eventSetBURST)
562 {
562 {
563 sid = SID_BURST_BP1_F0;
563 sid = SID_BURST_BP1_F0;
564 }
564 }
565 else if (event & eventSetSBM)
565 else if (event & eventSetSBM)
566 {
566 {
567 sid = SID_SBM1_BP1_F0;
567 sid = SID_SBM1_BP1_F0;
568 }
568 }
569 else
569 else
570 {
570 {
571 sid = 0;
571 sid = 0;
572 }
572 }
573
573
574 return sid;
574 return sid;
575 }
575 }
576
576
577 void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
577 void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
578 {
578 {
579 unsigned int i;
579 unsigned int i;
580 float re;
580 float re;
581 float im;
581 float im;
582
582
583 for (i=0; i<NB_BINS_PER_SM; i++){
583 for (i=0; i<NB_BINS_PER_SM; i++){
584 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ];
584 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ];
585 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1];
585 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1];
586 outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re;
586 outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re;
587 outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im;
587 outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im;
588 }
588 }
589 }
589 }
590
590
591 void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
591 void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
592 {
592 {
593 unsigned int i;
593 unsigned int i;
594 float re;
594 float re;
595
595
596 for (i=0; i<NB_BINS_PER_SM; i++){
596 for (i=0; i<NB_BINS_PER_SM; i++){
597 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i];
597 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i];
598 outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re;
598 outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re;
599 }
599 }
600 }
600 }
601
601
602 void ASM_patch( float *inputASM, float *outputASM )
602 void ASM_patch( float *inputASM, float *outputASM )
603 {
603 {
604 extractReImVectors( inputASM, outputASM, 1); // b1b2
604 extractReImVectors( inputASM, outputASM, 1); // b1b2
605 extractReImVectors( inputASM, outputASM, 3 ); // b1b3
605 extractReImVectors( inputASM, outputASM, 3 ); // b1b3
606 extractReImVectors( inputASM, outputASM, 5 ); // b1e1
606 extractReImVectors( inputASM, outputASM, 5 ); // b1e1
607 extractReImVectors( inputASM, outputASM, 7 ); // b1e2
607 extractReImVectors( inputASM, outputASM, 7 ); // b1e2
608 extractReImVectors( inputASM, outputASM, 10 ); // b2b3
608 extractReImVectors( inputASM, outputASM, 10 ); // b2b3
609 extractReImVectors( inputASM, outputASM, 12 ); // b2e1
609 extractReImVectors( inputASM, outputASM, 12 ); // b2e1
610 extractReImVectors( inputASM, outputASM, 14 ); // b2e2
610 extractReImVectors( inputASM, outputASM, 14 ); // b2e2
611 extractReImVectors( inputASM, outputASM, 17 ); // b3e1
611 extractReImVectors( inputASM, outputASM, 17 ); // b3e1
612 extractReImVectors( inputASM, outputASM, 19 ); // b3e2
612 extractReImVectors( inputASM, outputASM, 19 ); // b3e2
613 extractReImVectors( inputASM, outputASM, 22 ); // e1e2
613 extractReImVectors( inputASM, outputASM, 22 ); // e1e2
614
614
615 copyReVectors(inputASM, outputASM, 0 ); // b1b1
615 copyReVectors(inputASM, outputASM, 0 ); // b1b1
616 copyReVectors(inputASM, outputASM, 9 ); // b2b2
616 copyReVectors(inputASM, outputASM, 9 ); // b2b2
617 copyReVectors(inputASM, outputASM, 16); // b3b3
617 copyReVectors(inputASM, outputASM, 16); // b3b3
618 copyReVectors(inputASM, outputASM, 21); // e1e1
618 copyReVectors(inputASM, outputASM, 21); // e1e1
619 copyReVectors(inputASM, outputASM, 24); // e2e2
619 copyReVectors(inputASM, outputASM, 24); // e2e2
620 }
620 }
621
621
622 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
622 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
623 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage,
623 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage,
624 unsigned char ASMIndexStart,
624 unsigned char ASMIndexStart,
625 unsigned char channel )
625 unsigned char channel )
626 {
626 {
627 //*************
627 //*************
628 // input format
628 // input format
629 // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127]
629 // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127]
630 //**************
630 //**************
631 // output format
631 // output format
632 // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24]
632 // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24]
633 //************
633 //************
634 // compression
634 // compression
635 // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM
635 // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM
636 // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM
636 // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM
637
637
638 int frequencyBin;
638 int frequencyBin;
639 int asmComponent;
639 int asmComponent;
640 int offsetASM;
640 int offsetASM;
641 int offsetCompressed;
641 int offsetCompressed;
642 int offsetFBin;
642 int offsetFBin;
643 int fBinMask;
643 int fBinMask;
644 int k;
644 int k;
645
645
646 // BUILD DATA
646 // BUILD DATA
647 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
647 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
648 {
648 {
649 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
649 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
650 {
650 {
651 offsetCompressed = // NO TIME OFFSET
651 offsetCompressed = // NO TIME OFFSET
652 frequencyBin * NB_VALUES_PER_SM
652 frequencyBin * NB_VALUES_PER_SM
653 + asmComponent;
653 + asmComponent;
654 offsetASM = // NO TIME OFFSET
654 offsetASM = // NO TIME OFFSET
655 asmComponent * NB_BINS_PER_SM
655 asmComponent * NB_BINS_PER_SM
656 + ASMIndexStart
656 + ASMIndexStart
657 + frequencyBin * nbBinsToAverage;
657 + frequencyBin * nbBinsToAverage;
658 offsetFBin = ASMIndexStart
658 offsetFBin = ASMIndexStart
659 + frequencyBin * nbBinsToAverage;
659 + frequencyBin * nbBinsToAverage;
660 compressed_spec_mat[ offsetCompressed ] = 0;
660 compressed_spec_mat[ offsetCompressed ] = 0;
661 for ( k = 0; k < nbBinsToAverage; k++ )
661 for ( k = 0; k < nbBinsToAverage; k++ )
662 {
662 {
663 fBinMask = getFBinMask( offsetFBin + k, channel );
663 fBinMask = getFBinMask( offsetFBin + k, channel );
664 compressed_spec_mat[offsetCompressed ] =
664 compressed_spec_mat[offsetCompressed ] =
665 ( compressed_spec_mat[ offsetCompressed ]
665 ( compressed_spec_mat[ offsetCompressed ]
666 + averaged_spec_mat[ offsetASM + k ] * fBinMask );
666 + averaged_spec_mat[ offsetASM + k ] * fBinMask );
667 }
667 }
668 compressed_spec_mat[ offsetCompressed ] =
668 compressed_spec_mat[ offsetCompressed ] =
669 (divider != 0.) ? compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage) : 0.0;
669 (divider != 0.) ? compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage) : 0.0;
670 }
670 }
671 }
671 }
672
672
673 }
673 }
674
674
675 int getFBinMask( int index, unsigned char channel )
675 int getFBinMask( int index, unsigned char channel )
676 {
676 {
677 unsigned int indexInChar;
677 unsigned int indexInChar;
678 unsigned int indexInTheChar;
678 unsigned int indexInTheChar;
679 int fbin;
679 int fbin;
680 unsigned char *sy_lfr_fbins_fx_word1;
680 unsigned char *sy_lfr_fbins_fx_word1;
681
681
682 sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
682 sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins.fx.f0_word1;
683
683
684 switch(channel)
684 switch(channel)
685 {
685 {
686 case 0:
686 case 0:
687 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f0;
687 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f0;
688 break;
688 break;
689 case 1:
689 case 1:
690 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f1;
690 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f1;
691 break;
691 break;
692 case 2:
692 case 2:
693 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f2;
693 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f2;
694 break;
694 break;
695 default:
695 default:
696 PRINTF("ERR *** in getFBinMask, wrong frequency channel")
696 PRINTF("ERR *** in getFBinMask, wrong frequency channel")
697 }
697 }
698
698
699 indexInChar = index >> 3;
699 indexInChar = index >> 3;
700 indexInTheChar = index - indexInChar * 8;
700 indexInTheChar = index - indexInChar * 8;
701
701
702 fbin = (int) ((sy_lfr_fbins_fx_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1);
702 fbin = (int) ((sy_lfr_fbins_fx_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1);
703
703
704 return fbin;
704 return fbin;
705 }
705 }
706
706
707 unsigned char acquisitionTimeIsValid( unsigned int coarseTime, unsigned int fineTime, unsigned char channel)
707 unsigned char acquisitionTimeIsValid( unsigned int coarseTime, unsigned int fineTime, unsigned char channel)
708 {
708 {
709 u_int64_t acquisitionTime;
709 u_int64_t acquisitionTime;
710 u_int64_t timecodeReference;
710 u_int64_t timecodeReference;
711 u_int64_t offsetInFineTime;
711 u_int64_t offsetInFineTime;
712 u_int64_t shiftInFineTime;
712 u_int64_t shiftInFineTime;
713 u_int64_t tBadInFineTime;
713 u_int64_t tBadInFineTime;
714 u_int64_t acquisitionTimeRangeMin;
714 u_int64_t acquisitionTimeRangeMin;
715 u_int64_t acquisitionTimeRangeMax;
715 u_int64_t acquisitionTimeRangeMax;
716 unsigned char pasFilteringIsEnabled;
716 unsigned char pasFilteringIsEnabled;
717 unsigned char ret;
717 unsigned char ret;
718
718
719 pasFilteringIsEnabled = (filterPar.spare_sy_lfr_pas_filter_enabled & 0x01); // [0000 0001]
719 pasFilteringIsEnabled = (filterPar.spare_sy_lfr_pas_filter_enabled & 0x01); // [0000 0001]
720 ret = 1;
720 ret = 1;
721
721
722 // compute acquisition time from caoarseTime and fineTime
722 // compute acquisition time from caoarseTime and fineTime
723 acquisitionTime = ( ((u_int64_t)coarseTime) << 16 )
723 acquisitionTime = ( ((u_int64_t)coarseTime) << 16 )
724 + (u_int64_t) fineTime;
724 + (u_int64_t) fineTime;
725
725
726 // compute the timecode reference
726 // compute the timecode reference
727 timecodeReference = (u_int64_t) (floor( ((double) coarseTime) / ((double) filterPar.sy_lfr_pas_filter_modulus) )
727 timecodeReference = (u_int64_t) (floor( ((double) coarseTime) / ((double) filterPar.sy_lfr_pas_filter_modulus) )
728 * ((double) filterPar.sy_lfr_pas_filter_modulus)) * 65536;
728 * ((double) filterPar.sy_lfr_pas_filter_modulus)) * 65536;
729
729
730 // compute the acquitionTime range
730 // compute the acquitionTime range
731 offsetInFineTime = ((double) filterPar.sy_lfr_pas_filter_offset) * 65536;
731 offsetInFineTime = ((double) filterPar.sy_lfr_pas_filter_offset) * 65536;
732 shiftInFineTime = ((double) filterPar.sy_lfr_pas_filter_shift) * 65536;
732 shiftInFineTime = ((double) filterPar.sy_lfr_pas_filter_shift) * 65536;
733 tBadInFineTime = ((double) filterPar.sy_lfr_pas_filter_tbad) * 65536;
733 tBadInFineTime = ((double) filterPar.sy_lfr_pas_filter_tbad) * 65536;
734
734
735 acquisitionTimeRangeMin =
735 acquisitionTimeRangeMin =
736 timecodeReference
736 timecodeReference
737 + offsetInFineTime
737 + offsetInFineTime
738 + shiftInFineTime
738 + shiftInFineTime
739 - acquisitionDurations[channel];
739 - acquisitionDurations[channel];
740 acquisitionTimeRangeMax =
740 acquisitionTimeRangeMax =
741 timecodeReference
741 timecodeReference
742 + offsetInFineTime
742 + offsetInFineTime
743 + shiftInFineTime
743 + shiftInFineTime
744 + tBadInFineTime;
744 + tBadInFineTime;
745
745
746 if ( (acquisitionTime >= acquisitionTimeRangeMin)
746 if ( (acquisitionTime >= acquisitionTimeRangeMin)
747 && (acquisitionTime <= acquisitionTimeRangeMax)
747 && (acquisitionTime <= acquisitionTimeRangeMax)
748 && (pasFilteringIsEnabled == 1) )
748 && (pasFilteringIsEnabled == 1) )
749 {
749 {
750 ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored
750 ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored
751 }
751 }
752 else
752 else
753 {
753 {
754 ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging
754 ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging
755 }
755 }
756
756
757 // printf("coarseTime = %x, fineTime = %x\n",
757 // printf("coarseTime = %x, fineTime = %x\n",
758 // coarseTime,
758 // coarseTime,
759 // fineTime);
759 // fineTime);
760
760
761 // printf("[ret = %d] *** acquisitionTime = %f, Reference = %f",
761 // printf("[ret = %d] *** acquisitionTime = %f, Reference = %f",
762 // ret,
762 // ret,
763 // acquisitionTime / 65536.,
763 // acquisitionTime / 65536.,
764 // timecodeReference / 65536.);
764 // timecodeReference / 65536.);
765
765
766 // printf(", Min = %f, Max = %f\n",
766 // printf(", Min = %f, Max = %f\n",
767 // acquisitionTimeRangeMin / 65536.,
767 // acquisitionTimeRangeMin / 65536.,
768 // acquisitionTimeRangeMax / 65536.);
768 // acquisitionTimeRangeMax / 65536.);
769
769
770 return ret;
770 return ret;
771 }
771 }
772
772
773 void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm)
773 void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm)
774 {
774 {
775 unsigned char bin;
775 unsigned char bin;
776 unsigned char kcoeff;
776 unsigned char kcoeff;
777
777
778 for (bin=0; bin<nb_bins_norm; bin++)
778 for (bin=0; bin<nb_bins_norm; bin++)
779 {
779 {
780 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
780 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
781 {
781 {
782 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
782 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
783 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
783 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
784 }
784 }
785 }
785 }
786 }
786 }
@@ -1,1628 +1,1619
1 /** Functions to load and dump parameters in the LFR registers.
1 /** Functions to load and dump parameters in the LFR registers.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TC related to parameter loading and dumping.\n
6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 * TC_LFR_LOAD_COMMON_PAR\n
7 * TC_LFR_LOAD_COMMON_PAR\n
8 * TC_LFR_LOAD_NORMAL_PAR\n
8 * TC_LFR_LOAD_NORMAL_PAR\n
9 * TC_LFR_LOAD_BURST_PAR\n
9 * TC_LFR_LOAD_BURST_PAR\n
10 * TC_LFR_LOAD_SBM1_PAR\n
10 * TC_LFR_LOAD_SBM1_PAR\n
11 * TC_LFR_LOAD_SBM2_PAR\n
11 * TC_LFR_LOAD_SBM2_PAR\n
12 *
12 *
13 */
13 */
14
14
15 #include "tc_load_dump_parameters.h"
15 #include "tc_load_dump_parameters.h"
16
16
17 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1;
17 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1;
18 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2;
18 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2;
19 ring_node kcoefficient_node_1;
19 ring_node kcoefficient_node_1;
20 ring_node kcoefficient_node_2;
20 ring_node kcoefficient_node_2;
21
21
22 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
22 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
23 {
23 {
24 /** This function updates the LFR registers with the incoming common parameters.
24 /** This function updates the LFR registers with the incoming common parameters.
25 *
25 *
26 * @param TC points to the TeleCommand packet that is being processed
26 * @param TC points to the TeleCommand packet that is being processed
27 *
27 *
28 *
28 *
29 */
29 */
30
30
31 parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0];
31 parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0];
32 parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1];
32 parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1];
33 set_wfp_data_shaping( );
33 set_wfp_data_shaping( );
34 return LFR_SUCCESSFUL;
34 return LFR_SUCCESSFUL;
35 }
35 }
36
36
37 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
37 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
38 {
38 {
39 /** This function updates the LFR registers with the incoming normal parameters.
39 /** This function updates the LFR registers with the incoming normal parameters.
40 *
40 *
41 * @param TC points to the TeleCommand packet that is being processed
41 * @param TC points to the TeleCommand packet that is being processed
42 * @param queue_id is the id of the queue which handles TM related to this execution step
42 * @param queue_id is the id of the queue which handles TM related to this execution step
43 *
43 *
44 */
44 */
45
45
46 int result;
46 int result;
47 int flag;
47 int flag;
48 rtems_status_code status;
48 rtems_status_code status;
49
49
50 flag = LFR_SUCCESSFUL;
50 flag = LFR_SUCCESSFUL;
51
51
52 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
52 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
53 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
53 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
54 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
54 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
55 flag = LFR_DEFAULT;
55 flag = LFR_DEFAULT;
56 }
56 }
57
57
58 // CHECK THE PARAMETERS SET CONSISTENCY
58 // CHECK THE PARAMETERS SET CONSISTENCY
59 if (flag == LFR_SUCCESSFUL)
59 if (flag == LFR_SUCCESSFUL)
60 {
60 {
61 flag = check_normal_par_consistency( TC, queue_id );
61 flag = check_normal_par_consistency( TC, queue_id );
62 }
62 }
63
63
64 // SET THE PARAMETERS IF THEY ARE CONSISTENT
64 // SET THE PARAMETERS IF THEY ARE CONSISTENT
65 if (flag == LFR_SUCCESSFUL)
65 if (flag == LFR_SUCCESSFUL)
66 {
66 {
67 result = set_sy_lfr_n_swf_l( TC );
67 result = set_sy_lfr_n_swf_l( TC );
68 result = set_sy_lfr_n_swf_p( TC );
68 result = set_sy_lfr_n_swf_p( TC );
69 result = set_sy_lfr_n_bp_p0( TC );
69 result = set_sy_lfr_n_bp_p0( TC );
70 result = set_sy_lfr_n_bp_p1( TC );
70 result = set_sy_lfr_n_bp_p1( TC );
71 result = set_sy_lfr_n_asm_p( TC );
71 result = set_sy_lfr_n_asm_p( TC );
72 result = set_sy_lfr_n_cwf_long_f3( TC );
72 result = set_sy_lfr_n_cwf_long_f3( TC );
73 }
73 }
74
74
75 return flag;
75 return flag;
76 }
76 }
77
77
78 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
78 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
79 {
79 {
80 /** This function updates the LFR registers with the incoming burst parameters.
80 /** This function updates the LFR registers with the incoming burst parameters.
81 *
81 *
82 * @param TC points to the TeleCommand packet that is being processed
82 * @param TC points to the TeleCommand packet that is being processed
83 * @param queue_id is the id of the queue which handles TM related to this execution step
83 * @param queue_id is the id of the queue which handles TM related to this execution step
84 *
84 *
85 */
85 */
86
86
87 int flag;
87 int flag;
88 rtems_status_code status;
88 rtems_status_code status;
89 unsigned char sy_lfr_b_bp_p0;
89 unsigned char sy_lfr_b_bp_p0;
90 unsigned char sy_lfr_b_bp_p1;
90 unsigned char sy_lfr_b_bp_p1;
91 float aux;
91 float aux;
92
92
93 flag = LFR_SUCCESSFUL;
93 flag = LFR_SUCCESSFUL;
94
94
95 if ( lfrCurrentMode == LFR_MODE_BURST ) {
95 if ( lfrCurrentMode == LFR_MODE_BURST ) {
96 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
96 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
97 flag = LFR_DEFAULT;
97 flag = LFR_DEFAULT;
98 }
98 }
99
99
100 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
100 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
101 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
101 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
102
102
103 // sy_lfr_b_bp_p0 shall not be lower than its default value
103 // sy_lfr_b_bp_p0 shall not be lower than its default value
104 if (flag == LFR_SUCCESSFUL)
104 if (flag == LFR_SUCCESSFUL)
105 {
105 {
106 if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 )
106 if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 )
107 {
107 {
108 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
108 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
109 flag = WRONG_APP_DATA;
109 flag = WRONG_APP_DATA;
110 }
110 }
111 }
111 }
112 // sy_lfr_b_bp_p1 shall not be lower than its default value
112 // sy_lfr_b_bp_p1 shall not be lower than its default value
113 if (flag == LFR_SUCCESSFUL)
113 if (flag == LFR_SUCCESSFUL)
114 {
114 {
115 if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 )
115 if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 )
116 {
116 {
117 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 );
117 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 );
118 flag = WRONG_APP_DATA;
118 flag = WRONG_APP_DATA;
119 }
119 }
120 }
120 }
121 //****************************************************************
121 //****************************************************************
122 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
122 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
123 if (flag == LFR_SUCCESSFUL)
123 if (flag == LFR_SUCCESSFUL)
124 {
124 {
125 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
125 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
126 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
126 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
127 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
127 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
128 if (aux > FLOAT_EQUAL_ZERO)
128 if (aux > FLOAT_EQUAL_ZERO)
129 {
129 {
130 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
130 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
131 flag = LFR_DEFAULT;
131 flag = LFR_DEFAULT;
132 }
132 }
133 }
133 }
134
134
135 // SET THE PARAMETERS
135 // SET THE PARAMETERS
136 if (flag == LFR_SUCCESSFUL)
136 if (flag == LFR_SUCCESSFUL)
137 {
137 {
138 flag = set_sy_lfr_b_bp_p0( TC );
138 flag = set_sy_lfr_b_bp_p0( TC );
139 flag = set_sy_lfr_b_bp_p1( TC );
139 flag = set_sy_lfr_b_bp_p1( TC );
140 }
140 }
141
141
142 return flag;
142 return flag;
143 }
143 }
144
144
145 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
145 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
146 {
146 {
147 /** This function updates the LFR registers with the incoming sbm1 parameters.
147 /** This function updates the LFR registers with the incoming sbm1 parameters.
148 *
148 *
149 * @param TC points to the TeleCommand packet that is being processed
149 * @param TC points to the TeleCommand packet that is being processed
150 * @param queue_id is the id of the queue which handles TM related to this execution step
150 * @param queue_id is the id of the queue which handles TM related to this execution step
151 *
151 *
152 */
152 */
153
153
154 int flag;
154 int flag;
155 rtems_status_code status;
155 rtems_status_code status;
156 unsigned char sy_lfr_s1_bp_p0;
156 unsigned char sy_lfr_s1_bp_p0;
157 unsigned char sy_lfr_s1_bp_p1;
157 unsigned char sy_lfr_s1_bp_p1;
158 float aux;
158 float aux;
159
159
160 flag = LFR_SUCCESSFUL;
160 flag = LFR_SUCCESSFUL;
161
161
162 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
162 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
163 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
163 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
164 flag = LFR_DEFAULT;
164 flag = LFR_DEFAULT;
165 }
165 }
166
166
167 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
167 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
168 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
168 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
169
169
170 // sy_lfr_s1_bp_p0
170 // sy_lfr_s1_bp_p0
171 if (flag == LFR_SUCCESSFUL)
171 if (flag == LFR_SUCCESSFUL)
172 {
172 {
173 if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 )
173 if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 )
174 {
174 {
175 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
175 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
176 flag = WRONG_APP_DATA;
176 flag = WRONG_APP_DATA;
177 }
177 }
178 }
178 }
179 // sy_lfr_s1_bp_p1
179 // sy_lfr_s1_bp_p1
180 if (flag == LFR_SUCCESSFUL)
180 if (flag == LFR_SUCCESSFUL)
181 {
181 {
182 if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 )
182 if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 )
183 {
183 {
184 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 );
184 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 );
185 flag = WRONG_APP_DATA;
185 flag = WRONG_APP_DATA;
186 }
186 }
187 }
187 }
188 //******************************************************************
188 //******************************************************************
189 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
189 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
190 if (flag == LFR_SUCCESSFUL)
190 if (flag == LFR_SUCCESSFUL)
191 {
191 {
192 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
192 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
193 if (aux > FLOAT_EQUAL_ZERO)
193 if (aux > FLOAT_EQUAL_ZERO)
194 {
194 {
195 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
195 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
196 flag = LFR_DEFAULT;
196 flag = LFR_DEFAULT;
197 }
197 }
198 }
198 }
199
199
200 // SET THE PARAMETERS
200 // SET THE PARAMETERS
201 if (flag == LFR_SUCCESSFUL)
201 if (flag == LFR_SUCCESSFUL)
202 {
202 {
203 flag = set_sy_lfr_s1_bp_p0( TC );
203 flag = set_sy_lfr_s1_bp_p0( TC );
204 flag = set_sy_lfr_s1_bp_p1( TC );
204 flag = set_sy_lfr_s1_bp_p1( TC );
205 }
205 }
206
206
207 return flag;
207 return flag;
208 }
208 }
209
209
210 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
210 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
211 {
211 {
212 /** This function updates the LFR registers with the incoming sbm2 parameters.
212 /** This function updates the LFR registers with the incoming sbm2 parameters.
213 *
213 *
214 * @param TC points to the TeleCommand packet that is being processed
214 * @param TC points to the TeleCommand packet that is being processed
215 * @param queue_id is the id of the queue which handles TM related to this execution step
215 * @param queue_id is the id of the queue which handles TM related to this execution step
216 *
216 *
217 */
217 */
218
218
219 int flag;
219 int flag;
220 rtems_status_code status;
220 rtems_status_code status;
221 unsigned char sy_lfr_s2_bp_p0;
221 unsigned char sy_lfr_s2_bp_p0;
222 unsigned char sy_lfr_s2_bp_p1;
222 unsigned char sy_lfr_s2_bp_p1;
223 float aux;
223 float aux;
224
224
225 flag = LFR_SUCCESSFUL;
225 flag = LFR_SUCCESSFUL;
226
226
227 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
227 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
228 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
228 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
229 flag = LFR_DEFAULT;
229 flag = LFR_DEFAULT;
230 }
230 }
231
231
232 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
232 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
233 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
233 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
234
234
235 // sy_lfr_s2_bp_p0
235 // sy_lfr_s2_bp_p0
236 if (flag == LFR_SUCCESSFUL)
236 if (flag == LFR_SUCCESSFUL)
237 {
237 {
238 if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 )
238 if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 )
239 {
239 {
240 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
240 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
241 flag = WRONG_APP_DATA;
241 flag = WRONG_APP_DATA;
242 }
242 }
243 }
243 }
244 // sy_lfr_s2_bp_p1
244 // sy_lfr_s2_bp_p1
245 if (flag == LFR_SUCCESSFUL)
245 if (flag == LFR_SUCCESSFUL)
246 {
246 {
247 if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 )
247 if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 )
248 {
248 {
249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 );
249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 );
250 flag = WRONG_APP_DATA;
250 flag = WRONG_APP_DATA;
251 }
251 }
252 }
252 }
253 //******************************************************************
253 //******************************************************************
254 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
254 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
255 if (flag == LFR_SUCCESSFUL)
255 if (flag == LFR_SUCCESSFUL)
256 {
256 {
257 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
257 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
258 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
258 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
259 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
259 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
260 if (aux > FLOAT_EQUAL_ZERO)
260 if (aux > FLOAT_EQUAL_ZERO)
261 {
261 {
262 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
262 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
263 flag = LFR_DEFAULT;
263 flag = LFR_DEFAULT;
264 }
264 }
265 }
265 }
266
266
267 // SET THE PARAMETERS
267 // SET THE PARAMETERS
268 if (flag == LFR_SUCCESSFUL)
268 if (flag == LFR_SUCCESSFUL)
269 {
269 {
270 flag = set_sy_lfr_s2_bp_p0( TC );
270 flag = set_sy_lfr_s2_bp_p0( TC );
271 flag = set_sy_lfr_s2_bp_p1( TC );
271 flag = set_sy_lfr_s2_bp_p1( TC );
272 }
272 }
273
273
274 return flag;
274 return flag;
275 }
275 }
276
276
277 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
277 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
278 {
278 {
279 /** This function updates the LFR registers with the incoming sbm2 parameters.
279 /** This function updates the LFR registers with the incoming sbm2 parameters.
280 *
280 *
281 * @param TC points to the TeleCommand packet that is being processed
281 * @param TC points to the TeleCommand packet that is being processed
282 * @param queue_id is the id of the queue which handles TM related to this execution step
282 * @param queue_id is the id of the queue which handles TM related to this execution step
283 *
283 *
284 */
284 */
285
285
286 int flag;
286 int flag;
287
287
288 flag = LFR_DEFAULT;
288 flag = LFR_DEFAULT;
289
289
290 flag = set_sy_lfr_kcoeff( TC, queue_id );
290 flag = set_sy_lfr_kcoeff( TC, queue_id );
291
291
292 return flag;
292 return flag;
293 }
293 }
294
294
295 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
295 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
296 {
296 {
297 /** This function updates the LFR registers with the incoming sbm2 parameters.
297 /** This function updates the LFR registers with the incoming sbm2 parameters.
298 *
298 *
299 * @param TC points to the TeleCommand packet that is being processed
299 * @param TC points to the TeleCommand packet that is being processed
300 * @param queue_id is the id of the queue which handles TM related to this execution step
300 * @param queue_id is the id of the queue which handles TM related to this execution step
301 *
301 *
302 */
302 */
303
303
304 int flag;
304 int flag;
305
305
306 flag = LFR_DEFAULT;
306 flag = LFR_DEFAULT;
307
307
308 flag = set_sy_lfr_fbins( TC );
308 flag = set_sy_lfr_fbins( TC );
309
309
310 return flag;
310 return flag;
311 }
311 }
312
312
313 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
313 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
314 {
314 {
315 /** This function updates the LFR registers with the incoming sbm2 parameters.
315 /** This function updates the LFR registers with the incoming sbm2 parameters.
316 *
316 *
317 * @param TC points to the TeleCommand packet that is being processed
317 * @param TC points to the TeleCommand packet that is being processed
318 * @param queue_id is the id of the queue which handles TM related to this execution step
318 * @param queue_id is the id of the queue which handles TM related to this execution step
319 *
319 *
320 */
320 */
321
321
322 int flag;
322 int flag;
323
323
324 flag = LFR_DEFAULT;
324 flag = LFR_DEFAULT;
325
325
326 flag = check_sy_lfr_filter_parameters( TC, queue_id );
326 flag = check_sy_lfr_filter_parameters( TC, queue_id );
327
327
328 if (flag == LFR_SUCCESSFUL)
328 if (flag == LFR_SUCCESSFUL)
329 {
329 {
330 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
330 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
331 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
331 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
332 parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ];
332 parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ];
333 parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ];
333 parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ];
334 parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ];
334 parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ];
335 parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ];
335 parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ];
336 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
336 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
337 parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ];
337 parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ];
338 parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ];
338 parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ];
339 parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ];
339 parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ];
340 parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ];
340 parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ];
341 parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ];
341 parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ];
342 parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ];
342 parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ];
343 parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ];
343 parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ];
344 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
344 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
345
345
346 //****************************
346 //****************************
347 // store PAS filter parameters
347 // store PAS filter parameters
348 // sy_lfr_pas_filter_enabled
348 // sy_lfr_pas_filter_enabled
349 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
349 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
350 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 );
350 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 );
351 // sy_lfr_pas_filter_modulus
351 // sy_lfr_pas_filter_modulus
352 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
352 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
353 // sy_lfr_pas_filter_tbad
353 // sy_lfr_pas_filter_tbad
354 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
354 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
355 parameter_dump_packet.sy_lfr_pas_filter_tbad );
355 parameter_dump_packet.sy_lfr_pas_filter_tbad );
356 // sy_lfr_pas_filter_offset
356 // sy_lfr_pas_filter_offset
357 filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset;
357 filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset;
358 // sy_lfr_pas_filter_shift
358 // sy_lfr_pas_filter_shift
359 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
359 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
360 parameter_dump_packet.sy_lfr_pas_filter_shift );
360 parameter_dump_packet.sy_lfr_pas_filter_shift );
361
361
362 //****************************************************
362 //****************************************************
363 // store the parameter sy_lfr_sc_rw_delta_f as a float
363 // store the parameter sy_lfr_sc_rw_delta_f as a float
364 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
364 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
365 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
365 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
366 }
366 }
367
367
368 return flag;
368 return flag;
369 }
369 }
370
370
371 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
371 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
372 {
372 {
373 /** This function updates the LFR registers with the incoming sbm2 parameters.
373 /** This function updates the LFR registers with the incoming sbm2 parameters.
374 *
374 *
375 * @param TC points to the TeleCommand packet that is being processed
375 * @param TC points to the TeleCommand packet that is being processed
376 * @param queue_id is the id of the queue which handles TM related to this execution step
376 * @param queue_id is the id of the queue which handles TM related to this execution step
377 *
377 *
378 */
378 */
379
379
380 unsigned int address;
380 unsigned int address;
381 rtems_status_code status;
381 rtems_status_code status;
382 unsigned int freq;
382 unsigned int freq;
383 unsigned int bin;
383 unsigned int bin;
384 unsigned int coeff;
384 unsigned int coeff;
385 unsigned char *kCoeffPtr;
385 unsigned char *kCoeffPtr;
386 unsigned char *kCoeffDumpPtr;
386 unsigned char *kCoeffDumpPtr;
387
387
388 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
388 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
389 // F0 => 11 bins
389 // F0 => 11 bins
390 // F1 => 13 bins
390 // F1 => 13 bins
391 // F2 => 12 bins
391 // F2 => 12 bins
392 // 36 bins to dump in two packets (30 bins max per packet)
392 // 36 bins to dump in two packets (30 bins max per packet)
393
393
394 //*********
394 //*********
395 // PACKET 1
395 // PACKET 1
396 // 11 F0 bins, 13 F1 bins and 6 F2 bins
396 // 11 F0 bins, 13 F1 bins and 6 F2 bins
397 kcoefficients_dump_1.destinationID = TC->sourceID;
397 kcoefficients_dump_1.destinationID = TC->sourceID;
398 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
398 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
399 for( freq=0;
399 for( freq=0;
400 freq<NB_BINS_COMPRESSED_SM_F0;
400 freq<NB_BINS_COMPRESSED_SM_F0;
401 freq++ )
401 freq++ )
402 {
402 {
403 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
403 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
404 bin = freq;
404 bin = freq;
405 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
405 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
406 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
406 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
407 {
407 {
408 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
408 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
409 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
409 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
410 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
410 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
411 }
411 }
412 }
412 }
413 for( freq=NB_BINS_COMPRESSED_SM_F0;
413 for( freq=NB_BINS_COMPRESSED_SM_F0;
414 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
414 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
415 freq++ )
415 freq++ )
416 {
416 {
417 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
417 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
418 bin = freq - NB_BINS_COMPRESSED_SM_F0;
418 bin = freq - NB_BINS_COMPRESSED_SM_F0;
419 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
419 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
420 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
420 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
421 {
421 {
422 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
422 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
423 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
423 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
424 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
424 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
425 }
425 }
426 }
426 }
427 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
427 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
428 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
428 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
429 freq++ )
429 freq++ )
430 {
430 {
431 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
431 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
432 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
432 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
433 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
433 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
434 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
434 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
435 {
435 {
436 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
436 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
437 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
437 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
438 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
438 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
439 }
439 }
440 }
440 }
441 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
441 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
442 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
442 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
443 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
443 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
444 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
444 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
445 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
445 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
446 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
446 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
447 // SEND DATA
447 // SEND DATA
448 kcoefficient_node_1.status = 1;
448 kcoefficient_node_1.status = 1;
449 address = (unsigned int) &kcoefficient_node_1;
449 address = (unsigned int) &kcoefficient_node_1;
450 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
450 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
451 if (status != RTEMS_SUCCESSFUL) {
451 if (status != RTEMS_SUCCESSFUL) {
452 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
452 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
453 }
453 }
454
454
455 //********
455 //********
456 // PACKET 2
456 // PACKET 2
457 // 6 F2 bins
457 // 6 F2 bins
458 kcoefficients_dump_2.destinationID = TC->sourceID;
458 kcoefficients_dump_2.destinationID = TC->sourceID;
459 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
459 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
460 for( freq=0; freq<6; freq++ )
460 for( freq=0; freq<6; freq++ )
461 {
461 {
462 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
462 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
463 bin = freq + 6;
463 bin = freq + 6;
464 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
464 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
465 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
465 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
466 {
466 {
467 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
467 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
468 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
468 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
469 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
469 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
470 }
470 }
471 }
471 }
472 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
472 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
473 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
473 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
474 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
474 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
475 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
475 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
476 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
476 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
477 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
477 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
478 // SEND DATA
478 // SEND DATA
479 kcoefficient_node_2.status = 1;
479 kcoefficient_node_2.status = 1;
480 address = (unsigned int) &kcoefficient_node_2;
480 address = (unsigned int) &kcoefficient_node_2;
481 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
481 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
482 if (status != RTEMS_SUCCESSFUL) {
482 if (status != RTEMS_SUCCESSFUL) {
483 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
483 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
484 }
484 }
485
485
486 return status;
486 return status;
487 }
487 }
488
488
489 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
489 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
490 {
490 {
491 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
491 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
492 *
492 *
493 * @param queue_id is the id of the queue which handles TM related to this execution step.
493 * @param queue_id is the id of the queue which handles TM related to this execution step.
494 *
494 *
495 * @return RTEMS directive status codes:
495 * @return RTEMS directive status codes:
496 * - RTEMS_SUCCESSFUL - message sent successfully
496 * - RTEMS_SUCCESSFUL - message sent successfully
497 * - RTEMS_INVALID_ID - invalid queue id
497 * - RTEMS_INVALID_ID - invalid queue id
498 * - RTEMS_INVALID_SIZE - invalid message size
498 * - RTEMS_INVALID_SIZE - invalid message size
499 * - RTEMS_INVALID_ADDRESS - buffer is NULL
499 * - RTEMS_INVALID_ADDRESS - buffer is NULL
500 * - RTEMS_UNSATISFIED - out of message buffers
500 * - RTEMS_UNSATISFIED - out of message buffers
501 * - RTEMS_TOO_MANY - queue s limit has been reached
501 * - RTEMS_TOO_MANY - queue s limit has been reached
502 *
502 *
503 */
503 */
504
504
505 int status;
505 int status;
506
506
507 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
507 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
508 parameter_dump_packet.destinationID = TC->sourceID;
508 parameter_dump_packet.destinationID = TC->sourceID;
509
509
510 // UPDATE TIME
510 // UPDATE TIME
511 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
511 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
512 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
512 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
513 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
513 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
514 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
514 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
515 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
515 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
516 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
516 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
517 // SEND DATA
517 // SEND DATA
518 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
518 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
519 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
519 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
520 if (status != RTEMS_SUCCESSFUL) {
520 if (status != RTEMS_SUCCESSFUL) {
521 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
521 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
522 }
522 }
523
523
524 return status;
524 return status;
525 }
525 }
526
526
527 //***********************
527 //***********************
528 // NORMAL MODE PARAMETERS
528 // NORMAL MODE PARAMETERS
529
529
530 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
530 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
531 {
531 {
532 unsigned char msb;
532 unsigned char msb;
533 unsigned char lsb;
533 unsigned char lsb;
534 int flag;
534 int flag;
535 float aux;
535 float aux;
536 rtems_status_code status;
536 rtems_status_code status;
537
537
538 unsigned int sy_lfr_n_swf_l;
538 unsigned int sy_lfr_n_swf_l;
539 unsigned int sy_lfr_n_swf_p;
539 unsigned int sy_lfr_n_swf_p;
540 unsigned int sy_lfr_n_asm_p;
540 unsigned int sy_lfr_n_asm_p;
541 unsigned char sy_lfr_n_bp_p0;
541 unsigned char sy_lfr_n_bp_p0;
542 unsigned char sy_lfr_n_bp_p1;
542 unsigned char sy_lfr_n_bp_p1;
543 unsigned char sy_lfr_n_cwf_long_f3;
543 unsigned char sy_lfr_n_cwf_long_f3;
544
544
545 flag = LFR_SUCCESSFUL;
545 flag = LFR_SUCCESSFUL;
546
546
547 //***************
547 //***************
548 // get parameters
548 // get parameters
549 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
549 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
550 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
550 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
551 sy_lfr_n_swf_l = msb * 256 + lsb;
551 sy_lfr_n_swf_l = msb * 256 + lsb;
552
552
553 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
553 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
554 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
554 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
555 sy_lfr_n_swf_p = msb * 256 + lsb;
555 sy_lfr_n_swf_p = msb * 256 + lsb;
556
556
557 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
557 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
558 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
558 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
559 sy_lfr_n_asm_p = msb * 256 + lsb;
559 sy_lfr_n_asm_p = msb * 256 + lsb;
560
560
561 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
561 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
562
562
563 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
563 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
564
564
565 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
565 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
566
566
567 //******************
567 //******************
568 // check consistency
568 // check consistency
569 // sy_lfr_n_swf_l
569 // sy_lfr_n_swf_l
570 if (sy_lfr_n_swf_l != 2048)
570 if (sy_lfr_n_swf_l != 2048)
571 {
571 {
572 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
572 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
573 flag = WRONG_APP_DATA;
573 flag = WRONG_APP_DATA;
574 }
574 }
575 // sy_lfr_n_swf_p
575 // sy_lfr_n_swf_p
576 if (flag == LFR_SUCCESSFUL)
576 if (flag == LFR_SUCCESSFUL)
577 {
577 {
578 if ( sy_lfr_n_swf_p < 22 )
578 if ( sy_lfr_n_swf_p < 22 )
579 {
579 {
580 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
580 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
581 flag = WRONG_APP_DATA;
581 flag = WRONG_APP_DATA;
582 }
582 }
583 }
583 }
584 // sy_lfr_n_bp_p0
584 // sy_lfr_n_bp_p0
585 if (flag == LFR_SUCCESSFUL)
585 if (flag == LFR_SUCCESSFUL)
586 {
586 {
587 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
587 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
588 {
588 {
589 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
589 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
590 flag = WRONG_APP_DATA;
590 flag = WRONG_APP_DATA;
591 }
591 }
592 }
592 }
593 // sy_lfr_n_asm_p
593 // sy_lfr_n_asm_p
594 if (flag == LFR_SUCCESSFUL)
594 if (flag == LFR_SUCCESSFUL)
595 {
595 {
596 if (sy_lfr_n_asm_p == 0)
596 if (sy_lfr_n_asm_p == 0)
597 {
597 {
598 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
598 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
599 flag = WRONG_APP_DATA;
599 flag = WRONG_APP_DATA;
600 }
600 }
601 }
601 }
602 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
602 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
603 if (flag == LFR_SUCCESSFUL)
603 if (flag == LFR_SUCCESSFUL)
604 {
604 {
605 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
605 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
606 if (aux > FLOAT_EQUAL_ZERO)
606 if (aux > FLOAT_EQUAL_ZERO)
607 {
607 {
608 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
608 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
609 flag = WRONG_APP_DATA;
609 flag = WRONG_APP_DATA;
610 }
610 }
611 }
611 }
612 // sy_lfr_n_bp_p1
612 // sy_lfr_n_bp_p1
613 if (flag == LFR_SUCCESSFUL)
613 if (flag == LFR_SUCCESSFUL)
614 {
614 {
615 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
615 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
616 {
616 {
617 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
617 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
618 flag = WRONG_APP_DATA;
618 flag = WRONG_APP_DATA;
619 }
619 }
620 }
620 }
621 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
621 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
622 if (flag == LFR_SUCCESSFUL)
622 if (flag == LFR_SUCCESSFUL)
623 {
623 {
624 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
624 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
625 if (aux > FLOAT_EQUAL_ZERO)
625 if (aux > FLOAT_EQUAL_ZERO)
626 {
626 {
627 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
627 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
628 flag = LFR_DEFAULT;
628 flag = LFR_DEFAULT;
629 }
629 }
630 }
630 }
631 // sy_lfr_n_cwf_long_f3
631 // sy_lfr_n_cwf_long_f3
632
632
633 return flag;
633 return flag;
634 }
634 }
635
635
636 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
636 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
637 {
637 {
638 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
638 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
639 *
639 *
640 * @param TC points to the TeleCommand packet that is being processed
640 * @param TC points to the TeleCommand packet that is being processed
641 * @param queue_id is the id of the queue which handles TM related to this execution step
641 * @param queue_id is the id of the queue which handles TM related to this execution step
642 *
642 *
643 */
643 */
644
644
645 int result;
645 int result;
646
646
647 result = LFR_SUCCESSFUL;
647 result = LFR_SUCCESSFUL;
648
648
649 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
649 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
650 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
650 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
651
651
652 return result;
652 return result;
653 }
653 }
654
654
655 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
655 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
656 {
656 {
657 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
657 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
658 *
658 *
659 * @param TC points to the TeleCommand packet that is being processed
659 * @param TC points to the TeleCommand packet that is being processed
660 * @param queue_id is the id of the queue which handles TM related to this execution step
660 * @param queue_id is the id of the queue which handles TM related to this execution step
661 *
661 *
662 */
662 */
663
663
664 int result;
664 int result;
665
665
666 result = LFR_SUCCESSFUL;
666 result = LFR_SUCCESSFUL;
667
667
668 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
668 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
669 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
669 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
670
670
671 return result;
671 return result;
672 }
672 }
673
673
674 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
674 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
675 {
675 {
676 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
676 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
677 *
677 *
678 * @param TC points to the TeleCommand packet that is being processed
678 * @param TC points to the TeleCommand packet that is being processed
679 * @param queue_id is the id of the queue which handles TM related to this execution step
679 * @param queue_id is the id of the queue which handles TM related to this execution step
680 *
680 *
681 */
681 */
682
682
683 int result;
683 int result;
684
684
685 result = LFR_SUCCESSFUL;
685 result = LFR_SUCCESSFUL;
686
686
687 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
687 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
688 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
688 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
689
689
690 return result;
690 return result;
691 }
691 }
692
692
693 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
693 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
694 {
694 {
695 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
695 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
696 *
696 *
697 * @param TC points to the TeleCommand packet that is being processed
697 * @param TC points to the TeleCommand packet that is being processed
698 * @param queue_id is the id of the queue which handles TM related to this execution step
698 * @param queue_id is the id of the queue which handles TM related to this execution step
699 *
699 *
700 */
700 */
701
701
702 int status;
702 int status;
703
703
704 status = LFR_SUCCESSFUL;
704 status = LFR_SUCCESSFUL;
705
705
706 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
706 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
707
707
708 return status;
708 return status;
709 }
709 }
710
710
711 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
711 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
712 {
712 {
713 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
713 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
714 *
714 *
715 * @param TC points to the TeleCommand packet that is being processed
715 * @param TC points to the TeleCommand packet that is being processed
716 * @param queue_id is the id of the queue which handles TM related to this execution step
716 * @param queue_id is the id of the queue which handles TM related to this execution step
717 *
717 *
718 */
718 */
719
719
720 int status;
720 int status;
721
721
722 status = LFR_SUCCESSFUL;
722 status = LFR_SUCCESSFUL;
723
723
724 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
724 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
725
725
726 return status;
726 return status;
727 }
727 }
728
728
729 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
729 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
730 {
730 {
731 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
731 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
732 *
732 *
733 * @param TC points to the TeleCommand packet that is being processed
733 * @param TC points to the TeleCommand packet that is being processed
734 * @param queue_id is the id of the queue which handles TM related to this execution step
734 * @param queue_id is the id of the queue which handles TM related to this execution step
735 *
735 *
736 */
736 */
737
737
738 int status;
738 int status;
739
739
740 status = LFR_SUCCESSFUL;
740 status = LFR_SUCCESSFUL;
741
741
742 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
742 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
743
743
744 return status;
744 return status;
745 }
745 }
746
746
747 //**********************
747 //**********************
748 // BURST MODE PARAMETERS
748 // BURST MODE PARAMETERS
749 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
749 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
750 {
750 {
751 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
751 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
752 *
752 *
753 * @param TC points to the TeleCommand packet that is being processed
753 * @param TC points to the TeleCommand packet that is being processed
754 * @param queue_id is the id of the queue which handles TM related to this execution step
754 * @param queue_id is the id of the queue which handles TM related to this execution step
755 *
755 *
756 */
756 */
757
757
758 int status;
758 int status;
759
759
760 status = LFR_SUCCESSFUL;
760 status = LFR_SUCCESSFUL;
761
761
762 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
762 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
763
763
764 return status;
764 return status;
765 }
765 }
766
766
767 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
767 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
768 {
768 {
769 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
769 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
770 *
770 *
771 * @param TC points to the TeleCommand packet that is being processed
771 * @param TC points to the TeleCommand packet that is being processed
772 * @param queue_id is the id of the queue which handles TM related to this execution step
772 * @param queue_id is the id of the queue which handles TM related to this execution step
773 *
773 *
774 */
774 */
775
775
776 int status;
776 int status;
777
777
778 status = LFR_SUCCESSFUL;
778 status = LFR_SUCCESSFUL;
779
779
780 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
780 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
781
781
782 return status;
782 return status;
783 }
783 }
784
784
785 //*********************
785 //*********************
786 // SBM1 MODE PARAMETERS
786 // SBM1 MODE PARAMETERS
787 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
787 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
788 {
788 {
789 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
789 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
790 *
790 *
791 * @param TC points to the TeleCommand packet that is being processed
791 * @param TC points to the TeleCommand packet that is being processed
792 * @param queue_id is the id of the queue which handles TM related to this execution step
792 * @param queue_id is the id of the queue which handles TM related to this execution step
793 *
793 *
794 */
794 */
795
795
796 int status;
796 int status;
797
797
798 status = LFR_SUCCESSFUL;
798 status = LFR_SUCCESSFUL;
799
799
800 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
800 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
801
801
802 return status;
802 return status;
803 }
803 }
804
804
805 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
805 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
806 {
806 {
807 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
807 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
808 *
808 *
809 * @param TC points to the TeleCommand packet that is being processed
809 * @param TC points to the TeleCommand packet that is being processed
810 * @param queue_id is the id of the queue which handles TM related to this execution step
810 * @param queue_id is the id of the queue which handles TM related to this execution step
811 *
811 *
812 */
812 */
813
813
814 int status;
814 int status;
815
815
816 status = LFR_SUCCESSFUL;
816 status = LFR_SUCCESSFUL;
817
817
818 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
818 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
819
819
820 return status;
820 return status;
821 }
821 }
822
822
823 //*********************
823 //*********************
824 // SBM2 MODE PARAMETERS
824 // SBM2 MODE PARAMETERS
825 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
825 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
826 {
826 {
827 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
827 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
828 *
828 *
829 * @param TC points to the TeleCommand packet that is being processed
829 * @param TC points to the TeleCommand packet that is being processed
830 * @param queue_id is the id of the queue which handles TM related to this execution step
830 * @param queue_id is the id of the queue which handles TM related to this execution step
831 *
831 *
832 */
832 */
833
833
834 int status;
834 int status;
835
835
836 status = LFR_SUCCESSFUL;
836 status = LFR_SUCCESSFUL;
837
837
838 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
838 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
839
839
840 return status;
840 return status;
841 }
841 }
842
842
843 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
843 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
844 {
844 {
845 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
845 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
846 *
846 *
847 * @param TC points to the TeleCommand packet that is being processed
847 * @param TC points to the TeleCommand packet that is being processed
848 * @param queue_id is the id of the queue which handles TM related to this execution step
848 * @param queue_id is the id of the queue which handles TM related to this execution step
849 *
849 *
850 */
850 */
851
851
852 int status;
852 int status;
853
853
854 status = LFR_SUCCESSFUL;
854 status = LFR_SUCCESSFUL;
855
855
856 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
856 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
857
857
858 return status;
858 return status;
859 }
859 }
860
860
861 //*******************
861 //*******************
862 // TC_LFR_UPDATE_INFO
862 // TC_LFR_UPDATE_INFO
863 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
863 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
864 {
864 {
865 unsigned int status;
865 unsigned int status;
866
866
867 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
867 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
868 || (mode == LFR_MODE_BURST)
868 || (mode == LFR_MODE_BURST)
869 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
869 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
870 {
870 {
871 status = LFR_SUCCESSFUL;
871 status = LFR_SUCCESSFUL;
872 }
872 }
873 else
873 else
874 {
874 {
875 status = LFR_DEFAULT;
875 status = LFR_DEFAULT;
876 }
876 }
877
877
878 return status;
878 return status;
879 }
879 }
880
880
881 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
881 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
882 {
882 {
883 unsigned int status;
883 unsigned int status;
884
884
885 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
885 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
886 || (mode == TDS_MODE_BURST)
886 || (mode == TDS_MODE_BURST)
887 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
887 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
888 || (mode == TDS_MODE_LFM))
888 || (mode == TDS_MODE_LFM))
889 {
889 {
890 status = LFR_SUCCESSFUL;
890 status = LFR_SUCCESSFUL;
891 }
891 }
892 else
892 else
893 {
893 {
894 status = LFR_DEFAULT;
894 status = LFR_DEFAULT;
895 }
895 }
896
896
897 return status;
897 return status;
898 }
898 }
899
899
900 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
900 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
901 {
901 {
902 unsigned int status;
902 unsigned int status;
903
903
904 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
904 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
905 || (mode == THR_MODE_BURST))
905 || (mode == THR_MODE_BURST))
906 {
906 {
907 status = LFR_SUCCESSFUL;
907 status = LFR_SUCCESSFUL;
908 }
908 }
909 else
909 else
910 {
910 {
911 status = LFR_DEFAULT;
911 status = LFR_DEFAULT;
912 }
912 }
913
913
914 return status;
914 return status;
915 }
915 }
916
916
917 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
917 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
918 {
918 {
919 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
919 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
920 *
920 *
921 * @param TC points to the TeleCommand packet that is being processed
921 * @param TC points to the TeleCommand packet that is being processed
922 *
922 *
923 */
923 */
924
924
925 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
925 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
926
926
927 bytePosPtr = (unsigned char *) &TC->packetID;
927 bytePosPtr = (unsigned char *) &TC->packetID;
928
928
929 // cp_rpw_sc_rw1_f1
929 // cp_rpw_sc_rw1_f1
930 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1,
930 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1,
931 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
931 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
932
932
933 // cp_rpw_sc_rw1_f2
933 // cp_rpw_sc_rw1_f2
934 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2,
934 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2,
935 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
935 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
936
936
937 // cp_rpw_sc_rw2_f1
937 // cp_rpw_sc_rw2_f1
938 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1,
938 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1,
939 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
939 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
940
940
941 // cp_rpw_sc_rw2_f2
941 // cp_rpw_sc_rw2_f2
942 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2,
942 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2,
943 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
943 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
944
944
945 // cp_rpw_sc_rw3_f1
945 // cp_rpw_sc_rw3_f1
946 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1,
946 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1,
947 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
947 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
948
948
949 // cp_rpw_sc_rw3_f2
949 // cp_rpw_sc_rw3_f2
950 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2,
950 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2,
951 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
951 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
952
952
953 // cp_rpw_sc_rw4_f1
953 // cp_rpw_sc_rw4_f1
954 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1,
954 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1,
955 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
955 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
956
956
957 // cp_rpw_sc_rw4_f2
957 // cp_rpw_sc_rw4_f2
958 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2,
958 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2,
959 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
959 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
960 }
960 }
961
961
962 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag )
962 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag )
963 {
963 {
964 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
964 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
965 *
965 *
966 * @param fbins_mask
966 * @param fbins_mask
967 * @param rw_f is the reaction wheel frequency to filter
967 * @param rw_f is the reaction wheel frequency to filter
968 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
968 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
969 * @param flag [true] filtering enabled [false] filtering disabled
969 * @param flag [true] filtering enabled [false] filtering disabled
970 *
970 *
971 * @return void
971 * @return void
972 *
972 *
973 */
973 */
974
974
975 float f_RW_min;
975 float f_RW_min;
976 float f_RW_MAX;
976 float f_RW_MAX;
977 float fi_min;
977 float fi_min;
978 float fi_MAX;
978 float fi_MAX;
979 float fi;
979 float fi;
980 float deltaBelow;
980 float deltaBelow;
981 float deltaAbove;
981 float deltaAbove;
982 int binBelow;
982 int binBelow;
983 int binAbove;
983 int binAbove;
984 int closestBin;
984 int closestBin;
985 unsigned int whichByte;
985 unsigned int whichByte;
986 int selectedByte;
986 int selectedByte;
987 int bin;
987 int bin;
988 int binToRemove[3];
988 int binToRemove[3];
989 int k;
989 int k;
990
990
991 whichByte = 0;
991 whichByte = 0;
992 bin = 0;
992 bin = 0;
993
993
994 binToRemove[0] = -1;
994 binToRemove[0] = -1;
995 binToRemove[1] = -1;
995 binToRemove[1] = -1;
996 binToRemove[2] = -1;
996 binToRemove[2] = -1;
997
997
998 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
998 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
999 f_RW_min = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.;
999 f_RW_min = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.;
1000 f_RW_MAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.;
1000 f_RW_MAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.;
1001
1001
1002 // compute the index of the frequency bin immediately below rw_f
1002 // compute the index of the frequency bin immediately below rw_f
1003 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1003 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1004 deltaBelow = rw_f - binBelow * deltaFreq;
1004 deltaBelow = rw_f - binBelow * deltaFreq;
1005
1005
1006 // compute the index of the frequency bin immediately above rw_f
1006 // compute the index of the frequency bin immediately above rw_f
1007 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1007 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1008 deltaAbove = binAbove * deltaFreq - rw_f;
1008 deltaAbove = binAbove * deltaFreq - rw_f;
1009
1009
1010 // search the closest bin
1010 // search the closest bin
1011 if (deltaAbove > deltaBelow)
1011 if (deltaAbove > deltaBelow)
1012 {
1012 {
1013 closestBin = binBelow;
1013 closestBin = binBelow;
1014 }
1014 }
1015 else
1015 else
1016 {
1016 {
1017 closestBin = binAbove;
1017 closestBin = binAbove;
1018 }
1018 }
1019
1019
1020 // compute the fi interval [fi - Delta_f * 0.285, fi + Delta_f * 0.285]
1020 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1021 fi = closestBin * deltaFreq;
1021 fi = closestBin * deltaFreq;
1022
1023 fi_min = fi - (deltaFreq * 0.285);
1022 fi_min = fi - (deltaFreq * 0.285);
1024 if ( fi_min < 0 )
1023 fi_MAX = fi + (deltaFreq * 0.285);
1025 {
1026 fi_min = 0;
1027 }
1028 else if ( fi_min > (deltaFreq * 127) )
1029 {
1030 fi_min = -1;
1031 }
1032
1024
1033 fi_MAX = fi + (deltaFreq * 0.285);
1025 //**************************************************************************************
1034 if ( fi_MAX > (deltaFreq*127) )
1026 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
1035 {
1027 // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum
1036 fi_MAX = -1;
1028 //**************************************************************************************
1037 }
1038
1029
1039 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1030 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1040 // => remove f_(i), f_(i-1) and f_(i+1)
1031 // => remove f_(i), f_(i-1) and f_(i+1)
1041 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1032 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1042 {
1033 {
1043 binToRemove[0] = closestBin - 1;
1034 binToRemove[0] = (closestBin - 1) - 1;
1044 binToRemove[1] = closestBin;
1035 binToRemove[1] = (closestBin) - 1;
1045 binToRemove[2] = closestBin + 1;
1036 binToRemove[2] = (closestBin + 1) - 1;
1046 }
1037 }
1047 // 2. ELSE
1038 // 2. ELSE
1048 // => remove the two f_(i) which are around f_RW
1039 // => remove the two f_(i) which are around f_RW
1049 else
1040 else
1050 {
1041 {
1051 binToRemove[0] = binBelow;
1042 binToRemove[0] = (binBelow) - 1;
1052 binToRemove[1] = binAbove;
1043 binToRemove[1] = (binAbove) - 1;
1053 binToRemove[2] = -1;
1044 binToRemove[2] = (-1);
1054 }
1045 }
1055
1046
1056 for (k = 0; k < 3; k++)
1047 for (k = 0; k < 3; k++)
1057 {
1048 {
1058 bin = binToRemove[k];
1049 bin = binToRemove[k];
1059 if ( (bin >= 0) && (bin <= 127) )
1050 if ( (bin >= 0) && (bin <= 127) )
1060 {
1051 {
1061 if (flag == 1)
1052 if (flag == 1)
1062 {
1053 {
1063 whichByte = (bin >> 3); // division by 8
1054 whichByte = (bin >> 3); // division by 8
1064 selectedByte = ( 1 << (bin - (whichByte * 8)) );
1055 selectedByte = ( 1 << (bin - (whichByte * 8)) );
1065 fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1056 fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1066 }
1057 }
1067 }
1058 }
1068 }
1059 }
1069 }
1060 }
1070
1061
1071 void build_sy_lfr_rw_mask( unsigned int channel )
1062 void build_sy_lfr_rw_mask( unsigned int channel )
1072 {
1063 {
1073 unsigned char local_rw_fbins_mask[16];
1064 unsigned char local_rw_fbins_mask[16];
1074 unsigned char *maskPtr;
1065 unsigned char *maskPtr;
1075 double deltaF;
1066 double deltaF;
1076 unsigned k;
1067 unsigned k;
1077
1068
1078 k = 0;
1069 k = 0;
1079
1070
1080 maskPtr = NULL;
1071 maskPtr = NULL;
1081 deltaF = 1.;
1072 deltaF = 1.;
1082
1073
1083 switch (channel)
1074 switch (channel)
1084 {
1075 {
1085 case 0:
1076 case 0:
1086 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1077 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f0_word1;
1087 deltaF = 96.;
1078 deltaF = 96.;
1088 break;
1079 break;
1089 case 1:
1080 case 1:
1090 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1081 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f1_word1;
1091 deltaF = 16.;
1082 deltaF = 16.;
1092 break;
1083 break;
1093 case 2:
1084 case 2:
1094 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1085 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f2_word1;
1095 deltaF = 1.;
1086 deltaF = 1.;
1096 break;
1087 break;
1097 default:
1088 default:
1098 break;
1089 break;
1099 }
1090 }
1100
1091
1101 for (k = 0; k < 16; k++)
1092 for (k = 0; k < 16; k++)
1102 {
1093 {
1103 local_rw_fbins_mask[k] = 0xff;
1094 local_rw_fbins_mask[k] = 0xff;
1104 }
1095 }
1105
1096
1106 // RW1 F1
1097 // RW1 F1
1107 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000]
1098 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000]
1108
1099
1109 // RW1 F2
1100 // RW1 F2
1110 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000]
1101 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000]
1111
1102
1112 // RW2 F1
1103 // RW2 F1
1113 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000]
1104 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000]
1114
1105
1115 // RW2 F2
1106 // RW2 F2
1116 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000]
1107 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000]
1117
1108
1118 // RW3 F1
1109 // RW3 F1
1119 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000]
1110 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000]
1120
1111
1121 // RW3 F2
1112 // RW3 F2
1122 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100]
1113 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100]
1123
1114
1124 // RW4 F1
1115 // RW4 F1
1125 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010]
1116 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010]
1126
1117
1127 // RW4 F2
1118 // RW4 F2
1128 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001]
1119 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001]
1129
1120
1130 // update the value of the fbins related to reaction wheels frequency filtering
1121 // update the value of the fbins related to reaction wheels frequency filtering
1131 if (maskPtr != NULL)
1122 if (maskPtr != NULL)
1132 {
1123 {
1133 for (k = 0; k < 16; k++)
1124 for (k = 0; k < 16; k++)
1134 {
1125 {
1135 maskPtr[k] = local_rw_fbins_mask[k];
1126 maskPtr[k] = local_rw_fbins_mask[k];
1136 }
1127 }
1137 }
1128 }
1138 }
1129 }
1139
1130
1140 void build_sy_lfr_rw_masks( void )
1131 void build_sy_lfr_rw_masks( void )
1141 {
1132 {
1142 build_sy_lfr_rw_mask( 0 );
1133 build_sy_lfr_rw_mask( 0 );
1143 build_sy_lfr_rw_mask( 1 );
1134 build_sy_lfr_rw_mask( 1 );
1144 build_sy_lfr_rw_mask( 2 );
1135 build_sy_lfr_rw_mask( 2 );
1145
1136
1146 merge_fbins_masks();
1137 merge_fbins_masks();
1147 }
1138 }
1148
1139
1149 void merge_fbins_masks( void )
1140 void merge_fbins_masks( void )
1150 {
1141 {
1151 unsigned char k;
1142 unsigned char k;
1152
1143
1153 unsigned char *fbins_f0;
1144 unsigned char *fbins_f0;
1154 unsigned char *fbins_f1;
1145 unsigned char *fbins_f1;
1155 unsigned char *fbins_f2;
1146 unsigned char *fbins_f2;
1156 unsigned char *rw_mask_f0;
1147 unsigned char *rw_mask_f0;
1157 unsigned char *rw_mask_f1;
1148 unsigned char *rw_mask_f1;
1158 unsigned char *rw_mask_f2;
1149 unsigned char *rw_mask_f2;
1159
1150
1160 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1151 fbins_f0 = parameter_dump_packet.sy_lfr_fbins.fx.f0_word1;
1161 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1152 fbins_f1 = parameter_dump_packet.sy_lfr_fbins.fx.f1_word1;
1162 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1153 fbins_f2 = parameter_dump_packet.sy_lfr_fbins.fx.f2_word1;
1163 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1154 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask.fx.f0_word1;
1164 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1155 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask.fx.f1_word1;
1165 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1156 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask.fx.f2_word1;
1166
1157
1167 for( k=0; k < 16; k++ )
1158 for( k=0; k < 16; k++ )
1168 {
1159 {
1169 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1160 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1170 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1161 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1171 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1162 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1172 }
1163 }
1173 }
1164 }
1174
1165
1175 //***********
1166 //***********
1176 // FBINS MASK
1167 // FBINS MASK
1177
1168
1178 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1169 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1179 {
1170 {
1180 int status;
1171 int status;
1181 unsigned int k;
1172 unsigned int k;
1182 unsigned char *fbins_mask_dump;
1173 unsigned char *fbins_mask_dump;
1183 unsigned char *fbins_mask_TC;
1174 unsigned char *fbins_mask_TC;
1184
1175
1185 status = LFR_SUCCESSFUL;
1176 status = LFR_SUCCESSFUL;
1186
1177
1187 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1178 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins.raw;
1188 fbins_mask_TC = TC->dataAndCRC;
1179 fbins_mask_TC = TC->dataAndCRC;
1189
1180
1190 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1181 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1191 {
1182 {
1192 fbins_mask_dump[k] = fbins_mask_TC[k];
1183 fbins_mask_dump[k] = fbins_mask_TC[k];
1193 }
1184 }
1194
1185
1195 return status;
1186 return status;
1196 }
1187 }
1197
1188
1198 //***************************
1189 //***************************
1199 // TC_LFR_LOAD_PAS_FILTER_PAR
1190 // TC_LFR_LOAD_PAS_FILTER_PAR
1200
1191
1201 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1192 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1202 {
1193 {
1203 int flag;
1194 int flag;
1204 rtems_status_code status;
1195 rtems_status_code status;
1205
1196
1206 unsigned char sy_lfr_pas_filter_enabled;
1197 unsigned char sy_lfr_pas_filter_enabled;
1207 unsigned char sy_lfr_pas_filter_modulus;
1198 unsigned char sy_lfr_pas_filter_modulus;
1208 float sy_lfr_pas_filter_tbad;
1199 float sy_lfr_pas_filter_tbad;
1209 unsigned char sy_lfr_pas_filter_offset;
1200 unsigned char sy_lfr_pas_filter_offset;
1210 float sy_lfr_pas_filter_shift;
1201 float sy_lfr_pas_filter_shift;
1211 float sy_lfr_sc_rw_delta_f;
1202 float sy_lfr_sc_rw_delta_f;
1212 char *parPtr;
1203 char *parPtr;
1213
1204
1214 flag = LFR_SUCCESSFUL;
1205 flag = LFR_SUCCESSFUL;
1215 sy_lfr_pas_filter_tbad = 0.0;
1206 sy_lfr_pas_filter_tbad = 0.0;
1216 sy_lfr_pas_filter_shift = 0.0;
1207 sy_lfr_pas_filter_shift = 0.0;
1217 sy_lfr_sc_rw_delta_f = 0.0;
1208 sy_lfr_sc_rw_delta_f = 0.0;
1218 parPtr = NULL;
1209 parPtr = NULL;
1219
1210
1220 //***************
1211 //***************
1221 // get parameters
1212 // get parameters
1222 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1213 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1223 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1214 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1224 copyFloatByChar(
1215 copyFloatByChar(
1225 (unsigned char*) &sy_lfr_pas_filter_tbad,
1216 (unsigned char*) &sy_lfr_pas_filter_tbad,
1226 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1217 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1227 );
1218 );
1228 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1219 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1229 copyFloatByChar(
1220 copyFloatByChar(
1230 (unsigned char*) &sy_lfr_pas_filter_shift,
1221 (unsigned char*) &sy_lfr_pas_filter_shift,
1231 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1222 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1232 );
1223 );
1233 copyFloatByChar(
1224 copyFloatByChar(
1234 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1225 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1235 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1226 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1236 );
1227 );
1237
1228
1238 //******************
1229 //******************
1239 // CHECK CONSISTENCY
1230 // CHECK CONSISTENCY
1240
1231
1241 //**************************
1232 //**************************
1242 // sy_lfr_pas_filter_enabled
1233 // sy_lfr_pas_filter_enabled
1243 // nothing to check, value is 0 or 1
1234 // nothing to check, value is 0 or 1
1244
1235
1245 //**************************
1236 //**************************
1246 // sy_lfr_pas_filter_modulus
1237 // sy_lfr_pas_filter_modulus
1247 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1238 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1248 {
1239 {
1249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1240 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1250 flag = WRONG_APP_DATA;
1241 flag = WRONG_APP_DATA;
1251 }
1242 }
1252
1243
1253 //***********************
1244 //***********************
1254 // sy_lfr_pas_filter_tbad
1245 // sy_lfr_pas_filter_tbad
1255 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1246 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1256 {
1247 {
1257 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1248 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1258 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1259 flag = WRONG_APP_DATA;
1250 flag = WRONG_APP_DATA;
1260 }
1251 }
1261
1252
1262 //*************************
1253 //*************************
1263 // sy_lfr_pas_filter_offset
1254 // sy_lfr_pas_filter_offset
1264 if (flag == LFR_SUCCESSFUL)
1255 if (flag == LFR_SUCCESSFUL)
1265 {
1256 {
1266 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1257 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1267 {
1258 {
1268 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1259 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1269 flag = WRONG_APP_DATA;
1260 flag = WRONG_APP_DATA;
1270 }
1261 }
1271 }
1262 }
1272
1263
1273 //************************
1264 //************************
1274 // sy_lfr_pas_filter_shift
1265 // sy_lfr_pas_filter_shift
1275 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1266 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1276 {
1267 {
1277 parPtr = (char*) &sy_lfr_pas_filter_shift;
1268 parPtr = (char*) &sy_lfr_pas_filter_shift;
1278 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1269 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1279 flag = WRONG_APP_DATA;
1270 flag = WRONG_APP_DATA;
1280 }
1271 }
1281
1272
1282 //*********************
1273 //*********************
1283 // sy_lfr_sc_rw_delta_f
1274 // sy_lfr_sc_rw_delta_f
1284 // nothing to check, no default value in the ICD
1275 // nothing to check, no default value in the ICD
1285
1276
1286 return flag;
1277 return flag;
1287 }
1278 }
1288
1279
1289 //**************
1280 //**************
1290 // KCOEFFICIENTS
1281 // KCOEFFICIENTS
1291 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1282 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1292 {
1283 {
1293 unsigned int kcoeff;
1284 unsigned int kcoeff;
1294 unsigned short sy_lfr_kcoeff_frequency;
1285 unsigned short sy_lfr_kcoeff_frequency;
1295 unsigned short bin;
1286 unsigned short bin;
1296 unsigned short *freqPtr;
1287 unsigned short *freqPtr;
1297 float *kcoeffPtr_norm;
1288 float *kcoeffPtr_norm;
1298 float *kcoeffPtr_sbm;
1289 float *kcoeffPtr_sbm;
1299 int status;
1290 int status;
1300 unsigned char *kcoeffLoadPtr;
1291 unsigned char *kcoeffLoadPtr;
1301 unsigned char *kcoeffNormPtr;
1292 unsigned char *kcoeffNormPtr;
1302 unsigned char *kcoeffSbmPtr_a;
1293 unsigned char *kcoeffSbmPtr_a;
1303 unsigned char *kcoeffSbmPtr_b;
1294 unsigned char *kcoeffSbmPtr_b;
1304
1295
1305 status = LFR_SUCCESSFUL;
1296 status = LFR_SUCCESSFUL;
1306
1297
1307 kcoeffPtr_norm = NULL;
1298 kcoeffPtr_norm = NULL;
1308 kcoeffPtr_sbm = NULL;
1299 kcoeffPtr_sbm = NULL;
1309 bin = 0;
1300 bin = 0;
1310
1301
1311 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1302 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1312 sy_lfr_kcoeff_frequency = *freqPtr;
1303 sy_lfr_kcoeff_frequency = *freqPtr;
1313
1304
1314 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1305 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1315 {
1306 {
1316 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1307 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1317 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1308 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1318 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1309 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1319 status = LFR_DEFAULT;
1310 status = LFR_DEFAULT;
1320 }
1311 }
1321 else
1312 else
1322 {
1313 {
1323 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1314 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1324 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1315 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1325 {
1316 {
1326 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1317 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1327 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1318 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1328 bin = sy_lfr_kcoeff_frequency;
1319 bin = sy_lfr_kcoeff_frequency;
1329 }
1320 }
1330 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1321 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1331 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1322 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1332 {
1323 {
1333 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1324 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1334 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1325 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1335 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1326 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1336 }
1327 }
1337 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1328 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1338 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1329 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1339 {
1330 {
1340 kcoeffPtr_norm = k_coeff_intercalib_f2;
1331 kcoeffPtr_norm = k_coeff_intercalib_f2;
1341 kcoeffPtr_sbm = NULL;
1332 kcoeffPtr_sbm = NULL;
1342 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1333 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1343 }
1334 }
1344 }
1335 }
1345
1336
1346 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1337 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1347 {
1338 {
1348 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1339 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1349 {
1340 {
1350 // destination
1341 // destination
1351 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1342 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1352 // source
1343 // source
1353 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1344 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1354 // copy source to destination
1345 // copy source to destination
1355 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1346 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1356 }
1347 }
1357 }
1348 }
1358
1349
1359 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1350 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1360 {
1351 {
1361 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1352 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1362 {
1353 {
1363 // destination
1354 // destination
1364 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1355 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1365 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1356 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1366 // source
1357 // source
1367 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1358 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1368 // copy source to destination
1359 // copy source to destination
1369 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1360 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1370 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1361 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1371 }
1362 }
1372 }
1363 }
1373
1364
1374 // print_k_coeff();
1365 // print_k_coeff();
1375
1366
1376 return status;
1367 return status;
1377 }
1368 }
1378
1369
1379 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1370 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1380 {
1371 {
1381 destination[0] = source[0];
1372 destination[0] = source[0];
1382 destination[1] = source[1];
1373 destination[1] = source[1];
1383 destination[2] = source[2];
1374 destination[2] = source[2];
1384 destination[3] = source[3];
1375 destination[3] = source[3];
1385 }
1376 }
1386
1377
1387 void floatToChar( float value, unsigned char* ptr)
1378 void floatToChar( float value, unsigned char* ptr)
1388 {
1379 {
1389 unsigned char* valuePtr;
1380 unsigned char* valuePtr;
1390
1381
1391 valuePtr = (unsigned char*) &value;
1382 valuePtr = (unsigned char*) &value;
1392 ptr[0] = valuePtr[0];
1383 ptr[0] = valuePtr[0];
1393 ptr[1] = valuePtr[1];
1384 ptr[1] = valuePtr[1];
1394 ptr[2] = valuePtr[2];
1385 ptr[2] = valuePtr[2];
1395 ptr[3] = valuePtr[3];
1386 ptr[3] = valuePtr[3];
1396 }
1387 }
1397
1388
1398 //**********
1389 //**********
1399 // init dump
1390 // init dump
1400
1391
1401 void init_parameter_dump( void )
1392 void init_parameter_dump( void )
1402 {
1393 {
1403 /** This function initialize the parameter_dump_packet global variable with default values.
1394 /** This function initialize the parameter_dump_packet global variable with default values.
1404 *
1395 *
1405 */
1396 */
1406
1397
1407 unsigned int k;
1398 unsigned int k;
1408
1399
1409 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1400 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1410 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1401 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1411 parameter_dump_packet.reserved = CCSDS_RESERVED;
1402 parameter_dump_packet.reserved = CCSDS_RESERVED;
1412 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1403 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1413 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1404 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1414 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1405 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1415 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1406 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1416 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1407 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1417 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1408 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1418 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1409 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1419 // DATA FIELD HEADER
1410 // DATA FIELD HEADER
1420 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1411 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1421 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1412 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1422 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1413 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1423 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1414 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1424 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1415 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1425 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1416 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1426 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1417 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1427 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1418 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1428 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1419 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1429 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1420 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1430 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1421 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1431
1422
1432 //******************
1423 //******************
1433 // COMMON PARAMETERS
1424 // COMMON PARAMETERS
1434 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1425 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1435 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1426 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1436
1427
1437 //******************
1428 //******************
1438 // NORMAL PARAMETERS
1429 // NORMAL PARAMETERS
1439 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1430 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1440 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1431 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1441 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1432 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1442 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1433 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1443 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1434 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1444 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1435 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1445 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1436 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1446 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1437 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1447 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1438 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1448
1439
1449 //*****************
1440 //*****************
1450 // BURST PARAMETERS
1441 // BURST PARAMETERS
1451 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1442 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1452 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1443 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1453
1444
1454 //****************
1445 //****************
1455 // SBM1 PARAMETERS
1446 // SBM1 PARAMETERS
1456 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
1447 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
1457 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1448 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1458
1449
1459 //****************
1450 //****************
1460 // SBM2 PARAMETERS
1451 // SBM2 PARAMETERS
1461 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1452 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1462 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1453 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1463
1454
1464 //************
1455 //************
1465 // FBINS MASKS
1456 // FBINS MASKS
1466 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1457 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1467 {
1458 {
1468 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1459 parameter_dump_packet.sy_lfr_fbins.raw[k] = 0xff;
1469 }
1460 }
1470
1461
1471 // PAS FILTER PARAMETERS
1462 // PAS FILTER PARAMETERS
1472 parameter_dump_packet.pa_rpw_spare8_2 = 0x00;
1463 parameter_dump_packet.pa_rpw_spare8_2 = 0x00;
1473 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00;
1464 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00;
1474 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1465 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1475 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1466 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1476 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1467 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1477 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1468 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1478 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1469 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1479
1470
1480 // LFR_RW_MASK
1471 // LFR_RW_MASK
1481 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1472 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1482 {
1473 {
1483 parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = 0xff;
1474 parameter_dump_packet.sy_lfr_rw_mask.raw[k] = 0xff;
1484 }
1475 }
1485 }
1476 }
1486
1477
1487 void init_kcoefficients_dump( void )
1478 void init_kcoefficients_dump( void )
1488 {
1479 {
1489 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1480 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1490 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1481 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1491
1482
1492 kcoefficient_node_1.previous = NULL;
1483 kcoefficient_node_1.previous = NULL;
1493 kcoefficient_node_1.next = NULL;
1484 kcoefficient_node_1.next = NULL;
1494 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1485 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1495 kcoefficient_node_1.coarseTime = 0x00;
1486 kcoefficient_node_1.coarseTime = 0x00;
1496 kcoefficient_node_1.fineTime = 0x00;
1487 kcoefficient_node_1.fineTime = 0x00;
1497 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1488 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1498 kcoefficient_node_1.status = 0x00;
1489 kcoefficient_node_1.status = 0x00;
1499
1490
1500 kcoefficient_node_2.previous = NULL;
1491 kcoefficient_node_2.previous = NULL;
1501 kcoefficient_node_2.next = NULL;
1492 kcoefficient_node_2.next = NULL;
1502 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1493 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1503 kcoefficient_node_2.coarseTime = 0x00;
1494 kcoefficient_node_2.coarseTime = 0x00;
1504 kcoefficient_node_2.fineTime = 0x00;
1495 kcoefficient_node_2.fineTime = 0x00;
1505 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1496 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1506 kcoefficient_node_2.status = 0x00;
1497 kcoefficient_node_2.status = 0x00;
1507 }
1498 }
1508
1499
1509 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1500 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1510 {
1501 {
1511 unsigned int k;
1502 unsigned int k;
1512 unsigned int packetLength;
1503 unsigned int packetLength;
1513
1504
1514 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1505 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1515
1506
1516 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1507 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1517 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1508 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1518 kcoefficients_dump->reserved = CCSDS_RESERVED;
1509 kcoefficients_dump->reserved = CCSDS_RESERVED;
1519 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1510 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1520 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1511 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1521 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1512 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1522 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1513 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1523 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1514 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1524 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1515 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1525 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1516 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1526 // DATA FIELD HEADER
1517 // DATA FIELD HEADER
1527 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1518 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1528 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1519 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1529 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1520 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1530 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1521 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1531 kcoefficients_dump->time[0] = 0x00;
1522 kcoefficients_dump->time[0] = 0x00;
1532 kcoefficients_dump->time[1] = 0x00;
1523 kcoefficients_dump->time[1] = 0x00;
1533 kcoefficients_dump->time[2] = 0x00;
1524 kcoefficients_dump->time[2] = 0x00;
1534 kcoefficients_dump->time[3] = 0x00;
1525 kcoefficients_dump->time[3] = 0x00;
1535 kcoefficients_dump->time[4] = 0x00;
1526 kcoefficients_dump->time[4] = 0x00;
1536 kcoefficients_dump->time[5] = 0x00;
1527 kcoefficients_dump->time[5] = 0x00;
1537 kcoefficients_dump->sid = SID_K_DUMP;
1528 kcoefficients_dump->sid = SID_K_DUMP;
1538
1529
1539 kcoefficients_dump->pkt_cnt = 2;
1530 kcoefficients_dump->pkt_cnt = 2;
1540 kcoefficients_dump->pkt_nr = pkt_nr;
1531 kcoefficients_dump->pkt_nr = pkt_nr;
1541 kcoefficients_dump->blk_nr = blk_nr;
1532 kcoefficients_dump->blk_nr = blk_nr;
1542
1533
1543 //******************
1534 //******************
1544 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1535 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1545 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1536 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1546 for (k=0; k<3900; k++)
1537 for (k=0; k<3900; k++)
1547 {
1538 {
1548 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1539 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1549 }
1540 }
1550 }
1541 }
1551
1542
1552 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1543 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1553 {
1544 {
1554 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1545 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1555 *
1546 *
1556 * @param packet_sequence_control points to the packet sequence control which will be incremented
1547 * @param packet_sequence_control points to the packet sequence control which will be incremented
1557 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1548 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1558 *
1549 *
1559 * If the destination ID is not known, a dedicated counter is incremented.
1550 * If the destination ID is not known, a dedicated counter is incremented.
1560 *
1551 *
1561 */
1552 */
1562
1553
1563 unsigned short sequence_cnt;
1554 unsigned short sequence_cnt;
1564 unsigned short segmentation_grouping_flag;
1555 unsigned short segmentation_grouping_flag;
1565 unsigned short new_packet_sequence_control;
1556 unsigned short new_packet_sequence_control;
1566 unsigned char i;
1557 unsigned char i;
1567
1558
1568 switch (destination_id)
1559 switch (destination_id)
1569 {
1560 {
1570 case SID_TC_GROUND:
1561 case SID_TC_GROUND:
1571 i = GROUND;
1562 i = GROUND;
1572 break;
1563 break;
1573 case SID_TC_MISSION_TIMELINE:
1564 case SID_TC_MISSION_TIMELINE:
1574 i = MISSION_TIMELINE;
1565 i = MISSION_TIMELINE;
1575 break;
1566 break;
1576 case SID_TC_TC_SEQUENCES:
1567 case SID_TC_TC_SEQUENCES:
1577 i = TC_SEQUENCES;
1568 i = TC_SEQUENCES;
1578 break;
1569 break;
1579 case SID_TC_RECOVERY_ACTION_CMD:
1570 case SID_TC_RECOVERY_ACTION_CMD:
1580 i = RECOVERY_ACTION_CMD;
1571 i = RECOVERY_ACTION_CMD;
1581 break;
1572 break;
1582 case SID_TC_BACKUP_MISSION_TIMELINE:
1573 case SID_TC_BACKUP_MISSION_TIMELINE:
1583 i = BACKUP_MISSION_TIMELINE;
1574 i = BACKUP_MISSION_TIMELINE;
1584 break;
1575 break;
1585 case SID_TC_DIRECT_CMD:
1576 case SID_TC_DIRECT_CMD:
1586 i = DIRECT_CMD;
1577 i = DIRECT_CMD;
1587 break;
1578 break;
1588 case SID_TC_SPARE_GRD_SRC1:
1579 case SID_TC_SPARE_GRD_SRC1:
1589 i = SPARE_GRD_SRC1;
1580 i = SPARE_GRD_SRC1;
1590 break;
1581 break;
1591 case SID_TC_SPARE_GRD_SRC2:
1582 case SID_TC_SPARE_GRD_SRC2:
1592 i = SPARE_GRD_SRC2;
1583 i = SPARE_GRD_SRC2;
1593 break;
1584 break;
1594 case SID_TC_OBCP:
1585 case SID_TC_OBCP:
1595 i = OBCP;
1586 i = OBCP;
1596 break;
1587 break;
1597 case SID_TC_SYSTEM_CONTROL:
1588 case SID_TC_SYSTEM_CONTROL:
1598 i = SYSTEM_CONTROL;
1589 i = SYSTEM_CONTROL;
1599 break;
1590 break;
1600 case SID_TC_AOCS:
1591 case SID_TC_AOCS:
1601 i = AOCS;
1592 i = AOCS;
1602 break;
1593 break;
1603 case SID_TC_RPW_INTERNAL:
1594 case SID_TC_RPW_INTERNAL:
1604 i = RPW_INTERNAL;
1595 i = RPW_INTERNAL;
1605 break;
1596 break;
1606 default:
1597 default:
1607 i = GROUND;
1598 i = GROUND;
1608 break;
1599 break;
1609 }
1600 }
1610
1601
1611 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1602 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1612 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1603 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1613
1604
1614 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1605 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1615
1606
1616 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1607 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1617 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1608 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1618
1609
1619 // increment the sequence counter
1610 // increment the sequence counter
1620 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1611 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1621 {
1612 {
1622 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1613 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1623 }
1614 }
1624 else
1615 else
1625 {
1616 {
1626 sequenceCounters_TM_DUMP[ i ] = 0;
1617 sequenceCounters_TM_DUMP[ i ] = 0;
1627 }
1618 }
1628 }
1619 }
General Comments 0
You need to be logged in to leave comments. Login now