##// END OF EJS Templates
printf are used to test the new setFBinMask (Bug 747 and other similar bugs)
paul -
r314:9e5325937a5e R3_plus draft
parent child
Show More
@@ -1,108 +1,108
1 cmake_minimum_required (VERSION 2.6)
1 cmake_minimum_required (VERSION 2.6)
2 project (fsw)
2 project (fsw)
3
3
4 include(sparc-rtems)
4 include(sparc-rtems)
5 include(cppcheck)
5 include(cppcheck)
6
6
7 include_directories("../header"
7 include_directories("../header"
8 "../header/lfr_common_headers"
8 "../header/lfr_common_headers"
9 "../header/processing"
9 "../header/processing"
10 "../LFR_basic-parameters"
10 "../LFR_basic-parameters"
11 "../src")
11 "../src")
12
12
13 set(SOURCES wf_handler.c
13 set(SOURCES wf_handler.c
14 tc_handler.c
14 tc_handler.c
15 fsw_misc.c
15 fsw_misc.c
16 fsw_init.c
16 fsw_init.c
17 fsw_globals.c
17 fsw_globals.c
18 fsw_spacewire.c
18 fsw_spacewire.c
19 tc_load_dump_parameters.c
19 tc_load_dump_parameters.c
20 tm_lfr_tc_exe.c
20 tm_lfr_tc_exe.c
21 tc_acceptance.c
21 tc_acceptance.c
22 processing/fsw_processing.c
22 processing/fsw_processing.c
23 processing/avf0_prc0.c
23 processing/avf0_prc0.c
24 processing/avf1_prc1.c
24 processing/avf1_prc1.c
25 processing/avf2_prc2.c
25 processing/avf2_prc2.c
26 lfr_cpu_usage_report.c
26 lfr_cpu_usage_report.c
27 ${LFR_BP_SRC}
27 ${LFR_BP_SRC}
28 ../header/wf_handler.h
28 ../header/wf_handler.h
29 ../header/tc_handler.h
29 ../header/tc_handler.h
30 ../header/grlib_regs.h
30 ../header/grlib_regs.h
31 ../header/fsw_misc.h
31 ../header/fsw_misc.h
32 ../header/fsw_init.h
32 ../header/fsw_init.h
33 ../header/fsw_spacewire.h
33 ../header/fsw_spacewire.h
34 ../header/tc_load_dump_parameters.h
34 ../header/tc_load_dump_parameters.h
35 ../header/tm_lfr_tc_exe.h
35 ../header/tm_lfr_tc_exe.h
36 ../header/tc_acceptance.h
36 ../header/tc_acceptance.h
37 ../header/processing/fsw_processing.h
37 ../header/processing/fsw_processing.h
38 ../header/processing/avf0_prc0.h
38 ../header/processing/avf0_prc0.h
39 ../header/processing/avf1_prc1.h
39 ../header/processing/avf1_prc1.h
40 ../header/processing/avf2_prc2.h
40 ../header/processing/avf2_prc2.h
41 ../header/fsw_params_wf_handler.h
41 ../header/fsw_params_wf_handler.h
42 ../header/lfr_cpu_usage_report.h
42 ../header/lfr_cpu_usage_report.h
43 ../header/lfr_common_headers/ccsds_types.h
43 ../header/lfr_common_headers/ccsds_types.h
44 ../header/lfr_common_headers/fsw_params.h
44 ../header/lfr_common_headers/fsw_params.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
46 ../header/lfr_common_headers/fsw_params_processing.h
46 ../header/lfr_common_headers/fsw_params_processing.h
47 ../header/lfr_common_headers/tm_byte_positions.h
47 ../header/lfr_common_headers/tm_byte_positions.h
48 ../LFR_basic-parameters/basic_parameters.h
48 ../LFR_basic-parameters/basic_parameters.h
49 ../LFR_basic-parameters/basic_parameters_params.h
49 ../LFR_basic-parameters/basic_parameters_params.h
50 ../header/GscMemoryLPP.hpp
50 ../header/GscMemoryLPP.hpp
51 )
51 )
52
52
53
53
54 option(FSW_verbose "Enable verbose LFR" ON)
54 option(FSW_verbose "Enable verbose LFR" ON)
55 option(FSW_boot_messages "Enable LFR boot messages" ON)
55 option(FSW_boot_messages "Enable LFR boot messages" ON)
56 option(FSW_debug_messages "Enable LFR debug messages" ON)
56 option(FSW_debug_messages "Enable LFR debug messages" ON)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)
59 option(FSW_vhdl_dev "?" OFF)
59 option(FSW_vhdl_dev "?" OFF)
60 option(FSW_lpp_dpu_destid "Set to debug at LPP" ON)
60 option(FSW_lpp_dpu_destid "Set to debug at LPP" ON)
61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
62 option(FSW_debug_tch "?" OFF)
62 option(FSW_debug_tch "?" OFF)
63
63
64 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
64 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
65 set(SW_VERSION_N2 "1" CACHE STRING "Choose N2 FSW Version." FORCE)
65 set(SW_VERSION_N2 "1" CACHE STRING "Choose N2 FSW Version." FORCE)
66 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
66 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
67 set(SW_VERSION_N4 "4" CACHE STRING "Choose N4 FSW Version." FORCE)
67 set(SW_VERSION_N4 "4" CACHE STRING "Choose N4 FSW Version." FORCE)
68
68
69
69
70 if(FSW_verbose)
70 if(FSW_verbose)
71 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
71 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
72 endif()
72 endif()
73 if(FSW_boot_messages)
73 if(FSW_boot_messages)
74 add_definitions(-DBOOT_MESSAGES)
74 add_definitions(-DBOOT_MESSAGES)
75 endif()
75 endif()
76 if(FSW_debug_messages)
76 if(FSW_debug_messages)
77 add_definitions(-DDEBUG_MESSAGES)
77 add_definitions(-DDEBUG_MESSAGES)
78 endif()
78 endif()
79 if(FSW_cpu_usage_report)
79 if(FSW_cpu_usage_report)
80 add_definitions(-DPRINT_TASK_STATISTICS)
80 add_definitions(-DPRINT_TASK_STATISTICS)
81 endif()
81 endif()
82 if(FSW_stack_report)
82 if(FSW_stack_report)
83 add_definitions(-DPRINT_STACK_REPORT)
83 add_definitions(-DPRINT_STACK_REPORT)
84 endif()
84 endif()
85 if(FSW_vhdl_dev)
85 if(FSW_vhdl_dev)
86 add_definitions(-DVHDL_DEV)
86 add_definitions(-DVHDL_DEV)
87 endif()
87 endif()
88 if(FSW_lpp_dpu_destid)
88 if(FSW_lpp_dpu_destid)
89 add_definitions(-DLPP_DPU_DESTID)
89 add_definitions(-DLPP_DPU_DESTID)
90 endif()
90 endif()
91 if(FSW_debug_watchdog)
91 if(FSW_debug_watchdog)
92 add_definitions(-DDEBUG_WATCHDOG)
92 add_definitions(-DDEBUG_WATCHDOG)
93 endif()
93 endif()
94 if(FSW_debug_tch)
94 if(FSW_debug_tch)
95 add_definitions(-DDEBUG_TCH)
95 add_definitions(-DDEBUG_TCH)
96 endif()
96 endif()
97
97
98 add_definitions(-DMSB_FIRST_TCH)
98 add_definitions(-DMSB_FIRST_TCH)
99
99
100 add_definitions(-DSWVERSION=-1-0)
100 add_definitions(-DSWVERSION=-1-0)
101 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
101 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
102 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
102 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
103 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
103 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
104 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
104 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
105
105
106 add_executable(FSW ${SOURCES})
106 add_executable(fsw ${SOURCES})
107 add_test_cppcheck(FSW STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE)
107 add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE)
108
108
@@ -1,1641 +1,1642
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
298 cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ];
299 cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ];
299 getReactionWheelsFrequencies( TC );
300 getReactionWheelsFrequencies( TC );
300 build_sy_lfr_rw_masks();
301 build_sy_lfr_rw_masks();
301
302
302 result = status;
303 result = status;
303
304
304 return result;
305 return result;
305 }
306 }
306
307
307 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
308 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
308 {
309 {
309 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
310 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
310 *
311 *
311 * @param TC points to the TeleCommand packet that is being processed
312 * @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
313 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
313 *
314 *
314 */
315 */
315
316
316 int result;
317 int result;
317
318
318 result = LFR_DEFAULT;
319 result = LFR_DEFAULT;
319
320
320 setCalibration( true );
321 setCalibration( true );
321
322
322 result = LFR_SUCCESSFUL;
323 result = LFR_SUCCESSFUL;
323
324
324 return result;
325 return result;
325 }
326 }
326
327
327 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
328 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
328 {
329 {
329 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
330 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
330 *
331 *
331 * @param TC points to the TeleCommand packet that is being processed
332 * @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
333 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
333 *
334 *
334 */
335 */
335
336
336 int result;
337 int result;
337
338
338 result = LFR_DEFAULT;
339 result = LFR_DEFAULT;
339
340
340 setCalibration( false );
341 setCalibration( false );
341
342
342 result = LFR_SUCCESSFUL;
343 result = LFR_SUCCESSFUL;
343
344
344 return result;
345 return result;
345 }
346 }
346
347
347 int action_update_time(ccsdsTelecommandPacket_t *TC)
348 int action_update_time(ccsdsTelecommandPacket_t *TC)
348 {
349 {
349 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
350 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
350 *
351 *
351 * @param TC points to the TeleCommand packet that is being processed
352 * @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
353 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
353 *
354 *
354 * @return LFR_SUCCESSFUL
355 * @return LFR_SUCCESSFUL
355 *
356 *
356 */
357 */
357
358
358 unsigned int val;
359 unsigned int val;
359
360
360 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
361 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
361 + (TC->dataAndCRC[1] << 16)
362 + (TC->dataAndCRC[1] << 16)
362 + (TC->dataAndCRC[2] << 8)
363 + (TC->dataAndCRC[2] << 8)
363 + TC->dataAndCRC[3];
364 + TC->dataAndCRC[3];
364
365
365 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
366 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
366 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
367 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
367 val++;
368 val++;
368 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
369 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);
370 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
370
371
371 oneTcLfrUpdateTimeReceived = 1;
372 oneTcLfrUpdateTimeReceived = 1;
372
373
373 return LFR_SUCCESSFUL;
374 return LFR_SUCCESSFUL;
374 }
375 }
375
376
376 //*******************
377 //*******************
377 // ENTERING THE MODES
378 // ENTERING THE MODES
378 int check_mode_value( unsigned char requestedMode )
379 int check_mode_value( unsigned char requestedMode )
379 {
380 {
380 int status;
381 int status;
381
382
382 if ( (requestedMode != LFR_MODE_STANDBY)
383 if ( (requestedMode != LFR_MODE_STANDBY)
383 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
384 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
384 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
385 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
385 {
386 {
386 status = LFR_DEFAULT;
387 status = LFR_DEFAULT;
387 }
388 }
388 else
389 else
389 {
390 {
390 status = LFR_SUCCESSFUL;
391 status = LFR_SUCCESSFUL;
391 }
392 }
392
393
393 return status;
394 return status;
394 }
395 }
395
396
396 int check_mode_transition( unsigned char requestedMode )
397 int check_mode_transition( unsigned char requestedMode )
397 {
398 {
398 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
399 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
399 *
400 *
400 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
401 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
401 *
402 *
402 * @return LFR directive status codes:
403 * @return LFR directive status codes:
403 * - LFR_SUCCESSFUL - the transition is authorized
404 * - LFR_SUCCESSFUL - the transition is authorized
404 * - LFR_DEFAULT - the transition is not authorized
405 * - LFR_DEFAULT - the transition is not authorized
405 *
406 *
406 */
407 */
407
408
408 int status;
409 int status;
409
410
410 switch (requestedMode)
411 switch (requestedMode)
411 {
412 {
412 case LFR_MODE_STANDBY:
413 case LFR_MODE_STANDBY:
413 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
414 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
414 status = LFR_DEFAULT;
415 status = LFR_DEFAULT;
415 }
416 }
416 else
417 else
417 {
418 {
418 status = LFR_SUCCESSFUL;
419 status = LFR_SUCCESSFUL;
419 }
420 }
420 break;
421 break;
421 case LFR_MODE_NORMAL:
422 case LFR_MODE_NORMAL:
422 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
423 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
423 status = LFR_DEFAULT;
424 status = LFR_DEFAULT;
424 }
425 }
425 else {
426 else {
426 status = LFR_SUCCESSFUL;
427 status = LFR_SUCCESSFUL;
427 }
428 }
428 break;
429 break;
429 case LFR_MODE_BURST:
430 case LFR_MODE_BURST:
430 if ( lfrCurrentMode == LFR_MODE_BURST ) {
431 if ( lfrCurrentMode == LFR_MODE_BURST ) {
431 status = LFR_DEFAULT;
432 status = LFR_DEFAULT;
432 }
433 }
433 else {
434 else {
434 status = LFR_SUCCESSFUL;
435 status = LFR_SUCCESSFUL;
435 }
436 }
436 break;
437 break;
437 case LFR_MODE_SBM1:
438 case LFR_MODE_SBM1:
438 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
439 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
439 status = LFR_DEFAULT;
440 status = LFR_DEFAULT;
440 }
441 }
441 else {
442 else {
442 status = LFR_SUCCESSFUL;
443 status = LFR_SUCCESSFUL;
443 }
444 }
444 break;
445 break;
445 case LFR_MODE_SBM2:
446 case LFR_MODE_SBM2:
446 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
447 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
447 status = LFR_DEFAULT;
448 status = LFR_DEFAULT;
448 }
449 }
449 else {
450 else {
450 status = LFR_SUCCESSFUL;
451 status = LFR_SUCCESSFUL;
451 }
452 }
452 break;
453 break;
453 default:
454 default:
454 status = LFR_DEFAULT;
455 status = LFR_DEFAULT;
455 break;
456 break;
456 }
457 }
457
458
458 return status;
459 return status;
459 }
460 }
460
461
461 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
462 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
462 {
463 {
463 if (transitionCoarseTime == 0)
464 if (transitionCoarseTime == 0)
464 {
465 {
465 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
466 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
466 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime);
467 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime);
467 }
468 }
468 else
469 else
469 {
470 {
470 lastValidEnterModeTime = transitionCoarseTime;
471 lastValidEnterModeTime = transitionCoarseTime;
471 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
472 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
472 }
473 }
473 }
474 }
474
475
475 int check_transition_date( unsigned int transitionCoarseTime )
476 int check_transition_date( unsigned int transitionCoarseTime )
476 {
477 {
477 int status;
478 int status;
478 unsigned int localCoarseTime;
479 unsigned int localCoarseTime;
479 unsigned int deltaCoarseTime;
480 unsigned int deltaCoarseTime;
480
481
481 status = LFR_SUCCESSFUL;
482 status = LFR_SUCCESSFUL;
482
483
483 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
484 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
484 {
485 {
485 status = LFR_SUCCESSFUL;
486 status = LFR_SUCCESSFUL;
486 }
487 }
487 else
488 else
488 {
489 {
489 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
490 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
490
491
491 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
492 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
492
493
493 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
494 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
494 {
495 {
495 status = LFR_DEFAULT;
496 status = LFR_DEFAULT;
496 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
497 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
497 }
498 }
498
499
499 if (status == LFR_SUCCESSFUL)
500 if (status == LFR_SUCCESSFUL)
500 {
501 {
501 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
502 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
502 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
503 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
503 {
504 {
504 status = LFR_DEFAULT;
505 status = LFR_DEFAULT;
505 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
506 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
506 }
507 }
507 }
508 }
508 }
509 }
509
510
510 return status;
511 return status;
511 }
512 }
512
513
513 int restart_asm_activities( unsigned char lfrRequestedMode )
514 int restart_asm_activities( unsigned char lfrRequestedMode )
514 {
515 {
515 rtems_status_code status;
516 rtems_status_code status;
516
517
517 status = stop_spectral_matrices();
518 status = stop_spectral_matrices();
518