@@ -1,2 +1,2 | |||||
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
2 | f97721719ddb7e088956d5fd3cffb0f9587a041b header/lfr_common_headers |
|
2 | e01ac8bd125a79a7af38b0e3ba0330f5be1a3c92 header/lfr_common_headers |
@@ -1,120 +1,122 | |||||
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H | |
2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
2 | #define TC_LOAD_DUMP_PARAMETERS_H | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 |
|
6 | |||
7 | #include "fsw_params.h" |
|
7 | #include "fsw_params.h" | |
8 | #include "wf_handler.h" |
|
8 | #include "wf_handler.h" | |
9 | #include "tm_lfr_tc_exe.h" |
|
9 | #include "tm_lfr_tc_exe.h" | |
10 | #include "fsw_misc.h" |
|
10 | #include "fsw_misc.h" | |
11 | #include "basic_parameters_params.h" |
|
11 | #include "basic_parameters_params.h" | |
12 | #include "avf0_prc0.h" |
|
12 | #include "avf0_prc0.h" | |
13 |
|
13 | |||
14 | #define FLOAT_EQUAL_ZERO 0.001 |
|
14 | #define FLOAT_EQUAL_ZERO 0.001 | |
15 | #define NB_BINS_TO_REMOVE 3 |
|
15 | #define NB_BINS_TO_REMOVE 3 | |
16 | #define FI_INTERVAL_COEFF 0.285 |
|
16 | #define FI_INTERVAL_COEFF 0.285 | |
17 | #define BIN_MIN 0 |
|
17 | #define BIN_MIN 0 | |
18 | #define BIN_MAX 127 |
|
18 | #define BIN_MAX 127 | |
19 | #define DELTAF_F0 96. |
|
19 | #define DELTAF_F0 96. | |
20 | #define DELTAF_F1 16. |
|
20 | #define DELTAF_F1 16. | |
21 | #define DELTAF_F2 1. |
|
21 | #define DELTAF_F2 1. | |
22 | #define DELTAF_DIV 2. |
|
22 | #define DELTAF_DIV 2. | |
23 |
|
23 | |||
24 | #define BIT_RW1_F1 0x80 |
|
24 | #define BIT_RW1_F1 0x80 | |
25 | #define BIT_RW1_F2 0x40 |
|
25 | #define BIT_RW1_F2 0x40 | |
26 | #define BIT_RW2_F1 0x20 |
|
26 | #define BIT_RW2_F1 0x20 | |
27 | #define BIT_RW2_F2 0x10 |
|
27 | #define BIT_RW2_F2 0x10 | |
28 | #define BIT_RW3_F1 0x08 |
|
28 | #define BIT_RW3_F1 0x08 | |
29 | #define BIT_RW3_F2 0x04 |
|
29 | #define BIT_RW3_F2 0x04 | |
30 | #define BIT_RW4_F1 0x02 |
|
30 | #define BIT_RW4_F1 0x02 | |
31 | #define BIT_RW4_F2 0x01 |
|
31 | #define BIT_RW4_F2 0x01 | |
32 |
|
32 | |||
33 | #define WHEEL_1 1 |
|
33 | #define WHEEL_1 1 | |
34 | #define WHEEL_2 2 |
|
34 | #define WHEEL_2 2 | |
35 | #define WHEEL_3 3 |
|
35 | #define WHEEL_3 3 | |
36 | #define WHEEL_4 4 |
|
36 | #define WHEEL_4 4 | |
37 | #define FREQ_1 1 |
|
37 | #define FREQ_1 1 | |
38 | #define FREQ_2 2 |
|
38 | #define FREQ_2 2 | |
39 | #define FREQ_3 3 |
|
39 | #define FREQ_3 3 | |
40 | #define FREQ_4 4 |
|
40 | #define FREQ_4 4 | |
41 | #define FLAG_OFFSET_WHEELS_1_3 8 |
|
41 | #define FLAG_OFFSET_WHEELS_1_3 8 | |
42 | #define FLAG_OFFSET_WHEELS_2_4 4 |
|
42 | #define FLAG_OFFSET_WHEELS_2_4 4 | |
43 |
|
43 | |||
44 | #define FLAG_NAN 0 // Not A NUMBER |
|
44 | #define FLAG_NAN 0 // Not A NUMBER | |
45 | #define FLAG_IAN 1 // Is A Number |
|
45 | #define FLAG_IAN 1 // Is A Number | |
46 |
|
46 | |||
47 | #define SBM_KCOEFF_PER_NORM_KCOEFF 2 |
|
47 | #define SBM_KCOEFF_PER_NORM_KCOEFF 2 | |
48 |
|
48 | |||
49 | extern unsigned short sequenceCounterParameterDump; |
|
49 | extern unsigned short sequenceCounterParameterDump; | |
50 | extern unsigned short sequenceCounters_TM_DUMP[]; |
|
50 | extern unsigned short sequenceCounters_TM_DUMP[]; | |
51 | extern float k_coeff_intercalib_f0_norm[ ]; |
|
51 | extern float k_coeff_intercalib_f0_norm[ ]; | |
52 | extern float k_coeff_intercalib_f0_sbm[ ]; |
|
52 | extern float k_coeff_intercalib_f0_sbm[ ]; | |
53 | extern float k_coeff_intercalib_f1_norm[ ]; |
|
53 | extern float k_coeff_intercalib_f1_norm[ ]; | |
54 | extern float k_coeff_intercalib_f1_sbm[ ]; |
|
54 | extern float k_coeff_intercalib_f1_sbm[ ]; | |
55 | extern float k_coeff_intercalib_f2[ ]; |
|
55 | extern float k_coeff_intercalib_f2[ ]; | |
56 | extern fbins_masks_t fbins_masks; |
|
56 | extern fbins_masks_t fbins_masks; | |
57 |
|
57 | |||
58 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
58 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); | |
59 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
59 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
60 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
60 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
61 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
61 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
62 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
62 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
63 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
63 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
64 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
64 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
65 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
65 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
66 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
66 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
67 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
67 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
68 |
|
68 | |||
69 | // NORMAL |
|
69 | // NORMAL | |
70 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
70 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
71 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
71 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); | |
72 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
72 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); | |
73 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
73 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); | |
74 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
74 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
75 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
75 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
76 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
76 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); | |
77 |
|
77 | |||
78 | // BURST |
|
78 | // BURST | |
79 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
79 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
80 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
80 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
81 |
|
81 | |||
82 | // SBM1 |
|
82 | // SBM1 | |
83 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
83 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
84 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
84 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
85 |
|
85 | |||
86 | // SBM2 |
|
86 | // SBM2 | |
87 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
87 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
88 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
88 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
89 |
|
89 | |||
90 | // TC_LFR_UPDATE_INFO |
|
90 | // TC_LFR_UPDATE_INFO | |
91 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
91 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); | |
92 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
92 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); | |
93 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); |
|
93 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); | |
94 | void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value ); |
|
94 | void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value ); | |
95 | void set_hk_lfr_sc_rw_f_flags( void ); |
|
95 | void set_hk_lfr_sc_rw_f_flags( void ); | |
96 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ); |
|
96 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ); | |
97 | void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k ); |
|
97 | void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k ); | |
98 | void build_sy_lfr_rw_mask( unsigned int channel ); |
|
98 | void build_sy_lfr_rw_mask( unsigned int channel ); | |
99 | void build_sy_lfr_rw_masks(); |
|
99 | void build_sy_lfr_rw_masks(); | |
100 | void merge_fbins_masks( void ); |
|
100 | void merge_fbins_masks( void ); | |
101 |
|
101 | |||
102 | // FBINS_MASK |
|
102 | // FBINS_MASK | |
103 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); |
|
103 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); | |
104 |
|
104 | |||
105 | // TC_LFR_LOAD_PARS_FILTER_PAR |
|
105 | // TC_LFR_LOAD_PARS_FILTER_PAR | |
|
106 | int check_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value ); | |||
|
107 | int check_all_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int *pos, float*value ); | |||
106 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
108 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
107 |
|
109 | |||
108 | // KCOEFFICIENTS |
|
110 | // KCOEFFICIENTS | |
109 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); |
|
111 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); | |
110 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); |
|
112 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); | |
111 | void copyInt32ByChar( unsigned char *destination, unsigned char *source ); |
|
113 | void copyInt32ByChar( unsigned char *destination, unsigned char *source ); | |
112 | void copyInt16ByChar( unsigned char *destination, unsigned char *source ); |
|
114 | void copyInt16ByChar( unsigned char *destination, unsigned char *source ); | |
113 | void floatToChar( float value, unsigned char* ptr); |
|
115 | void floatToChar( float value, unsigned char* ptr); | |
114 |
|
116 | |||
115 | void init_parameter_dump( void ); |
|
117 | void init_parameter_dump( void ); | |
116 | void init_kcoefficients_dump( void ); |
|
118 | void init_kcoefficients_dump( void ); | |
117 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); |
|
119 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); | |
118 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); |
|
120 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); | |
119 |
|
121 | |||
120 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
|
122 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,107 +1,107 | |||||
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" OFF) |
|
54 | option(FSW_verbose "Enable verbose LFR" OFF) | |
55 | option(FSW_boot_messages "Enable LFR boot messages" OFF) |
|
55 | option(FSW_boot_messages "Enable LFR boot messages" OFF) | |
56 | option(FSW_debug_messages "Enable LFR debug messages" OFF) |
|
56 | option(FSW_debug_messages "Enable LFR debug messages" OFF) | |
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 "2" CACHE STRING "Choose N2 FSW Version." FORCE) |
|
65 | set(SW_VERSION_N2 "2" 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 " |
|
67 | set(SW_VERSION_N4 "3" CACHE STRING "Choose N4 FSW Version." FORCE) | |
68 |
|
68 | |||
69 | if(FSW_verbose) |
|
69 | if(FSW_verbose) | |
70 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) |
|
70 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) | |
71 | endif() |
|
71 | endif() | |
72 | if(FSW_boot_messages) |
|
72 | if(FSW_boot_messages) | |
73 | add_definitions(-DBOOT_MESSAGES) |
|
73 | add_definitions(-DBOOT_MESSAGES) | |
74 | endif() |
|
74 | endif() | |
75 | if(FSW_debug_messages) |
|
75 | if(FSW_debug_messages) | |
76 | add_definitions(-DDEBUG_MESSAGES) |
|
76 | add_definitions(-DDEBUG_MESSAGES) | |
77 | endif() |
|
77 | endif() | |
78 | if(FSW_cpu_usage_report) |
|
78 | if(FSW_cpu_usage_report) | |
79 | add_definitions(-DPRINT_TASK_STATISTICS) |
|
79 | add_definitions(-DPRINT_TASK_STATISTICS) | |
80 | endif() |
|
80 | endif() | |
81 | if(FSW_stack_report) |
|
81 | if(FSW_stack_report) | |
82 | add_definitions(-DPRINT_STACK_REPORT) |
|
82 | add_definitions(-DPRINT_STACK_REPORT) | |
83 | endif() |
|
83 | endif() | |
84 | if(FSW_vhdl_dev) |
|
84 | if(FSW_vhdl_dev) | |
85 | add_definitions(-DVHDL_DEV) |
|
85 | add_definitions(-DVHDL_DEV) | |
86 | endif() |
|
86 | endif() | |
87 | if(FSW_lpp_dpu_destid) |
|
87 | if(FSW_lpp_dpu_destid) | |
88 | add_definitions(-DLPP_DPU_DESTID) |
|
88 | add_definitions(-DLPP_DPU_DESTID) | |
89 | endif() |
|
89 | endif() | |
90 | if(FSW_debug_watchdog) |
|
90 | if(FSW_debug_watchdog) | |
91 | add_definitions(-DDEBUG_WATCHDOG) |
|
91 | add_definitions(-DDEBUG_WATCHDOG) | |
92 | endif() |
|
92 | endif() | |
93 | if(FSW_debug_tch) |
|
93 | if(FSW_debug_tch) | |
94 | add_definitions(-DDEBUG_TCH) |
|
94 | add_definitions(-DDEBUG_TCH) | |
95 | endif() |
|
95 | endif() | |
96 |
|
96 | |||
97 | add_definitions(-DMSB_FIRST_TCH) |
|
97 | add_definitions(-DMSB_FIRST_TCH) | |
98 |
|
98 | |||
99 | add_definitions(-DSWVERSION=-1-0) |
|
99 | add_definitions(-DSWVERSION=-1-0) | |
100 | add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1}) |
|
100 | add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1}) | |
101 | add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2}) |
|
101 | add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2}) | |
102 | add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) |
|
102 | add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) | |
103 | add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) |
|
103 | add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) | |
104 |
|
104 | |||
105 | add_executable(fsw ${SOURCES}) |
|
105 | add_executable(fsw ${SOURCES}) | |
106 | add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE) |
|
106 | add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE) | |
107 |
|
107 |
@@ -1,830 +1,817 | |||||
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 = 0; |
|
14 | unsigned int nb_sm_f0 = 0; | |
15 | unsigned int nb_sm_f0_aux_f1= 0; |
|
15 | unsigned int nb_sm_f0_aux_f1= 0; | |
16 | unsigned int nb_sm_f1 = 0; |
|
16 | unsigned int nb_sm_f1 = 0; | |
17 | unsigned int nb_sm_f0_aux_f2= 0; |
|
17 | unsigned int nb_sm_f0_aux_f2= 0; | |
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 ] = {0}; |
|
28 | ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ] = {0}; | |
29 | ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ] = {0}; |
|
29 | ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ] = {0}; | |
30 | ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ] = {0}; |
|
30 | ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ] = {0}; | |
31 | ring_node *current_ring_node_sm_f0 = NULL; |
|
31 | ring_node *current_ring_node_sm_f0 = NULL; | |
32 | ring_node *current_ring_node_sm_f1 = NULL; |
|
32 | ring_node *current_ring_node_sm_f1 = NULL; | |
33 | ring_node *current_ring_node_sm_f2 = NULL; |
|
33 | ring_node *current_ring_node_sm_f2 = NULL; | |
34 | ring_node *ring_node_for_averaging_sm_f0= NULL; |
|
34 | ring_node *ring_node_for_averaging_sm_f0= NULL; | |
35 | ring_node *ring_node_for_averaging_sm_f1= NULL; |
|
35 | ring_node *ring_node_for_averaging_sm_f1= NULL; | |
36 | ring_node *ring_node_for_averaging_sm_f2= NULL; |
|
36 | ring_node *ring_node_for_averaging_sm_f2= NULL; | |
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 CHANNELF0: |
|
45 | case CHANNELF0: | |
46 | node = ring_node_for_averaging_sm_f0; |
|
46 | node = ring_node_for_averaging_sm_f0; | |
47 | break; |
|
47 | break; | |
48 | case CHANNELF1: |
|
48 | case CHANNELF1: | |
49 | node = ring_node_for_averaging_sm_f1; |
|
49 | node = ring_node_for_averaging_sm_f1; | |
50 | break; |
|
50 | break; | |
51 | case CHANNELF2: |
|
51 | case CHANNELF2: | |
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 & BITS_STATUS_F0); // [0011] get the status_ready_matrix_f0_x bits |
|
70 | status = (unsigned char) (statusReg & BITS_STATUS_F0); // [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 BIT_READY_0_1: |
|
76 | case BIT_READY_0_1: | |
77 | // UNEXPECTED VALUE |
|
77 | // UNEXPECTED VALUE | |
78 | spectral_matrix_regs->status = BIT_READY_0_1; // [0011] |
|
78 | spectral_matrix_regs->status = BIT_READY_0_1; // [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 BIT_READY_0: |
|
81 | case BIT_READY_0: | |
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_F1) |
|
89 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0_F1) | |
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 = BIT_READY_0; // [0000 0001] |
|
98 | spectral_matrix_regs->status = BIT_READY_0; // [0000 0001] | |
99 | break; |
|
99 | break; | |
100 | case BIT_READY_1: |
|
100 | case BIT_READY_1: | |
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_F1) |
|
108 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0_F1) | |
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 = BIT_READY_1; // [0000 0010] |
|
117 | spectral_matrix_regs->status = BIT_READY_1; // [0000 0010] | |
118 | break; |
|
118 | break; | |
119 | default: |
|
119 | default: | |
120 | break; |
|
120 | break; | |
121 | } |
|
121 | } | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | void spectral_matrices_isr_f1( int statusReg ) |
|
124 | void spectral_matrices_isr_f1( int statusReg ) | |
125 | { |
|
125 | { | |
126 | rtems_status_code status_code; |
|
126 | rtems_status_code status_code; | |
127 | unsigned char status; |
|
127 | unsigned char status; | |
128 | ring_node *full_ring_node; |
|
128 | ring_node *full_ring_node; | |
129 |
|
129 | |||
130 | status = (unsigned char) ((statusReg & BITS_STATUS_F1) >> SHIFT_2_BITS); // [1100] get the status_ready_matrix_f1_x bits |
|
130 | status = (unsigned char) ((statusReg & BITS_STATUS_F1) >> SHIFT_2_BITS); // [1100] get the status_ready_matrix_f1_x bits | |
131 |
|
131 | |||
132 | switch(status) |
|
132 | switch(status) | |
133 | { |
|
133 | { | |
134 | case 0: |
|
134 | case 0: | |
135 | break; |
|
135 | break; | |
136 | case BIT_READY_0_1: |
|
136 | case BIT_READY_0_1: | |
137 | // UNEXPECTED VALUE |
|
137 | // UNEXPECTED VALUE | |
138 | spectral_matrix_regs->status = BITS_STATUS_F1; // [1100] |
|
138 | spectral_matrix_regs->status = BITS_STATUS_F1; // [1100] | |
139 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
139 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
140 | break; |
|
140 | break; | |
141 | case BIT_READY_0: |
|
141 | case BIT_READY_0: | |
142 | full_ring_node = current_ring_node_sm_f1->previous; |
|
142 | full_ring_node = current_ring_node_sm_f1->previous; | |
143 | full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time; |
|
143 | full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time; | |
144 | full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time; |
|
144 | full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time; | |
145 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
145 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; | |
146 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; |
|
146 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; | |
147 | // if there are enough ring nodes ready, wake up an AVFx task |
|
147 | // if there are enough ring nodes ready, wake up an AVFx task | |
148 | nb_sm_f1 = nb_sm_f1 + 1; |
|
148 | nb_sm_f1 = nb_sm_f1 + 1; | |
149 | if (nb_sm_f1 == NB_SM_BEFORE_AVF0_F1) |
|
149 | if (nb_sm_f1 == NB_SM_BEFORE_AVF0_F1) | |
150 | { |
|
150 | { | |
151 | ring_node_for_averaging_sm_f1 = full_ring_node; |
|
151 | ring_node_for_averaging_sm_f1 = full_ring_node; | |
152 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
152 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
153 | { |
|
153 | { | |
154 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
154 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
155 | } |
|
155 | } | |
156 | nb_sm_f1 = 0; |
|
156 | nb_sm_f1 = 0; | |
157 | } |
|
157 | } | |
158 | spectral_matrix_regs->status = BIT_STATUS_F1_0; // [0000 0100] |
|
158 | spectral_matrix_regs->status = BIT_STATUS_F1_0; // [0000 0100] | |
159 | break; |
|
159 | break; | |
160 | case BIT_READY_1: |
|
160 | case BIT_READY_1: | |
161 | full_ring_node = current_ring_node_sm_f1->previous; |
|
161 | full_ring_node = current_ring_node_sm_f1->previous; | |
162 | full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time; |
|
162 | full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time; | |
163 | full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time; |
|
163 | full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time; | |
164 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
164 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; | |
165 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
165 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; | |
166 | // if there are enough ring nodes ready, wake up an AVFx task |
|
166 | // if there are enough ring nodes ready, wake up an AVFx task | |
167 | nb_sm_f1 = nb_sm_f1 + 1; |
|
167 | nb_sm_f1 = nb_sm_f1 + 1; | |
168 | if (nb_sm_f1 == NB_SM_BEFORE_AVF0_F1) |
|
168 | if (nb_sm_f1 == NB_SM_BEFORE_AVF0_F1) | |
169 | { |
|
169 | { | |
170 | ring_node_for_averaging_sm_f1 = full_ring_node; |
|
170 | ring_node_for_averaging_sm_f1 = full_ring_node; | |
171 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
171 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
172 | { |
|
172 | { | |
173 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
173 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
174 | } |
|
174 | } | |
175 | nb_sm_f1 = 0; |
|
175 | nb_sm_f1 = 0; | |
176 | } |
|
176 | } | |
177 | spectral_matrix_regs->status = BIT_STATUS_F1_1; // [1000 0000] |
|
177 | spectral_matrix_regs->status = BIT_STATUS_F1_1; // [1000 0000] | |
178 | break; |
|
178 | break; | |
179 | default: |
|
179 | default: | |
180 | break; |
|
180 | break; | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | void spectral_matrices_isr_f2( int statusReg ) |
|
184 | void spectral_matrices_isr_f2( int statusReg ) | |
185 | { |
|
185 | { | |
186 | unsigned char status; |
|
186 | unsigned char status; | |
187 | rtems_status_code status_code; |
|
187 | rtems_status_code status_code; | |
188 |
|
188 | |||
189 | status = (unsigned char) ((statusReg & BITS_STATUS_F2) >> SHIFT_4_BITS); // [0011 0000] get the status_ready_matrix_f2_x bits |
|
189 | status = (unsigned char) ((statusReg & BITS_STATUS_F2) >> SHIFT_4_BITS); // [0011 0000] get the status_ready_matrix_f2_x bits | |
190 |
|
190 | |||
191 | switch(status) |
|
191 | switch(status) | |
192 | { |
|
192 | { | |
193 | case 0: |
|
193 | case 0: | |
194 | break; |
|
194 | break; | |
195 | case BIT_READY_0_1: |
|
195 | case BIT_READY_0_1: | |
196 | // UNEXPECTED VALUE |
|
196 | // UNEXPECTED VALUE | |
197 | spectral_matrix_regs->status = BITS_STATUS_F2; // [0011 0000] |
|
197 | spectral_matrix_regs->status = BITS_STATUS_F2; // [0011 0000] | |
198 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
198 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
199 | break; |
|
199 | break; | |
200 | case BIT_READY_0: |
|
200 | case BIT_READY_0: | |
201 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; |
|
201 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; | |
202 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
202 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; | |
203 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; |
|
203 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; | |
204 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; |
|
204 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; | |
205 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; |
|
205 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; | |
206 | spectral_matrix_regs->status = BIT_STATUS_F2_0; // [0001 0000] |
|
206 | spectral_matrix_regs->status = BIT_STATUS_F2_0; // [0001 0000] | |
207 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
207 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
208 | { |
|
208 | { | |
209 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
209 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
210 | } |
|
210 | } | |
211 | break; |
|
211 | break; | |
212 | case BIT_READY_1: |
|
212 | case BIT_READY_1: | |
213 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; |
|
213 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; | |
214 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
214 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; | |
215 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; |
|
215 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; | |
216 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; |
|
216 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; | |
217 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
217 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; | |
218 | spectral_matrix_regs->status = BIT_STATUS_F2_1; // [0010 0000] |
|
218 | spectral_matrix_regs->status = BIT_STATUS_F2_1; // [0010 0000] | |
219 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
219 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
220 | { |
|
220 | { | |
221 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
221 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
222 | } |
|
222 | } | |
223 | break; |
|
223 | break; | |
224 | default: |
|
224 | default: | |
225 | break; |
|
225 | break; | |
226 | } |
|
226 | } | |
227 | } |
|
227 | } | |
228 |
|
228 | |||
229 | void spectral_matrix_isr_error_handler( int statusReg ) |
|
229 | void spectral_matrix_isr_error_handler( int statusReg ) | |
230 | { |
|
230 | { | |
231 | // STATUS REGISTER |
|
231 | // STATUS REGISTER | |
232 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) |
|
232 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) | |
233 | // 10 9 8 |
|
233 | // 10 9 8 | |
234 | // buffer_full ** [bad_component_err] ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 |
|
234 | // buffer_full ** [bad_component_err] ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 | |
235 | // 7 6 5 4 3 2 1 0 |
|
235 | // 7 6 5 4 3 2 1 0 | |
236 | // [bad_component_err] not defined in the last version of the VHDL code |
|
236 | // [bad_component_err] not defined in the last version of the VHDL code | |
237 |
|
237 | |||
238 | rtems_status_code status_code; |
|
238 | rtems_status_code status_code; | |
239 |
|
239 | |||
240 | //*************************************************** |
|
240 | //*************************************************** | |
241 | // the ASM status register is copied in the HK packet |
|
241 | // the ASM status register is copied in the HK packet | |
242 | housekeeping_packet.hk_lfr_vhdl_aa_sm = (unsigned char) ((statusReg & BITS_HK_AA_SM) >> SHIFT_7_BITS); // [0111 1000 0000] |
|
242 | housekeeping_packet.hk_lfr_vhdl_aa_sm = (unsigned char) ((statusReg & BITS_HK_AA_SM) >> SHIFT_7_BITS); // [0111 1000 0000] | |
243 |
|
243 | |||
244 | if (statusReg & BITS_SM_ERR) // [0111 1100 0000] |
|
244 | if (statusReg & BITS_SM_ERR) // [0111 1100 0000] | |
245 | { |
|
245 | { | |
246 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); |
|
246 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
247 | } |
|
247 | } | |
248 |
|
248 | |||
249 | spectral_matrix_regs->status = spectral_matrix_regs->status & BITS_SM_ERR; |
|
249 | spectral_matrix_regs->status = spectral_matrix_regs->status & BITS_SM_ERR; | |
250 |
|
250 | |||
251 | } |
|
251 | } | |
252 |
|
252 | |||
253 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
253 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) | |
254 | { |
|
254 | { | |
255 | // STATUS REGISTER |
|
255 | // STATUS REGISTER | |
256 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) |
|
256 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) | |
257 | // 10 9 8 |
|
257 | // 10 9 8 | |
258 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 |
|
258 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 | |
259 | // 7 6 5 4 3 2 1 0 |
|
259 | // 7 6 5 4 3 2 1 0 | |
260 |
|
260 | |||
261 | int statusReg; |
|
261 | int statusReg; | |
262 |
|
262 | |||
263 | static restartState state = WAIT_FOR_F2; |
|
263 | static restartState state = WAIT_FOR_F2; | |
264 |
|
264 | |||
265 | statusReg = spectral_matrix_regs->status; |
|
265 | statusReg = spectral_matrix_regs->status; | |
266 |
|
266 | |||
267 | if (thisIsAnASMRestart == 0) |
|
267 | if (thisIsAnASMRestart == 0) | |
268 | { // this is not a restart sequence, process incoming matrices normally |
|
268 | { // this is not a restart sequence, process incoming matrices normally | |
269 | spectral_matrices_isr_f0( statusReg ); |
|
269 | spectral_matrices_isr_f0( statusReg ); | |
270 |
|
270 | |||
271 | spectral_matrices_isr_f1( statusReg ); |
|
271 | spectral_matrices_isr_f1( statusReg ); | |
272 |
|
272 | |||
273 | spectral_matrices_isr_f2( statusReg ); |
|
273 | spectral_matrices_isr_f2( statusReg ); | |
274 | } |
|
274 | } | |
275 | else |
|
275 | else | |
276 | { // a restart sequence has to be launched |
|
276 | { // a restart sequence has to be launched | |
277 | switch (state) { |
|
277 | switch (state) { | |
278 | case WAIT_FOR_F2: |
|
278 | case WAIT_FOR_F2: | |
279 | if ((statusReg & BITS_STATUS_F2) != INIT_CHAR) // [0011 0000] check the status_ready_matrix_f2_x bits |
|
279 | if ((statusReg & BITS_STATUS_F2) != INIT_CHAR) // [0011 0000] check the status_ready_matrix_f2_x bits | |
280 | { |
|
280 | { | |
281 | state = WAIT_FOR_F1; |
|
281 | state = WAIT_FOR_F1; | |
282 | } |
|
282 | } | |
283 | break; |
|
283 | break; | |
284 | case WAIT_FOR_F1: |
|
284 | case WAIT_FOR_F1: | |
285 | if ((statusReg & BITS_STATUS_F1) != INIT_CHAR) // [0000 1100] check the status_ready_matrix_f1_x bits |
|
285 | if ((statusReg & BITS_STATUS_F1) != INIT_CHAR) // [0000 1100] check the status_ready_matrix_f1_x bits | |
286 | { |
|
286 | { | |
287 | state = WAIT_FOR_F0; |
|
287 | state = WAIT_FOR_F0; | |
288 | } |
|
288 | } | |
289 | break; |
|
289 | break; | |
290 | case WAIT_FOR_F0: |
|
290 | case WAIT_FOR_F0: | |
291 | if ((statusReg & BITS_STATUS_F0) != INIT_CHAR) // [0000 0011] check the status_ready_matrix_f0_x bits |
|
291 | if ((statusReg & BITS_STATUS_F0) != INIT_CHAR) // [0000 0011] check the status_ready_matrix_f0_x bits | |
292 | { |
|
292 | { | |
293 | state = WAIT_FOR_F2; |
|
293 | state = WAIT_FOR_F2; | |
294 | thisIsAnASMRestart = 0; |
|
294 | thisIsAnASMRestart = 0; | |
295 | } |
|
295 | } | |
296 | break; |
|
296 | break; | |
297 | default: |
|
297 | default: | |
298 | break; |
|
298 | break; | |
299 | } |
|
299 | } | |
300 | reset_sm_status(); |
|
300 | reset_sm_status(); | |
301 | } |
|
301 | } | |
302 |
|
302 | |||
303 | spectral_matrix_isr_error_handler( statusReg ); |
|
303 | spectral_matrix_isr_error_handler( statusReg ); | |
304 |
|
304 | |||
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 | //****************** |
|
307 | //****************** | |
308 | // Spectral Matrices |
|
308 | // Spectral Matrices | |
309 |
|
309 | |||
310 | void reset_nb_sm( void ) |
|
310 | void reset_nb_sm( void ) | |
311 | { |
|
311 | { | |
312 | nb_sm_f0 = 0; |
|
312 | nb_sm_f0 = 0; | |
313 | nb_sm_f0_aux_f1 = 0; |
|
313 | nb_sm_f0_aux_f1 = 0; | |
314 | nb_sm_f0_aux_f2 = 0; |
|
314 | nb_sm_f0_aux_f2 = 0; | |
315 |
|
315 | |||
316 | nb_sm_f1 = 0; |
|
316 | nb_sm_f1 = 0; | |
317 | } |
|
317 | } | |
318 |
|
318 | |||
319 | void SM_init_rings( void ) |
|
319 | void SM_init_rings( void ) | |
320 | { |
|
320 | { | |
321 | init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM ); |
|
321 | init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM ); | |
322 | init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM ); |
|
322 | init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM ); | |
323 | init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM ); |
|
323 | init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM ); | |
324 |
|
324 | |||
325 | DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) |
|
325 | DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) | |
326 | DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) |
|
326 | DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) | |
327 | DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) |
|
327 | DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) | |
328 | DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0) |
|
328 | DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0) | |
329 | DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1) |
|
329 | DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1) | |
330 | DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2) |
|
330 | DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2) | |
331 | } |
|
331 | } | |
332 |
|
332 | |||
333 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) |
|
333 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) | |
334 | { |
|
334 | { | |
335 | unsigned char i; |
|
335 | unsigned char i; | |
336 |
|
336 | |||
337 | ring[ nbNodes - 1 ].next |
|
337 | ring[ nbNodes - 1 ].next | |
338 | = (ring_node_asm*) &ring[ 0 ]; |
|
338 | = (ring_node_asm*) &ring[ 0 ]; | |
339 |
|
339 | |||
340 | for(i=0; i<nbNodes-1; i++) |
|
340 | for(i=0; i<nbNodes-1; i++) | |
341 | { |
|
341 | { | |
342 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; |
|
342 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; | |
343 | } |
|
343 | } | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 | void SM_reset_current_ring_nodes( void ) |
|
346 | void SM_reset_current_ring_nodes( void ) | |
347 | { |
|
347 | { | |
348 | current_ring_node_sm_f0 = sm_ring_f0[0].next; |
|
348 | current_ring_node_sm_f0 = sm_ring_f0[0].next; | |
349 | current_ring_node_sm_f1 = sm_ring_f1[0].next; |
|
349 | current_ring_node_sm_f1 = sm_ring_f1[0].next; | |
350 | current_ring_node_sm_f2 = sm_ring_f2[0].next; |
|
350 | current_ring_node_sm_f2 = sm_ring_f2[0].next; | |
351 |
|
351 | |||
352 | ring_node_for_averaging_sm_f0 = NULL; |
|
352 | ring_node_for_averaging_sm_f0 = NULL; | |
353 | ring_node_for_averaging_sm_f1 = NULL; |
|
353 | ring_node_for_averaging_sm_f1 = NULL; | |
354 | ring_node_for_averaging_sm_f2 = NULL; |
|
354 | ring_node_for_averaging_sm_f2 = NULL; | |
355 | } |
|
355 | } | |
356 |
|
356 | |||
357 | //***************** |
|
357 | //***************** | |
358 | // Basic Parameters |
|
358 | // Basic Parameters | |
359 |
|
359 | |||
360 | void BP_init_header( bp_packet *packet, |
|
360 | void BP_init_header( bp_packet *packet, | |
361 | unsigned int apid, unsigned char sid, |
|
361 | unsigned int apid, unsigned char sid, | |
362 | unsigned int packetLength, unsigned char blkNr ) |
|
362 | unsigned int packetLength, unsigned char blkNr ) | |
363 | { |
|
363 | { | |
364 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
364 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
365 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
365 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
366 | packet->reserved = INIT_CHAR; |
|
366 | packet->reserved = INIT_CHAR; | |
367 | packet->userApplication = CCSDS_USER_APP; |
|
367 | packet->userApplication = CCSDS_USER_APP; | |
368 | packet->packetID[0] = (unsigned char) (apid >> SHIFT_1_BYTE); |
|
368 | packet->packetID[0] = (unsigned char) (apid >> SHIFT_1_BYTE); | |
369 | packet->packetID[1] = (unsigned char) (apid); |
|
369 | packet->packetID[1] = (unsigned char) (apid); | |
370 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
370 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
371 | packet->packetSequenceControl[1] = INIT_CHAR; |
|
371 | packet->packetSequenceControl[1] = INIT_CHAR; | |
372 | packet->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); |
|
372 | packet->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); | |
373 | packet->packetLength[1] = (unsigned char) (packetLength); |
|
373 | packet->packetLength[1] = (unsigned char) (packetLength); | |
374 | // DATA FIELD HEADER |
|
374 | // DATA FIELD HEADER | |
375 | packet->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
375 | packet->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
376 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
376 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
377 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
377 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
378 | packet->destinationID = TM_DESTINATION_ID_GROUND; |
|
378 | packet->destinationID = TM_DESTINATION_ID_GROUND; | |
379 | packet->time[BYTE_0] = INIT_CHAR; |
|
379 | packet->time[BYTE_0] = INIT_CHAR; | |
380 | packet->time[BYTE_1] = INIT_CHAR; |
|
380 | packet->time[BYTE_1] = INIT_CHAR; | |
381 | packet->time[BYTE_2] = INIT_CHAR; |
|
381 | packet->time[BYTE_2] = INIT_CHAR; | |
382 | packet->time[BYTE_3] = INIT_CHAR; |
|
382 | packet->time[BYTE_3] = INIT_CHAR; | |
383 | packet->time[BYTE_4] = INIT_CHAR; |
|
383 | packet->time[BYTE_4] = INIT_CHAR; | |
384 | packet->time[BYTE_5] = INIT_CHAR; |
|
384 | packet->time[BYTE_5] = INIT_CHAR; | |
385 | // AUXILIARY DATA HEADER |
|
385 | // AUXILIARY DATA HEADER | |
386 | packet->sid = sid; |
|
386 | packet->sid = sid; | |
387 | packet->pa_bia_status_info = INIT_CHAR; |
|
387 | packet->pa_bia_status_info = INIT_CHAR; | |
388 | packet->sy_lfr_common_parameters_spare = INIT_CHAR; |
|
388 | packet->sy_lfr_common_parameters_spare = INIT_CHAR; | |
389 | packet->sy_lfr_common_parameters = INIT_CHAR; |
|
389 | packet->sy_lfr_common_parameters = INIT_CHAR; | |
390 | packet->acquisitionTime[BYTE_0] = INIT_CHAR; |
|
390 | packet->acquisitionTime[BYTE_0] = INIT_CHAR; | |
391 | packet->acquisitionTime[BYTE_1] = INIT_CHAR; |
|
391 | packet->acquisitionTime[BYTE_1] = INIT_CHAR; | |
392 | packet->acquisitionTime[BYTE_2] = INIT_CHAR; |
|
392 | packet->acquisitionTime[BYTE_2] = INIT_CHAR; | |
393 | packet->acquisitionTime[BYTE_3] = INIT_CHAR; |
|
393 | packet->acquisitionTime[BYTE_3] = INIT_CHAR; | |
394 | packet->acquisitionTime[BYTE_4] = INIT_CHAR; |
|
394 | packet->acquisitionTime[BYTE_4] = INIT_CHAR; | |
395 | packet->acquisitionTime[BYTE_5] = INIT_CHAR; |
|
395 | packet->acquisitionTime[BYTE_5] = INIT_CHAR; | |
396 | packet->pa_lfr_bp_blk_nr[0] = INIT_CHAR; // BLK_NR MSB |
|
396 | packet->pa_lfr_bp_blk_nr[0] = INIT_CHAR; // BLK_NR MSB | |
397 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
397 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB | |
398 | } |
|
398 | } | |
399 |
|
399 | |||
400 | void BP_init_header_with_spare( bp_packet_with_spare *packet, |
|
400 | void BP_init_header_with_spare( bp_packet_with_spare *packet, | |
401 | unsigned int apid, unsigned char sid, |
|
401 | unsigned int apid, unsigned char sid, | |
402 | unsigned int packetLength , unsigned char blkNr) |
|
402 | unsigned int packetLength , unsigned char blkNr) | |
403 | { |
|
403 | { | |
404 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
404 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
405 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
405 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
406 | packet->reserved = INIT_CHAR; |
|
406 | packet->reserved = INIT_CHAR; | |
407 | packet->userApplication = CCSDS_USER_APP; |
|
407 | packet->userApplication = CCSDS_USER_APP; | |
408 | packet->packetID[0] = (unsigned char) (apid >> SHIFT_1_BYTE); |
|
408 | packet->packetID[0] = (unsigned char) (apid >> SHIFT_1_BYTE); | |
409 | packet->packetID[1] = (unsigned char) (apid); |
|
409 | packet->packetID[1] = (unsigned char) (apid); | |
410 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
410 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
411 | packet->packetSequenceControl[1] = INIT_CHAR; |
|
411 | packet->packetSequenceControl[1] = INIT_CHAR; | |
412 | packet->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); |
|
412 | packet->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); | |
413 | packet->packetLength[1] = (unsigned char) (packetLength); |
|
413 | packet->packetLength[1] = (unsigned char) (packetLength); | |
414 | // DATA FIELD HEADER |
|
414 | // DATA FIELD HEADER | |
415 | packet->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
415 | packet->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
416 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
416 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
417 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
417 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
418 | packet->destinationID = TM_DESTINATION_ID_GROUND; |
|
418 | packet->destinationID = TM_DESTINATION_ID_GROUND; | |
419 | // AUXILIARY DATA HEADER |
|
419 | // AUXILIARY DATA HEADER | |
420 | packet->sid = sid; |
|
420 | packet->sid = sid; | |
421 | packet->pa_bia_status_info = INIT_CHAR; |
|
421 | packet->pa_bia_status_info = INIT_CHAR; | |
422 | packet->sy_lfr_common_parameters_spare = INIT_CHAR; |
|
422 | packet->sy_lfr_common_parameters_spare = INIT_CHAR; | |
423 | packet->sy_lfr_common_parameters = INIT_CHAR; |
|
423 | packet->sy_lfr_common_parameters = INIT_CHAR; | |
424 | packet->time[BYTE_0] = INIT_CHAR; |
|
424 | packet->time[BYTE_0] = INIT_CHAR; | |
425 | packet->time[BYTE_1] = INIT_CHAR; |
|
425 | packet->time[BYTE_1] = INIT_CHAR; | |
426 | packet->time[BYTE_2] = INIT_CHAR; |
|
426 | packet->time[BYTE_2] = INIT_CHAR; | |
427 | packet->time[BYTE_3] = INIT_CHAR; |
|
427 | packet->time[BYTE_3] = INIT_CHAR; | |
428 | packet->time[BYTE_4] = INIT_CHAR; |
|
428 | packet->time[BYTE_4] = INIT_CHAR; | |
429 | packet->time[BYTE_5] = INIT_CHAR; |
|
429 | packet->time[BYTE_5] = INIT_CHAR; | |
430 | packet->source_data_spare = INIT_CHAR; |
|
430 | packet->source_data_spare = INIT_CHAR; | |
431 | packet->pa_lfr_bp_blk_nr[0] = INIT_CHAR; // BLK_NR MSB |
|
431 | packet->pa_lfr_bp_blk_nr[0] = INIT_CHAR; // BLK_NR MSB | |
432 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
432 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB | |
433 | } |
|
433 | } | |
434 |
|
434 | |||
435 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) |
|
435 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) | |
436 | { |
|
436 | { | |
437 | rtems_status_code status; |
|
437 | rtems_status_code status; | |
438 |
|
438 | |||
439 | // SEND PACKET |
|
439 | // SEND PACKET | |
440 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); |
|
440 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); | |
441 | if (status != RTEMS_SUCCESSFUL) |
|
441 | if (status != RTEMS_SUCCESSFUL) | |
442 | { |
|
442 | { | |
443 | PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) |
|
443 | PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) | |
444 | } |
|
444 | } | |
445 | } |
|
445 | } | |
446 |
|
446 | |||
447 | void BP_send_s1_s2(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) |
|
447 | void BP_send_s1_s2(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) | |
448 | { |
|
448 | { | |
449 | /** This function is used to send the BP paquets when needed. |
|
449 | /** This function is used to send the BP paquets when needed. | |
450 | * |
|
450 | * | |
451 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
451 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
452 | * |
|
452 | * | |
453 | * @return void |
|
453 | * @return void | |
454 | * |
|
454 | * | |
455 | * SBM1 and SBM2 paquets are sent depending on the type of the LFR mode transition. |
|
455 | * SBM1 and SBM2 paquets are sent depending on the type of the LFR mode transition. | |
456 | * BURST paquets are sent everytime. |
|
456 | * BURST paquets are sent everytime. | |
457 | * |
|
457 | * | |
458 | */ |
|
458 | */ | |
459 |
|
459 | |||
460 | rtems_status_code status; |
|
460 | rtems_status_code status; | |
461 |
|
461 | |||
462 | // SEND PACKET |
|
462 | // SEND PACKET | |
463 | // before lastValidTransitionDate, the data are drops even if they are ready |
|
463 | // before lastValidTransitionDate, the data are drops even if they are ready | |
464 | // this guarantees that no SBM packets will be received before the requested enter mode time |
|
464 | // this guarantees that no SBM packets will be received before the requested enter mode time | |
465 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime) |
|
465 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime) | |
466 | { |
|
466 | { | |
467 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); |
|
467 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); | |
468 | if (status != RTEMS_SUCCESSFUL) |
|
468 | if (status != RTEMS_SUCCESSFUL) | |
469 | { |
|
469 | { | |
470 | PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) |
|
470 | PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) | |
471 | } |
|
471 | } | |
472 | } |
|
472 | } | |
473 | } |
|
473 | } | |
474 |
|
474 | |||
475 | //****************** |
|
475 | //****************** | |
476 | // general functions |
|
476 | // general functions | |
477 |
|
477 | |||
478 | void reset_sm_status( void ) |
|
478 | void reset_sm_status( void ) | |
479 | { |
|
479 | { | |
480 | // error |
|
480 | // error | |
481 | // 10 --------------- 9 ---------------- 8 ---------------- 7 --------- |
|
481 | // 10 --------------- 9 ---------------- 8 ---------------- 7 --------- | |
482 | // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full |
|
482 | // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full | |
483 | // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 -- |
|
483 | // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 -- | |
484 | // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0 |
|
484 | // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0 | |
485 |
|
485 | |||
486 | spectral_matrix_regs->status = BITS_STATUS_REG; // [0111 1111 1111] |
|
486 | spectral_matrix_regs->status = BITS_STATUS_REG; // [0111 1111 1111] | |
487 | } |
|
487 | } | |
488 |
|
488 | |||
489 | void reset_spectral_matrix_regs( void ) |
|
489 | void reset_spectral_matrix_regs( void ) | |
490 | { |
|
490 | { | |
491 | /** This function resets the spectral matrices module registers. |
|
491 | /** This function resets the spectral matrices module registers. | |
492 | * |
|
492 | * | |
493 | * The registers affected by this function are located at the following offset addresses: |
|
493 | * The registers affected by this function are located at the following offset addresses: | |
494 | * |
|
494 | * | |
495 | * - 0x00 config |
|
495 | * - 0x00 config | |
496 | * - 0x04 status |
|
496 | * - 0x04 status | |
497 | * - 0x08 matrixF0_Address0 |
|
497 | * - 0x08 matrixF0_Address0 | |
498 | * - 0x10 matrixFO_Address1 |
|
498 | * - 0x10 matrixFO_Address1 | |
499 | * - 0x14 matrixF1_Address |
|
499 | * - 0x14 matrixF1_Address | |
500 | * - 0x18 matrixF2_Address |
|
500 | * - 0x18 matrixF2_Address | |
501 | * |
|
501 | * | |
502 | */ |
|
502 | */ | |
503 |
|
503 | |||
504 | set_sm_irq_onError( 0 ); |
|
504 | set_sm_irq_onError( 0 ); | |
505 |
|
505 | |||
506 | set_sm_irq_onNewMatrix( 0 ); |
|
506 | set_sm_irq_onNewMatrix( 0 ); | |
507 |
|
507 | |||
508 | reset_sm_status(); |
|
508 | reset_sm_status(); | |
509 |
|
509 | |||
510 | // F1 |
|
510 | // F1 | |
511 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; |
|
511 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; | |
512 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
512 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; | |
513 | // F2 |
|
513 | // F2 | |
514 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; |
|
514 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; | |
515 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
515 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; | |
516 | // F3 |
|
516 | // F3 | |
517 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; |
|
517 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; | |
518 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
518 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; | |
519 |
|
519 | |||
520 | spectral_matrix_regs->matrix_length = DEFAULT_MATRIX_LENGTH; // 25 * 128 / 16 = 200 = 0xc8 |
|
520 | spectral_matrix_regs->matrix_length = DEFAULT_MATRIX_LENGTH; // 25 * 128 / 16 = 200 = 0xc8 | |
521 | } |
|
521 | } | |
522 |
|
522 | |||
523 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) |
|
523 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) | |
524 | { |
|
524 | { | |
525 | time[BYTE_0] = timeInBuffer[BYTE_0]; |
|
525 | time[BYTE_0] = timeInBuffer[BYTE_0]; | |
526 | time[BYTE_1] = timeInBuffer[BYTE_1]; |
|
526 | time[BYTE_1] = timeInBuffer[BYTE_1]; | |
527 | time[BYTE_2] = timeInBuffer[BYTE_2]; |
|
527 | time[BYTE_2] = timeInBuffer[BYTE_2]; | |
528 | time[BYTE_3] = timeInBuffer[BYTE_3]; |
|
528 | time[BYTE_3] = timeInBuffer[BYTE_3]; | |
529 | time[BYTE_4] = timeInBuffer[BYTE_6]; |
|
529 | time[BYTE_4] = timeInBuffer[BYTE_6]; | |
530 | time[BYTE_5] = timeInBuffer[BYTE_7]; |
|
530 | time[BYTE_5] = timeInBuffer[BYTE_7]; | |
531 | } |
|
531 | } | |
532 |
|
532 | |||
533 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) |
|
533 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) | |
534 | { |
|
534 | { | |
535 | unsigned long long int acquisitionTimeAslong; |
|
535 | unsigned long long int acquisitionTimeAslong; | |
536 | acquisitionTimeAslong = INIT_CHAR; |
|
536 | acquisitionTimeAslong = INIT_CHAR; | |
537 | acquisitionTimeAslong = |
|
537 | acquisitionTimeAslong = | |
538 | ( (unsigned long long int) (timePtr[BYTE_0] & SYNC_BIT_MASK) << SHIFT_5_BYTES ) // [0111 1111] mask the synchronization bit |
|
538 | ( (unsigned long long int) (timePtr[BYTE_0] & SYNC_BIT_MASK) << SHIFT_5_BYTES ) // [0111 1111] mask the synchronization bit | |
539 | + ( (unsigned long long int) timePtr[BYTE_1] << SHIFT_4_BYTES ) |
|
539 | + ( (unsigned long long int) timePtr[BYTE_1] << SHIFT_4_BYTES ) | |
540 | + ( (unsigned long long int) timePtr[BYTE_2] << SHIFT_3_BYTES ) |
|
540 | + ( (unsigned long long int) timePtr[BYTE_2] << SHIFT_3_BYTES ) | |
541 | + ( (unsigned long long int) timePtr[BYTE_3] << SHIFT_2_BYTES ) |
|
541 | + ( (unsigned long long int) timePtr[BYTE_3] << SHIFT_2_BYTES ) | |
542 | + ( (unsigned long long int) timePtr[BYTE_6] << SHIFT_1_BYTE ) |
|
542 | + ( (unsigned long long int) timePtr[BYTE_6] << SHIFT_1_BYTE ) | |
543 | + ( (unsigned long long int) timePtr[BYTE_7] ); |
|
543 | + ( (unsigned long long int) timePtr[BYTE_7] ); | |
544 | return acquisitionTimeAslong; |
|
544 | return acquisitionTimeAslong; | |
545 | } |
|
545 | } | |
546 |
|
546 | |||
547 | unsigned char getSID( rtems_event_set event ) |
|
547 | unsigned char getSID( rtems_event_set event ) | |
548 | { |
|
548 | { | |
549 | unsigned char sid; |
|
549 | unsigned char sid; | |
550 |
|
550 | |||
551 | rtems_event_set eventSetBURST; |
|
551 | rtems_event_set eventSetBURST; | |
552 | rtems_event_set eventSetSBM; |
|
552 | rtems_event_set eventSetSBM; | |
553 |
|
553 | |||
554 | sid = 0; |
|
554 | sid = 0; | |
555 |
|
555 | |||
556 | //****** |
|
556 | //****** | |
557 | // BURST |
|
557 | // BURST | |
558 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 |
|
558 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 | |
559 | | RTEMS_EVENT_BURST_BP1_F1 |
|
559 | | RTEMS_EVENT_BURST_BP1_F1 | |
560 | | RTEMS_EVENT_BURST_BP2_F0 |
|
560 | | RTEMS_EVENT_BURST_BP2_F0 | |
561 | | RTEMS_EVENT_BURST_BP2_F1; |
|
561 | | RTEMS_EVENT_BURST_BP2_F1; | |
562 |
|
562 | |||
563 | //**** |
|
563 | //**** | |
564 | // SBM |
|
564 | // SBM | |
565 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 |
|
565 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 | |
566 | | RTEMS_EVENT_SBM_BP1_F1 |
|
566 | | RTEMS_EVENT_SBM_BP1_F1 | |
567 | | RTEMS_EVENT_SBM_BP2_F0 |
|
567 | | RTEMS_EVENT_SBM_BP2_F0 | |
568 | | RTEMS_EVENT_SBM_BP2_F1; |
|
568 | | RTEMS_EVENT_SBM_BP2_F1; | |
569 |
|
569 | |||
570 | if (event & eventSetBURST) |
|
570 | if (event & eventSetBURST) | |
571 | { |
|
571 | { | |
572 | sid = SID_BURST_BP1_F0; |
|
572 | sid = SID_BURST_BP1_F0; | |
573 | } |
|
573 | } | |
574 | else if (event & eventSetSBM) |
|
574 | else if (event & eventSetSBM) | |
575 | { |
|
575 | { | |
576 | sid = SID_SBM1_BP1_F0; |
|
576 | sid = SID_SBM1_BP1_F0; | |
577 | } |
|
577 | } | |
578 | else |
|
578 | else | |
579 | { |
|
579 | { | |
580 | sid = 0; |
|
580 | sid = 0; | |
581 | } |
|
581 | } | |
582 |
|
582 | |||
583 | return sid; |
|
583 | return sid; | |
584 | } |
|
584 | } | |
585 |
|
585 | |||
586 | void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) |
|
586 | void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) | |
587 | { |
|
587 | { | |
588 | unsigned int i; |
|
588 | unsigned int i; | |
589 | float re; |
|
589 | float re; | |
590 | float im; |
|
590 | float im; | |
591 |
|
591 | |||
592 | for (i=0; i<NB_BINS_PER_SM; i++){ |
|
592 | for (i=0; i<NB_BINS_PER_SM; i++){ | |
593 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + (i * SM_BYTES_PER_VAL) ]; |
|
593 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + (i * SM_BYTES_PER_VAL) ]; | |
594 | im = inputASM[ (asmComponent*NB_BINS_PER_SM) + (i * SM_BYTES_PER_VAL) + 1]; |
|
594 | im = inputASM[ (asmComponent*NB_BINS_PER_SM) + (i * SM_BYTES_PER_VAL) + 1]; | |
595 | outputASM[ ( asmComponent *NB_BINS_PER_SM) + i] = re; |
|
595 | outputASM[ ( asmComponent *NB_BINS_PER_SM) + i] = re; | |
596 | outputASM[ ((asmComponent+1)*NB_BINS_PER_SM) + i] = im; |
|
596 | outputASM[ ((asmComponent+1)*NB_BINS_PER_SM) + i] = im; | |
597 | } |
|
597 | } | |
598 | } |
|
598 | } | |
599 |
|
599 | |||
600 | void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) |
|
600 | void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) | |
601 | { |
|
601 | { | |
602 | unsigned int i; |
|
602 | unsigned int i; | |
603 | float re; |
|
603 | float re; | |
604 |
|
604 | |||
605 | for (i=0; i<NB_BINS_PER_SM; i++){ |
|
605 | for (i=0; i<NB_BINS_PER_SM; i++){ | |
606 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i]; |
|
606 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i]; | |
607 | outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re; |
|
607 | outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re; | |
608 | } |
|
608 | } | |
609 | } |
|
609 | } | |
610 |
|
610 | |||
611 | void ASM_patch( float *inputASM, float *outputASM ) |
|
611 | void ASM_patch( float *inputASM, float *outputASM ) | |
612 | { |
|
612 | { | |
613 | extractReImVectors( inputASM, outputASM, ASM_COMP_B1B2); // b1b2 |
|
613 | extractReImVectors( inputASM, outputASM, ASM_COMP_B1B2); // b1b2 | |
614 | extractReImVectors( inputASM, outputASM, ASM_COMP_B1B3 ); // b1b3 |
|
614 | extractReImVectors( inputASM, outputASM, ASM_COMP_B1B3 ); // b1b3 | |
615 | extractReImVectors( inputASM, outputASM, ASM_COMP_B1E1 ); // b1e1 |
|
615 | extractReImVectors( inputASM, outputASM, ASM_COMP_B1E1 ); // b1e1 | |
616 | extractReImVectors( inputASM, outputASM, ASM_COMP_B1E2 ); // b1e2 |
|
616 | extractReImVectors( inputASM, outputASM, ASM_COMP_B1E2 ); // b1e2 | |
617 | extractReImVectors( inputASM, outputASM, ASM_COMP_B2B3 ); // b2b3 |
|
617 | extractReImVectors( inputASM, outputASM, ASM_COMP_B2B3 ); // b2b3 | |
618 | extractReImVectors( inputASM, outputASM, ASM_COMP_B2E1 ); // b2e1 |
|
618 | extractReImVectors( inputASM, outputASM, ASM_COMP_B2E1 ); // b2e1 | |
619 | extractReImVectors( inputASM, outputASM, ASM_COMP_B2E2 ); // b2e2 |
|
619 | extractReImVectors( inputASM, outputASM, ASM_COMP_B2E2 ); // b2e2 | |
620 | extractReImVectors( inputASM, outputASM, ASM_COMP_B3E1 ); // b3e1 |
|
620 | extractReImVectors( inputASM, outputASM, ASM_COMP_B3E1 ); // b3e1 | |
621 | extractReImVectors( inputASM, outputASM, ASM_COMP_B3E2 ); // b3e2 |
|
621 | extractReImVectors( inputASM, outputASM, ASM_COMP_B3E2 ); // b3e2 | |
622 | extractReImVectors( inputASM, outputASM, ASM_COMP_E1E2 ); // e1e2 |
|
622 | extractReImVectors( inputASM, outputASM, ASM_COMP_E1E2 ); // e1e2 | |
623 |
|
623 | |||
624 | copyReVectors(inputASM, outputASM, ASM_COMP_B1B1 ); // b1b1 |
|
624 | copyReVectors(inputASM, outputASM, ASM_COMP_B1B1 ); // b1b1 | |
625 | copyReVectors(inputASM, outputASM, ASM_COMP_B2B2 ); // b2b2 |
|
625 | copyReVectors(inputASM, outputASM, ASM_COMP_B2B2 ); // b2b2 | |
626 | copyReVectors(inputASM, outputASM, ASM_COMP_B3B3); // b3b3 |
|
626 | copyReVectors(inputASM, outputASM, ASM_COMP_B3B3); // b3b3 | |
627 | copyReVectors(inputASM, outputASM, ASM_COMP_E1E1); // e1e1 |
|
627 | copyReVectors(inputASM, outputASM, ASM_COMP_E1E1); // e1e1 | |
628 | copyReVectors(inputASM, outputASM, ASM_COMP_E2E2); // e2e2 |
|
628 | copyReVectors(inputASM, outputASM, ASM_COMP_E2E2); // e2e2 | |
629 | } |
|
629 | } | |
630 |
|
630 | |||
631 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
631 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider, | |
632 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, |
|
632 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, | |
633 | unsigned char ASMIndexStart, |
|
633 | unsigned char ASMIndexStart, | |
634 | unsigned char channel ) |
|
634 | unsigned char channel ) | |
635 | { |
|
635 | { | |
636 | //************* |
|
636 | //************* | |
637 | // input format |
|
637 | // input format | |
638 | // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127] |
|
638 | // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127] | |
639 | //************** |
|
639 | //************** | |
640 | // output format |
|
640 | // output format | |
641 | // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24] |
|
641 | // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24] | |
642 | //************ |
|
642 | //************ | |
643 | // compression |
|
643 | // compression | |
644 | // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM |
|
644 | // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM | |
645 | // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM |
|
645 | // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM | |
646 |
|
646 | |||
647 | int frequencyBin; |
|
647 | int frequencyBin; | |
648 | int asmComponent; |
|
648 | int asmComponent; | |
649 | int offsetASM; |
|
649 | int offsetASM; | |
650 | int offsetCompressed; |
|
650 | int offsetCompressed; | |
651 | int offsetFBin; |
|
651 | int offsetFBin; | |
652 | int fBinMask; |
|
652 | int fBinMask; | |
653 | int k; |
|
653 | int k; | |
654 |
|
654 | |||
655 | // BUILD DATA |
|
655 | // BUILD DATA | |
656 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
656 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
657 | { |
|
657 | { | |
658 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
658 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) | |
659 | { |
|
659 | { | |
660 | offsetCompressed = // NO TIME OFFSET |
|
660 | offsetCompressed = // NO TIME OFFSET | |
661 | (frequencyBin * NB_VALUES_PER_SM) |
|
661 | (frequencyBin * NB_VALUES_PER_SM) | |
662 | + asmComponent; |
|
662 | + asmComponent; | |
663 | offsetASM = // NO TIME OFFSET |
|
663 | offsetASM = // NO TIME OFFSET | |
664 | (asmComponent * NB_BINS_PER_SM) |
|
664 | (asmComponent * NB_BINS_PER_SM) | |
665 | + ASMIndexStart |
|
665 | + ASMIndexStart | |
666 | + (frequencyBin * nbBinsToAverage); |
|
666 | + (frequencyBin * nbBinsToAverage); | |
667 | offsetFBin = ASMIndexStart |
|
667 | offsetFBin = ASMIndexStart | |
668 | + (frequencyBin * nbBinsToAverage); |
|
668 | + (frequencyBin * nbBinsToAverage); | |
669 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
669 | compressed_spec_mat[ offsetCompressed ] = 0; | |
670 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
670 | for ( k = 0; k < nbBinsToAverage; k++ ) | |
671 | { |
|
671 | { | |
672 | fBinMask = getFBinMask( offsetFBin + k, channel ); |
|
672 | fBinMask = getFBinMask( offsetFBin + k, channel ); | |
673 | compressed_spec_mat[offsetCompressed ] = compressed_spec_mat[ offsetCompressed ] |
|
673 | compressed_spec_mat[offsetCompressed ] = compressed_spec_mat[ offsetCompressed ] | |
674 | + (averaged_spec_mat[ offsetASM + k ] * fBinMask); |
|
674 | + (averaged_spec_mat[ offsetASM + k ] * fBinMask); | |
675 | } |
|
675 | } | |
676 | if (divider != 0) |
|
676 | if (divider != 0) | |
677 | { |
|
677 | { | |
678 | compressed_spec_mat[ offsetCompressed ] = compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); |
|
678 | compressed_spec_mat[ offsetCompressed ] = compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); | |
679 | } |
|
679 | } | |
680 | else |
|
680 | else | |
681 | { |
|
681 | { | |
682 | compressed_spec_mat[ offsetCompressed ] = INIT_FLOAT; |
|
682 | compressed_spec_mat[ offsetCompressed ] = INIT_FLOAT; | |
683 | } |
|
683 | } | |
684 | } |
|
684 | } | |
685 | } |
|
685 | } | |
686 |
|
686 | |||
687 | } |
|
687 | } | |
688 |
|
688 | |||
689 | int getFBinMask( int index, unsigned char channel ) |
|
689 | int getFBinMask( int index, unsigned char channel ) | |
690 | { |
|
690 | { | |
691 | unsigned int indexInChar; |
|
691 | unsigned int indexInChar; | |
692 | unsigned int indexInTheChar; |
|
692 | unsigned int indexInTheChar; | |
693 | int fbin; |
|
693 | int fbin; | |
694 | unsigned char *sy_lfr_fbins_fx_word1; |
|
694 | unsigned char *sy_lfr_fbins_fx_word1; | |
695 |
|
695 | |||
696 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
696 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
697 |
|
697 | |||
698 | switch(channel) |
|
698 | switch(channel) | |
699 | { |
|
699 | { | |
700 | case CHANNELF0: |
|
700 | case CHANNELF0: | |
701 | sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f0; |
|
701 | sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f0; | |
702 | break; |
|
702 | break; | |
703 | case CHANNELF1: |
|
703 | case CHANNELF1: | |
704 | sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f1; |
|
704 | sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f1; | |
705 | break; |
|
705 | break; | |
706 | case CHANNELF2: |
|
706 | case CHANNELF2: | |
707 | sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f2; |
|
707 | sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f2; | |
708 | break; |
|
708 | break; | |
709 | default: |
|
709 | default: | |
710 | PRINTF("ERR *** in getFBinMask, wrong frequency channel") |
|
710 | PRINTF("ERR *** in getFBinMask, wrong frequency channel") | |
711 | } |
|
711 | } | |
712 |
|
712 | |||
713 | indexInChar = index >> SHIFT_3_BITS; |
|
713 | indexInChar = index >> SHIFT_3_BITS; | |
714 | indexInTheChar = index - (indexInChar * BITS_PER_BYTE); |
|
714 | indexInTheChar = index - (indexInChar * BITS_PER_BYTE); | |
715 |
|
715 | |||
716 | fbin = (int) ((sy_lfr_fbins_fx_word1[ BYTES_PER_MASK - 1 - indexInChar] >> indexInTheChar) & 1); |
|
716 | fbin = (int) ((sy_lfr_fbins_fx_word1[ BYTES_PER_MASK - 1 - indexInChar] >> indexInTheChar) & 1); | |
717 |
|
717 | |||
718 | return fbin; |
|
718 | return fbin; | |
719 | } |
|
719 | } | |
720 |
|
720 | |||
721 | unsigned char acquisitionTimeIsValid( unsigned int coarseTime, unsigned int fineTime, unsigned char channel) |
|
721 | unsigned char acquisitionTimeIsValid( unsigned int coarseTime, unsigned int fineTime, unsigned char channel) | |
722 | { |
|
722 | { | |
723 | u_int64_t acquisitionTimeStart; |
|
723 | u_int64_t acquisitionTimeStart; | |
724 | u_int64_t acquisitionTimeStop; |
|
724 | u_int64_t acquisitionTimeStop; | |
725 | u_int64_t timecodeReference; |
|
725 | u_int64_t timecodeReference; | |
726 | u_int64_t offsetInFineTime; |
|
726 | u_int64_t offsetInFineTime; | |
727 | u_int64_t shiftInFineTime; |
|
727 | u_int64_t shiftInFineTime; | |
728 | u_int64_t tBadInFineTime; |
|
728 | u_int64_t tBadInFineTime; | |
729 | u_int64_t acquisitionTimeRangeMin; |
|
729 | u_int64_t acquisitionTimeRangeMin; | |
730 | u_int64_t acquisitionTimeRangeMax; |
|
730 | u_int64_t acquisitionTimeRangeMax; | |
731 | unsigned char pasFilteringIsEnabled; |
|
731 | unsigned char pasFilteringIsEnabled; | |
732 | unsigned char ret; |
|
732 | unsigned char ret; | |
733 |
|
733 | |||
734 | pasFilteringIsEnabled = (filterPar.spare_sy_lfr_pas_filter_enabled & 1); // [0000 0001] |
|
734 | pasFilteringIsEnabled = (filterPar.spare_sy_lfr_pas_filter_enabled & 1); // [0000 0001] | |
735 | ret = 1; |
|
735 | ret = 1; | |
736 |
|
736 | |||
737 | // compute acquisition time from caoarseTime and fineTime |
|
737 | // compute acquisition time from caoarseTime and fineTime | |
738 | acquisitionTimeStart = ( ((u_int64_t)coarseTime) << SHIFT_2_BYTES ) |
|
738 | acquisitionTimeStart = ( ((u_int64_t)coarseTime) << SHIFT_2_BYTES ) | |
739 | + (u_int64_t) fineTime; |
|
739 | + (u_int64_t) fineTime; | |
740 | switch(channel) |
|
740 | switch(channel) | |
741 | { |
|
741 | { | |
742 | case CHANNELF0: |
|
742 | case CHANNELF0: | |
743 | acquisitionTimeStop = acquisitionTimeStart + FINETIME_PER_SM_F0; |
|
743 | acquisitionTimeStop = acquisitionTimeStart + FINETIME_PER_SM_F0; | |
744 | break; |
|
744 | break; | |
745 | case CHANNELF1: |
|
745 | case CHANNELF1: | |
746 | acquisitionTimeStop = acquisitionTimeStart + FINETIME_PER_SM_F1; |
|
746 | acquisitionTimeStop = acquisitionTimeStart + FINETIME_PER_SM_F1; | |
747 | break; |
|
747 | break; | |
748 | case CHANNELF2: |
|
748 | case CHANNELF2: | |
749 | acquisitionTimeStop = acquisitionTimeStart + FINETIME_PER_SM_F2; |
|
749 | acquisitionTimeStop = acquisitionTimeStart + FINETIME_PER_SM_F2; | |
750 | break; |
|
750 | break; | |
751 | } |
|
751 | } | |
752 |
|
752 | |||
753 | // compute the timecode reference |
|
753 | // compute the timecode reference | |
754 | timecodeReference = (u_int64_t) ( (floor( ((double) coarseTime) / ((double) filterPar.sy_lfr_pas_filter_modulus) ) |
|
754 | timecodeReference = (u_int64_t) ( (floor( ((double) coarseTime) / ((double) filterPar.sy_lfr_pas_filter_modulus) ) | |
755 | * ((double) filterPar.sy_lfr_pas_filter_modulus)) * CONST_65536 ); |
|
755 | * ((double) filterPar.sy_lfr_pas_filter_modulus)) * CONST_65536 ); | |
756 |
|
756 | |||
757 | // compute the acquitionTime range |
|
757 | // compute the acquitionTime range | |
758 | offsetInFineTime = ((double) filterPar.sy_lfr_pas_filter_offset) * CONST_65536; |
|
758 | offsetInFineTime = ((double) filterPar.sy_lfr_pas_filter_offset) * CONST_65536; | |
759 | shiftInFineTime = ((double) filterPar.sy_lfr_pas_filter_shift) * CONST_65536; |
|
759 | shiftInFineTime = ((double) filterPar.sy_lfr_pas_filter_shift) * CONST_65536; | |
760 | tBadInFineTime = ((double) filterPar.sy_lfr_pas_filter_tbad) * CONST_65536; |
|
760 | tBadInFineTime = ((double) filterPar.sy_lfr_pas_filter_tbad) * CONST_65536; | |
761 |
|
761 | |||
762 | acquisitionTimeRangeMin = |
|
762 | acquisitionTimeRangeMin = | |
763 | timecodeReference |
|
763 | timecodeReference | |
764 | + offsetInFineTime |
|
764 | + offsetInFineTime | |
765 | + shiftInFineTime |
|
765 | + shiftInFineTime | |
766 | - acquisitionDurations[channel]; |
|
766 | - acquisitionDurations[channel]; | |
767 | acquisitionTimeRangeMax = |
|
767 | acquisitionTimeRangeMax = | |
768 | timecodeReference |
|
768 | timecodeReference | |
769 | + offsetInFineTime |
|
769 | + offsetInFineTime | |
770 | + shiftInFineTime |
|
770 | + shiftInFineTime | |
771 | + tBadInFineTime; |
|
771 | + tBadInFineTime; | |
772 |
|
772 | |||
773 | if ( (acquisitionTimeStart >= acquisitionTimeRangeMin) |
|
773 | if ( (acquisitionTimeStart >= acquisitionTimeRangeMin) | |
774 | && (acquisitionTimeStart <= acquisitionTimeRangeMax) |
|
774 | && (acquisitionTimeStart <= acquisitionTimeRangeMax) | |
775 | && (pasFilteringIsEnabled == 1) ) |
|
775 | && (pasFilteringIsEnabled == 1) ) | |
776 | { |
|
776 | { | |
777 | ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored |
|
777 | ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored | |
778 | } |
|
778 | } | |
779 | else |
|
779 | else | |
780 | { |
|
780 | { | |
781 | ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging |
|
781 | ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging | |
782 | } |
|
782 | } | |
783 |
|
783 | |||
784 | // the last sample of the data used to compute the matrix shall not be INSIDE the range, test it now, it depends on the channel |
|
784 | // the last sample of the data used to compute the matrix shall not be INSIDE the range, test it now, it depends on the channel | |
785 | if (ret == 1) |
|
785 | if (ret == 1) | |
786 | { |
|
786 | { | |
787 | if ( (acquisitionTimeStop >= acquisitionTimeRangeMin) |
|
787 | if ( (acquisitionTimeStop >= acquisitionTimeRangeMin) | |
788 | && (acquisitionTimeStop <= acquisitionTimeRangeMax) |
|
788 | && (acquisitionTimeStop <= acquisitionTimeRangeMax) | |
789 | && (pasFilteringIsEnabled == 1) ) |
|
789 | && (pasFilteringIsEnabled == 1) ) | |
790 | { |
|
790 | { | |
791 | ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored |
|
791 | ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored | |
792 | } |
|
792 | } | |
793 | else |
|
793 | else | |
794 | { |
|
794 | { | |
795 | ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging |
|
795 | ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging | |
796 | } |
|
796 | } | |
797 | } |
|
797 | } | |
798 |
|
798 | |||
799 | // printf("coarseTime = %x, fineTime = %x\n", |
|
|||
800 | // coarseTime, |
|
|||
801 | // fineTime); |
|
|||
802 |
|
||||
803 | // printf("[ret = %d] *** acquisitionTime = %f, Reference = %f", |
|
|||
804 | // ret, |
|
|||
805 | // acquisitionTime / 65536., |
|
|||
806 | // timecodeReference / 65536.); |
|
|||
807 |
|
||||
808 | // printf(", Min = %f, Max = %f\n", |
|
|||
809 | // acquisitionTimeRangeMin / 65536., |
|
|||
810 | // acquisitionTimeRangeMax / 65536.); |
|
|||
811 |
|
||||
812 | return ret; |
|
799 | return ret; | |
813 | } |
|
800 | } | |
814 |
|
801 | |||
815 | void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm) |
|
802 | void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm) | |
816 | { |
|
803 | { | |
817 | unsigned char bin; |
|
804 | unsigned char bin; | |
818 | unsigned char kcoeff; |
|
805 | unsigned char kcoeff; | |
819 |
|
806 | |||
820 | for (bin=0; bin<nb_bins_norm; bin++) |
|
807 | for (bin=0; bin<nb_bins_norm; bin++) | |
821 | { |
|
808 | { | |
822 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
809 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
823 | { |
|
810 | { | |
824 | output_kcoeff[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff ) * SBM_COEFF_PER_NORM_COEFF ] |
|
811 | output_kcoeff[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff ) * SBM_COEFF_PER_NORM_COEFF ] | |
825 | = input_kcoeff[ (bin*NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
812 | = input_kcoeff[ (bin*NB_K_COEFF_PER_BIN) + kcoeff ]; | |
826 | output_kcoeff[ ( ( (bin * NB_K_COEFF_PER_BIN ) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ) + 1 ] |
|
813 | output_kcoeff[ ( ( (bin * NB_K_COEFF_PER_BIN ) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ) + 1 ] | |
827 | = input_kcoeff[ (bin*NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
814 | = input_kcoeff[ (bin*NB_K_COEFF_PER_BIN) + kcoeff ]; | |
828 | } |
|
815 | } | |
829 | } |
|
816 | } | |
830 | } |
|
817 | } |
@@ -1,1816 +1,1951 | |||||
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 = {0}; |
|
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1 = {0}; | |
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2 = {0}; |
|
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2 = {0}; | |
19 | ring_node kcoefficient_node_1 = {0}; |
|
19 | ring_node kcoefficient_node_1 = {0}; | |
20 | ring_node kcoefficient_node_2 = {0}; |
|
20 | ring_node kcoefficient_node_2 = {0}; | |
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 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 ); |
|
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, 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 + DATAFIELD_OFFSET, sy_lfr_b_bp_p1 ); |
|
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1 + DATAFIELD_OFFSET, 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 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 ); |
|
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, 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 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); |
|
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, 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 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p1 ); |
|
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1 + DATAFIELD_OFFSET, 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 * S1_BP_P0_SCALE) ) |
|
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE) ) | |
193 | - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE)); |
|
193 | - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE)); | |
194 | if (aux > FLOAT_EQUAL_ZERO) |
|
194 | if (aux > FLOAT_EQUAL_ZERO) | |
195 | { |
|
195 | { | |
196 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); |
|
196 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); | |
197 | flag = LFR_DEFAULT; |
|
197 | flag = LFR_DEFAULT; | |
198 | } |
|
198 | } | |
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 | // SET THE PARAMETERS |
|
201 | // SET THE PARAMETERS | |
202 | if (flag == LFR_SUCCESSFUL) |
|
202 | if (flag == LFR_SUCCESSFUL) | |
203 | { |
|
203 | { | |
204 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
204 | flag = set_sy_lfr_s1_bp_p0( TC ); | |
205 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
205 | flag = set_sy_lfr_s1_bp_p1( TC ); | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | return flag; |
|
208 | return flag; | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
211 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
212 | { |
|
212 | { | |
213 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
213 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
214 | * |
|
214 | * | |
215 | * @param TC points to the TeleCommand packet that is being processed |
|
215 | * @param TC points to the TeleCommand packet that is being processed | |
216 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
216 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
217 | * |
|
217 | * | |
218 | */ |
|
218 | */ | |
219 |
|
219 | |||
220 | int flag; |
|
220 | int flag; | |
221 | rtems_status_code status; |
|
221 | rtems_status_code status; | |
222 | unsigned char sy_lfr_s2_bp_p0; |
|
222 | unsigned char sy_lfr_s2_bp_p0; | |
223 | unsigned char sy_lfr_s2_bp_p1; |
|
223 | unsigned char sy_lfr_s2_bp_p1; | |
224 | float aux; |
|
224 | float aux; | |
225 |
|
225 | |||
226 | flag = LFR_SUCCESSFUL; |
|
226 | flag = LFR_SUCCESSFUL; | |
227 |
|
227 | |||
228 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
228 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
229 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
229 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
230 | flag = LFR_DEFAULT; |
|
230 | flag = LFR_DEFAULT; | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
233 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
234 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
234 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
235 |
|
235 | |||
236 | // sy_lfr_s2_bp_p0 |
|
236 | // sy_lfr_s2_bp_p0 | |
237 | if (flag == LFR_SUCCESSFUL) |
|
237 | if (flag == LFR_SUCCESSFUL) | |
238 | { |
|
238 | { | |
239 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
239 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) | |
240 | { |
|
240 | { | |
241 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); |
|
241 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); | |
242 | flag = WRONG_APP_DATA; |
|
242 | flag = WRONG_APP_DATA; | |
243 | } |
|
243 | } | |
244 | } |
|
244 | } | |
245 | // sy_lfr_s2_bp_p1 |
|
245 | // sy_lfr_s2_bp_p1 | |
246 | if (flag == LFR_SUCCESSFUL) |
|
246 | if (flag == LFR_SUCCESSFUL) | |
247 | { |
|
247 | { | |
248 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
248 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) | |
249 | { |
|
249 | { | |
250 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p1 ); |
|
250 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p1 ); | |
251 | flag = WRONG_APP_DATA; |
|
251 | flag = WRONG_APP_DATA; | |
252 | } |
|
252 | } | |
253 | } |
|
253 | } | |
254 | //****************************************************************** |
|
254 | //****************************************************************** | |
255 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
255 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 | |
256 | if (flag == LFR_SUCCESSFUL) |
|
256 | if (flag == LFR_SUCCESSFUL) | |
257 | { |
|
257 | { | |
258 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
258 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
259 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
259 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
260 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
260 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); | |
261 | if (aux > FLOAT_EQUAL_ZERO) |
|
261 | if (aux > FLOAT_EQUAL_ZERO) | |
262 | { |
|
262 | { | |
263 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); |
|
263 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); | |
264 | flag = LFR_DEFAULT; |
|
264 | flag = LFR_DEFAULT; | |
265 | } |
|
265 | } | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | // SET THE PARAMETERS |
|
268 | // SET THE PARAMETERS | |
269 | if (flag == LFR_SUCCESSFUL) |
|
269 | if (flag == LFR_SUCCESSFUL) | |
270 | { |
|
270 | { | |
271 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
271 | flag = set_sy_lfr_s2_bp_p0( TC ); | |
272 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
272 | flag = set_sy_lfr_s2_bp_p1( TC ); | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | return flag; |
|
275 | return flag; | |
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
278 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
279 | { |
|
279 | { | |
280 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
280 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
281 | * |
|
281 | * | |
282 | * @param TC points to the TeleCommand packet that is being processed |
|
282 | * @param TC points to the TeleCommand packet that is being processed | |
283 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
283 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
284 | * |
|
284 | * | |
285 | */ |
|
285 | */ | |
286 |
|
286 | |||
287 | int flag; |
|
287 | int flag; | |
288 |
|
288 | |||
289 | flag = LFR_DEFAULT; |
|
289 | flag = LFR_DEFAULT; | |
290 |
|
290 | |||
291 | flag = set_sy_lfr_kcoeff( TC, queue_id ); |
|
291 | flag = set_sy_lfr_kcoeff( TC, queue_id ); | |
292 |
|
292 | |||
293 | return flag; |
|
293 | return flag; | |
294 | } |
|
294 | } | |
295 |
|
295 | |||
296 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
296 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
297 | { |
|
297 | { | |
298 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
298 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
299 | * |
|
299 | * | |
300 | * @param TC points to the TeleCommand packet that is being processed |
|
300 | * @param TC points to the TeleCommand packet that is being processed | |
301 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
301 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
302 | * |
|
302 | * | |
303 | */ |
|
303 | */ | |
304 |
|
304 | |||
305 | int flag; |
|
305 | int flag; | |
306 |
|
306 | |||
307 | flag = LFR_DEFAULT; |
|
307 | flag = LFR_DEFAULT; | |
308 |
|
308 | |||
309 | flag = set_sy_lfr_fbins( TC ); |
|
309 | flag = set_sy_lfr_fbins( TC ); | |
310 |
|
310 | |||
311 | // once the fbins masks have been stored, they have to be merged with the masks which handle the reaction wheels frequencies filtering |
|
311 | // once the fbins masks have been stored, they have to be merged with the masks which handle the reaction wheels frequencies filtering | |
312 | merge_fbins_masks(); |
|
312 | merge_fbins_masks(); | |
313 |
|
313 | |||
314 | return flag; |
|
314 | return flag; | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
317 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
318 | { |
|
318 | { | |
319 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
319 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
320 | * |
|
320 | * | |
321 | * @param TC points to the TeleCommand packet that is being processed |
|
321 | * @param TC points to the TeleCommand packet that is being processed | |
322 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
322 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
323 | * |
|
323 | * | |
324 | */ |
|
324 | */ | |
325 |
|
325 | |||
326 | int flag; |
|
326 | int flag; | |
327 | unsigned char k; |
|
327 | unsigned char k; | |
328 |
|
328 | |||
329 | flag = LFR_DEFAULT; |
|
329 | flag = LFR_DEFAULT; | |
330 | k = INIT_CHAR; |
|
330 | k = INIT_CHAR; | |
331 |
|
331 | |||
332 | flag = check_sy_lfr_filter_parameters( TC, queue_id ); |
|
332 | flag = check_sy_lfr_filter_parameters( TC, queue_id ); | |
333 |
|
333 | |||
334 | if (flag == LFR_SUCCESSFUL) |
|
334 | if (flag == LFR_SUCCESSFUL) | |
335 | { |
|
335 | { | |
336 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ]; |
|
336 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ]; | |
337 | parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
337 | parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; | |
338 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_0 ]; |
|
338 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_0 ]; | |
339 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_1 ]; |
|
339 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_1 ]; | |
340 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_2 ]; |
|
340 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_2 ]; | |
341 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_3 ]; |
|
341 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_3 ]; | |
342 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
342 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |
343 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_0 ]; |
|
343 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_0 ]; | |
344 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_1 ]; |
|
344 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_1 ]; | |
345 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_2 ]; |
|
345 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_2 ]; | |
346 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_3 ]; |
|
346 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_3 ]; | |
347 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_0 ]; |
|
347 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_0 ]; | |
348 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_1 ]; |
|
348 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_1 ]; | |
349 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_2 ]; |
|
349 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_2 ]; | |
350 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_3 ]; |
|
350 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_3 ]; | |
351 |
|
351 | |||
352 | //**************************** |
|
352 | //**************************** | |
353 | // store PAS filter parameters |
|
353 | // store PAS filter parameters | |
354 | // sy_lfr_pas_filter_enabled |
|
354 | // sy_lfr_pas_filter_enabled | |
355 | filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled; |
|
355 | filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled; | |
356 | set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & BIT_PAS_FILTER_ENABLED ); |
|
356 | set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & BIT_PAS_FILTER_ENABLED ); | |
357 | // sy_lfr_pas_filter_modulus |
|
357 | // sy_lfr_pas_filter_modulus | |
358 | filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus; |
|
358 | filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus; | |
359 | // sy_lfr_pas_filter_tbad |
|
359 | // sy_lfr_pas_filter_tbad | |
360 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad, |
|
360 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad, | |
361 | parameter_dump_packet.sy_lfr_pas_filter_tbad ); |
|
361 | parameter_dump_packet.sy_lfr_pas_filter_tbad ); | |
362 | // sy_lfr_pas_filter_offset |
|
362 | // sy_lfr_pas_filter_offset | |
363 | filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset; |
|
363 | filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset; | |
364 | // sy_lfr_pas_filter_shift |
|
364 | // sy_lfr_pas_filter_shift | |
365 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift, |
|
365 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift, | |
366 | parameter_dump_packet.sy_lfr_pas_filter_shift ); |
|
366 | parameter_dump_packet.sy_lfr_pas_filter_shift ); | |
367 |
|
367 | |||
368 | //**************************************************** |
|
368 | //**************************************************** | |
369 | // store the parameter sy_lfr_sc_rw_delta_f as a float |
|
369 | // store the parameter sy_lfr_sc_rw_delta_f as a float | |
370 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f, |
|
370 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f, | |
371 | parameter_dump_packet.sy_lfr_sc_rw_delta_f ); |
|
371 | parameter_dump_packet.sy_lfr_sc_rw_delta_f ); | |
372 |
|
372 | |||
373 | // copy rw.._k.. from the incoming TC to the local parameter_dump_packet |
|
373 | // copy rw.._k.. from the incoming TC to the local parameter_dump_packet | |
374 | for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++) |
|
374 | for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++) | |
375 | { |
|
375 | { | |
376 | parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ]; |
|
376 | parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ]; | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | //*********************************************** |
|
379 | //*********************************************** | |
380 | // store the parameter sy_lfr_rw.._k.. as a float |
|
380 | // store the parameter sy_lfr_rw.._k.. as a float | |
381 | // rw1_k |
|
381 | // rw1_k | |
382 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 ); |
|
382 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 ); | |
383 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 ); |
|
383 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 ); | |
384 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 ); |
|
384 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 ); | |
385 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 ); |
|
385 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 ); | |
386 | // rw2_k |
|
386 | // rw2_k | |
387 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 ); |
|
387 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 ); | |
388 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 ); |
|
388 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 ); | |
389 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 ); |
|
389 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 ); | |
390 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 ); |
|
390 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 ); | |
391 | // rw3_k |
|
391 | // rw3_k | |
392 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 ); |
|
392 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 ); | |
393 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 ); |
|
393 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 ); | |
394 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 ); |
|
394 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 ); | |
395 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 ); |
|
395 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 ); | |
396 | // rw4_k |
|
396 | // rw4_k | |
397 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 ); |
|
397 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 ); | |
398 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 ); |
|
398 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 ); | |
399 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 ); |
|
399 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 ); | |
400 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 ); |
|
400 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 ); | |
401 |
|
401 | |||
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | return flag; |
|
404 | return flag; | |
405 | } |
|
405 | } | |
406 |
|
406 | |||
407 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
407 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
408 | { |
|
408 | { | |
409 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
409 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
410 | * |
|
410 | * | |
411 | * @param TC points to the TeleCommand packet that is being processed |
|
411 | * @param TC points to the TeleCommand packet that is being processed | |
412 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
412 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
413 | * |
|
413 | * | |
414 | */ |
|
414 | */ | |
415 |
|
415 | |||
416 | unsigned int address; |
|
416 | unsigned int address; | |
417 | rtems_status_code status; |
|
417 | rtems_status_code status; | |
418 | unsigned int freq; |
|
418 | unsigned int freq; | |
419 | unsigned int bin; |
|
419 | unsigned int bin; | |
420 | unsigned int coeff; |
|
420 | unsigned int coeff; | |
421 | unsigned char *kCoeffPtr; |
|
421 | unsigned char *kCoeffPtr; | |
422 | unsigned char *kCoeffDumpPtr; |
|
422 | unsigned char *kCoeffDumpPtr; | |
423 |
|
423 | |||
424 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
424 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff | |
425 | // F0 => 11 bins |
|
425 | // F0 => 11 bins | |
426 | // F1 => 13 bins |
|
426 | // F1 => 13 bins | |
427 | // F2 => 12 bins |
|
427 | // F2 => 12 bins | |
428 | // 36 bins to dump in two packets (30 bins max per packet) |
|
428 | // 36 bins to dump in two packets (30 bins max per packet) | |
429 |
|
429 | |||
430 | //********* |
|
430 | //********* | |
431 | // PACKET 1 |
|
431 | // PACKET 1 | |
432 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
432 | // 11 F0 bins, 13 F1 bins and 6 F2 bins | |
433 | kcoefficients_dump_1.destinationID = TC->sourceID; |
|
433 | kcoefficients_dump_1.destinationID = TC->sourceID; | |
434 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); |
|
434 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); | |
435 | for( freq = 0; |
|
435 | for( freq = 0; | |
436 | freq < NB_BINS_COMPRESSED_SM_F0; |
|
436 | freq < NB_BINS_COMPRESSED_SM_F0; | |
437 | freq++ ) |
|
437 | freq++ ) | |
438 | { |
|
438 | { | |
439 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq; |
|
439 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq; | |
440 | bin = freq; |
|
440 | bin = freq; | |
441 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
441 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); | |
442 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
442 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
443 | { |
|
443 | { | |
444 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ |
|
444 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ | |
445 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ |
|
445 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ | |
446 | ]; // 2 for the kcoeff_frequency |
|
446 | ]; // 2 for the kcoeff_frequency | |
447 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
447 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
448 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
448 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
449 | } |
|
449 | } | |
450 | } |
|
450 | } | |
451 | for( freq = NB_BINS_COMPRESSED_SM_F0; |
|
451 | for( freq = NB_BINS_COMPRESSED_SM_F0; | |
452 | freq < ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); |
|
452 | freq < ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); | |
453 | freq++ ) |
|
453 | freq++ ) | |
454 | { |
|
454 | { | |
455 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = freq; |
|
455 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = freq; | |
456 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
456 | bin = freq - NB_BINS_COMPRESSED_SM_F0; | |
457 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
457 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); | |
458 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
458 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
459 | { |
|
459 | { | |
460 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ |
|
460 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ | |
461 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ |
|
461 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ | |
462 | ]; // 2 for the kcoeff_frequency |
|
462 | ]; // 2 for the kcoeff_frequency | |
463 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
463 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
464 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
464 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
465 | } |
|
465 | } | |
466 | } |
|
466 | } | |
467 | for( freq = ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); |
|
467 | for( freq = ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); | |
468 | freq < KCOEFF_BLK_NR_PKT1 ; |
|
468 | freq < KCOEFF_BLK_NR_PKT1 ; | |
469 | freq++ ) |
|
469 | freq++ ) | |
470 | { |
|
470 | { | |
471 | kcoefficients_dump_1.kcoeff_blks[ (freq * KCOEFF_BLK_SIZE) + 1 ] = freq; |
|
471 | kcoefficients_dump_1.kcoeff_blks[ (freq * KCOEFF_BLK_SIZE) + 1 ] = freq; | |
472 | bin = freq - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
472 | bin = freq - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
473 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
473 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
474 | for ( coeff = 0; coeff <NB_K_COEFF_PER_BIN; coeff++ ) |
|
474 | for ( coeff = 0; coeff <NB_K_COEFF_PER_BIN; coeff++ ) | |
475 | { |
|
475 | { | |
476 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ |
|
476 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ | |
477 | (freq * KCOEFF_BLK_SIZE) + (coeff * NB_BYTES_PER_FLOAT) + KCOEFF_FREQ |
|
477 | (freq * KCOEFF_BLK_SIZE) + (coeff * NB_BYTES_PER_FLOAT) + KCOEFF_FREQ | |
478 | ]; // 2 for the kcoeff_frequency |
|
478 | ]; // 2 for the kcoeff_frequency | |
479 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
479 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
480 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
480 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
481 | } |
|
481 | } | |
482 | } |
|
482 | } | |
483 | kcoefficients_dump_1.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
483 | kcoefficients_dump_1.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
484 | kcoefficients_dump_1.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
484 | kcoefficients_dump_1.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
485 | kcoefficients_dump_1.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
485 | kcoefficients_dump_1.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
486 | kcoefficients_dump_1.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
486 | kcoefficients_dump_1.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
487 | kcoefficients_dump_1.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
487 | kcoefficients_dump_1.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
488 | kcoefficients_dump_1.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
488 | kcoefficients_dump_1.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
489 | // SEND DATA |
|
489 | // SEND DATA | |
490 | kcoefficient_node_1.status = 1; |
|
490 | kcoefficient_node_1.status = 1; | |
491 | address = (unsigned int) &kcoefficient_node_1; |
|
491 | address = (unsigned int) &kcoefficient_node_1; | |
492 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
492 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
493 | if (status != RTEMS_SUCCESSFUL) { |
|
493 | if (status != RTEMS_SUCCESSFUL) { | |
494 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
494 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) | |
495 | } |
|
495 | } | |
496 |
|
496 | |||
497 | //******** |
|
497 | //******** | |
498 | // PACKET 2 |
|
498 | // PACKET 2 | |
499 | // 6 F2 bins |
|
499 | // 6 F2 bins | |
500 | kcoefficients_dump_2.destinationID = TC->sourceID; |
|
500 | kcoefficients_dump_2.destinationID = TC->sourceID; | |
501 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); |
|
501 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); | |
502 | for( freq = 0; |
|
502 | for( freq = 0; | |
503 | freq < KCOEFF_BLK_NR_PKT2; |
|
503 | freq < KCOEFF_BLK_NR_PKT2; | |
504 | freq++ ) |
|
504 | freq++ ) | |
505 | { |
|
505 | { | |
506 | kcoefficients_dump_2.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = KCOEFF_BLK_NR_PKT1 + freq; |
|
506 | kcoefficients_dump_2.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = KCOEFF_BLK_NR_PKT1 + freq; | |
507 | bin = freq + KCOEFF_BLK_NR_PKT2; |
|
507 | bin = freq + KCOEFF_BLK_NR_PKT2; | |
508 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
508 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
509 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
509 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
510 | { |
|
510 | { | |
511 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ |
|
511 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ | |
512 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ ]; // 2 for the kcoeff_frequency |
|
512 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ ]; // 2 for the kcoeff_frequency | |
513 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
513 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
514 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
514 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
515 | } |
|
515 | } | |
516 | } |
|
516 | } | |
517 | kcoefficients_dump_2.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
517 | kcoefficients_dump_2.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
518 | kcoefficients_dump_2.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
518 | kcoefficients_dump_2.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
519 | kcoefficients_dump_2.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
519 | kcoefficients_dump_2.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
520 | kcoefficients_dump_2.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
520 | kcoefficients_dump_2.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
521 | kcoefficients_dump_2.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
521 | kcoefficients_dump_2.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
522 | kcoefficients_dump_2.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
522 | kcoefficients_dump_2.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
523 | // SEND DATA |
|
523 | // SEND DATA | |
524 | kcoefficient_node_2.status = 1; |
|
524 | kcoefficient_node_2.status = 1; | |
525 | address = (unsigned int) &kcoefficient_node_2; |
|
525 | address = (unsigned int) &kcoefficient_node_2; | |
526 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
526 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
527 | if (status != RTEMS_SUCCESSFUL) { |
|
527 | if (status != RTEMS_SUCCESSFUL) { | |
528 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
528 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) | |
529 | } |
|
529 | } | |
530 |
|
530 | |||
531 | return status; |
|
531 | return status; | |
532 | } |
|
532 | } | |
533 |
|
533 | |||
534 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
534 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
535 | { |
|
535 | { | |
536 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
536 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
537 | * |
|
537 | * | |
538 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
538 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
539 | * |
|
539 | * | |
540 | * @return RTEMS directive status codes: |
|
540 | * @return RTEMS directive status codes: | |
541 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
541 | * - RTEMS_SUCCESSFUL - message sent successfully | |
542 | * - RTEMS_INVALID_ID - invalid queue id |
|
542 | * - RTEMS_INVALID_ID - invalid queue id | |
543 | * - RTEMS_INVALID_SIZE - invalid message size |
|
543 | * - RTEMS_INVALID_SIZE - invalid message size | |
544 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
544 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
545 | * - RTEMS_UNSATISFIED - out of message buffers |
|
545 | * - RTEMS_UNSATISFIED - out of message buffers | |
546 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
546 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
547 | * |
|
547 | * | |
548 | */ |
|
548 | */ | |
549 |
|
549 | |||
550 | int status; |
|
550 | int status; | |
551 |
|
551 | |||
552 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); |
|
552 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); | |
553 | parameter_dump_packet.destinationID = TC->sourceID; |
|
553 | parameter_dump_packet.destinationID = TC->sourceID; | |
554 |
|
554 | |||
555 | // UPDATE TIME |
|
555 | // UPDATE TIME | |
556 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
556 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
557 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
557 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
558 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
558 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
559 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
559 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
560 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
560 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
561 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
561 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
562 | // SEND DATA |
|
562 | // SEND DATA | |
563 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
563 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
564 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
564 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
565 | if (status != RTEMS_SUCCESSFUL) { |
|
565 | if (status != RTEMS_SUCCESSFUL) { | |
566 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
566 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
567 | } |
|
567 | } | |
568 |
|
568 | |||
569 | return status; |
|
569 | return status; | |
570 | } |
|
570 | } | |
571 |
|
571 | |||
572 | //*********************** |
|
572 | //*********************** | |
573 | // NORMAL MODE PARAMETERS |
|
573 | // NORMAL MODE PARAMETERS | |
574 |
|
574 | |||
575 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
575 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
576 | { |
|
576 | { | |
577 | unsigned char msb; |
|
577 | unsigned char msb; | |
578 | unsigned char lsb; |
|
578 | unsigned char lsb; | |
579 | int flag; |
|
579 | int flag; | |
580 | float aux; |
|
580 | float aux; | |
581 | rtems_status_code status; |
|
581 | rtems_status_code status; | |
582 |
|
582 | |||
583 | unsigned int sy_lfr_n_swf_l; |
|
583 | unsigned int sy_lfr_n_swf_l; | |
584 | unsigned int sy_lfr_n_swf_p; |
|
584 | unsigned int sy_lfr_n_swf_p; | |
585 | unsigned int sy_lfr_n_asm_p; |
|
585 | unsigned int sy_lfr_n_asm_p; | |
586 | unsigned char sy_lfr_n_bp_p0; |
|
586 | unsigned char sy_lfr_n_bp_p0; | |
587 | unsigned char sy_lfr_n_bp_p1; |
|
587 | unsigned char sy_lfr_n_bp_p1; | |
588 | unsigned char sy_lfr_n_cwf_long_f3; |
|
588 | unsigned char sy_lfr_n_cwf_long_f3; | |
589 |
|
589 | |||
590 | flag = LFR_SUCCESSFUL; |
|
590 | flag = LFR_SUCCESSFUL; | |
591 |
|
591 | |||
592 | //*************** |
|
592 | //*************** | |
593 | // get parameters |
|
593 | // get parameters | |
594 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
594 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
595 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
595 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
596 | sy_lfr_n_swf_l = (msb * CONST_256) + lsb; |
|
596 | sy_lfr_n_swf_l = (msb * CONST_256) + lsb; | |
597 |
|
597 | |||
598 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
598 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
599 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
599 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
600 | sy_lfr_n_swf_p = (msb * CONST_256) + lsb; |
|
600 | sy_lfr_n_swf_p = (msb * CONST_256) + lsb; | |
601 |
|
601 | |||
602 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
602 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
603 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
603 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
604 | sy_lfr_n_asm_p = (msb * CONST_256) + lsb; |
|
604 | sy_lfr_n_asm_p = (msb * CONST_256) + lsb; | |
605 |
|
605 | |||
606 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
606 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
607 |
|
607 | |||
608 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
608 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
609 |
|
609 | |||
610 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
610 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
611 |
|
611 | |||
612 | //****************** |
|
612 | //****************** | |
613 | // check consistency |
|
613 | // check consistency | |
614 | // sy_lfr_n_swf_l |
|
614 | // sy_lfr_n_swf_l | |
615 | if (sy_lfr_n_swf_l != DFLT_SY_LFR_N_SWF_L) |
|
615 | if (sy_lfr_n_swf_l != DFLT_SY_LFR_N_SWF_L) | |
616 | { |
|
616 | { | |
617 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L + DATAFIELD_OFFSET, sy_lfr_n_swf_l ); |
|
617 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L + DATAFIELD_OFFSET, sy_lfr_n_swf_l ); | |
618 | flag = WRONG_APP_DATA; |
|
618 | flag = WRONG_APP_DATA; | |
619 | } |
|
619 | } | |
620 | // sy_lfr_n_swf_p |
|
620 | // sy_lfr_n_swf_p | |
621 | if (flag == LFR_SUCCESSFUL) |
|
621 | if (flag == LFR_SUCCESSFUL) | |
622 | { |
|
622 | { | |
623 | if ( sy_lfr_n_swf_p < MIN_SY_LFR_N_SWF_P ) |
|
623 | if ( sy_lfr_n_swf_p < MIN_SY_LFR_N_SWF_P ) | |
624 | { |
|
624 | { | |
625 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P + DATAFIELD_OFFSET, sy_lfr_n_swf_p ); |
|
625 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P + DATAFIELD_OFFSET, sy_lfr_n_swf_p ); | |
626 | flag = WRONG_APP_DATA; |
|
626 | flag = WRONG_APP_DATA; | |
627 | } |
|
627 | } | |
628 | } |
|
628 | } | |
629 | // sy_lfr_n_bp_p0 |
|
629 | // sy_lfr_n_bp_p0 | |
630 | if (flag == LFR_SUCCESSFUL) |
|
630 | if (flag == LFR_SUCCESSFUL) | |
631 | { |
|
631 | { | |
632 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
632 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) | |
633 | { |
|
633 | { | |
634 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0 + DATAFIELD_OFFSET, sy_lfr_n_bp_p0 ); |
|
634 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0 + DATAFIELD_OFFSET, sy_lfr_n_bp_p0 ); | |
635 | flag = WRONG_APP_DATA; |
|
635 | flag = WRONG_APP_DATA; | |
636 | } |
|
636 | } | |
637 | } |
|
637 | } | |
638 | // sy_lfr_n_asm_p |
|
638 | // sy_lfr_n_asm_p | |
639 | if (flag == LFR_SUCCESSFUL) |
|
639 | if (flag == LFR_SUCCESSFUL) | |
640 | { |
|
640 | { | |
641 | if (sy_lfr_n_asm_p == 0) |
|
641 | if (sy_lfr_n_asm_p == 0) | |
642 | { |
|
642 | { | |
643 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); |
|
643 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); | |
644 | flag = WRONG_APP_DATA; |
|
644 | flag = WRONG_APP_DATA; | |
645 | } |
|
645 | } | |
646 | } |
|
646 | } | |
647 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
647 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 | |
648 | if (flag == LFR_SUCCESSFUL) |
|
648 | if (flag == LFR_SUCCESSFUL) | |
649 | { |
|
649 | { | |
650 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
650 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); | |
651 | if (aux > FLOAT_EQUAL_ZERO) |
|
651 | if (aux > FLOAT_EQUAL_ZERO) | |
652 | { |
|
652 | { | |
653 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); |
|
653 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); | |
654 | flag = WRONG_APP_DATA; |
|
654 | flag = WRONG_APP_DATA; | |
655 | } |
|
655 | } | |
656 | } |
|
656 | } | |
657 | // sy_lfr_n_bp_p1 |
|
657 | // sy_lfr_n_bp_p1 | |
658 | if (flag == LFR_SUCCESSFUL) |
|
658 | if (flag == LFR_SUCCESSFUL) | |
659 | { |
|
659 | { | |
660 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
660 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) | |
661 | { |
|
661 | { | |
662 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); |
|
662 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); | |
663 | flag = WRONG_APP_DATA; |
|
663 | flag = WRONG_APP_DATA; | |
664 | } |
|
664 | } | |
665 | } |
|
665 | } | |
666 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
666 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 | |
667 | if (flag == LFR_SUCCESSFUL) |
|
667 | if (flag == LFR_SUCCESSFUL) | |
668 | { |
|
668 | { | |
669 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
669 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); | |
670 | if (aux > FLOAT_EQUAL_ZERO) |
|
670 | if (aux > FLOAT_EQUAL_ZERO) | |
671 | { |
|
671 | { | |
672 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); |
|
672 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); | |
673 | flag = LFR_DEFAULT; |
|
673 | flag = LFR_DEFAULT; | |
674 | } |
|
674 | } | |
675 | } |
|
675 | } | |
676 | // sy_lfr_n_cwf_long_f3 |
|
676 | // sy_lfr_n_cwf_long_f3 | |
677 |
|
677 | |||
678 | return flag; |
|
678 | return flag; | |
679 | } |
|
679 | } | |
680 |
|
680 | |||
681 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
681 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) | |
682 | { |
|
682 | { | |
683 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
683 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
684 | * |
|
684 | * | |
685 | * @param TC points to the TeleCommand packet that is being processed |
|
685 | * @param TC points to the TeleCommand packet that is being processed | |
686 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
686 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
687 | * |
|
687 | * | |
688 | */ |
|
688 | */ | |
689 |
|
689 | |||
690 | int result; |
|
690 | int result; | |
691 |
|
691 | |||
692 | result = LFR_SUCCESSFUL; |
|
692 | result = LFR_SUCCESSFUL; | |
693 |
|
693 | |||
694 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
694 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
695 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
695 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
696 |
|
696 | |||
697 | return result; |
|
697 | return result; | |
698 | } |
|
698 | } | |
699 |
|
699 | |||
700 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
700 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) | |
701 | { |
|
701 | { | |
702 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
702 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
703 | * |
|
703 | * | |
704 | * @param TC points to the TeleCommand packet that is being processed |
|
704 | * @param TC points to the TeleCommand packet that is being processed | |
705 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
705 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
706 | * |
|
706 | * | |
707 | */ |
|
707 | */ | |
708 |
|
708 | |||
709 | int result; |
|
709 | int result; | |
710 |
|
710 | |||
711 | result = LFR_SUCCESSFUL; |
|
711 | result = LFR_SUCCESSFUL; | |
712 |
|
712 | |||
713 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
713 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
714 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
714 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
715 |
|
715 | |||
716 | return result; |
|
716 | return result; | |
717 | } |
|
717 | } | |
718 |
|
718 | |||
719 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
719 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) | |
720 | { |
|
720 | { | |
721 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
721 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). | |
722 | * |
|
722 | * | |
723 | * @param TC points to the TeleCommand packet that is being processed |
|
723 | * @param TC points to the TeleCommand packet that is being processed | |
724 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
724 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
725 | * |
|
725 | * | |
726 | */ |
|
726 | */ | |
727 |
|
727 | |||
728 | int result; |
|
728 | int result; | |
729 |
|
729 | |||
730 | result = LFR_SUCCESSFUL; |
|
730 | result = LFR_SUCCESSFUL; | |
731 |
|
731 | |||
732 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
732 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
733 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
733 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
734 |
|
734 | |||
735 | return result; |
|
735 | return result; | |
736 | } |
|
736 | } | |
737 |
|
737 | |||
738 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
738 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
739 | { |
|
739 | { | |
740 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
740 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). | |
741 | * |
|
741 | * | |
742 | * @param TC points to the TeleCommand packet that is being processed |
|
742 | * @param TC points to the TeleCommand packet that is being processed | |
743 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
743 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
744 | * |
|
744 | * | |
745 | */ |
|
745 | */ | |
746 |
|
746 | |||
747 | int status; |
|
747 | int status; | |
748 |
|
748 | |||
749 | status = LFR_SUCCESSFUL; |
|
749 | status = LFR_SUCCESSFUL; | |
750 |
|
750 | |||
751 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
751 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
752 |
|
752 | |||
753 | return status; |
|
753 | return status; | |
754 | } |
|
754 | } | |
755 |
|
755 | |||
756 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
756 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) | |
757 | { |
|
757 | { | |
758 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
758 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
759 | * |
|
759 | * | |
760 | * @param TC points to the TeleCommand packet that is being processed |
|
760 | * @param TC points to the TeleCommand packet that is being processed | |
761 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
761 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
762 | * |
|
762 | * | |
763 | */ |
|
763 | */ | |
764 |
|
764 | |||
765 | int status; |
|
765 | int status; | |
766 |
|
766 | |||
767 | status = LFR_SUCCESSFUL; |
|
767 | status = LFR_SUCCESSFUL; | |
768 |
|
768 | |||
769 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
769 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
770 |
|
770 | |||
771 | return status; |
|
771 | return status; | |
772 | } |
|
772 | } | |
773 |
|
773 | |||
774 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
774 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) | |
775 | { |
|
775 | { | |
776 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
776 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. | |
777 | * |
|
777 | * | |
778 | * @param TC points to the TeleCommand packet that is being processed |
|
778 | * @param TC points to the TeleCommand packet that is being processed | |
779 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
779 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
780 | * |
|
780 | * | |
781 | */ |
|
781 | */ | |
782 |
|
782 | |||
783 | int status; |
|
783 | int status; | |
784 |
|
784 | |||
785 | status = LFR_SUCCESSFUL; |
|
785 | status = LFR_SUCCESSFUL; | |
786 |
|
786 | |||
787 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
787 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
788 |
|
788 | |||
789 | return status; |
|
789 | return status; | |
790 | } |
|
790 | } | |
791 |
|
791 | |||
792 | //********************** |
|
792 | //********************** | |
793 | // BURST MODE PARAMETERS |
|
793 | // BURST MODE PARAMETERS | |
794 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
794 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) | |
795 | { |
|
795 | { | |
796 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
796 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). | |
797 | * |
|
797 | * | |
798 | * @param TC points to the TeleCommand packet that is being processed |
|
798 | * @param TC points to the TeleCommand packet that is being processed | |
799 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
799 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
800 | * |
|
800 | * | |
801 | */ |
|
801 | */ | |
802 |
|
802 | |||
803 | int status; |
|
803 | int status; | |
804 |
|
804 | |||
805 | status = LFR_SUCCESSFUL; |
|
805 | status = LFR_SUCCESSFUL; | |
806 |
|
806 | |||
807 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
807 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
808 |
|
808 | |||
809 | return status; |
|
809 | return status; | |
810 | } |
|
810 | } | |
811 |
|
811 | |||
812 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
812 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
813 | { |
|
813 | { | |
814 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
814 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). | |
815 | * |
|
815 | * | |
816 | * @param TC points to the TeleCommand packet that is being processed |
|
816 | * @param TC points to the TeleCommand packet that is being processed | |
817 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
817 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
818 | * |
|
818 | * | |
819 | */ |
|
819 | */ | |
820 |
|
820 | |||
821 | int status; |
|
821 | int status; | |
822 |
|
822 | |||
823 | status = LFR_SUCCESSFUL; |
|
823 | status = LFR_SUCCESSFUL; | |
824 |
|
824 | |||
825 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
825 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
826 |
|
826 | |||
827 | return status; |
|
827 | return status; | |
828 | } |
|
828 | } | |
829 |
|
829 | |||
830 | //********************* |
|
830 | //********************* | |
831 | // SBM1 MODE PARAMETERS |
|
831 | // SBM1 MODE PARAMETERS | |
832 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
832 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
833 | { |
|
833 | { | |
834 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
834 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). | |
835 | * |
|
835 | * | |
836 | * @param TC points to the TeleCommand packet that is being processed |
|
836 | * @param TC points to the TeleCommand packet that is being processed | |
837 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
837 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
838 | * |
|
838 | * | |
839 | */ |
|
839 | */ | |
840 |
|
840 | |||
841 | int status; |
|
841 | int status; | |
842 |
|
842 | |||
843 | status = LFR_SUCCESSFUL; |
|
843 | status = LFR_SUCCESSFUL; | |
844 |
|
844 | |||
845 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
845 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
846 |
|
846 | |||
847 | return status; |
|
847 | return status; | |
848 | } |
|
848 | } | |
849 |
|
849 | |||
850 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
850 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
851 | { |
|
851 | { | |
852 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
852 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). | |
853 | * |
|
853 | * | |
854 | * @param TC points to the TeleCommand packet that is being processed |
|
854 | * @param TC points to the TeleCommand packet that is being processed | |
855 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
855 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
856 | * |
|
856 | * | |
857 | */ |
|
857 | */ | |
858 |
|
858 | |||
859 | int status; |
|
859 | int status; | |
860 |
|
860 | |||
861 | status = LFR_SUCCESSFUL; |
|
861 | status = LFR_SUCCESSFUL; | |
862 |
|
862 | |||
863 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
863 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
864 |
|
864 | |||
865 | return status; |
|
865 | return status; | |
866 | } |
|
866 | } | |
867 |
|
867 | |||
868 | //********************* |
|
868 | //********************* | |
869 | // SBM2 MODE PARAMETERS |
|
869 | // SBM2 MODE PARAMETERS | |
870 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
870 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
871 | { |
|
871 | { | |
872 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
872 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). | |
873 | * |
|
873 | * | |
874 | * @param TC points to the TeleCommand packet that is being processed |
|
874 | * @param TC points to the TeleCommand packet that is being processed | |
875 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
875 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
876 | * |
|
876 | * | |
877 | */ |
|
877 | */ | |
878 |
|
878 | |||
879 | int status; |
|
879 | int status; | |
880 |
|
880 | |||
881 | status = LFR_SUCCESSFUL; |
|
881 | status = LFR_SUCCESSFUL; | |
882 |
|
882 | |||
883 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
883 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
884 |
|
884 | |||
885 | return status; |
|
885 | return status; | |
886 | } |
|
886 | } | |
887 |
|
887 | |||
888 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
888 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
889 | { |
|
889 | { | |
890 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
890 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). | |
891 | * |
|
891 | * | |
892 | * @param TC points to the TeleCommand packet that is being processed |
|
892 | * @param TC points to the TeleCommand packet that is being processed | |
893 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
893 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
894 | * |
|
894 | * | |
895 | */ |
|
895 | */ | |
896 |
|
896 | |||
897 | int status; |
|
897 | int status; | |
898 |
|
898 | |||
899 | status = LFR_SUCCESSFUL; |
|
899 | status = LFR_SUCCESSFUL; | |
900 |
|
900 | |||
901 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
901 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
902 |
|
902 | |||
903 | return status; |
|
903 | return status; | |
904 | } |
|
904 | } | |
905 |
|
905 | |||
906 | //******************* |
|
906 | //******************* | |
907 | // TC_LFR_UPDATE_INFO |
|
907 | // TC_LFR_UPDATE_INFO | |
908 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
908 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) | |
909 | { |
|
909 | { | |
910 | unsigned int status; |
|
910 | unsigned int status; | |
911 |
|
911 | |||
912 | status = LFR_DEFAULT; |
|
912 | status = LFR_DEFAULT; | |
913 |
|
913 | |||
914 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
914 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) | |
915 | || (mode == LFR_MODE_BURST) |
|
915 | || (mode == LFR_MODE_BURST) | |
916 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
916 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) | |
917 | { |
|
917 | { | |
918 | status = LFR_SUCCESSFUL; |
|
918 | status = LFR_SUCCESSFUL; | |
919 | } |
|
919 | } | |
920 | else |
|
920 | else | |
921 | { |
|
921 | { | |
922 | status = LFR_DEFAULT; |
|
922 | status = LFR_DEFAULT; | |
923 | } |
|
923 | } | |
924 |
|
924 | |||
925 | return status; |
|
925 | return status; | |
926 | } |
|
926 | } | |
927 |
|
927 | |||
928 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
928 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) | |
929 | { |
|
929 | { | |
930 | unsigned int status; |
|
930 | unsigned int status; | |
931 |
|
931 | |||
932 | status = LFR_DEFAULT; |
|
932 | status = LFR_DEFAULT; | |
933 |
|
933 | |||
934 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
934 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) | |
935 | || (mode == TDS_MODE_BURST) |
|
935 | || (mode == TDS_MODE_BURST) | |
936 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
936 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) | |
937 | || (mode == TDS_MODE_LFM)) |
|
937 | || (mode == TDS_MODE_LFM)) | |
938 | { |
|
938 | { | |
939 | status = LFR_SUCCESSFUL; |
|
939 | status = LFR_SUCCESSFUL; | |
940 | } |
|
940 | } | |
941 | else |
|
941 | else | |
942 | { |
|
942 | { | |
943 | status = LFR_DEFAULT; |
|
943 | status = LFR_DEFAULT; | |
944 | } |
|
944 | } | |
945 |
|
945 | |||
946 | return status; |
|
946 | return status; | |
947 | } |
|
947 | } | |
948 |
|
948 | |||
949 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
949 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) | |
950 | { |
|
950 | { | |
951 | unsigned int status; |
|
951 | unsigned int status; | |
952 |
|
952 | |||
953 | status = LFR_DEFAULT; |
|
953 | status = LFR_DEFAULT; | |
954 |
|
954 | |||
955 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
955 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) | |
956 | || (mode == THR_MODE_BURST)) |
|
956 | || (mode == THR_MODE_BURST)) | |
957 | { |
|
957 | { | |
958 | status = LFR_SUCCESSFUL; |
|
958 | status = LFR_SUCCESSFUL; | |
959 | } |
|
959 | } | |
960 | else |
|
960 | else | |
961 | { |
|
961 | { | |
962 | status = LFR_DEFAULT; |
|
962 | status = LFR_DEFAULT; | |
963 | } |
|
963 | } | |
964 |
|
964 | |||
965 | return status; |
|
965 | return status; | |
966 | } |
|
966 | } | |
967 |
|
967 | |||
968 | void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value ) |
|
968 | void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value ) | |
969 | { |
|
969 | { | |
970 | unsigned char flag; |
|
970 | unsigned char flag; | |
971 | unsigned char flagPosInByte; |
|
971 | unsigned char flagPosInByte; | |
972 | unsigned char newFlag; |
|
972 | unsigned char newFlag; | |
973 | unsigned char flagMask; |
|
973 | unsigned char flagMask; | |
974 |
|
974 | |||
975 | // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered |
|
975 | // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered | |
976 | if (isnan(value)) |
|
976 | if (isnan(value)) | |
977 | { |
|
977 | { | |
978 | flag = FLAG_NAN; |
|
978 | flag = FLAG_NAN; | |
979 | } |
|
979 | } | |
980 | else |
|
980 | else | |
981 | { |
|
981 | { | |
982 | flag = FLAG_IAN; |
|
982 | flag = FLAG_IAN; | |
983 | } |
|
983 | } | |
984 |
|
984 | |||
985 | switch(wheel) |
|
985 | switch(wheel) | |
986 | { |
|
986 | { | |
987 | case WHEEL_1: |
|
987 | case WHEEL_1: | |
988 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; |
|
988 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; | |
989 | flagMask = ~(1 << flagPosInByte); |
|
989 | flagMask = ~(1 << flagPosInByte); | |
990 | newFlag = flag << flagPosInByte; |
|
990 | newFlag = flag << flagPosInByte; | |
991 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; |
|
991 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; | |
992 | break; |
|
992 | break; | |
993 | case WHEEL_2: |
|
993 | case WHEEL_2: | |
994 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; |
|
994 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; | |
995 | flagMask = ~(1 << flagPosInByte); |
|
995 | flagMask = ~(1 << flagPosInByte); | |
996 | newFlag = flag << flagPosInByte; |
|
996 | newFlag = flag << flagPosInByte; | |
997 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; |
|
997 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; | |
998 | break; |
|
998 | break; | |
999 | case WHEEL_3: |
|
999 | case WHEEL_3: | |
1000 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; |
|
1000 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; | |
1001 | flagMask = ~(1 << flagPosInByte); |
|
1001 | flagMask = ~(1 << flagPosInByte); | |
1002 | newFlag = flag << flagPosInByte; |
|
1002 | newFlag = flag << flagPosInByte; | |
1003 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; |
|
1003 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; | |
1004 | break; |
|
1004 | break; | |
1005 | case WHEEL_4: |
|
1005 | case WHEEL_4: | |
1006 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; |
|
1006 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; | |
1007 | flagMask = ~(1 << flagPosInByte); |
|
1007 | flagMask = ~(1 << flagPosInByte); | |
1008 | newFlag = flag << flagPosInByte; |
|
1008 | newFlag = flag << flagPosInByte; | |
1009 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; |
|
1009 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; | |
1010 | break; |
|
1010 | break; | |
1011 | default: |
|
1011 | default: | |
1012 | break; |
|
1012 | break; | |
1013 | } |
|
1013 | } | |
1014 | } |
|
1014 | } | |
1015 |
|
1015 | |||
1016 | void set_hk_lfr_sc_rw_f_flags( void ) |
|
1016 | void set_hk_lfr_sc_rw_f_flags( void ) | |
1017 | { |
|
1017 | { | |
1018 | // RW1 |
|
1018 | // RW1 | |
1019 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_1, rw_f.cp_rpw_sc_rw1_f1 ); |
|
1019 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_1, rw_f.cp_rpw_sc_rw1_f1 ); | |
1020 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_2, rw_f.cp_rpw_sc_rw1_f2 ); |
|
1020 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_2, rw_f.cp_rpw_sc_rw1_f2 ); | |
1021 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_3, rw_f.cp_rpw_sc_rw1_f3 ); |
|
1021 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_3, rw_f.cp_rpw_sc_rw1_f3 ); | |
1022 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_4, rw_f.cp_rpw_sc_rw1_f4 ); |
|
1022 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_4, rw_f.cp_rpw_sc_rw1_f4 ); | |
1023 |
|
1023 | |||
1024 | // RW2 |
|
1024 | // RW2 | |
1025 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_1, rw_f.cp_rpw_sc_rw2_f1 ); |
|
1025 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_1, rw_f.cp_rpw_sc_rw2_f1 ); | |
1026 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_2, rw_f.cp_rpw_sc_rw2_f2 ); |
|
1026 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_2, rw_f.cp_rpw_sc_rw2_f2 ); | |
1027 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_3, rw_f.cp_rpw_sc_rw2_f3 ); |
|
1027 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_3, rw_f.cp_rpw_sc_rw2_f3 ); | |
1028 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_4, rw_f.cp_rpw_sc_rw2_f4 ); |
|
1028 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_4, rw_f.cp_rpw_sc_rw2_f4 ); | |
1029 |
|
1029 | |||
1030 | // RW3 |
|
1030 | // RW3 | |
1031 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_1, rw_f.cp_rpw_sc_rw3_f1 ); |
|
1031 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_1, rw_f.cp_rpw_sc_rw3_f1 ); | |
1032 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_2, rw_f.cp_rpw_sc_rw3_f2 ); |
|
1032 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_2, rw_f.cp_rpw_sc_rw3_f2 ); | |
1033 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_3, rw_f.cp_rpw_sc_rw3_f3 ); |
|
1033 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_3, rw_f.cp_rpw_sc_rw3_f3 ); | |
1034 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_4, rw_f.cp_rpw_sc_rw3_f4 ); |
|
1034 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_4, rw_f.cp_rpw_sc_rw3_f4 ); | |
1035 |
|
1035 | |||
1036 | // RW4 |
|
1036 | // RW4 | |
1037 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_1, rw_f.cp_rpw_sc_rw4_f1 ); |
|
1037 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_1, rw_f.cp_rpw_sc_rw4_f1 ); | |
1038 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_2, rw_f.cp_rpw_sc_rw4_f2 ); |
|
1038 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_2, rw_f.cp_rpw_sc_rw4_f2 ); | |
1039 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_3, rw_f.cp_rpw_sc_rw4_f3 ); |
|
1039 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_3, rw_f.cp_rpw_sc_rw4_f3 ); | |
1040 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_4, rw_f.cp_rpw_sc_rw4_f4 ); |
|
1040 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_4, rw_f.cp_rpw_sc_rw4_f4 ); | |
1041 | } |
|
1041 | } | |
1042 |
|
1042 | |||
1043 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ) |
|
1043 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ) | |
1044 | { |
|
1044 | { | |
1045 | /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally. |
|
1045 | /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally. | |
1046 | * |
|
1046 | * | |
1047 | * @param TC points to the TeleCommand packet that is being processed |
|
1047 | * @param TC points to the TeleCommand packet that is being processed | |
1048 | * |
|
1048 | * | |
1049 | */ |
|
1049 | */ | |
1050 |
|
1050 | |||
1051 | unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet |
|
1051 | unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet | |
1052 |
|
1052 | |||
1053 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
1053 | bytePosPtr = (unsigned char *) &TC->packetID; | |
1054 |
|
1054 | |||
1055 | // rw1_f |
|
1055 | // rw1_f | |
1056 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] ); |
|
1056 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] ); | |
1057 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] ); |
|
1057 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] ); | |
1058 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] ); |
|
1058 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] ); | |
1059 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] ); |
|
1059 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] ); | |
1060 |
|
1060 | |||
1061 | // rw2_f |
|
1061 | // rw2_f | |
1062 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] ); |
|
1062 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] ); | |
1063 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] ); |
|
1063 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] ); | |
1064 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] ); |
|
1064 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] ); | |
1065 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] ); |
|
1065 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] ); | |
1066 |
|
1066 | |||
1067 | // rw3_f |
|
1067 | // rw3_f | |
1068 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] ); |
|
1068 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] ); | |
1069 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] ); |
|
1069 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] ); | |
1070 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] ); |
|
1070 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] ); | |
1071 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] ); |
|
1071 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] ); | |
1072 |
|
1072 | |||
1073 | // rw4_f |
|
1073 | // rw4_f | |
1074 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] ); |
|
1074 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] ); | |
1075 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] ); |
|
1075 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] ); | |
1076 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] ); |
|
1076 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] ); | |
1077 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] ); |
|
1077 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] ); | |
1078 |
|
1078 | |||
1079 | // test each reaction wheel frequency value. NaN means that the frequency is not filtered |
|
1079 | // test each reaction wheel frequency value. NaN means that the frequency is not filtered | |
1080 |
|
1080 | |||
1081 | } |
|
1081 | } | |
1082 |
|
1082 | |||
1083 | void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k ) |
|
1083 | void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k ) | |
1084 | { |
|
1084 | { | |
1085 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
1085 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
1086 | * |
|
1086 | * | |
1087 | * @param fbins_mask |
|
1087 | * @param fbins_mask | |
1088 | * @param rw_f is the reaction wheel frequency to filter |
|
1088 | * @param rw_f is the reaction wheel frequency to filter | |
1089 | * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel |
|
1089 | * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel | |
1090 | * @param flag [true] filtering enabled [false] filtering disabled |
|
1090 | * @param flag [true] filtering enabled [false] filtering disabled | |
1091 | * |
|
1091 | * | |
1092 | * @return void |
|
1092 | * @return void | |
1093 | * |
|
1093 | * | |
1094 | */ |
|
1094 | */ | |
1095 |
|
1095 | |||
1096 | float f_RW_min; |
|
1096 | float f_RW_min; | |
1097 | float f_RW_MAX; |
|
1097 | float f_RW_MAX; | |
1098 | float fi_min; |
|
1098 | float fi_min; | |
1099 | float fi_MAX; |
|
1099 | float fi_MAX; | |
1100 | float fi; |
|
1100 | float fi; | |
1101 | float deltaBelow; |
|
1101 | float deltaBelow; | |
1102 | float deltaAbove; |
|
1102 | float deltaAbove; | |
1103 | float freqToFilterOut; |
|
1103 | float freqToFilterOut; | |
1104 | int binBelow; |
|
1104 | int binBelow; | |
1105 | int binAbove; |
|
1105 | int binAbove; | |
1106 | int closestBin; |
|
1106 | int closestBin; | |
1107 | unsigned int whichByte; |
|
1107 | unsigned int whichByte; | |
1108 | int selectedByte; |
|
1108 | int selectedByte; | |
1109 | int bin; |
|
1109 | int bin; | |
1110 | int binToRemove[NB_BINS_TO_REMOVE]; |
|
1110 | int binToRemove[NB_BINS_TO_REMOVE]; | |
1111 | int k; |
|
1111 | int k; | |
1112 | bool filteringSet; |
|
1112 | bool filteringSet; | |
1113 |
|
1113 | |||
1114 | closestBin = 0; |
|
1114 | closestBin = 0; | |
1115 | whichByte = 0; |
|
1115 | whichByte = 0; | |
1116 | bin = 0; |
|
1116 | bin = 0; | |
1117 | filteringSet = false; |
|
1117 | filteringSet = false; | |
1118 |
|
1118 | |||
1119 | for (k = 0; k < NB_BINS_TO_REMOVE; k++) |
|
1119 | for (k = 0; k < NB_BINS_TO_REMOVE; k++) | |
1120 | { |
|
1120 | { | |
1121 | binToRemove[k] = -1; |
|
1121 | binToRemove[k] = -1; | |
1122 | } |
|
1122 | } | |
1123 |
|
1123 | |||
1124 | if (!isnan(rw_f)) |
|
1124 | if (!isnan(rw_f)) | |
1125 | { |
|
1125 | { | |
1126 | // compute the frequency range to filter [ rw_f - delta_f; rw_f + delta_f ] |
|
1126 | // compute the frequency range to filter [ rw_f - delta_f; rw_f + delta_f ] | |
1127 | f_RW_min = rw_f - ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k); |
|
1127 | f_RW_min = rw_f - ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k); | |
1128 | f_RW_MAX = rw_f + ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k); |
|
1128 | f_RW_MAX = rw_f + ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k); | |
1129 |
|
1129 | |||
1130 | freqToFilterOut = f_RW_min; |
|
1130 | freqToFilterOut = f_RW_min; | |
1131 | while ( filteringSet == false ) |
|
1131 | while ( filteringSet == false ) | |
1132 | { |
|
1132 | { | |
1133 | // compute the index of the frequency bin immediately below rw_f |
|
1133 | // compute the index of the frequency bin immediately below rw_f | |
1134 | binBelow = (int) ( floor( ((double) freqToFilterOut) / ((double) deltaFreq)) ); |
|
1134 | binBelow = (int) ( floor( ((double) freqToFilterOut) / ((double) deltaFreq)) ); | |
1135 | deltaBelow = freqToFilterOut - binBelow * deltaFreq; |
|
1135 | deltaBelow = freqToFilterOut - binBelow * deltaFreq; | |
1136 |
|
1136 | |||
1137 | // compute the index of the frequency bin immediately above rw_f |
|
1137 | // compute the index of the frequency bin immediately above rw_f | |
1138 | binAbove = (int) ( ceil( ((double) freqToFilterOut) / ((double) deltaFreq)) ); |
|
1138 | binAbove = (int) ( ceil( ((double) freqToFilterOut) / ((double) deltaFreq)) ); | |
1139 | deltaAbove = binAbove * deltaFreq - freqToFilterOut; |
|
1139 | deltaAbove = binAbove * deltaFreq - freqToFilterOut; | |
1140 |
|
1140 | |||
1141 | // search the closest bin |
|
1141 | // search the closest bin | |
1142 | if (deltaAbove > deltaBelow) |
|
1142 | if (deltaAbove > deltaBelow) | |
1143 | { |
|
1143 | { | |
1144 | closestBin = binBelow; |
|
1144 | closestBin = binBelow; | |
1145 | } |
|
1145 | } | |
1146 | else |
|
1146 | else | |
1147 | { |
|
1147 | { | |
1148 | closestBin = binAbove; |
|
1148 | closestBin = binAbove; | |
1149 | } |
|
1149 | } | |
1150 |
|
1150 | |||
1151 | // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285] |
|
1151 | // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285] | |
1152 | fi = closestBin * deltaFreq; |
|
1152 | fi = closestBin * deltaFreq; | |
1153 | fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF); |
|
1153 | fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF); | |
1154 | fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF); |
|
1154 | fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF); | |
1155 |
|
1155 | |||
1156 | //************************************************************************************** |
|
1156 | //************************************************************************************** | |
1157 | // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra |
|
1157 | // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra | |
1158 | // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum |
|
1158 | // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum | |
1159 | //************************************************************************************** |
|
1159 | //************************************************************************************** | |
1160 |
|
1160 | |||
1161 | // 1. IF freqToFilterOut is included in [ fi_min; fi_MAX ] |
|
1161 | // 1. IF freqToFilterOut is included in [ fi_min; fi_MAX ] | |
1162 | // => remove f_(i), f_(i-1) and f_(i+1) |
|
1162 | // => remove f_(i), f_(i-1) and f_(i+1) | |
1163 | if ( ( freqToFilterOut > fi_min ) && ( freqToFilterOut < fi_MAX ) ) |
|
1163 | if ( ( freqToFilterOut > fi_min ) && ( freqToFilterOut < fi_MAX ) ) | |
1164 | { |
|
1164 | { | |
1165 | binToRemove[0] = (closestBin - 1) - 1; |
|
1165 | binToRemove[0] = (closestBin - 1) - 1; | |
1166 | binToRemove[1] = (closestBin) - 1; |
|
1166 | binToRemove[1] = (closestBin) - 1; | |
1167 | binToRemove[2] = (closestBin + 1) - 1; |
|
1167 | binToRemove[2] = (closestBin + 1) - 1; | |
1168 | } |
|
1168 | } | |
1169 | // 2. ELSE |
|
1169 | // 2. ELSE | |
1170 | // => remove the two f_(i) which are around f_RW |
|
1170 | // => remove the two f_(i) which are around f_RW | |
1171 | else |
|
1171 | else | |
1172 | { |
|
1172 | { | |
1173 | binToRemove[0] = (binBelow) - 1; |
|
1173 | binToRemove[0] = (binBelow) - 1; | |
1174 | binToRemove[1] = (binAbove) - 1; |
|
1174 | binToRemove[1] = (binAbove) - 1; | |
1175 | binToRemove[2] = (-1); |
|
1175 | binToRemove[2] = (-1); | |
1176 | } |
|
1176 | } | |
1177 |
|
1177 | |||
1178 | for (k = 0; k < NB_BINS_TO_REMOVE; k++) |
|
1178 | for (k = 0; k < NB_BINS_TO_REMOVE; k++) | |
1179 | { |
|
1179 | { | |
1180 | bin = binToRemove[k]; |
|
1180 | bin = binToRemove[k]; | |
1181 | if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) ) |
|
1181 | if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) ) | |
1182 | { |
|
1182 | { | |
1183 | whichByte = (bin >> SHIFT_3_BITS); // division by 8 |
|
1183 | whichByte = (bin >> SHIFT_3_BITS); // division by 8 | |
1184 | selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) ); |
|
1184 | selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) ); | |
1185 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] = |
|
1185 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] = | |
1186 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets |
|
1186 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets | |
1187 |
|
1187 | |||
1188 | } |
|
1188 | } | |
1189 | } |
|
1189 | } | |
1190 |
|
1190 | |||
1191 | // update freqToFilterOut |
|
1191 | // update freqToFilterOut | |
1192 | if ( freqToFilterOut == f_RW_MAX ) |
|
1192 | if ( freqToFilterOut == f_RW_MAX ) | |
1193 | { |
|
1193 | { | |
1194 | filteringSet = true; // end of the loop |
|
1194 | filteringSet = true; // end of the loop | |
1195 | } |
|
1195 | } | |
1196 | else |
|
1196 | else | |
1197 | { |
|
1197 | { | |
1198 | freqToFilterOut = freqToFilterOut + deltaFreq; |
|
1198 | freqToFilterOut = freqToFilterOut + deltaFreq; | |
1199 | } |
|
1199 | } | |
1200 |
|
1200 | |||
1201 | if ( freqToFilterOut > f_RW_MAX) |
|
1201 | if ( freqToFilterOut > f_RW_MAX) | |
1202 | { |
|
1202 | { | |
1203 | freqToFilterOut = f_RW_MAX; |
|
1203 | freqToFilterOut = f_RW_MAX; | |
1204 | } |
|
1204 | } | |
1205 | } |
|
1205 | } | |
1206 | } |
|
1206 | } | |
1207 | } |
|
1207 | } | |
1208 |
|
1208 | |||
1209 | void build_sy_lfr_rw_mask( unsigned int channel ) |
|
1209 | void build_sy_lfr_rw_mask( unsigned int channel ) | |
1210 | { |
|
1210 | { | |
1211 | unsigned char local_rw_fbins_mask[BYTES_PER_MASK]; |
|
1211 | unsigned char local_rw_fbins_mask[BYTES_PER_MASK]; | |
1212 | unsigned char *maskPtr; |
|
1212 | unsigned char *maskPtr; | |
1213 | double deltaF; |
|
1213 | double deltaF; | |
1214 | unsigned k; |
|
1214 | unsigned k; | |
1215 |
|
1215 | |||
1216 | maskPtr = NULL; |
|
1216 | maskPtr = NULL; | |
1217 | deltaF = DELTAF_F2; |
|
1217 | deltaF = DELTAF_F2; | |
1218 |
|
1218 | |||
1219 | switch (channel) |
|
1219 | switch (channel) | |
1220 | { |
|
1220 | { | |
1221 | case CHANNELF0: |
|
1221 | case CHANNELF0: | |
1222 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1222 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; | |
1223 | deltaF = DELTAF_F0; |
|
1223 | deltaF = DELTAF_F0; | |
1224 | break; |
|
1224 | break; | |
1225 | case CHANNELF1: |
|
1225 | case CHANNELF1: | |
1226 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1226 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; | |
1227 | deltaF = DELTAF_F1; |
|
1227 | deltaF = DELTAF_F1; | |
1228 | break; |
|
1228 | break; | |
1229 | case CHANNELF2: |
|
1229 | case CHANNELF2: | |
1230 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1230 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; | |
1231 | deltaF = DELTAF_F2; |
|
1231 | deltaF = DELTAF_F2; | |
1232 | break; |
|
1232 | break; | |
1233 | default: |
|
1233 | default: | |
1234 | break; |
|
1234 | break; | |
1235 | } |
|
1235 | } | |
1236 |
|
1236 | |||
1237 | for (k = 0; k < BYTES_PER_MASK; k++) |
|
1237 | for (k = 0; k < BYTES_PER_MASK; k++) | |
1238 | { |
|
1238 | { | |
1239 | local_rw_fbins_mask[k] = INT8_ALL_F; |
|
1239 | local_rw_fbins_mask[k] = INT8_ALL_F; | |
1240 | } |
|
1240 | } | |
1241 |
|
1241 | |||
1242 | // RW1 |
|
1242 | // RW1 | |
1243 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 ); |
|
1243 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 ); | |
1244 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 ); |
|
1244 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 ); | |
1245 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 ); |
|
1245 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 ); | |
1246 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 ); |
|
1246 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 ); | |
1247 |
|
1247 | |||
1248 | // RW2 |
|
1248 | // RW2 | |
1249 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 ); |
|
1249 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 ); | |
1250 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 ); |
|
1250 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 ); | |
1251 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 ); |
|
1251 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 ); | |
1252 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 ); |
|
1252 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 ); | |
1253 |
|
1253 | |||
1254 | // RW3 |
|
1254 | // RW3 | |
1255 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 ); |
|
1255 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 ); | |
1256 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 ); |
|
1256 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 ); | |
1257 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 ); |
|
1257 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 ); | |
1258 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 ); |
|
1258 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 ); | |
1259 |
|
1259 | |||
1260 | // RW4 |
|
1260 | // RW4 | |
1261 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 ); |
|
1261 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 ); | |
1262 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 ); |
|
1262 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 ); | |
1263 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 ); |
|
1263 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 ); | |
1264 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 ); |
|
1264 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 ); | |
1265 |
|
1265 | |||
1266 | // update the value of the fbins related to reaction wheels frequency filtering |
|
1266 | // update the value of the fbins related to reaction wheels frequency filtering | |
1267 | if (maskPtr != NULL) |
|
1267 | if (maskPtr != NULL) | |
1268 | { |
|
1268 | { | |
1269 | for (k = 0; k < BYTES_PER_MASK; k++) |
|
1269 | for (k = 0; k < BYTES_PER_MASK; k++) | |
1270 | { |
|
1270 | { | |
1271 | maskPtr[k] = local_rw_fbins_mask[k]; |
|
1271 | maskPtr[k] = local_rw_fbins_mask[k]; | |
1272 | } |
|
1272 | } | |
1273 | } |
|
1273 | } | |
1274 | } |
|
1274 | } | |
1275 |
|
1275 | |||
1276 | void build_sy_lfr_rw_masks( void ) |
|
1276 | void build_sy_lfr_rw_masks( void ) | |
1277 | { |
|
1277 | { | |
1278 | build_sy_lfr_rw_mask( CHANNELF0 ); |
|
1278 | build_sy_lfr_rw_mask( CHANNELF0 ); | |
1279 | build_sy_lfr_rw_mask( CHANNELF1 ); |
|
1279 | build_sy_lfr_rw_mask( CHANNELF1 ); | |
1280 | build_sy_lfr_rw_mask( CHANNELF2 ); |
|
1280 | build_sy_lfr_rw_mask( CHANNELF2 ); | |
1281 | } |
|
1281 | } | |
1282 |
|
1282 | |||
1283 | void merge_fbins_masks( void ) |
|
1283 | void merge_fbins_masks( void ) | |
1284 | { |
|
1284 | { | |
1285 | unsigned char k; |
|
1285 | unsigned char k; | |
1286 |
|
1286 | |||
1287 | unsigned char *fbins_f0; |
|
1287 | unsigned char *fbins_f0; | |
1288 | unsigned char *fbins_f1; |
|
1288 | unsigned char *fbins_f1; | |
1289 | unsigned char *fbins_f2; |
|
1289 | unsigned char *fbins_f2; | |
1290 | unsigned char *rw_mask_f0; |
|
1290 | unsigned char *rw_mask_f0; | |
1291 | unsigned char *rw_mask_f1; |
|
1291 | unsigned char *rw_mask_f1; | |
1292 | unsigned char *rw_mask_f2; |
|
1292 | unsigned char *rw_mask_f2; | |
1293 |
|
1293 | |||
1294 | fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1294 | fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
1295 | fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; |
|
1295 | fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; | |
1296 | fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1; |
|
1296 | fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1; | |
1297 | rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1297 | rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; | |
1298 | rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1298 | rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; | |
1299 | rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1299 | rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; | |
1300 |
|
1300 | |||
1301 | for( k=0; k < BYTES_PER_MASK; k++ ) |
|
1301 | for( k=0; k < BYTES_PER_MASK; k++ ) | |
1302 | { |
|
1302 | { | |
1303 | fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k]; |
|
1303 | fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k]; | |
1304 | fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k]; |
|
1304 | fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k]; | |
1305 | fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k]; |
|
1305 | fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k]; | |
1306 | } |
|
1306 | } | |
1307 | } |
|
1307 | } | |
1308 |
|
1308 | |||
1309 | //*********** |
|
1309 | //*********** | |
1310 | // FBINS MASK |
|
1310 | // FBINS MASK | |
1311 |
|
1311 | |||
1312 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
1312 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) | |
1313 | { |
|
1313 | { | |
1314 | int status; |
|
1314 | int status; | |
1315 | unsigned int k; |
|
1315 | unsigned int k; | |
1316 | unsigned char *fbins_mask_dump; |
|
1316 | unsigned char *fbins_mask_dump; | |
1317 | unsigned char *fbins_mask_TC; |
|
1317 | unsigned char *fbins_mask_TC; | |
1318 |
|
1318 | |||
1319 | status = LFR_SUCCESSFUL; |
|
1319 | status = LFR_SUCCESSFUL; | |
1320 |
|
1320 | |||
1321 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1321 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
1322 | fbins_mask_TC = TC->dataAndCRC; |
|
1322 | fbins_mask_TC = TC->dataAndCRC; | |
1323 |
|
1323 | |||
1324 | for (k=0; k < BYTES_PER_MASKS_SET; k++) |
|
1324 | for (k=0; k < BYTES_PER_MASKS_SET; k++) | |
1325 | { |
|
1325 | { | |
1326 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
1326 | fbins_mask_dump[k] = fbins_mask_TC[k]; | |
1327 | } |
|
1327 | } | |
1328 |
|
1328 | |||
1329 | return status; |
|
1329 | return status; | |
1330 | } |
|
1330 | } | |
1331 |
|
1331 | |||
1332 | //*************************** |
|
1332 | //*************************** | |
1333 | // TC_LFR_LOAD_PAS_FILTER_PAR |
|
1333 | // TC_LFR_LOAD_PAS_FILTER_PAR | |
1334 |
|
1334 | |||
|
1335 | int check_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value ) | |||
|
1336 | { | |||
|
1337 | float rw_k; | |||
|
1338 | int ret; | |||
|
1339 | ||||
|
1340 | ret = LFR_SUCCESSFUL; | |||
|
1341 | rw_k = INIT_FLOAT; | |||
|
1342 | ||||
|
1343 | copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->dataAndCRC[ offset ] ); | |||
|
1344 | ||||
|
1345 | *pos = offset; | |||
|
1346 | *value = rw_k; | |||
|
1347 | ||||
|
1348 | if (rw_k < MIN_SY_LFR_RW_K) | |||
|
1349 | { | |||
|
1350 | ret = WRONG_APP_DATA; | |||
|
1351 | } | |||
|
1352 | ||||
|
1353 | return ret; | |||
|
1354 | } | |||
|
1355 | ||||
|
1356 | int check_all_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int *pos, float*value ) | |||
|
1357 | { | |||
|
1358 | int ret; | |||
|
1359 | ||||
|
1360 | ret = LFR_SUCCESSFUL; | |||
|
1361 | ||||
|
1362 | //**** | |||
|
1363 | //**** | |||
|
1364 | // RW1 | |||
|
1365 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K1, pos, value ); // K1 | |||
|
1366 | if (ret == LFR_SUCCESSFUL) // K2 | |||
|
1367 | { | |||
|
1368 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K2, pos, value ); | |||
|
1369 | } | |||
|
1370 | if (ret == LFR_SUCCESSFUL) // K3 | |||
|
1371 | { | |||
|
1372 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K3, pos, value ); | |||
|
1373 | } | |||
|
1374 | if (ret == LFR_SUCCESSFUL) // K4 | |||
|
1375 | { | |||
|
1376 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K4, pos, value ); | |||
|
1377 | } | |||
|
1378 | ||||
|
1379 | //**** | |||
|
1380 | //**** | |||
|
1381 | // RW2 | |||
|
1382 | if (ret == LFR_SUCCESSFUL) // K1 | |||
|
1383 | { | |||
|
1384 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K1, pos, value ); | |||
|
1385 | } | |||
|
1386 | if (ret == LFR_SUCCESSFUL) // K2 | |||
|
1387 | { | |||
|
1388 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K2, pos, value ); | |||
|
1389 | } | |||
|
1390 | if (ret == LFR_SUCCESSFUL) // K3 | |||
|
1391 | { | |||
|
1392 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K3, pos, value ); | |||
|
1393 | } | |||
|
1394 | if (ret == LFR_SUCCESSFUL) // K4 | |||
|
1395 | { | |||
|
1396 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K4, pos, value ); | |||
|
1397 | } | |||
|
1398 | ||||
|
1399 | //**** | |||
|
1400 | //**** | |||
|
1401 | // RW3 | |||
|
1402 | if (ret == LFR_SUCCESSFUL) // K1 | |||
|
1403 | { | |||
|
1404 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K1, pos, value ); | |||
|
1405 | } | |||
|
1406 | if (ret == LFR_SUCCESSFUL) // K2 | |||
|
1407 | { | |||
|
1408 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K2, pos, value ); | |||
|
1409 | } | |||
|
1410 | if (ret == LFR_SUCCESSFUL) // K3 | |||
|
1411 | { | |||
|
1412 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K3, pos, value ); | |||
|
1413 | } | |||
|
1414 | if (ret == LFR_SUCCESSFUL) // K4 | |||
|
1415 | { | |||
|
1416 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K4, pos, value ); | |||
|
1417 | } | |||
|
1418 | ||||
|
1419 | //**** | |||
|
1420 | //**** | |||
|
1421 | // RW4 | |||
|
1422 | if (ret == LFR_SUCCESSFUL) // K1 | |||
|
1423 | { | |||
|
1424 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K1, pos, value ); | |||
|
1425 | } | |||
|
1426 | if (ret == LFR_SUCCESSFUL) // K2 | |||
|
1427 | { | |||
|
1428 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K2, pos, value ); | |||
|
1429 | } | |||
|
1430 | if (ret == LFR_SUCCESSFUL) // K3 | |||
|
1431 | { | |||
|
1432 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K3, pos, value ); | |||
|
1433 | } | |||
|
1434 | if (ret == LFR_SUCCESSFUL) // K4 | |||
|
1435 | { | |||
|
1436 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K4, pos, value ); | |||
|
1437 | } | |||
|
1438 | ||||
|
1439 | ||||
|
1440 | ||||
|
1441 | return ret; | |||
|
1442 | } | |||
|
1443 | ||||
1335 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
1444 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
1336 | { |
|
1445 | { | |
1337 | int flag; |
|
1446 | int flag; | |
1338 | rtems_status_code status; |
|
1447 | rtems_status_code status; | |
1339 |
|
1448 | |||
1340 | unsigned char sy_lfr_pas_filter_enabled; |
|
1449 | unsigned char sy_lfr_pas_filter_enabled; | |
1341 | unsigned char sy_lfr_pas_filter_modulus; |
|
1450 | unsigned char sy_lfr_pas_filter_modulus; | |
1342 | float sy_lfr_pas_filter_tbad; |
|
1451 | float sy_lfr_pas_filter_tbad; | |
1343 | unsigned char sy_lfr_pas_filter_offset; |
|
1452 | unsigned char sy_lfr_pas_filter_offset; | |
1344 | float sy_lfr_pas_filter_shift; |
|
1453 | float sy_lfr_pas_filter_shift; | |
1345 | float sy_lfr_sc_rw_delta_f; |
|
1454 | float sy_lfr_sc_rw_delta_f; | |
1346 | char *parPtr; |
|
1455 | char *parPtr; | |
|
1456 | int *datafield_pos; | |||
|
1457 | float *rw_k; | |||
1347 |
|
1458 | |||
1348 | flag = LFR_SUCCESSFUL; |
|
1459 | flag = LFR_SUCCESSFUL; | |
1349 | sy_lfr_pas_filter_tbad = INIT_FLOAT; |
|
1460 | sy_lfr_pas_filter_tbad = INIT_FLOAT; | |
1350 | sy_lfr_pas_filter_shift = INIT_FLOAT; |
|
1461 | sy_lfr_pas_filter_shift = INIT_FLOAT; | |
1351 | sy_lfr_sc_rw_delta_f = INIT_FLOAT; |
|
1462 | sy_lfr_sc_rw_delta_f = INIT_FLOAT; | |
1352 | parPtr = NULL; |
|
1463 | parPtr = NULL; | |
|
1464 | datafield_pos = NULL; | |||
|
1465 | rw_k = NULL; | |||
|
1466 | ||||
|
1467 | *datafield_pos = LFR_DEFAULT_ALT; | |||
|
1468 | *rw_k = INIT_FLOAT; | |||
1353 |
|
1469 | |||
1354 | //*************** |
|
1470 | //*************** | |
1355 | // get parameters |
|
1471 | // get parameters | |
1356 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001] |
|
1472 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001] | |
1357 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
1473 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; | |
1358 | copyFloatByChar( |
|
1474 | copyFloatByChar( | |
1359 | (unsigned char*) &sy_lfr_pas_filter_tbad, |
|
1475 | (unsigned char*) &sy_lfr_pas_filter_tbad, | |
1360 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ] |
|
1476 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ] | |
1361 | ); |
|
1477 | ); | |
1362 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
1478 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |
1363 | copyFloatByChar( |
|
1479 | copyFloatByChar( | |
1364 | (unsigned char*) &sy_lfr_pas_filter_shift, |
|
1480 | (unsigned char*) &sy_lfr_pas_filter_shift, | |
1365 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ] |
|
1481 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ] | |
1366 | ); |
|
1482 | ); | |
1367 | copyFloatByChar( |
|
1483 | copyFloatByChar( | |
1368 | (unsigned char*) &sy_lfr_sc_rw_delta_f, |
|
1484 | (unsigned char*) &sy_lfr_sc_rw_delta_f, | |
1369 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ] |
|
1485 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ] | |
1370 | ); |
|
1486 | ); | |
1371 |
|
1487 | |||
1372 | //****************** |
|
1488 | //****************** | |
1373 | // CHECK CONSISTENCY |
|
1489 | // CHECK CONSISTENCY | |
1374 |
|
1490 | |||
1375 | //************************** |
|
1491 | //************************** | |
1376 | // sy_lfr_pas_filter_enabled |
|
1492 | // sy_lfr_pas_filter_enabled | |
1377 | // nothing to check, value is 0 or 1 |
|
1493 | // nothing to check, value is 0 or 1 | |
1378 |
|
1494 | |||
1379 | //************************** |
|
1495 | //************************** | |
1380 | // sy_lfr_pas_filter_modulus |
|
1496 | // sy_lfr_pas_filter_modulus | |
1381 | if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) ) |
|
1497 | if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) ) | |
1382 | { |
|
1498 | { | |
1383 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); |
|
1499 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); | |
1384 | flag = WRONG_APP_DATA; |
|
1500 | flag = WRONG_APP_DATA; | |
1385 | } |
|
1501 | } | |
1386 |
|
1502 | |||
1387 | //*********************** |
|
1503 | //*********************** | |
1388 | // sy_lfr_pas_filter_tbad |
|
1504 | // sy_lfr_pas_filter_tbad | |
1389 | if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) ) |
|
1505 | if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) ) | |
1390 | { |
|
1506 | { | |
1391 | parPtr = (char*) &sy_lfr_pas_filter_tbad; |
|
1507 | parPtr = (char*) &sy_lfr_pas_filter_tbad; | |
1392 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); |
|
1508 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); | |
1393 | flag = WRONG_APP_DATA; |
|
1509 | flag = WRONG_APP_DATA; | |
1394 | } |
|
1510 | } | |
1395 |
|
1511 | |||
1396 | //************************* |
|
1512 | //************************* | |
1397 | // sy_lfr_pas_filter_offset |
|
1513 | // sy_lfr_pas_filter_offset | |
1398 | if (flag == LFR_SUCCESSFUL) |
|
1514 | if (flag == LFR_SUCCESSFUL) | |
1399 | { |
|
1515 | { | |
1400 | if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) ) |
|
1516 | if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) ) | |
1401 | { |
|
1517 | { | |
1402 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset ); |
|
1518 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset ); | |
1403 | flag = WRONG_APP_DATA; |
|
1519 | flag = WRONG_APP_DATA; | |
1404 | } |
|
1520 | } | |
1405 | } |
|
1521 | } | |
1406 |
|
1522 | |||
1407 | //************************ |
|
1523 | //************************ | |
1408 | // sy_lfr_pas_filter_shift |
|
1524 | // sy_lfr_pas_filter_shift | |
1409 | if (flag == LFR_SUCCESSFUL) |
|
1525 | if (flag == LFR_SUCCESSFUL) | |
1410 | { |
|
1526 | { | |
1411 | if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) ) |
|
1527 | if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) ) | |
1412 | { |
|
1528 | { | |
1413 | parPtr = (char*) &sy_lfr_pas_filter_shift; |
|
1529 | parPtr = (char*) &sy_lfr_pas_filter_shift; | |
1414 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); |
|
1530 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); | |
1415 | flag = WRONG_APP_DATA; |
|
1531 | flag = WRONG_APP_DATA; | |
1416 | } |
|
1532 | } | |
1417 | } |
|
1533 | } | |
1418 |
|
1534 | |||
1419 | //************************************* |
|
1535 | //************************************* | |
1420 | // check global coherency of the values |
|
1536 | // check global coherency of the values | |
1421 | if (flag == LFR_SUCCESSFUL) |
|
1537 | if (flag == LFR_SUCCESSFUL) | |
1422 | { |
|
1538 | { | |
1423 | if ( (sy_lfr_pas_filter_tbad + sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) > sy_lfr_pas_filter_modulus ) |
|
1539 | if ( (sy_lfr_pas_filter_tbad + sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) > sy_lfr_pas_filter_modulus ) | |
1424 | { |
|
1540 | { | |
1425 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); |
|
1541 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); | |
1426 | flag = WRONG_APP_DATA; |
|
1542 | flag = WRONG_APP_DATA; | |
1427 | } |
|
1543 | } | |
1428 | } |
|
1544 | } | |
1429 |
|
1545 | |||
1430 | //********************* |
|
1546 | //********************* | |
1431 | // sy_lfr_sc_rw_delta_f |
|
1547 | // sy_lfr_sc_rw_delta_f | |
1432 | // nothing to check, no default value in the ICD |
|
1548 | if (flag == LFR_SUCCESSFUL) | |
|
1549 | { | |||
|
1550 | if ( sy_lfr_sc_rw_delta_f < MIN_SY_LFR_SC_RW_DELTA_F ) | |||
|
1551 | { | |||
|
1552 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + DATAFIELD_OFFSET, sy_lfr_sc_rw_delta_f ); | |||
|
1553 | flag = WRONG_APP_DATA; | |||
|
1554 | } | |||
|
1555 | } | |||
|
1556 | ||||
|
1557 | //************ | |||
|
1558 | // sy_lfr_rw_k | |||
|
1559 | if (flag == LFR_SUCCESSFUL) | |||
|
1560 | { | |||
|
1561 | flag = check_all_sy_lfr_rw_k( TC, datafield_pos, rw_k ); | |||
|
1562 | if (flag != LFR_SUCCESSFUL) | |||
|
1563 | { | |||
|
1564 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, *datafield_pos + DATAFIELD_OFFSET, *rw_k ); | |||
|
1565 | } | |||
|
1566 | } | |||
|
1567 | ||||
1433 |
|
1568 | |||
1434 | return flag; |
|
1569 | return flag; | |
1435 | } |
|
1570 | } | |
1436 |
|
1571 | |||
1437 | //************** |
|
1572 | //************** | |
1438 | // KCOEFFICIENTS |
|
1573 | // KCOEFFICIENTS | |
1439 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
1574 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) | |
1440 | { |
|
1575 | { | |
1441 | unsigned int kcoeff; |
|
1576 | unsigned int kcoeff; | |
1442 | unsigned short sy_lfr_kcoeff_frequency; |
|
1577 | unsigned short sy_lfr_kcoeff_frequency; | |
1443 | unsigned short bin; |
|
1578 | unsigned short bin; | |
1444 | float *kcoeffPtr_norm; |
|
1579 | float *kcoeffPtr_norm; | |
1445 | float *kcoeffPtr_sbm; |
|
1580 | float *kcoeffPtr_sbm; | |
1446 | int status; |
|
1581 | int status; | |
1447 | unsigned char *kcoeffLoadPtr; |
|
1582 | unsigned char *kcoeffLoadPtr; | |
1448 | unsigned char *kcoeffNormPtr; |
|
1583 | unsigned char *kcoeffNormPtr; | |
1449 | unsigned char *kcoeffSbmPtr_a; |
|
1584 | unsigned char *kcoeffSbmPtr_a; | |
1450 | unsigned char *kcoeffSbmPtr_b; |
|
1585 | unsigned char *kcoeffSbmPtr_b; | |
1451 |
|
1586 | |||
1452 | sy_lfr_kcoeff_frequency = 0; |
|
1587 | sy_lfr_kcoeff_frequency = 0; | |
1453 | bin = 0; |
|
1588 | bin = 0; | |
1454 | kcoeffPtr_norm = NULL; |
|
1589 | kcoeffPtr_norm = NULL; | |
1455 | kcoeffPtr_sbm = NULL; |
|
1590 | kcoeffPtr_sbm = NULL; | |
1456 | status = LFR_SUCCESSFUL; |
|
1591 | status = LFR_SUCCESSFUL; | |
1457 |
|
1592 | |||
1458 | // copy the value of the frequency byte by byte DO NOT USE A SHORT* POINTER |
|
1593 | // copy the value of the frequency byte by byte DO NOT USE A SHORT* POINTER | |
1459 | copyInt16ByChar( (unsigned char*) &sy_lfr_kcoeff_frequency, &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] ); |
|
1594 | copyInt16ByChar( (unsigned char*) &sy_lfr_kcoeff_frequency, &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] ); | |
1460 |
|
1595 | |||
1461 |
|
1596 | |||
1462 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
1597 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) | |
1463 | { |
|
1598 | { | |
1464 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
1599 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) | |
1465 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET + 1, |
|
1600 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET + 1, | |
1466 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
1601 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB | |
1467 | status = LFR_DEFAULT; |
|
1602 | status = LFR_DEFAULT; | |
1468 | } |
|
1603 | } | |
1469 | else |
|
1604 | else | |
1470 | { |
|
1605 | { | |
1471 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
1606 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) | |
1472 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
1607 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) | |
1473 | { |
|
1608 | { | |
1474 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
1609 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; | |
1475 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
1610 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; | |
1476 | bin = sy_lfr_kcoeff_frequency; |
|
1611 | bin = sy_lfr_kcoeff_frequency; | |
1477 | } |
|
1612 | } | |
1478 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
1613 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) | |
1479 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
1614 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) | |
1480 | { |
|
1615 | { | |
1481 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
1616 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; | |
1482 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
1617 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; | |
1483 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
1618 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; | |
1484 | } |
|
1619 | } | |
1485 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
1620 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) | |
1486 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
1621 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) | |
1487 | { |
|
1622 | { | |
1488 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
1623 | kcoeffPtr_norm = k_coeff_intercalib_f2; | |
1489 | kcoeffPtr_sbm = NULL; |
|
1624 | kcoeffPtr_sbm = NULL; | |
1490 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
1625 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
1491 | } |
|
1626 | } | |
1492 | } |
|
1627 | } | |
1493 |
|
1628 | |||
1494 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
1629 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products | |
1495 | { |
|
1630 | { | |
1496 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1631 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1497 | { |
|
1632 | { | |
1498 | // destination |
|
1633 | // destination | |
1499 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
1634 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; | |
1500 | // source |
|
1635 | // source | |
1501 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; |
|
1636 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; | |
1502 | // copy source to destination |
|
1637 | // copy source to destination | |
1503 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
1638 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); | |
1504 | } |
|
1639 | } | |
1505 | } |
|
1640 | } | |
1506 |
|
1641 | |||
1507 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
1642 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products | |
1508 | { |
|
1643 | { | |
1509 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1644 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1510 | { |
|
1645 | { | |
1511 | // destination |
|
1646 | // destination | |
1512 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ]; |
|
1647 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ]; | |
1513 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ]; |
|
1648 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ]; | |
1514 | // source |
|
1649 | // source | |
1515 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; |
|
1650 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; | |
1516 | // copy source to destination |
|
1651 | // copy source to destination | |
1517 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
1652 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); | |
1518 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
1653 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); | |
1519 | } |
|
1654 | } | |
1520 | } |
|
1655 | } | |
1521 |
|
1656 | |||
1522 | // print_k_coeff(); |
|
1657 | // print_k_coeff(); | |
1523 |
|
1658 | |||
1524 | return status; |
|
1659 | return status; | |
1525 | } |
|
1660 | } | |
1526 |
|
1661 | |||
1527 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
1662 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) | |
1528 | { |
|
1663 | { | |
1529 | destination[BYTE_0] = source[BYTE_0]; |
|
1664 | destination[BYTE_0] = source[BYTE_0]; | |
1530 | destination[BYTE_1] = source[BYTE_1]; |
|
1665 | destination[BYTE_1] = source[BYTE_1]; | |
1531 | destination[BYTE_2] = source[BYTE_2]; |
|
1666 | destination[BYTE_2] = source[BYTE_2]; | |
1532 | destination[BYTE_3] = source[BYTE_3]; |
|
1667 | destination[BYTE_3] = source[BYTE_3]; | |
1533 | } |
|
1668 | } | |
1534 |
|
1669 | |||
1535 | void copyInt32ByChar( unsigned char *destination, unsigned char *source ) |
|
1670 | void copyInt32ByChar( unsigned char *destination, unsigned char *source ) | |
1536 | { |
|
1671 | { | |
1537 | destination[BYTE_0] = source[BYTE_0]; |
|
1672 | destination[BYTE_0] = source[BYTE_0]; | |
1538 | destination[BYTE_1] = source[BYTE_1]; |
|
1673 | destination[BYTE_1] = source[BYTE_1]; | |
1539 | destination[BYTE_2] = source[BYTE_2]; |
|
1674 | destination[BYTE_2] = source[BYTE_2]; | |
1540 | destination[BYTE_3] = source[BYTE_3]; |
|
1675 | destination[BYTE_3] = source[BYTE_3]; | |
1541 | } |
|
1676 | } | |
1542 |
|
1677 | |||
1543 | void copyInt16ByChar( unsigned char *destination, unsigned char *source ) |
|
1678 | void copyInt16ByChar( unsigned char *destination, unsigned char *source ) | |
1544 | { |
|
1679 | { | |
1545 | destination[BYTE_0] = source[BYTE_0]; |
|
1680 | destination[BYTE_0] = source[BYTE_0]; | |
1546 | destination[BYTE_1] = source[BYTE_1]; |
|
1681 | destination[BYTE_1] = source[BYTE_1]; | |
1547 | } |
|
1682 | } | |
1548 |
|
1683 | |||
1549 | void floatToChar( float value, unsigned char* ptr) |
|
1684 | void floatToChar( float value, unsigned char* ptr) | |
1550 | { |
|
1685 | { | |
1551 | unsigned char* valuePtr; |
|
1686 | unsigned char* valuePtr; | |
1552 |
|
1687 | |||
1553 | valuePtr = (unsigned char*) &value; |
|
1688 | valuePtr = (unsigned char*) &value; | |
1554 |
|
1689 | |||
1555 | ptr[BYTE_0] = valuePtr[BYTE_0]; |
|
1690 | ptr[BYTE_0] = valuePtr[BYTE_0]; | |
1556 | ptr[BYTE_1] = valuePtr[BYTE_1]; |
|
1691 | ptr[BYTE_1] = valuePtr[BYTE_1]; | |
1557 | ptr[BYTE_2] = valuePtr[BYTE_2]; |
|
1692 | ptr[BYTE_2] = valuePtr[BYTE_2]; | |
1558 | ptr[BYTE_3] = valuePtr[BYTE_3]; |
|
1693 | ptr[BYTE_3] = valuePtr[BYTE_3]; | |
1559 | } |
|
1694 | } | |
1560 |
|
1695 | |||
1561 | //********** |
|
1696 | //********** | |
1562 | // init dump |
|
1697 | // init dump | |
1563 |
|
1698 | |||
1564 | void init_parameter_dump( void ) |
|
1699 | void init_parameter_dump( void ) | |
1565 | { |
|
1700 | { | |
1566 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
1701 | /** This function initialize the parameter_dump_packet global variable with default values. | |
1567 | * |
|
1702 | * | |
1568 | */ |
|
1703 | */ | |
1569 |
|
1704 | |||
1570 | unsigned int k; |
|
1705 | unsigned int k; | |
1571 |
|
1706 | |||
1572 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1707 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1573 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1708 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1574 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
1709 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
1575 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1710 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
1576 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); |
|
1711 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); | |
1577 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1712 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1578 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1713 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1579 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1714 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1580 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE); |
|
1715 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE); | |
1581 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1716 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
1582 | // DATA FIELD HEADER |
|
1717 | // DATA FIELD HEADER | |
1583 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1718 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1584 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1719 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
1585 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1720 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
1586 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1721 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
1587 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
1722 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
1588 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
1723 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
1589 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
1724 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
1590 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
1725 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
1591 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
1726 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
1592 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
1727 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
1593 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1728 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
1594 |
|
1729 | |||
1595 | //****************** |
|
1730 | //****************** | |
1596 | // COMMON PARAMETERS |
|
1731 | // COMMON PARAMETERS | |
1597 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1732 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; | |
1598 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1733 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; | |
1599 |
|
1734 | |||
1600 | //****************** |
|
1735 | //****************** | |
1601 | // NORMAL PARAMETERS |
|
1736 | // NORMAL PARAMETERS | |
1602 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE); |
|
1737 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE); | |
1603 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1738 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); | |
1604 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE); |
|
1739 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE); | |
1605 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1740 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); | |
1606 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE); |
|
1741 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE); | |
1607 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1742 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); | |
1608 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1743 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; | |
1609 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1744 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; | |
1610 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1745 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; | |
1611 |
|
1746 | |||
1612 | //***************** |
|
1747 | //***************** | |
1613 | // BURST PARAMETERS |
|
1748 | // BURST PARAMETERS | |
1614 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1749 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
1615 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1750 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
1616 |
|
1751 | |||
1617 | //**************** |
|
1752 | //**************** | |
1618 | // SBM1 PARAMETERS |
|
1753 | // SBM1 PARAMETERS | |
1619 | 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 |
|
1754 | 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 | |
1620 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1755 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
1621 |
|
1756 | |||
1622 | //**************** |
|
1757 | //**************** | |
1623 | // SBM2 PARAMETERS |
|
1758 | // SBM2 PARAMETERS | |
1624 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1759 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
1625 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1760 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
1626 |
|
1761 | |||
1627 | //************ |
|
1762 | //************ | |
1628 | // FBINS MASKS |
|
1763 | // FBINS MASKS | |
1629 | for (k=0; k < BYTES_PER_MASKS_SET; k++) |
|
1764 | for (k=0; k < BYTES_PER_MASKS_SET; k++) | |
1630 | { |
|
1765 | { | |
1631 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F; |
|
1766 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F; | |
1632 | } |
|
1767 | } | |
1633 |
|
1768 | |||
1634 | // PAS FILTER PARAMETERS |
|
1769 | // PAS FILTER PARAMETERS | |
1635 | parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR; |
|
1770 | parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR; | |
1636 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR; |
|
1771 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR; | |
1637 | parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; |
|
1772 | parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; | |
1638 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad ); |
|
1773 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad ); | |
1639 | parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; |
|
1774 | parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; | |
1640 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift ); |
|
1775 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift ); | |
1641 | floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f ); |
|
1776 | floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f ); | |
1642 |
|
1777 | |||
1643 | // RW1_K |
|
1778 | // RW1_K | |
1644 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1); |
|
1779 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1); | |
1645 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2); |
|
1780 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2); | |
1646 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3); |
|
1781 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3); | |
1647 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4); |
|
1782 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4); | |
1648 | // RW2_K |
|
1783 | // RW2_K | |
1649 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1); |
|
1784 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1); | |
1650 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2); |
|
1785 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2); | |
1651 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3); |
|
1786 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3); | |
1652 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4); |
|
1787 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4); | |
1653 | // RW3_K |
|
1788 | // RW3_K | |
1654 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1); |
|
1789 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1); | |
1655 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2); |
|
1790 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2); | |
1656 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3); |
|
1791 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3); | |
1657 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4); |
|
1792 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4); | |
1658 | // RW4_K |
|
1793 | // RW4_K | |
1659 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1); |
|
1794 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1); | |
1660 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2); |
|
1795 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2); | |
1661 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3); |
|
1796 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3); | |
1662 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4); |
|
1797 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4); | |
1663 |
|
1798 | |||
1664 | // LFR_RW_MASK |
|
1799 | // LFR_RW_MASK | |
1665 | for (k=0; k < BYTES_PER_MASKS_SET; k++) |
|
1800 | for (k=0; k < BYTES_PER_MASKS_SET; k++) | |
1666 | { |
|
1801 | { | |
1667 | parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F; |
|
1802 | parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F; | |
1668 | } |
|
1803 | } | |
1669 |
|
1804 | |||
1670 | // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks |
|
1805 | // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks | |
1671 | merge_fbins_masks(); |
|
1806 | merge_fbins_masks(); | |
1672 | } |
|
1807 | } | |
1673 |
|
1808 | |||
1674 | void init_kcoefficients_dump( void ) |
|
1809 | void init_kcoefficients_dump( void ) | |
1675 | { |
|
1810 | { | |
1676 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 ); |
|
1811 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 ); | |
1677 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 ); |
|
1812 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 ); | |
1678 |
|
1813 | |||
1679 | kcoefficient_node_1.previous = NULL; |
|
1814 | kcoefficient_node_1.previous = NULL; | |
1680 | kcoefficient_node_1.next = NULL; |
|
1815 | kcoefficient_node_1.next = NULL; | |
1681 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1816 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; | |
1682 | kcoefficient_node_1.coarseTime = INIT_CHAR; |
|
1817 | kcoefficient_node_1.coarseTime = INIT_CHAR; | |
1683 | kcoefficient_node_1.fineTime = INIT_CHAR; |
|
1818 | kcoefficient_node_1.fineTime = INIT_CHAR; | |
1684 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1819 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; | |
1685 | kcoefficient_node_1.status = INIT_CHAR; |
|
1820 | kcoefficient_node_1.status = INIT_CHAR; | |
1686 |
|
1821 | |||
1687 | kcoefficient_node_2.previous = NULL; |
|
1822 | kcoefficient_node_2.previous = NULL; | |
1688 | kcoefficient_node_2.next = NULL; |
|
1823 | kcoefficient_node_2.next = NULL; | |
1689 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1824 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; | |
1690 | kcoefficient_node_2.coarseTime = INIT_CHAR; |
|
1825 | kcoefficient_node_2.coarseTime = INIT_CHAR; | |
1691 | kcoefficient_node_2.fineTime = INIT_CHAR; |
|
1826 | kcoefficient_node_2.fineTime = INIT_CHAR; | |
1692 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1827 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; | |
1693 | kcoefficient_node_2.status = INIT_CHAR; |
|
1828 | kcoefficient_node_2.status = INIT_CHAR; | |
1694 | } |
|
1829 | } | |
1695 |
|
1830 | |||
1696 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1831 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) | |
1697 | { |
|
1832 | { | |
1698 | unsigned int k; |
|
1833 | unsigned int k; | |
1699 | unsigned int packetLength; |
|
1834 | unsigned int packetLength; | |
1700 |
|
1835 | |||
1701 | packetLength = |
|
1836 | packetLength = | |
1702 | ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1837 | ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header | |
1703 |
|
1838 | |||
1704 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1839 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1705 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1840 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1706 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1841 | kcoefficients_dump->reserved = CCSDS_RESERVED; | |
1707 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1842 | kcoefficients_dump->userApplication = CCSDS_USER_APP; | |
1708 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); |
|
1843 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); | |
1709 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1844 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1710 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1845 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1711 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1846 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1712 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); |
|
1847 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); | |
1713 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1848 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; | |
1714 | // DATA FIELD HEADER |
|
1849 | // DATA FIELD HEADER | |
1715 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1850 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1716 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1851 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; | |
1717 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1852 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; | |
1718 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1853 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; | |
1719 | kcoefficients_dump->time[BYTE_0] = INIT_CHAR; |
|
1854 | kcoefficients_dump->time[BYTE_0] = INIT_CHAR; | |
1720 | kcoefficients_dump->time[BYTE_1] = INIT_CHAR; |
|
1855 | kcoefficients_dump->time[BYTE_1] = INIT_CHAR; | |
1721 | kcoefficients_dump->time[BYTE_2] = INIT_CHAR; |
|
1856 | kcoefficients_dump->time[BYTE_2] = INIT_CHAR; | |
1722 | kcoefficients_dump->time[BYTE_3] = INIT_CHAR; |
|
1857 | kcoefficients_dump->time[BYTE_3] = INIT_CHAR; | |
1723 | kcoefficients_dump->time[BYTE_4] = INIT_CHAR; |
|
1858 | kcoefficients_dump->time[BYTE_4] = INIT_CHAR; | |
1724 | kcoefficients_dump->time[BYTE_5] = INIT_CHAR; |
|
1859 | kcoefficients_dump->time[BYTE_5] = INIT_CHAR; | |
1725 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1860 | kcoefficients_dump->sid = SID_K_DUMP; | |
1726 |
|
1861 | |||
1727 | kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT; |
|
1862 | kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT; | |
1728 | kcoefficients_dump->pkt_nr = PKTNR_1; |
|
1863 | kcoefficients_dump->pkt_nr = PKTNR_1; | |
1729 | kcoefficients_dump->blk_nr = blk_nr; |
|
1864 | kcoefficients_dump->blk_nr = blk_nr; | |
1730 |
|
1865 | |||
1731 | //****************** |
|
1866 | //****************** | |
1732 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1867 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] | |
1733 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1868 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) | |
1734 | for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++) |
|
1869 | for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++) | |
1735 | { |
|
1870 | { | |
1736 | kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR; |
|
1871 | kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR; | |
1737 | } |
|
1872 | } | |
1738 | } |
|
1873 | } | |
1739 |
|
1874 | |||
1740 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) |
|
1875 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) | |
1741 | { |
|
1876 | { | |
1742 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. |
|
1877 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. | |
1743 | * |
|
1878 | * | |
1744 | * @param packet_sequence_control points to the packet sequence control which will be incremented |
|
1879 | * @param packet_sequence_control points to the packet sequence control which will be incremented | |
1745 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID |
|
1880 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID | |
1746 | * |
|
1881 | * | |
1747 | * If the destination ID is not known, a dedicated counter is incremented. |
|
1882 | * If the destination ID is not known, a dedicated counter is incremented. | |
1748 | * |
|
1883 | * | |
1749 | */ |
|
1884 | */ | |
1750 |
|
1885 | |||
1751 | unsigned short sequence_cnt; |
|
1886 | unsigned short sequence_cnt; | |
1752 | unsigned short segmentation_grouping_flag; |
|
1887 | unsigned short segmentation_grouping_flag; | |
1753 | unsigned short new_packet_sequence_control; |
|
1888 | unsigned short new_packet_sequence_control; | |
1754 | unsigned char i; |
|
1889 | unsigned char i; | |
1755 |
|
1890 | |||
1756 | switch (destination_id) |
|
1891 | switch (destination_id) | |
1757 | { |
|
1892 | { | |
1758 | case SID_TC_GROUND: |
|
1893 | case SID_TC_GROUND: | |
1759 | i = GROUND; |
|
1894 | i = GROUND; | |
1760 | break; |
|
1895 | break; | |
1761 | case SID_TC_MISSION_TIMELINE: |
|
1896 | case SID_TC_MISSION_TIMELINE: | |
1762 | i = MISSION_TIMELINE; |
|
1897 | i = MISSION_TIMELINE; | |
1763 | break; |
|
1898 | break; | |
1764 | case SID_TC_TC_SEQUENCES: |
|
1899 | case SID_TC_TC_SEQUENCES: | |
1765 | i = TC_SEQUENCES; |
|
1900 | i = TC_SEQUENCES; | |
1766 | break; |
|
1901 | break; | |
1767 | case SID_TC_RECOVERY_ACTION_CMD: |
|
1902 | case SID_TC_RECOVERY_ACTION_CMD: | |
1768 | i = RECOVERY_ACTION_CMD; |
|
1903 | i = RECOVERY_ACTION_CMD; | |
1769 | break; |
|
1904 | break; | |
1770 | case SID_TC_BACKUP_MISSION_TIMELINE: |
|
1905 | case SID_TC_BACKUP_MISSION_TIMELINE: | |
1771 | i = BACKUP_MISSION_TIMELINE; |
|
1906 | i = BACKUP_MISSION_TIMELINE; | |
1772 | break; |
|
1907 | break; | |
1773 | case SID_TC_DIRECT_CMD: |
|
1908 | case SID_TC_DIRECT_CMD: | |
1774 | i = DIRECT_CMD; |
|
1909 | i = DIRECT_CMD; | |
1775 | break; |
|
1910 | break; | |
1776 | case SID_TC_SPARE_GRD_SRC1: |
|
1911 | case SID_TC_SPARE_GRD_SRC1: | |
1777 | i = SPARE_GRD_SRC1; |
|
1912 | i = SPARE_GRD_SRC1; | |
1778 | break; |
|
1913 | break; | |
1779 | case SID_TC_SPARE_GRD_SRC2: |
|
1914 | case SID_TC_SPARE_GRD_SRC2: | |
1780 | i = SPARE_GRD_SRC2; |
|
1915 | i = SPARE_GRD_SRC2; | |
1781 | break; |
|
1916 | break; | |
1782 | case SID_TC_OBCP: |
|
1917 | case SID_TC_OBCP: | |
1783 | i = OBCP; |
|
1918 | i = OBCP; | |
1784 | break; |
|
1919 | break; | |
1785 | case SID_TC_SYSTEM_CONTROL: |
|
1920 | case SID_TC_SYSTEM_CONTROL: | |
1786 | i = SYSTEM_CONTROL; |
|
1921 | i = SYSTEM_CONTROL; | |
1787 | break; |
|
1922 | break; | |
1788 | case SID_TC_AOCS: |
|
1923 | case SID_TC_AOCS: | |
1789 | i = AOCS; |
|
1924 | i = AOCS; | |
1790 | break; |
|
1925 | break; | |
1791 | case SID_TC_RPW_INTERNAL: |
|
1926 | case SID_TC_RPW_INTERNAL: | |
1792 | i = RPW_INTERNAL; |
|
1927 | i = RPW_INTERNAL; | |
1793 | break; |
|
1928 | break; | |
1794 | default: |
|
1929 | default: | |
1795 | i = GROUND; |
|
1930 | i = GROUND; | |
1796 | break; |
|
1931 | break; | |
1797 | } |
|
1932 | } | |
1798 |
|
1933 | |||
1799 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; |
|
1934 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; | |
1800 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK; |
|
1935 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK; | |
1801 |
|
1936 | |||
1802 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; |
|
1937 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; | |
1803 |
|
1938 | |||
1804 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); |
|
1939 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); | |
1805 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1940 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1806 |
|
1941 | |||
1807 | // increment the sequence counter |
|
1942 | // increment the sequence counter | |
1808 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) |
|
1943 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) | |
1809 | { |
|
1944 | { | |
1810 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; |
|
1945 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; | |
1811 | } |
|
1946 | } | |
1812 | else |
|
1947 | else | |
1813 | { |
|
1948 | { | |
1814 | sequenceCounters_TM_DUMP[ i ] = 0; |
|
1949 | sequenceCounters_TM_DUMP[ i ] = 0; | |
1815 | } |
|
1950 | } | |
1816 | } |
|
1951 | } |
General Comments 0
You need to be logged in to leave comments.
Login now