##// 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
519
519 thisIsAnASMRestart = 1;
520 thisIsAnASMRestart = 1;
520
521
521 status = restart_asm_tasks( lfrRequestedMode );
522 status = restart_asm_tasks( lfrRequestedMode );
522
523
523 launch_spectral_matrix();
524 launch_spectral_matrix();
524
525
525 return status;
526 return status;
526 }
527 }
527
528
528 int stop_spectral_matrices( void )
529 int stop_spectral_matrices( void )
529 {
530 {
530 /** This function stops and restarts the current mode average spectral matrices activities.
531 /** This function stops and restarts the current mode average spectral matrices activities.
531 *
532 *
532 * @return RTEMS directive status codes:
533 * @return RTEMS directive status codes:
533 * - RTEMS_SUCCESSFUL - task restarted successfully
534 * - RTEMS_SUCCESSFUL - task restarted successfully
534 * - RTEMS_INVALID_ID - task id invalid
535 * - RTEMS_INVALID_ID - task id invalid
535 * - RTEMS_ALREADY_SUSPENDED - task already suspended
536 * - RTEMS_ALREADY_SUSPENDED - task already suspended
536 *
537 *
537 */
538 */
538
539
539 rtems_status_code status;
540 rtems_status_code status;
540
541
541 status = RTEMS_SUCCESSFUL;
542 status = RTEMS_SUCCESSFUL;
542
543
543 // (1) mask interruptions
544 // (1) mask interruptions
544 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
545 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
545
546
546 // (2) reset spectral matrices registers
547 // (2) reset spectral matrices registers
547 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
548 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
548 reset_sm_status();
549 reset_sm_status();
549
550
550 // (3) clear interruptions
551 // (3) clear interruptions
551 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
552 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
552
553
553 // suspend several tasks
554 // suspend several tasks
554 if (lfrCurrentMode != LFR_MODE_STANDBY) {
555 if (lfrCurrentMode != LFR_MODE_STANDBY) {
555 status = suspend_asm_tasks();
556 status = suspend_asm_tasks();
556 }
557 }
557
558
558 if (status != RTEMS_SUCCESSFUL)
559 if (status != RTEMS_SUCCESSFUL)
559 {
560 {
560 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
561 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
561 }
562 }
562
563
563 return status;
564 return status;
564 }
565 }
565
566
566 int stop_current_mode( void )
567 int stop_current_mode( void )
567 {
568 {
568 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
569 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
569 *
570 *
570 * @return RTEMS directive status codes:
571 * @return RTEMS directive status codes:
571 * - RTEMS_SUCCESSFUL - task restarted successfully
572 * - RTEMS_SUCCESSFUL - task restarted successfully
572 * - RTEMS_INVALID_ID - task id invalid
573 * - RTEMS_INVALID_ID - task id invalid
573 * - RTEMS_ALREADY_SUSPENDED - task already suspended
574 * - RTEMS_ALREADY_SUSPENDED - task already suspended
574 *
575 *
575 */
576 */
576
577
577 rtems_status_code status;
578 rtems_status_code status;
578
579
579 status = RTEMS_SUCCESSFUL;
580 status = RTEMS_SUCCESSFUL;
580
581
581 // (1) mask interruptions
582 // (1) mask interruptions
582 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
583 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
583 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
584 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
584
585
585 // (2) reset waveform picker registers
586 // (2) reset waveform picker registers
586 reset_wfp_burst_enable(); // reset burst and enable bits
587 reset_wfp_burst_enable(); // reset burst and enable bits
587 reset_wfp_status(); // reset all the status bits
588 reset_wfp_status(); // reset all the status bits
588
589
589 // (3) reset spectral matrices registers
590 // (3) reset spectral matrices registers
590 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
591 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
591 reset_sm_status();
592 reset_sm_status();
592
593
593 // reset lfr VHDL module
594 // reset lfr VHDL module
594 reset_lfr();
595 reset_lfr();
595
596
596 reset_extractSWF(); // reset the extractSWF flag to false
597 reset_extractSWF(); // reset the extractSWF flag to false
597
598
598 // (4) clear interruptions
599 // (4) clear interruptions
599 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
600 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
600 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
601 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
601
602
602 // suspend several tasks
603 // suspend several tasks
603 if (lfrCurrentMode != LFR_MODE_STANDBY) {
604 if (lfrCurrentMode != LFR_MODE_STANDBY) {
604 status = suspend_science_tasks();
605 status = suspend_science_tasks();
605 }
606 }
606
607
607 if (status != RTEMS_SUCCESSFUL)
608 if (status != RTEMS_SUCCESSFUL)
608 {
609 {
609 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
610 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
610 }
611 }
611
612
612 return status;
613 return status;
613 }
614 }
614
615
615 int enter_mode_standby( void )
616 int enter_mode_standby( void )
616 {
617 {
617 /** This function is used to put LFR in the STANDBY mode.
618 /** This function is used to put LFR in the STANDBY mode.
618 *
619 *
619 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
620 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
620 *
621 *
621 * @return RTEMS directive status codes:
622 * @return RTEMS directive status codes:
622 * - RTEMS_SUCCESSFUL - task restarted successfully
623 * - RTEMS_SUCCESSFUL - task restarted successfully
623 * - RTEMS_INVALID_ID - task id invalid
624 * - RTEMS_INVALID_ID - task id invalid
624 * - RTEMS_INCORRECT_STATE - task never started
625 * - RTEMS_INCORRECT_STATE - task never started
625 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
626 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
626 *
627 *
627 * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE
628 * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE
628 * is immediate.
629 * is immediate.
629 *
630 *
630 */
631 */
631
632
632 int status;
633 int status;
633
634
634 status = stop_current_mode(); // STOP THE CURRENT MODE
635 status = stop_current_mode(); // STOP THE CURRENT MODE
635
636
636 #ifdef PRINT_TASK_STATISTICS
637 #ifdef PRINT_TASK_STATISTICS
637 rtems_cpu_usage_report();
638 rtems_cpu_usage_report();
638 #endif
639 #endif
639
640
640 #ifdef PRINT_STACK_REPORT
641 #ifdef PRINT_STACK_REPORT
641 PRINTF("stack report selected\n")
642 PRINTF("stack report selected\n")
642 rtems_stack_checker_report_usage();
643 rtems_stack_checker_report_usage();
643 #endif
644 #endif
644
645
645 return status;
646 return status;
646 }
647 }
647
648
648 int enter_mode_normal( unsigned int transitionCoarseTime )
649 int enter_mode_normal( unsigned int transitionCoarseTime )
649 {
650 {
650 /** This function is used to start the NORMAL mode.
651 /** This function is used to start the NORMAL mode.
651 *
652 *
652 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
653 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
653 *
654 *
654 * @return RTEMS directive status codes:
655 * @return RTEMS directive status codes:
655 * - RTEMS_SUCCESSFUL - task restarted successfully
656 * - RTEMS_SUCCESSFUL - task restarted successfully
656 * - RTEMS_INVALID_ID - task id invalid
657 * - RTEMS_INVALID_ID - task id invalid
657 * - RTEMS_INCORRECT_STATE - task never started
658 * - RTEMS_INCORRECT_STATE - task never started
658 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
659 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
659 *
660 *
660 * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2,
661 * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2,
661 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected.
662 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected.
662 *
663 *
663 */
664 */
664
665
665 int status;
666 int status;
666
667
667 #ifdef PRINT_TASK_STATISTICS
668 #ifdef PRINT_TASK_STATISTICS
668 rtems_cpu_usage_reset();
669 rtems_cpu_usage_reset();
669 #endif
670 #endif
670
671
671 status = RTEMS_UNSATISFIED;
672 status = RTEMS_UNSATISFIED;
672
673
673 switch( lfrCurrentMode )
674 switch( lfrCurrentMode )
674 {
675 {
675 case LFR_MODE_STANDBY:
676 case LFR_MODE_STANDBY:
676 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks
677 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks
677 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
678 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
678 {
679 {
679 launch_spectral_matrix( );
680 launch_spectral_matrix( );
680 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
681 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
681 }
682 }
682 break;
683 break;
683 case LFR_MODE_BURST:
684 case LFR_MODE_BURST:
684 status = stop_current_mode(); // stop the current mode
685 status = stop_current_mode(); // stop the current mode
685 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks
686 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks
686 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
687 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
687 {
688 {
688 launch_spectral_matrix( );
689 launch_spectral_matrix( );
689 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
690 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
690 }
691 }
691 break;
692 break;
692 case LFR_MODE_SBM1:
693 case LFR_MODE_SBM1:
693 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
694 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
694 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
695 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
695 update_last_valid_transition_date( transitionCoarseTime );
696 update_last_valid_transition_date( transitionCoarseTime );
696 break;
697 break;
697 case LFR_MODE_SBM2:
698 case LFR_MODE_SBM2:
698 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
699 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
699 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
700 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
700 update_last_valid_transition_date( transitionCoarseTime );
701 update_last_valid_transition_date( transitionCoarseTime );
701 break;
702 break;
702 default:
703 default:
703 break;
704 break;
704 }
705 }
705
706
706 if (status != RTEMS_SUCCESSFUL)
707 if (status != RTEMS_SUCCESSFUL)
707 {
708 {
708 PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status)
709 PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status)
709 status = RTEMS_UNSATISFIED;
710 status = RTEMS_UNSATISFIED;
710 }
711 }
711
712
712 return status;
713 return status;
713 }
714 }
714
715
715 int enter_mode_burst( unsigned int transitionCoarseTime )
716 int enter_mode_burst( unsigned int transitionCoarseTime )
716 {
717 {
717 /** This function is used to start the BURST mode.
718 /** This function is used to start the BURST mode.
718 *
719 *
719 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
720 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
720 *
721 *
721 * @return RTEMS directive status codes:
722 * @return RTEMS directive status codes:
722 * - RTEMS_SUCCESSFUL - task restarted successfully
723 * - RTEMS_SUCCESSFUL - task restarted successfully
723 * - RTEMS_INVALID_ID - task id invalid
724 * - RTEMS_INVALID_ID - task id invalid
724 * - RTEMS_INCORRECT_STATE - task never started
725 * - RTEMS_INCORRECT_STATE - task never started
725 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
726 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
726 *
727 *
727 * The way the BURST mode is started does not depend on the LFR current mode.
728 * The way the BURST mode is started does not depend on the LFR current mode.
728 *
729 *
729 */
730 */
730
731
731
732
732 int status;
733 int status;
733
734
734 #ifdef PRINT_TASK_STATISTICS
735 #ifdef PRINT_TASK_STATISTICS
735 rtems_cpu_usage_reset();
736 rtems_cpu_usage_reset();
736 #endif
737 #endif
737
738
738 status = stop_current_mode(); // stop the current mode
739 status = stop_current_mode(); // stop the current mode
739 status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks
740 status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks
740 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
741 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
741 {
742 {
742 launch_spectral_matrix( );
743 launch_spectral_matrix( );
743 launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime );
744 launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime );
744 }
745 }
745
746
746 if (status != RTEMS_SUCCESSFUL)
747 if (status != RTEMS_SUCCESSFUL)
747 {
748 {
748 PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status)
749 PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status)
749 status = RTEMS_UNSATISFIED;
750 status = RTEMS_UNSATISFIED;
750 }
751 }
751
752
752 return status;
753 return status;
753 }
754 }
754
755
755 int enter_mode_sbm1( unsigned int transitionCoarseTime )
756 int enter_mode_sbm1( unsigned int transitionCoarseTime )
756 {
757 {
757 /** This function is used to start the SBM1 mode.
758 /** This function is used to start the SBM1 mode.
758 *
759 *
759 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
760 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
760 *
761 *
761 * @return RTEMS directive status codes:
762 * @return RTEMS directive status codes:
762 * - RTEMS_SUCCESSFUL - task restarted successfully
763 * - RTEMS_SUCCESSFUL - task restarted successfully
763 * - RTEMS_INVALID_ID - task id invalid
764 * - RTEMS_INVALID_ID - task id invalid
764 * - RTEMS_INCORRECT_STATE - task never started
765 * - RTEMS_INCORRECT_STATE - task never started
765 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
766 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
766 *
767 *
767 * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2,
768 * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2,
768 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
769 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
769 * cases, the acquisition is completely restarted.
770 * cases, the acquisition is completely restarted.
770 *
771 *
771 */
772 */
772
773
773 int status;
774 int status;
774
775
775 #ifdef PRINT_TASK_STATISTICS
776 #ifdef PRINT_TASK_STATISTICS
776 rtems_cpu_usage_reset();
777 rtems_cpu_usage_reset();
777 #endif
778 #endif
778
779
779 status = RTEMS_UNSATISFIED;
780 status = RTEMS_UNSATISFIED;
780
781
781 switch( lfrCurrentMode )
782 switch( lfrCurrentMode )
782 {
783 {
783 case LFR_MODE_STANDBY:
784 case LFR_MODE_STANDBY:
784 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks
785 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks
785 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
786 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
786 {
787 {
787 launch_spectral_matrix( );
788 launch_spectral_matrix( );
788 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
789 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
789 }
790 }
790 break;
791 break;
791 case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action
792 case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action
792 status = restart_asm_activities( LFR_MODE_SBM1 );
793 status = restart_asm_activities( LFR_MODE_SBM1 );
793 status = LFR_SUCCESSFUL;
794 status = LFR_SUCCESSFUL;
794 update_last_valid_transition_date( transitionCoarseTime );
795 update_last_valid_transition_date( transitionCoarseTime );
795 break;
796 break;
796 case LFR_MODE_BURST:
797 case LFR_MODE_BURST:
797 status = stop_current_mode(); // stop the current mode
798 status = stop_current_mode(); // stop the current mode
798 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks
799 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks
799 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
800 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
800 {
801 {
801 launch_spectral_matrix( );
802 launch_spectral_matrix( );
802 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
803 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
803 }
804 }
804 break;
805 break;
805 case LFR_MODE_SBM2:
806 case LFR_MODE_SBM2:
806 status = restart_asm_activities( LFR_MODE_SBM1 );
807 status = restart_asm_activities( LFR_MODE_SBM1 );
807 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
808 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
808 update_last_valid_transition_date( transitionCoarseTime );
809 update_last_valid_transition_date( transitionCoarseTime );
809 break;
810 break;
810 default:
811 default:
811 break;
812 break;
812 }
813 }
813
814
814 if (status != RTEMS_SUCCESSFUL)
815 if (status != RTEMS_SUCCESSFUL)
815 {
816 {
816 PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status);
817 PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status);
817 status = RTEMS_UNSATISFIED;
818 status = RTEMS_UNSATISFIED;
818 }
819 }
819
820
820 return status;
821 return status;
821 }
822 }
822
823
823 int enter_mode_sbm2( unsigned int transitionCoarseTime )
824 int enter_mode_sbm2( unsigned int transitionCoarseTime )
824 {
825 {
825 /** This function is used to start the SBM2 mode.
826 /** This function is used to start the SBM2 mode.
826 *
827 *
827 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
828 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
828 *
829 *
829 * @return RTEMS directive status codes:
830 * @return RTEMS directive status codes:
830 * - RTEMS_SUCCESSFUL - task restarted successfully
831 * - RTEMS_SUCCESSFUL - task restarted successfully
831 * - RTEMS_INVALID_ID - task id invalid
832 * - RTEMS_INVALID_ID - task id invalid
832 * - RTEMS_INCORRECT_STATE - task never started
833 * - RTEMS_INCORRECT_STATE - task never started
833 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
834 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
834 *
835 *
835 * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1,
836 * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1,
836 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
837 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
837 * cases, the acquisition is completely restarted.
838 * cases, the acquisition is completely restarted.
838 *
839 *
839 */
840 */
840
841
841 int status;
842 int status;
842
843
843 #ifdef PRINT_TASK_STATISTICS
844 #ifdef PRINT_TASK_STATISTICS
844 rtems_cpu_usage_reset();
845 rtems_cpu_usage_reset();
845 #endif
846 #endif
846
847
847 status = RTEMS_UNSATISFIED;
848 status = RTEMS_UNSATISFIED;
848
849
849 switch( lfrCurrentMode )
850 switch( lfrCurrentMode )
850 {
851 {
851 case LFR_MODE_STANDBY:
852 case LFR_MODE_STANDBY:
852 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks
853 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks
853 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
854 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
854 {
855 {
855 launch_spectral_matrix( );
856 launch_spectral_matrix( );
856 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
857 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
857 }
858 }
858 break;
859 break;
859 case LFR_MODE_NORMAL:
860 case LFR_MODE_NORMAL:
860 status = restart_asm_activities( LFR_MODE_SBM2 );
861 status = restart_asm_activities( LFR_MODE_SBM2 );
861 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
862 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
862 update_last_valid_transition_date( transitionCoarseTime );
863 update_last_valid_transition_date( transitionCoarseTime );
863 break;
864 break;
864 case LFR_MODE_BURST:
865 case LFR_MODE_BURST:
865 status = stop_current_mode(); // stop the current mode
866 status = stop_current_mode(); // stop the current mode
866 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks
867 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks
867 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
868 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
868 {
869 {
869 launch_spectral_matrix( );
870 launch_spectral_matrix( );
870 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
871 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
871 }
872 }
872 break;
873 break;
873 case LFR_MODE_SBM1:
874 case LFR_MODE_SBM1:
874 status = restart_asm_activities( LFR_MODE_SBM2 );
875 status = restart_asm_activities( LFR_MODE_SBM2 );
875 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
876 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
876 update_last_valid_transition_date( transitionCoarseTime );
877 update_last_valid_transition_date( transitionCoarseTime );
877 break;
878 break;
878 default:
879 default:
879 break;
880 break;
880 }
881 }
881
882
882 if (status != RTEMS_SUCCESSFUL)
883 if (status != RTEMS_SUCCESSFUL)
883 {
884 {
884 PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status)
885 PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status)
885 status = RTEMS_UNSATISFIED;
886 status = RTEMS_UNSATISFIED;
886 }
887 }
887
888
888 return status;
889 return status;
889 }
890 }
890
891
891 int restart_science_tasks( unsigned char lfrRequestedMode )
892 int restart_science_tasks( unsigned char lfrRequestedMode )
892 {
893 {
893 /** This function is used to restart all science tasks.
894 /** This function is used to restart all science tasks.
894 *
895 *
895 * @return RTEMS directive status codes:
896 * @return RTEMS directive status codes:
896 * - RTEMS_SUCCESSFUL - task restarted successfully
897 * - RTEMS_SUCCESSFUL - task restarted successfully
897 * - RTEMS_INVALID_ID - task id invalid
898 * - RTEMS_INVALID_ID - task id invalid
898 * - RTEMS_INCORRECT_STATE - task never started
899 * - RTEMS_INCORRECT_STATE - task never started
899 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
900 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
900 *
901 *
901 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
902 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
902 *
903 *
903 */
904 */
904
905
905 rtems_status_code status[10];
906 rtems_status_code status[10];
906 rtems_status_code ret;
907 rtems_status_code ret;
907
908
908 ret = RTEMS_SUCCESSFUL;
909 ret = RTEMS_SUCCESSFUL;
909
910
910 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
911 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
911 if (status[0] != RTEMS_SUCCESSFUL)
912 if (status[0] != RTEMS_SUCCESSFUL)
912 {
913 {
913 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
914 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
914 }
915 }
915
916
916 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
917 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
917 if (status[1] != RTEMS_SUCCESSFUL)
918 if (status[1] != RTEMS_SUCCESSFUL)
918 {
919 {
919 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
920 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
920 }
921 }
921
922
922 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
923 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
923 if (status[2] != RTEMS_SUCCESSFUL)
924 if (status[2] != RTEMS_SUCCESSFUL)
924 {
925 {
925 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
926 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
926 }
927 }
927
928
928 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
929 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
929 if (status[3] != RTEMS_SUCCESSFUL)
930 if (status[3] != RTEMS_SUCCESSFUL)
930 {
931 {
931 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
932 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
932 }
933 }
933
934
934 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
935 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
935 if (status[4] != RTEMS_SUCCESSFUL)
936 if (status[4] != RTEMS_SUCCESSFUL)
936 {
937 {
937 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
938 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
938 }
939 }
939
940
940 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
941 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
941 if (status[5] != RTEMS_SUCCESSFUL)
942 if (status[5] != RTEMS_SUCCESSFUL)
942 {
943 {
943 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
944 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
944 }
945 }
945
946
946 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
947 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
947 if (status[6] != RTEMS_SUCCESSFUL)
948 if (status[6] != RTEMS_SUCCESSFUL)
948 {
949 {
949 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
950 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
950 }
951 }
951
952
952 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
953 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
953 if (status[7] != RTEMS_SUCCESSFUL)
954 if (status[7] != RTEMS_SUCCESSFUL)
954 {
955 {
955 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
956 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
956 }
957 }
957
958
958 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
959 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
959 if (status[8] != RTEMS_SUCCESSFUL)
960 if (status[8] != RTEMS_SUCCESSFUL)
960 {
961 {
961 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
962 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
962 }
963 }
963
964
964 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
965 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
965 if (status[9] != RTEMS_SUCCESSFUL)
966 if (status[9] != RTEMS_SUCCESSFUL)
966 {
967 {
967 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
968 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
968 }
969 }
969
970
970 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
971 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
971 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
972 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
972 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
973 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
973 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
974 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
974 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
975 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
975 {
976 {
976 ret = RTEMS_UNSATISFIED;
977 ret = RTEMS_UNSATISFIED;
977 }
978 }
978
979
979 return ret;
980 return ret;
980 }
981 }
981
982
982 int restart_asm_tasks( unsigned char lfrRequestedMode )
983 int restart_asm_tasks( unsigned char lfrRequestedMode )
983 {
984 {
984 /** This function is used to restart average spectral matrices tasks.
985 /** This function is used to restart average spectral matrices tasks.
985 *
986 *
986 * @return RTEMS directive status codes:
987 * @return RTEMS directive status codes:
987 * - RTEMS_SUCCESSFUL - task restarted successfully
988 * - RTEMS_SUCCESSFUL - task restarted successfully
988 * - RTEMS_INVALID_ID - task id invalid
989 * - RTEMS_INVALID_ID - task id invalid
989 * - RTEMS_INCORRECT_STATE - task never started
990 * - RTEMS_INCORRECT_STATE - task never started
990 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
991 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
991 *
992 *
992 * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2
993 * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2
993 *
994 *
994 */
995 */
995
996
996 rtems_status_code status[6];
997 rtems_status_code status[6];
997 rtems_status_code ret;
998 rtems_status_code ret;
998
999
999 ret = RTEMS_SUCCESSFUL;
1000 ret = RTEMS_SUCCESSFUL;
1000
1001
1001 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
1002 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
1002 if (status[0] != RTEMS_SUCCESSFUL)
1003 if (status[0] != RTEMS_SUCCESSFUL)
1003 {
1004 {
1004 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
1005 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
1005 }
1006 }
1006
1007
1007 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
1008 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
1008 if (status[1] != RTEMS_SUCCESSFUL)
1009 if (status[1] != RTEMS_SUCCESSFUL)
1009 {
1010 {
1010 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
1011 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
1011 }
1012 }
1012
1013
1013 status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
1014 status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
1014 if (status[2] != RTEMS_SUCCESSFUL)
1015 if (status[2] != RTEMS_SUCCESSFUL)
1015 {
1016 {
1016 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2])
1017 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2])
1017 }
1018 }
1018
1019
1019 status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
1020 status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
1020 if (status[3] != RTEMS_SUCCESSFUL)
1021 if (status[3] != RTEMS_SUCCESSFUL)
1021 {
1022 {
1022 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3])
1023 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3])
1023 }
1024 }
1024
1025
1025 status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
1026 status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
1026 if (status[4] != RTEMS_SUCCESSFUL)
1027 if (status[4] != RTEMS_SUCCESSFUL)
1027 {
1028 {
1028 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4])
1029 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4])
1029 }
1030 }
1030
1031
1031 status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
1032 status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
1032 if (status[5] != RTEMS_SUCCESSFUL)
1033 if (status[5] != RTEMS_SUCCESSFUL)
1033 {
1034 {
1034 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5])
1035 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5])
1035 }
1036 }
1036
1037
1037 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
1038 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
1038 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
1039 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
1039 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1040 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1040 {
1041 {
1041 ret = RTEMS_UNSATISFIED;
1042 ret = RTEMS_UNSATISFIED;
1042 }
1043 }
1043
1044
1044 return ret;
1045 return ret;
1045 }
1046 }
1046
1047
1047 int suspend_science_tasks( void )
1048 int suspend_science_tasks( void )
1048 {
1049 {
1049 /** This function suspends the science tasks.
1050 /** This function suspends the science tasks.
1050 *
1051 *
1051 * @return RTEMS directive status codes:
1052 * @return RTEMS directive status codes:
1052 * - RTEMS_SUCCESSFUL - task restarted successfully
1053 * - RTEMS_SUCCESSFUL - task restarted successfully
1053 * - RTEMS_INVALID_ID - task id invalid
1054 * - RTEMS_INVALID_ID - task id invalid
1054 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1055 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1055 *
1056 *
1056 */
1057 */
1057
1058
1058 rtems_status_code status;
1059 rtems_status_code status;
1059
1060
1060 PRINTF("in suspend_science_tasks\n")
1061 PRINTF("in suspend_science_tasks\n")
1061
1062
1062 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1063 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1063 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1064 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1064 {
1065 {
1065 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1066 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1066 }
1067 }
1067 else
1068 else
1068 {
1069 {
1069 status = RTEMS_SUCCESSFUL;
1070 status = RTEMS_SUCCESSFUL;
1070 }
1071 }
1071 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1072 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1072 {
1073 {
1073 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1074 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1074 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1075 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1075 {
1076 {
1076 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1077 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1077 }
1078 }
1078 else
1079 else
1079 {
1080 {
1080 status = RTEMS_SUCCESSFUL;
1081 status = RTEMS_SUCCESSFUL;
1081 }
1082 }
1082 }
1083 }
1083 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1084 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1084 {
1085 {
1085 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1086 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1086 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1087 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1087 {
1088 {
1088 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1089 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1089 }
1090 }
1090 else
1091 else
1091 {
1092 {
1092 status = RTEMS_SUCCESSFUL;
1093 status = RTEMS_SUCCESSFUL;
1093 }
1094 }
1094 }
1095 }
1095 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1096 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1096 {
1097 {
1097 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1098 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1098 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1099 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1099 {
1100 {
1100 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1101 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1101 }
1102 }
1102 else
1103 else
1103 {
1104 {
1104 status = RTEMS_SUCCESSFUL;
1105 status = RTEMS_SUCCESSFUL;
1105 }
1106 }
1106 }
1107 }
1107 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1108 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1108 {
1109 {
1109 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1110 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1110 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1111 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1111 {
1112 {
1112 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1113 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1113 }
1114 }
1114 else
1115 else
1115 {
1116 {
1116 status = RTEMS_SUCCESSFUL;
1117 status = RTEMS_SUCCESSFUL;
1117 }
1118 }
1118 }
1119 }
1119 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1120 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1120 {
1121 {
1121 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1122 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1122 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1123 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1123 {
1124 {
1124 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1125 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1125 }
1126 }
1126 else
1127 else
1127 {
1128 {
1128 status = RTEMS_SUCCESSFUL;
1129 status = RTEMS_SUCCESSFUL;
1129 }
1130 }
1130 }
1131 }
1131 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
1132 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
1132 {
1133 {
1133 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
1134 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
1134 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1135 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1135 {
1136 {
1136 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
1137 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
1137 }
1138 }
1138 else
1139 else
1139 {
1140 {
1140 status = RTEMS_SUCCESSFUL;
1141 status = RTEMS_SUCCESSFUL;
1141 }
1142 }
1142 }
1143 }
1143 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
1144 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
1144 {
1145 {
1145 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
1146 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
1146 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1147 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1147 {
1148 {
1148 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
1149 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
1149 }
1150 }
1150 else
1151 else
1151 {
1152 {
1152 status = RTEMS_SUCCESSFUL;
1153 status = RTEMS_SUCCESSFUL;
1153 }
1154 }
1154 }
1155 }
1155 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
1156 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
1156 {
1157 {
1157 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
1158 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
1158 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1159 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1159 {
1160 {
1160 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
1161 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
1161 }
1162 }
1162 else
1163 else
1163 {
1164 {
1164 status = RTEMS_SUCCESSFUL;
1165 status = RTEMS_SUCCESSFUL;
1165 }
1166 }
1166 }
1167 }
1167 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
1168 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
1168 {
1169 {
1169 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
1170 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
1170 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1171 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1171 {
1172 {
1172 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
1173 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
1173 }
1174 }
1174 else
1175 else
1175 {
1176 {
1176 status = RTEMS_SUCCESSFUL;
1177 status = RTEMS_SUCCESSFUL;
1177 }
1178 }
1178 }
1179 }
1179
1180
1180 return status;
1181 return status;
1181 }
1182 }
1182
1183
1183 int suspend_asm_tasks( void )
1184 int suspend_asm_tasks( void )
1184 {
1185 {
1185 /** This function suspends the science tasks.
1186 /** This function suspends the science tasks.
1186 *
1187 *
1187 * @return RTEMS directive status codes:
1188 * @return RTEMS directive status codes:
1188 * - RTEMS_SUCCESSFUL - task restarted successfully
1189 * - RTEMS_SUCCESSFUL - task restarted successfully
1189 * - RTEMS_INVALID_ID - task id invalid
1190 * - RTEMS_INVALID_ID - task id invalid
1190 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1191 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1191 *
1192 *
1192 */
1193 */
1193
1194
1194 rtems_status_code status;
1195 rtems_status_code status;
1195
1196
1196 PRINTF("in suspend_science_tasks\n")
1197 PRINTF("in suspend_science_tasks\n")
1197
1198
1198 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1199 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1199 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1200 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1200 {
1201 {
1201 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1202 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1202 }
1203 }
1203 else
1204 else
1204 {
1205 {
1205 status = RTEMS_SUCCESSFUL;
1206 status = RTEMS_SUCCESSFUL;
1206 }
1207 }
1207
1208
1208 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1209 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1209 {
1210 {
1210 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1211 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1211 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1212 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1212 {
1213 {
1213 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1214 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1214 }
1215 }
1215 else
1216 else
1216 {
1217 {
1217 status = RTEMS_SUCCESSFUL;
1218 status = RTEMS_SUCCESSFUL;
1218 }
1219 }
1219 }
1220 }
1220
1221
1221 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1222 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1222 {
1223 {
1223 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1224 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1224 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1225 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1225 {
1226 {
1226 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1227 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1227 }
1228 }
1228 else
1229 else
1229 {
1230 {
1230 status = RTEMS_SUCCESSFUL;
1231 status = RTEMS_SUCCESSFUL;
1231 }
1232 }
1232 }
1233 }
1233
1234
1234 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1235 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1235 {
1236 {
1236 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1237 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1237 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1238 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1238 {
1239 {
1239 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1240 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1240 }
1241 }
1241 else
1242 else
1242 {
1243 {
1243 status = RTEMS_SUCCESSFUL;
1244 status = RTEMS_SUCCESSFUL;
1244 }
1245 }
1245 }
1246 }
1246
1247
1247 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1248 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1248 {
1249 {
1249 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1250 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1250 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1251 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1251 {
1252 {
1252 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1253 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1253 }
1254 }
1254 else
1255 else
1255 {
1256 {
1256 status = RTEMS_SUCCESSFUL;
1257 status = RTEMS_SUCCESSFUL;
1257 }
1258 }
1258 }
1259 }
1259
1260
1260 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1261 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1261 {
1262 {
1262 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1263 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1263 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1264 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1264 {
1265 {
1265 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1266 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1266 }
1267 }
1267 else
1268 else
1268 {
1269 {
1269 status = RTEMS_SUCCESSFUL;
1270 status = RTEMS_SUCCESSFUL;
1270 }
1271 }
1271 }
1272 }
1272
1273
1273 return status;
1274 return status;
1274 }
1275 }
1275
1276
1276 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
1277 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
1277 {
1278 {
1278
1279
1279 WFP_reset_current_ring_nodes();
1280 WFP_reset_current_ring_nodes();
1280
1281
1281 reset_waveform_picker_regs();
1282 reset_waveform_picker_regs();
1282
1283
1283 set_wfp_burst_enable_register( mode );
1284 set_wfp_burst_enable_register( mode );
1284
1285
1285 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1286 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1286 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1287 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1287
1288
1288 if (transitionCoarseTime == 0)
1289 if (transitionCoarseTime == 0)
1289 {
1290 {
1290 // instant transition means transition on the next valid date
1291 // instant transition means transition on the next valid date
1291 // this is mandatory to have a good snapshot period and a good correction of the snapshot period
1292 // this is mandatory to have a good snapshot period and a good correction of the snapshot period
1292 waveform_picker_regs->start_date = time_management_regs->coarse_time + 1;
1293 waveform_picker_regs->start_date = time_management_regs->coarse_time + 1;
1293 }
1294 }
1294 else
1295 else
1295 {
1296 {
1296 waveform_picker_regs->start_date = transitionCoarseTime;
1297 waveform_picker_regs->start_date = transitionCoarseTime;
1297 }
1298 }
1298
1299
1299 update_last_valid_transition_date(waveform_picker_regs->start_date);
1300 update_last_valid_transition_date(waveform_picker_regs->start_date);
1300
1301
1301 }
1302 }
1302
1303
1303 void launch_spectral_matrix( void )
1304 void launch_spectral_matrix( void )
1304 {
1305 {
1305 SM_reset_current_ring_nodes();
1306 SM_reset_current_ring_nodes();
1306
1307
1307 reset_spectral_matrix_regs();
1308 reset_spectral_matrix_regs();
1308
1309
1309 reset_nb_sm();
1310 reset_nb_sm();
1310
1311
1311 set_sm_irq_onNewMatrix( 1 );
1312 set_sm_irq_onNewMatrix( 1 );
1312
1313
1313 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
1314 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
1314 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
1315 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
1315
1316
1316 }
1317 }
1317
1318
1318 void set_sm_irq_onNewMatrix( unsigned char value )
1319 void set_sm_irq_onNewMatrix( unsigned char value )
1319 {
1320 {
1320 if (value == 1)
1321 if (value == 1)
1321 {
1322 {
1322 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
1323 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
1323 }
1324 }
1324 else
1325 else
1325 {
1326 {
1326 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
1327 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
1327 }
1328 }
1328 }
1329 }
1329
1330
1330 void set_sm_irq_onError( unsigned char value )
1331 void set_sm_irq_onError( unsigned char value )
1331 {
1332 {
1332 if (value == 1)
1333 if (value == 1)
1333 {
1334 {
1334 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
1335 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
1335 }
1336 }
1336 else
1337 else
1337 {
1338 {
1338 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
1339 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
1339 }
1340 }
1340 }
1341 }
1341
1342
1342 //*****************************
1343 //*****************************
1343 // CONFIGURE CALIBRATION SIGNAL
1344 // CONFIGURE CALIBRATION SIGNAL
1344 void setCalibrationPrescaler( unsigned int prescaler )
1345 void setCalibrationPrescaler( unsigned int prescaler )
1345 {
1346 {
1346 // prescaling of the master clock (25 MHz)
1347 // prescaling of the master clock (25 MHz)
1347 // master clock is divided by 2^prescaler
1348 // master clock is divided by 2^prescaler
1348 time_management_regs->calPrescaler = prescaler;
1349 time_management_regs->calPrescaler = prescaler;
1349 }
1350 }
1350
1351
1351 void setCalibrationDivisor( unsigned int divisionFactor )
1352 void setCalibrationDivisor( unsigned int divisionFactor )
1352 {
1353 {
1353 // division of the prescaled clock by the division factor
1354 // division of the prescaled clock by the division factor
1354 time_management_regs->calDivisor = divisionFactor;
1355 time_management_regs->calDivisor = divisionFactor;
1355 }
1356 }
1356
1357
1357 void setCalibrationData( void ){
1358 void setCalibrationData( void ){
1358 unsigned int k;
1359 unsigned int k;
1359 unsigned short data;
1360 unsigned short data;
1360 float val;
1361 float val;
1361 float f0;
1362 float f0;
1362 float f1;
1363 float f1;
1363 float fs;
1364 float fs;
1364 float Ts;
1365 float Ts;
1365 float scaleFactor;
1366 float scaleFactor;
1366
1367
1367 f0 = 625;
1368 f0 = 625;
1368 f1 = 10000;
1369 f1 = 10000;
1369 fs = 160256.410;
1370 fs = 160256.410;
1370 Ts = 1. / fs;
1371 Ts = 1. / fs;
1371 scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
1372 scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
1372
1373
1373 time_management_regs->calDataPtr = 0x00;
1374 time_management_regs->calDataPtr = 0x00;
1374
1375
1375 // build the signal for the SCM calibration
1376 // build the signal for the SCM calibration
1376 for (k=0; k<256; k++)
1377 for (k=0; k<256; k++)
1377 {
1378 {
1378 val = sin( 2 * pi * f0 * k * Ts )
1379 val = sin( 2 * pi * f0 * k * Ts )
1379 + sin( 2 * pi * f1 * k * Ts );
1380 + sin( 2 * pi * f1 * k * Ts );
1380 data = (unsigned short) ((val * scaleFactor) + 2048);
1381 data = (unsigned short) ((val * scaleFactor) + 2048);
1381 time_management_regs->calData = data & 0xfff;
1382 time_management_regs->calData = data & 0xfff;
1382 }
1383 }
1383 }
1384 }
1384
1385
1385 void setCalibrationDataInterleaved( void ){
1386 void setCalibrationDataInterleaved( void ){
1386 unsigned int k;
1387 unsigned int k;
1387 float val;
1388 float val;
1388 float f0;
1389 float f0;
1389 float f1;
1390 float f1;
1390 float fs;
1391 float fs;
1391 float Ts;
1392 float Ts;
1392 unsigned short data[384];
1393 unsigned short data[384];
1393 unsigned char *dataPtr;
1394 unsigned char *dataPtr;
1394
1395
1395 f0 = 625;
1396 f0 = 625;
1396 f1 = 10000;
1397 f1 = 10000;
1397 fs = 240384.615;
1398 fs = 240384.615;
1398 Ts = 1. / fs;
1399 Ts = 1. / fs;
1399
1400
1400 time_management_regs->calDataPtr = 0x00;
1401 time_management_regs->calDataPtr = 0x00;
1401
1402
1402 // build the signal for the SCM calibration
1403 // build the signal for the SCM calibration
1403 for (k=0; k<384; k++)
1404 for (k=0; k<384; k++)
1404 {
1405 {
1405 val = sin( 2 * pi * f0 * k * Ts )
1406 val = sin( 2 * pi * f0 * k * Ts )
1406 + sin( 2 * pi * f1 * k * Ts );
1407 + sin( 2 * pi * f1 * k * Ts );
1407 data[k] = (unsigned short) (val * 512 + 2048);
1408 data[k] = (unsigned short) (val * 512 + 2048);
1408 }
1409 }
1409
1410
1410 // write the signal in interleaved mode
1411 // write the signal in interleaved mode
1411 for (k=0; k<128; k++)
1412 for (k=0; k<128; k++)
1412 {
1413 {
1413 dataPtr = (unsigned char*) &data[k*3 + 2];
1414 dataPtr = (unsigned char*) &data[k*3 + 2];
1414 time_management_regs->calData = (data[k*3] & 0xfff)
1415 time_management_regs->calData = (data[k*3] & 0xfff)
1415 + ( (dataPtr[0] & 0x3f) << 12);
1416 + ( (dataPtr[0] & 0x3f) << 12);
1416 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
1417 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
1417 + ( (dataPtr[1] & 0x3f) << 12);
1418 + ( (dataPtr[1] & 0x3f) << 12);
1418 }
1419 }
1419 }
1420 }
1420
1421
1421 void setCalibrationReload( bool state)
1422 void setCalibrationReload( bool state)
1422 {
1423 {
1423 if (state == true)
1424 if (state == true)
1424 {
1425 {
1425 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
1426 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
1426 }
1427 }
1427 else
1428 else
1428 {
1429 {
1429 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
1430 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
1430 }
1431 }
1431 }
1432 }
1432
1433
1433 void setCalibrationEnable( bool state )
1434 void setCalibrationEnable( bool state )
1434 {
1435 {
1435 // this bit drives the multiplexer
1436 // this bit drives the multiplexer
1436 if (state == true)
1437 if (state == true)
1437 {
1438 {
1438 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
1439 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
1439 }
1440 }
1440 else
1441 else
1441 {
1442 {
1442 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
1443 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
1443 }
1444 }
1444 }
1445 }
1445
1446
1446 void setCalibrationInterleaved( bool state )
1447 void setCalibrationInterleaved( bool state )
1447 {
1448 {
1448 // this bit drives the multiplexer
1449 // this bit drives the multiplexer
1449 if (state == true)
1450 if (state == true)
1450 {
1451 {
1451 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
1452 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
1452 }
1453 }
1453 else
1454 else
1454 {
1455 {
1455 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
1456 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
1456 }
1457 }
1457 }
1458 }
1458
1459
1459 void setCalibration( bool state )
1460 void setCalibration( bool state )
1460 {
1461 {
1461 if (state == true)
1462 if (state == true)
1462 {
1463 {
1463 setCalibrationEnable( true );
1464 setCalibrationEnable( true );
1464 setCalibrationReload( false );
1465 setCalibrationReload( false );
1465 set_hk_lfr_calib_enable( true );
1466 set_hk_lfr_calib_enable( true );
1466 }
1467 }
1467 else
1468 else
1468 {
1469 {
1469 setCalibrationEnable( false );
1470 setCalibrationEnable( false );
1470 setCalibrationReload( true );
1471 setCalibrationReload( true );
1471 set_hk_lfr_calib_enable( false );
1472 set_hk_lfr_calib_enable( false );
1472 }
1473 }
1473 }
1474 }
1474
1475
1475 void configureCalibration( bool interleaved )
1476 void configureCalibration( bool interleaved )
1476 {
1477 {
1477 setCalibration( false );
1478 setCalibration( false );
1478 if ( interleaved == true )
1479 if ( interleaved == true )
1479 {
1480 {
1480 setCalibrationInterleaved( true );
1481 setCalibrationInterleaved( true );
1481 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1482 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1482 setCalibrationDivisor( 26 ); // => 240 384
1483 setCalibrationDivisor( 26 ); // => 240 384
1483 setCalibrationDataInterleaved();
1484 setCalibrationDataInterleaved();
1484 }
1485 }
1485 else
1486 else
1486 {
1487 {
1487 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1488 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1488 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1489 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1489 setCalibrationData();
1490 setCalibrationData();
1490 }
1491 }
1491 }
1492 }
1492
1493
1493 //****************
1494 //****************
1494 // CLOSING ACTIONS
1495 // CLOSING ACTIONS
1495 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1496 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1496 {
1497 {
1497 /** This function is used to update the HK packets statistics after a successful TC execution.
1498 /** This function is used to update the HK packets statistics after a successful TC execution.
1498 *
1499 *
1499 * @param TC points to the TC being processed
1500 * @param TC points to the TC being processed
1500 * @param time is the time used to date the TC execution
1501 * @param time is the time used to date the TC execution
1501 *
1502 *
1502 */
1503 */
1503
1504
1504 unsigned int val;
1505 unsigned int val;
1505
1506
1506 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1507 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1507 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1508 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1508 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1509 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1509 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1510 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1510 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1511 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1511 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1512 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1512 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1513 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1513 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1514 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1514 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1515 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1515 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1516 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1516 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1517 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1517 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1518 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1518
1519
1519 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1520 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1520 val++;
1521 val++;
1521 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1522 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1522 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1523 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1523 }
1524 }
1524
1525
1525 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1526 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1526 {
1527 {
1527 /** This function is used to update the HK packets statistics after a TC rejection.
1528 /** This function is used to update the HK packets statistics after a TC rejection.
1528 *
1529 *
1529 * @param TC points to the TC being processed
1530 * @param TC points to the TC being processed
1530 * @param time is the time used to date the TC rejection
1531 * @param time is the time used to date the TC rejection
1531 *
1532 *
1532 */
1533 */
1533
1534
1534 unsigned int val;
1535 unsigned int val;
1535
1536
1536 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1537 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1537 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1538 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1538 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1539 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1539 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1540 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1540 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1541 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1541 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1542 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1542 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1543 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1543 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1544 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1544 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1545 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1545 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1546 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1546 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1547 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1547 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1548 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1548
1549
1549 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1550 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1550 val++;
1551 val++;
1551 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1552 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1552 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1553 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1553 }
1554 }
1554
1555
1555 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1556 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1556 {
1557 {
1557 /** This function is the last step of the TC execution workflow.
1558 /** This function is the last step of the TC execution workflow.
1558 *
1559 *
1559 * @param TC points to the TC being processed
1560 * @param TC points to the TC being processed
1560 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1561 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1561 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1562 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1562 * @param time is the time used to date the TC execution
1563 * @param time is the time used to date the TC execution
1563 *
1564 *
1564 */
1565 */
1565
1566
1566 unsigned char requestedMode;
1567 unsigned char requestedMode;
1567
1568
1568 if (result == LFR_SUCCESSFUL)
1569 if (result == LFR_SUCCESSFUL)
1569 {
1570 {
1570 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1571 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1571 &
1572 &
1572 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1573 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1573 )
1574 )
1574 {
1575 {
1575 send_tm_lfr_tc_exe_success( TC, queue_id );
1576 send_tm_lfr_tc_exe_success( TC, queue_id );
1576 }
1577 }
1577 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1578 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1578 {
1579 {
1579 //**********************************
1580 //**********************************
1580 // UPDATE THE LFRMODE LOCAL VARIABLE
1581 // UPDATE THE LFRMODE LOCAL VARIABLE
1581 requestedMode = TC->dataAndCRC[1];
1582 requestedMode = TC->dataAndCRC[1];
1582 updateLFRCurrentMode( requestedMode );
1583 updateLFRCurrentMode( requestedMode );
1583 }
1584 }
1584 }
1585 }
1585 else if (result == LFR_EXE_ERROR)
1586 else if (result == LFR_EXE_ERROR)
1586 {
1587 {
1587 send_tm_lfr_tc_exe_error( TC, queue_id );
1588 send_tm_lfr_tc_exe_error( TC, queue_id );
1588 }
1589 }
1589 }
1590 }
1590
1591
1591 //***************************
1592 //***************************
1592 // Interrupt Service Routines
1593 // Interrupt Service Routines
1593 rtems_isr commutation_isr1( rtems_vector_number vector )
1594 rtems_isr commutation_isr1( rtems_vector_number vector )
1594 {
1595 {
1595 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1596 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1596 PRINTF("In commutation_isr1 *** Error sending event to DUMB\n")
1597 PRINTF("In commutation_isr1 *** Error sending event to DUMB\n")
1597 }
1598 }
1598 }
1599 }
1599
1600
1600 rtems_isr commutation_isr2( rtems_vector_number vector )
1601 rtems_isr commutation_isr2( rtems_vector_number vector )
1601 {
1602 {
1602 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1603 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1603 PRINTF("In commutation_isr2 *** Error sending event to DUMB\n")
1604 PRINTF("In commutation_isr2 *** Error sending event to DUMB\n")
1604 }
1605 }
1605 }
1606 }
1606
1607
1607 //****************
1608 //****************
1608 // OTHER FUNCTIONS
1609 // OTHER FUNCTIONS
1609 void updateLFRCurrentMode( unsigned char requestedMode )
1610 void updateLFRCurrentMode( unsigned char requestedMode )
1610 {
1611 {
1611 /** This function updates the value of the global variable lfrCurrentMode.
1612 /** This function updates the value of the global variable lfrCurrentMode.
1612 *
1613 *
1613 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1614 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1614 *
1615 *
1615 */
1616 */
1616
1617
1617 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1618 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1618 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1619 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1619 lfrCurrentMode = requestedMode;
1620 lfrCurrentMode = requestedMode;
1620 }
1621 }
1621
1622
1622 void set_lfr_soft_reset( unsigned char value )
1623 void set_lfr_soft_reset( unsigned char value )
1623 {
1624 {
1624 if (value == 1)
1625 if (value == 1)
1625 {
1626 {
1626 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1627 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1627 }
1628 }
1628 else
1629 else
1629 {
1630 {
1630 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1631 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1631 }
1632 }
1632 }
1633 }
1633
1634
1634 void reset_lfr( void )
1635 void reset_lfr( void )
1635 {
1636 {
1636 set_lfr_soft_reset( 1 );
1637 set_lfr_soft_reset( 1 );
1637
1638
1638 set_lfr_soft_reset( 0 );
1639 set_lfr_soft_reset( 0 );
1639
1640
1640 set_hk_lfr_sc_potential_flag( true );
1641 set_hk_lfr_sc_potential_flag( true );
1641 }
1642 }
@@ -1,1619 +1,1660
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
323
324 flag = LFR_DEFAULT;
324 flag = LFR_DEFAULT;
325
325
326 flag = check_sy_lfr_filter_parameters( TC, queue_id );
326 flag = check_sy_lfr_filter_parameters( TC, queue_id );
327
327
328 if (flag == LFR_SUCCESSFUL)
328 if (flag == LFR_SUCCESSFUL)
329 {
329 {
330 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
330 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
331 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
331 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
332 parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ];
332 parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ];
333 parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ];
333 parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ];
334 parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ];
334 parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ];
335 parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ];
335 parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ];
336 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
336 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
337 parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ];
337 parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ];
338 parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ];
338 parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ];
339 parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ];
339 parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ];
340 parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ];
340 parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ];
341 parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ];
341 parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ];
342 parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ];
342 parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ];
343 parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ];
343 parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ];
344 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
344 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
345
345
346 //****************************
346 //****************************
347 // store PAS filter parameters
347 // store PAS filter parameters
348 // sy_lfr_pas_filter_enabled
348 // sy_lfr_pas_filter_enabled
349 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
349 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
350 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 );
350 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 );
351 // sy_lfr_pas_filter_modulus
351 // sy_lfr_pas_filter_modulus
352 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
352 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
353 // sy_lfr_pas_filter_tbad
353 // sy_lfr_pas_filter_tbad
354 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
354 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
355 parameter_dump_packet.sy_lfr_pas_filter_tbad );
355 parameter_dump_packet.sy_lfr_pas_filter_tbad );
356 // sy_lfr_pas_filter_offset
356 // sy_lfr_pas_filter_offset
357 filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset;
357 filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset;
358 // sy_lfr_pas_filter_shift
358 // sy_lfr_pas_filter_shift
359 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
359 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
360 parameter_dump_packet.sy_lfr_pas_filter_shift );
360 parameter_dump_packet.sy_lfr_pas_filter_shift );
361
361
362 //****************************************************
362 //****************************************************
363 // store the parameter sy_lfr_sc_rw_delta_f as a float
363 // store the parameter sy_lfr_sc_rw_delta_f as a float
364 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
364 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
365 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
365 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
366 }
366 }
367
367
368 return flag;
368 return flag;
369 }
369 }
370
370
371 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
371 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
372 {
372 {
373 /** This function updates the LFR registers with the incoming sbm2 parameters.
373 /** This function updates the LFR registers with the incoming sbm2 parameters.
374 *
374 *
375 * @param TC points to the TeleCommand packet that is being processed
375 * @param TC points to the TeleCommand packet that is being processed
376 * @param queue_id is the id of the queue which handles TM related to this execution step
376 * @param queue_id is the id of the queue which handles TM related to this execution step
377 *
377 *
378 */
378 */
379
379
380 unsigned int address;
380 unsigned int address;
381 rtems_status_code status;
381 rtems_status_code status;
382 unsigned int freq;
382 unsigned int freq;
383 unsigned int bin;
383 unsigned int bin;
384 unsigned int coeff;
384 unsigned int coeff;
385 unsigned char *kCoeffPtr;
385 unsigned char *kCoeffPtr;
386 unsigned char *kCoeffDumpPtr;
386 unsigned char *kCoeffDumpPtr;
387
387
388 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
388 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
389 // F0 => 11 bins
389 // F0 => 11 bins
390 // F1 => 13 bins
390 // F1 => 13 bins
391 // F2 => 12 bins
391 // F2 => 12 bins
392 // 36 bins to dump in two packets (30 bins max per packet)
392 // 36 bins to dump in two packets (30 bins max per packet)
393
393
394 //*********
394 //*********
395 // PACKET 1
395 // PACKET 1
396 // 11 F0 bins, 13 F1 bins and 6 F2 bins
396 // 11 F0 bins, 13 F1 bins and 6 F2 bins
397 kcoefficients_dump_1.destinationID = TC->sourceID;
397 kcoefficients_dump_1.destinationID = TC->sourceID;
398 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
398 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
399 for( freq=0;
399 for( freq=0;
400 freq<NB_BINS_COMPRESSED_SM_F0;
400 freq<NB_BINS_COMPRESSED_SM_F0;
401 freq++ )
401 freq++ )
402 {
402 {
403 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
403 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
404 bin = freq;
404 bin = freq;
405 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
405 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
406 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
406 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
407 {
407 {
408 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
408 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
409 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
409 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
410 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
410 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
411 }
411 }
412 }
412 }
413 for( freq=NB_BINS_COMPRESSED_SM_F0;
413 for( freq=NB_BINS_COMPRESSED_SM_F0;
414 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
414 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
415 freq++ )
415 freq++ )
416 {
416 {
417 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
417 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
418 bin = freq - NB_BINS_COMPRESSED_SM_F0;
418 bin = freq - NB_BINS_COMPRESSED_SM_F0;
419 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
419 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
420 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
420 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
421 {
421 {
422 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
422 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
423 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
423 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
424 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
424 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
425 }
425 }
426 }
426 }
427 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
427 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
428 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
428 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
429 freq++ )
429 freq++ )
430 {
430 {
431 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
431 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
432 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
432 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
433 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
433 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
434 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
434 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
435 {
435 {
436 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
436 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
437 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
437 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
438 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
438 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
439 }
439 }
440 }
440 }
441 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
441 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
442 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
442 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
443 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
443 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
444 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
444 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
445 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
445 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
446 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
446 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
447 // SEND DATA
447 // SEND DATA
448 kcoefficient_node_1.status = 1;
448 kcoefficient_node_1.status = 1;
449 address = (unsigned int) &kcoefficient_node_1;
449 address = (unsigned int) &kcoefficient_node_1;
450 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
450 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
451 if (status != RTEMS_SUCCESSFUL) {
451 if (status != RTEMS_SUCCESSFUL) {
452 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
452 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
453 }
453 }
454
454
455 //********
455 //********
456 // PACKET 2
456 // PACKET 2
457 // 6 F2 bins
457 // 6 F2 bins
458 kcoefficients_dump_2.destinationID = TC->sourceID;
458 kcoefficients_dump_2.destinationID = TC->sourceID;
459 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
459 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
460 for( freq=0; freq<6; freq++ )
460 for( freq=0; freq<6; freq++ )
461 {
461 {
462 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
462 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
463 bin = freq + 6;
463 bin = freq + 6;
464 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
464 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
465 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
465 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
466 {
466 {
467 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
467 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
468 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
468 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
469 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
469 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
470 }
470 }
471 }
471 }
472 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
472 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
473 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
473 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
474 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
474 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
475 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
475 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
476 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
476 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
477 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
477 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
478 // SEND DATA
478 // SEND DATA
479 kcoefficient_node_2.status = 1;
479 kcoefficient_node_2.status = 1;
480 address = (unsigned int) &kcoefficient_node_2;
480 address = (unsigned int) &kcoefficient_node_2;
481 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
481 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
482 if (status != RTEMS_SUCCESSFUL) {
482 if (status != RTEMS_SUCCESSFUL) {
483 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
483 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
484 }
484 }
485
485
486 return status;
486 return status;
487 }
487 }
488
488
489 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
489 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
490 {
490 {
491 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
491 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
492 *
492 *
493 * @param queue_id is the id of the queue which handles TM related to this execution step.
493 * @param queue_id is the id of the queue which handles TM related to this execution step.
494 *
494 *
495 * @return RTEMS directive status codes:
495 * @return RTEMS directive status codes:
496 * - RTEMS_SUCCESSFUL - message sent successfully
496 * - RTEMS_SUCCESSFUL - message sent successfully
497 * - RTEMS_INVALID_ID - invalid queue id
497 * - RTEMS_INVALID_ID - invalid queue id
498 * - RTEMS_INVALID_SIZE - invalid message size
498 * - RTEMS_INVALID_SIZE - invalid message size
499 * - RTEMS_INVALID_ADDRESS - buffer is NULL
499 * - RTEMS_INVALID_ADDRESS - buffer is NULL
500 * - RTEMS_UNSATISFIED - out of message buffers
500 * - RTEMS_UNSATISFIED - out of message buffers
501 * - RTEMS_TOO_MANY - queue s limit has been reached
501 * - RTEMS_TOO_MANY - queue s limit has been reached
502 *
502 *
503 */
503 */
504
504
505 int status;
505 int status;
506
506
507 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
507 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
508 parameter_dump_packet.destinationID = TC->sourceID;
508 parameter_dump_packet.destinationID = TC->sourceID;
509
509
510 // UPDATE TIME
510 // UPDATE TIME
511 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
511 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
512 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
512 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
513 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
513 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
514 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
514 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
515 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
515 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
516 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
516 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
517 // SEND DATA
517 // SEND DATA
518 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
518 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
519 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
519 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
520 if (status != RTEMS_SUCCESSFUL) {
520 if (status != RTEMS_SUCCESSFUL) {
521 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
521 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
522 }
522 }
523
523
524 return status;
524 return status;
525 }
525 }
526
526
527 //***********************
527 //***********************
528 // NORMAL MODE PARAMETERS
528 // NORMAL MODE PARAMETERS
529
529
530 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
530 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
531 {
531 {
532 unsigned char msb;
532 unsigned char msb;
533 unsigned char lsb;
533 unsigned char lsb;
534 int flag;
534 int flag;
535 float aux;
535 float aux;
536 rtems_status_code status;
536 rtems_status_code status;
537
537
538 unsigned int sy_lfr_n_swf_l;
538 unsigned int sy_lfr_n_swf_l;
539 unsigned int sy_lfr_n_swf_p;
539 unsigned int sy_lfr_n_swf_p;
540 unsigned int sy_lfr_n_asm_p;
540 unsigned int sy_lfr_n_asm_p;
541 unsigned char sy_lfr_n_bp_p0;
541 unsigned char sy_lfr_n_bp_p0;
542 unsigned char sy_lfr_n_bp_p1;
542 unsigned char sy_lfr_n_bp_p1;
543 unsigned char sy_lfr_n_cwf_long_f3;
543 unsigned char sy_lfr_n_cwf_long_f3;
544
544
545 flag = LFR_SUCCESSFUL;
545 flag = LFR_SUCCESSFUL;
546
546
547 //***************
547 //***************
548 // get parameters
548 // get parameters
549 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
549 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
550 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
550 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
551 sy_lfr_n_swf_l = msb * 256 + lsb;
551 sy_lfr_n_swf_l = msb * 256 + lsb;
552
552
553 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
553 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
554 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
554 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
555 sy_lfr_n_swf_p = msb * 256 + lsb;
555 sy_lfr_n_swf_p = msb * 256 + lsb;
556
556
557 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
557 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
558 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
558 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
559 sy_lfr_n_asm_p = msb * 256 + lsb;
559 sy_lfr_n_asm_p = msb * 256 + lsb;
560
560
561 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
561 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
562
562
563 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
563 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
564
564
565 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
565 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
566
566
567 //******************
567 //******************
568 // check consistency
568 // check consistency
569 // sy_lfr_n_swf_l
569 // sy_lfr_n_swf_l
570 if (sy_lfr_n_swf_l != 2048)
570 if (sy_lfr_n_swf_l != 2048)
571 {
571 {
572 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
572 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
573 flag = WRONG_APP_DATA;
573 flag = WRONG_APP_DATA;
574 }
574 }
575 // sy_lfr_n_swf_p
575 // sy_lfr_n_swf_p
576 if (flag == LFR_SUCCESSFUL)
576 if (flag == LFR_SUCCESSFUL)
577 {
577 {
578 if ( sy_lfr_n_swf_p < 22 )
578 if ( sy_lfr_n_swf_p < 22 )
579 {
579 {
580 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
580 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
581 flag = WRONG_APP_DATA;
581 flag = WRONG_APP_DATA;
582 }
582 }
583 }
583 }
584 // sy_lfr_n_bp_p0
584 // sy_lfr_n_bp_p0
585 if (flag == LFR_SUCCESSFUL)
585 if (flag == LFR_SUCCESSFUL)
586 {
586 {
587 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
587 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
588 {
588 {
589 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
589 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
590 flag = WRONG_APP_DATA;
590 flag = WRONG_APP_DATA;
591 }
591 }
592 }
592 }
593 // sy_lfr_n_asm_p
593 // sy_lfr_n_asm_p
594 if (flag == LFR_SUCCESSFUL)
594 if (flag == LFR_SUCCESSFUL)
595 {
595 {
596 if (sy_lfr_n_asm_p == 0)
596 if (sy_lfr_n_asm_p == 0)
597 {
597 {
598 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
598 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
599 flag = WRONG_APP_DATA;
599 flag = WRONG_APP_DATA;
600 }
600 }
601 }
601 }
602 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
602 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
603 if (flag == LFR_SUCCESSFUL)
603 if (flag == LFR_SUCCESSFUL)
604 {
604 {
605 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
605 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
606 if (aux > FLOAT_EQUAL_ZERO)
606 if (aux > FLOAT_EQUAL_ZERO)
607 {
607 {
608 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
608 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
609 flag = WRONG_APP_DATA;
609 flag = WRONG_APP_DATA;
610 }
610 }
611 }
611 }
612 // sy_lfr_n_bp_p1
612 // sy_lfr_n_bp_p1
613 if (flag == LFR_SUCCESSFUL)
613 if (flag == LFR_SUCCESSFUL)
614 {
614 {
615 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
615 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
616 {
616 {
617 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
617 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
618 flag = WRONG_APP_DATA;
618 flag = WRONG_APP_DATA;
619 }
619 }
620 }
620 }
621 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
621 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
622 if (flag == LFR_SUCCESSFUL)
622 if (flag == LFR_SUCCESSFUL)
623 {
623 {
624 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
624 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
625 if (aux > FLOAT_EQUAL_ZERO)
625 if (aux > FLOAT_EQUAL_ZERO)
626 {
626 {
627 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
627 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
628 flag = LFR_DEFAULT;
628 flag = LFR_DEFAULT;
629 }
629 }
630 }
630 }
631 // sy_lfr_n_cwf_long_f3
631 // sy_lfr_n_cwf_long_f3
632
632
633 return flag;
633 return flag;
634 }
634 }
635
635
636 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
636 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
637 {
637 {
638 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
638 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
639 *
639 *
640 * @param TC points to the TeleCommand packet that is being processed
640 * @param TC points to the TeleCommand packet that is being processed
641 * @param queue_id is the id of the queue which handles TM related to this execution step
641 * @param queue_id is the id of the queue which handles TM related to this execution step
642 *
642 *
643 */
643 */
644
644
645 int result;
645 int result;
646
646
647 result = LFR_SUCCESSFUL;
647 result = LFR_SUCCESSFUL;
648
648
649 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
649 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
650 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
650 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
651
651
652 return result;
652 return result;
653 }
653 }
654
654
655 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
655 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
656 {
656 {
657 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
657 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
658 *
658 *
659 * @param TC points to the TeleCommand packet that is being processed
659 * @param TC points to the TeleCommand packet that is being processed
660 * @param queue_id is the id of the queue which handles TM related to this execution step
660 * @param queue_id is the id of the queue which handles TM related to this execution step
661 *
661 *
662 */
662 */
663
663
664 int result;
664 int result;
665
665
666 result = LFR_SUCCESSFUL;
666 result = LFR_SUCCESSFUL;
667
667
668 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
668 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
669 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
669 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
670
670
671 return result;
671 return result;
672 }
672 }
673
673
674 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
674 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
675 {
675 {
676 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
676 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
677 *
677 *
678 * @param TC points to the TeleCommand packet that is being processed
678 * @param TC points to the TeleCommand packet that is being processed
679 * @param queue_id is the id of the queue which handles TM related to this execution step
679 * @param queue_id is the id of the queue which handles TM related to this execution step
680 *
680 *
681 */
681 */
682
682
683 int result;
683 int result;
684
684
685 result = LFR_SUCCESSFUL;
685 result = LFR_SUCCESSFUL;
686
686
687 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
687 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
688 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
688 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
689
689
690 return result;
690 return result;
691 }
691 }
692
692
693 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
693 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
694 {
694 {
695 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
695 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
696 *
696 *
697 * @param TC points to the TeleCommand packet that is being processed
697 * @param TC points to the TeleCommand packet that is being processed
698 * @param queue_id is the id of the queue which handles TM related to this execution step
698 * @param queue_id is the id of the queue which handles TM related to this execution step
699 *
699 *
700 */
700 */
701
701
702 int status;
702 int status;
703
703
704 status = LFR_SUCCESSFUL;
704 status = LFR_SUCCESSFUL;
705
705
706 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
706 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
707
707
708 return status;
708 return status;
709 }
709 }
710
710
711 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
711 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
712 {
712 {
713 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
713 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
714 *
714 *
715 * @param TC points to the TeleCommand packet that is being processed
715 * @param TC points to the TeleCommand packet that is being processed
716 * @param queue_id is the id of the queue which handles TM related to this execution step
716 * @param queue_id is the id of the queue which handles TM related to this execution step
717 *
717 *
718 */
718 */
719
719
720 int status;
720 int status;
721
721
722 status = LFR_SUCCESSFUL;
722 status = LFR_SUCCESSFUL;
723
723
724 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
724 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
725
725
726 return status;
726 return status;
727 }
727 }
728
728
729 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
729 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
730 {
730 {
731 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
731 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
732 *
732 *
733 * @param TC points to the TeleCommand packet that is being processed
733 * @param TC points to the TeleCommand packet that is being processed
734 * @param queue_id is the id of the queue which handles TM related to this execution step
734 * @param queue_id is the id of the queue which handles TM related to this execution step
735 *
735 *
736 */
736 */
737
737
738 int status;
738 int status;
739
739
740 status = LFR_SUCCESSFUL;
740 status = LFR_SUCCESSFUL;
741
741
742 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
742 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
743
743
744 return status;
744 return status;
745 }
745 }
746
746
747 //**********************
747 //**********************
748 // BURST MODE PARAMETERS
748 // BURST MODE PARAMETERS
749 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
749 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
750 {
750 {
751 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
751 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
752 *
752 *
753 * @param TC points to the TeleCommand packet that is being processed
753 * @param TC points to the TeleCommand packet that is being processed
754 * @param queue_id is the id of the queue which handles TM related to this execution step
754 * @param queue_id is the id of the queue which handles TM related to this execution step
755 *
755 *
756 */
756 */
757
757
758 int status;
758 int status;
759
759
760 status = LFR_SUCCESSFUL;
760 status = LFR_SUCCESSFUL;
761
761
762 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
762 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
763
763
764 return status;
764 return status;
765 }
765 }
766
766
767 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
767 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
768 {
768 {
769 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
769 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
770 *
770 *
771 * @param TC points to the TeleCommand packet that is being processed
771 * @param TC points to the TeleCommand packet that is being processed
772 * @param queue_id is the id of the queue which handles TM related to this execution step
772 * @param queue_id is the id of the queue which handles TM related to this execution step
773 *
773 *
774 */
774 */
775
775
776 int status;
776 int status;
777
777
778 status = LFR_SUCCESSFUL;
778 status = LFR_SUCCESSFUL;
779
779
780 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
780 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
781
781
782 return status;
782 return status;
783 }
783 }
784
784
785 //*********************
785 //*********************
786 // SBM1 MODE PARAMETERS
786 // SBM1 MODE PARAMETERS
787 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
787 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
788 {
788 {
789 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
789 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
790 *
790 *
791 * @param TC points to the TeleCommand packet that is being processed
791 * @param TC points to the TeleCommand packet that is being processed
792 * @param queue_id is the id of the queue which handles TM related to this execution step
792 * @param queue_id is the id of the queue which handles TM related to this execution step
793 *
793 *
794 */
794 */
795
795
796 int status;
796 int status;
797
797
798 status = LFR_SUCCESSFUL;
798 status = LFR_SUCCESSFUL;
799
799
800 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
800 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
801
801
802 return status;
802 return status;
803 }
803 }
804
804
805 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
805 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
806 {
806 {
807 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
807 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
808 *
808 *
809 * @param TC points to the TeleCommand packet that is being processed
809 * @param TC points to the TeleCommand packet that is being processed
810 * @param queue_id is the id of the queue which handles TM related to this execution step
810 * @param queue_id is the id of the queue which handles TM related to this execution step
811 *
811 *
812 */
812 */
813
813
814 int status;
814 int status;
815
815
816 status = LFR_SUCCESSFUL;
816 status = LFR_SUCCESSFUL;
817
817
818 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
818 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
819
819
820 return status;
820 return status;
821 }
821 }
822
822
823 //*********************
823 //*********************
824 // SBM2 MODE PARAMETERS
824 // SBM2 MODE PARAMETERS
825 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
825 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
826 {
826 {
827 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
827 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
828 *
828 *
829 * @param TC points to the TeleCommand packet that is being processed
829 * @param TC points to the TeleCommand packet that is being processed
830 * @param queue_id is the id of the queue which handles TM related to this execution step
830 * @param queue_id is the id of the queue which handles TM related to this execution step
831 *
831 *
832 */
832 */
833
833
834 int status;
834 int status;
835
835
836 status = LFR_SUCCESSFUL;
836 status = LFR_SUCCESSFUL;
837
837
838 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
838 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
839
839
840 return status;
840 return status;
841 }
841 }
842
842
843 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
843 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
844 {
844 {
845 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
845 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
846 *
846 *
847 * @param TC points to the TeleCommand packet that is being processed
847 * @param TC points to the TeleCommand packet that is being processed
848 * @param queue_id is the id of the queue which handles TM related to this execution step
848 * @param queue_id is the id of the queue which handles TM related to this execution step
849 *
849 *
850 */
850 */
851
851
852 int status;
852 int status;
853
853
854 status = LFR_SUCCESSFUL;
854 status = LFR_SUCCESSFUL;
855
855
856 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
856 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
857
857
858 return status;
858 return status;
859 }
859 }
860
860
861 //*******************
861 //*******************
862 // TC_LFR_UPDATE_INFO
862 // TC_LFR_UPDATE_INFO
863 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
863 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
864 {
864 {
865 unsigned int status;
865 unsigned int status;
866
866
867 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
867 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
868 || (mode == LFR_MODE_BURST)
868 || (mode == LFR_MODE_BURST)
869 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
869 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
870 {
870 {
871 status = LFR_SUCCESSFUL;
871 status = LFR_SUCCESSFUL;
872 }
872 }
873 else
873 else
874 {
874 {
875 status = LFR_DEFAULT;
875 status = LFR_DEFAULT;
876 }
876 }
877
877
878 return status;
878 return status;
879 }
879 }
880
880
881 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
881 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
882 {
882 {
883 unsigned int status;
883 unsigned int status;
884
884
885 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
885 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
886 || (mode == TDS_MODE_BURST)
886 || (mode == TDS_MODE_BURST)
887 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
887 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
888 || (mode == TDS_MODE_LFM))
888 || (mode == TDS_MODE_LFM))
889 {
889 {
890 status = LFR_SUCCESSFUL;
890 status = LFR_SUCCESSFUL;
891 }
891 }
892 else
892 else
893 {
893 {
894 status = LFR_DEFAULT;
894 status = LFR_DEFAULT;
895 }
895 }
896
896
897 return status;
897 return status;
898 }
898 }
899
899
900 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
900 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
901 {
901 {
902 unsigned int status;
902 unsigned int status;
903
903
904 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
904 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
905 || (mode == THR_MODE_BURST))
905 || (mode == THR_MODE_BURST))
906 {
906 {
907 status = LFR_SUCCESSFUL;
907 status = LFR_SUCCESSFUL;
908 }
908 }
909 else
909 else
910 {
910 {
911 status = LFR_DEFAULT;
911 status = LFR_DEFAULT;
912 }
912 }
913
913
914 return status;
914 return status;
915 }
915 }
916
916
917 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
917 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
918 {
918 {
919 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
919 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
920 *
920 *
921 * @param TC points to the TeleCommand packet that is being processed
921 * @param TC points to the TeleCommand packet that is being processed
922 *
922 *
923 */
923 */
924
924
925 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
925 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
926
926
927 bytePosPtr = (unsigned char *) &TC->packetID;
927 bytePosPtr = (unsigned char *) &TC->packetID;
928
928
929 // cp_rpw_sc_rw1_f1
929 // cp_rpw_sc_rw1_f1
930 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1,
930 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1,
931 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
931 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
932
932
933 // cp_rpw_sc_rw1_f2
933 // cp_rpw_sc_rw1_f2
934 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2,
934 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2,
935 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
935 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
936
936
937 // cp_rpw_sc_rw2_f1
937 // cp_rpw_sc_rw2_f1
938 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1,
938 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1,
939 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
939 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
940
940
941 // cp_rpw_sc_rw2_f2
941 // cp_rpw_sc_rw2_f2
942 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2,
942 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2,
943 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
943 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
944
944
945 // cp_rpw_sc_rw3_f1
945 // cp_rpw_sc_rw3_f1
946 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1,
946 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1,
947 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
947 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
948
948
949 // cp_rpw_sc_rw3_f2
949 // cp_rpw_sc_rw3_f2
950 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2,
950 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2,
951 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
951 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
952
952
953 // cp_rpw_sc_rw4_f1
953 // cp_rpw_sc_rw4_f1
954 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1,
954 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1,
955 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
955 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
956
956
957 // cp_rpw_sc_rw4_f2
957 // cp_rpw_sc_rw4_f2
958 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2,
958 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2,
959 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
959 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
960 }
960 }
961
961
962 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag )
962 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag )
963 {
963 {
964 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
964 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
965 *
965 *
966 * @param fbins_mask
966 * @param fbins_mask
967 * @param rw_f is the reaction wheel frequency to filter
967 * @param rw_f is the reaction wheel frequency to filter
968 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
968 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
969 * @param flag [true] filtering enabled [false] filtering disabled
969 * @param flag [true] filtering enabled [false] filtering disabled
970 *
970 *
971 * @return void
971 * @return void
972 *
972 *
973 */
973 */
974
974
975 float f_RW_min;
975 float f_RW_min;
976 float f_RW_MAX;
976 float f_RW_MAX;
977 float fi_min;
977 float fi_min;
978 float fi_MAX;
978 float fi_MAX;
979 float fi;
979 float fi;
980 float deltaBelow;
980 float deltaBelow;
981 float deltaAbove;
981 float deltaAbove;
982 int binBelow;
982 int binBelow;
983 int binAbove;
983 int binAbove;
984 int closestBin;
984 int closestBin;
985 unsigned int whichByte;
985 unsigned int whichByte;
986 int selectedByte;
986 int selectedByte;
987 int bin;
987 int bin;
988 int binToRemove[3];
988 int binToRemove[3];
989 int k;
989 int k;
990
990
991 whichByte = 0;
991 whichByte = 0;
992 bin = 0;
992 bin = 0;
993
993
994 binToRemove[0] = -1;
994 binToRemove[0] = -1;
995 binToRemove[1] = -1;
995 binToRemove[1] = -1;
996 binToRemove[2] = -1;
996 binToRemove[2] = -1;
997
997
998 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
998 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
999 f_RW_min = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.;
999 f_RW_min = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.;
1000 f_RW_MAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.;
1000 f_RW_MAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.;
1001
1001
1002 // compute the index of the frequency bin immediately below rw_f
1002 // compute the index of the frequency bin immediately below rw_f
1003 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1003 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1004 deltaBelow = rw_f - binBelow * deltaFreq;
1004 deltaBelow = rw_f - binBelow * deltaFreq;
1005
1005
1006 // compute the index of the frequency bin immediately above rw_f
1006 // compute the index of the frequency bin immediately above rw_f
1007 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1007 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1008 deltaAbove = binAbove * deltaFreq - rw_f;
1008 deltaAbove = binAbove * deltaFreq - rw_f;
1009
1009
1010 // search the closest bin
1010 // search the closest bin
1011 if (deltaAbove > deltaBelow)
1011 if (deltaAbove > deltaBelow)
1012 {
1012 {
1013 closestBin = binBelow;
1013 closestBin = binBelow;
1014 }
1014 }
1015 else
1015 else
1016 {
1016 {
1017 closestBin = binAbove;
1017 closestBin = binAbove;
1018 }
1018 }
1019
1019
1020 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1020 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1021 fi = closestBin * deltaFreq;
1021 fi = closestBin * deltaFreq;
1022 fi_min = fi - (deltaFreq * 0.285);
1022 fi_min = fi - (deltaFreq * 0.285);
1023 fi_MAX = fi + (deltaFreq * 0.285);
1023 fi_MAX = fi + (deltaFreq * 0.285);
1024
1024
1025 //**************************************************************************************
1025 //**************************************************************************************
1026 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
1026 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
1027 // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum
1027 // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum
1028 //**************************************************************************************
1028 //**************************************************************************************
1029
1029
1030 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1030 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1031 // => remove f_(i), f_(i-1) and f_(i+1)
1031 // => remove f_(i), f_(i-1) and f_(i+1)
1032 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1032 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1033 {
1033 {
1034 binToRemove[0] = (closestBin - 1) - 1;
1034 binToRemove[0] = (closestBin - 1) - 1;
1035 binToRemove[1] = (closestBin) - 1;
1035 binToRemove[1] = (closestBin) - 1;
1036 binToRemove[2] = (closestBin + 1) - 1;
1036 binToRemove[2] = (closestBin + 1) - 1;
1037 }
1037 }
1038 // 2. ELSE
1038 // 2. ELSE
1039 // => remove the two f_(i) which are around f_RW
1039 // => remove the two f_(i) which are around f_RW
1040 else
1040 else
1041 {
1041 {
1042 binToRemove[0] = (binBelow) - 1;
1042 binToRemove[0] = (binBelow) - 1;
1043 binToRemove[1] = (binAbove) - 1;
1043 binToRemove[1] = (binAbove) - 1;
1044 binToRemove[2] = (-1);
1044 binToRemove[2] = (-1);
1045 }
1045 }
1046
1046
1047 for (k = 0; k < 3; k++)
1047 for (k = 0; k < 3; k++)
1048 {
1048 {
1049 bin = binToRemove[k];
1049 bin = binToRemove[k];
1050 if ( (bin >= 0) && (bin <= 127) )
1050 if ( (bin >= 0) && (bin <= 127) )
1051 {
1051 {
1052 if (flag == 1)
1052 if (flag == 1)
1053 {
1053 {
1054 whichByte = (bin >> 3); // division by 8
1054 whichByte = (bin >> 3); // division by 8
1055 selectedByte = ( 1 << (bin - (whichByte * 8)) );
1055 selectedByte = ( 1 << (bin - (whichByte * 8)) );
1056 fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1056 fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1057 }
1057 }
1058 }
1058 }
1059 }
1059 }
1060 }
1060 }
1061
1061
1062 void build_sy_lfr_rw_mask( unsigned int channel )
1062 void build_sy_lfr_rw_mask( unsigned int channel )
1063 {
1063 {
1064 unsigned char local_rw_fbins_mask[16];
1064 unsigned char local_rw_fbins_mask[16];
1065 unsigned char *maskPtr;
1065 unsigned char *maskPtr;
1066 double deltaF;
1066 double deltaF;
1067 unsigned k;
1067 unsigned k;
1068
1068
1069 k = 0;
1069 k = 0;
1070
1070
1071 maskPtr = NULL;
1071 maskPtr = NULL;
1072 deltaF = 1.;
1072 deltaF = 1.;
1073
1073
1074 switch (channel)
1074 switch (channel)
1075 {
1075 {
1076 case 0:
1076 case 0:
1077 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f0_word1;
1077 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f0_word1;
1078 deltaF = 96.;
1078 deltaF = 96.;
1079 break;
1079 break;
1080 case 1:
1080 case 1:
1081 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f1_word1;
1081 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f1_word1;
1082 deltaF = 16.;
1082 deltaF = 16.;
1083 break;
1083 break;
1084 case 2:
1084 case 2:
1085 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f2_word1;
1085 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f2_word1;
1086 deltaF = 1.;
1086 deltaF = 1.;
1087 break;
1087 break;
1088 default:
1088 default:
1089 break;
1089 break;
1090 }
1090 }
1091
1091
1092 for (k = 0; k < 16; k++)
1092 for (k = 0; k < 16; k++)
1093 {
1093 {
1094 local_rw_fbins_mask[k] = 0xff;
1094 local_rw_fbins_mask[k] = 0xff;
1095 }
1095 }
1096
1096
1097 // RW1 F1
1097 // RW1 F1
1098 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000]
1098 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000]
1099
1099
1100 // RW1 F2
1100 // RW1 F2
1101 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000]
1101 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000]
1102
1102
1103 // RW2 F1
1103 // RW2 F1
1104 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000]
1104 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000]
1105
1105
1106 // RW2 F2
1106 // RW2 F2
1107 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000]
1107 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000]
1108
1108
1109 // RW3 F1
1109 // RW3 F1
1110 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000]
1110 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000]
1111
1111
1112 // RW3 F2
1112 // RW3 F2
1113 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100]
1113 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100]
1114
1114
1115 // RW4 F1
1115 // RW4 F1
1116 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010]
1116 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010]
1117
1117
1118 // RW4 F2
1118 // RW4 F2
1119 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001]
1119 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001]
1120
1120
1121 // update the value of the fbins related to reaction wheels frequency filtering
1121 // update the value of the fbins related to reaction wheels frequency filtering
1122 if (maskPtr != NULL)
1122 if (maskPtr != NULL)
1123 {
1123 {
1124 printf("channel = %d\n", channel);
1124 for (k = 0; k < 16; k++)
1125 for (k = 0; k < 16; k++)
1125 {
1126 {
1127 printf("%x ", local_rw_fbins_mask[k]);
1126 maskPtr[k] = local_rw_fbins_mask[k];
1128 maskPtr[k] = local_rw_fbins_mask[k];
1127 }
1129 }
1130 printf("\n", local_rw_fbins_mask[k]);
1128 }
1131 }
1129 }
1132 }
1130
1133
1134 void print_sy_lfr_rw_masks( void )
1135 {
1136 int k;
1137
1138 printf("cp_rpw_sc_rw1_f1 = %f\n", cp_rpw_sc_rw1_f1);
1139 printf("cp_rpw_sc_rw1_f2 = %f\n", cp_rpw_sc_rw1_f2);
1140 printf("cp_rpw_sc_rw2_f1 = %f\n", cp_rpw_sc_rw2_f1);
1141 printf("cp_rpw_sc_rw2_f2 = %f\n", cp_rpw_sc_rw2_f2);
1142 printf("cp_rpw_sc_rw3_f1 = %f\n", cp_rpw_sc_rw3_f1);
1143 printf("cp_rpw_sc_rw3_f2 = %f\n", cp_rpw_sc_rw3_f2);
1144 printf("cp_rpw_sc_rw4_f1 = %f\n", cp_rpw_sc_rw4_f1);
1145 printf("cp_rpw_sc_rw4_f2 = %f\n", cp_rpw_sc_rw4_f2);
1146
1147 printf("f0\n");
1148 for (k = 0; k < 16; k++)
1149 {
1150 printf("%x ", parameter_dump_packet.sy_lfr_rw_mask.fx.f0_word1[k] );
1151 }
1152 printf("\n");
1153
1154 printf("f1\n");
1155 for (k = 0; k < 16; k++)
1156 {
1157 printf("%x ", parameter_dump_packet.sy_lfr_rw_mask.fx.f1_word1[k] );
1158 }
1159 printf("\n");
1160
1161 printf("f2\n");
1162 for (k = 0; k < 16; k++)
1163 {
1164 printf("%x ", parameter_dump_packet.sy_lfr_rw_mask.fx.f2_word1[k] );
1165 }
1166 printf("\n");
1167
1168 }
1169
1131 void build_sy_lfr_rw_masks( void )
1170 void build_sy_lfr_rw_masks( void )
1132 {
1171 {
1133 build_sy_lfr_rw_mask( 0 );
1172 build_sy_lfr_rw_mask( 0 );
1134 build_sy_lfr_rw_mask( 1 );
1173 build_sy_lfr_rw_mask( 1 );
1135 build_sy_lfr_rw_mask( 2 );
1174 build_sy_lfr_rw_mask( 2 );
1136
1175
1176 print_sy_lfr_rw_masks();
1177
1137 merge_fbins_masks();
1178 merge_fbins_masks();
1138 }
1179 }
1139
1180
1140 void merge_fbins_masks( void )
1181 void merge_fbins_masks( void )
1141 {
1182 {
1142 unsigned char k;
1183 unsigned char k;
1143
1184
1144 unsigned char *fbins_f0;
1185 unsigned char *fbins_f0;
1145 unsigned char *fbins_f1;
1186 unsigned char *fbins_f1;
1146 unsigned char *fbins_f2;
1187 unsigned char *fbins_f2;
1147 unsigned char *rw_mask_f0;
1188 unsigned char *rw_mask_f0;
1148 unsigned char *rw_mask_f1;
1189 unsigned char *rw_mask_f1;
1149 unsigned char *rw_mask_f2;
1190 unsigned char *rw_mask_f2;
1150
1191
1151 fbins_f0 = parameter_dump_packet.sy_lfr_fbins.fx.f0_word1;
1192 fbins_f0 = parameter_dump_packet.sy_lfr_fbins.fx.f0_word1;
1152 fbins_f1 = parameter_dump_packet.sy_lfr_fbins.fx.f1_word1;
1193 fbins_f1 = parameter_dump_packet.sy_lfr_fbins.fx.f1_word1;
1153 fbins_f2 = parameter_dump_packet.sy_lfr_fbins.fx.f2_word1;
1194 fbins_f2 = parameter_dump_packet.sy_lfr_fbins.fx.f2_word1;
1154 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask.fx.f0_word1;
1195 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask.fx.f0_word1;
1155 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask.fx.f1_word1;
1196 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask.fx.f1_word1;
1156 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask.fx.f2_word1;
1197 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask.fx.f2_word1;
1157
1198
1158 for( k=0; k < 16; k++ )
1199 for( k=0; k < 16; k++ )
1159 {
1200 {
1160 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1201 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1161 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1202 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1162 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1203 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1163 }
1204 }
1164 }
1205 }
1165
1206
1166 //***********
1207 //***********
1167 // FBINS MASK
1208 // FBINS MASK
1168
1209
1169 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1210 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1170 {
1211 {
1171 int status;
1212 int status;
1172 unsigned int k;
1213 unsigned int k;
1173 unsigned char *fbins_mask_dump;
1214 unsigned char *fbins_mask_dump;
1174 unsigned char *fbins_mask_TC;
1215 unsigned char *fbins_mask_TC;
1175
1216
1176 status = LFR_SUCCESSFUL;
1217 status = LFR_SUCCESSFUL;
1177
1218
1178 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins.raw;
1219 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins.raw;
1179 fbins_mask_TC = TC->dataAndCRC;
1220 fbins_mask_TC = TC->dataAndCRC;
1180
1221
1181 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1222 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1182 {
1223 {
1183 fbins_mask_dump[k] = fbins_mask_TC[k];
1224 fbins_mask_dump[k] = fbins_mask_TC[k];
1184 }
1225 }
1185
1226
1186 return status;
1227 return status;
1187 }
1228 }
1188
1229
1189 //***************************
1230 //***************************
1190 // TC_LFR_LOAD_PAS_FILTER_PAR
1231 // TC_LFR_LOAD_PAS_FILTER_PAR
1191
1232
1192 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1233 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1193 {
1234 {
1194 int flag;
1235 int flag;
1195 rtems_status_code status;
1236 rtems_status_code status;
1196
1237
1197 unsigned char sy_lfr_pas_filter_enabled;
1238 unsigned char sy_lfr_pas_filter_enabled;
1198 unsigned char sy_lfr_pas_filter_modulus;
1239 unsigned char sy_lfr_pas_filter_modulus;
1199 float sy_lfr_pas_filter_tbad;
1240 float sy_lfr_pas_filter_tbad;
1200 unsigned char sy_lfr_pas_filter_offset;
1241 unsigned char sy_lfr_pas_filter_offset;
1201 float sy_lfr_pas_filter_shift;
1242 float sy_lfr_pas_filter_shift;
1202 float sy_lfr_sc_rw_delta_f;
1243 float sy_lfr_sc_rw_delta_f;
1203 char *parPtr;
1244 char *parPtr;
1204
1245
1205 flag = LFR_SUCCESSFUL;
1246 flag = LFR_SUCCESSFUL;
1206 sy_lfr_pas_filter_tbad = 0.0;
1247 sy_lfr_pas_filter_tbad = 0.0;
1207 sy_lfr_pas_filter_shift = 0.0;
1248 sy_lfr_pas_filter_shift = 0.0;
1208 sy_lfr_sc_rw_delta_f = 0.0;
1249 sy_lfr_sc_rw_delta_f = 0.0;
1209 parPtr = NULL;
1250 parPtr = NULL;
1210
1251
1211 //***************
1252 //***************
1212 // get parameters
1253 // get parameters
1213 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1254 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1214 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1255 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1215 copyFloatByChar(
1256 copyFloatByChar(
1216 (unsigned char*) &sy_lfr_pas_filter_tbad,
1257 (unsigned char*) &sy_lfr_pas_filter_tbad,
1217 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1258 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1218 );
1259 );
1219 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1260 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1220 copyFloatByChar(
1261 copyFloatByChar(
1221 (unsigned char*) &sy_lfr_pas_filter_shift,
1262 (unsigned char*) &sy_lfr_pas_filter_shift,
1222 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1263 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1223 );
1264 );
1224 copyFloatByChar(
1265 copyFloatByChar(
1225 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1266 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1226 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1267 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1227 );
1268 );
1228
1269
1229 //******************
1270 //******************
1230 // CHECK CONSISTENCY
1271 // CHECK CONSISTENCY
1231
1272
1232 //**************************
1273 //**************************
1233 // sy_lfr_pas_filter_enabled
1274 // sy_lfr_pas_filter_enabled
1234 // nothing to check, value is 0 or 1
1275 // nothing to check, value is 0 or 1
1235
1276
1236 //**************************
1277 //**************************
1237 // sy_lfr_pas_filter_modulus
1278 // sy_lfr_pas_filter_modulus
1238 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1279 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1239 {
1280 {
1240 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1281 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1241 flag = WRONG_APP_DATA;
1282 flag = WRONG_APP_DATA;
1242 }
1283 }
1243
1284
1244 //***********************
1285 //***********************
1245 // sy_lfr_pas_filter_tbad
1286 // sy_lfr_pas_filter_tbad
1246 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1287 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1247 {
1288 {
1248 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1289 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1290 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1250 flag = WRONG_APP_DATA;
1291 flag = WRONG_APP_DATA;
1251 }
1292 }
1252
1293
1253 //*************************
1294 //*************************
1254 // sy_lfr_pas_filter_offset
1295 // sy_lfr_pas_filter_offset
1255 if (flag == LFR_SUCCESSFUL)
1296 if (flag == LFR_SUCCESSFUL)
1256 {
1297 {
1257 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1298 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1258 {
1299 {
1259 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1300 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1260 flag = WRONG_APP_DATA;
1301 flag = WRONG_APP_DATA;
1261 }
1302 }
1262 }
1303 }
1263
1304
1264 //************************
1305 //************************
1265 // sy_lfr_pas_filter_shift
1306 // sy_lfr_pas_filter_shift
1266 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1307 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1267 {
1308 {
1268 parPtr = (char*) &sy_lfr_pas_filter_shift;
1309 parPtr = (char*) &sy_lfr_pas_filter_shift;
1269 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1310 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1270 flag = WRONG_APP_DATA;
1311 flag = WRONG_APP_DATA;
1271 }
1312 }
1272
1313
1273 //*********************
1314 //*********************
1274 // sy_lfr_sc_rw_delta_f
1315 // sy_lfr_sc_rw_delta_f
1275 // nothing to check, no default value in the ICD
1316 // nothing to check, no default value in the ICD
1276
1317
1277 return flag;
1318 return flag;
1278 }
1319 }
1279
1320
1280 //**************
1321 //**************
1281 // KCOEFFICIENTS
1322 // KCOEFFICIENTS
1282 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1323 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1283 {
1324 {
1284 unsigned int kcoeff;
1325 unsigned int kcoeff;
1285 unsigned short sy_lfr_kcoeff_frequency;
1326 unsigned short sy_lfr_kcoeff_frequency;
1286 unsigned short bin;
1327 unsigned short bin;
1287 unsigned short *freqPtr;
1328 unsigned short *freqPtr;
1288 float *kcoeffPtr_norm;
1329 float *kcoeffPtr_norm;
1289 float *kcoeffPtr_sbm;
1330 float *kcoeffPtr_sbm;
1290 int status;
1331 int status;
1291 unsigned char *kcoeffLoadPtr;
1332 unsigned char *kcoeffLoadPtr;
1292 unsigned char *kcoeffNormPtr;
1333 unsigned char *kcoeffNormPtr;
1293 unsigned char *kcoeffSbmPtr_a;
1334 unsigned char *kcoeffSbmPtr_a;
1294 unsigned char *kcoeffSbmPtr_b;
1335 unsigned char *kcoeffSbmPtr_b;
1295
1336
1296 status = LFR_SUCCESSFUL;
1337 status = LFR_SUCCESSFUL;
1297
1338
1298 kcoeffPtr_norm = NULL;
1339 kcoeffPtr_norm = NULL;
1299 kcoeffPtr_sbm = NULL;
1340 kcoeffPtr_sbm = NULL;
1300 bin = 0;
1341 bin = 0;
1301
1342
1302 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1343 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1303 sy_lfr_kcoeff_frequency = *freqPtr;
1344 sy_lfr_kcoeff_frequency = *freqPtr;
1304
1345
1305 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1346 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1306 {
1347 {
1307 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1348 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1308 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1349 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1309 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1350 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1310 status = LFR_DEFAULT;
1351 status = LFR_DEFAULT;
1311 }
1352 }
1312 else
1353 else
1313 {
1354 {
1314 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1355 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1315 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1356 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1316 {
1357 {
1317 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1358 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1318 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1359 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1319 bin = sy_lfr_kcoeff_frequency;
1360 bin = sy_lfr_kcoeff_frequency;
1320 }
1361 }
1321 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1362 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1322 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1363 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1323 {
1364 {
1324 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1365 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1325 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1366 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1326 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1367 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1327 }
1368 }
1328 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1369 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1329 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1370 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1330 {
1371 {
1331 kcoeffPtr_norm = k_coeff_intercalib_f2;
1372 kcoeffPtr_norm = k_coeff_intercalib_f2;
1332 kcoeffPtr_sbm = NULL;
1373 kcoeffPtr_sbm = NULL;
1333 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1374 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1334 }
1375 }
1335 }
1376 }
1336
1377
1337 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1378 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1338 {
1379 {
1339 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1380 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1340 {
1381 {
1341 // destination
1382 // destination
1342 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1383 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1343 // source
1384 // source
1344 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1385 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1345 // copy source to destination
1386 // copy source to destination
1346 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1387 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1347 }
1388 }
1348 }
1389 }
1349
1390
1350 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1391 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1351 {
1392 {
1352 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1393 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1353 {
1394 {
1354 // destination
1395 // destination
1355 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1396 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1356 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1397 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1357 // source
1398 // source
1358 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1399 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1359 // copy source to destination
1400 // copy source to destination
1360 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1401 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1361 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1402 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1362 }
1403 }
1363 }
1404 }
1364
1405
1365 // print_k_coeff();
1406 // print_k_coeff();
1366
1407
1367 return status;
1408 return status;
1368 }
1409 }
1369
1410
1370 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1411 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1371 {
1412 {
1372 destination[0] = source[0];
1413 destination[0] = source[0];
1373 destination[1] = source[1];
1414 destination[1] = source[1];
1374 destination[2] = source[2];
1415 destination[2] = source[2];
1375 destination[3] = source[3];
1416 destination[3] = source[3];
1376 }
1417 }
1377
1418
1378 void floatToChar( float value, unsigned char* ptr)
1419 void floatToChar( float value, unsigned char* ptr)
1379 {
1420 {
1380 unsigned char* valuePtr;
1421 unsigned char* valuePtr;
1381
1422
1382 valuePtr = (unsigned char*) &value;
1423 valuePtr = (unsigned char*) &value;
1383 ptr[0] = valuePtr[0];
1424 ptr[0] = valuePtr[0];
1384 ptr[1] = valuePtr[1];
1425 ptr[1] = valuePtr[1];
1385 ptr[2] = valuePtr[2];
1426 ptr[2] = valuePtr[2];
1386 ptr[3] = valuePtr[3];
1427 ptr[3] = valuePtr[3];
1387 }
1428 }
1388
1429
1389 //**********
1430 //**********
1390 // init dump
1431 // init dump
1391
1432
1392 void init_parameter_dump( void )
1433 void init_parameter_dump( void )
1393 {
1434 {
1394 /** This function initialize the parameter_dump_packet global variable with default values.
1435 /** This function initialize the parameter_dump_packet global variable with default values.
1395 *
1436 *
1396 */
1437 */
1397
1438
1398 unsigned int k;
1439 unsigned int k;
1399
1440
1400 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1441 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1401 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1442 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1402 parameter_dump_packet.reserved = CCSDS_RESERVED;
1443 parameter_dump_packet.reserved = CCSDS_RESERVED;
1403 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1444 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1404 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1445 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1405 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1446 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1406 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1447 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1407 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1448 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1408 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1449 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1409 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1450 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1410 // DATA FIELD HEADER
1451 // DATA FIELD HEADER
1411 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1452 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1412 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1453 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1413 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1454 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1414 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1455 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1415 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1456 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1416 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1457 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1417 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1458 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1418 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1459 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1419 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1460 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1420 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1461 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1421 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1462 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1422
1463
1423 //******************
1464 //******************
1424 // COMMON PARAMETERS
1465 // COMMON PARAMETERS
1425 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1466 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1426 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1467 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1427
1468
1428 //******************
1469 //******************
1429 // NORMAL PARAMETERS
1470 // NORMAL PARAMETERS
1430 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1471 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1431 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1472 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1432 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1473 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1433 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1474 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1434 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1475 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1435 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1476 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1436 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1477 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1437 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1478 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1438 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1479 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1439
1480
1440 //*****************
1481 //*****************
1441 // BURST PARAMETERS
1482 // BURST PARAMETERS
1442 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1483 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1443 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1484 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1444
1485
1445 //****************
1486 //****************
1446 // SBM1 PARAMETERS
1487 // SBM1 PARAMETERS
1447 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
1488 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
1448 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1489 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1449
1490
1450 //****************
1491 //****************
1451 // SBM2 PARAMETERS
1492 // SBM2 PARAMETERS
1452 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1493 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1453 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1494 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1454
1495
1455 //************
1496 //************
1456 // FBINS MASKS
1497 // FBINS MASKS
1457 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1498 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1458 {
1499 {
1459 parameter_dump_packet.sy_lfr_fbins.raw[k] = 0xff;
1500 parameter_dump_packet.sy_lfr_fbins.raw[k] = 0xff;
1460 }
1501 }
1461
1502
1462 // PAS FILTER PARAMETERS
1503 // PAS FILTER PARAMETERS
1463 parameter_dump_packet.pa_rpw_spare8_2 = 0x00;
1504 parameter_dump_packet.pa_rpw_spare8_2 = 0x00;
1464 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00;
1505 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00;
1465 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1506 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1466 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1507 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1467 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1508 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1468 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1509 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1469 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1510 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1470
1511
1471 // LFR_RW_MASK
1512 // LFR_RW_MASK
1472 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1513 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1473 {
1514 {
1474 parameter_dump_packet.sy_lfr_rw_mask.raw[k] = 0xff;
1515 parameter_dump_packet.sy_lfr_rw_mask.raw[k] = 0xff;
1475 }
1516 }
1476 }
1517 }
1477
1518
1478 void init_kcoefficients_dump( void )
1519 void init_kcoefficients_dump( void )
1479 {
1520 {
1480 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1521 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1481 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1522 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1482
1523
1483 kcoefficient_node_1.previous = NULL;
1524 kcoefficient_node_1.previous = NULL;
1484 kcoefficient_node_1.next = NULL;
1525 kcoefficient_node_1.next = NULL;
1485 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1526 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1486 kcoefficient_node_1.coarseTime = 0x00;
1527 kcoefficient_node_1.coarseTime = 0x00;
1487 kcoefficient_node_1.fineTime = 0x00;
1528 kcoefficient_node_1.fineTime = 0x00;
1488 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1529 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1489 kcoefficient_node_1.status = 0x00;
1530 kcoefficient_node_1.status = 0x00;
1490
1531
1491 kcoefficient_node_2.previous = NULL;
1532 kcoefficient_node_2.previous = NULL;
1492 kcoefficient_node_2.next = NULL;
1533 kcoefficient_node_2.next = NULL;
1493 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1534 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1494 kcoefficient_node_2.coarseTime = 0x00;
1535 kcoefficient_node_2.coarseTime = 0x00;
1495 kcoefficient_node_2.fineTime = 0x00;
1536 kcoefficient_node_2.fineTime = 0x00;
1496 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1537 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1497 kcoefficient_node_2.status = 0x00;
1538 kcoefficient_node_2.status = 0x00;
1498 }
1539 }
1499
1540
1500 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1541 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1501 {
1542 {
1502 unsigned int k;
1543 unsigned int k;
1503 unsigned int packetLength;
1544 unsigned int packetLength;
1504
1545
1505 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1546 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1506
1547
1507 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1548 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1508 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1549 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1509 kcoefficients_dump->reserved = CCSDS_RESERVED;
1550 kcoefficients_dump->reserved = CCSDS_RESERVED;
1510 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1551 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1511 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1552 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1512 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1553 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1513 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1554 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1514 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1555 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1515 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1556 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1516 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1557 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1517 // DATA FIELD HEADER
1558 // DATA FIELD HEADER
1518 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1559 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1519 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1560 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1520 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1561 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1521 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1562 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1522 kcoefficients_dump->time[0] = 0x00;
1563 kcoefficients_dump->time[0] = 0x00;
1523 kcoefficients_dump->time[1] = 0x00;
1564 kcoefficients_dump->time[1] = 0x00;
1524 kcoefficients_dump->time[2] = 0x00;
1565 kcoefficients_dump->time[2] = 0x00;
1525 kcoefficients_dump->time[3] = 0x00;
1566 kcoefficients_dump->time[3] = 0x00;
1526 kcoefficients_dump->time[4] = 0x00;
1567 kcoefficients_dump->time[4] = 0x00;
1527 kcoefficients_dump->time[5] = 0x00;
1568 kcoefficients_dump->time[5] = 0x00;
1528 kcoefficients_dump->sid = SID_K_DUMP;
1569 kcoefficients_dump->sid = SID_K_DUMP;
1529
1570
1530 kcoefficients_dump->pkt_cnt = 2;
1571 kcoefficients_dump->pkt_cnt = 2;
1531 kcoefficients_dump->pkt_nr = pkt_nr;
1572 kcoefficients_dump->pkt_nr = pkt_nr;
1532 kcoefficients_dump->blk_nr = blk_nr;
1573 kcoefficients_dump->blk_nr = blk_nr;
1533
1574
1534 //******************
1575 //******************
1535 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1576 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1536 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1577 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1537 for (k=0; k<3900; k++)
1578 for (k=0; k<3900; k++)
1538 {
1579 {
1539 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1580 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1540 }
1581 }
1541 }
1582 }
1542
1583
1543 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1584 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1544 {
1585 {
1545 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1586 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1546 *
1587 *
1547 * @param packet_sequence_control points to the packet sequence control which will be incremented
1588 * @param packet_sequence_control points to the packet sequence control which will be incremented
1548 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1589 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1549 *
1590 *
1550 * If the destination ID is not known, a dedicated counter is incremented.
1591 * If the destination ID is not known, a dedicated counter is incremented.
1551 *
1592 *
1552 */
1593 */
1553
1594
1554 unsigned short sequence_cnt;
1595 unsigned short sequence_cnt;
1555 unsigned short segmentation_grouping_flag;
1596 unsigned short segmentation_grouping_flag;
1556 unsigned short new_packet_sequence_control;
1597 unsigned short new_packet_sequence_control;
1557 unsigned char i;
1598 unsigned char i;
1558
1599
1559 switch (destination_id)
1600 switch (destination_id)
1560 {
1601 {
1561 case SID_TC_GROUND:
1602 case SID_TC_GROUND:
1562 i = GROUND;
1603 i = GROUND;
1563 break;
1604 break;
1564 case SID_TC_MISSION_TIMELINE:
1605 case SID_TC_MISSION_TIMELINE:
1565 i = MISSION_TIMELINE;
1606 i = MISSION_TIMELINE;
1566 break;
1607 break;
1567 case SID_TC_TC_SEQUENCES:
1608 case SID_TC_TC_SEQUENCES:
1568 i = TC_SEQUENCES;
1609 i = TC_SEQUENCES;
1569 break;
1610 break;
1570 case SID_TC_RECOVERY_ACTION_CMD:
1611 case SID_TC_RECOVERY_ACTION_CMD:
1571 i = RECOVERY_ACTION_CMD;
1612 i = RECOVERY_ACTION_CMD;
1572 break;
1613 break;
1573 case SID_TC_BACKUP_MISSION_TIMELINE:
1614 case SID_TC_BACKUP_MISSION_TIMELINE:
1574 i = BACKUP_MISSION_TIMELINE;
1615 i = BACKUP_MISSION_TIMELINE;
1575 break;
1616 break;
1576 case SID_TC_DIRECT_CMD:
1617 case SID_TC_DIRECT_CMD:
1577 i = DIRECT_CMD;
1618 i = DIRECT_CMD;
1578 break;
1619 break;
1579 case SID_TC_SPARE_GRD_SRC1:
1620 case SID_TC_SPARE_GRD_SRC1:
1580 i = SPARE_GRD_SRC1;
1621 i = SPARE_GRD_SRC1;
1581 break;
1622 break;
1582 case SID_TC_SPARE_GRD_SRC2:
1623 case SID_TC_SPARE_GRD_SRC2:
1583 i = SPARE_GRD_SRC2;
1624 i = SPARE_GRD_SRC2;
1584 break;
1625 break;
1585 case SID_TC_OBCP:
1626 case SID_TC_OBCP:
1586 i = OBCP;
1627 i = OBCP;
1587 break;
1628 break;
1588 case SID_TC_SYSTEM_CONTROL:
1629 case SID_TC_SYSTEM_CONTROL:
1589 i = SYSTEM_CONTROL;
1630 i = SYSTEM_CONTROL;
1590 break;
1631 break;
1591 case SID_TC_AOCS:
1632 case SID_TC_AOCS:
1592 i = AOCS;
1633 i = AOCS;
1593 break;
1634 break;
1594 case SID_TC_RPW_INTERNAL:
1635 case SID_TC_RPW_INTERNAL:
1595 i = RPW_INTERNAL;
1636 i = RPW_INTERNAL;
1596 break;
1637 break;
1597 default:
1638 default:
1598 i = GROUND;
1639 i = GROUND;
1599 break;
1640 break;
1600 }
1641 }
1601
1642
1602 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1643 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1603 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1644 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1604
1645
1605 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1646 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1606
1647
1607 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1648 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1608 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1649 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1609
1650
1610 // increment the sequence counter
1651 // increment the sequence counter
1611 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1652 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1612 {
1653 {
1613 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1654 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1614 }
1655 }
1615 else
1656 else
1616 {
1657 {
1617 sequenceCounters_TM_DUMP[ i ] = 0;
1658 sequenceCounters_TM_DUMP[ i ] = 0;
1618 }
1659 }
1619 }
1660 }
General Comments 0
You need to be logged in to leave comments. Login now