##// END OF EJS Templates
minor updates
paul -
r285:bc5036e4a86c R3_plus draft
parent child
Show More
@@ -1,82 +1,82
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
15
16 extern unsigned short sequenceCounterParameterDump;
16 extern unsigned short sequenceCounterParameterDump;
17 extern unsigned short sequenceCounters_TM_DUMP[];
17 extern unsigned short sequenceCounters_TM_DUMP[];
18 extern float k_coeff_intercalib_f0_norm[ ];
18 extern float k_coeff_intercalib_f0_norm[ ];
19 extern float k_coeff_intercalib_f0_sbm[ ];
19 extern float k_coeff_intercalib_f0_sbm[ ];
20 extern float k_coeff_intercalib_f1_norm[ ];
20 extern float k_coeff_intercalib_f1_norm[ ];
21 extern float k_coeff_intercalib_f1_sbm[ ];
21 extern float k_coeff_intercalib_f1_sbm[ ];
22 extern float k_coeff_intercalib_f2[ ];
22 extern float k_coeff_intercalib_f2[ ];
23 extern unsigned char rw_fbins_mask_f0[16];
23 extern unsigned char rw_fbins_mask_f0[16];
24 extern unsigned char rw_fbins_mask_f1[16];
24 extern unsigned char rw_fbins_mask_f1[16];
25 extern unsigned char rw_fbins_mask_f2[16];
25 extern unsigned char rw_fbins_mask_f2[16];
26
26
27 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
27 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
28 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
28 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
29 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
29 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
30 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
30 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
31 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
31 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
32 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
32 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
33 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
33 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
34 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
34 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
35 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
35 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
36 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
36 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
37
37
38 // NORMAL
38 // NORMAL
39 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
39 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
40 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
40 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
41 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
41 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
42 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
42 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
43 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
43 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
44 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
44 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
45 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
45 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
46
46
47 // BURST
47 // BURST
48 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
48 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
49 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
49 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
50
50
51 // SBM1
51 // SBM1
52 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
52 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
53 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
53 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
54
54
55 // SBM2
55 // SBM2
56 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
56 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
57 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
57 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
58
58
59 // TC_LFR_UPDATE_INFO
59 // TC_LFR_UPDATE_INFO
60 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
60 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
61 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
61 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
62 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
62 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
63 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
63 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
64 void build_rw_fbins_mask( unsigned int channel );
64 void build_rw_fbins_mask( unsigned int channel );
65 void build_rw_fbins_masks();
65 void build_rw_fbins_masks();
66
66
67 // FBINS_MASK
67 // FBINS_MASK
68 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
68 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
69
69
70 // TC_LFR_LOAD_PARS_FILTER_PAR
70 // TC_LFR_LOAD_PARS_FILTER_PAR
71 int check_sy_lfr_pas_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
71 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
72
72
73 // KCOEFFICIENTS
73 // KCOEFFICIENTS
74 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
74 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
75 void copyFloatByChar( unsigned char *destination, unsigned char *source );
75 void copyFloatByChar( unsigned char *destination, unsigned char *source );
76
76
77 void init_parameter_dump( void );
77 void init_parameter_dump( void );
78 void init_kcoefficients_dump( void );
78 void init_kcoefficients_dump( void );
79 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
79 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
80 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
80 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
81
81
82 #endif // TC_LOAD_DUMP_PARAMETERS_H
82 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,1641 +1,1641
1 /** Functions and tasks related to TeleCommand handling.
1 /** Functions and tasks related to TeleCommand handling.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TeleCommands:\n
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
7 * action launching\n
8 * TC parsing\n
8 * TC parsing\n
9 * ...
9 * ...
10 *
10 *
11 */
11 */
12
12
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14 #include "math.h"
14 #include "math.h"
15
15
16 //***********
16 //***********
17 // RTEMS TASK
17 // RTEMS TASK
18
18
19 rtems_task actn_task( rtems_task_argument unused )
19 rtems_task actn_task( rtems_task_argument unused )
20 {
20 {
21 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
22 *
22 *
23 * @param unused is the starting argument of the RTEMS task
23 * @param unused is the starting argument of the RTEMS task
24 *
24 *
25 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
26 * on the incoming TeleCommand.
26 * on the incoming TeleCommand.
27 *
27 *
28 */
28 */
29
29
30 int result;
30 int result;
31 rtems_status_code status; // RTEMS status code
31 rtems_status_code status; // RTEMS status code
32 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
33 size_t size; // size of the incoming TC packet
33 size_t size; // size of the incoming TC packet
34 unsigned char subtype; // subtype of the current TC packet
34 unsigned char subtype; // subtype of the current TC packet
35 unsigned char time[6];
35 unsigned char time[6];
36 rtems_id queue_rcv_id;
36 rtems_id queue_rcv_id;
37 rtems_id queue_snd_id;
37 rtems_id queue_snd_id;
38
38
39 status = get_message_queue_id_recv( &queue_rcv_id );
39 status = get_message_queue_id_recv( &queue_rcv_id );
40 if (status != RTEMS_SUCCESSFUL)
40 if (status != RTEMS_SUCCESSFUL)
41 {
41 {
42 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
43 }
43 }
44
44
45 status = get_message_queue_id_send( &queue_snd_id );
45 status = get_message_queue_id_send( &queue_snd_id );
46 if (status != RTEMS_SUCCESSFUL)
46 if (status != RTEMS_SUCCESSFUL)
47 {
47 {
48 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
49 }
49 }
50
50
51 result = LFR_SUCCESSFUL;
51 result = LFR_SUCCESSFUL;
52 subtype = 0; // subtype of the current TC packet
52 subtype = 0; // subtype of the current TC packet
53
53
54 BOOT_PRINTF("in ACTN *** \n")
54 BOOT_PRINTF("in ACTN *** \n");
55
55
56 while(1)
56 while(1)
57 {
57 {
58 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
59 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
60 getTime( time ); // set time to the current time
60 getTime( time ); // set time to the current time
61 if (status!=RTEMS_SUCCESSFUL)
61 if (status!=RTEMS_SUCCESSFUL)
62 {
62 {
63 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
64 }
64 }
65 else
65 else
66 {
66 {
67 subtype = TC.serviceSubType;
67 subtype = TC.serviceSubType;
68 switch(subtype)
68 switch(subtype)
69 {
69 {
70 case TC_SUBTYPE_RESET:
70 case TC_SUBTYPE_RESET:
71 result = action_reset( &TC, queue_snd_id, time );
71 result = action_reset( &TC, queue_snd_id, time );
72 close_action( &TC, result, queue_snd_id );
72 close_action( &TC, result, queue_snd_id );
73 break;
73 break;
74 case TC_SUBTYPE_LOAD_COMM:
74 case TC_SUBTYPE_LOAD_COMM:
75 result = action_load_common_par( &TC );
75 result = action_load_common_par( &TC );
76 close_action( &TC, result, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
77 break;
77 break;
78 case TC_SUBTYPE_LOAD_NORM:
78 case TC_SUBTYPE_LOAD_NORM:
79 result = action_load_normal_par( &TC, queue_snd_id, time );
79 result = action_load_normal_par( &TC, queue_snd_id, time );
80 close_action( &TC, result, queue_snd_id );
80 close_action( &TC, result, queue_snd_id );
81 break;
81 break;
82 case TC_SUBTYPE_LOAD_BURST:
82 case TC_SUBTYPE_LOAD_BURST:
83 result = action_load_burst_par( &TC, queue_snd_id, time );
83 result = action_load_burst_par( &TC, queue_snd_id, time );
84 close_action( &TC, result, queue_snd_id );
84 close_action( &TC, result, queue_snd_id );
85 break;
85 break;
86 case TC_SUBTYPE_LOAD_SBM1:
86 case TC_SUBTYPE_LOAD_SBM1:
87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
88 close_action( &TC, result, queue_snd_id );
88 close_action( &TC, result, queue_snd_id );
89 break;
89 break;
90 case TC_SUBTYPE_LOAD_SBM2:
90 case TC_SUBTYPE_LOAD_SBM2:
91 result = action_load_sbm2_par( &TC, queue_snd_id, time );
91 result = action_load_sbm2_par( &TC, queue_snd_id, time );
92 close_action( &TC, result, queue_snd_id );
92 close_action( &TC, result, queue_snd_id );
93 break;
93 break;
94 case TC_SUBTYPE_DUMP:
94 case TC_SUBTYPE_DUMP:
95 result = action_dump_par( &TC, queue_snd_id );
95 result = action_dump_par( &TC, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
97 break;
97 break;
98 case TC_SUBTYPE_ENTER:
98 case TC_SUBTYPE_ENTER:
99 result = action_enter_mode( &TC, queue_snd_id );
99 result = action_enter_mode( &TC, queue_snd_id );
100 close_action( &TC, result, queue_snd_id );
100 close_action( &TC, result, queue_snd_id );
101 break;
101 break;
102 case TC_SUBTYPE_UPDT_INFO:
102 case TC_SUBTYPE_UPDT_INFO:
103 result = action_update_info( &TC, queue_snd_id );
103 result = action_update_info( &TC, queue_snd_id );
104 close_action( &TC, result, queue_snd_id );
104 close_action( &TC, result, queue_snd_id );
105 break;
105 break;
106 case TC_SUBTYPE_EN_CAL:
106 case TC_SUBTYPE_EN_CAL:
107 result = action_enable_calibration( &TC, queue_snd_id, time );
107 result = action_enable_calibration( &TC, queue_snd_id, time );
108 close_action( &TC, result, queue_snd_id );
108 close_action( &TC, result, queue_snd_id );
109 break;
109 break;
110 case TC_SUBTYPE_DIS_CAL:
110 case TC_SUBTYPE_DIS_CAL:
111 result = action_disable_calibration( &TC, queue_snd_id, time );
111 result = action_disable_calibration( &TC, queue_snd_id, time );
112 close_action( &TC, result, queue_snd_id );
112 close_action( &TC, result, queue_snd_id );
113 break;
113 break;
114 case TC_SUBTYPE_LOAD_K:
114 case TC_SUBTYPE_LOAD_K:
115 result = action_load_kcoefficients( &TC, queue_snd_id, time );
115 result = action_load_kcoefficients( &TC, queue_snd_id, time );
116 close_action( &TC, result, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
117 break;
117 break;
118 case TC_SUBTYPE_DUMP_K:
118 case TC_SUBTYPE_DUMP_K:
119 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
119 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
120 close_action( &TC, result, queue_snd_id );
120 close_action( &TC, result, queue_snd_id );
121 break;
121 break;
122 case TC_SUBTYPE_LOAD_FBINS:
122 case TC_SUBTYPE_LOAD_FBINS:
123 result = action_load_fbins_mask( &TC, queue_snd_id, time );
123 result = action_load_fbins_mask( &TC, queue_snd_id, time );
124 close_action( &TC, result, queue_snd_id );
124 close_action( &TC, result, queue_snd_id );
125 break;
125 break;
126 case TC_SUBTYPE_LOAD_FILTER_PAR:
126 case TC_SUBTYPE_LOAD_FILTER_PAR:
127 result = action_load_filter_par( &TC, queue_snd_id, time );
127 result = action_load_filter_par( &TC, queue_snd_id, time );
128 close_action( &TC, result, queue_snd_id );
128 close_action( &TC, result, queue_snd_id );
129 break;
129 break;
130 case TC_SUBTYPE_UPDT_TIME:
130 case TC_SUBTYPE_UPDT_TIME:
131 result = action_update_time( &TC );
131 result = action_update_time( &TC );
132 close_action( &TC, result, queue_snd_id );
132 close_action( &TC, result, queue_snd_id );
133 break;
133 break;
134 default:
134 default:
135 break;
135 break;
136 }
136 }
137 }
137 }
138 }
138 }
139 }
139 }
140
140
141 //***********
141 //***********
142 // TC ACTIONS
142 // TC ACTIONS
143
143
144 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
144 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
145 {
145 {
146 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
146 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
147 *
147 *
148 * @param TC points to the TeleCommand packet that is being processed
148 * @param TC points to the TeleCommand packet that is being processed
149 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
149 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
150 *
150 *
151 */
151 */
152
152
153 PRINTF("this is the end!!!\n");
153 PRINTF("this is the end!!!\n");
154 exit(0);
154 exit(0);
155
155
156 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
156 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
157
157
158 return LFR_DEFAULT;
158 return LFR_DEFAULT;
159 }
159 }
160
160
161 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
161 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
162 {
162 {
163 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
163 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
164 *
164 *
165 * @param TC points to the TeleCommand packet that is being processed
165 * @param TC points to the TeleCommand packet that is being processed
166 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
166 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
167 *
167 *
168 */
168 */
169
169
170 rtems_status_code status;
170 rtems_status_code status;
171 unsigned char requestedMode;
171 unsigned char requestedMode;
172 unsigned int *transitionCoarseTime_ptr;
172 unsigned int *transitionCoarseTime_ptr;
173 unsigned int transitionCoarseTime;
173 unsigned int transitionCoarseTime;
174 unsigned char * bytePosPtr;
174 unsigned char * bytePosPtr;
175
175
176 bytePosPtr = (unsigned char *) &TC->packetID;
176 bytePosPtr = (unsigned char *) &TC->packetID;
177
177
178 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
178 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
179 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
179 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
180 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
180 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
181
181
182 status = check_mode_value( requestedMode );
182 status = check_mode_value( requestedMode );
183
183
184 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
184 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
185 {
185 {
186 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
186 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
187 }
187 }
188
188
189 else // the mode value is valid, check the transition
189 else // the mode value is valid, check the transition
190 {
190 {
191 status = check_mode_transition(requestedMode);
191 status = check_mode_transition(requestedMode);
192 if (status != LFR_SUCCESSFUL)
192 if (status != LFR_SUCCESSFUL)
193 {
193 {
194 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
194 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
195 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
195 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
196 }
196 }
197 }
197 }
198
198
199 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
199 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
200 {
200 {
201 status = check_transition_date( transitionCoarseTime );
201 status = check_transition_date( transitionCoarseTime );
202 if (status != LFR_SUCCESSFUL)
202 if (status != LFR_SUCCESSFUL)
203 {
203 {
204 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
204 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
205 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
205 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
206 }
206 }
207 }
207 }
208
208
209 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
209 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
210 {
210 {
211 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
211 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
212
212
213 switch(requestedMode)
213 switch(requestedMode)
214 {
214 {
215 case LFR_MODE_STANDBY:
215 case LFR_MODE_STANDBY:
216 status = enter_mode_standby();
216 status = enter_mode_standby();
217 break;
217 break;
218 case LFR_MODE_NORMAL:
218 case LFR_MODE_NORMAL:
219 status = enter_mode_normal( transitionCoarseTime );
219 status = enter_mode_normal( transitionCoarseTime );
220 break;
220 break;
221 case LFR_MODE_BURST:
221 case LFR_MODE_BURST:
222 status = enter_mode_burst( transitionCoarseTime );
222 status = enter_mode_burst( transitionCoarseTime );
223 break;
223 break;
224 case LFR_MODE_SBM1:
224 case LFR_MODE_SBM1:
225 status = enter_mode_sbm1( transitionCoarseTime );
225 status = enter_mode_sbm1( transitionCoarseTime );
226 break;
226 break;
227 case LFR_MODE_SBM2:
227 case LFR_MODE_SBM2:
228 status = enter_mode_sbm2( transitionCoarseTime );
228 status = enter_mode_sbm2( transitionCoarseTime );
229 break;
229 break;
230 default:
230 default:
231 break;
231 break;
232 }
232 }
233
233
234 if (status != RTEMS_SUCCESSFUL)
234 if (status != RTEMS_SUCCESSFUL)
235 {
235 {
236 status = LFR_EXE_ERROR;
236 status = LFR_EXE_ERROR;
237 }
237 }
238 }
238 }
239
239
240 return status;
240 return status;
241 }
241 }
242
242
243 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
243 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
244 {
244 {
245 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
245 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
246 *
246 *
247 * @param TC points to the TeleCommand packet that is being processed
247 * @param TC points to the TeleCommand packet that is being processed
248 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
248 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
249 *
249 *
250 * @return LFR directive status code:
250 * @return LFR directive status code:
251 * - LFR_DEFAULT
251 * - LFR_DEFAULT
252 * - LFR_SUCCESSFUL
252 * - LFR_SUCCESSFUL
253 *
253 *
254 */
254 */
255
255
256 unsigned int val;
256 unsigned int val;
257 int result;
257 int result;
258 unsigned int status;
258 unsigned int status;
259 unsigned char mode;
259 unsigned char mode;
260 unsigned char * bytePosPtr;
260 unsigned char * bytePosPtr;
261
261
262 bytePosPtr = (unsigned char *) &TC->packetID;
262 bytePosPtr = (unsigned char *) &TC->packetID;
263
263
264 // check LFR mode
264 // check LFR mode
265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
266 status = check_update_info_hk_lfr_mode( mode );
266 status = check_update_info_hk_lfr_mode( mode );
267 if (status == LFR_SUCCESSFUL) // check TDS mode
267 if (status == LFR_SUCCESSFUL) // check TDS mode
268 {
268 {
269 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
269 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
270 status = check_update_info_hk_tds_mode( mode );
270 status = check_update_info_hk_tds_mode( mode );
271 }
271 }
272 if (status == LFR_SUCCESSFUL) // check THR mode
272 if (status == LFR_SUCCESSFUL) // check THR mode
273 {
273 {
274 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
274 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
275 status = check_update_info_hk_thr_mode( mode );
275 status = check_update_info_hk_thr_mode( mode );
276 }
276 }
277 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
277 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
278 {
278 {
279 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
279 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
280 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
280 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
281 val++;
281 val++;
282 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
282 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
283 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
283 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
284 }
284 }
285
285
286 // pa_bia_status_info
286 // pa_bia_status_info
287 // => pa_bia_mode_mux_set 3 bits
287 // => pa_bia_mode_mux_set 3 bits
288 // => pa_bia_mode_hv_enabled 1 bit
288 // => pa_bia_mode_hv_enabled 1 bit
289 // => pa_bia_mode_bias1_enabled 1 bit
289 // => pa_bia_mode_bias1_enabled 1 bit
290 // => pa_bia_mode_bias2_enabled 1 bit
290 // => pa_bia_mode_bias2_enabled 1 bit
291 // => pa_bia_mode_bias3_enabled 1 bit
291 // => pa_bia_mode_bias3_enabled 1 bit
292 // => pa_bia_on_off (cp_dpu_bias_on_off)
292 // => pa_bia_on_off (cp_dpu_bias_on_off)
293 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
293 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
294 pa_bia_status_info = pa_bia_status_info
294 pa_bia_status_info = pa_bia_status_info
295 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
295 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
296
296
297 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
297 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
298 cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ];
298 cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ];
299 getReactionWheelsFrequencies( TC );
299 getReactionWheelsFrequencies( TC );
300 build_rw_fbins_masks();
300 build_rw_fbins_masks();
301
301
302 result = status;
302 result = status;
303
303
304 return result;
304 return result;
305 }
305 }
306
306
307 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
307 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
308 {
308 {
309 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
309 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
310 *
310 *
311 * @param TC points to the TeleCommand packet that is being processed
311 * @param TC points to the TeleCommand packet that is being processed
312 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
312 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
313 *
313 *
314 */
314 */
315
315
316 int result;
316 int result;
317
317
318 result = LFR_DEFAULT;
318 result = LFR_DEFAULT;
319
319
320 setCalibration( true );
320 setCalibration( true );
321
321
322 result = LFR_SUCCESSFUL;
322 result = LFR_SUCCESSFUL;
323
323
324 return result;
324 return result;
325 }
325 }
326
326
327 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
327 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
328 {
328 {
329 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
329 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
330 *
330 *
331 * @param TC points to the TeleCommand packet that is being processed
331 * @param TC points to the TeleCommand packet that is being processed
332 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
332 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
333 *
333 *
334 */
334 */
335
335
336 int result;
336 int result;
337
337
338 result = LFR_DEFAULT;
338 result = LFR_DEFAULT;
339
339
340 setCalibration( false );
340 setCalibration( false );
341
341
342 result = LFR_SUCCESSFUL;
342 result = LFR_SUCCESSFUL;
343
343
344 return result;
344 return result;
345 }
345 }
346
346
347 int action_update_time(ccsdsTelecommandPacket_t *TC)
347 int action_update_time(ccsdsTelecommandPacket_t *TC)
348 {
348 {
349 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
349 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
350 *
350 *
351 * @param TC points to the TeleCommand packet that is being processed
351 * @param TC points to the TeleCommand packet that is being processed
352 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
352 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
353 *
353 *
354 * @return LFR_SUCCESSFUL
354 * @return LFR_SUCCESSFUL
355 *
355 *
356 */
356 */
357
357
358 unsigned int val;
358 unsigned int val;
359
359
360 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
360 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
361 + (TC->dataAndCRC[1] << 16)
361 + (TC->dataAndCRC[1] << 16)
362 + (TC->dataAndCRC[2] << 8)
362 + (TC->dataAndCRC[2] << 8)
363 + TC->dataAndCRC[3];
363 + TC->dataAndCRC[3];
364
364
365 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
365 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
366 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
366 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
367 val++;
367 val++;
368 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
368 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
369 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
369 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
370
370
371 oneTcLfrUpdateTimeReceived = 1;
371 oneTcLfrUpdateTimeReceived = 1;
372
372
373 return LFR_SUCCESSFUL;
373 return LFR_SUCCESSFUL;
374 }
374 }
375
375
376 //*******************
376 //*******************
377 // ENTERING THE MODES
377 // ENTERING THE MODES
378 int check_mode_value( unsigned char requestedMode )
378 int check_mode_value( unsigned char requestedMode )
379 {
379 {
380 int status;
380 int status;
381
381
382 if ( (requestedMode != LFR_MODE_STANDBY)
382 if ( (requestedMode != LFR_MODE_STANDBY)
383 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
383 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
384 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
384 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
385 {
385 {
386 status = LFR_DEFAULT;
386 status = LFR_DEFAULT;
387 }
387 }
388 else
388 else
389 {
389 {
390 status = LFR_SUCCESSFUL;
390 status = LFR_SUCCESSFUL;
391 }
391 }
392
392
393 return status;
393 return status;
394 }
394 }
395
395
396 int check_mode_transition( unsigned char requestedMode )
396 int check_mode_transition( unsigned char requestedMode )
397 {
397 {
398 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
398 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
399 *
399 *
400 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
400 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
401 *
401 *
402 * @return LFR directive status codes:
402 * @return LFR directive status codes:
403 * - LFR_SUCCESSFUL - the transition is authorized
403 * - LFR_SUCCESSFUL - the transition is authorized
404 * - LFR_DEFAULT - the transition is not authorized
404 * - LFR_DEFAULT - the transition is not authorized
405 *
405 *
406 */
406 */
407
407
408 int status;
408 int status;
409
409
410 switch (requestedMode)
410 switch (requestedMode)
411 {
411 {
412 case LFR_MODE_STANDBY:
412 case LFR_MODE_STANDBY:
413 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
413 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
414 status = LFR_DEFAULT;
414 status = LFR_DEFAULT;
415 }
415 }
416 else
416 else
417 {
417 {
418 status = LFR_SUCCESSFUL;
418 status = LFR_SUCCESSFUL;
419 }
419 }
420 break;
420 break;
421 case LFR_MODE_NORMAL:
421 case LFR_MODE_NORMAL:
422 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
422 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
423 status = LFR_DEFAULT;
423 status = LFR_DEFAULT;
424 }
424 }
425 else {
425 else {
426 status = LFR_SUCCESSFUL;
426 status = LFR_SUCCESSFUL;
427 }
427 }
428 break;
428 break;
429 case LFR_MODE_BURST:
429 case LFR_MODE_BURST:
430 if ( lfrCurrentMode == LFR_MODE_BURST ) {
430 if ( lfrCurrentMode == LFR_MODE_BURST ) {
431 status = LFR_DEFAULT;
431 status = LFR_DEFAULT;
432 }
432 }
433 else {
433 else {
434 status = LFR_SUCCESSFUL;
434 status = LFR_SUCCESSFUL;
435 }
435 }
436 break;
436 break;
437 case LFR_MODE_SBM1:
437 case LFR_MODE_SBM1:
438 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
438 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
439 status = LFR_DEFAULT;
439 status = LFR_DEFAULT;
440 }
440 }
441 else {
441 else {
442 status = LFR_SUCCESSFUL;
442 status = LFR_SUCCESSFUL;
443 }
443 }
444 break;
444 break;
445 case LFR_MODE_SBM2:
445 case LFR_MODE_SBM2:
446 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
446 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
447 status = LFR_DEFAULT;
447 status = LFR_DEFAULT;
448 }
448 }
449 else {
449 else {
450 status = LFR_SUCCESSFUL;
450 status = LFR_SUCCESSFUL;
451 }
451 }
452 break;
452 break;
453 default:
453 default:
454 status = LFR_DEFAULT;
454 status = LFR_DEFAULT;
455 break;
455 break;
456 }
456 }
457
457
458 return status;
458 return status;
459 }
459 }
460
460
461 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
461 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
462 {
462 {
463 if (transitionCoarseTime == 0)
463 if (transitionCoarseTime == 0)
464 {
464 {
465 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
465 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
466 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime);
466 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime);
467 }
467 }
468 else
468 else
469 {
469 {
470 lastValidEnterModeTime = transitionCoarseTime;
470 lastValidEnterModeTime = transitionCoarseTime;
471 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
471 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
472 }
472 }
473 }
473 }
474
474
475 int check_transition_date( unsigned int transitionCoarseTime )
475 int check_transition_date( unsigned int transitionCoarseTime )
476 {
476 {
477 int status;
477 int status;
478 unsigned int localCoarseTime;
478 unsigned int localCoarseTime;
479 unsigned int deltaCoarseTime;
479 unsigned int deltaCoarseTime;
480
480
481 status = LFR_SUCCESSFUL;
481 status = LFR_SUCCESSFUL;
482
482
483 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
483 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
484 {
484 {
485 status = LFR_SUCCESSFUL;
485 status = LFR_SUCCESSFUL;
486 }
486 }
487 else
487 else
488 {
488 {
489 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
489 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
490
490
491 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
491 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
492
492
493 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
493 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
494 {
494 {
495 status = LFR_DEFAULT;
495 status = LFR_DEFAULT;
496 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
496 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
497 }
497 }
498
498
499 if (status == LFR_SUCCESSFUL)
499 if (status == LFR_SUCCESSFUL)
500 {
500 {
501 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
501 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
502 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
502 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
503 {
503 {
504 status = LFR_DEFAULT;
504 status = LFR_DEFAULT;
505 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
505 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
506 }
506 }
507 }
507 }
508 }
508 }
509
509
510 return status;
510 return status;
511 }
511 }
512
512
513 int restart_asm_activities( unsigned char lfrRequestedMode )
513 int restart_asm_activities( unsigned char lfrRequestedMode )
514 {
514 {
515 rtems_status_code status;
515 rtems_status_code status;
516
516
517 status = stop_spectral_matrices();
517 status = stop_spectral_matrices();
518
518
519 thisIsAnASMRestart = 1;
519 thisIsAnASMRestart = 1;
520
520
521 status = restart_asm_tasks( lfrRequestedMode );
521 status = restart_asm_tasks( lfrRequestedMode );
522
522