##// END OF EJS Templates
partial recoding of reaction wheel filtering
paul -
r305:245f3ace2b2a R3++ draft
parent child
Show More
@@ -1,85 +1,89
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 RW1 1
16 #define RW2 2
17 #define RW3 3
18 #define RW4 4
15
19
16 extern unsigned short sequenceCounterParameterDump;
20 extern unsigned short sequenceCounterParameterDump;
17 extern unsigned short sequenceCounters_TM_DUMP[];
21 extern unsigned short sequenceCounters_TM_DUMP[];
18 extern float k_coeff_intercalib_f0_norm[ ];
22 extern float k_coeff_intercalib_f0_norm[ ];
19 extern float k_coeff_intercalib_f0_sbm[ ];
23 extern float k_coeff_intercalib_f0_sbm[ ];
20 extern float k_coeff_intercalib_f1_norm[ ];
24 extern float k_coeff_intercalib_f1_norm[ ];
21 extern float k_coeff_intercalib_f1_sbm[ ];
25 extern float k_coeff_intercalib_f1_sbm[ ];
22 extern float k_coeff_intercalib_f2[ ];
26 extern float k_coeff_intercalib_f2[ ];
23 extern fbins_masks_t fbins_masks;
27 extern fbins_masks_t fbins_masks;
24
28
25 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
29 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
26 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
30 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
27 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
31 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
28 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
32 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
29 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
33 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
30 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
34 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
31 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
35 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
32 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
36 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
33 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
37 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
34 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
38 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
35
39
36 // NORMAL
40 // NORMAL
37 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
41 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
38 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
42 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
39 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
43 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
40 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
44 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
41 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
45 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
42 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
46 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
43 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
47 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
44
48
45 // BURST
49 // BURST
46 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
50 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
47 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
51 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
48
52
49 // SBM1
53 // SBM1
50 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
54 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
51 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
55 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
52
56
53 // SBM2
57 // SBM2
54 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
58 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
55 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
59 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
56
60
57 // TC_LFR_UPDATE_INFO
61 // TC_LFR_UPDATE_INFO
58 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
62 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
59 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
63 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
60 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
64 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
61 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value );
65 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value );
62 void set_hk_lfr_sc_rw_f_flags( void );
66 void set_hk_lfr_sc_rw_f_flags( void );
63 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
67 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
64 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag );
68 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float k);
65 void build_sy_lfr_rw_mask( unsigned int channel );
69 void build_sy_lfr_rw_mask( unsigned int channel );
66 void build_sy_lfr_rw_masks();
70 void build_sy_lfr_rw_masks();
67 void merge_fbins_masks( void );
71 void merge_fbins_masks( void );
68
72
69 // FBINS_MASK
73 // FBINS_MASK
70 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
74 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
71
75
72 // TC_LFR_LOAD_PARS_FILTER_PAR
76 // TC_LFR_LOAD_PARS_FILTER_PAR
73 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
77 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
74
78
75 // KCOEFFICIENTS
79 // KCOEFFICIENTS
76 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
80 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
77 void copyFloatByChar( unsigned char *destination, unsigned char *source );
81 void copyFloatByChar( unsigned char *destination, unsigned char *source );
78 void floatToChar( float value, unsigned char* ptr);
82 void floatToChar( float value, unsigned char* ptr);
79
83
80 void init_parameter_dump( void );
84 void init_parameter_dump( void );
81 void init_kcoefficients_dump( void );
85 void init_kcoefficients_dump( void );
82 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
86 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
83 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
87 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
84
88
85 #endif // TC_LOAD_DUMP_PARAMETERS_H
89 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,913 +1,913
1 /** General usage functions and RTEMS tasks.
1 /** General usage functions and RTEMS tasks.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 */
6 */
7
7
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9
9
10 int16_t hk_lfr_sc_v_f3_as_int16;
10 int16_t hk_lfr_sc_v_f3_as_int16;
11 int16_t hk_lfr_sc_e1_f3_as_int16;
11 int16_t hk_lfr_sc_e1_f3_as_int16;
12 int16_t hk_lfr_sc_e2_f3_as_int16;
12 int16_t hk_lfr_sc_e2_f3_as_int16;
13
13
14 void timer_configure(unsigned char timer, unsigned int clock_divider,
14 void timer_configure(unsigned char timer, unsigned int clock_divider,
15 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
15 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
16 {
16 {
17 /** This function configures a GPTIMER timer instantiated in the VHDL design.
17 /** This function configures a GPTIMER timer instantiated in the VHDL design.
18 *
18 *
19 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
19 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
20 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
20 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
21 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
21 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
22 * @param interrupt_level is the interrupt level that the timer drives.
22 * @param interrupt_level is the interrupt level that the timer drives.
23 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
23 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
24 *
24 *
25 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
25 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
26 *
26 *
27 */
27 */
28
28
29 rtems_status_code status;
29 rtems_status_code status;
30 rtems_isr_entry old_isr_handler;
30 rtems_isr_entry old_isr_handler;
31
31
32 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
32 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
33
33
34 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
34 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
35 if (status!=RTEMS_SUCCESSFUL)
35 if (status!=RTEMS_SUCCESSFUL)
36 {
36 {
37 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
37 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
38 }
38 }
39
39
40 timer_set_clock_divider( timer, clock_divider);
40 timer_set_clock_divider( timer, clock_divider);
41 }
41 }
42
42
43 void timer_start(unsigned char timer)
43 void timer_start(unsigned char timer)
44 {
44 {
45 /** This function starts a GPTIMER timer.
45 /** This function starts a GPTIMER timer.
46 *
46 *
47 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
47 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
48 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
48 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
49 *
49 *
50 */
50 */
51
51
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
53 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
53 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
54 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
54 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
55 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
55 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
56 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
56 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
57 }
57 }
58
58
59 void timer_stop(unsigned char timer)
59 void timer_stop(unsigned char timer)
60 {
60 {
61 /** This function stops a GPTIMER timer.
61 /** This function stops a GPTIMER timer.
62 *
62 *
63 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
63 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
64 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
64 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
65 *
65 *
66 */
66 */
67
67
68 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
68 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
69 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
69 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
70 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
70 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
71 }
71 }
72
72
73 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider)
73 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider)
74 {
74 {
75 /** This function sets the clock divider of a GPTIMER timer.
75 /** This function sets the clock divider of a GPTIMER timer.
76 *
76 *
77 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
77 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
78 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
78 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
79 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
79 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
80 *
80 *
81 */
81 */
82
82
83 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
83 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
84 }
84 }
85
85
86 // WATCHDOG
86 // WATCHDOG
87
87
88 rtems_isr watchdog_isr( rtems_vector_number vector )
88 rtems_isr watchdog_isr( rtems_vector_number vector )
89 {
89 {
90 rtems_status_code status_code;
90 rtems_status_code status_code;
91
91
92 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 );
92 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 );
93
93
94 PRINTF("watchdog_isr *** this is the end, exit(0)\n");
94 PRINTF("watchdog_isr *** this is the end, exit(0)\n");
95
95
96 exit(0);
96 exit(0);
97 }
97 }
98
98
99 void watchdog_configure(void)
99 void watchdog_configure(void)
100 {
100 {
101 /** This function configure the watchdog.
101 /** This function configure the watchdog.
102 *
102 *
103 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
103 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
104 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
104 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
105 *
105 *
106 * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB.
106 * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB.
107 *
107 *
108 */
108 */
109
109
110 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration
110 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration
111
111
112 timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr );
112 timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr );
113
113
114 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
114 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
115 }
115 }
116
116
117 void watchdog_stop(void)
117 void watchdog_stop(void)
118 {
118 {
119 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line
119 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line
120 timer_stop( TIMER_WATCHDOG );
120 timer_stop( TIMER_WATCHDOG );
121 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
121 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
122 }
122 }
123
123
124 void watchdog_reload(void)
124 void watchdog_reload(void)
125 {
125 {
126 /** This function reloads the watchdog timer counter with the timer reload value.
126 /** This function reloads the watchdog timer counter with the timer reload value.
127 *
127 *
128 * @param void
128 * @param void
129 *
129 *
130 * @return void
130 * @return void
131 *
131 *
132 */
132 */
133
133
134 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
134 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
135 }
135 }
136
136
137 void watchdog_start(void)
137 void watchdog_start(void)
138 {
138 {
139 /** This function starts the watchdog timer.
139 /** This function starts the watchdog timer.
140 *
140 *
141 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
141 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
142 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
142 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
143 *
143 *
144 */
144 */
145
145
146 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG );
146 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG );
147
147
148 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any
148 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any
149 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
149 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
150 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer
150 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer
151 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable
151 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable
152
152
153 LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG );
153 LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG );
154
154
155 }
155 }
156
156
157 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
157 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
158 {
158 {
159 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
159 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
160
160
161 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
161 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
162
162
163 return 0;
163 return 0;
164 }
164 }
165
165
166 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
166 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
167 {
167 {
168 /** This function sets the scaler reload register of the apbuart module
168 /** This function sets the scaler reload register of the apbuart module
169 *
169 *
170 * @param regs is the address of the apbuart registers in memory
170 * @param regs is the address of the apbuart registers in memory
171 * @param value is the value that will be stored in the scaler register
171 * @param value is the value that will be stored in the scaler register
172 *
172 *
173 * The value shall be set by the software to get data on the serial interface.
173 * The value shall be set by the software to get data on the serial interface.
174 *
174 *
175 */
175 */
176
176
177 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
177 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
178
178
179 apbuart_regs->scaler = value;
179 apbuart_regs->scaler = value;
180
180
181 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
181 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
182 }
182 }
183
183
184 //************
184 //************
185 // RTEMS TASKS
185 // RTEMS TASKS
186
186
187 rtems_task load_task(rtems_task_argument argument)
187 rtems_task load_task(rtems_task_argument argument)
188 {
188 {
189 BOOT_PRINTF("in LOAD *** \n")
189 BOOT_PRINTF("in LOAD *** \n")
190
190
191 rtems_status_code status;
191 rtems_status_code status;
192 unsigned int i;
192 unsigned int i;
193 unsigned int j;
193 unsigned int j;
194 rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic
194 rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic
195 rtems_id watchdog_period_id; // id of the watchdog rate monotonic period
195 rtems_id watchdog_period_id; // id of the watchdog rate monotonic period
196
196
197 name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' );
197 name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' );
198
198
199 status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id );
199 status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id );
200 if( status != RTEMS_SUCCESSFUL ) {
200 if( status != RTEMS_SUCCESSFUL ) {
201 PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status )
201 PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status )
202 }
202 }
203
203
204 i = 0;
204 i = 0;
205 j = 0;
205 j = 0;
206
206
207 watchdog_configure();
207 watchdog_configure();
208
208
209 watchdog_start();
209 watchdog_start();
210
210
211 set_sy_lfr_watchdog_enabled( true );
211 set_sy_lfr_watchdog_enabled( true );
212
212
213 while(1){
213 while(1){
214 status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD );
214 status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD );
215 watchdog_reload();
215 watchdog_reload();
216 i = i + 1;
216 i = i + 1;
217 if ( i == 10 )
217 if ( i == 10 )
218 {
218 {
219 i = 0;
219 i = 0;
220 j = j + 1;
220 j = j + 1;
221 PRINTF1("%d\n", j)
221 PRINTF1("%d\n", j)
222 }
222 }
223 #ifdef DEBUG_WATCHDOG
223 #ifdef DEBUG_WATCHDOG
224 if (j == 3 )
224 if (j == 3 )
225 {
225 {
226 status = rtems_task_delete(RTEMS_SELF);
226 status = rtems_task_delete(RTEMS_SELF);
227 }
227 }
228 #endif
228 #endif
229 }
229 }
230 }
230 }
231
231
232 rtems_task hous_task(rtems_task_argument argument)
232 rtems_task hous_task(rtems_task_argument argument)
233 {
233 {
234 rtems_status_code status;
234 rtems_status_code status;
235 rtems_status_code spare_status;
235 rtems_status_code spare_status;
236 rtems_id queue_id;
236 rtems_id queue_id;
237 rtems_rate_monotonic_period_status period_status;
237 rtems_rate_monotonic_period_status period_status;
238
238
239 status = get_message_queue_id_send( &queue_id );
239 status = get_message_queue_id_send( &queue_id );
240 if (status != RTEMS_SUCCESSFUL)
240 if (status != RTEMS_SUCCESSFUL)
241 {
241 {
242 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
242 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
243 }
243 }
244
244
245 BOOT_PRINTF("in HOUS ***\n");
245 BOOT_PRINTF("in HOUS ***\n");
246
246
247 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
247 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
248 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
248 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
249 if( status != RTEMS_SUCCESSFUL ) {
249 if( status != RTEMS_SUCCESSFUL ) {
250 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
250 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
251 }
251 }
252 }
252 }
253
253
254 status = rtems_rate_monotonic_cancel(HK_id);
254 status = rtems_rate_monotonic_cancel(HK_id);
255 if( status != RTEMS_SUCCESSFUL ) {
255 if( status != RTEMS_SUCCESSFUL ) {
256 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status );
256 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status );
257 }
257 }
258 else {
258 else {
259 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n");
259 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n");
260 }
260 }
261
261
262 // startup phase
262 // startup phase
263 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
263 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
264 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
264 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
265 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
265 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
266 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
266 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
267 {
267 {
268 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
268 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
269 {
269 {
270 break; // break if LFR is synchronized
270 break; // break if LFR is synchronized
271 }
271 }
272 else
272 else
273 {
273 {
274 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
274 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
275 // sched_yield();
275 // sched_yield();
276 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
276 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
277 }
277 }
278 }
278 }
279 status = rtems_rate_monotonic_cancel(HK_id);
279 status = rtems_rate_monotonic_cancel(HK_id);
280 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
280 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
281
281
282 set_hk_lfr_reset_cause( POWER_ON );
282 set_hk_lfr_reset_cause( POWER_ON );
283
283
284 while(1){ // launch the rate monotonic task
284 while(1){ // launch the rate monotonic task
285 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
285 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
286 if ( status != RTEMS_SUCCESSFUL ) {
286 if ( status != RTEMS_SUCCESSFUL ) {
287 PRINTF1( "in HOUS *** ERR period: %d\n", status);
287 PRINTF1( "in HOUS *** ERR period: %d\n", status);
288 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
288 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
289 }
289 }
290 else {
290 else {
291 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
291 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
292 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
292 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
293 increment_seq_counter( &sequenceCounterHK );
293 increment_seq_counter( &sequenceCounterHK );
294
294
295 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
295 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
296 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
296 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
297 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
297 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
298 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
298 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
299 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
299 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
300 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
300 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
301
301
302 spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] );
302 spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] );
303
303
304 spacewire_read_statistics();
304 spacewire_read_statistics();
305
305
306 update_hk_with_grspw_stats();
306 update_hk_with_grspw_stats();
307
307
308 set_hk_lfr_time_not_synchro();
308 set_hk_lfr_time_not_synchro();
309
309
310 housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max;
310 housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max;
311 housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max;
311 housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max;
312 housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max;
312 housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max;
313 housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max;
313 housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max;
314 housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max;
314 housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max;
315
315
316 housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare;
316 housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare;
317 housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
317 housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
318 get_temperatures( housekeeping_packet.hk_lfr_temp_scm );
318 get_temperatures( housekeeping_packet.hk_lfr_temp_scm );
319 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
319 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
320 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
320 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
321
321
322 hk_lfr_le_me_he_update();
322 hk_lfr_le_me_he_update();
323
323
324 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = cp_rpw_sc_rw1_rw2_f_flags;
324 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = cp_rpw_sc_rw1_rw2_f_flags;
325 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = cp_rpw_sc_rw3_rw4_f_flags;
325 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = cp_rpw_sc_rw3_rw4_f_flags;
326
326
327 // SEND PACKET
327 // SEND PACKET
328 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
328 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
329 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
329 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
330 if (status != RTEMS_SUCCESSFUL) {
330 if (status != RTEMS_SUCCESSFUL) {
331 PRINTF1("in HOUS *** ERR send: %d\n", status)
331 PRINTF1("in HOUS *** ERR send: %d\n", status)
332 }
332 }
333 }
333 }
334 }
334 }
335
335
336 PRINTF("in HOUS *** deleting task\n")
336 PRINTF("in HOUS *** deleting task\n")
337
337
338 status = rtems_task_delete( RTEMS_SELF ); // should not return
338 status = rtems_task_delete( RTEMS_SELF ); // should not return
339
339
340 return;
340 return;
341 }
341 }
342
342
343 rtems_task avgv_task(rtems_task_argument argument)
343 rtems_task avgv_task(rtems_task_argument argument)
344 {
344 {
345 #define MOVING_AVERAGE 16
345 #define MOVING_AVERAGE 16
346 rtems_status_code status;
346 rtems_status_code status;
347 unsigned int v[MOVING_AVERAGE];
347 unsigned int v[MOVING_AVERAGE];
348 unsigned int e1[MOVING_AVERAGE];
348 unsigned int e1[MOVING_AVERAGE];
349 unsigned int e2[MOVING_AVERAGE];
349 unsigned int e2[MOVING_AVERAGE];
350 float average_v;
350 float average_v;
351 float average_e1;
351 float average_e1;
352 float average_e2;
352 float average_e2;
353 float newValue_v;
353 float newValue_v;
354 float newValue_e1;
354 float newValue_e1;
355 float newValue_e2;
355 float newValue_e2;
356 unsigned char k;
356 unsigned char k;
357 unsigned char indexOfOldValue;
357 unsigned char indexOfOldValue;
358
358
359 BOOT_PRINTF("in AVGV ***\n");
359 BOOT_PRINTF("in AVGV ***\n");
360
360
361 if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
361 if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
362 status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id );
362 status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id );
363 if( status != RTEMS_SUCCESSFUL ) {
363 if( status != RTEMS_SUCCESSFUL ) {
364 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
364 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
365 }
365 }
366 }
366 }
367
367
368 status = rtems_rate_monotonic_cancel(AVGV_id);
368 status = rtems_rate_monotonic_cancel(AVGV_id);
369 if( status != RTEMS_SUCCESSFUL ) {
369 if( status != RTEMS_SUCCESSFUL ) {
370 PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status );
370 PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status );
371 }
371 }
372 else {
372 else {
373 DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n");
373 DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n");
374 }
374 }
375
375
376 // initialize values
376 // initialize values
377 k = 0;
377 k = 0;
378 indexOfOldValue = MOVING_AVERAGE - 1;
378 indexOfOldValue = MOVING_AVERAGE - 1;
379 for (k = 0; k < MOVING_AVERAGE; k++)
379 for (k = 0; k < MOVING_AVERAGE; k++)
380 {
380 {
381 v[k] = 0;
381 v[k] = 0;
382 e1[k] = 0;
382 e1[k] = 0;
383 e2[k] = 0;
383 e2[k] = 0;
384 average_v = 0.;
384 average_v = 0.;
385 average_e1 = 0.;
385 average_e1 = 0.;
386 average_e2 = 0.;
386 average_e2 = 0.;
387 newValue_v = 0.;
387 newValue_v = 0.;
388 newValue_e1 = 0.;
388 newValue_e1 = 0.;
389 newValue_e2 = 0.;
389 newValue_e2 = 0.;
390 }
390 }
391
391
392 k = 0;
392 k = 0;
393
393
394 while(1){ // launch the rate monotonic task
394 while(1){ // launch the rate monotonic task
395 status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD );
395 status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD );
396 if ( status != RTEMS_SUCCESSFUL ) {
396 if ( status != RTEMS_SUCCESSFUL ) {
397 PRINTF1( "in AVGV *** ERR period: %d\n", status);
397 PRINTF1( "in AVGV *** ERR period: %d\n", status);
398 }
398 }
399 else {
399 else {
400 // get new values
400 // get new values
401 newValue_v = waveform_picker_regs->v;
401 newValue_v = waveform_picker_regs->v;
402 newValue_e1 = waveform_picker_regs->e1;
402 newValue_e1 = waveform_picker_regs->e1;
403 newValue_e2 = waveform_picker_regs->e2;
403 newValue_e2 = waveform_picker_regs->e2;
404
404
405 // compute the moving average
405 // compute the moving average
406 average_v = average_v + newValue_v - v[k];
406 average_v = average_v + newValue_v - v[k];
407 average_e1 = average_e1 + newValue_e1 - e1[k];
407 average_e1 = average_e1 + newValue_e1 - e1[k];
408 average_e2 = average_e2 + newValue_e2 - e2[k];
408 average_e2 = average_e2 + newValue_e2 - e2[k];
409
409
410 // store new values in buffers
410 // store new values in buffers
411 v[k] = newValue_v;
411 v[k] = newValue_v;
412 e1[k] = newValue_e1;
412 e1[k] = newValue_e1;
413 e2[k] = newValue_e2;
413 e2[k] = newValue_e2;
414 }
414 }
415 if (k == (MOVING_AVERAGE-1))
415 if (k == (MOVING_AVERAGE-1))
416 {
416 {
417 k = 0;
417 k = 0;
418 printf("tick\n");
418 printf("tick\n");
419 }
419 }
420 else
420 else
421 {
421 {
422 k++;
422 k++;
423 }
423 }
424
425 //update int16 values
426 hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / ((float) MOVING_AVERAGE) );
427 hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / ((float) MOVING_AVERAGE) );
428 hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / ((float) MOVING_AVERAGE) );
424 }
429 }
425
430
426 //update int16 values
427 hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / ((float) MOVING_AVERAGE) );
428 hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / ((float) MOVING_AVERAGE) );
429 hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / ((float) MOVING_AVERAGE) );
430
431 PRINTF("in AVGV *** deleting task\n");
431 PRINTF("in AVGV *** deleting task\n");
432
432
433 status = rtems_task_delete( RTEMS_SELF ); // should not return
433 status = rtems_task_delete( RTEMS_SELF ); // should not return
434
434
435 return;
435 return;
436 }
436 }
437
437
438 rtems_task dumb_task( rtems_task_argument unused )
438 rtems_task dumb_task( rtems_task_argument unused )
439 {
439 {
440 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
440 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
441 *
441 *
442 * @param unused is the starting argument of the RTEMS task
442 * @param unused is the starting argument of the RTEMS task
443 *
443 *
444 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
444 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
445 *
445 *
446 */
446 */
447
447
448 unsigned int i;
448 unsigned int i;
449 unsigned int intEventOut;
449 unsigned int intEventOut;
450 unsigned int coarse_time = 0;
450 unsigned int coarse_time = 0;
451 unsigned int fine_time = 0;
451 unsigned int fine_time = 0;
452 rtems_event_set event_out;
452 rtems_event_set event_out;
453
453
454 char *DumbMessages[15] = {"in DUMB *** default", // RTEMS_EVENT_0
454 char *DumbMessages[15] = {"in DUMB *** default", // RTEMS_EVENT_0
455 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
455 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
456 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
456 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
457 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
457 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
458 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
458 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
459 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
459 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
460 "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6
460 "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6
461 "ready for dump", // RTEMS_EVENT_7
461 "ready for dump", // RTEMS_EVENT_7
462 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
462 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
463 "tick", // RTEMS_EVENT_9
463 "tick", // RTEMS_EVENT_9
464 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
464 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
465 "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
465 "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
466 "WATCHDOG timer", // RTEMS_EVENT_12
466 "WATCHDOG timer", // RTEMS_EVENT_12
467 "TIMECODE timer", // RTEMS_EVENT_13
467 "TIMECODE timer", // RTEMS_EVENT_13
468 "TIMECODE ISR" // RTEMS_EVENT_14
468 "TIMECODE ISR" // RTEMS_EVENT_14
469 };
469 };
470
470
471 BOOT_PRINTF("in DUMB *** \n")
471 BOOT_PRINTF("in DUMB *** \n")
472
472
473 while(1){
473 while(1){
474 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
474 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
475 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
475 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
476 | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13
476 | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13
477 | RTEMS_EVENT_14,
477 | RTEMS_EVENT_14,
478 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
478 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
479 intEventOut = (unsigned int) event_out;
479 intEventOut = (unsigned int) event_out;
480 for ( i=0; i<32; i++)
480 for ( i=0; i<32; i++)
481 {
481 {
482 if ( ((intEventOut >> i) & 0x0001) != 0)
482 if ( ((intEventOut >> i) & 0x0001) != 0)
483 {
483 {
484 coarse_time = time_management_regs->coarse_time;
484 coarse_time = time_management_regs->coarse_time;
485 fine_time = time_management_regs->fine_time;
485 fine_time = time_management_regs->fine_time;
486 if (i==12)
486 if (i==12)
487 {
487 {
488 PRINTF1("%s\n", DumbMessages[12])
488 PRINTF1("%s\n", DumbMessages[12])
489 }
489 }
490 if (i==13)
490 if (i==13)
491 {
491 {
492 PRINTF1("%s\n", DumbMessages[13])
492 PRINTF1("%s\n", DumbMessages[13])
493 }
493 }
494 if (i==14)
494 if (i==14)
495 {
495 {
496 PRINTF1("%s\n", DumbMessages[1])
496 PRINTF1("%s\n", DumbMessages[1])
497 }
497 }
498 }
498 }
499 }
499 }
500 }
500 }
501 }
501 }
502
502
503 //*****************************
503 //*****************************
504 // init housekeeping parameters
504 // init housekeeping parameters
505
505
506 void init_housekeeping_parameters( void )
506 void init_housekeeping_parameters( void )
507 {
507 {
508 /** This function initialize the housekeeping_packet global variable with default values.
508 /** This function initialize the housekeeping_packet global variable with default values.
509 *
509 *
510 */
510 */
511
511
512 unsigned int i = 0;
512 unsigned int i = 0;
513 unsigned char *parameters;
513 unsigned char *parameters;
514 unsigned char sizeOfHK;
514 unsigned char sizeOfHK;
515
515
516 sizeOfHK = sizeof( Packet_TM_LFR_HK_t );
516 sizeOfHK = sizeof( Packet_TM_LFR_HK_t );
517
517
518 parameters = (unsigned char*) &housekeeping_packet;
518 parameters = (unsigned char*) &housekeeping_packet;
519
519
520 for(i = 0; i< sizeOfHK; i++)
520 for(i = 0; i< sizeOfHK; i++)
521 {
521 {
522 parameters[i] = 0x00;
522 parameters[i] = 0x00;
523 }
523 }
524
524
525 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
525 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
526 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
526 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
527 housekeeping_packet.reserved = DEFAULT_RESERVED;
527 housekeeping_packet.reserved = DEFAULT_RESERVED;
528 housekeeping_packet.userApplication = CCSDS_USER_APP;
528 housekeeping_packet.userApplication = CCSDS_USER_APP;
529 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
529 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
530 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
530 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
531 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
531 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
532 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
532 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
533 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
533 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
534 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
534 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
535 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
535 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
536 housekeeping_packet.serviceType = TM_TYPE_HK;
536 housekeeping_packet.serviceType = TM_TYPE_HK;
537 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
537 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
538 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
538 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
539 housekeeping_packet.sid = SID_HK;
539 housekeeping_packet.sid = SID_HK;
540
540
541 // init status word
541 // init status word
542 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
542 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
543 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
543 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
544 // init software version
544 // init software version
545 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
545 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
546 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
546 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
547 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
547 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
548 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
548 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
549 // init fpga version
549 // init fpga version
550 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
550 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
551 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
551 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
552 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
552 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
553 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
553 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
554
554
555 housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND;
555 housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND;
556 housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV;
556 housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV;
557 housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0;
557 housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0;
558 housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1;
558 housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1;
559 housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2;
559 housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2;
560 }
560 }
561
561
562 void increment_seq_counter( unsigned short *packetSequenceControl )
562 void increment_seq_counter( unsigned short *packetSequenceControl )
563 {
563 {
564 /** This function increment the sequence counter passes in argument.
564 /** This function increment the sequence counter passes in argument.
565 *
565 *
566 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
566 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
567 *
567 *
568 */
568 */
569
569
570 unsigned short segmentation_grouping_flag;
570 unsigned short segmentation_grouping_flag;
571 unsigned short sequence_cnt;
571 unsigned short sequence_cnt;
572
572
573 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
573 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
574 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
574 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
575
575
576 if ( sequence_cnt < SEQ_CNT_MAX)
576 if ( sequence_cnt < SEQ_CNT_MAX)
577 {
577 {
578 sequence_cnt = sequence_cnt + 1;
578 sequence_cnt = sequence_cnt + 1;
579 }
579 }
580 else
580 else
581 {
581 {
582 sequence_cnt = 0;
582 sequence_cnt = 0;
583 }
583 }
584
584
585 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
585 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
586 }
586 }
587
587
588 void getTime( unsigned char *time)
588 void getTime( unsigned char *time)
589 {
589 {
590 /** This function write the current local time in the time buffer passed in argument.
590 /** This function write the current local time in the time buffer passed in argument.
591 *
591 *
592 */
592 */
593
593
594 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
594 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
595 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
595 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
596 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
596 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
597 time[3] = (unsigned char) (time_management_regs->coarse_time);
597 time[3] = (unsigned char) (time_management_regs->coarse_time);
598 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
598 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
599 time[5] = (unsigned char) (time_management_regs->fine_time);
599 time[5] = (unsigned char) (time_management_regs->fine_time);
600 }
600 }
601
601
602 unsigned long long int getTimeAsUnsignedLongLongInt( )
602 unsigned long long int getTimeAsUnsignedLongLongInt( )
603 {
603 {
604 /** This function write the current local time in the time buffer passed in argument.
604 /** This function write the current local time in the time buffer passed in argument.
605 *
605 *
606 */
606 */
607 unsigned long long int time;
607 unsigned long long int time;
608
608
609 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
609 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
610 + time_management_regs->fine_time;
610 + time_management_regs->fine_time;
611
611
612 return time;
612 return time;
613 }
613 }
614
614
615 void send_dumb_hk( void )
615 void send_dumb_hk( void )
616 {
616 {
617 Packet_TM_LFR_HK_t dummy_hk_packet;
617 Packet_TM_LFR_HK_t dummy_hk_packet;
618 unsigned char *parameters;
618 unsigned char *parameters;
619 unsigned int i;
619 unsigned int i;
620 rtems_id queue_id;
620 rtems_id queue_id;
621
621
622 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
622 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
623 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
623 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
624 dummy_hk_packet.reserved = DEFAULT_RESERVED;
624 dummy_hk_packet.reserved = DEFAULT_RESERVED;
625 dummy_hk_packet.userApplication = CCSDS_USER_APP;
625 dummy_hk_packet.userApplication = CCSDS_USER_APP;
626 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
626 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
627 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
627 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
628 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
628 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
629 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
629 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
630 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
630 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
631 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
631 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
632 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
632 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
633 dummy_hk_packet.serviceType = TM_TYPE_HK;
633 dummy_hk_packet.serviceType = TM_TYPE_HK;
634 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
634 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
635 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
635 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
636 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
636 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
637 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
637 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
638 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
638 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
639 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
639 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
640 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
640 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
641 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
641 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
642 dummy_hk_packet.sid = SID_HK;
642 dummy_hk_packet.sid = SID_HK;
643
643
644 // init status word
644 // init status word
645 dummy_hk_packet.lfr_status_word[0] = 0xff;
645 dummy_hk_packet.lfr_status_word[0] = 0xff;
646 dummy_hk_packet.lfr_status_word[1] = 0xff;
646 dummy_hk_packet.lfr_status_word[1] = 0xff;
647 // init software version
647 // init software version
648 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
648 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
649 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
649 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
650 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
650 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
651 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
651 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
652 // init fpga version
652 // init fpga version
653 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
653 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
654 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
654 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
655 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
655 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
656 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
656 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
657
657
658 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
658 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
659
659
660 for (i=0; i<100; i++)
660 for (i=0; i<100; i++)
661 {
661 {
662 parameters[i] = 0xff;
662 parameters[i] = 0xff;
663 }
663 }
664
664
665 get_message_queue_id_send( &queue_id );
665 get_message_queue_id_send( &queue_id );
666
666
667 rtems_message_queue_send( queue_id, &dummy_hk_packet,
667 rtems_message_queue_send( queue_id, &dummy_hk_packet,
668 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
668 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
669 }
669 }
670
670
671 void get_temperatures( unsigned char *temperatures )
671 void get_temperatures( unsigned char *temperatures )
672 {
672 {
673 unsigned char* temp_scm_ptr;
673 unsigned char* temp_scm_ptr;
674 unsigned char* temp_pcb_ptr;
674 unsigned char* temp_pcb_ptr;
675 unsigned char* temp_fpga_ptr;
675 unsigned char* temp_fpga_ptr;
676
676
677 // SEL1 SEL0
677 // SEL1 SEL0
678 // 0 0 => PCB
678 // 0 0 => PCB
679 // 0 1 => FPGA
679 // 0 1 => FPGA
680 // 1 0 => SCM
680 // 1 0 => SCM
681
681
682 temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm;
682 temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm;
683 temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb;
683 temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb;
684 temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga;
684 temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga;
685
685
686 temperatures[0] = temp_scm_ptr[2];
686 temperatures[0] = temp_scm_ptr[2];
687 temperatures[1] = temp_scm_ptr[3];
687 temperatures[1] = temp_scm_ptr[3];
688 temperatures[2] = temp_pcb_ptr[2];
688 temperatures[2] = temp_pcb_ptr[2];
689 temperatures[3] = temp_pcb_ptr[3];
689 temperatures[3] = temp_pcb_ptr[3];
690 temperatures[4] = temp_fpga_ptr[2];
690 temperatures[4] = temp_fpga_ptr[2];
691 temperatures[5] = temp_fpga_ptr[3];
691 temperatures[5] = temp_fpga_ptr[3];
692 }
692 }
693
693
694 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
694 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
695 {
695 {
696 unsigned char* v_ptr;
696 unsigned char* v_ptr;
697 unsigned char* e1_ptr;
697 unsigned char* e1_ptr;
698 unsigned char* e2_ptr;
698 unsigned char* e2_ptr;
699
699
700 v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16;
700 v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16;
701 e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16;
701 e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16;
702 e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16;
702 e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16;
703
703
704 spacecraft_potential[0] = v_ptr[0];
704 spacecraft_potential[0] = v_ptr[0];
705 spacecraft_potential[1] = v_ptr[1];
705 spacecraft_potential[1] = v_ptr[1];
706 spacecraft_potential[2] = e1_ptr[0];
706 spacecraft_potential[2] = e1_ptr[0];
707 spacecraft_potential[3] = e1_ptr[1];
707 spacecraft_potential[3] = e1_ptr[1];
708 spacecraft_potential[4] = e2_ptr[0];
708 spacecraft_potential[4] = e2_ptr[0];
709 spacecraft_potential[5] = e2_ptr[1];
709 spacecraft_potential[5] = e2_ptr[1];
710 }
710 }
711
711
712 void get_cpu_load( unsigned char *resource_statistics )
712 void get_cpu_load( unsigned char *resource_statistics )
713 {
713 {
714 unsigned char cpu_load;
714 unsigned char cpu_load;
715
715
716 cpu_load = lfr_rtems_cpu_usage_report();
716 cpu_load = lfr_rtems_cpu_usage_report();
717
717
718 // HK_LFR_CPU_LOAD
718 // HK_LFR_CPU_LOAD
719 resource_statistics[0] = cpu_load;
719 resource_statistics[0] = cpu_load;
720
720
721 // HK_LFR_CPU_LOAD_MAX
721 // HK_LFR_CPU_LOAD_MAX
722 if (cpu_load > resource_statistics[1])
722 if (cpu_load > resource_statistics[1])
723 {
723 {
724 resource_statistics[1] = cpu_load;
724 resource_statistics[1] = cpu_load;
725 }
725 }
726
726
727 // CPU_LOAD_AVE
727 // CPU_LOAD_AVE
728 resource_statistics[2] = 0;
728 resource_statistics[2] = 0;
729
729
730 #ifndef PRINT_TASK_STATISTICS
730 #ifndef PRINT_TASK_STATISTICS
731 rtems_cpu_usage_reset();
731 rtems_cpu_usage_reset();
732 #endif
732 #endif
733
733
734 }
734 }
735
735
736 void set_hk_lfr_sc_potential_flag( bool state )
736 void set_hk_lfr_sc_potential_flag( bool state )
737 {
737 {
738 if (state == true)
738 if (state == true)
739 {
739 {
740 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000]
740 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000]
741 }
741 }
742 else
742 else
743 {
743 {
744 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111]
744 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111]
745 }
745 }
746 }
746 }
747
747
748 void set_sy_lfr_pas_filter_enabled( bool state )
748 void set_sy_lfr_pas_filter_enabled( bool state )
749 {
749 {
750 if (state == true)
750 if (state == true)
751 {
751 {
752 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000]
752 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000]
753 }
753 }
754 else
754 else
755 {
755 {
756 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xdf; // [1101 1111]
756 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xdf; // [1101 1111]
757 }
757 }
758 }
758 }
759
759
760 void set_sy_lfr_watchdog_enabled( bool state )
760 void set_sy_lfr_watchdog_enabled( bool state )
761 {
761 {
762 if (state == true)
762 if (state == true)
763 {
763 {
764 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x10; // [0001 0000]
764 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x10; // [0001 0000]
765 }
765 }
766 else
766 else
767 {
767 {
768 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xef; // [1110 1111]
768 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xef; // [1110 1111]
769 }
769 }
770 }
770 }
771
771
772 void set_hk_lfr_calib_enable( bool state )
772 void set_hk_lfr_calib_enable( bool state )
773 {
773 {
774 if (state == true)
774 if (state == true)
775 {
775 {
776 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000]
776 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000]
777 }
777 }
778 else
778 else
779 {
779 {
780 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111]
780 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111]
781 }
781 }
782 }
782 }
783
783
784 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause )
784 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause )
785 {
785 {
786 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf8; // [1111 1000]
786 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf8; // [1111 1000]
787
787
788 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
788 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
789 | (lfr_reset_cause & 0x07 ); // [0000 0111]
789 | (lfr_reset_cause & 0x07 ); // [0000 0111]
790
790
791 }
791 }
792
792
793 void hk_lfr_le_me_he_update()
793 void hk_lfr_le_me_he_update()
794 {
794 {
795 unsigned int hk_lfr_le_cnt;
795 unsigned int hk_lfr_le_cnt;
796 unsigned int hk_lfr_me_cnt;
796 unsigned int hk_lfr_me_cnt;
797 unsigned int hk_lfr_he_cnt;
797 unsigned int hk_lfr_he_cnt;
798 unsigned int current_hk_lfr_le_cnt;
798 unsigned int current_hk_lfr_le_cnt;
799 unsigned int current_hk_lfr_me_cnt;
799 unsigned int current_hk_lfr_me_cnt;
800 unsigned int current_hk_lfr_he_cnt;
800 unsigned int current_hk_lfr_he_cnt;
801
801
802 hk_lfr_le_cnt = 0;
802 hk_lfr_le_cnt = 0;
803 hk_lfr_me_cnt = 0;
803 hk_lfr_me_cnt = 0;
804 hk_lfr_he_cnt = 0;
804 hk_lfr_he_cnt = 0;
805 current_hk_lfr_le_cnt = ((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256 + housekeeping_packet.hk_lfr_le_cnt[1];
805 current_hk_lfr_le_cnt = ((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256 + housekeeping_packet.hk_lfr_le_cnt[1];
806 current_hk_lfr_me_cnt = ((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256 + housekeeping_packet.hk_lfr_me_cnt[1];
806 current_hk_lfr_me_cnt = ((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256 + housekeeping_packet.hk_lfr_me_cnt[1];
807 current_hk_lfr_he_cnt = ((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256 + housekeeping_packet.hk_lfr_he_cnt[1];
807 current_hk_lfr_he_cnt = ((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256 + housekeeping_packet.hk_lfr_he_cnt[1];
808
808
809 //update the low severity error counter
809 //update the low severity error counter
810 hk_lfr_le_cnt =
810 hk_lfr_le_cnt =
811 current_hk_lfr_le_cnt
811 current_hk_lfr_le_cnt
812 + housekeeping_packet.hk_lfr_dpu_spw_parity
812 + housekeeping_packet.hk_lfr_dpu_spw_parity
813 + housekeeping_packet.hk_lfr_dpu_spw_disconnect
813 + housekeeping_packet.hk_lfr_dpu_spw_disconnect
814 + housekeeping_packet.hk_lfr_dpu_spw_escape
814 + housekeeping_packet.hk_lfr_dpu_spw_escape
815 + housekeeping_packet.hk_lfr_dpu_spw_credit
815 + housekeeping_packet.hk_lfr_dpu_spw_credit
816 + housekeeping_packet.hk_lfr_dpu_spw_write_sync
816 + housekeeping_packet.hk_lfr_dpu_spw_write_sync
817 + housekeeping_packet.hk_lfr_timecode_erroneous
817 + housekeeping_packet.hk_lfr_timecode_erroneous
818 + housekeeping_packet.hk_lfr_timecode_missing
818 + housekeeping_packet.hk_lfr_timecode_missing
819 + housekeeping_packet.hk_lfr_timecode_invalid
819 + housekeeping_packet.hk_lfr_timecode_invalid
820 + housekeeping_packet.hk_lfr_time_timecode_it
820 + housekeeping_packet.hk_lfr_time_timecode_it
821 + housekeeping_packet.hk_lfr_time_not_synchro
821 + housekeeping_packet.hk_lfr_time_not_synchro
822 + housekeeping_packet.hk_lfr_time_timecode_ctr
822 + housekeeping_packet.hk_lfr_time_timecode_ctr
823 + housekeeping_packet.hk_lfr_ahb_correctable;
823 + housekeeping_packet.hk_lfr_ahb_correctable;
824 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
824 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
825 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
825 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
826
826
827 //update the medium severity error counter
827 //update the medium severity error counter
828 hk_lfr_me_cnt =
828 hk_lfr_me_cnt =
829 current_hk_lfr_me_cnt
829 current_hk_lfr_me_cnt
830 + housekeeping_packet.hk_lfr_dpu_spw_early_eop
830 + housekeeping_packet.hk_lfr_dpu_spw_early_eop
831 + housekeeping_packet.hk_lfr_dpu_spw_invalid_addr
831 + housekeeping_packet.hk_lfr_dpu_spw_invalid_addr
832 + housekeeping_packet.hk_lfr_dpu_spw_eep
832 + housekeeping_packet.hk_lfr_dpu_spw_eep
833 + housekeeping_packet.hk_lfr_dpu_spw_rx_too_big;
833 + housekeeping_packet.hk_lfr_dpu_spw_rx_too_big;
834
834
835 //update the high severity error counter
835 //update the high severity error counter
836 hk_lfr_he_cnt = 0;
836 hk_lfr_he_cnt = 0;
837
837
838 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
838 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
839 // LE
839 // LE
840 housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((hk_lfr_le_cnt & 0xff00) >> 8);
840 housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((hk_lfr_le_cnt & 0xff00) >> 8);
841 housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (hk_lfr_le_cnt & 0x00ff);
841 housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (hk_lfr_le_cnt & 0x00ff);
842 // ME
842 // ME
843 housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((hk_lfr_me_cnt & 0xff00) >> 8);
843 housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((hk_lfr_me_cnt & 0xff00) >> 8);
844 housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (hk_lfr_me_cnt & 0x00ff);
844 housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (hk_lfr_me_cnt & 0x00ff);
845 // HE
845 // HE
846 housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & 0xff00) >> 8);
846 housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & 0xff00) >> 8);
847 housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & 0x00ff);
847 housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & 0x00ff);
848
848
849 }
849 }
850
850
851 void set_hk_lfr_time_not_synchro()
851 void set_hk_lfr_time_not_synchro()
852 {
852 {
853 static unsigned char synchroLost = 1;
853 static unsigned char synchroLost = 1;
854 int synchronizationBit;
854 int synchronizationBit;
855
855
856 // get the synchronization bit
856 // get the synchronization bit
857 synchronizationBit = (time_management_regs->coarse_time & 0x80000000) >> 31; // 1000 0000 0000 0000
857 synchronizationBit = (time_management_regs->coarse_time & 0x80000000) >> 31; // 1000 0000 0000 0000
858
858
859 switch (synchronizationBit)
859 switch (synchronizationBit)
860 {
860 {
861 case 0:
861 case 0:
862 if (synchroLost == 1)
862 if (synchroLost == 1)
863 {
863 {
864 synchroLost = 0;
864 synchroLost = 0;
865 }
865 }
866 break;
866 break;
867 case 1:
867 case 1:
868 if (synchroLost == 0 )
868 if (synchroLost == 0 )
869 {
869 {
870 synchroLost = 1;
870 synchroLost = 1;
871 increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro);
871 increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro);
872 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO );
872 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO );
873 }
873 }
874 break;
874 break;
875 default:
875 default:
876 PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit);
876 PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit);
877 break;
877 break;
878 }
878 }
879
879
880 }
880 }
881
881
882 void set_hk_lfr_ahb_correctable() // CRITICITY L
882 void set_hk_lfr_ahb_correctable() // CRITICITY L
883 {
883 {
884 /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided
884 /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided
885 * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the
885 * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the
886 * detected errors in the cache, in the integer unit and in the floating point unit.
886 * detected errors in the cache, in the integer unit and in the floating point unit.
887 *
887 *
888 * @param void
888 * @param void
889 *
889 *
890 * @return void
890 * @return void
891 *
891 *
892 * All errors are summed to set the value of the hk_lfr_ahb_correctable counter.
892 * All errors are summed to set the value of the hk_lfr_ahb_correctable counter.
893 *
893 *
894 */
894 */
895
895
896 unsigned int ahb_correctable;
896 unsigned int ahb_correctable;
897 unsigned int instructionErrorCounter;
897 unsigned int instructionErrorCounter;
898 unsigned int dataErrorCounter;
898 unsigned int dataErrorCounter;
899 unsigned int fprfErrorCounter;
899 unsigned int fprfErrorCounter;
900 unsigned int iurfErrorCounter;
900 unsigned int iurfErrorCounter;
901
901
902 CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter);
902 CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter);
903 ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter);
903 ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter);
904
904
905 ahb_correctable = instructionErrorCounter
905 ahb_correctable = instructionErrorCounter
906 + dataErrorCounter
906 + dataErrorCounter
907 + fprfErrorCounter
907 + fprfErrorCounter
908 + iurfErrorCounter
908 + iurfErrorCounter
909 + housekeeping_packet.hk_lfr_ahb_correctable;
909 + housekeeping_packet.hk_lfr_ahb_correctable;
910
910
911 housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & 0xff); // [1111 1111]
911 housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & 0xff); // [1111 1111]
912
912
913 }
913 }
@@ -1,1753 +1,1711
1 /** Functions to load and dump parameters in the LFR registers.
1 /** Functions to load and dump parameters in the LFR registers.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TC related to parameter loading and dumping.\n
6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 * TC_LFR_LOAD_COMMON_PAR\n
7 * TC_LFR_LOAD_COMMON_PAR\n
8 * TC_LFR_LOAD_NORMAL_PAR\n
8 * TC_LFR_LOAD_NORMAL_PAR\n
9 * TC_LFR_LOAD_BURST_PAR\n
9 * TC_LFR_LOAD_BURST_PAR\n
10 * TC_LFR_LOAD_SBM1_PAR\n
10 * TC_LFR_LOAD_SBM1_PAR\n
11 * TC_LFR_LOAD_SBM2_PAR\n
11 * TC_LFR_LOAD_SBM2_PAR\n
12 *
12 *
13 */
13 */
14
14
15 #include "tc_load_dump_parameters.h"
15 #include "tc_load_dump_parameters.h"
16
16
17 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1;
17 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1;
18 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2;
18 Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2;
19 ring_node kcoefficient_node_1;
19 ring_node kcoefficient_node_1;
20 ring_node kcoefficient_node_2;
20 ring_node kcoefficient_node_2;
21
21
22 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
22 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
23 {
23 {
24 /** This function updates the LFR registers with the incoming common parameters.
24 /** This function updates the LFR registers with the incoming common parameters.
25 *
25 *
26 * @param TC points to the TeleCommand packet that is being processed
26 * @param TC points to the TeleCommand packet that is being processed
27 *
27 *
28 *
28 *
29 */
29 */
30
30
31 parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0];
31 parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0];
32 parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1];
32 parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1];
33 set_wfp_data_shaping( );
33 set_wfp_data_shaping( );
34 return LFR_SUCCESSFUL;
34 return LFR_SUCCESSFUL;
35 }
35 }
36
36
37 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
37 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
38 {
38 {
39 /** This function updates the LFR registers with the incoming normal parameters.
39 /** This function updates the LFR registers with the incoming normal parameters.
40 *
40 *
41 * @param TC points to the TeleCommand packet that is being processed
41 * @param TC points to the TeleCommand packet that is being processed
42 * @param queue_id is the id of the queue which handles TM related to this execution step
42 * @param queue_id is the id of the queue which handles TM related to this execution step
43 *
43 *
44 */
44 */
45
45
46 int result;
46 int result;
47 int flag;
47 int flag;
48 rtems_status_code status;
48 rtems_status_code status;
49
49
50 flag = LFR_SUCCESSFUL;
50 flag = LFR_SUCCESSFUL;
51
51
52 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
52 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
53 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
53 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
54 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
54 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
55 flag = LFR_DEFAULT;
55 flag = LFR_DEFAULT;
56 }
56 }
57
57
58 // CHECK THE PARAMETERS SET CONSISTENCY
58 // CHECK THE PARAMETERS SET CONSISTENCY
59 if (flag == LFR_SUCCESSFUL)
59 if (flag == LFR_SUCCESSFUL)
60 {
60 {
61 flag = check_normal_par_consistency( TC, queue_id );
61 flag = check_normal_par_consistency( TC, queue_id );
62 }
62 }
63
63
64 // SET THE PARAMETERS IF THEY ARE CONSISTENT
64 // SET THE PARAMETERS IF THEY ARE CONSISTENT
65 if (flag == LFR_SUCCESSFUL)
65 if (flag == LFR_SUCCESSFUL)
66 {
66 {
67 result = set_sy_lfr_n_swf_l( TC );
67 result = set_sy_lfr_n_swf_l( TC );
68 result = set_sy_lfr_n_swf_p( TC );
68 result = set_sy_lfr_n_swf_p( TC );
69 result = set_sy_lfr_n_bp_p0( TC );
69 result = set_sy_lfr_n_bp_p0( TC );
70 result = set_sy_lfr_n_bp_p1( TC );
70 result = set_sy_lfr_n_bp_p1( TC );
71 result = set_sy_lfr_n_asm_p( TC );
71 result = set_sy_lfr_n_asm_p( TC );
72 result = set_sy_lfr_n_cwf_long_f3( TC );
72 result = set_sy_lfr_n_cwf_long_f3( TC );
73 }
73 }
74
74
75 return flag;
75 return flag;
76 }
76 }
77
77
78 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
78 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
79 {
79 {
80 /** This function updates the LFR registers with the incoming burst parameters.
80 /** This function updates the LFR registers with the incoming burst parameters.
81 *
81 *
82 * @param TC points to the TeleCommand packet that is being processed
82 * @param TC points to the TeleCommand packet that is being processed
83 * @param queue_id is the id of the queue which handles TM related to this execution step
83 * @param queue_id is the id of the queue which handles TM related to this execution step
84 *
84 *
85 */
85 */
86
86
87 int flag;
87 int flag;
88 rtems_status_code status;
88 rtems_status_code status;
89 unsigned char sy_lfr_b_bp_p0;
89 unsigned char sy_lfr_b_bp_p0;
90 unsigned char sy_lfr_b_bp_p1;
90 unsigned char sy_lfr_b_bp_p1;
91 float aux;
91 float aux;
92
92
93 flag = LFR_SUCCESSFUL;
93 flag = LFR_SUCCESSFUL;
94
94
95 if ( lfrCurrentMode == LFR_MODE_BURST ) {
95 if ( lfrCurrentMode == LFR_MODE_BURST ) {
96 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
96 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
97 flag = LFR_DEFAULT;
97 flag = LFR_DEFAULT;
98 }
98 }
99
99
100 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
100 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
101 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
101 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
102
102
103 // sy_lfr_b_bp_p0 shall not be lower than its default value
103 // sy_lfr_b_bp_p0 shall not be lower than its default value
104 if (flag == LFR_SUCCESSFUL)
104 if (flag == LFR_SUCCESSFUL)
105 {
105 {
106 if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 )
106 if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 )
107 {
107 {
108 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
108 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
109 flag = WRONG_APP_DATA;
109 flag = WRONG_APP_DATA;
110 }
110 }
111 }
111 }
112 // sy_lfr_b_bp_p1 shall not be lower than its default value
112 // sy_lfr_b_bp_p1 shall not be lower than its default value
113 if (flag == LFR_SUCCESSFUL)
113 if (flag == LFR_SUCCESSFUL)
114 {
114 {
115 if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 )
115 if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 )
116 {
116 {
117 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 );
117 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 );
118 flag = WRONG_APP_DATA;
118 flag = WRONG_APP_DATA;
119 }
119 }
120 }
120 }
121 //****************************************************************
121 //****************************************************************
122 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
122 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
123 if (flag == LFR_SUCCESSFUL)
123 if (flag == LFR_SUCCESSFUL)
124 {
124 {
125 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
125 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
126 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
126 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
127 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
127 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
128 if (aux > FLOAT_EQUAL_ZERO)
128 if (aux > FLOAT_EQUAL_ZERO)
129 {
129 {
130 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
130 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
131 flag = LFR_DEFAULT;
131 flag = LFR_DEFAULT;
132 }
132 }
133 }
133 }
134
134
135 // SET THE PARAMETERS
135 // SET THE PARAMETERS
136 if (flag == LFR_SUCCESSFUL)
136 if (flag == LFR_SUCCESSFUL)
137 {
137 {
138 flag = set_sy_lfr_b_bp_p0( TC );
138 flag = set_sy_lfr_b_bp_p0( TC );
139 flag = set_sy_lfr_b_bp_p1( TC );
139 flag = set_sy_lfr_b_bp_p1( TC );
140 }
140 }
141
141
142 return flag;
142 return flag;
143 }
143 }
144
144
145 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
145 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
146 {
146 {
147 /** This function updates the LFR registers with the incoming sbm1 parameters.
147 /** This function updates the LFR registers with the incoming sbm1 parameters.
148 *
148 *
149 * @param TC points to the TeleCommand packet that is being processed
149 * @param TC points to the TeleCommand packet that is being processed
150 * @param queue_id is the id of the queue which handles TM related to this execution step
150 * @param queue_id is the id of the queue which handles TM related to this execution step
151 *
151 *
152 */
152 */
153
153
154 int flag;
154 int flag;
155 rtems_status_code status;
155 rtems_status_code status;
156 unsigned char sy_lfr_s1_bp_p0;
156 unsigned char sy_lfr_s1_bp_p0;
157 unsigned char sy_lfr_s1_bp_p1;
157 unsigned char sy_lfr_s1_bp_p1;
158 float aux;
158 float aux;
159
159
160 flag = LFR_SUCCESSFUL;
160 flag = LFR_SUCCESSFUL;
161
161
162 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
162 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
163 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
163 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
164 flag = LFR_DEFAULT;
164 flag = LFR_DEFAULT;
165 }
165 }
166
166
167 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
167 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
168 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
168 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
169
169
170 // sy_lfr_s1_bp_p0
170 // sy_lfr_s1_bp_p0
171 if (flag == LFR_SUCCESSFUL)
171 if (flag == LFR_SUCCESSFUL)
172 {
172 {
173 if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 )
173 if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 )
174 {
174 {
175 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
175 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
176 flag = WRONG_APP_DATA;
176 flag = WRONG_APP_DATA;
177 }
177 }
178 }
178 }
179 // sy_lfr_s1_bp_p1
179 // sy_lfr_s1_bp_p1
180 if (flag == LFR_SUCCESSFUL)
180 if (flag == LFR_SUCCESSFUL)
181 {
181 {
182 if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 )
182 if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 )
183 {
183 {
184 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 );
184 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 );
185 flag = WRONG_APP_DATA;
185 flag = WRONG_APP_DATA;
186 }
186 }
187 }
187 }
188 //******************************************************************
188 //******************************************************************
189 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
189 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
190 if (flag == LFR_SUCCESSFUL)
190 if (flag == LFR_SUCCESSFUL)
191 {
191 {
192 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
192 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
193 if (aux > FLOAT_EQUAL_ZERO)
193 if (aux > FLOAT_EQUAL_ZERO)
194 {
194 {
195 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
195 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
196 flag = LFR_DEFAULT;
196 flag = LFR_DEFAULT;
197 }
197 }
198 }
198 }
199
199
200 // SET THE PARAMETERS
200 // SET THE PARAMETERS
201 if (flag == LFR_SUCCESSFUL)
201 if (flag == LFR_SUCCESSFUL)
202 {
202 {
203 flag = set_sy_lfr_s1_bp_p0( TC );
203 flag = set_sy_lfr_s1_bp_p0( TC );
204 flag = set_sy_lfr_s1_bp_p1( TC );
204 flag = set_sy_lfr_s1_bp_p1( TC );
205 }
205 }
206
206
207 return flag;
207 return flag;
208 }
208 }
209
209
210 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
210 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
211 {
211 {
212 /** This function updates the LFR registers with the incoming sbm2 parameters.
212 /** This function updates the LFR registers with the incoming sbm2 parameters.
213 *
213 *
214 * @param TC points to the TeleCommand packet that is being processed
214 * @param TC points to the TeleCommand packet that is being processed
215 * @param queue_id is the id of the queue which handles TM related to this execution step
215 * @param queue_id is the id of the queue which handles TM related to this execution step
216 *
216 *
217 */
217 */
218
218
219 int flag;
219 int flag;
220 rtems_status_code status;
220 rtems_status_code status;
221 unsigned char sy_lfr_s2_bp_p0;
221 unsigned char sy_lfr_s2_bp_p0;
222 unsigned char sy_lfr_s2_bp_p1;
222 unsigned char sy_lfr_s2_bp_p1;
223 float aux;
223 float aux;
224
224
225 flag = LFR_SUCCESSFUL;
225 flag = LFR_SUCCESSFUL;
226
226
227 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
227 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
228 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
228 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
229 flag = LFR_DEFAULT;
229 flag = LFR_DEFAULT;
230 }
230 }
231
231
232 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
232 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
233 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
233 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
234
234
235 // sy_lfr_s2_bp_p0
235 // sy_lfr_s2_bp_p0
236 if (flag == LFR_SUCCESSFUL)
236 if (flag == LFR_SUCCESSFUL)
237 {
237 {
238 if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 )
238 if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 )
239 {
239 {
240 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
240 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
241 flag = WRONG_APP_DATA;
241 flag = WRONG_APP_DATA;
242 }
242 }
243 }
243 }
244 // sy_lfr_s2_bp_p1
244 // sy_lfr_s2_bp_p1
245 if (flag == LFR_SUCCESSFUL)
245 if (flag == LFR_SUCCESSFUL)
246 {
246 {
247 if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 )
247 if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 )
248 {
248 {
249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 );
249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 );
250 flag = WRONG_APP_DATA;
250 flag = WRONG_APP_DATA;
251 }
251 }
252 }
252 }
253 //******************************************************************
253 //******************************************************************
254 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
254 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
255 if (flag == LFR_SUCCESSFUL)
255 if (flag == LFR_SUCCESSFUL)
256 {
256 {
257 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
257 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
258 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
258 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
259 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
259 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
260 if (aux > FLOAT_EQUAL_ZERO)
260 if (aux > FLOAT_EQUAL_ZERO)
261 {
261 {
262 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
262 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
263 flag = LFR_DEFAULT;
263 flag = LFR_DEFAULT;
264 }
264 }
265 }
265 }
266
266
267 // SET THE PARAMETERS
267 // SET THE PARAMETERS
268 if (flag == LFR_SUCCESSFUL)
268 if (flag == LFR_SUCCESSFUL)
269 {
269 {
270 flag = set_sy_lfr_s2_bp_p0( TC );
270 flag = set_sy_lfr_s2_bp_p0( TC );
271 flag = set_sy_lfr_s2_bp_p1( TC );
271 flag = set_sy_lfr_s2_bp_p1( TC );
272 }
272 }
273
273
274 return flag;
274 return flag;
275 }
275 }
276
276
277 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
277 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
278 {
278 {
279 /** This function updates the LFR registers with the incoming sbm2 parameters.
279 /** This function updates the LFR registers with the incoming sbm2 parameters.
280 *
280 *
281 * @param TC points to the TeleCommand packet that is being processed
281 * @param TC points to the TeleCommand packet that is being processed
282 * @param queue_id is the id of the queue which handles TM related to this execution step
282 * @param queue_id is the id of the queue which handles TM related to this execution step
283 *
283 *
284 */
284 */
285
285
286 int flag;
286 int flag;
287
287
288 flag = LFR_DEFAULT;
288 flag = LFR_DEFAULT;
289
289
290 flag = set_sy_lfr_kcoeff( TC, queue_id );
290 flag = set_sy_lfr_kcoeff( TC, queue_id );
291
291
292 return flag;
292 return flag;
293 }
293 }
294
294
295 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
295 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
296 {
296 {
297 /** This function updates the LFR registers with the incoming sbm2 parameters.
297 /** This function updates the LFR registers with the incoming sbm2 parameters.
298 *
298 *
299 * @param TC points to the TeleCommand packet that is being processed
299 * @param TC points to the TeleCommand packet that is being processed
300 * @param queue_id is the id of the queue which handles TM related to this execution step
300 * @param queue_id is the id of the queue which handles TM related to this execution step
301 *
301 *
302 */
302 */
303
303
304 int flag;
304 int flag;
305
305
306 flag = LFR_DEFAULT;
306 flag = LFR_DEFAULT;
307
307
308 flag = set_sy_lfr_fbins( TC );
308 flag = set_sy_lfr_fbins( TC );
309
309
310 return flag;
310 return flag;
311 }
311 }
312
312
313 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
313 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
314 {
314 {
315 /** This function updates the LFR registers with the incoming sbm2 parameters.
315 /** This function updates the LFR registers with the incoming sbm2 parameters.
316 *
316 *
317 * @param TC points to the TeleCommand packet that is being processed
317 * @param TC points to the TeleCommand packet that is being processed
318 * @param queue_id is the id of the queue which handles TM related to this execution step
318 * @param queue_id is the id of the queue which handles TM related to this execution step
319 *
319 *
320 */
320 */
321
321
322 int flag;
322 int flag;
323 unsigned char k;
323 unsigned char k;
324
324
325 flag = LFR_DEFAULT;
325 flag = LFR_DEFAULT;
326 k = 0;
326 k = 0;
327
327
328 flag = check_sy_lfr_filter_parameters( TC, queue_id );
328 flag = check_sy_lfr_filter_parameters( TC, queue_id );
329
329
330 if (flag == LFR_SUCCESSFUL)
330 if (flag == LFR_SUCCESSFUL)
331 {
331 {
332 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
332 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
333 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
333 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
334 parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ];
334 parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ];
335 parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ];
335 parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ];
336 parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ];
336 parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ];
337 parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ];
337 parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ];
338 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
338 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
339 parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ];
339 parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ];
340 parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ];
340 parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ];
341 parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ];
341 parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ];
342 parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ];
342 parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ];
343 parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ];
343 parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ];
344 parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ];
344 parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ];
345 parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ];
345 parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ];
346 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
346 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
347
347
348 //****************************
348 //****************************
349 // store PAS filter parameters
349 // store PAS filter parameters
350 // sy_lfr_pas_filter_enabled
350 // sy_lfr_pas_filter_enabled
351 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
351 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
352 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 );
352 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 );
353 // sy_lfr_pas_filter_modulus
353 // sy_lfr_pas_filter_modulus
354 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
354 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
355 // sy_lfr_pas_filter_tbad
355 // sy_lfr_pas_filter_tbad
356 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
356 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
357 parameter_dump_packet.sy_lfr_pas_filter_tbad );
357 parameter_dump_packet.sy_lfr_pas_filter_tbad );
358 // sy_lfr_pas_filter_offset
358 // sy_lfr_pas_filter_offset
359 filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset;
359 filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset;
360 // sy_lfr_pas_filter_shift
360 // sy_lfr_pas_filter_shift
361 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
361 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
362 parameter_dump_packet.sy_lfr_pas_filter_shift );
362 parameter_dump_packet.sy_lfr_pas_filter_shift );
363
363
364 //****************************************************
364 //****************************************************
365 // store the parameter sy_lfr_sc_rw_delta_f as a float
365 // store the parameter sy_lfr_sc_rw_delta_f as a float
366 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
366 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
367 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
367 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
368
368
369 // copy rw.._k.. from the incoming TC to the local parameter_dump_packet
369 // copy rw.._k.. from the incoming TC to the local parameter_dump_packet
370 for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++)
370 for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++)
371 {
371 {
372 parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ];
372 parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ];
373 }
373 }
374
374
375 //***********************************************
375 //***********************************************
376 // store the parameter sy_lfr_rw.._k.. as a float
376 // store the parameter sy_lfr_rw.._k.. as a float
377 // rw1_k
377 // rw1_k
378 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 );
378 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 );
379 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 );
379 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 );
380 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 );
380 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 );
381 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 );
381 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 );
382 // rw2_k
382 // rw2_k
383 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 );
383 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 );
384 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 );
384 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 );
385 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 );
385 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 );
386 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 );
386 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 );
387 // rw3_k
387 // rw3_k
388 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 );
388 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 );
389 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 );
389 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 );
390 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 );
390 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 );
391 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 );
391 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 );
392 // rw4_k
392 // rw4_k
393 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 );
393 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 );
394 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 );
394 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 );
395 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 );
395 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 );
396 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 );
396 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 );
397
397
398 }
398 }
399
399
400 return flag;
400 return flag;
401 }
401 }
402
402
403 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
403 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
404 {
404 {
405 /** This function updates the LFR registers with the incoming sbm2 parameters.
405 /** This function updates the LFR registers with the incoming sbm2 parameters.
406 *
406 *
407 * @param TC points to the TeleCommand packet that is being processed
407 * @param TC points to the TeleCommand packet that is being processed
408 * @param queue_id is the id of the queue which handles TM related to this execution step
408 * @param queue_id is the id of the queue which handles TM related to this execution step
409 *
409 *
410 */
410 */
411
411
412 unsigned int address;
412 unsigned int address;
413 rtems_status_code status;
413 rtems_status_code status;
414 unsigned int freq;
414 unsigned int freq;
415 unsigned int bin;
415 unsigned int bin;
416 unsigned int coeff;
416 unsigned int coeff;
417 unsigned char *kCoeffPtr;
417 unsigned char *kCoeffPtr;
418 unsigned char *kCoeffDumpPtr;
418 unsigned char *kCoeffDumpPtr;
419
419
420 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
420 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
421 // F0 => 11 bins
421 // F0 => 11 bins
422 // F1 => 13 bins
422 // F1 => 13 bins
423 // F2 => 12 bins
423 // F2 => 12 bins
424 // 36 bins to dump in two packets (30 bins max per packet)
424 // 36 bins to dump in two packets (30 bins max per packet)
425
425
426 //*********
426 //*********
427 // PACKET 1
427 // PACKET 1
428 // 11 F0 bins, 13 F1 bins and 6 F2 bins
428 // 11 F0 bins, 13 F1 bins and 6 F2 bins
429 kcoefficients_dump_1.destinationID = TC->sourceID;
429 kcoefficients_dump_1.destinationID = TC->sourceID;
430 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
430 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
431 for( freq=0;
431 for( freq=0;
432 freq<NB_BINS_COMPRESSED_SM_F0;
432 freq<NB_BINS_COMPRESSED_SM_F0;
433 freq++ )
433 freq++ )
434 {
434 {
435 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
435 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
436 bin = freq;
436 bin = freq;
437 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
437 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
438 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
438 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
439 {
439 {
440 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
440 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
441 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
441 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
442 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
442 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
443 }
443 }
444 }
444 }
445 for( freq=NB_BINS_COMPRESSED_SM_F0;
445 for( freq=NB_BINS_COMPRESSED_SM_F0;
446 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
446 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
447 freq++ )
447 freq++ )
448 {
448 {
449 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
449 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
450 bin = freq - NB_BINS_COMPRESSED_SM_F0;
450 bin = freq - NB_BINS_COMPRESSED_SM_F0;
451 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
451 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
452 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
452 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
453 {
453 {
454 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
454 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
455 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
455 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
456 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
456 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
457 }
457 }
458 }
458 }
459 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
459 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
460 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
460 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
461 freq++ )
461 freq++ )
462 {
462 {
463 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
463 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
464 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
464 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
465 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
465 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
466 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
466 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
467 {
467 {
468 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
468 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
469 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
469 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
470 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
470 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
471 }
471 }
472 }
472 }
473 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
473 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
474 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
474 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
475 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
475 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
476 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
476 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
477 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
477 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
478 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
478 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
479 // SEND DATA
479 // SEND DATA
480 kcoefficient_node_1.status = 1;
480 kcoefficient_node_1.status = 1;
481 address = (unsigned int) &kcoefficient_node_1;
481 address = (unsigned int) &kcoefficient_node_1;
482 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
482 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
483 if (status != RTEMS_SUCCESSFUL) {
483 if (status != RTEMS_SUCCESSFUL) {
484 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
484 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
485 }
485 }
486
486
487 //********
487 //********
488 // PACKET 2
488 // PACKET 2
489 // 6 F2 bins
489 // 6 F2 bins
490 kcoefficients_dump_2.destinationID = TC->sourceID;
490 kcoefficients_dump_2.destinationID = TC->sourceID;
491 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
491 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
492 for( freq=0; freq<6; freq++ )
492 for( freq=0; freq<6; freq++ )
493 {
493 {
494 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
494 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
495 bin = freq + 6;
495 bin = freq + 6;
496 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
496 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
497 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
497 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
498 {
498 {
499 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
499 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
500 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
500 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
501 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
501 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
502 }
502 }
503 }
503 }
504 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
504 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
505 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
505 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
506 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
506 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
507 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
507 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
508 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
508 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
509 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
509 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
510 // SEND DATA
510 // SEND DATA
511 kcoefficient_node_2.status = 1;
511 kcoefficient_node_2.status = 1;
512 address = (unsigned int) &kcoefficient_node_2;
512 address = (unsigned int) &kcoefficient_node_2;
513 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
513 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
514 if (status != RTEMS_SUCCESSFUL) {
514 if (status != RTEMS_SUCCESSFUL) {
515 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
515 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
516 }
516 }
517
517
518 return status;
518 return status;
519 }
519 }
520
520
521 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
521 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
522 {
522 {
523 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
523 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
524 *
524 *
525 * @param queue_id is the id of the queue which handles TM related to this execution step.
525 * @param queue_id is the id of the queue which handles TM related to this execution step.
526 *
526 *
527 * @return RTEMS directive status codes:
527 * @return RTEMS directive status codes:
528 * - RTEMS_SUCCESSFUL - message sent successfully
528 * - RTEMS_SUCCESSFUL - message sent successfully
529 * - RTEMS_INVALID_ID - invalid queue id
529 * - RTEMS_INVALID_ID - invalid queue id
530 * - RTEMS_INVALID_SIZE - invalid message size
530 * - RTEMS_INVALID_SIZE - invalid message size
531 * - RTEMS_INVALID_ADDRESS - buffer is NULL
531 * - RTEMS_INVALID_ADDRESS - buffer is NULL
532 * - RTEMS_UNSATISFIED - out of message buffers
532 * - RTEMS_UNSATISFIED - out of message buffers
533 * - RTEMS_TOO_MANY - queue s limit has been reached
533 * - RTEMS_TOO_MANY - queue s limit has been reached
534 *
534 *
535 */
535 */
536
536
537 int status;
537 int status;
538
538
539 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
539 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
540 parameter_dump_packet.destinationID = TC->sourceID;
540 parameter_dump_packet.destinationID = TC->sourceID;
541
541
542 // UPDATE TIME
542 // UPDATE TIME
543 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
543 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
544 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
544 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
545 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
545 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
546 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
546 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
547 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
547 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
548 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
548 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
549 // SEND DATA
549 // SEND DATA
550 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
550 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
551 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
551 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
552 if (status != RTEMS_SUCCESSFUL) {
552 if (status != RTEMS_SUCCESSFUL) {
553 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
553 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
554 }
554 }
555
555
556 return status;
556 return status;
557 }
557 }
558
558
559 //***********************
559 //***********************
560 // NORMAL MODE PARAMETERS
560 // NORMAL MODE PARAMETERS
561
561
562 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
562 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
563 {
563 {
564 unsigned char msb;
564 unsigned char msb;
565 unsigned char lsb;
565 unsigned char lsb;
566 int flag;
566 int flag;
567 float aux;
567 float aux;
568 rtems_status_code status;
568 rtems_status_code status;
569
569
570 unsigned int sy_lfr_n_swf_l;
570 unsigned int sy_lfr_n_swf_l;
571 unsigned int sy_lfr_n_swf_p;
571 unsigned int sy_lfr_n_swf_p;
572 unsigned int sy_lfr_n_asm_p;
572 unsigned int sy_lfr_n_asm_p;
573 unsigned char sy_lfr_n_bp_p0;
573 unsigned char sy_lfr_n_bp_p0;
574 unsigned char sy_lfr_n_bp_p1;
574 unsigned char sy_lfr_n_bp_p1;
575 unsigned char sy_lfr_n_cwf_long_f3;
575 unsigned char sy_lfr_n_cwf_long_f3;
576
576
577 flag = LFR_SUCCESSFUL;
577 flag = LFR_SUCCESSFUL;
578
578
579 //***************
579 //***************
580 // get parameters
580 // get parameters
581 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
581 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
582 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
582 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
583 sy_lfr_n_swf_l = msb * 256 + lsb;
583 sy_lfr_n_swf_l = msb * 256 + lsb;
584
584
585 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
585 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
586 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
586 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
587 sy_lfr_n_swf_p = msb * 256 + lsb;
587 sy_lfr_n_swf_p = msb * 256 + lsb;
588
588
589 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
589 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
590 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
590 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
591 sy_lfr_n_asm_p = msb * 256 + lsb;
591 sy_lfr_n_asm_p = msb * 256 + lsb;
592
592
593 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
593 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
594
594
595 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
595 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
596
596
597 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
597 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
598
598
599 //******************
599 //******************
600 // check consistency
600 // check consistency
601 // sy_lfr_n_swf_l
601 // sy_lfr_n_swf_l
602 if (sy_lfr_n_swf_l != 2048)
602 if (sy_lfr_n_swf_l != 2048)
603 {
603 {
604 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
604 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
605 flag = WRONG_APP_DATA;
605 flag = WRONG_APP_DATA;
606 }
606 }
607 // sy_lfr_n_swf_p
607 // sy_lfr_n_swf_p
608 if (flag == LFR_SUCCESSFUL)
608 if (flag == LFR_SUCCESSFUL)
609 {
609 {
610 if ( sy_lfr_n_swf_p < 22 )
610 if ( sy_lfr_n_swf_p < 22 )
611 {
611 {
612 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
612 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
613 flag = WRONG_APP_DATA;
613 flag = WRONG_APP_DATA;
614 }
614 }
615 }
615 }
616 // sy_lfr_n_bp_p0
616 // sy_lfr_n_bp_p0
617 if (flag == LFR_SUCCESSFUL)
617 if (flag == LFR_SUCCESSFUL)
618 {
618 {
619 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
619 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
620 {
620 {
621 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
621 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
622 flag = WRONG_APP_DATA;
622 flag = WRONG_APP_DATA;
623 }
623 }
624 }
624 }
625 // sy_lfr_n_asm_p
625 // sy_lfr_n_asm_p
626 if (flag == LFR_SUCCESSFUL)
626 if (flag == LFR_SUCCESSFUL)
627 {
627 {
628 if (sy_lfr_n_asm_p == 0)
628 if (sy_lfr_n_asm_p == 0)
629 {
629 {
630 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
630 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
631 flag = WRONG_APP_DATA;
631 flag = WRONG_APP_DATA;
632 }
632 }
633 }
633 }
634 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
634 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
635 if (flag == LFR_SUCCESSFUL)
635 if (flag == LFR_SUCCESSFUL)
636 {
636 {
637 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
637 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
638 if (aux > FLOAT_EQUAL_ZERO)
638 if (aux > FLOAT_EQUAL_ZERO)
639 {
639 {
640 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
640 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
641 flag = WRONG_APP_DATA;
641 flag = WRONG_APP_DATA;
642 }
642 }
643 }
643 }
644 // sy_lfr_n_bp_p1
644 // sy_lfr_n_bp_p1
645 if (flag == LFR_SUCCESSFUL)
645 if (flag == LFR_SUCCESSFUL)
646 {
646 {
647 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
647 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
648 {
648 {
649 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
649 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
650 flag = WRONG_APP_DATA;
650 flag = WRONG_APP_DATA;
651 }
651 }
652 }
652 }
653 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
653 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
654 if (flag == LFR_SUCCESSFUL)
654 if (flag == LFR_SUCCESSFUL)
655 {
655 {
656 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
656 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
657 if (aux > FLOAT_EQUAL_ZERO)
657 if (aux > FLOAT_EQUAL_ZERO)
658 {
658 {
659 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
659 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
660 flag = LFR_DEFAULT;
660 flag = LFR_DEFAULT;
661 }
661 }
662 }
662 }
663 // sy_lfr_n_cwf_long_f3
663 // sy_lfr_n_cwf_long_f3
664
664
665 return flag;
665 return flag;
666 }
666 }
667
667
668 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
668 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
669 {
669 {
670 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
670 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
671 *
671 *
672 * @param TC points to the TeleCommand packet that is being processed
672 * @param TC points to the TeleCommand packet that is being processed
673 * @param queue_id is the id of the queue which handles TM related to this execution step
673 * @param queue_id is the id of the queue which handles TM related to this execution step
674 *
674 *
675 */
675 */
676
676
677 int result;
677 int result;
678
678
679 result = LFR_SUCCESSFUL;
679 result = LFR_SUCCESSFUL;
680
680
681 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
681 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
682 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
682 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
683
683
684 return result;
684 return result;
685 }
685 }
686
686
687 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
687 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
688 {
688 {
689 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
689 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
690 *
690 *
691 * @param TC points to the TeleCommand packet that is being processed
691 * @param TC points to the TeleCommand packet that is being processed
692 * @param queue_id is the id of the queue which handles TM related to this execution step
692 * @param queue_id is the id of the queue which handles TM related to this execution step
693 *
693 *
694 */
694 */
695
695
696 int result;
696 int result;
697
697
698 result = LFR_SUCCESSFUL;
698 result = LFR_SUCCESSFUL;
699
699
700 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
700 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
701 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
701 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
702
702
703 return result;
703 return result;
704 }
704 }
705
705
706 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
706 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
707 {
707 {
708 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
708 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
709 *
709 *
710 * @param TC points to the TeleCommand packet that is being processed
710 * @param TC points to the TeleCommand packet that is being processed
711 * @param queue_id is the id of the queue which handles TM related to this execution step
711 * @param queue_id is the id of the queue which handles TM related to this execution step
712 *
712 *
713 */
713 */
714
714
715 int result;
715 int result;
716
716
717 result = LFR_SUCCESSFUL;
717 result = LFR_SUCCESSFUL;
718
718
719 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
719 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
720 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
720 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
721
721
722 return result;
722 return result;
723 }
723 }
724
724
725 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
725 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
726 {
726 {
727 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
727 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
728 *
728 *
729 * @param TC points to the TeleCommand packet that is being processed
729 * @param TC points to the TeleCommand packet that is being processed
730 * @param queue_id is the id of the queue which handles TM related to this execution step
730 * @param queue_id is the id of the queue which handles TM related to this execution step
731 *
731 *
732 */
732 */
733
733
734 int status;
734 int status;
735
735
736 status = LFR_SUCCESSFUL;
736 status = LFR_SUCCESSFUL;
737
737
738 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
738 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
739
739
740 return status;
740 return status;
741 }
741 }
742
742
743 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
743 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
744 {
744 {
745 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
745 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
746 *
746 *
747 * @param TC points to the TeleCommand packet that is being processed
747 * @param TC points to the TeleCommand packet that is being processed
748 * @param queue_id is the id of the queue which handles TM related to this execution step
748 * @param queue_id is the id of the queue which handles TM related to this execution step
749 *
749 *
750 */
750 */
751
751
752 int status;
752 int status;
753
753
754 status = LFR_SUCCESSFUL;
754 status = LFR_SUCCESSFUL;
755
755
756 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
756 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
757
757
758 return status;
758 return status;
759 }
759 }
760
760
761 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
761 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
762 {
762 {
763 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
763 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
764 *
764 *
765 * @param TC points to the TeleCommand packet that is being processed
765 * @param TC points to the TeleCommand packet that is being processed
766 * @param queue_id is the id of the queue which handles TM related to this execution step
766 * @param queue_id is the id of the queue which handles TM related to this execution step
767 *
767 *
768 */
768 */
769
769
770 int status;
770 int status;
771
771
772 status = LFR_SUCCESSFUL;
772 status = LFR_SUCCESSFUL;
773
773
774 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
774 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
775
775
776 return status;
776 return status;
777 }
777 }
778
778
779 //**********************
779 //**********************
780 // BURST MODE PARAMETERS
780 // BURST MODE PARAMETERS
781 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
781 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
782 {
782 {
783 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
783 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
784 *
784 *
785 * @param TC points to the TeleCommand packet that is being processed
785 * @param TC points to the TeleCommand packet that is being processed
786 * @param queue_id is the id of the queue which handles TM related to this execution step
786 * @param queue_id is the id of the queue which handles TM related to this execution step
787 *
787 *
788 */
788 */
789
789
790 int status;
790 int status;
791
791
792 status = LFR_SUCCESSFUL;
792 status = LFR_SUCCESSFUL;
793
793
794 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
794 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
795
795
796 return status;
796 return status;
797 }
797 }
798
798
799 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
799 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
800 {
800 {
801 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
801 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
802 *
802 *
803 * @param TC points to the TeleCommand packet that is being processed
803 * @param TC points to the TeleCommand packet that is being processed
804 * @param queue_id is the id of the queue which handles TM related to this execution step
804 * @param queue_id is the id of the queue which handles TM related to this execution step
805 *
805 *
806 */
806 */
807
807
808 int status;
808 int status;
809
809
810 status = LFR_SUCCESSFUL;
810 status = LFR_SUCCESSFUL;
811
811
812 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
812 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
813
813
814 return status;
814 return status;
815 }
815 }
816
816
817 //*********************
817 //*********************
818 // SBM1 MODE PARAMETERS
818 // SBM1 MODE PARAMETERS
819 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
819 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
820 {
820 {
821 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
821 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
822 *
822 *
823 * @param TC points to the TeleCommand packet that is being processed
823 * @param TC points to the TeleCommand packet that is being processed
824 * @param queue_id is the id of the queue which handles TM related to this execution step
824 * @param queue_id is the id of the queue which handles TM related to this execution step
825 *
825 *
826 */
826 */
827
827
828 int status;
828 int status;
829
829
830 status = LFR_SUCCESSFUL;
830 status = LFR_SUCCESSFUL;
831
831
832 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
832 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
833
833
834 return status;
834 return status;
835 }
835 }
836
836
837 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
837 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
838 {
838 {
839 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
839 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
840 *
840 *
841 * @param TC points to the TeleCommand packet that is being processed
841 * @param TC points to the TeleCommand packet that is being processed
842 * @param queue_id is the id of the queue which handles TM related to this execution step
842 * @param queue_id is the id of the queue which handles TM related to this execution step
843 *
843 *
844 */
844 */
845
845
846 int status;
846 int status;
847
847
848 status = LFR_SUCCESSFUL;
848 status = LFR_SUCCESSFUL;
849
849
850 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
850 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
851
851
852 return status;
852 return status;
853 }
853 }
854
854
855 //*********************
855 //*********************
856 // SBM2 MODE PARAMETERS
856 // SBM2 MODE PARAMETERS
857 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
857 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
858 {
858 {
859 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
859 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
860 *
860 *
861 * @param TC points to the TeleCommand packet that is being processed
861 * @param TC points to the TeleCommand packet that is being processed
862 * @param queue_id is the id of the queue which handles TM related to this execution step
862 * @param queue_id is the id of the queue which handles TM related to this execution step
863 *
863 *
864 */
864 */
865
865
866 int status;
866 int status;
867
867
868 status = LFR_SUCCESSFUL;
868 status = LFR_SUCCESSFUL;
869
869
870 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
870 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
871
871
872 return status;
872 return status;
873 }
873 }
874
874
875 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
875 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
876 {
876 {
877 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
877 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
878 *
878 *
879 * @param TC points to the TeleCommand packet that is being processed
879 * @param TC points to the TeleCommand packet that is being processed
880 * @param queue_id is the id of the queue which handles TM related to this execution step
880 * @param queue_id is the id of the queue which handles TM related to this execution step
881 *
881 *
882 */
882 */
883
883
884 int status;
884 int status;
885
885
886 status = LFR_SUCCESSFUL;
886 status = LFR_SUCCESSFUL;
887
887
888 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
888 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
889
889
890 return status;
890 return status;
891 }
891 }
892
892
893 //*******************
893 //*******************
894 // TC_LFR_UPDATE_INFO
894 // TC_LFR_UPDATE_INFO
895 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
895 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
896 {
896 {
897 unsigned int status;
897 unsigned int status;
898
898
899 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
899 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
900 || (mode == LFR_MODE_BURST)
900 || (mode == LFR_MODE_BURST)
901 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
901 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
902 {
902 {
903 status = LFR_SUCCESSFUL;
903 status = LFR_SUCCESSFUL;
904 }
904 }
905 else
905 else
906 {
906 {
907 status = LFR_DEFAULT;
907 status = LFR_DEFAULT;
908 }
908 }
909
909
910 return status;
910 return status;
911 }
911 }
912
912
913 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
913 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
914 {
914 {
915 unsigned int status;
915 unsigned int status;
916
916
917 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
917 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
918 || (mode == TDS_MODE_BURST)
918 || (mode == TDS_MODE_BURST)
919 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
919 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
920 || (mode == TDS_MODE_LFM))
920 || (mode == TDS_MODE_LFM))
921 {
921 {
922 status = LFR_SUCCESSFUL;
922 status = LFR_SUCCESSFUL;
923 }
923 }
924 else
924 else
925 {
925 {
926 status = LFR_DEFAULT;
926 status = LFR_DEFAULT;
927 }
927 }
928
928
929 return status;
929 return status;
930 }
930 }
931
931
932 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
932 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
933 {
933 {
934 unsigned int status;
934 unsigned int status;
935
935
936 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
936 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
937 || (mode == THR_MODE_BURST))
937 || (mode == THR_MODE_BURST))
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 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value )
949 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value )
950 {
950 {
951 unsigned char flag;
951 unsigned char flag;
952 unsigned char flagPosInByte;
952 unsigned char flagPosInByte;
953 unsigned char newFlag;
953 unsigned char newFlag;
954 unsigned char flagMask;
954 unsigned char flagMask;
955
955
956 // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered
956 // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered
957 if (isnan(value))
957 if (isnan(value))
958 {
958 {
959 flag = 0;
959 flag = 0;
960 }
960 }
961 else
961 else
962 {
962 {
963 flag = 1;
963 flag = 1;
964 }
964 }
965
965
966 switch(wheel)
966 switch(wheel)
967 {
967 {
968 case 1:
968 case 1:
969 flagPosInByte = 8 - freq;
969 flagPosInByte = 8 - freq;
970 flagMask = ~(1 << flagPosInByte);
970 flagMask = ~(1 << flagPosInByte);
971 newFlag = flag << flagPosInByte;
971 newFlag = flag << flagPosInByte;
972 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
972 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
973 break;
973 break;
974 case 2:
974 case 2:
975 flagPosInByte = 4 - freq;
975 flagPosInByte = 4 - freq;
976 flagMask = ~(1 << flagPosInByte);
976 flagMask = ~(1 << flagPosInByte);
977 newFlag = flag << flagPosInByte;
977 newFlag = flag << flagPosInByte;
978 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
978 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
979 break;
979 break;
980 case 3:
980 case 3:
981 flagPosInByte = 8 - freq;
981 flagPosInByte = 8 - freq;
982 flagMask = ~(1 << flagPosInByte);
982 flagMask = ~(1 << flagPosInByte);
983 newFlag = flag << flagPosInByte;
983 newFlag = flag << flagPosInByte;
984 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
984 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
985 break;
985 break;
986 case 4:
986 case 4:
987 flagPosInByte = 4 - freq;
987 flagPosInByte = 4 - freq;
988 flagMask = ~(1 << flagPosInByte);
988 flagMask = ~(1 << flagPosInByte);
989 newFlag = flag << flagPosInByte;
989 newFlag = flag << flagPosInByte;
990 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
990 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
991 break;
991 break;
992 default:
992 default:
993 break;
993 break;
994 }
994 }
995 }
995 }
996
996
997 void set_hk_lfr_sc_rw_f_flags( void )
997 void set_hk_lfr_sc_rw_f_flags( void )
998 {
998 {
999 // RW1
999 // RW1
1000 set_hk_lfr_sc_rw_f_flag( 1, 1, rw_f.cp_rpw_sc_rw1_f1 );
1000 set_hk_lfr_sc_rw_f_flag( 1, 1, rw_f.cp_rpw_sc_rw1_f1 );
1001 set_hk_lfr_sc_rw_f_flag( 1, 2, rw_f.cp_rpw_sc_rw1_f2 );
1001 set_hk_lfr_sc_rw_f_flag( 1, 2, rw_f.cp_rpw_sc_rw1_f2 );
1002 set_hk_lfr_sc_rw_f_flag( 1, 3, rw_f.cp_rpw_sc_rw1_f3 );
1002 set_hk_lfr_sc_rw_f_flag( 1, 3, rw_f.cp_rpw_sc_rw1_f3 );
1003 set_hk_lfr_sc_rw_f_flag( 1, 4, rw_f.cp_rpw_sc_rw1_f4 );
1003 set_hk_lfr_sc_rw_f_flag( 1, 4, rw_f.cp_rpw_sc_rw1_f4 );
1004
1004
1005 // RW2
1005 // RW2
1006 set_hk_lfr_sc_rw_f_flag( 2, 1, rw_f.cp_rpw_sc_rw2_f1 );
1006 set_hk_lfr_sc_rw_f_flag( 2, 1, rw_f.cp_rpw_sc_rw2_f1 );
1007 set_hk_lfr_sc_rw_f_flag( 2, 2, rw_f.cp_rpw_sc_rw2_f2 );
1007 set_hk_lfr_sc_rw_f_flag( 2, 2, rw_f.cp_rpw_sc_rw2_f2 );
1008 set_hk_lfr_sc_rw_f_flag( 2, 3, rw_f.cp_rpw_sc_rw2_f3 );
1008 set_hk_lfr_sc_rw_f_flag( 2, 3, rw_f.cp_rpw_sc_rw2_f3 );
1009 set_hk_lfr_sc_rw_f_flag( 2, 4, rw_f.cp_rpw_sc_rw2_f4 );
1009 set_hk_lfr_sc_rw_f_flag( 2, 4, rw_f.cp_rpw_sc_rw2_f4 );
1010
1010
1011 // RW3
1011 // RW3
1012 set_hk_lfr_sc_rw_f_flag( 3, 1, rw_f.cp_rpw_sc_rw3_f1 );
1012 set_hk_lfr_sc_rw_f_flag( 3, 1, rw_f.cp_rpw_sc_rw3_f1 );
1013 set_hk_lfr_sc_rw_f_flag( 3, 2, rw_f.cp_rpw_sc_rw3_f2 );
1013 set_hk_lfr_sc_rw_f_flag( 3, 2, rw_f.cp_rpw_sc_rw3_f2 );
1014 set_hk_lfr_sc_rw_f_flag( 3, 3, rw_f.cp_rpw_sc_rw3_f3 );
1014 set_hk_lfr_sc_rw_f_flag( 3, 3, rw_f.cp_rpw_sc_rw3_f3 );
1015 set_hk_lfr_sc_rw_f_flag( 3, 4, rw_f.cp_rpw_sc_rw3_f4 );
1015 set_hk_lfr_sc_rw_f_flag( 3, 4, rw_f.cp_rpw_sc_rw3_f4 );
1016
1016
1017 // RW4
1017 // RW4
1018 set_hk_lfr_sc_rw_f_flag( 4, 1, rw_f.cp_rpw_sc_rw4_f1 );
1018 set_hk_lfr_sc_rw_f_flag( 4, 1, rw_f.cp_rpw_sc_rw4_f1 );
1019 set_hk_lfr_sc_rw_f_flag( 4, 2, rw_f.cp_rpw_sc_rw4_f2 );
1019 set_hk_lfr_sc_rw_f_flag( 4, 2, rw_f.cp_rpw_sc_rw4_f2 );
1020 set_hk_lfr_sc_rw_f_flag( 4, 3, rw_f.cp_rpw_sc_rw4_f3 );
1020 set_hk_lfr_sc_rw_f_flag( 4, 3, rw_f.cp_rpw_sc_rw4_f3 );
1021 set_hk_lfr_sc_rw_f_flag( 4, 4, rw_f.cp_rpw_sc_rw4_f4 );
1021 set_hk_lfr_sc_rw_f_flag( 4, 4, rw_f.cp_rpw_sc_rw4_f4 );
1022 }
1022 }
1023
1023
1024 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
1024 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
1025 {
1025 {
1026 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
1026 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
1027 *
1027 *
1028 * @param TC points to the TeleCommand packet that is being processed
1028 * @param TC points to the TeleCommand packet that is being processed
1029 *
1029 *
1030 */
1030 */
1031
1031
1032 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
1032 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
1033
1033
1034 bytePosPtr = (unsigned char *) &TC->packetID;
1034 bytePosPtr = (unsigned char *) &TC->packetID;
1035
1035
1036 // rw1_f
1036 // rw1_f
1037 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
1037 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
1038 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
1038 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
1039 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] );
1039 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] );
1040 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] );
1040 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] );
1041
1041
1042 // rw2_f
1042 // rw2_f
1043 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
1043 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
1044 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
1044 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
1045 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] );
1045 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] );
1046 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] );
1046 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] );
1047
1047
1048 // rw3_f
1048 // rw3_f
1049 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
1049 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
1050 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
1050 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
1051 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] );
1051 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] );
1052 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] );
1052 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] );
1053
1053
1054 // rw4_f
1054 // rw4_f
1055 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
1055 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
1056 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
1056 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
1057 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] );
1057 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] );
1058 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] );
1058 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] );
1059
1059
1060 // test each reaction wheel frequency value. NaN means that the frequency is not filtered
1060 // test each reaction wheel frequency value. NaN means that the frequency is not filtered
1061
1061
1062
1062
1063 }
1063 }
1064
1064
1065 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag )
1065 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float k )
1066 {
1066 {
1067 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
1067 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
1068 *
1068 *
1069 * @param fbins_mask
1069 * @param fbins_mask
1070 * @param rw_f is the reaction wheel frequency to filter
1070 * @param rw_f is the reaction wheel frequency to filter
1071 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
1071 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
1072 * @param flag [true] filtering enabled [false] filtering disabled
1072 * @param flag [true] filtering enabled [false] filtering disabled
1073 *
1073 *
1074 * @return void
1074 * @return void
1075 *
1075 *
1076 */
1076 */
1077
1077
1078 float f_RW_min;
1078 float f_RW_min;
1079 float f_RW_MAX;
1079 float f_RW_MAX;
1080 float fi_min;
1080 float bandWidth;
1081 float fi_MAX;
1082 float fi;
1083 float deltaBelow;
1084 float deltaAbove;
1085 int binBelow;
1081 int binBelow;
1086 int binAbove;
1082 int binAbove;
1087 int closestBin;
1088 unsigned int whichByte;
1083 unsigned int whichByte;
1089 int selectedByte;
1084 int selectedByte;
1090 int bin;
1085 int bin;
1091 int binToRemove[3];
1086 int binToRemove;
1092 int k;
1093
1094 whichByte = 0;
1095 bin = 0;
1096
1097 binToRemove[0] = -1;
1098 binToRemove[1] = -1;
1099 binToRemove[2] = -1;
1100
1101 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
1102 f_RW_min = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.;
1103 f_RW_MAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.;
1104
1087
1105 // compute the index of the frequency bin immediately below rw_f
1088 f_RW_min = 0.0;
1106 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1089 f_RW_MAX = 0.0;
1107 deltaBelow = rw_f - binBelow * deltaFreq;
1090 bandWidth = 0.0;
1108
1091 binBelow = -1;
1109 // compute the index of the frequency bin immediately above rw_f
1092 binAbove = -1;
1110 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1093 whichByte = 0;
1111 deltaAbove = binAbove * deltaFreq - rw_f;
1094 selectedByte = -1;
1112
1095 bin = -1;
1113 // search the closest bin
1096 binToRemove = -1;
1114 if (deltaAbove > deltaBelow)
1115 {
1116 closestBin = binBelow;
1117 }
1118 else
1119 {
1120 closestBin = binAbove;
1121 }
1122
1123 // compute the fi interval [fi - Delta_f * 0.285, fi + Delta_f * 0.285]
1124 fi = closestBin * deltaFreq;
1125
1097
1126 fi_min = fi - (deltaFreq * 0.285);
1098 if (!isnan(rw_f))
1127 if ( fi_min < 0 )
1128 {
1129 fi_min = 0;
1130 }
1131 else if ( fi_min > (deltaFreq*127) )
1132 {
1133 fi_min = -1;
1134 }
1135
1136 fi_MAX = fi + (deltaFreq * 0.285);
1137 if ( fi_MAX > (deltaFreq*127) )
1138 {
1139 fi_MAX = -1;
1140 }
1141
1142 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1143 // => remove f_(i), f_(i-1) and f_(i+1)
1144 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1145 {
1099 {
1146 binToRemove[0] = closestBin - 1;
1100 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
1147 binToRemove[1] = closestBin;
1101 bandWidth = filterPar.sy_lfr_sc_rw_delta_f * k;
1148 binToRemove[2] = closestBin + 1;
1102 f_RW_min = rw_f - bandWidth / 2.;
1149 }
1103 f_RW_MAX = rw_f + bandWidth / 2.;
1150 // 2. ELSE
1151 // => remove the two f_(i) which are around f_RW
1152 else
1153 {
1154 binToRemove[0] = binBelow;
1155 binToRemove[1] = binAbove;
1156 binToRemove[2] = -1;
1157 }
1158
1104
1159 for (k = 0; k <= 3; k++)
1105 // compute the index of the frequency bin immediately below f_RW_min
1160 {
1106 binBelow = (int) ( floor( ((double) f_RW_min) / ((double) deltaFreq)) );
1161 bin = binToRemove[k];
1107 if (binBelow < 0)
1162 if ( (bin >= 0) && (bin <= 127) )
1163 {
1108 {
1164 if (flag == 1)
1109 binBelow = -1;
1110 }
1111
1112 // compute the index of the frequency bin immediately above f_RW_MAX
1113 binAbove = (int) ( ceil( ((double) f_RW_MAX) / ((double) deltaFreq)) );
1114 if (binAbove > 127)
1115 {
1116 binAbove = 128;
1117 }
1118
1119 for (binToRemove = binBelow; binToRemove <= binAbove; binToRemove++)
1120 {
1121 if ( (binToRemove >= 0) && (binToRemove <= 127) )
1165 {
1122 {
1166 whichByte = (bin >> 3); // division by 8
1123 whichByte = (bin >> 3); // division by 8
1167 selectedByte = ( 1 << (bin - (whichByte * 8)) );
1124 selectedByte = ( 1 << (bin - (whichByte * 8)) );
1168 fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1125 fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1169 }
1126 }
1170 }
1127 }
1171 }
1128 }
1129
1172 }
1130 }
1173
1131
1174 void build_sy_lfr_rw_mask( unsigned int channel )
1132 void build_sy_lfr_rw_mask( unsigned int channel )
1175 {
1133 {
1176 unsigned char local_rw_fbins_mask[16];
1134 unsigned char local_rw_fbins_mask[16];
1177 unsigned char *maskPtr;
1135 unsigned char *maskPtr;
1178 double deltaF;
1136 double deltaF;
1179 unsigned k;
1137 unsigned k;
1180
1138
1181 k = 0;
1139 k = 0;
1182
1140
1183 maskPtr = NULL;
1141 maskPtr = NULL;
1184 deltaF = 1.;
1142 deltaF = 1.;
1185
1143
1186 switch (channel)
1144 switch (channel)
1187 {
1145 {
1188 case 0:
1146 case 0:
1189 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1147 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1190 deltaF = 96.;
1148 deltaF = 96.;
1191 break;
1149 break;
1192 case 1:
1150 case 1:
1193 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1151 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1194 deltaF = 16.;
1152 deltaF = 16.;
1195 break;
1153 break;
1196 case 2:
1154 case 2:
1197 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1155 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1198 deltaF = 1.;
1156 deltaF = 1.;
1199 break;
1157 break;
1200 default:
1158 default:
1201 break;
1159 break;
1202 }
1160 }
1203
1161
1204 for (k = 0; k < 16; k++)
1162 for (k = 0; k < 16; k++)
1205 {
1163 {
1206 local_rw_fbins_mask[k] = 0xff;
1164 local_rw_fbins_mask[k] = 0xff;
1207 }
1165 }
1208
1166
1209 // RW1
1167 // RW1
1210 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x80) >> 7 ); // [1000 0000]
1168 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 );
1211 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x40) >> 6 ); // [0100 0000]
1169 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 );
1212 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x20) >> 5 ); // [0010 0000]
1170 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 );
1213 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x10) >> 4 ); // [0001 0000]
1171 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 );
1214
1172
1215 // RW2
1173 // RW2
1216 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x08) >> 3 ); // [0000 1000]
1174 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 );
1217 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x04) >> 2 ); // [0000 0100]
1175 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 );
1218 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x02) >> 1 ); // [0000 0010]
1176 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 );
1219 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x01) ); // [0000 0001]
1177 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 );
1220
1178
1221 // RW3
1179 // RW3
1222 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x80) >> 7 ); // [1000 0000]
1180 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 );
1223 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x40) >> 6 ); // [0100 0000]
1181 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 );
1224 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x20) >> 5 ); // [0010 0000]
1182 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 );
1225 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x10) >> 4 ); // [0001 0000]
1183 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 );
1226
1184
1227 // RW4
1185 // RW4
1228 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x08) >> 3 ); // [0000 1000]
1186 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 );
1229 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x04) >> 2 ); // [0000 0100]
1187 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 );
1230 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x02) >> 1 ); // [0000 0010]
1188 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 );
1231 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x03) ); // [0000 0001]
1189 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 );
1232
1190
1233 // update the value of the fbins related to reaction wheels frequency filtering
1191 // update the value of the fbins related to reaction wheels frequency filtering
1234 if (maskPtr != NULL)
1192 if (maskPtr != NULL)
1235 {
1193 {
1236 for (k = 0; k < 16; k++)
1194 for (k = 0; k < 16; k++)
1237 {
1195 {
1238 maskPtr[k] = local_rw_fbins_mask[k];
1196 maskPtr[k] = local_rw_fbins_mask[k];
1239 }
1197 }
1240 }
1198 }
1241 }
1199 }
1242
1200
1243 void build_sy_lfr_rw_masks( void )
1201 void build_sy_lfr_rw_masks( void )
1244 {
1202 {
1245 build_sy_lfr_rw_mask( 0 );
1203 build_sy_lfr_rw_mask( 0 );
1246 build_sy_lfr_rw_mask( 1 );
1204 build_sy_lfr_rw_mask( 1 );
1247 build_sy_lfr_rw_mask( 2 );
1205 build_sy_lfr_rw_mask( 2 );
1248
1206
1249 merge_fbins_masks();
1207 merge_fbins_masks();
1250 }
1208 }
1251
1209
1252 void merge_fbins_masks( void )
1210 void merge_fbins_masks( void )
1253 {
1211 {
1254 unsigned char k;
1212 unsigned char k;
1255
1213
1256 unsigned char *fbins_f0;
1214 unsigned char *fbins_f0;
1257 unsigned char *fbins_f1;
1215 unsigned char *fbins_f1;
1258 unsigned char *fbins_f2;
1216 unsigned char *fbins_f2;
1259 unsigned char *rw_mask_f0;
1217 unsigned char *rw_mask_f0;
1260 unsigned char *rw_mask_f1;
1218 unsigned char *rw_mask_f1;
1261 unsigned char *rw_mask_f2;
1219 unsigned char *rw_mask_f2;
1262
1220
1263 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1221 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1264 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1222 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1265 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1223 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1266 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1224 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1267 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1225 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1268 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1226 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1269
1227
1270 for( k=0; k < 16; k++ )
1228 for( k=0; k < 16; k++ )
1271 {
1229 {
1272 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1230 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1273 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1231 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1274 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1232 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1275 }
1233 }
1276 }
1234 }
1277
1235
1278 //***********
1236 //***********
1279 // FBINS MASK
1237 // FBINS MASK
1280
1238
1281 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1239 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1282 {
1240 {
1283 int status;
1241 int status;
1284 unsigned int k;
1242 unsigned int k;
1285 unsigned char *fbins_mask_dump;
1243 unsigned char *fbins_mask_dump;
1286 unsigned char *fbins_mask_TC;
1244 unsigned char *fbins_mask_TC;
1287
1245
1288 status = LFR_SUCCESSFUL;
1246 status = LFR_SUCCESSFUL;
1289
1247
1290 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1248 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1291 fbins_mask_TC = TC->dataAndCRC;
1249 fbins_mask_TC = TC->dataAndCRC;
1292
1250
1293 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1251 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1294 {
1252 {
1295 fbins_mask_dump[k] = fbins_mask_TC[k];
1253 fbins_mask_dump[k] = fbins_mask_TC[k];
1296 }
1254 }
1297
1255
1298 return status;
1256 return status;
1299 }
1257 }
1300
1258
1301 //***************************
1259 //***************************
1302 // TC_LFR_LOAD_PAS_FILTER_PAR
1260 // TC_LFR_LOAD_PAS_FILTER_PAR
1303
1261
1304 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1262 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1305 {
1263 {
1306 int flag;
1264 int flag;
1307 rtems_status_code status;
1265 rtems_status_code status;
1308
1266
1309 unsigned char sy_lfr_pas_filter_enabled;
1267 unsigned char sy_lfr_pas_filter_enabled;
1310 unsigned char sy_lfr_pas_filter_modulus;
1268 unsigned char sy_lfr_pas_filter_modulus;
1311 float sy_lfr_pas_filter_tbad;
1269 float sy_lfr_pas_filter_tbad;
1312 unsigned char sy_lfr_pas_filter_offset;
1270 unsigned char sy_lfr_pas_filter_offset;
1313 float sy_lfr_pas_filter_shift;
1271 float sy_lfr_pas_filter_shift;
1314 float sy_lfr_sc_rw_delta_f;
1272 float sy_lfr_sc_rw_delta_f;
1315 char *parPtr;
1273 char *parPtr;
1316
1274
1317 flag = LFR_SUCCESSFUL;
1275 flag = LFR_SUCCESSFUL;
1318 sy_lfr_pas_filter_tbad = 0.0;
1276 sy_lfr_pas_filter_tbad = 0.0;
1319 sy_lfr_pas_filter_shift = 0.0;
1277 sy_lfr_pas_filter_shift = 0.0;
1320 sy_lfr_sc_rw_delta_f = 0.0;
1278 sy_lfr_sc_rw_delta_f = 0.0;
1321 parPtr = NULL;
1279 parPtr = NULL;
1322
1280
1323 //***************
1281 //***************
1324 // get parameters
1282 // get parameters
1325 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1283 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1326 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1284 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1327 copyFloatByChar(
1285 copyFloatByChar(
1328 (unsigned char*) &sy_lfr_pas_filter_tbad,
1286 (unsigned char*) &sy_lfr_pas_filter_tbad,
1329 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1287 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1330 );
1288 );
1331 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1289 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1332 copyFloatByChar(
1290 copyFloatByChar(
1333 (unsigned char*) &sy_lfr_pas_filter_shift,
1291 (unsigned char*) &sy_lfr_pas_filter_shift,
1334 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1292 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1335 );
1293 );
1336 copyFloatByChar(
1294 copyFloatByChar(
1337 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1295 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1338 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1296 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1339 );
1297 );
1340
1298
1341 //******************
1299 //******************
1342 // CHECK CONSISTENCY
1300 // CHECK CONSISTENCY
1343
1301
1344 //**************************
1302 //**************************
1345 // sy_lfr_pas_filter_enabled
1303 // sy_lfr_pas_filter_enabled
1346 // nothing to check, value is 0 or 1
1304 // nothing to check, value is 0 or 1
1347
1305
1348 //**************************
1306 //**************************
1349 // sy_lfr_pas_filter_modulus
1307 // sy_lfr_pas_filter_modulus
1350 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1308 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1351 {
1309 {
1352 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1310 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1353 flag = WRONG_APP_DATA;
1311 flag = WRONG_APP_DATA;
1354 }
1312 }
1355
1313
1356 //***********************
1314 //***********************
1357 // sy_lfr_pas_filter_tbad
1315 // sy_lfr_pas_filter_tbad
1358 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1316 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1359 {
1317 {
1360 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1318 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1361 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1319 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1362 flag = WRONG_APP_DATA;
1320 flag = WRONG_APP_DATA;
1363 }
1321 }
1364
1322
1365 //*************************
1323 //*************************
1366 // sy_lfr_pas_filter_offset
1324 // sy_lfr_pas_filter_offset
1367 if (flag == LFR_SUCCESSFUL)
1325 if (flag == LFR_SUCCESSFUL)
1368 {
1326 {
1369 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1327 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1370 {
1328 {
1371 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1329 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1372 flag = WRONG_APP_DATA;
1330 flag = WRONG_APP_DATA;
1373 }
1331 }
1374 }
1332 }
1375
1333
1376 //************************
1334 //************************
1377 // sy_lfr_pas_filter_shift
1335 // sy_lfr_pas_filter_shift
1378 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1336 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1379 {
1337 {
1380 parPtr = (char*) &sy_lfr_pas_filter_shift;
1338 parPtr = (char*) &sy_lfr_pas_filter_shift;
1381 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1339 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1382 flag = WRONG_APP_DATA;
1340 flag = WRONG_APP_DATA;
1383 }
1341 }
1384
1342
1385 //*********************
1343 //*********************
1386 // sy_lfr_sc_rw_delta_f
1344 // sy_lfr_sc_rw_delta_f
1387 // nothing to check, no default value in the ICD
1345 // nothing to check, no default value in the ICD
1388
1346
1389 return flag;
1347 return flag;
1390 }
1348 }
1391
1349
1392 //**************
1350 //**************
1393 // KCOEFFICIENTS
1351 // KCOEFFICIENTS
1394 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1352 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1395 {
1353 {
1396 unsigned int kcoeff;
1354 unsigned int kcoeff;
1397 unsigned short sy_lfr_kcoeff_frequency;
1355 unsigned short sy_lfr_kcoeff_frequency;
1398 unsigned short bin;
1356 unsigned short bin;
1399 unsigned short *freqPtr;
1357 unsigned short *freqPtr;
1400 float *kcoeffPtr_norm;
1358 float *kcoeffPtr_norm;
1401 float *kcoeffPtr_sbm;
1359 float *kcoeffPtr_sbm;
1402 int status;
1360 int status;
1403 unsigned char *kcoeffLoadPtr;
1361 unsigned char *kcoeffLoadPtr;
1404 unsigned char *kcoeffNormPtr;
1362 unsigned char *kcoeffNormPtr;
1405 unsigned char *kcoeffSbmPtr_a;
1363 unsigned char *kcoeffSbmPtr_a;
1406 unsigned char *kcoeffSbmPtr_b;
1364 unsigned char *kcoeffSbmPtr_b;
1407
1365
1408 status = LFR_SUCCESSFUL;
1366 status = LFR_SUCCESSFUL;
1409
1367
1410 kcoeffPtr_norm = NULL;
1368 kcoeffPtr_norm = NULL;
1411 kcoeffPtr_sbm = NULL;
1369 kcoeffPtr_sbm = NULL;
1412 bin = 0;
1370 bin = 0;
1413
1371
1414 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1372 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1415 sy_lfr_kcoeff_frequency = *freqPtr;
1373 sy_lfr_kcoeff_frequency = *freqPtr;
1416
1374
1417 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1375 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1418 {
1376 {
1419 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1377 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1420 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1378 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1421 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1379 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1422 status = LFR_DEFAULT;
1380 status = LFR_DEFAULT;
1423 }
1381 }
1424 else
1382 else
1425 {
1383 {
1426 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1384 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1427 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1385 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1428 {
1386 {
1429 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1387 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1430 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1388 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1431 bin = sy_lfr_kcoeff_frequency;
1389 bin = sy_lfr_kcoeff_frequency;
1432 }
1390 }
1433 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1391 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1434 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1392 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1435 {
1393 {
1436 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1394 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1437 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1395 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1438 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1396 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1439 }
1397 }
1440 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1398 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1441 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1399 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1442 {
1400 {
1443 kcoeffPtr_norm = k_coeff_intercalib_f2;
1401 kcoeffPtr_norm = k_coeff_intercalib_f2;
1444 kcoeffPtr_sbm = NULL;
1402 kcoeffPtr_sbm = NULL;
1445 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1403 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1446 }
1404 }
1447 }
1405 }
1448
1406
1449 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1407 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1450 {
1408 {
1451 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1409 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1452 {
1410 {
1453 // destination
1411 // destination
1454 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1412 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1455 // source
1413 // source
1456 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1414 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1457 // copy source to destination
1415 // copy source to destination
1458 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1416 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1459 }
1417 }
1460 }
1418 }
1461
1419
1462 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1420 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1463 {
1421 {
1464 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1422 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1465 {
1423 {
1466 // destination
1424 // destination
1467 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1425 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1468 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1426 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1469 // source
1427 // source
1470 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1428 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1471 // copy source to destination
1429 // copy source to destination
1472 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1430 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1473 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1431 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1474 }
1432 }
1475 }
1433 }
1476
1434
1477 // print_k_coeff();
1435 // print_k_coeff();
1478
1436
1479 return status;
1437 return status;
1480 }
1438 }
1481
1439
1482 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1440 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1483 {
1441 {
1484 destination[0] = source[0];
1442 destination[0] = source[0];
1485 destination[1] = source[1];
1443 destination[1] = source[1];
1486 destination[2] = source[2];
1444 destination[2] = source[2];
1487 destination[3] = source[3];
1445 destination[3] = source[3];
1488 }
1446 }
1489
1447
1490 void floatToChar( float value, unsigned char* ptr)
1448 void floatToChar( float value, unsigned char* ptr)
1491 {
1449 {
1492 unsigned char* valuePtr;
1450 unsigned char* valuePtr;
1493
1451
1494 valuePtr = (unsigned char*) &value;
1452 valuePtr = (unsigned char*) &value;
1495 ptr[0] = valuePtr[0];
1453 ptr[0] = valuePtr[0];
1496 ptr[1] = valuePtr[0];
1454 ptr[1] = valuePtr[0];
1497 ptr[2] = valuePtr[0];
1455 ptr[2] = valuePtr[0];
1498 ptr[3] = valuePtr[0];
1456 ptr[3] = valuePtr[0];
1499 }
1457 }
1500
1458
1501 //**********
1459 //**********
1502 // init dump
1460 // init dump
1503
1461
1504 void init_parameter_dump( void )
1462 void init_parameter_dump( void )
1505 {
1463 {
1506 /** This function initialize the parameter_dump_packet global variable with default values.
1464 /** This function initialize the parameter_dump_packet global variable with default values.
1507 *
1465 *
1508 */
1466 */
1509
1467
1510 unsigned int k;
1468 unsigned int k;
1511
1469
1512 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1470 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1513 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1471 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1514 parameter_dump_packet.reserved = CCSDS_RESERVED;
1472 parameter_dump_packet.reserved = CCSDS_RESERVED;
1515 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1473 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1516 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1474 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1517 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1475 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1518 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1476 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1519 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1477 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1520 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1478 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1521 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1479 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1522 // DATA FIELD HEADER
1480 // DATA FIELD HEADER
1523 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1481 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1524 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1482 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1525 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1483 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1526 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1484 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1527 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1485 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1528 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1486 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1529 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1487 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1530 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1488 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1531 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1489 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1532 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1490 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1533 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1491 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1534
1492
1535 //******************
1493 //******************
1536 // COMMON PARAMETERS
1494 // COMMON PARAMETERS
1537 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1495 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1538 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1496 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1539
1497
1540 //******************
1498 //******************
1541 // NORMAL PARAMETERS
1499 // NORMAL PARAMETERS
1542 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1500 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1543 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1501 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1544 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1502 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1545 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1503 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1546 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1504 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1547 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1505 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1548 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1506 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1549 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1507 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1550 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1508 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1551
1509
1552 //*****************
1510 //*****************
1553 // BURST PARAMETERS
1511 // BURST PARAMETERS
1554 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1512 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1555 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1513 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1556
1514
1557 //****************
1515 //****************
1558 // SBM1 PARAMETERS
1516 // SBM1 PARAMETERS
1559 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
1517 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
1560 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1518 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1561
1519
1562 //****************
1520 //****************
1563 // SBM2 PARAMETERS
1521 // SBM2 PARAMETERS
1564 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1522 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1565 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1523 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1566
1524
1567 //************
1525 //************
1568 // FBINS MASKS
1526 // FBINS MASKS
1569 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1527 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1570 {
1528 {
1571 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1529 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1572 }
1530 }
1573
1531
1574 //******************
1532 //******************
1575 // FILTER PARAMETERS
1533 // FILTER PARAMETERS
1576 parameter_dump_packet.pa_rpw_spare8_2 = 0x00;
1534 parameter_dump_packet.pa_rpw_spare8_2 = 0x00;
1577 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00;
1535 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00;
1578 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1536 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1579 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1537 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1580 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1538 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1581 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1539 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1582 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1540 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1583
1541
1584 // RW1_K
1542 // RW1_K
1585 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1);
1543 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1);
1586 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2);
1544 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2);
1587 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3);
1545 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3);
1588 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4);
1546 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4);
1589 // RW2_K
1547 // RW2_K
1590 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1);
1548 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1);
1591 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2);
1549 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2);
1592 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3);
1550 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3);
1593 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4);
1551 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4);
1594 // RW3_K
1552 // RW3_K
1595 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1);
1553 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1);
1596 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2);
1554 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2);
1597 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3);
1555 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3);
1598 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4);
1556 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4);
1599 // RW4_K
1557 // RW4_K
1600 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1);
1558 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1);
1601 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2);
1559 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2);
1602 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3);
1560 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3);
1603 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4);
1561 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4);
1604
1562
1605 // LFR_RW_MASK
1563 // LFR_RW_MASK
1606 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1564 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1607 {
1565 {
1608 parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = 0xff;
1566 parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = 0xff;
1609 }
1567 }
1610 }
1568 }
1611
1569
1612 void init_kcoefficients_dump( void )
1570 void init_kcoefficients_dump( void )
1613 {
1571 {
1614 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1572 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1615 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1573 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1616
1574
1617 kcoefficient_node_1.previous = NULL;
1575 kcoefficient_node_1.previous = NULL;
1618 kcoefficient_node_1.next = NULL;
1576 kcoefficient_node_1.next = NULL;
1619 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1577 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1620 kcoefficient_node_1.coarseTime = 0x00;
1578 kcoefficient_node_1.coarseTime = 0x00;
1621 kcoefficient_node_1.fineTime = 0x00;
1579 kcoefficient_node_1.fineTime = 0x00;
1622 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1580 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1623 kcoefficient_node_1.status = 0x00;
1581 kcoefficient_node_1.status = 0x00;
1624
1582
1625 kcoefficient_node_2.previous = NULL;
1583 kcoefficient_node_2.previous = NULL;
1626 kcoefficient_node_2.next = NULL;
1584 kcoefficient_node_2.next = NULL;
1627 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1585 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1628 kcoefficient_node_2.coarseTime = 0x00;
1586 kcoefficient_node_2.coarseTime = 0x00;
1629 kcoefficient_node_2.fineTime = 0x00;
1587 kcoefficient_node_2.fineTime = 0x00;
1630 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1588 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1631 kcoefficient_node_2.status = 0x00;
1589 kcoefficient_node_2.status = 0x00;
1632 }
1590 }
1633
1591
1634 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1592 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1635 {
1593 {
1636 unsigned int k;
1594 unsigned int k;
1637 unsigned int packetLength;
1595 unsigned int packetLength;
1638
1596
1639 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1597 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1640
1598
1641 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1599 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1642 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1600 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1643 kcoefficients_dump->reserved = CCSDS_RESERVED;
1601 kcoefficients_dump->reserved = CCSDS_RESERVED;
1644 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1602 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1645 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1603 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1646 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1604 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1647 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1605 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1648 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1606 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1649 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1607 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1650 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1608 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1651 // DATA FIELD HEADER
1609 // DATA FIELD HEADER
1652 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1610 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1653 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1611 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1654 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1612 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1655 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1613 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1656 kcoefficients_dump->time[0] = 0x00;
1614 kcoefficients_dump->time[0] = 0x00;
1657 kcoefficients_dump->time[1] = 0x00;
1615 kcoefficients_dump->time[1] = 0x00;
1658 kcoefficients_dump->time[2] = 0x00;
1616 kcoefficients_dump->time[2] = 0x00;
1659 kcoefficients_dump->time[3] = 0x00;
1617 kcoefficients_dump->time[3] = 0x00;
1660 kcoefficients_dump->time[4] = 0x00;
1618 kcoefficients_dump->time[4] = 0x00;
1661 kcoefficients_dump->time[5] = 0x00;
1619 kcoefficients_dump->time[5] = 0x00;
1662 kcoefficients_dump->sid = SID_K_DUMP;
1620 kcoefficients_dump->sid = SID_K_DUMP;
1663
1621
1664 kcoefficients_dump->pkt_cnt = 2;
1622 kcoefficients_dump->pkt_cnt = 2;
1665 kcoefficients_dump->pkt_nr = pkt_nr;
1623 kcoefficients_dump->pkt_nr = pkt_nr;
1666 kcoefficients_dump->blk_nr = blk_nr;
1624 kcoefficients_dump->blk_nr = blk_nr;
1667
1625
1668 //******************
1626 //******************
1669 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1627 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1670 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1628 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1671 for (k=0; k<3900; k++)
1629 for (k=0; k<3900; k++)
1672 {
1630 {
1673 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1631 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1674 }
1632 }
1675 }
1633 }
1676
1634
1677 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1635 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1678 {
1636 {
1679 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1637 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1680 *
1638 *
1681 * @param packet_sequence_control points to the packet sequence control which will be incremented
1639 * @param packet_sequence_control points to the packet sequence control which will be incremented
1682 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1640 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1683 *
1641 *
1684 * If the destination ID is not known, a dedicated counter is incremented.
1642 * If the destination ID is not known, a dedicated counter is incremented.
1685 *
1643 *
1686 */
1644 */
1687
1645
1688 unsigned short sequence_cnt;
1646 unsigned short sequence_cnt;
1689 unsigned short segmentation_grouping_flag;
1647 unsigned short segmentation_grouping_flag;
1690 unsigned short new_packet_sequence_control;
1648 unsigned short new_packet_sequence_control;
1691 unsigned char i;
1649 unsigned char i;
1692
1650
1693 switch (destination_id)
1651 switch (destination_id)
1694 {
1652 {
1695 case SID_TC_GROUND:
1653 case SID_TC_GROUND:
1696 i = GROUND;
1654 i = GROUND;
1697 break;
1655 break;
1698 case SID_TC_MISSION_TIMELINE:
1656 case SID_TC_MISSION_TIMELINE:
1699 i = MISSION_TIMELINE;
1657 i = MISSION_TIMELINE;
1700 break;
1658 break;
1701 case SID_TC_TC_SEQUENCES:
1659 case SID_TC_TC_SEQUENCES:
1702 i = TC_SEQUENCES;
1660 i = TC_SEQUENCES;
1703 break;
1661 break;
1704 case SID_TC_RECOVERY_ACTION_CMD:
1662 case SID_TC_RECOVERY_ACTION_CMD:
1705 i = RECOVERY_ACTION_CMD;
1663 i = RECOVERY_ACTION_CMD;
1706 break;
1664 break;
1707 case SID_TC_BACKUP_MISSION_TIMELINE:
1665 case SID_TC_BACKUP_MISSION_TIMELINE:
1708 i = BACKUP_MISSION_TIMELINE;
1666 i = BACKUP_MISSION_TIMELINE;
1709 break;
1667 break;
1710 case SID_TC_DIRECT_CMD:
1668 case SID_TC_DIRECT_CMD:
1711 i = DIRECT_CMD;
1669 i = DIRECT_CMD;
1712 break;
1670 break;
1713 case SID_TC_SPARE_GRD_SRC1:
1671 case SID_TC_SPARE_GRD_SRC1:
1714 i = SPARE_GRD_SRC1;
1672 i = SPARE_GRD_SRC1;
1715 break;
1673 break;
1716 case SID_TC_SPARE_GRD_SRC2:
1674 case SID_TC_SPARE_GRD_SRC2:
1717 i = SPARE_GRD_SRC2;
1675 i = SPARE_GRD_SRC2;
1718 break;
1676 break;
1719 case SID_TC_OBCP:
1677 case SID_TC_OBCP:
1720 i = OBCP;
1678 i = OBCP;
1721 break;
1679 break;
1722 case SID_TC_SYSTEM_CONTROL:
1680 case SID_TC_SYSTEM_CONTROL:
1723 i = SYSTEM_CONTROL;
1681 i = SYSTEM_CONTROL;
1724 break;
1682 break;
1725 case SID_TC_AOCS:
1683 case SID_TC_AOCS:
1726 i = AOCS;
1684 i = AOCS;
1727 break;
1685 break;
1728 case SID_TC_RPW_INTERNAL:
1686 case SID_TC_RPW_INTERNAL:
1729 i = RPW_INTERNAL;
1687 i = RPW_INTERNAL;
1730 break;
1688 break;
1731 default:
1689 default:
1732 i = GROUND;
1690 i = GROUND;
1733 break;
1691 break;
1734 }
1692 }
1735
1693
1736 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1694 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1737 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1695 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1738
1696
1739 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1697 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1740
1698
1741 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1699 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1742 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1700 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1743
1701
1744 // increment the sequence counter
1702 // increment the sequence counter
1745 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1703 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1746 {
1704 {
1747 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1705 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1748 }
1706 }
1749 else
1707 else
1750 {
1708 {
1751 sequenceCounters_TM_DUMP[ i ] = 0;
1709 sequenceCounters_TM_DUMP[ i ] = 0;
1752 }
1710 }
1753 }
1711 }
General Comments 0
You need to be logged in to leave comments. Login now