##// END OF EJS Templates
Commit before going back to Rev 326
paul -
r330:cd97edc61709 R3++ draft
parent child
Show More
@@ -1,117 +1,118
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
23
23 #define BIT_RW1_F1 0x80
24 #define BIT_RW1_F1 0x80
24 #define BIT_RW1_F2 0x40
25 #define BIT_RW1_F2 0x40
25 #define BIT_RW2_F1 0x20
26 #define BIT_RW2_F1 0x20
26 #define BIT_RW2_F2 0x10
27 #define BIT_RW2_F2 0x10
27 #define BIT_RW3_F1 0x08
28 #define BIT_RW3_F1 0x08
28 #define BIT_RW3_F2 0x04
29 #define BIT_RW3_F2 0x04
29 #define BIT_RW4_F1 0x02
30 #define BIT_RW4_F1 0x02
30 #define BIT_RW4_F2 0x01
31 #define BIT_RW4_F2 0x01
31
32
32 #define WHEEL_1 1
33 #define WHEEL_1 1
33 #define WHEEL_2 2
34 #define WHEEL_2 2
34 #define WHEEL_3 3
35 #define WHEEL_3 3
35 #define WHEEL_4 4
36 #define WHEEL_4 4
36 #define FREQ_1 1
37 #define FREQ_1 1
37 #define FREQ_2 2
38 #define FREQ_2 2
38 #define FREQ_3 3
39 #define FREQ_3 3
39 #define FREQ_4 4
40 #define FREQ_4 4
40 #define FLAG_OFFSET_WHEELS_1_3 8
41 #define FLAG_OFFSET_WHEELS_1_3 8
41 #define FLAG_OFFSET_WHEELS_2_4 4
42 #define FLAG_OFFSET_WHEELS_2_4 4
42
43
43 #define FLAG_NAN 0 // Not A NUMBER
44 #define FLAG_NAN 0 // Not A NUMBER
44 #define FLAG_IAN 1 // Is A Number
45 #define FLAG_IAN 1 // Is A Number
45
46
46 #define SBM_KCOEFF_PER_NORM_KCOEFF 2
47 #define SBM_KCOEFF_PER_NORM_KCOEFF 2
47
48
48 extern unsigned short sequenceCounterParameterDump;
49 extern unsigned short sequenceCounterParameterDump;
49 extern unsigned short sequenceCounters_TM_DUMP[];
50 extern unsigned short sequenceCounters_TM_DUMP[];
50 extern float k_coeff_intercalib_f0_norm[ ];
51 extern float k_coeff_intercalib_f0_norm[ ];
51 extern float k_coeff_intercalib_f0_sbm[ ];
52 extern float k_coeff_intercalib_f0_sbm[ ];
52 extern float k_coeff_intercalib_f1_norm[ ];
53 extern float k_coeff_intercalib_f1_norm[ ];
53 extern float k_coeff_intercalib_f1_sbm[ ];
54 extern float k_coeff_intercalib_f1_sbm[ ];
54 extern float k_coeff_intercalib_f2[ ];
55 extern float k_coeff_intercalib_f2[ ];
55 extern fbins_masks_t fbins_masks;
56 extern fbins_masks_t fbins_masks;
56
57
57 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
58 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
58 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);
59 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);
60 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);
61 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);
62 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);
63 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);
64 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);
65 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);
66 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
67 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
67
68
68 // NORMAL
69 // NORMAL
69 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 );
70 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
71 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
71 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
72 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
72 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
73 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
73 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
74 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
74 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
75 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
75 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
76 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
76
77
77 // BURST
78 // BURST
78 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
79 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
79 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
80 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
80
81
81 // SBM1
82 // SBM1
82 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
83 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
83 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
84 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
84
85
85 // SBM2
86 // SBM2
86 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
87 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
87 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
88 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
88
89
89 // TC_LFR_UPDATE_INFO
90 // TC_LFR_UPDATE_INFO
90 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
91 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
91 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
92 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
92 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
93 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
93 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 );
94 void set_hk_lfr_sc_rw_f_flags( void );
95 void set_hk_lfr_sc_rw_f_flags( void );
95 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
96 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
96 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float k );
97 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float kcoeff );
97 void build_sy_lfr_rw_mask( unsigned int channel );
98 void build_sy_lfr_rw_mask( unsigned int channel );
98 void build_sy_lfr_rw_masks();
99 void build_sy_lfr_rw_masks();
99 void merge_fbins_masks( void );
100 void merge_fbins_masks( void );
100
101
101 // FBINS_MASK
102 // FBINS_MASK
102 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
103 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
103
104
104 // TC_LFR_LOAD_PARS_FILTER_PAR
105 // TC_LFR_LOAD_PARS_FILTER_PAR
105 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
106 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
106
107
107 // KCOEFFICIENTS
108 // KCOEFFICIENTS
108 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
109 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
109 void copyFloatByChar( unsigned char *destination, unsigned char *source );
110 void copyFloatByChar( unsigned char *destination, unsigned char *source );
110 void floatToChar( float value, unsigned char* ptr);
111 void floatToChar( float value, unsigned char* ptr);
111
112
112 void init_parameter_dump( void );
113 void init_parameter_dump( void );
113 void init_kcoefficients_dump( void );
114 void init_kcoefficients_dump( void );
114 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
115 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
115 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
116 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
116
117
117 #endif // TC_LOAD_DUMP_PARAMETERS_H
118 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,1782 +1,1780
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, &parameter_dump_packet,
563 status = rtems_message_queue_send( queue_id, &parameter_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 k )
1083 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float kcoeff )
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 int binBelow;
1103 int binBelow;
1104 int binAbove;
1104 int binAbove;
1105 int closestBin;
1105 int closestBin;
1106 unsigned int whichByte;
1106 unsigned int whichByte;
1107 int selectedByte;
1107 int selectedByte;
1108 int bin;
1108 int bin;
1109 int binToRemove[NB_BINS_TO_REMOVE];
1109 int binToRemove[NB_BINS_TO_REMOVE];
1110 int i;
1110 int i;
1111
1111
1112 closestBin = 0;
1112 closestBin = 0;
1113 whichByte = 0;
1113 whichByte = 0;
1114 bin = 0;
1114 bin = 0;
1115
1115
1116 for (i = 0; i < NB_BINS_TO_REMOVE; i++)
1116 for (i = 0; i < NB_BINS_TO_REMOVE; i++)
1117 {
1117 {
1118 binToRemove[i] = -1;
1118 binToRemove[i] = -1;
1119 }
1119 }
1120
1120
1121 if (!isnan(rw_f))
1121 if (!isnan(rw_f))
1122 {
1122 {
1123
1123
1124 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
1124 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
1125 f_RW_min = rw_f - (filterPar.sy_lfr_sc_rw_delta_f / 2.);
1125 f_RW_min = rw_f - ( (filterPar.sy_lfr_sc_rw_delta_f * kcoeff) / DELTAF_DIV);
1126 f_RW_MAX = rw_f + (filterPar.sy_lfr_sc_rw_delta_f / 2.);
1126 f_RW_MAX = rw_f + ( (filterPar.sy_lfr_sc_rw_delta_f * kcoeff) / DELTAF_DIV);
1127
1127
1128 // compute the index of the frequency bin immediately below rw_f
1128 // compute the index of the frequency bin immediately below rw_f
1129 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1129 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1130 deltaBelow = rw_f - binBelow * deltaFreq;
1130 deltaBelow = rw_f - binBelow * deltaFreq;
1131
1131
1132 // compute the index of the frequency bin immediately above rw_f
1132 // compute the index of the frequency bin immediately above rw_f
1133 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1133 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1134 deltaAbove = binAbove * deltaFreq - rw_f;
1134 deltaAbove = binAbove * deltaFreq - rw_f;
1135
1135
1136 // search the closest bin
1136 // search the closest bin
1137 if (deltaAbove > deltaBelow)
1137 if (deltaAbove > deltaBelow)
1138 {
1138 {
1139 closestBin = binBelow;
1139 closestBin = binBelow;
1140 }
1140 }
1141 else
1141 else
1142 {
1142 {
1143 closestBin = binAbove;
1143 closestBin = binAbove;
1144 }
1144 }
1145
1145
1146 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1146 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1147 fi = closestBin * deltaFreq;
1147 fi = closestBin * deltaFreq;
1148 fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF);
1148 fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF);
1149 fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF);
1149 fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF);
1150
1150
1151 //**************************************************************************************
1151 //**************************************************************************************
1152 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
1152 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
1153 // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum
1153 // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum
1154 //**************************************************************************************
1154 //**************************************************************************************
1155
1155
1156 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1156 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1157 // => remove f_(i), f_(i-1) and f_(i+1)
1157 // => remove f_(i), f_(i-1) and f_(i+1)
1158 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1158 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1159 {
1159 {
1160 binToRemove[0] = (closestBin - 1) - 1;
1160 binToRemove[0] = (closestBin - 1) - 1;
1161 binToRemove[1] = (closestBin) - 1;
1161 binToRemove[1] = (closestBin) - 1;
1162 binToRemove[2] = (closestBin + 1) - 1;
1162 binToRemove[2] = (closestBin + 1) - 1;
1163 }
1163 }
1164 // 2. ELSE
1164 // 2. ELSE
1165 // => remove the two f_(i) which are around f_RW
1165 // => remove the two f_(i) which are around f_RW
1166 else
1166 else
1167 {
1167 {
1168 binToRemove[0] = (binBelow) - 1;
1168 binToRemove[0] = (binBelow) - 1;
1169 binToRemove[1] = (binAbove) - 1;
1169 binToRemove[1] = (binAbove) - 1;
1170 binToRemove[2] = (-1);
1170 binToRemove[2] = (-1);
1171 }
1171 }
1172
1172
1173 for (i = 0; i < NB_BINS_TO_REMOVE; i++)
1173 for (i = 0; i < NB_BINS_TO_REMOVE; i++)
1174 {
1174 {
1175 bin = binToRemove[i];
1175 bin = binToRemove[i];
1176 if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) )
1176 if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) )
1177 {
1177 {
1178
1178
1179 whichByte = (bin >> SHIFT_3_BITS); // division by 8
1179 whichByte = (bin >> SHIFT_3_BITS); // division by 8
1180 selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) );
1180 selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) );
1181 fbins_mask[BYTES_PER_MASK - 1 - whichByte] =
1181 fbins_mask[BYTES_PER_MASK - 1 - whichByte] =
1182 fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1182 fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1183 }
1183 }
1184 }
1184 }
1185 }
1185 }
1186 }
1186 }
1187
1187
1188 void build_sy_lfr_rw_mask( unsigned int channel )
1188 void build_sy_lfr_rw_mask( unsigned int channel )
1189 {
1189 {
1190 unsigned char local_rw_fbins_mask[BYTES_PER_MASK];
1190 unsigned char local_rw_fbins_mask[BYTES_PER_MASK];
1191 unsigned char *maskPtr;
1191 unsigned char *maskPtr;
1192 double deltaF;
1192 double deltaF;
1193 unsigned k;
1193 unsigned k;
1194
1194
1195 k = 0;
1196
1197 maskPtr = NULL;
1195 maskPtr = NULL;
1198 deltaF = DELTAF_F2;
1196 deltaF = DELTAF_F2;
1199
1197
1200 switch (channel)
1198 switch (channel)
1201 {
1199 {
1202 case CHANNELF0:
1200 case CHANNELF0:
1203 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1201 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1204 deltaF = DELTAF_F0;
1202 deltaF = DELTAF_F0;
1205 break;
1203 break;
1206 case CHANNELF1:
1204 case CHANNELF1:
1207 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1205 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1208 deltaF = DELTAF_F1;
1206 deltaF = DELTAF_F1;
1209 break;
1207 break;
1210 case CHANNELF2:
1208 case CHANNELF2:
1211 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1209 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1212 deltaF = DELTAF_F2;
1210 deltaF = DELTAF_F2;
1213 break;
1211 break;
1214 default:
1212 default:
1215 break;
1213 break;
1216 }
1214 }
1217
1215
1218 for (k = 0; k < BYTES_PER_MASK; k++)
1216 for (k = 0; k < BYTES_PER_MASK; k++)
1219 {
1217 {
1220 local_rw_fbins_mask[k] = INT8_ALL_F;
1218 local_rw_fbins_mask[k] = INT8_ALL_F;
1221 }
1219 }
1222
1220
1223 // RW1
1221 // RW1
1224 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 );
1222 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 );
1225 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 );
1223 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 );
1226 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 );
1224 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 );
1227 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 );
1225 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 );
1228
1226
1229 // RW2
1227 // RW2
1230 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 );
1228 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 );
1231 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 );
1229 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 );
1232 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 );
1230 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 );
1233 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 );
1231 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 );
1234
1232
1235 // RW3
1233 // RW3
1236 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 );
1234 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 );
1237 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 );
1235 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 );
1238 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 );
1236 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 );
1239 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 );
1237 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 );
1240
1238
1241 // RW4
1239 // RW4
1242 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 );
1240 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 );
1243 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 );
1241 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 );
1244 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 );
1242 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 );
1245 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 );
1243 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 );
1246
1244
1247 // update the value of the fbins related to reaction wheels frequency filtering
1245 // update the value of the fbins related to reaction wheels frequency filtering
1248 if (maskPtr != NULL)
1246 if (maskPtr != NULL)
1249 {
1247 {
1250 for (k = 0; k < BYTES_PER_MASK; k++)
1248 for (k = 0; k < BYTES_PER_MASK; k++)
1251 {
1249 {
1252 maskPtr[k] = local_rw_fbins_mask[k];
1250 maskPtr[k] = local_rw_fbins_mask[k];
1253 }
1251 }
1254 }
1252 }
1255 }
1253 }
1256
1254
1257 void build_sy_lfr_rw_masks( void )
1255 void build_sy_lfr_rw_masks( void )
1258 {
1256 {
1259 build_sy_lfr_rw_mask( CHANNELF0 );
1257 build_sy_lfr_rw_mask( CHANNELF0 );
1260 build_sy_lfr_rw_mask( CHANNELF1 );
1258 build_sy_lfr_rw_mask( CHANNELF1 );
1261 build_sy_lfr_rw_mask( CHANNELF2 );
1259 build_sy_lfr_rw_mask( CHANNELF2 );
1262 }
1260 }
1263
1261
1264 void merge_fbins_masks( void )
1262 void merge_fbins_masks( void )
1265 {
1263 {
1266 unsigned char k;
1264 unsigned char k;
1267
1265
1268 unsigned char *fbins_f0;
1266 unsigned char *fbins_f0;
1269 unsigned char *fbins_f1;
1267 unsigned char *fbins_f1;
1270 unsigned char *fbins_f2;
1268 unsigned char *fbins_f2;
1271 unsigned char *rw_mask_f0;
1269 unsigned char *rw_mask_f0;
1272 unsigned char *rw_mask_f1;
1270 unsigned char *rw_mask_f1;
1273 unsigned char *rw_mask_f2;
1271 unsigned char *rw_mask_f2;
1274
1272
1275 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1273 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1276 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1274 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1277 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1275 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1278 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1276 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1279 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1277 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1280 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1278 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1281
1279
1282 for( k=0; k < BYTES_PER_MASK; k++ )
1280 for( k=0; k < BYTES_PER_MASK; k++ )
1283 {
1281 {
1284 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1282 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1285 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1283 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1286 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1284 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1287 }
1285 }
1288 }
1286 }
1289
1287
1290 //***********
1288 //***********
1291 // FBINS MASK
1289 // FBINS MASK
1292
1290
1293 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1291 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1294 {
1292 {
1295 int status;
1293 int status;
1296 unsigned int k;
1294 unsigned int k;
1297 unsigned char *fbins_mask_dump;
1295 unsigned char *fbins_mask_dump;
1298 unsigned char *fbins_mask_TC;
1296 unsigned char *fbins_mask_TC;
1299
1297
1300 status = LFR_SUCCESSFUL;
1298 status = LFR_SUCCESSFUL;
1301
1299
1302 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1300 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1303 fbins_mask_TC = TC->dataAndCRC;
1301 fbins_mask_TC = TC->dataAndCRC;
1304
1302
1305 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1303 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1306 {
1304 {
1307 fbins_mask_dump[k] = fbins_mask_TC[k];
1305 fbins_mask_dump[k] = fbins_mask_TC[k];
1308 }
1306 }
1309
1307
1310 return status;
1308 return status;
1311 }
1309 }
1312
1310
1313 //***************************
1311 //***************************
1314 // TC_LFR_LOAD_PAS_FILTER_PAR
1312 // TC_LFR_LOAD_PAS_FILTER_PAR
1315
1313
1316 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1314 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1317 {
1315 {
1318 int flag;
1316 int flag;
1319 rtems_status_code status;
1317 rtems_status_code status;
1320
1318
1321 unsigned char sy_lfr_pas_filter_enabled;
1319 unsigned char sy_lfr_pas_filter_enabled;
1322 unsigned char sy_lfr_pas_filter_modulus;
1320 unsigned char sy_lfr_pas_filter_modulus;
1323 float sy_lfr_pas_filter_tbad;
1321 float sy_lfr_pas_filter_tbad;
1324 unsigned char sy_lfr_pas_filter_offset;
1322 unsigned char sy_lfr_pas_filter_offset;
1325 float sy_lfr_pas_filter_shift;
1323 float sy_lfr_pas_filter_shift;
1326 float sy_lfr_sc_rw_delta_f;
1324 float sy_lfr_sc_rw_delta_f;
1327 char *parPtr;
1325 char *parPtr;
1328
1326
1329 flag = LFR_SUCCESSFUL;
1327 flag = LFR_SUCCESSFUL;
1330 sy_lfr_pas_filter_tbad = INIT_FLOAT;
1328 sy_lfr_pas_filter_tbad = INIT_FLOAT;
1331 sy_lfr_pas_filter_shift = INIT_FLOAT;
1329 sy_lfr_pas_filter_shift = INIT_FLOAT;
1332 sy_lfr_sc_rw_delta_f = INIT_FLOAT;
1330 sy_lfr_sc_rw_delta_f = INIT_FLOAT;
1333 parPtr = NULL;
1331 parPtr = NULL;
1334
1332
1335 //***************
1333 //***************
1336 // get parameters
1334 // get parameters
1337 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001]
1335 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001]
1338 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1336 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1339 copyFloatByChar(
1337 copyFloatByChar(
1340 (unsigned char*) &sy_lfr_pas_filter_tbad,
1338 (unsigned char*) &sy_lfr_pas_filter_tbad,
1341 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1339 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1342 );
1340 );
1343 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1341 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1344 copyFloatByChar(
1342 copyFloatByChar(
1345 (unsigned char*) &sy_lfr_pas_filter_shift,
1343 (unsigned char*) &sy_lfr_pas_filter_shift,
1346 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1344 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1347 );
1345 );
1348 copyFloatByChar(
1346 copyFloatByChar(
1349 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1347 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1350 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1348 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1351 );
1349 );
1352
1350
1353 //******************
1351 //******************
1354 // CHECK CONSISTENCY
1352 // CHECK CONSISTENCY
1355
1353
1356 //**************************
1354 //**************************
1357 // sy_lfr_pas_filter_enabled
1355 // sy_lfr_pas_filter_enabled
1358 // nothing to check, value is 0 or 1
1356 // nothing to check, value is 0 or 1
1359
1357
1360 //**************************
1358 //**************************
1361 // sy_lfr_pas_filter_modulus
1359 // sy_lfr_pas_filter_modulus
1362 if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) )
1360 if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) )
1363 {
1361 {
1364 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1362 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1365 flag = WRONG_APP_DATA;
1363 flag = WRONG_APP_DATA;
1366 }
1364 }
1367
1365
1368 //***********************
1366 //***********************
1369 // sy_lfr_pas_filter_tbad
1367 // sy_lfr_pas_filter_tbad
1370 if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) )
1368 if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) )
1371 {
1369 {
1372 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1370 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1373 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1371 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1374 flag = WRONG_APP_DATA;
1372 flag = WRONG_APP_DATA;
1375 }
1373 }
1376
1374
1377 //*************************
1375 //*************************
1378 // sy_lfr_pas_filter_offset
1376 // sy_lfr_pas_filter_offset
1379 if (flag == LFR_SUCCESSFUL)
1377 if (flag == LFR_SUCCESSFUL)
1380 {
1378 {
1381 if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) )
1379 if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) )
1382 {
1380 {
1383 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset );
1381 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset );
1384 flag = WRONG_APP_DATA;
1382 flag = WRONG_APP_DATA;
1385 }
1383 }
1386 }
1384 }
1387
1385
1388 //************************
1386 //************************
1389 // sy_lfr_pas_filter_shift
1387 // sy_lfr_pas_filter_shift
1390 if (flag == LFR_SUCCESSFUL)
1388 if (flag == LFR_SUCCESSFUL)
1391 {
1389 {
1392 if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) )
1390 if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) )
1393 {
1391 {
1394 parPtr = (char*) &sy_lfr_pas_filter_shift;
1392 parPtr = (char*) &sy_lfr_pas_filter_shift;
1395 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1393 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1396 flag = WRONG_APP_DATA;
1394 flag = WRONG_APP_DATA;
1397 }
1395 }
1398 }
1396 }
1399
1397
1400 //*************************************
1398 //*************************************
1401 // check global coherency of the values
1399 // check global coherency of the values
1402 if (flag == LFR_SUCCESSFUL)
1400 if (flag == LFR_SUCCESSFUL)
1403 {
1401 {
1404 if ( (sy_lfr_pas_filter_tbad + sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) > sy_lfr_pas_filter_modulus )
1402 if ( (sy_lfr_pas_filter_tbad + sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) > sy_lfr_pas_filter_modulus )
1405 {
1403 {
1406 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1404 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1407 flag = WRONG_APP_DATA;
1405 flag = WRONG_APP_DATA;
1408 }
1406 }
1409 }
1407 }
1410
1408
1411 //*********************
1409 //*********************
1412 // sy_lfr_sc_rw_delta_f
1410 // sy_lfr_sc_rw_delta_f
1413 // nothing to check, no default value in the ICD
1411 // nothing to check, no default value in the ICD
1414
1412
1415 return flag;
1413 return flag;
1416 }
1414 }
1417
1415
1418 //**************
1416 //**************
1419 // KCOEFFICIENTS
1417 // KCOEFFICIENTS
1420 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1418 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1421 {
1419 {
1422 unsigned int kcoeff;
1420 unsigned int kcoeff;
1423 unsigned short sy_lfr_kcoeff_frequency;
1421 unsigned short sy_lfr_kcoeff_frequency;
1424 unsigned short bin;
1422 unsigned short bin;
1425 unsigned short *freqPtr;
1423 unsigned short *freqPtr;
1426 float *kcoeffPtr_norm;
1424 float *kcoeffPtr_norm;
1427 float *kcoeffPtr_sbm;
1425 float *kcoeffPtr_sbm;
1428 int status;
1426 int status;
1429 unsigned char *kcoeffLoadPtr;
1427 unsigned char *kcoeffLoadPtr;
1430 unsigned char *kcoeffNormPtr;
1428 unsigned char *kcoeffNormPtr;
1431 unsigned char *kcoeffSbmPtr_a;
1429 unsigned char *kcoeffSbmPtr_a;
1432 unsigned char *kcoeffSbmPtr_b;
1430 unsigned char *kcoeffSbmPtr_b;
1433
1431
1434 status = LFR_SUCCESSFUL;
1432 status = LFR_SUCCESSFUL;
1435
1433
1436 kcoeffPtr_norm = NULL;
1434 kcoeffPtr_norm = NULL;
1437 kcoeffPtr_sbm = NULL;
1435 kcoeffPtr_sbm = NULL;
1438 bin = 0;
1436 bin = 0;
1439
1437
1440 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1438 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1441 sy_lfr_kcoeff_frequency = *freqPtr;
1439 sy_lfr_kcoeff_frequency = *freqPtr;
1442
1440
1443 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1441 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1444 {
1442 {
1445 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1443 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1446 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET + 1,
1444 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET + 1,
1447 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1445 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1448 status = LFR_DEFAULT;
1446 status = LFR_DEFAULT;
1449 }
1447 }
1450 else
1448 else
1451 {
1449 {
1452 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1450 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1453 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1451 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1454 {
1452 {
1455 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1453 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1456 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1454 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1457 bin = sy_lfr_kcoeff_frequency;
1455 bin = sy_lfr_kcoeff_frequency;
1458 }
1456 }
1459 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1457 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1460 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1458 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1461 {
1459 {
1462 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1460 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1463 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1461 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1464 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1462 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1465 }
1463 }
1466 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1464 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1467 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1465 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1468 {
1466 {
1469 kcoeffPtr_norm = k_coeff_intercalib_f2;
1467 kcoeffPtr_norm = k_coeff_intercalib_f2;
1470 kcoeffPtr_sbm = NULL;
1468 kcoeffPtr_sbm = NULL;
1471 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1469 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1472 }
1470 }
1473 }
1471 }
1474
1472
1475 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1473 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1476 {
1474 {
1477 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1475 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1478 {
1476 {
1479 // destination
1477 // destination
1480 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1478 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1481 // source
1479 // source
1482 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1480 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1483 // copy source to destination
1481 // copy source to destination
1484 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1482 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1485 }
1483 }
1486 }
1484 }
1487
1485
1488 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1486 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1489 {
1487 {
1490 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1488 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1491 {
1489 {
1492 // destination
1490 // destination
1493 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ];
1491 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ];
1494 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ];
1492 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ];
1495 // source
1493 // source
1496 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1494 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1497 // copy source to destination
1495 // copy source to destination
1498 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1496 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1499 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1497 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1500 }
1498 }
1501 }
1499 }
1502
1500
1503 // print_k_coeff();
1501 // print_k_coeff();
1504
1502
1505 return status;
1503 return status;
1506 }
1504 }
1507
1505
1508 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1506 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1509 {
1507 {
1510 destination[BYTE_0] = source[BYTE_0];
1508 destination[BYTE_0] = source[BYTE_0];
1511 destination[BYTE_1] = source[BYTE_1];
1509 destination[BYTE_1] = source[BYTE_1];
1512 destination[BYTE_2] = source[BYTE_2];
1510 destination[BYTE_2] = source[BYTE_2];
1513 destination[BYTE_3] = source[BYTE_3];
1511 destination[BYTE_3] = source[BYTE_3];
1514 }
1512 }
1515
1513
1516 void floatToChar( float value, unsigned char* ptr)
1514 void floatToChar( float value, unsigned char* ptr)
1517 {
1515 {
1518 unsigned char* valuePtr;
1516 unsigned char* valuePtr;
1519
1517
1520 valuePtr = (unsigned char*) &value;
1518 valuePtr = (unsigned char*) &value;
1521 ptr[BYTE_0] = valuePtr[BYTE_0];
1519 ptr[BYTE_0] = valuePtr[BYTE_0];
1522 ptr[BYTE_1] = valuePtr[BYTE_1];
1520 ptr[BYTE_1] = valuePtr[BYTE_1];
1523 ptr[BYTE_2] = valuePtr[BYTE_2];
1521 ptr[BYTE_2] = valuePtr[BYTE_2];
1524 ptr[BYTE_3] = valuePtr[BYTE_3];
1522 ptr[BYTE_3] = valuePtr[BYTE_3];
1525 }
1523 }
1526
1524
1527 //**********
1525 //**********
1528 // init dump
1526 // init dump
1529
1527
1530 void init_parameter_dump( void )
1528 void init_parameter_dump( void )
1531 {
1529 {
1532 /** This function initialize the parameter_dump_packet global variable with default values.
1530 /** This function initialize the parameter_dump_packet global variable with default values.
1533 *
1531 *
1534 */
1532 */
1535
1533
1536 unsigned int k;
1534 unsigned int k;
1537
1535
1538 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1536 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1539 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1537 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1540 parameter_dump_packet.reserved = CCSDS_RESERVED;
1538 parameter_dump_packet.reserved = CCSDS_RESERVED;
1541 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1539 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1542 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1540 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1543 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1541 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1544 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1542 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1545 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1543 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1546 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE);
1544 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE);
1547 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1545 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1548 // DATA FIELD HEADER
1546 // DATA FIELD HEADER
1549 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1547 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1550 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1548 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1551 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1549 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1552 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1550 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1553 parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
1551 parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
1554 parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
1552 parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
1555 parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
1553 parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
1556 parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
1554 parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
1557 parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
1555 parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
1558 parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
1556 parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
1559 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1557 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1560
1558
1561 //******************
1559 //******************
1562 // COMMON PARAMETERS
1560 // COMMON PARAMETERS
1563 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1561 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1564 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1562 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1565
1563
1566 //******************
1564 //******************
1567 // NORMAL PARAMETERS
1565 // NORMAL PARAMETERS
1568 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE);
1566 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE);
1569 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1567 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1570 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE);
1568 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE);
1571 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1569 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1572 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE);
1570 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE);
1573 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1571 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1574 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1572 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1575 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1573 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1576 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1574 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1577
1575
1578 //*****************
1576 //*****************
1579 // BURST PARAMETERS
1577 // BURST PARAMETERS
1580 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1578 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1581 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1579 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1582
1580
1583 //****************
1581 //****************
1584 // SBM1 PARAMETERS
1582 // SBM1 PARAMETERS
1585 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
1583 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
1586 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1584 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1587
1585
1588 //****************
1586 //****************
1589 // SBM2 PARAMETERS
1587 // SBM2 PARAMETERS
1590 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1588 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1591 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1589 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1592
1590
1593 //************
1591 //************
1594 // FBINS MASKS
1592 // FBINS MASKS
1595 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1593 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1596 {
1594 {
1597 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F;
1595 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F;
1598 }
1596 }
1599
1597
1600 // PAS FILTER PARAMETERS
1598 // PAS FILTER PARAMETERS
1601 parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR;
1599 parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR;
1602 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR;
1600 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR;
1603 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1601 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1604 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1602 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1605 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1603 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1606 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1604 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1607 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1605 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1608
1606
1609 // RW1_K
1607 // RW1_K
1610 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1);
1608 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1);
1611 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2);
1609 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2);
1612 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3);
1610 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3);
1613 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4);
1611 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4);
1614 // RW2_K
1612 // RW2_K
1615 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1);
1613 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1);
1616 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2);
1614 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2);
1617 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3);
1615 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3);
1618 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4);
1616 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4);
1619 // RW3_K
1617 // RW3_K
1620 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1);
1618 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1);
1621 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2);
1619 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2);
1622 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3);
1620 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3);
1623 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4);
1621 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4);
1624 // RW4_K
1622 // RW4_K
1625 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1);
1623 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1);
1626 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2);
1624 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2);
1627 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3);
1625 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3);
1628 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4);
1626 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4);
1629
1627
1630 // LFR_RW_MASK
1628 // LFR_RW_MASK
1631 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1629 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1632 {
1630 {
1633 parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F;
1631 parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F;
1634 }
1632 }
1635
1633
1636 // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks
1634 // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks
1637 merge_fbins_masks();
1635 merge_fbins_masks();
1638 }
1636 }
1639
1637
1640 void init_kcoefficients_dump( void )
1638 void init_kcoefficients_dump( void )
1641 {
1639 {
1642 init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 );
1640 init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 );
1643 init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 );
1641 init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 );
1644
1642
1645 kcoefficient_node_1.previous = NULL;
1643 kcoefficient_node_1.previous = NULL;
1646 kcoefficient_node_1.next = NULL;
1644 kcoefficient_node_1.next = NULL;
1647 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1645 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1648 kcoefficient_node_1.coarseTime = INIT_CHAR;
1646 kcoefficient_node_1.coarseTime = INIT_CHAR;
1649 kcoefficient_node_1.fineTime = INIT_CHAR;
1647 kcoefficient_node_1.fineTime = INIT_CHAR;
1650 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1648 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1651 kcoefficient_node_1.status = INIT_CHAR;
1649 kcoefficient_node_1.status = INIT_CHAR;
1652
1650
1653 kcoefficient_node_2.previous = NULL;
1651 kcoefficient_node_2.previous = NULL;
1654 kcoefficient_node_2.next = NULL;
1652 kcoefficient_node_2.next = NULL;
1655 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1653 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1656 kcoefficient_node_2.coarseTime = INIT_CHAR;
1654 kcoefficient_node_2.coarseTime = INIT_CHAR;
1657 kcoefficient_node_2.fineTime = INIT_CHAR;
1655 kcoefficient_node_2.fineTime = INIT_CHAR;
1658 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1656 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1659 kcoefficient_node_2.status = INIT_CHAR;
1657 kcoefficient_node_2.status = INIT_CHAR;
1660 }
1658 }
1661
1659
1662 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1660 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1663 {
1661 {
1664 unsigned int k;
1662 unsigned int k;
1665 unsigned int packetLength;
1663 unsigned int packetLength;
1666
1664
1667 packetLength =
1665 packetLength =
1668 ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1666 ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1669
1667
1670 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1668 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1671 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1669 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1672 kcoefficients_dump->reserved = CCSDS_RESERVED;
1670 kcoefficients_dump->reserved = CCSDS_RESERVED;
1673 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1671 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1674 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1672 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1675 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1673 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1676 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1674 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1677 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1675 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1678 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE);
1676 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE);
1679 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1677 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1680 // DATA FIELD HEADER
1678 // DATA FIELD HEADER
1681 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1679 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1682 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1680 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1683 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1681 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1684 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1682 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1685 kcoefficients_dump->time[BYTE_0] = INIT_CHAR;
1683 kcoefficients_dump->time[BYTE_0] = INIT_CHAR;
1686 kcoefficients_dump->time[BYTE_1] = INIT_CHAR;
1684 kcoefficients_dump->time[BYTE_1] = INIT_CHAR;
1687 kcoefficients_dump->time[BYTE_2] = INIT_CHAR;
1685 kcoefficients_dump->time[BYTE_2] = INIT_CHAR;
1688 kcoefficients_dump->time[BYTE_3] = INIT_CHAR;
1686 kcoefficients_dump->time[BYTE_3] = INIT_CHAR;
1689 kcoefficients_dump->time[BYTE_4] = INIT_CHAR;
1687 kcoefficients_dump->time[BYTE_4] = INIT_CHAR;
1690 kcoefficients_dump->time[BYTE_5] = INIT_CHAR;
1688 kcoefficients_dump->time[BYTE_5] = INIT_CHAR;
1691 kcoefficients_dump->sid = SID_K_DUMP;
1689 kcoefficients_dump->sid = SID_K_DUMP;
1692
1690
1693 kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT;
1691 kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT;
1694 kcoefficients_dump->pkt_nr = PKTNR_1;
1692 kcoefficients_dump->pkt_nr = PKTNR_1;
1695 kcoefficients_dump->blk_nr = blk_nr;
1693 kcoefficients_dump->blk_nr = blk_nr;
1696
1694
1697 //******************
1695 //******************
1698 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1696 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1699 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1697 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1700 for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++)
1698 for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++)
1701 {
1699 {
1702 kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR;
1700 kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR;
1703 }
1701 }
1704 }
1702 }
1705
1703
1706 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1704 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1707 {
1705 {
1708 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1706 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1709 *
1707 *
1710 * @param packet_sequence_control points to the packet sequence control which will be incremented
1708 * @param packet_sequence_control points to the packet sequence control which will be incremented
1711 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1709 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1712 *
1710 *
1713 * If the destination ID is not known, a dedicated counter is incremented.
1711 * If the destination ID is not known, a dedicated counter is incremented.
1714 *
1712 *
1715 */
1713 */
1716
1714
1717 unsigned short sequence_cnt;
1715 unsigned short sequence_cnt;
1718 unsigned short segmentation_grouping_flag;
1716 unsigned short segmentation_grouping_flag;
1719 unsigned short new_packet_sequence_control;
1717 unsigned short new_packet_sequence_control;
1720 unsigned char i;
1718 unsigned char i;
1721
1719
1722 switch (destination_id)
1720 switch (destination_id)
1723 {
1721 {
1724 case SID_TC_GROUND:
1722 case SID_TC_GROUND:
1725 i = GROUND;
1723 i = GROUND;
1726 break;
1724 break;
1727 case SID_TC_MISSION_TIMELINE:
1725 case SID_TC_MISSION_TIMELINE:
1728 i = MISSION_TIMELINE;
1726 i = MISSION_TIMELINE;
1729 break;
1727 break;
1730 case SID_TC_TC_SEQUENCES:
1728 case SID_TC_TC_SEQUENCES:
1731 i = TC_SEQUENCES;
1729 i = TC_SEQUENCES;
1732 break;
1730 break;
1733 case SID_TC_RECOVERY_ACTION_CMD:
1731 case SID_TC_RECOVERY_ACTION_CMD:
1734 i = RECOVERY_ACTION_CMD;
1732 i = RECOVERY_ACTION_CMD;
1735 break;
1733 break;
1736 case SID_TC_BACKUP_MISSION_TIMELINE:
1734 case SID_TC_BACKUP_MISSION_TIMELINE:
1737 i = BACKUP_MISSION_TIMELINE;
1735 i = BACKUP_MISSION_TIMELINE;
1738 break;
1736 break;
1739 case SID_TC_DIRECT_CMD:
1737 case SID_TC_DIRECT_CMD:
1740 i = DIRECT_CMD;
1738 i = DIRECT_CMD;
1741 break;
1739 break;
1742 case SID_TC_SPARE_GRD_SRC1:
1740 case SID_TC_SPARE_GRD_SRC1:
1743 i = SPARE_GRD_SRC1;
1741 i = SPARE_GRD_SRC1;
1744 break;
1742 break;
1745 case SID_TC_SPARE_GRD_SRC2:
1743 case SID_TC_SPARE_GRD_SRC2:
1746 i = SPARE_GRD_SRC2;
1744 i = SPARE_GRD_SRC2;
1747 break;
1745 break;
1748 case SID_TC_OBCP:
1746 case SID_TC_OBCP:
1749 i = OBCP;
1747 i = OBCP;
1750 break;
1748 break;
1751 case SID_TC_SYSTEM_CONTROL:
1749 case SID_TC_SYSTEM_CONTROL:
1752 i = SYSTEM_CONTROL;
1750 i = SYSTEM_CONTROL;
1753 break;
1751 break;
1754 case SID_TC_AOCS:
1752 case SID_TC_AOCS:
1755 i = AOCS;
1753 i = AOCS;
1756 break;
1754 break;
1757 case SID_TC_RPW_INTERNAL:
1755 case SID_TC_RPW_INTERNAL:
1758 i = RPW_INTERNAL;
1756 i = RPW_INTERNAL;
1759 break;
1757 break;
1760 default:
1758 default:
1761 i = GROUND;
1759 i = GROUND;
1762 break;
1760 break;
1763 }
1761 }
1764
1762
1765 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
1763 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
1766 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK;
1764 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK;
1767
1765
1768 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1766 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1769
1767
1770 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE);
1768 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE);
1771 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1769 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1772
1770
1773 // increment the sequence counter
1771 // increment the sequence counter
1774 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1772 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1775 {
1773 {
1776 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1774 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1777 }
1775 }
1778 else
1776 else
1779 {
1777 {
1780 sequenceCounters_TM_DUMP[ i ] = 0;
1778 sequenceCounters_TM_DUMP[ i ] = 0;
1781 }
1779 }
1782 }
1780 }
General Comments 0
You need to be logged in to leave comments. Login now