##// END OF EJS Templates
3.0.0.21...
paul -
r275:7563e13131aa R3a
parent child
Show More
@@ -1,124 +1,124
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options =
4 4 # verbose
5 5 # boot_messages
6 6 # debug_messages
7 7 # cpu_usage_report
8 8 # stack_report
9 9 # vhdl_dev
10 10 # debug_tch
11 11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
12 12 # debug_watchdog
13 13 CONFIG += console verbose lpp_dpu_destid
14 14 CONFIG -= qt
15 15
16 16 include(./sparc.pri)
17 17
18 18 # flight software version
19 19 SWVERSION=-1-0
20 20 DEFINES += SW_VERSION_N1=3 # major
21 21 DEFINES += SW_VERSION_N2=0 # minor
22 22 DEFINES += SW_VERSION_N3=0 # patch
23 DEFINES += SW_VERSION_N4=19 # internal
23 DEFINES += SW_VERSION_N4=20 # internal
24 24
25 25 # <GCOV>
26 26 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
27 27 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
28 28 # </GCOV>
29 29
30 30 # <CHANGE BEFORE FLIGHT>
31 31 contains( CONFIG, lpp_dpu_destid ) {
32 32 DEFINES += LPP_DPU_DESTID
33 33 }
34 34 # </CHANGE BEFORE FLIGHT>
35 35
36 36 contains( CONFIG, debug_tch ) {
37 37 DEFINES += DEBUG_TCH
38 38 }
39 39 DEFINES += MSB_FIRST_TCH
40 40
41 41 contains( CONFIG, vhdl_dev ) {
42 42 DEFINES += VHDL_DEV
43 43 }
44 44
45 45 contains( CONFIG, verbose ) {
46 46 DEFINES += PRINT_MESSAGES_ON_CONSOLE
47 47 }
48 48
49 49 contains( CONFIG, debug_messages ) {
50 50 DEFINES += DEBUG_MESSAGES
51 51 }
52 52
53 53 contains( CONFIG, cpu_usage_report ) {
54 54 DEFINES += PRINT_TASK_STATISTICS
55 55 }
56 56
57 57 contains( CONFIG, stack_report ) {
58 58 DEFINES += PRINT_STACK_REPORT
59 59 }
60 60
61 61 contains( CONFIG, boot_messages ) {
62 62 DEFINES += BOOT_MESSAGES
63 63 }
64 64
65 65 contains( CONFIG, debug_watchdog ) {
66 66 DEFINES += DEBUG_WATCHDOG
67 67 }
68 68
69 69 #doxygen.target = doxygen
70 70 #doxygen.commands = doxygen ../doc/Doxyfile
71 71 #QMAKE_EXTRA_TARGETS += doxygen
72 72
73 73 TARGET = fsw
74 74
75 75 INCLUDEPATH += \
76 76 $${PWD}/../src \
77 77 $${PWD}/../header \
78 78 $${PWD}/../header/lfr_common_headers \
79 79 $${PWD}/../header/processing \
80 80 $${PWD}/../LFR_basic-parameters
81 81
82 82 SOURCES += \
83 83 ../src/wf_handler.c \
84 84 ../src/tc_handler.c \
85 85 ../src/fsw_misc.c \
86 86 ../src/fsw_init.c \
87 87 ../src/fsw_globals.c \
88 88 ../src/fsw_spacewire.c \
89 89 ../src/tc_load_dump_parameters.c \
90 90 ../src/tm_lfr_tc_exe.c \
91 91 ../src/tc_acceptance.c \
92 92 ../src/processing/fsw_processing.c \
93 93 ../src/processing/avf0_prc0.c \
94 94 ../src/processing/avf1_prc1.c \
95 95 ../src/processing/avf2_prc2.c \
96 96 ../src/lfr_cpu_usage_report.c \
97 97 ../LFR_basic-parameters/basic_parameters.c
98 98
99 99 HEADERS += \
100 100 ../header/wf_handler.h \
101 101 ../header/tc_handler.h \
102 102 ../header/grlib_regs.h \
103 103 ../header/fsw_misc.h \
104 104 ../header/fsw_init.h \
105 105 ../header/fsw_spacewire.h \
106 106 ../header/tc_load_dump_parameters.h \
107 107 ../header/tm_lfr_tc_exe.h \
108 108 ../header/tc_acceptance.h \
109 109 ../header/processing/fsw_processing.h \
110 110 ../header/processing/avf0_prc0.h \
111 111 ../header/processing/avf1_prc1.h \
112 112 ../header/processing/avf2_prc2.h \
113 113 ../header/fsw_params_wf_handler.h \
114 114 ../header/lfr_cpu_usage_report.h \
115 115 ../header/lfr_common_headers/ccsds_types.h \
116 116 ../header/lfr_common_headers/fsw_params.h \
117 117 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
118 118 ../header/lfr_common_headers/fsw_params_processing.h \
119 119 ../header/lfr_common_headers/TC_types.h \
120 120 ../header/lfr_common_headers/tm_byte_positions.h \
121 121 ../LFR_basic-parameters/basic_parameters.h \
122 122 ../LFR_basic-parameters/basic_parameters_params.h \
123 123 ../header/GscMemoryLPP.hpp
124 124
@@ -1,72 +1,72
1 1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 2 #define TC_LOAD_DUMP_PARAMETERS_H
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "wf_handler.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "fsw_misc.h"
11 11 #include "basic_parameters_params.h"
12 12 #include "avf0_prc0.h"
13 13
14 14 #define FLOAT_EQUAL_ZERO 0.001
15 15
16 16 extern unsigned short sequenceCounterParameterDump;
17 17 extern unsigned short sequenceCounters_TM_DUMP[];
18 18 extern float k_coeff_intercalib_f0_norm[ ];
19 19 extern float k_coeff_intercalib_f0_sbm[ ];
20 20 extern float k_coeff_intercalib_f1_norm[ ];
21 21 extern float k_coeff_intercalib_f1_sbm[ ];
22 22 extern float k_coeff_intercalib_f2[ ];
23 23
24 24 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
25 25 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
26 26 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
27 27 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
28 28 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
29 29 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
30 30 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
31 31 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
32 32 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
33 33
34 34 // NORMAL
35 int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
35 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
36 36 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
37 37 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
38 38 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
39 39 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
40 40 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
41 41 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
42 42
43 43 // BURST
44 44 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
45 45 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
46 46
47 47 // SBM1
48 48 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
49 49 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
50 50
51 51 // SBM2
52 52 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
53 53 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
54 54
55 55 // TC_LFR_UPDATE_INFO
56 56 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
57 57 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
58 58 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
59 59
60 60 // FBINS_MASK
61 61 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
62 62
63 63 // KCOEFFICIENTS
64 64 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
65 65 void copyFloatByChar( unsigned char *destination, unsigned char *source );
66 66
67 67 void init_parameter_dump( void );
68 68 void init_kcoefficients_dump( void );
69 69 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
70 70 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
71 71
72 72 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,1201 +1,1201
1 1 /** Functions to load and dump parameters in the LFR registers.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 7 * TC_LFR_LOAD_COMMON_PAR\n
8 8 * TC_LFR_LOAD_NORMAL_PAR\n
9 9 * TC_LFR_LOAD_BURST_PAR\n
10 10 * TC_LFR_LOAD_SBM1_PAR\n
11 11 * TC_LFR_LOAD_SBM2_PAR\n
12 12 *
13 13 */
14 14
15 15 #include "tc_load_dump_parameters.h"
16 16
17 17 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1;
18 18 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2;
19 19 ring_node kcoefficient_node_1;
20 20 ring_node kcoefficient_node_2;
21 21
22 22 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
23 23 {
24 24 /** This function updates the LFR registers with the incoming common parameters.
25 25 *
26 26 * @param TC points to the TeleCommand packet that is being processed
27 27 *
28 28 *
29 29 */
30 30
31 31 parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0];
32 32 parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1];
33 33 set_wfp_data_shaping( );
34 34 return LFR_SUCCESSFUL;
35 35 }
36 36
37 37 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
38 38 {
39 39 /** This function updates the LFR registers with the incoming normal parameters.
40 40 *
41 41 * @param TC points to the TeleCommand packet that is being processed
42 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 46 int result;
47 47 int flag;
48 48 rtems_status_code status;
49 49
50 50 flag = LFR_SUCCESSFUL;
51 51
52 52 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
53 53 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
54 54 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
55 55 flag = LFR_DEFAULT;
56 56 }
57 57
58 58 // CHECK THE PARAMETERS SET CONSISTENCY
59 59 if (flag == LFR_SUCCESSFUL)
60 60 {
61 flag = check_common_par_consistency( TC, queue_id );
61 flag = check_normal_par_consistency( TC, queue_id );
62 62 }
63 63
64 64 // SET THE PARAMETERS IF THEY ARE CONSISTENT
65 65 if (flag == LFR_SUCCESSFUL)
66 66 {
67 67 result = set_sy_lfr_n_swf_l( TC );
68 68 result = set_sy_lfr_n_swf_p( TC );
69 69 result = set_sy_lfr_n_bp_p0( TC );
70 70 result = set_sy_lfr_n_bp_p1( TC );
71 71 result = set_sy_lfr_n_asm_p( TC );
72 72 result = set_sy_lfr_n_cwf_long_f3( TC );
73 73 }
74 74
75 75 return flag;
76 76 }
77 77
78 78 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
79 79 {
80 80 /** This function updates the LFR registers with the incoming burst parameters.
81 81 *
82 82 * @param TC points to the TeleCommand packet that is being processed
83 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 87 int flag;
88 88 rtems_status_code status;
89 89 unsigned char sy_lfr_b_bp_p0;
90 90 unsigned char sy_lfr_b_bp_p1;
91 91 float aux;
92 92
93 93 flag = LFR_SUCCESSFUL;
94 94
95 95 if ( lfrCurrentMode == LFR_MODE_BURST ) {
96 96 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
97 97 flag = LFR_DEFAULT;
98 98 }
99 99
100 100 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
101 101 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
102 102
103 103 // sy_lfr_b_bp_p0 shall not be lower than its default value
104 104 if (flag == LFR_SUCCESSFUL)
105 105 {
106 106 if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 )
107 107 {
108 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 109 flag = WRONG_APP_DATA;
110 110 }
111 111 }
112 112 // sy_lfr_b_bp_p1 shall not be lower than its default value
113 113 if (flag == LFR_SUCCESSFUL)
114 114 {
115 115 if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 )
116 116 {
117 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 118 flag = WRONG_APP_DATA;
119 119 }
120 120 }
121 121 //****************************************************************
122 122 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
123 123 if (flag == LFR_SUCCESSFUL)
124 124 {
125 125 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
126 126 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
127 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 128 if (aux > FLOAT_EQUAL_ZERO)
129 129 {
130 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 131 flag = LFR_DEFAULT;
132 132 }
133 133 }
134 134
135 135 // SET THE PARAMETERS
136 136 if (flag == LFR_SUCCESSFUL)
137 137 {
138 138 flag = set_sy_lfr_b_bp_p0( TC );
139 139 flag = set_sy_lfr_b_bp_p1( TC );
140 140 }
141 141
142 142 return flag;
143 143 }
144 144
145 145 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
146 146 {
147 147 /** This function updates the LFR registers with the incoming sbm1 parameters.
148 148 *
149 149 * @param TC points to the TeleCommand packet that is being processed
150 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 154 int flag;
155 155 rtems_status_code status;
156 156 unsigned char sy_lfr_s1_bp_p0;
157 157 unsigned char sy_lfr_s1_bp_p1;
158 158 float aux;
159 159
160 160 flag = LFR_SUCCESSFUL;
161 161
162 162 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
163 163 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
164 164 flag = LFR_DEFAULT;
165 165 }
166 166
167 167 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
168 168 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
169 169
170 170 // sy_lfr_s1_bp_p0
171 171 if (flag == LFR_SUCCESSFUL)
172 172 {
173 173 if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 )
174 174 {
175 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 176 flag = WRONG_APP_DATA;
177 177 }
178 178 }
179 179 // sy_lfr_s1_bp_p1
180 180 if (flag == LFR_SUCCESSFUL)
181 181 {
182 182 if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 )
183 183 {
184 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 185 flag = WRONG_APP_DATA;
186 186 }
187 187 }
188 188 //******************************************************************
189 189 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
190 190 if (flag == LFR_SUCCESSFUL)
191 191 {
192 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 193 if (aux > FLOAT_EQUAL_ZERO)
194 194 {
195 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 196 flag = LFR_DEFAULT;
197 197 }
198 198 }
199 199
200 200 // SET THE PARAMETERS
201 201 if (flag == LFR_SUCCESSFUL)
202 202 {
203 203 flag = set_sy_lfr_s1_bp_p0( TC );
204 204 flag = set_sy_lfr_s1_bp_p1( TC );
205 205 }
206 206
207 207 return flag;
208 208 }
209 209
210 210 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
211 211 {
212 212 /** This function updates the LFR registers with the incoming sbm2 parameters.
213 213 *
214 214 * @param TC points to the TeleCommand packet that is being processed
215 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 219 int flag;
220 220 rtems_status_code status;
221 221 unsigned char sy_lfr_s2_bp_p0;
222 222 unsigned char sy_lfr_s2_bp_p1;
223 223 float aux;
224 224
225 225 flag = LFR_SUCCESSFUL;
226 226
227 227 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
228 228 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
229 229 flag = LFR_DEFAULT;
230 230 }
231 231
232 232 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
233 233 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
234 234
235 235 // sy_lfr_s2_bp_p0
236 236 if (flag == LFR_SUCCESSFUL)
237 237 {
238 238 if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 )
239 239 {
240 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 241 flag = WRONG_APP_DATA;
242 242 }
243 243 }
244 244 // sy_lfr_s2_bp_p1
245 245 if (flag == LFR_SUCCESSFUL)
246 246 {
247 247 if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 )
248 248 {
249 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 250 flag = WRONG_APP_DATA;
251 251 }
252 252 }
253 253 //******************************************************************
254 254 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
255 255 if (flag == LFR_SUCCESSFUL)
256 256 {
257 257 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
258 258 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
259 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 260 if (aux > FLOAT_EQUAL_ZERO)
261 261 {
262 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 263 flag = LFR_DEFAULT;
264 264 }
265 265 }
266 266
267 267 // SET THE PARAMETERS
268 268 if (flag == LFR_SUCCESSFUL)
269 269 {
270 270 flag = set_sy_lfr_s2_bp_p0( TC );
271 271 flag = set_sy_lfr_s2_bp_p1( TC );
272 272 }
273 273
274 274 return flag;
275 275 }
276 276
277 277 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
278 278 {
279 279 /** This function updates the LFR registers with the incoming sbm2 parameters.
280 280 *
281 281 * @param TC points to the TeleCommand packet that is being processed
282 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 286 int flag;
287 287
288 288 flag = LFR_DEFAULT;
289 289
290 290 flag = set_sy_lfr_kcoeff( TC, queue_id );
291 291
292 292 return flag;
293 293 }
294 294
295 295 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
296 296 {
297 297 /** This function updates the LFR registers with the incoming sbm2 parameters.
298 298 *
299 299 * @param TC points to the TeleCommand packet that is being processed
300 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 304 int flag;
305 305
306 306 flag = LFR_DEFAULT;
307 307
308 308 flag = set_sy_lfr_fbins( TC );
309 309
310 310 return flag;
311 311 }
312 312
313 313 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
314 314 {
315 315 /** This function updates the LFR registers with the incoming sbm2 parameters.
316 316 *
317 317 * @param TC points to the TeleCommand packet that is being processed
318 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 322 unsigned int address;
323 323 rtems_status_code status;
324 324 unsigned int freq;
325 325 unsigned int bin;
326 326 unsigned int coeff;
327 327 unsigned char *kCoeffPtr;
328 328 unsigned char *kCoeffDumpPtr;
329 329
330 330 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
331 331 // F0 => 11 bins
332 332 // F1 => 13 bins
333 333 // F2 => 12 bins
334 334 // 36 bins to dump in two packets (30 bins max per packet)
335 335
336 336 //*********
337 337 // PACKET 1
338 338 // 11 F0 bins, 13 F1 bins and 6 F2 bins
339 339 kcoefficients_dump_1.destinationID = TC->sourceID;
340 340 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
341 341 for( freq=0;
342 342 freq<NB_BINS_COMPRESSED_SM_F0;
343 343 freq++ )
344 344 {
345 345 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
346 346 bin = freq;
347 347 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
348 348 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
349 349 {
350 350 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
351 351 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
352 352 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
353 353 }
354 354 }
355 355 for( freq=NB_BINS_COMPRESSED_SM_F0;
356 356 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
357 357 freq++ )
358 358 {
359 359 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
360 360 bin = freq - NB_BINS_COMPRESSED_SM_F0;
361 361 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
362 362 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
363 363 {
364 364 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
365 365 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
366 366 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
367 367 }
368 368 }
369 369 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
370 370 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
371 371 freq++ )
372 372 {
373 373 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
374 374 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
375 375 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
376 376 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
377 377 {
378 378 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
379 379 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
380 380 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
381 381 }
382 382 }
383 383 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
384 384 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
385 385 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
386 386 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
387 387 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
388 388 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
389 389 // SEND DATA
390 390 kcoefficient_node_1.status = 1;
391 391 address = (unsigned int) &kcoefficient_node_1;
392 392 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
393 393 if (status != RTEMS_SUCCESSFUL) {
394 394 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
395 395 }
396 396
397 397 //********
398 398 // PACKET 2
399 399 // 6 F2 bins
400 400 kcoefficients_dump_2.destinationID = TC->sourceID;
401 401 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
402 402 for( freq=0; freq<6; freq++ )
403 403 {
404 404 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
405 405 bin = freq + 6;
406 406 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
407 407 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
408 408 {
409 409 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
410 410 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
411 411 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
412 412 }
413 413 }
414 414 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
415 415 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
416 416 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
417 417 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
418 418 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
419 419 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
420 420 // SEND DATA
421 421 kcoefficient_node_2.status = 1;
422 422 address = (unsigned int) &kcoefficient_node_2;
423 423 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
424 424 if (status != RTEMS_SUCCESSFUL) {
425 425 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
426 426 }
427 427
428 428 return status;
429 429 }
430 430
431 431 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
432 432 {
433 433 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
434 434 *
435 435 * @param queue_id is the id of the queue which handles TM related to this execution step.
436 436 *
437 437 * @return RTEMS directive status codes:
438 438 * - RTEMS_SUCCESSFUL - message sent successfully
439 439 * - RTEMS_INVALID_ID - invalid queue id
440 440 * - RTEMS_INVALID_SIZE - invalid message size
441 441 * - RTEMS_INVALID_ADDRESS - buffer is NULL
442 442 * - RTEMS_UNSATISFIED - out of message buffers
443 443 * - RTEMS_TOO_MANY - queue s limit has been reached
444 444 *
445 445 */
446 446
447 447 int status;
448 448
449 449 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
450 450 parameter_dump_packet.destinationID = TC->sourceID;
451 451
452 452 // UPDATE TIME
453 453 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
454 454 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
455 455 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
456 456 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
457 457 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
458 458 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
459 459 // SEND DATA
460 460 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
461 461 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
462 462 if (status != RTEMS_SUCCESSFUL) {
463 463 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
464 464 }
465 465
466 466 return status;
467 467 }
468 468
469 469 //***********************
470 470 // NORMAL MODE PARAMETERS
471 471
472 int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
472 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
473 473 {
474 474 unsigned char msb;
475 475 unsigned char lsb;
476 476 int flag;
477 477 float aux;
478 478 rtems_status_code status;
479 479
480 480 unsigned int sy_lfr_n_swf_l;
481 481 unsigned int sy_lfr_n_swf_p;
482 482 unsigned int sy_lfr_n_asm_p;
483 483 unsigned char sy_lfr_n_bp_p0;
484 484 unsigned char sy_lfr_n_bp_p1;
485 485 unsigned char sy_lfr_n_cwf_long_f3;
486 486
487 487 flag = LFR_SUCCESSFUL;
488 488
489 489 //***************
490 490 // get parameters
491 491 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
492 492 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
493 493 sy_lfr_n_swf_l = msb * 256 + lsb;
494 494
495 495 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
496 496 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
497 497 sy_lfr_n_swf_p = msb * 256 + lsb;
498 498
499 499 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
500 500 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
501 501 sy_lfr_n_asm_p = msb * 256 + lsb;
502 502
503 503 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
504 504
505 505 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
506 506
507 507 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
508 508
509 509 //******************
510 510 // check consistency
511 511 // sy_lfr_n_swf_l
512 512 if (sy_lfr_n_swf_l != 2048)
513 513 {
514 514 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
515 515 flag = WRONG_APP_DATA;
516 516 }
517 517 // sy_lfr_n_swf_p
518 518 if (flag == LFR_SUCCESSFUL)
519 519 {
520 if ( sy_lfr_n_swf_p < 16 )
520 if ( sy_lfr_n_swf_p < 22 )
521 521 {
522 522 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
523 523 flag = WRONG_APP_DATA;
524 524 }
525 525 }
526 526 // sy_lfr_n_bp_p0
527 527 if (flag == LFR_SUCCESSFUL)
528 528 {
529 529 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
530 530 {
531 531 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
532 532 flag = WRONG_APP_DATA;
533 533 }
534 534 }
535 535 // sy_lfr_n_asm_p
536 536 if (flag == LFR_SUCCESSFUL)
537 537 {
538 538 if (sy_lfr_n_asm_p == 0)
539 539 {
540 540 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
541 541 flag = WRONG_APP_DATA;
542 542 }
543 543 }
544 544 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
545 545 if (flag == LFR_SUCCESSFUL)
546 546 {
547 547 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
548 548 if (aux > FLOAT_EQUAL_ZERO)
549 549 {
550 550 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
551 551 flag = WRONG_APP_DATA;
552 552 }
553 553 }
554 554 // sy_lfr_n_bp_p1
555 555 if (flag == LFR_SUCCESSFUL)
556 556 {
557 557 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
558 558 {
559 559 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
560 560 flag = WRONG_APP_DATA;
561 561 }
562 562 }
563 563 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
564 564 if (flag == LFR_SUCCESSFUL)
565 565 {
566 566 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
567 567 if (aux > FLOAT_EQUAL_ZERO)
568 568 {
569 569 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
570 570 flag = LFR_DEFAULT;
571 571 }
572 572 }
573 573 // sy_lfr_n_cwf_long_f3
574 574
575 575 return flag;
576 576 }
577 577
578 578 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
579 579 {
580 580 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
581 581 *
582 582 * @param TC points to the TeleCommand packet that is being processed
583 583 * @param queue_id is the id of the queue which handles TM related to this execution step
584 584 *
585 585 */
586 586
587 587 int result;
588 588
589 589 result = LFR_SUCCESSFUL;
590 590
591 591 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
592 592 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
593 593
594 594 return result;
595 595 }
596 596
597 597 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
598 598 {
599 599 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
600 600 *
601 601 * @param TC points to the TeleCommand packet that is being processed
602 602 * @param queue_id is the id of the queue which handles TM related to this execution step
603 603 *
604 604 */
605 605
606 606 int result;
607 607
608 608 result = LFR_SUCCESSFUL;
609 609
610 610 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
611 611 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
612 612
613 613 return result;
614 614 }
615 615
616 616 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
617 617 {
618 618 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
619 619 *
620 620 * @param TC points to the TeleCommand packet that is being processed
621 621 * @param queue_id is the id of the queue which handles TM related to this execution step
622 622 *
623 623 */
624 624
625 625 int result;
626 626
627 627 result = LFR_SUCCESSFUL;
628 628
629 629 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
630 630 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
631 631
632 632 return result;
633 633 }
634 634
635 635 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
636 636 {
637 637 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
638 638 *
639 639 * @param TC points to the TeleCommand packet that is being processed
640 640 * @param queue_id is the id of the queue which handles TM related to this execution step
641 641 *
642 642 */
643 643
644 644 int status;
645 645
646 646 status = LFR_SUCCESSFUL;
647 647
648 648 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
649 649
650 650 return status;
651 651 }
652 652
653 653 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
654 654 {
655 655 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
656 656 *
657 657 * @param TC points to the TeleCommand packet that is being processed
658 658 * @param queue_id is the id of the queue which handles TM related to this execution step
659 659 *
660 660 */
661 661
662 662 int status;
663 663
664 664 status = LFR_SUCCESSFUL;
665 665
666 666 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
667 667
668 668 return status;
669 669 }
670 670
671 671 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
672 672 {
673 673 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
674 674 *
675 675 * @param TC points to the TeleCommand packet that is being processed
676 676 * @param queue_id is the id of the queue which handles TM related to this execution step
677 677 *
678 678 */
679 679
680 680 int status;
681 681
682 682 status = LFR_SUCCESSFUL;
683 683
684 684 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
685 685
686 686 return status;
687 687 }
688 688
689 689 //**********************
690 690 // BURST MODE PARAMETERS
691 691 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
692 692 {