##// END OF EJS Templates
3.0.0.15
paul -
r258:1259d1eafcaf 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=15 # 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,1617 +1,1624
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
151 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
152 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
153
152 return LFR_DEFAULT;
154 return LFR_DEFAULT;
153 }
155 }
154
156
155 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
157 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
156 {
158 {
157 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
159 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
158 *
160 *
159 * @param TC points to the TeleCommand packet that is being processed
161 * @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
162 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
161 *
163 *
162 */
164 */
163
165
164 rtems_status_code status;
166 rtems_status_code status;
165 unsigned char requestedMode;
167 unsigned char requestedMode;
166 unsigned int *transitionCoarseTime_ptr;
168 unsigned int *transitionCoarseTime_ptr;
167 unsigned int transitionCoarseTime;
169 unsigned int transitionCoarseTime;
168 unsigned char * bytePosPtr;
170 unsigned char * bytePosPtr;
169
171
170 bytePosPtr = (unsigned char *) &TC->packetID;
172 bytePosPtr = (unsigned char *) &TC->packetID;
171
173
172 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
174 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
173 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
175 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
174 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
176 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
175
177
176 status = check_mode_value( requestedMode );
178 status = check_mode_value( requestedMode );
177
179
178 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
180 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
179 {
181 {
180 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
182 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
181 }
183 }
182
184
183 else // the mode value is valid, check the transition
185 else // the mode value is valid, check the transition
184 {
186 {
185 status = check_mode_transition(requestedMode);
187 status = check_mode_transition(requestedMode);
186 if (status != LFR_SUCCESSFUL)
188 if (status != LFR_SUCCESSFUL)
187 {
189 {
188 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
190 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
189 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
191 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
190 }
192 }
191 }
193 }
192
194
193 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
195 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
194 {
196 {
195 status = check_transition_date( transitionCoarseTime );
197 status = check_transition_date( transitionCoarseTime );
196 if (status != LFR_SUCCESSFUL)
198 if (status != LFR_SUCCESSFUL)
197 {
199 {
198 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
200 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
199 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
201 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
200 }
202 }
201 }
203 }
202
204
203 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
205 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
204 {
206 {
205 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
207 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
206
208
207 update_last_valid_transition_date( transitionCoarseTime );
209 update_last_valid_transition_date( transitionCoarseTime );
208
210
209 switch(requestedMode)
211 switch(requestedMode)
210 {
212 {
211 case LFR_MODE_STANDBY:
213 case LFR_MODE_STANDBY:
212 status = enter_mode_standby();
214 status = enter_mode_standby();
213 break;
215 break;
214 case LFR_MODE_NORMAL:
216 case LFR_MODE_NORMAL:
215 status = enter_mode_normal( transitionCoarseTime );
217 status = enter_mode_normal( transitionCoarseTime );
216 break;
218 break;
217 case LFR_MODE_BURST:
219 case LFR_MODE_BURST:
218 status = enter_mode_burst( transitionCoarseTime );
220 status = enter_mode_burst( transitionCoarseTime );
219 break;
221 break;
220 case LFR_MODE_SBM1:
222 case LFR_MODE_SBM1:
221 status = enter_mode_sbm1( transitionCoarseTime );
223 status = enter_mode_sbm1( transitionCoarseTime );
222 break;
224 break;
223 case LFR_MODE_SBM2:
225 case LFR_MODE_SBM2:
224 status = enter_mode_sbm2( transitionCoarseTime );
226 status = enter_mode_sbm2( transitionCoarseTime );
225 break;
227 break;
226 default:
228 default:
227 break;
229 break;
228 }
230 }
229 }
231 }
230
232
233 if (status != RTEMS_SUCCESSFUL)
234 {
235 status = LFR_EXE_ERROR;
236 }
237
231 return status;
238 return status;
232 }
239 }
233
240
234 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
241 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
235 {
242 {
236 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
243 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
237 *
244 *
238 * @param TC points to the TeleCommand packet that is being processed
245 * @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
246 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
240 *
247 *
241 * @return LFR directive status code:
248 * @return LFR directive status code:
242 * - LFR_DEFAULT
249 * - LFR_DEFAULT
243 * - LFR_SUCCESSFUL
250 * - LFR_SUCCESSFUL
244 *
251 *
245 */
252 */
246
253
247 unsigned int val;
254 unsigned int val;
248 int result;
255 int result;
249 unsigned int status;
256 unsigned int status;
250 unsigned char mode;
257 unsigned char mode;
251 unsigned char * bytePosPtr;
258 unsigned char * bytePosPtr;
252
259
253 bytePosPtr = (unsigned char *) &TC->packetID;
260 bytePosPtr = (unsigned char *) &TC->packetID;
254
261
255 // check LFR mode
262 // check LFR mode
256 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
263 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
257 status = check_update_info_hk_lfr_mode( mode );
264 status = check_update_info_hk_lfr_mode( mode );
258 if (status == LFR_SUCCESSFUL) // check TDS mode
265 if (status == LFR_SUCCESSFUL) // check TDS mode
259 {
266 {
260 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
267 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
261 status = check_update_info_hk_tds_mode( mode );
268 status = check_update_info_hk_tds_mode( mode );
262 }
269 }
263 if (status == LFR_SUCCESSFUL) // check THR mode
270 if (status == LFR_SUCCESSFUL) // check THR mode
264 {
271 {
265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
272 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
266 status = check_update_info_hk_thr_mode( mode );
273 status = check_update_info_hk_thr_mode( mode );
267 }
274 }
268 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
275 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
269 {
276 {
270 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
277 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
271 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
278 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
272 val++;
279 val++;
273 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
280 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);
281 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
275 }
282 }
276
283
277 // pa_bia_status_info
284 // pa_bia_status_info
278 // => pa_bia_mode_mux_set 3 bits
285 // => pa_bia_mode_mux_set 3 bits
279 // => pa_bia_mode_hv_enabled 1 bit
286 // => pa_bia_mode_hv_enabled 1 bit
280 // => pa_bia_mode_bias1_enabled 1 bit
287 // => pa_bia_mode_bias1_enabled 1 bit
281 // => pa_bia_mode_bias2_enabled 1 bit
288 // => pa_bia_mode_bias2_enabled 1 bit
282 // => pa_bia_mode_bias3_enabled 1 bit
289 // => pa_bia_mode_bias3_enabled 1 bit
283 // => pa_bia_on_off (cp_dpu_bias_on_off)
290 // => pa_bia_on_off (cp_dpu_bias_on_off)
284 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
291 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
285 pa_bia_status_info = pa_bia_status_info
292 pa_bia_status_info = pa_bia_status_info
286 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
293 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
287
294
288 result = status;
295 result = status;
289
296
290 return result;
297 return result;
291 }
298 }
292
299
293 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
300 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
294 {
301 {
295 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
302 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
296 *
303 *
297 * @param TC points to the TeleCommand packet that is being processed
304 * @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
305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
299 *
306 *
300 */
307 */
301
308
302 int result;
309 int result;
303
310
304 result = LFR_DEFAULT;
311 result = LFR_DEFAULT;
305
312
306 setCalibration( true );
313 setCalibration( true );
307
314
308 result = LFR_SUCCESSFUL;
315 result = LFR_SUCCESSFUL;
309
316
310 return result;
317 return result;
311 }
318 }
312
319
313 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
320 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
314 {
321 {
315 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
322 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
316 *
323 *
317 * @param TC points to the TeleCommand packet that is being processed
324 * @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
325 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
319 *
326 *
320 */
327 */
321
328
322 int result;
329 int result;
323
330
324 result = LFR_DEFAULT;
331 result = LFR_DEFAULT;
325
332
326 setCalibration( false );
333 setCalibration( false );
327
334
328 result = LFR_SUCCESSFUL;
335 result = LFR_SUCCESSFUL;
329
336
330 return result;
337 return result;
331 }
338 }
332
339
333 int action_update_time(ccsdsTelecommandPacket_t *TC)
340 int action_update_time(ccsdsTelecommandPacket_t *TC)
334 {
341 {
335 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
342 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
336 *
343 *
337 * @param TC points to the TeleCommand packet that is being processed
344 * @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
345 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
339 *
346 *
340 * @return LFR_SUCCESSFUL
347 * @return LFR_SUCCESSFUL
341 *
348 *
342 */
349 */
343
350
344 unsigned int val;
351 unsigned int val;
345
352
346 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
353 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
347 + (TC->dataAndCRC[1] << 16)
354 + (TC->dataAndCRC[1] << 16)
348 + (TC->dataAndCRC[2] << 8)
355 + (TC->dataAndCRC[2] << 8)
349 + TC->dataAndCRC[3];
356 + TC->dataAndCRC[3];
350
357
351 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
358 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
352 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
359 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
353 val++;
360 val++;
354 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
361 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);
362 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
356
363
357 return LFR_SUCCESSFUL;
364 return LFR_SUCCESSFUL;
358 }
365 }
359
366
360 //*******************
367 //*******************
361 // ENTERING THE MODES
368 // ENTERING THE MODES
362 int check_mode_value( unsigned char requestedMode )
369 int check_mode_value( unsigned char requestedMode )
363 {
370 {
364 int status;
371 int status;
365
372
366 if ( (requestedMode != LFR_MODE_STANDBY)
373 if ( (requestedMode != LFR_MODE_STANDBY)
367 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
374 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
368 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
375 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
369 {
376 {
370 status = LFR_DEFAULT;
377 status = LFR_DEFAULT;
371 }
378 }
372 else
379 else
373 {
380 {
374 status = LFR_SUCCESSFUL;
381 status = LFR_SUCCESSFUL;
375 }
382 }
376
383
377 return status;
384 return status;
378 }
385 }
379
386
380 int check_mode_transition( unsigned char requestedMode )
387 int check_mode_transition( unsigned char requestedMode )
381 {
388 {
382 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
389 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
383 *
390 *
384 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
391 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
385 *
392 *
386 * @return LFR directive status codes:
393 * @return LFR directive status codes:
387 * - LFR_SUCCESSFUL - the transition is authorized
394 * - LFR_SUCCESSFUL - the transition is authorized
388 * - LFR_DEFAULT - the transition is not authorized
395 * - LFR_DEFAULT - the transition is not authorized
389 *
396 *
390 */
397 */
391
398
392 int status;
399 int status;
393
400
394 switch (requestedMode)
401 switch (requestedMode)
395 {
402 {
396 case LFR_MODE_STANDBY:
403 case LFR_MODE_STANDBY:
397 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
404 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
398 status = LFR_DEFAULT;
405 status = LFR_DEFAULT;
399 }
406 }
400 else
407 else
401 {
408 {
402 status = LFR_SUCCESSFUL;
409 status = LFR_SUCCESSFUL;
403 }
410 }
404 break;
411 break;
405 case LFR_MODE_NORMAL:
412 case LFR_MODE_NORMAL:
406 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
413 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
407 status = LFR_DEFAULT;
414 status = LFR_DEFAULT;
408 }
415 }
409 else {
416 else {
410 status = LFR_SUCCESSFUL;
417 status = LFR_SUCCESSFUL;
411 }
418 }
412 break;
419 break;
413 case LFR_MODE_BURST:
420 case LFR_MODE_BURST:
414 if ( lfrCurrentMode == LFR_MODE_BURST ) {
421 if ( lfrCurrentMode == LFR_MODE_BURST ) {
415 status = LFR_DEFAULT;
422 status = LFR_DEFAULT;
416 }
423 }
417 else {
424 else {
418 status = LFR_SUCCESSFUL;
425 status = LFR_SUCCESSFUL;
419 }
426 }
420 break;
427 break;
421 case LFR_MODE_SBM1:
428 case LFR_MODE_SBM1:
422 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
429 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
423 status = LFR_DEFAULT;
430 status = LFR_DEFAULT;
424 }
431 }
425 else {
432 else {
426 status = LFR_SUCCESSFUL;
433 status = LFR_SUCCESSFUL;
427 }
434 }
428 break;
435 break;
429 case LFR_MODE_SBM2:
436 case LFR_MODE_SBM2:
430 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
437 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
431 status = LFR_DEFAULT;
438 status = LFR_DEFAULT;
432 }
439 }
433 else {
440 else {
434 status = LFR_SUCCESSFUL;
441 status = LFR_SUCCESSFUL;
435 }
442 }
436 break;
443 break;
437 default:
444 default:
438 status = LFR_DEFAULT;
445 status = LFR_DEFAULT;
439 break;
446 break;
440 }
447 }
441
448
442 return status;
449 return status;
443 }
450 }
444
451
445 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
452 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
446 {
453 {
447 if (transitionCoarseTime == 0)
454 if (transitionCoarseTime == 0)
448 {
455 {
449 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
456 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
450 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", transitionCoarseTime);
457 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", transitionCoarseTime);
451 }
458 }
452 else
459 else
453 {
460 {
454 lastValidEnterModeTime = transitionCoarseTime;
461 lastValidEnterModeTime = transitionCoarseTime;
455 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
462 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
456 }
463 }
457 }
464 }
458
465
459 int check_transition_date( unsigned int transitionCoarseTime )
466 int check_transition_date( unsigned int transitionCoarseTime )
460 {
467 {
461 int status;
468 int status;
462 unsigned int localCoarseTime;
469 unsigned int localCoarseTime;
463 unsigned int deltaCoarseTime;
470 unsigned int deltaCoarseTime;
464
471
465 status = LFR_SUCCESSFUL;
472 status = LFR_SUCCESSFUL;
466
473
467 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
474 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
468 {
475 {
469 status = LFR_SUCCESSFUL;
476 status = LFR_SUCCESSFUL;
470 }
477 }
471 else
478 else
472 {
479 {
473 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
480 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
474
481
475 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
482