##// END OF EJS Templates
3.0.0.14
paul -
r255:8000c9c61c45 R3a
parent child
Show More
@@ -1,124 +1,124
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options =
3 # CONFIG options =
4 # verbose
4 # verbose
5 # boot_messages
5 # boot_messages
6 # debug_messages
6 # debug_messages
7 # cpu_usage_report
7 # cpu_usage_report
8 # stack_report
8 # stack_report
9 # vhdl_dev
9 # vhdl_dev
10 # debug_tch
10 # debug_tch
11 # lpp_dpu_destid REMOVE BEFORE DELIVERY TO LESIA
11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
12 # debug_watchdog
12 # debug_watchdog
13 CONFIG += console verbose lpp_dpu_destid
13 CONFIG += console verbose lpp_dpu_destid
14 CONFIG -= qt
14 CONFIG -= qt
15
15
16 include(./sparc.pri)
16 include(./sparc.pri)
17
17
18 # flight software version
18 # flight software version
19 SWVERSION=-1-0
19 SWVERSION=-1-0
20 DEFINES += SW_VERSION_N1=3 # major
20 DEFINES += SW_VERSION_N1=3 # major
21 DEFINES += SW_VERSION_N2=0 # minor
21 DEFINES += SW_VERSION_N2=0 # minor
22 DEFINES += SW_VERSION_N3=0 # patch
22 DEFINES += SW_VERSION_N3=0 # patch
23 DEFINES += SW_VERSION_N4=14 # internal
23 DEFINES += SW_VERSION_N4=14 # internal
24
24
25 # <GCOV>
25 # <GCOV>
26 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
26 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
27 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
27 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
28 # </GCOV>
28 # </GCOV>
29
29
30 # <CHANGE BEFORE FLIGHT>
30 # <CHANGE BEFORE FLIGHT>
31 contains( CONFIG, lpp_dpu_destid ) {
31 contains( CONFIG, lpp_dpu_destid ) {
32 DEFINES += LPP_DPU_DESTID
32 DEFINES += LPP_DPU_DESTID
33 }
33 }
34 # </CHANGE BEFORE FLIGHT>
34 # </CHANGE BEFORE FLIGHT>
35
35
36 contains( CONFIG, debug_tch ) {
36 contains( CONFIG, debug_tch ) {
37 DEFINES += DEBUG_TCH
37 DEFINES += DEBUG_TCH
38 }
38 }
39 DEFINES += MSB_FIRST_TCH
39 DEFINES += MSB_FIRST_TCH
40
40
41 contains( CONFIG, vhdl_dev ) {
41 contains( CONFIG, vhdl_dev ) {
42 DEFINES += VHDL_DEV
42 DEFINES += VHDL_DEV
43 }
43 }
44
44
45 contains( CONFIG, verbose ) {
45 contains( CONFIG, verbose ) {
46 DEFINES += PRINT_MESSAGES_ON_CONSOLE
46 DEFINES += PRINT_MESSAGES_ON_CONSOLE
47 }
47 }
48
48
49 contains( CONFIG, debug_messages ) {
49 contains( CONFIG, debug_messages ) {
50 DEFINES += DEBUG_MESSAGES
50 DEFINES += DEBUG_MESSAGES
51 }
51 }
52
52
53 contains( CONFIG, cpu_usage_report ) {
53 contains( CONFIG, cpu_usage_report ) {
54 DEFINES += PRINT_TASK_STATISTICS
54 DEFINES += PRINT_TASK_STATISTICS
55 }
55 }
56
56
57 contains( CONFIG, stack_report ) {
57 contains( CONFIG, stack_report ) {
58 DEFINES += PRINT_STACK_REPORT
58 DEFINES += PRINT_STACK_REPORT
59 }
59 }
60
60
61 contains( CONFIG, boot_messages ) {
61 contains( CONFIG, boot_messages ) {
62 DEFINES += BOOT_MESSAGES
62 DEFINES += BOOT_MESSAGES
63 }
63 }
64
64
65 contains( CONFIG, debug_watchdog ) {
65 contains( CONFIG, debug_watchdog ) {
66 DEFINES += DEBUG_WATCHDOG
66 DEFINES += DEBUG_WATCHDOG
67 }
67 }
68
68
69 #doxygen.target = doxygen
69 #doxygen.target = doxygen
70 #doxygen.commands = doxygen ../doc/Doxyfile
70 #doxygen.commands = doxygen ../doc/Doxyfile
71 #QMAKE_EXTRA_TARGETS += doxygen
71 #QMAKE_EXTRA_TARGETS += doxygen
72
72
73 TARGET = fsw
73 TARGET = fsw
74
74
75 INCLUDEPATH += \
75 INCLUDEPATH += \
76 $${PWD}/../src \
76 $${PWD}/../src \
77 $${PWD}/../header \
77 $${PWD}/../header \
78 $${PWD}/../header/lfr_common_headers \
78 $${PWD}/../header/lfr_common_headers \
79 $${PWD}/../header/processing \
79 $${PWD}/../header/processing \
80 $${PWD}/../LFR_basic-parameters
80 $${PWD}/../LFR_basic-parameters
81
81
82 SOURCES += \
82 SOURCES += \
83 ../src/wf_handler.c \
83 ../src/wf_handler.c \
84 ../src/tc_handler.c \
84 ../src/tc_handler.c \
85 ../src/fsw_misc.c \
85 ../src/fsw_misc.c \
86 ../src/fsw_init.c \
86 ../src/fsw_init.c \
87 ../src/fsw_globals.c \
87 ../src/fsw_globals.c \
88 ../src/fsw_spacewire.c \
88 ../src/fsw_spacewire.c \
89 ../src/tc_load_dump_parameters.c \
89 ../src/tc_load_dump_parameters.c \
90 ../src/tm_lfr_tc_exe.c \
90 ../src/tm_lfr_tc_exe.c \
91 ../src/tc_acceptance.c \
91 ../src/tc_acceptance.c \
92 ../src/processing/fsw_processing.c \
92 ../src/processing/fsw_processing.c \
93 ../src/processing/avf0_prc0.c \
93 ../src/processing/avf0_prc0.c \
94 ../src/processing/avf1_prc1.c \
94 ../src/processing/avf1_prc1.c \
95 ../src/processing/avf2_prc2.c \
95 ../src/processing/avf2_prc2.c \
96 ../src/lfr_cpu_usage_report.c \
96 ../src/lfr_cpu_usage_report.c \
97 ../LFR_basic-parameters/basic_parameters.c
97 ../LFR_basic-parameters/basic_parameters.c
98
98
99 HEADERS += \
99 HEADERS += \
100 ../header/wf_handler.h \
100 ../header/wf_handler.h \
101 ../header/tc_handler.h \
101 ../header/tc_handler.h \
102 ../header/grlib_regs.h \
102 ../header/grlib_regs.h \
103 ../header/fsw_misc.h \
103 ../header/fsw_misc.h \
104 ../header/fsw_init.h \
104 ../header/fsw_init.h \
105 ../header/fsw_spacewire.h \
105 ../header/fsw_spacewire.h \
106 ../header/tc_load_dump_parameters.h \
106 ../header/tc_load_dump_parameters.h \
107 ../header/tm_lfr_tc_exe.h \
107 ../header/tm_lfr_tc_exe.h \
108 ../header/tc_acceptance.h \
108 ../header/tc_acceptance.h \
109 ../header/processing/fsw_processing.h \
109 ../header/processing/fsw_processing.h \
110 ../header/processing/avf0_prc0.h \
110 ../header/processing/avf0_prc0.h \
111 ../header/processing/avf1_prc1.h \
111 ../header/processing/avf1_prc1.h \
112 ../header/processing/avf2_prc2.h \
112 ../header/processing/avf2_prc2.h \
113 ../header/fsw_params_wf_handler.h \
113 ../header/fsw_params_wf_handler.h \
114 ../header/lfr_cpu_usage_report.h \
114 ../header/lfr_cpu_usage_report.h \
115 ../header/lfr_common_headers/ccsds_types.h \
115 ../header/lfr_common_headers/ccsds_types.h \
116 ../header/lfr_common_headers/fsw_params.h \
116 ../header/lfr_common_headers/fsw_params.h \
117 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
117 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
118 ../header/lfr_common_headers/fsw_params_processing.h \
118 ../header/lfr_common_headers/fsw_params_processing.h \
119 ../header/lfr_common_headers/TC_types.h \
119 ../header/lfr_common_headers/TC_types.h \
120 ../header/lfr_common_headers/tm_byte_positions.h \
120 ../header/lfr_common_headers/tm_byte_positions.h \
121 ../LFR_basic-parameters/basic_parameters.h \
121 ../LFR_basic-parameters/basic_parameters.h \
122 ../LFR_basic-parameters/basic_parameters_params.h \
122 ../LFR_basic-parameters/basic_parameters_params.h \
123 ../header/GscMemoryLPP.hpp
123 ../header/GscMemoryLPP.hpp
124
124
@@ -1,1606 +1,1606
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_UPDT_TIME:
126 case TC_SUBTYPE_UPDT_TIME:
127 result = action_update_time( &TC );
127 result = action_update_time( &TC );
128 close_action( &TC, result, queue_snd_id );
128 close_action( &TC, result, queue_snd_id );
129 break;
129 break;
130 default:
130 default:
131 break;
131 break;
132 }
132 }
133 }
133 }
134 }
134 }
135 }
135 }
136
136
137 //***********
137 //***********
138 // TC ACTIONS
138 // TC ACTIONS
139
139
140 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
141 {
141 {
142 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
143 *
143 *
144 * @param TC points to the TeleCommand packet that is being processed
144 * @param TC points to the TeleCommand packet that is being processed
145 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
146 *
146 *
147 */
147 */
148
148
149 PRINTF("this is the end!!!\n")
149 PRINTF("this is the end!!!\n")
150 exit(0);
150 exit(0);
151 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
151 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
152 return LFR_DEFAULT;
152 return LFR_DEFAULT;
153 }
153 }
154
154
155 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
155 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
156 {
156 {
157 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
157 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
158 *
158 *
159 * @param TC points to the TeleCommand packet that is being processed
159 * @param TC points to the TeleCommand packet that is being processed
160 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
160 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
161 *
161 *
162 */
162 */
163
163
164 rtems_status_code status;
164 rtems_status_code status;
165 unsigned char requestedMode;
165 unsigned char requestedMode;
166 unsigned int *transitionCoarseTime_ptr;
166 unsigned int *transitionCoarseTime_ptr;
167 unsigned int transitionCoarseTime;
167 unsigned int transitionCoarseTime;
168 unsigned char * bytePosPtr;
168 unsigned char * bytePosPtr;
169
169
170 bytePosPtr = (unsigned char *) &TC->packetID;
170 bytePosPtr = (unsigned char *) &TC->packetID;
171
171
172 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
172 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
173 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
173 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
174 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
174 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
175
175
176 status = check_mode_value( requestedMode );
176 status = check_mode_value( requestedMode );
177
177
178 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
178 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
179 {
179 {
180 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
180 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
181 }
181 }
182
182
183 else // the mode value is valid, check the transition
183 else // the mode value is valid, check the transition
184 {
184 {
185 status = check_mode_transition(requestedMode);
185 status = check_mode_transition(requestedMode);
186 if (status != LFR_SUCCESSFUL)
186 if (status != LFR_SUCCESSFUL)
187 {
187 {
188 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
188 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
189 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
189 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
190 }
190 }
191 }
191 }
192
192
193 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
193 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
194 {
194 {
195 status = check_transition_date( transitionCoarseTime );
195 status = check_transition_date( transitionCoarseTime );
196 if (status != LFR_SUCCESSFUL)
196 if (status != LFR_SUCCESSFUL)
197 {
197 {
198 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
198 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
199 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
199 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
200 }
200 }
201 }
201 }
202
202
203 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
203 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
204 {
204 {
205 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
205 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
206
206
207 update_last_valid_transition_date( transitionCoarseTime );
207 update_last_valid_transition_date( transitionCoarseTime );
208
208
209 switch(requestedMode)
209 switch(requestedMode)
210 {
210 {
211 case LFR_MODE_STANDBY:
211 case LFR_MODE_STANDBY:
212 status = enter_mode_standby();
212 status = enter_mode_standby();
213 break;
213 break;
214 case LFR_MODE_NORMAL:
214 case LFR_MODE_NORMAL:
215 status = enter_mode_normal( transitionCoarseTime );
215 status = enter_mode_normal( transitionCoarseTime );
216 break;
216 break;
217 case LFR_MODE_BURST:
217 case LFR_MODE_BURST:
218 status = enter_mode_burst( transitionCoarseTime );
218 status = enter_mode_burst( transitionCoarseTime );
219 break;
219 break;
220 case LFR_MODE_SBM1:
220 case LFR_MODE_SBM1:
221 status = enter_mode_sbm1( transitionCoarseTime );
221 status = enter_mode_sbm1( transitionCoarseTime );
222 break;
222 break;
223 case LFR_MODE_SBM2:
223 case LFR_MODE_SBM2:
224 status = enter_mode_sbm2( transitionCoarseTime );
224 status = enter_mode_sbm2( transitionCoarseTime );
225 break;
225 break;
226 default:
226 default:
227 break;
227 break;
228 }
228 }
229 }
229 }
230
230
231 return status;
231 return status;
232 }
232 }
233
233
234 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
234 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
235 {
235 {
236 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
236 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
237 *
237 *
238 * @param TC points to the TeleCommand packet that is being processed
238 * @param TC points to the TeleCommand packet that is being processed
239 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
239 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
240 *
240 *
241 * @return LFR directive status code:
241 * @return LFR directive status code:
242 * - LFR_DEFAULT
242 * - LFR_DEFAULT
243 * - LFR_SUCCESSFUL
243 * - LFR_SUCCESSFUL
244 *
244 *
245 */
245 */
246
246
247 unsigned int val;
247 unsigned int val;
248 int result;
248 int result;
249 unsigned int status;
249 unsigned int status;
250 unsigned char mode;
250 unsigned char mode;
251 unsigned char * bytePosPtr;
251 unsigned char * bytePosPtr;
252
252
253 bytePosPtr = (unsigned char *) &TC->packetID;
253 bytePosPtr = (unsigned char *) &TC->packetID;
254
254
255 // check LFR mode
255 // check LFR mode
256 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
256 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
257 status = check_update_info_hk_lfr_mode( mode );
257 status = check_update_info_hk_lfr_mode( mode );
258 if (status == LFR_SUCCESSFUL) // check TDS mode
258 if (status == LFR_SUCCESSFUL) // check TDS mode
259 {
259 {
260 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
260 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
261 status = check_update_info_hk_tds_mode( mode );
261 status = check_update_info_hk_tds_mode( mode );
262 }
262 }
263 if (status == LFR_SUCCESSFUL) // check THR mode
263 if (status == LFR_SUCCESSFUL) // check THR mode
264 {
264 {
265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
266 status = check_update_info_hk_thr_mode( mode );
266 status = check_update_info_hk_thr_mode( mode );
267 }
267 }
268 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
268 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
269 {
269 {
270 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
270 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
271 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
271 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
272 val++;
272 val++;
273 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
273 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
274 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
274 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
275 }
275 }
276
276
277 // pa_bia_status_info
277 // pa_bia_status_info
278 // => pa_bia_mode_mux_set 3 bits
278 // => pa_bia_mode_mux_set 3 bits
279 // => pa_bia_mode_hv_enabled 1 bit
279 // => pa_bia_mode_hv_enabled 1 bit
280 // => pa_bia_mode_bias1_enabled 1 bit
280 // => pa_bia_mode_bias1_enabled 1 bit
281 // => pa_bia_mode_bias2_enabled 1 bit
281 // => pa_bia_mode_bias2_enabled 1 bit
282 // => pa_bia_mode_bias3_enabled 1 bit
282 // => pa_bia_mode_bias3_enabled 1 bit
283 // => pa_bia_on_off (cp_dpu_bias_on_off)
283 // => pa_bia_on_off (cp_dpu_bias_on_off)
284 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
284 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
285 pa_bia_status_info = pa_bia_status_info
285 pa_bia_status_info = pa_bia_status_info
286 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
286 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
287
287
288 result = status;
288 result = status;
289
289
290 return result;
290 return result;
291 }
291 }
292
292
293 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
293 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
294 {
294 {
295 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
295 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
296 *
296 *
297 * @param TC points to the TeleCommand packet that is being processed
297 * @param TC points to the TeleCommand packet that is being processed
298 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
298 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
299 *
299 *
300 */
300 */
301
301
302 int result;
302 int result;
303
303
304 result = LFR_DEFAULT;
304 result = LFR_DEFAULT;
305
305
306 setCalibration( true );
306 setCalibration( true );
307
307
308 result = LFR_SUCCESSFUL;
308 result = LFR_SUCCESSFUL;
309
309
310 return result;
310 return result;
311 }
311 }
312
312
313 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
313 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
314 {
314 {
315 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
315 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
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 transmission by the SpaceWire driver
318 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
319 *
319 *
320 */
320 */
321
321
322 int result;
322 int result;
323
323
324 result = LFR_DEFAULT;
324 result = LFR_DEFAULT;
325
325
326 setCalibration( false );
326 setCalibration( false );
327
327
328 result = LFR_SUCCESSFUL;
328 result = LFR_SUCCESSFUL;
329
329
330 return result;
330 return result;
331 }
331 }
332
332
333 int action_update_time(ccsdsTelecommandPacket_t *TC)
333 int action_update_time(ccsdsTelecommandPacket_t *TC)
334 {
334 {
335 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
335 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
336 *
336 *
337 * @param TC points to the TeleCommand packet that is being processed
337 * @param TC points to the TeleCommand packet that is being processed
338 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
338 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
339 *
339 *
340 * @return LFR_SUCCESSFUL
340 * @return LFR_SUCCESSFUL
341 *
341 *
342 */
342 */
343
343
344 unsigned int val;
344 unsigned int val;
345
345
346 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
346 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
347 + (TC->dataAndCRC[1] << 16)
347 + (TC->dataAndCRC[1] << 16)
348 + (TC->dataAndCRC[2] << 8)
348 + (TC->dataAndCRC[2] << 8)
349 + TC->dataAndCRC[3];
349 + TC->dataAndCRC[3];
350
350
351 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
351 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
352 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
352 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
353 val++;
353 val++;
354 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
354 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
355 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
355 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
356
356
357 return LFR_SUCCESSFUL;
357 return LFR_SUCCESSFUL;
358 }
358 }
359
359
360 //*******************
360 //*******************
361 // ENTERING THE MODES
361 // ENTERING THE MODES
362 int check_mode_value( unsigned char requestedMode )
362 int check_mode_value( unsigned char requestedMode )
363 {
363 {
364 int status;
364 int status;
365
365
366 if ( (requestedMode != LFR_MODE_STANDBY)
366 if ( (requestedMode != LFR_MODE_STANDBY)
367 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
367 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
368 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
368 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
369 {
369 {
370 status = LFR_DEFAULT;
370 status = LFR_DEFAULT;
371 }
371 }
372 else
372 else
373 {
373 {
374 status = LFR_SUCCESSFUL;
374 status = LFR_SUCCESSFUL;
375 }
375 }
376
376
377 return status;
377 return status;
378 }
378 }
379
379
380 int check_mode_transition( unsigned char requestedMode )
380 int check_mode_transition( unsigned char requestedMode )
381 {
381 {
382 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
382 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
383 *
383 *
384 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
384 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
385 *
385 *
386 * @return LFR directive status codes:
386 * @return LFR directive status codes:
387 * - LFR_SUCCESSFUL - the transition is authorized
387 * - LFR_SUCCESSFUL - the transition is authorized
388 * - LFR_DEFAULT - the transition is not authorized
388 * - LFR_DEFAULT - the transition is not authorized
389 *
389 *
390 */
390 */
391
391
392 int status;
392 int status;
393
393
394 switch (requestedMode)
394 switch (requestedMode)
395 {
395 {
396 case LFR_MODE_STANDBY:
396 case LFR_MODE_STANDBY:
397 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
397 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
398 status = LFR_DEFAULT;
398 status = LFR_DEFAULT;
399 }
399 }
400 else
400 else
401 {
401 {
402 status = LFR_SUCCESSFUL;
402 status = LFR_SUCCESSFUL;
403 }
403 }
404 break;
404 break;
405 case LFR_MODE_NORMAL:
405 case LFR_MODE_NORMAL:
406 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
406 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
407 status = LFR_DEFAULT;
407 status = LFR_DEFAULT;
408 }
408 }
409 else {
409 else {
410 status = LFR_SUCCESSFUL;
410 status = LFR_SUCCESSFUL;
411 }
411 }
412 break;
412 break;
413 case LFR_MODE_BURST:
413 case LFR_MODE_BURST:
414 if ( lfrCurrentMode == LFR_MODE_BURST ) {
414 if ( lfrCurrentMode == LFR_MODE_BURST ) {
415 status = LFR_DEFAULT;
415 status = LFR_DEFAULT;
416 }
416 }
417 else {
417 else {
418 status = LFR_SUCCESSFUL;
418 status = LFR_SUCCESSFUL;
419 }
419 }
420 break;
420 break;
421 case LFR_MODE_SBM1:
421 case LFR_MODE_SBM1:
422 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
422 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
423 status = LFR_DEFAULT;
423 status = LFR_DEFAULT;
424 }
424 }
425 else {
425 else {
426 status = LFR_SUCCESSFUL;
426 status = LFR_SUCCESSFUL;
427 }
427 }
428 break;
428 break;
429 case LFR_MODE_SBM2:
429 case LFR_MODE_SBM2:
430 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
430 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
431 status = LFR_DEFAULT;
431 status = LFR_DEFAULT;
432 }
432 }
433 else {
433 else {
434 status = LFR_SUCCESSFUL;
434 status = LFR_SUCCESSFUL;
435 }
435 }
436 break;
436 break;
437 default:
437 default:
438 status = LFR_DEFAULT;
438 status = LFR_DEFAULT;
439 break;
439 break;
440 }
440 }
441
441
442 return status;
442 return status;
443 }
443 }
444
444
445 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
445 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
446 {
446 {
447 lastValidEnterModeTime = transitionCoarseTime;
447 lastValidEnterModeTime = transitionCoarseTime;
448 PRINTF1("lastValidEnterModeTime = %x\n", transitionCoarseTime);
448 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
449 }
449 }
450
450
451 int check_transition_date( unsigned int transitionCoarseTime )
451 int check_transition_date( unsigned int transitionCoarseTime )
452 {
452 {
453 int status;
453 int status;
454 unsigned int localCoarseTime;
454 unsigned int localCoarseTime;
455 unsigned int deltaCoarseTime;
455 unsigned int deltaCoarseTime;
456
456
457 status = LFR_SUCCESSFUL;
457 status = LFR_SUCCESSFUL;
458
458
459 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
459 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
460 {
460 {
461 status = LFR_SUCCESSFUL;
461 status = LFR_SUCCESSFUL;
462 }
462 }
463 else
463 else
464 {
464 {
465 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
465 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
466
466
467 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
467 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
468
468
469 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
469 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
470 {
470 {
471 status = LFR_DEFAULT;
471 status = LFR_DEFAULT;
472 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
472 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
473 }
473 }
474
474
475 if (status == LFR_SUCCESSFUL)
475 if (status == LFR_SUCCESSFUL)
476 {
476 {
477 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
477 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
478 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
478 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
479 {
479 {
480 status = LFR_DEFAULT;
480