@@ -1,2 +1,2 | |||||
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
2 | 1f3d7ce688e982a378d739596c8e3f8972f40b9d header/lfr_common_headers |
|
2 | c3197ff831df5057bdd145a4efd94ded0618661f header/lfr_common_headers |
@@ -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= |
|
21 | DEFINES += SW_VERSION_N2=1 # minor | |
22 | DEFINES += SW_VERSION_N3=0 # patch |
|
22 | DEFINES += SW_VERSION_N3=0 # patch | |
23 |
DEFINES += SW_VERSION_N4= |
|
23 | DEFINES += SW_VERSION_N4=0 # 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,72 +1,76 | |||||
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H | |
2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
2 | #define TC_LOAD_DUMP_PARAMETERS_H | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 |
|
6 | |||
7 | #include "fsw_params.h" |
|
7 | #include "fsw_params.h" | |
8 | #include "wf_handler.h" |
|
8 | #include "wf_handler.h" | |
9 | #include "tm_lfr_tc_exe.h" |
|
9 | #include "tm_lfr_tc_exe.h" | |
10 | #include "fsw_misc.h" |
|
10 | #include "fsw_misc.h" | |
11 | #include "basic_parameters_params.h" |
|
11 | #include "basic_parameters_params.h" | |
12 | #include "avf0_prc0.h" |
|
12 | #include "avf0_prc0.h" | |
13 |
|
13 | |||
14 | #define FLOAT_EQUAL_ZERO 0.001 |
|
14 | #define FLOAT_EQUAL_ZERO 0.001 | |
15 |
|
15 | |||
16 | extern unsigned short sequenceCounterParameterDump; |
|
16 | extern unsigned short sequenceCounterParameterDump; | |
17 | extern unsigned short sequenceCounters_TM_DUMP[]; |
|
17 | extern unsigned short sequenceCounters_TM_DUMP[]; | |
18 | extern float k_coeff_intercalib_f0_norm[ ]; |
|
18 | extern float k_coeff_intercalib_f0_norm[ ]; | |
19 | extern float k_coeff_intercalib_f0_sbm[ ]; |
|
19 | extern float k_coeff_intercalib_f0_sbm[ ]; | |
20 | extern float k_coeff_intercalib_f1_norm[ ]; |
|
20 | extern float k_coeff_intercalib_f1_norm[ ]; | |
21 | extern float k_coeff_intercalib_f1_sbm[ ]; |
|
21 | extern float k_coeff_intercalib_f1_sbm[ ]; | |
22 | extern float k_coeff_intercalib_f2[ ]; |
|
22 | extern float k_coeff_intercalib_f2[ ]; | |
23 |
|
23 | |||
24 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
24 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); | |
25 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
25 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
26 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
26 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
27 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
27 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
28 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
28 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
29 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
29 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
30 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
30 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
|
31 | int action_load_pas_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |||
31 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
32 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
32 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
33 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
33 |
|
34 | |||
34 | // NORMAL |
|
35 | // NORMAL | |
35 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
36 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
36 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
37 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); | |
37 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
38 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); | |
38 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
39 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); | |
39 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
40 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
40 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
41 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
41 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
42 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); | |
42 |
|
43 | |||
43 | // BURST |
|
44 | // BURST | |
44 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
45 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
45 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
46 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
46 |
|
47 | |||
47 | // SBM1 |
|
48 | // SBM1 | |
48 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
49 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
49 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
50 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
50 |
|
51 | |||
51 | // SBM2 |
|
52 | // SBM2 | |
52 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
53 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
53 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
54 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
54 |
|
55 | |||
55 | // TC_LFR_UPDATE_INFO |
|
56 | // TC_LFR_UPDATE_INFO | |
56 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
57 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); | |
57 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
58 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); | |
58 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); |
|
59 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); | |
59 |
|
60 | |||
60 | // FBINS_MASK |
|
61 | // FBINS_MASK | |
61 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); |
|
62 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); | |
62 |
|
63 | |||
|
64 | // TC_LFR_LOAD_PARS_FILTER_PAR | |||
|
65 | int check_sy_lfr_pas_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |||
|
66 | ||||
63 | // KCOEFFICIENTS |
|
67 | // KCOEFFICIENTS | |
64 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); |
|
68 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); | |
65 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); |
|
69 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); | |
66 |
|
70 | |||
67 | void init_parameter_dump( void ); |
|
71 | void init_parameter_dump( void ); | |
68 | void init_kcoefficients_dump( void ); |
|
72 | void init_kcoefficients_dump( void ); | |
69 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); |
|
73 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); | |
70 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); |
|
74 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); | |
71 |
|
75 | |||
72 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
|
76 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,465 +1,474 | |||||
1 | /** Functions related to TeleCommand acceptance. |
|
1 | /** Functions related to TeleCommand acceptance. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TeleCommands parsing.\n |
|
6 | * A group of functions to handle TeleCommands parsing.\n | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "tc_acceptance.h" |
|
10 | #include "tc_acceptance.h" | |
11 | #include <stdio.h> |
|
11 | #include <stdio.h> | |
12 |
|
12 | |||
13 | unsigned int lookUpTableForCRC[256]; |
|
13 | unsigned int lookUpTableForCRC[256]; | |
14 |
|
14 | |||
15 | //********************** |
|
15 | //********************** | |
16 | // GENERAL USE FUNCTIONS |
|
16 | // GENERAL USE FUNCTIONS | |
17 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) |
|
17 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) | |
18 | { |
|
18 | { | |
19 | /** This function generate the CRC for one byte and returns the value of the new syndrome. |
|
19 | /** This function generate the CRC for one byte and returns the value of the new syndrome. | |
20 | * |
|
20 | * | |
21 | * @param D is the current byte of data. |
|
21 | * @param D is the current byte of data. | |
22 | * @param Chk is the current syndrom value. |
|
22 | * @param Chk is the current syndrom value. | |
23 | * |
|
23 | * | |
24 | * @return the value of the new syndrome on two bytes. |
|
24 | * @return the value of the new syndrome on two bytes. | |
25 | * |
|
25 | * | |
26 | */ |
|
26 | */ | |
27 |
|
27 | |||
28 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); |
|
28 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | void initLookUpTableForCRC( void ) |
|
31 | void initLookUpTableForCRC( void ) | |
32 | { |
|
32 | { | |
33 | /** This function is used to initiates the look-up table for fast CRC computation. |
|
33 | /** This function is used to initiates the look-up table for fast CRC computation. | |
34 | * |
|
34 | * | |
35 | * The global table lookUpTableForCRC[256] is initiated. |
|
35 | * The global table lookUpTableForCRC[256] is initiated. | |
36 | * |
|
36 | * | |
37 | */ |
|
37 | */ | |
38 |
|
38 | |||
39 | unsigned int i; |
|
39 | unsigned int i; | |
40 | unsigned int tmp; |
|
40 | unsigned int tmp; | |
41 |
|
41 | |||
42 | for (i=0; i<256; i++) |
|
42 | for (i=0; i<256; i++) | |
43 | { |
|
43 | { | |
44 | tmp = 0; |
|
44 | tmp = 0; | |
45 | if((i & 1) != 0) { |
|
45 | if((i & 1) != 0) { | |
46 | tmp = tmp ^ 0x1021; |
|
46 | tmp = tmp ^ 0x1021; | |
47 | } |
|
47 | } | |
48 | if((i & 2) != 0) { |
|
48 | if((i & 2) != 0) { | |
49 | tmp = tmp ^ 0x2042; |
|
49 | tmp = tmp ^ 0x2042; | |
50 | } |
|
50 | } | |
51 | if((i & 4) != 0) { |
|
51 | if((i & 4) != 0) { | |
52 | tmp = tmp ^ 0x4084; |
|
52 | tmp = tmp ^ 0x4084; | |
53 | } |
|
53 | } | |
54 | if((i & 8) != 0) { |
|
54 | if((i & 8) != 0) { | |
55 | tmp = tmp ^ 0x8108; |
|
55 | tmp = tmp ^ 0x8108; | |
56 | } |
|
56 | } | |
57 | if((i & 16) != 0) { |
|
57 | if((i & 16) != 0) { | |
58 | tmp = tmp ^ 0x1231; |
|
58 | tmp = tmp ^ 0x1231; | |
59 | } |
|
59 | } | |
60 | if((i & 32) != 0) { |
|
60 | if((i & 32) != 0) { | |
61 | tmp = tmp ^ 0x2462; |
|
61 | tmp = tmp ^ 0x2462; | |
62 | } |
|
62 | } | |
63 | if((i & 64) != 0) { |
|
63 | if((i & 64) != 0) { | |
64 | tmp = tmp ^ 0x48c4; |
|
64 | tmp = tmp ^ 0x48c4; | |
65 | } |
|
65 | } | |
66 | if((i & 128) != 0) { |
|
66 | if((i & 128) != 0) { | |
67 | tmp = tmp ^ 0x9188; |
|
67 | tmp = tmp ^ 0x9188; | |
68 | } |
|
68 | } | |
69 | lookUpTableForCRC[i] = tmp; |
|
69 | lookUpTableForCRC[i] = tmp; | |
70 | } |
|
70 | } | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) |
|
73 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) | |
74 | { |
|
74 | { | |
75 | /** This function calculates a two bytes Cyclic Redundancy Code. |
|
75 | /** This function calculates a two bytes Cyclic Redundancy Code. | |
76 | * |
|
76 | * | |
77 | * @param data points to a buffer containing the data on which to compute the CRC. |
|
77 | * @param data points to a buffer containing the data on which to compute the CRC. | |
78 | * @param crcAsTwoBytes points points to a two bytes buffer in which the CRC is stored. |
|
78 | * @param crcAsTwoBytes points points to a two bytes buffer in which the CRC is stored. | |
79 | * @param sizeOfData is the number of bytes of *data* used to compute the CRC. |
|
79 | * @param sizeOfData is the number of bytes of *data* used to compute the CRC. | |
80 | * |
|
80 | * | |
81 | * The specification of the Cyclic Redundancy Code is described in the following document: ECSS-E-70-41-A. |
|
81 | * The specification of the Cyclic Redundancy Code is described in the following document: ECSS-E-70-41-A. | |
82 | * |
|
82 | * | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | unsigned int Chk; |
|
85 | unsigned int Chk; | |
86 | int j; |
|
86 | int j; | |
87 | Chk = 0xffff; // reset the syndrom to all ones |
|
87 | Chk = 0xffff; // reset the syndrom to all ones | |
88 | for (j=0; j<sizeOfData; j++) { |
|
88 | for (j=0; j<sizeOfData; j++) { | |
89 | Chk = Crc_opt(data[j], Chk); |
|
89 | Chk = Crc_opt(data[j], Chk); | |
90 | } |
|
90 | } | |
91 | crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); |
|
91 | crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); | |
92 | crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); |
|
92 | crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | //********************* |
|
95 | //********************* | |
96 | // ACCEPTANCE FUNCTIONS |
|
96 | // ACCEPTANCE FUNCTIONS | |
97 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int estimatedPacketLength, unsigned char *computed_CRC) |
|
97 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int estimatedPacketLength, unsigned char *computed_CRC) | |
98 | { |
|
98 | { | |
99 | /** This function parses TeleCommands. |
|
99 | /** This function parses TeleCommands. | |
100 | * |
|
100 | * | |
101 | * @param TC points to the TeleCommand that will be parsed. |
|
101 | * @param TC points to the TeleCommand that will be parsed. | |
102 | * @param estimatedPacketLength is the PACKET_LENGTH field calculated from the effective length of the received packet. |
|
102 | * @param estimatedPacketLength is the PACKET_LENGTH field calculated from the effective length of the received packet. | |
103 | * |
|
103 | * | |
104 | * @return Status code of the parsing. |
|
104 | * @return Status code of the parsing. | |
105 | * |
|
105 | * | |
106 | * The parsing checks: |
|
106 | * The parsing checks: | |
107 | * - process id |
|
107 | * - process id | |
108 | * - category |
|
108 | * - category | |
109 | * - length: a global check is performed and a per subtype check also |
|
109 | * - length: a global check is performed and a per subtype check also | |
110 | * - type |
|
110 | * - type | |
111 | * - subtype |
|
111 | * - subtype | |
112 | * - crc |
|
112 | * - crc | |
113 | * |
|
113 | * | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | int status; |
|
116 | int status; | |
117 | int status_crc; |
|
117 | int status_crc; | |
118 | unsigned char pid; |
|
118 | unsigned char pid; | |
119 | unsigned char category; |
|
119 | unsigned char category; | |
120 | unsigned int packetLength; |
|
120 | unsigned int packetLength; | |
121 | unsigned char packetType; |
|
121 | unsigned char packetType; | |
122 | unsigned char packetSubtype; |
|
122 | unsigned char packetSubtype; | |
123 | unsigned char sid; |
|
123 | unsigned char sid; | |
124 |
|
124 | |||
125 | status = CCSDS_TM_VALID; |
|
125 | status = CCSDS_TM_VALID; | |
126 |
|
126 | |||
127 | // APID check *** APID on 2 bytes |
|
127 | // APID check *** APID on 2 bytes | |
128 | pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx |
|
128 | pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx | |
129 | category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 |
|
129 | category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 | |
130 | packetLength = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1]; |
|
130 | packetLength = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1]; | |
131 | packetType = TCPacket->serviceType; |
|
131 | packetType = TCPacket->serviceType; | |
132 | packetSubtype = TCPacket->serviceSubType; |
|
132 | packetSubtype = TCPacket->serviceSubType; | |
133 | sid = TCPacket->sourceID; |
|
133 | sid = TCPacket->sourceID; | |
134 |
|
134 | |||
135 | if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID |
|
135 | if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID | |
136 | { |
|
136 | { | |
137 | status = ILLEGAL_APID; |
|
137 | status = ILLEGAL_APID; | |
138 | } |
|
138 | } | |
139 | if (status == CCSDS_TM_VALID) // CHECK THE CATEGORY |
|
139 | if (status == CCSDS_TM_VALID) // CHECK THE CATEGORY | |
140 | { |
|
140 | { | |
141 | if ( category != CCSDS_PACKET_CATEGORY ) |
|
141 | if ( category != CCSDS_PACKET_CATEGORY ) | |
142 | { |
|
142 | { | |
143 | status = ILLEGAL_APID; |
|
143 | status = ILLEGAL_APID; | |
144 | } |
|
144 | } | |
145 | } |
|
145 | } | |
146 | if (status == CCSDS_TM_VALID) // CHECK THE PACKET_LENGTH FIELD AND THE ESTIMATED PACKET_LENGTH COMPLIANCE |
|
146 | if (status == CCSDS_TM_VALID) // CHECK THE PACKET_LENGTH FIELD AND THE ESTIMATED PACKET_LENGTH COMPLIANCE | |
147 | { |
|
147 | { | |
148 | if (packetLength != estimatedPacketLength ) { |
|
148 | if (packetLength != estimatedPacketLength ) { | |
149 | status = WRONG_LEN_PKT; |
|
149 | status = WRONG_LEN_PKT; | |
150 | } |
|
150 | } | |
151 | } |
|
151 | } | |
152 | if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE |
|
152 | if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE | |
153 | { |
|
153 | { | |
154 | if ( packetLength >= CCSDS_TC_PKT_MAX_SIZE ) { |
|
154 | if ( packetLength >= CCSDS_TC_PKT_MAX_SIZE ) { | |
155 | status = WRONG_LEN_PKT; |
|
155 | status = WRONG_LEN_PKT; | |
156 | } |
|
156 | } | |
157 | } |
|
157 | } | |
158 | if (status == CCSDS_TM_VALID) // CHECK THE TYPE |
|
158 | if (status == CCSDS_TM_VALID) // CHECK THE TYPE | |
159 | { |
|
159 | { | |
160 | status = tc_check_type( packetType ); |
|
160 | status = tc_check_type( packetType ); | |
161 | } |
|
161 | } | |
162 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE |
|
162 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE | |
163 | { |
|
163 | { | |
164 | status = tc_check_type_subtype( packetType, packetSubtype ); |
|
164 | status = tc_check_type_subtype( packetType, packetSubtype ); | |
165 | } |
|
165 | } | |
166 | if (status == CCSDS_TM_VALID) // CHECK THE SID |
|
166 | if (status == CCSDS_TM_VALID) // CHECK THE SID | |
167 | { |
|
167 | { | |
168 | status = tc_check_sid( sid ); |
|
168 | status = tc_check_sid( sid ); | |
169 | } |
|
169 | } | |
170 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE |
|
170 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE | |
171 | { |
|
171 | { | |
172 | status = tc_check_length( packetSubtype, packetLength ); |
|
172 | status = tc_check_length( packetSubtype, packetLength ); | |
173 | } |
|
173 | } | |
174 | status_crc = tc_check_crc( TCPacket, estimatedPacketLength, computed_CRC ); |
|
174 | status_crc = tc_check_crc( TCPacket, estimatedPacketLength, computed_CRC ); | |
175 | if (status == CCSDS_TM_VALID ) // CHECK CRC |
|
175 | if (status == CCSDS_TM_VALID ) // CHECK CRC | |
176 | { |
|
176 | { | |
177 | status = status_crc; |
|
177 | status = status_crc; | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | return status; |
|
180 | return status; | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | int tc_check_type( unsigned char packetType ) |
|
183 | int tc_check_type( unsigned char packetType ) | |
184 | { |
|
184 | { | |
185 | /** This function checks that the type of a TeleCommand is valid. |
|
185 | /** This function checks that the type of a TeleCommand is valid. | |
186 | * |
|
186 | * | |
187 | * @param packetType is the type to check. |
|
187 | * @param packetType is the type to check. | |
188 | * |
|
188 | * | |
189 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. |
|
189 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. | |
190 | * |
|
190 | * | |
191 | */ |
|
191 | */ | |
192 |
|
192 | |||
193 | int status; |
|
193 | int status; | |
194 |
|
194 | |||
195 | if ( (packetType == TC_TYPE_GEN) || (packetType == TC_TYPE_TIME)) |
|
195 | if ( (packetType == TC_TYPE_GEN) || (packetType == TC_TYPE_TIME)) | |
196 | { |
|
196 | { | |
197 | status = CCSDS_TM_VALID; |
|
197 | status = CCSDS_TM_VALID; | |
198 | } |
|
198 | } | |
199 | else |
|
199 | else | |
200 | { |
|
200 | { | |
201 | status = ILL_TYPE; |
|
201 | status = ILL_TYPE; | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | return status; |
|
204 | return status; | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | int tc_check_type_subtype( unsigned char packetType, unsigned char packetSubType ) |
|
207 | int tc_check_type_subtype( unsigned char packetType, unsigned char packetSubType ) | |
208 | { |
|
208 | { | |
209 | /** This function checks that the subtype of a TeleCommand is valid and coherent with the type. |
|
209 | /** This function checks that the subtype of a TeleCommand is valid and coherent with the type. | |
210 | * |
|
210 | * | |
211 | * @param packetType is the type of the TC. |
|
211 | * @param packetType is the type of the TC. | |
212 | * @param packetSubType is the subtype to check. |
|
212 | * @param packetSubType is the subtype to check. | |
213 | * |
|
213 | * | |
214 | * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE. |
|
214 | * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE. | |
215 | * |
|
215 | * | |
216 | */ |
|
216 | */ | |
217 |
|
217 | |||
218 | int status; |
|
218 | int status; | |
219 |
|
219 | |||
220 | switch(packetType) |
|
220 | switch(packetType) | |
221 | { |
|
221 | { | |
222 | case TC_TYPE_GEN: |
|
222 | case TC_TYPE_GEN: | |
223 | if ( (packetSubType == TC_SUBTYPE_RESET) |
|
223 | if ( (packetSubType == TC_SUBTYPE_RESET) | |
224 | || (packetSubType == TC_SUBTYPE_LOAD_COMM) |
|
224 | || (packetSubType == TC_SUBTYPE_LOAD_COMM) | |
225 | || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST) |
|
225 | || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST) | |
226 | || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2) |
|
226 | || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2) | |
227 | || (packetSubType == TC_SUBTYPE_DUMP) |
|
227 | || (packetSubType == TC_SUBTYPE_DUMP) | |
228 | || (packetSubType == TC_SUBTYPE_ENTER) |
|
228 | || (packetSubType == TC_SUBTYPE_ENTER) | |
229 | || (packetSubType == TC_SUBTYPE_UPDT_INFO) |
|
229 | || (packetSubType == TC_SUBTYPE_UPDT_INFO) | |
230 | || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) |
|
230 | || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) | |
231 | || (packetSubType == TC_SUBTYPE_LOAD_K) || (packetSubType == TC_SUBTYPE_DUMP_K) |
|
231 | || (packetSubType == TC_SUBTYPE_LOAD_K) || (packetSubType == TC_SUBTYPE_DUMP_K) | |
232 |
|| (packetSubType == TC_SUBTYPE_LOAD_FBINS) |
|
232 | || (packetSubType == TC_SUBTYPE_LOAD_FBINS) | |
|
233 | || (packetSubType == TC_SUBTYPE_LOAD_PAS_FILTER_PAR)) | |||
233 | { |
|
234 | { | |
234 | status = CCSDS_TM_VALID; |
|
235 | status = CCSDS_TM_VALID; | |
235 | } |
|
236 | } | |
236 | else |
|
237 | else | |
237 | { |
|
238 | { | |
238 | status = ILL_SUBTYPE; |
|
239 | status = ILL_SUBTYPE; | |
239 | } |
|
240 | } | |
240 | break; |
|
241 | break; | |
241 |
|
242 | |||
242 | case TC_TYPE_TIME: |
|
243 | case TC_TYPE_TIME: | |
243 | if (packetSubType == TC_SUBTYPE_UPDT_TIME) |
|
244 | if (packetSubType == TC_SUBTYPE_UPDT_TIME) | |
244 | { |
|
245 | { | |
245 | status = CCSDS_TM_VALID; |
|
246 | status = CCSDS_TM_VALID; | |
246 | } |
|
247 | } | |
247 | else |
|
248 | else | |
248 | { |
|
249 | { | |
249 | status = ILL_SUBTYPE; |
|
250 | status = ILL_SUBTYPE; | |
250 | } |
|
251 | } | |
251 | break; |
|
252 | break; | |
252 |
|
253 | |||
253 | default: |
|
254 | default: | |
254 | status = ILL_SUBTYPE; |
|
255 | status = ILL_SUBTYPE; | |
255 | break; |
|
256 | break; | |
256 | } |
|
257 | } | |
257 |
|
258 | |||
258 | return status; |
|
259 | return status; | |
259 | } |
|
260 | } | |
260 |
|
261 | |||
261 | int tc_check_sid( unsigned char sid ) |
|
262 | int tc_check_sid( unsigned char sid ) | |
262 | { |
|
263 | { | |
263 | /** This function checks that the sid of a TeleCommand is valid. |
|
264 | /** This function checks that the sid of a TeleCommand is valid. | |
264 | * |
|
265 | * | |
265 | * @param sid is the sid to check. |
|
266 | * @param sid is the sid to check. | |
266 | * |
|
267 | * | |
267 | * @return Status code CCSDS_TM_VALID or CORRUPTED. |
|
268 | * @return Status code CCSDS_TM_VALID or CORRUPTED. | |
268 | * |
|
269 | * | |
269 | */ |
|
270 | */ | |
270 |
|
271 | |||
271 | int status; |
|
272 | int status; | |
272 |
|
273 | |||
273 | if ( (sid == SID_TC_MISSION_TIMELINE) || (sid == SID_TC_TC_SEQUENCES) || (sid == SID_TC_RECOVERY_ACTION_CMD) |
|
274 | if ( (sid == SID_TC_MISSION_TIMELINE) || (sid == SID_TC_TC_SEQUENCES) || (sid == SID_TC_RECOVERY_ACTION_CMD) | |
274 | || (sid == SID_TC_BACKUP_MISSION_TIMELINE) |
|
275 | || (sid == SID_TC_BACKUP_MISSION_TIMELINE) | |
275 | || (sid == SID_TC_DIRECT_CMD) || (sid == SID_TC_SPARE_GRD_SRC1) || (sid == SID_TC_SPARE_GRD_SRC2) |
|
276 | || (sid == SID_TC_DIRECT_CMD) || (sid == SID_TC_SPARE_GRD_SRC1) || (sid == SID_TC_SPARE_GRD_SRC2) | |
276 | || (sid == SID_TC_OBCP) || (sid == SID_TC_SYSTEM_CONTROL) || (sid == SID_TC_AOCS) |
|
277 | || (sid == SID_TC_OBCP) || (sid == SID_TC_SYSTEM_CONTROL) || (sid == SID_TC_AOCS) | |
277 | || (sid == SID_TC_RPW_INTERNAL)) |
|
278 | || (sid == SID_TC_RPW_INTERNAL)) | |
278 | { |
|
279 | { | |
279 | status = CCSDS_TM_VALID; |
|
280 | status = CCSDS_TM_VALID; | |
280 | } |
|
281 | } | |
281 | else |
|
282 | else | |
282 | { |
|
283 | { | |
283 | status = WRONG_SRC_ID; |
|
284 | status = WRONG_SRC_ID; | |
284 | } |
|
285 | } | |
285 |
|
286 | |||
286 | return status; |
|
287 | return status; | |
287 | } |
|
288 | } | |
288 |
|
289 | |||
289 | int tc_check_length( unsigned char packetSubType, unsigned int length ) |
|
290 | int tc_check_length( unsigned char packetSubType, unsigned int length ) | |
290 | { |
|
291 | { | |
291 | /** This function checks that the subtype and the length are compliant. |
|
292 | /** This function checks that the subtype and the length are compliant. | |
292 | * |
|
293 | * | |
293 | * @param packetSubType is the subtype to check. |
|
294 | * @param packetSubType is the subtype to check. | |
294 | * @param length is the length to check. |
|
295 | * @param length is the length to check. | |
295 | * |
|
296 | * | |
296 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. |
|
297 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. | |
297 | * |
|
298 | * | |
298 | */ |
|
299 | */ | |
299 |
|
300 | |||
300 | int status; |
|
301 | int status; | |
301 |
|
302 | |||
302 | status = LFR_SUCCESSFUL; |
|
303 | status = LFR_SUCCESSFUL; | |
303 |
|
304 | |||
304 | switch(packetSubType) |
|
305 | switch(packetSubType) | |
305 | { |
|
306 | { | |
306 | case TC_SUBTYPE_RESET: |
|
307 | case TC_SUBTYPE_RESET: | |
307 | if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
308 | if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { | |
308 | status = WRONG_LEN_PKT; |
|
309 | status = WRONG_LEN_PKT; | |
309 | } |
|
310 | } | |
310 | else { |
|
311 | else { | |
311 | status = CCSDS_TM_VALID; |
|
312 | status = CCSDS_TM_VALID; | |
312 | } |
|
313 | } | |
313 | break; |
|
314 | break; | |
314 | case TC_SUBTYPE_LOAD_COMM: |
|
315 | case TC_SUBTYPE_LOAD_COMM: | |
315 | if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
316 | if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { | |
316 | status = WRONG_LEN_PKT; |
|
317 | status = WRONG_LEN_PKT; | |
317 | } |
|
318 | } | |
318 | else { |
|
319 | else { | |
319 | status = CCSDS_TM_VALID; |
|
320 | status = CCSDS_TM_VALID; | |
320 | } |
|
321 | } | |
321 | break; |
|
322 | break; | |
322 | case TC_SUBTYPE_LOAD_NORM: |
|
323 | case TC_SUBTYPE_LOAD_NORM: | |
323 | if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
324 | if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { | |
324 | status = WRONG_LEN_PKT; |
|
325 | status = WRONG_LEN_PKT; | |
325 | } |
|
326 | } | |
326 | else { |
|
327 | else { | |
327 | status = CCSDS_TM_VALID; |
|
328 | status = CCSDS_TM_VALID; | |
328 | } |
|
329 | } | |
329 | break; |
|
330 | break; | |
330 | case TC_SUBTYPE_LOAD_BURST: |
|
331 | case TC_SUBTYPE_LOAD_BURST: | |
331 | if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
332 | if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { | |
332 | status = WRONG_LEN_PKT; |
|
333 | status = WRONG_LEN_PKT; | |
333 | } |
|
334 | } | |
334 | else { |
|
335 | else { | |
335 | status = CCSDS_TM_VALID; |
|
336 | status = CCSDS_TM_VALID; | |
336 | } |
|
337 | } | |
337 | break; |
|
338 | break; | |
338 | case TC_SUBTYPE_LOAD_SBM1: |
|
339 | case TC_SUBTYPE_LOAD_SBM1: | |
339 | if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
340 | if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { | |
340 | status = WRONG_LEN_PKT; |
|
341 | status = WRONG_LEN_PKT; | |
341 | } |
|
342 | } | |
342 | else { |
|
343 | else { | |
343 | status = CCSDS_TM_VALID; |
|
344 | status = CCSDS_TM_VALID; | |
344 | } |
|
345 | } | |
345 | break; |
|
346 | break; | |
346 | case TC_SUBTYPE_LOAD_SBM2: |
|
347 | case TC_SUBTYPE_LOAD_SBM2: | |
347 | if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
348 | if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { | |
348 | status = WRONG_LEN_PKT; |
|
349 | status = WRONG_LEN_PKT; | |
349 | } |
|
350 | } | |
350 | else { |
|
351 | else { | |
351 | status = CCSDS_TM_VALID; |
|
352 | status = CCSDS_TM_VALID; | |
352 | } |
|
353 | } | |
353 | break; |
|
354 | break; | |
354 | case TC_SUBTYPE_DUMP: |
|
355 | case TC_SUBTYPE_DUMP: | |
355 | if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
356 | if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { | |
356 | status = WRONG_LEN_PKT; |
|
357 | status = WRONG_LEN_PKT; | |
357 | } |
|
358 | } | |
358 | else { |
|
359 | else { | |
359 | status = CCSDS_TM_VALID; |
|
360 | status = CCSDS_TM_VALID; | |
360 | } |
|
361 | } | |
361 | break; |
|
362 | break; | |
362 | case TC_SUBTYPE_ENTER: |
|
363 | case TC_SUBTYPE_ENTER: | |
363 | if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
364 | if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { | |
364 | status = WRONG_LEN_PKT; |
|
365 | status = WRONG_LEN_PKT; | |
365 | } |
|
366 | } | |
366 | else { |
|
367 | else { | |
367 | status = CCSDS_TM_VALID; |
|
368 | status = CCSDS_TM_VALID; | |
368 | } |
|
369 | } | |
369 | break; |
|
370 | break; | |
370 | case TC_SUBTYPE_UPDT_INFO: |
|
371 | case TC_SUBTYPE_UPDT_INFO: | |
371 | if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
372 | if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { | |
372 | status = WRONG_LEN_PKT; |
|
373 | status = WRONG_LEN_PKT; | |
373 | } |
|
374 | } | |
374 | else { |
|
375 | else { | |
375 | status = CCSDS_TM_VALID; |
|
376 | status = CCSDS_TM_VALID; | |
376 | } |
|
377 | } | |
377 | break; |
|
378 | break; | |
378 | case TC_SUBTYPE_EN_CAL: |
|
379 | case TC_SUBTYPE_EN_CAL: | |
379 | if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
380 | if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |
380 | status = WRONG_LEN_PKT; |
|
381 | status = WRONG_LEN_PKT; | |
381 | } |
|
382 | } | |
382 | else { |
|
383 | else { | |
383 | status = CCSDS_TM_VALID; |
|
384 | status = CCSDS_TM_VALID; | |
384 | } |
|
385 | } | |
385 | break; |
|
386 | break; | |
386 | case TC_SUBTYPE_DIS_CAL: |
|
387 | case TC_SUBTYPE_DIS_CAL: | |
387 | if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
388 | if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |
388 | status = WRONG_LEN_PKT; |
|
389 | status = WRONG_LEN_PKT; | |
389 | } |
|
390 | } | |
390 | else { |
|
391 | else { | |
391 | status = CCSDS_TM_VALID; |
|
392 | status = CCSDS_TM_VALID; | |
392 | } |
|
393 | } | |
393 | break; |
|
394 | break; | |
394 | case TC_SUBTYPE_LOAD_K: |
|
395 | case TC_SUBTYPE_LOAD_K: | |
395 | if (length!=(TC_LEN_LOAD_K-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
396 | if (length!=(TC_LEN_LOAD_K-CCSDS_TC_TM_PACKET_OFFSET)) { | |
396 | status = WRONG_LEN_PKT; |
|
397 | status = WRONG_LEN_PKT; | |
397 | } |
|
398 | } | |
398 | else { |
|
399 | else { | |
399 | status = CCSDS_TM_VALID; |
|
400 | status = CCSDS_TM_VALID; | |
400 | } |
|
401 | } | |
401 | break; |
|
402 | break; | |
402 | case TC_SUBTYPE_DUMP_K: |
|
403 | case TC_SUBTYPE_DUMP_K: | |
403 | if (length!=(TC_LEN_DUMP_K-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
404 | if (length!=(TC_LEN_DUMP_K-CCSDS_TC_TM_PACKET_OFFSET)) { | |
404 | status = WRONG_LEN_PKT; |
|
405 | status = WRONG_LEN_PKT; | |
405 | } |
|
406 | } | |
406 | else { |
|
407 | else { | |
407 | status = CCSDS_TM_VALID; |
|
408 | status = CCSDS_TM_VALID; | |
408 | } |
|
409 | } | |
409 | break; |
|
410 | break; | |
410 | case TC_SUBTYPE_LOAD_FBINS: |
|
411 | case TC_SUBTYPE_LOAD_FBINS: | |
411 | if (length!=(TC_LEN_LOAD_FBINS-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
412 | if (length!=(TC_LEN_LOAD_FBINS-CCSDS_TC_TM_PACKET_OFFSET)) { | |
412 | status = WRONG_LEN_PKT; |
|
413 | status = WRONG_LEN_PKT; | |
413 | } |
|
414 | } | |
414 | else { |
|
415 | else { | |
415 | status = CCSDS_TM_VALID; |
|
416 | status = CCSDS_TM_VALID; | |
416 | } |
|
417 | } | |
417 | break; |
|
418 | break; | |
|
419 | case TC_SUBTYPE_LOAD_PAS_FILTER_PAR: | |||
|
420 | if (length!=(TC_LEN_LOAD_PAS_FILTER_PAR-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
421 | status = WRONG_LEN_PKT; | |||
|
422 | } | |||
|
423 | else { | |||
|
424 | status = CCSDS_TM_VALID; | |||
|
425 | } | |||
|
426 | break; | |||
418 | case TC_SUBTYPE_UPDT_TIME: |
|
427 | case TC_SUBTYPE_UPDT_TIME: | |
419 | if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
428 | if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { | |
420 | status = WRONG_LEN_PKT; |
|
429 | status = WRONG_LEN_PKT; | |
421 | } |
|
430 | } | |
422 | else { |
|
431 | else { | |
423 | status = CCSDS_TM_VALID; |
|
432 | status = CCSDS_TM_VALID; | |
424 | } |
|
433 | } | |
425 | break; |
|
434 | break; | |
426 | default: // if the subtype is not a legal value, return ILL_SUBTYPE |
|
435 | default: // if the subtype is not a legal value, return ILL_SUBTYPE | |
427 | status = ILL_SUBTYPE; |
|
436 | status = ILL_SUBTYPE; | |
428 | break ; |
|
437 | break ; | |
429 | } |
|
438 | } | |
430 |
|
439 | |||
431 | return status; |
|
440 | return status; | |
432 | } |
|
441 | } | |
433 |
|
442 | |||
434 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length, unsigned char *computed_CRC ) |
|
443 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length, unsigned char *computed_CRC ) | |
435 | { |
|
444 | { | |
436 | /** This function checks the CRC validity of the corresponding TeleCommand packet. |
|
445 | /** This function checks the CRC validity of the corresponding TeleCommand packet. | |
437 | * |
|
446 | * | |
438 | * @param TCPacket points to the TeleCommand packet to check. |
|
447 | * @param TCPacket points to the TeleCommand packet to check. | |
439 | * @param length is the length of the TC packet. |
|
448 | * @param length is the length of the TC packet. | |
440 | * |
|
449 | * | |
441 | * @return Status code CCSDS_TM_VALID or INCOR_CHECKSUM. |
|
450 | * @return Status code CCSDS_TM_VALID or INCOR_CHECKSUM. | |
442 | * |
|
451 | * | |
443 | */ |
|
452 | */ | |
444 |
|
453 | |||
445 | int status; |
|
454 | int status; | |
446 | unsigned char * CCSDSContent; |
|
455 | unsigned char * CCSDSContent; | |
447 |
|
456 | |||
448 | CCSDSContent = (unsigned char*) TCPacket->packetID; |
|
457 | CCSDSContent = (unsigned char*) TCPacket->packetID; | |
449 | GetCRCAsTwoBytes(CCSDSContent, computed_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC |
|
458 | GetCRCAsTwoBytes(CCSDSContent, computed_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC | |
450 |
|
459 | |||
451 | if (computed_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { |
|
460 | if (computed_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { | |
452 | status = INCOR_CHECKSUM; |
|
461 | status = INCOR_CHECKSUM; | |
453 | } |
|
462 | } | |
454 | else if (computed_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { |
|
463 | else if (computed_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { | |
455 | status = INCOR_CHECKSUM; |
|
464 | status = INCOR_CHECKSUM; | |
456 | } |
|
465 | } | |
457 | else { |
|
466 | else { | |
458 | status = CCSDS_TM_VALID; |
|
467 | status = CCSDS_TM_VALID; | |
459 | } |
|
468 | } | |
460 |
|
469 | |||
461 | return status; |
|
470 | return status; | |
462 | } |
|
471 | } | |
463 |
|
472 | |||
464 |
|
473 | |||
465 |
|
474 |
@@ -1,1632 +1,1636 | |||||
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_PAS_FILTER_PAR: | |||
|
127 | result = action_load_pas_filter_par( &TC, queue_snd_id, time ); | |||
|
128 | close_action( &TC, result, queue_snd_id ); | |||
|
129 | break; | |||
126 | case TC_SUBTYPE_UPDT_TIME: |
|
130 | case TC_SUBTYPE_UPDT_TIME: | |
127 | result = action_update_time( &TC ); |
|
131 | result = action_update_time( &TC ); | |
128 | close_action( &TC, result, queue_snd_id ); |
|
132 | close_action( &TC, result, queue_snd_id ); | |
129 | break; |
|
133 | break; | |
130 | default: |
|
134 | default: | |
131 | break; |
|
135 | break; | |
132 | } |
|
136 | } | |
133 | } |
|
137 | } | |
134 | } |
|
138 | } | |
135 | } |
|
139 | } | |
136 |
|
140 | |||
137 | //*********** |
|
141 | //*********** | |
138 | // TC ACTIONS |
|
142 | // TC ACTIONS | |
139 |
|
143 | |||
140 | 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) | |
141 | { |
|
145 | { | |
142 | /** 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. | |
143 | * |
|
147 | * | |
144 | * @param TC points to the TeleCommand packet that is being processed |
|
148 | * @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 |
|
149 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
146 | * |
|
150 | * | |
147 | */ |
|
151 | */ | |
148 |
|
152 | |||
149 | PRINTF("this is the end!!!\n"); |
|
153 | PRINTF("this is the end!!!\n"); | |
150 | exit(0); |
|
154 | exit(0); | |
151 |
|
155 | |||
152 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
156 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
153 |
|
157 | |||
154 | return LFR_DEFAULT; |
|
158 | return LFR_DEFAULT; | |
155 | } |
|
159 | } | |
156 |
|
160 | |||
157 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
161 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
158 | { |
|
162 | { | |
159 | /** 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. | |
160 | * |
|
164 | * | |
161 | * @param TC points to the TeleCommand packet that is being processed |
|
165 | * @param TC points to the TeleCommand packet that is being processed | |
162 | * @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 | |
163 | * |
|
167 | * | |
164 | */ |
|
168 | */ | |
165 |
|
169 | |||
166 | rtems_status_code status; |
|
170 | rtems_status_code status; | |
167 | unsigned char requestedMode; |
|
171 | unsigned char requestedMode; | |
168 | unsigned int *transitionCoarseTime_ptr; |
|
172 | unsigned int *transitionCoarseTime_ptr; | |
169 | unsigned int transitionCoarseTime; |
|
173 | unsigned int transitionCoarseTime; | |
170 | unsigned char * bytePosPtr; |
|
174 | unsigned char * bytePosPtr; | |
171 |
|
175 | |||
172 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
176 | bytePosPtr = (unsigned char *) &TC->packetID; | |
173 |
|
177 | |||
174 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
178 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; | |
175 | 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 ] ); | |
176 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
180 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; | |
177 |
|
181 | |||
178 | status = check_mode_value( requestedMode ); |
|
182 | status = check_mode_value( requestedMode ); | |
179 |
|
183 | |||
180 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
184 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent | |
181 | { |
|
185 | { | |
182 | 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 ); | |
183 | } |
|
187 | } | |
184 |
|
188 | |||
185 | else // the mode value is valid, check the transition |
|
189 | else // the mode value is valid, check the transition | |
186 | { |
|
190 | { | |
187 | status = check_mode_transition(requestedMode); |
|
191 | status = check_mode_transition(requestedMode); | |
188 | if (status != LFR_SUCCESSFUL) |
|
192 | if (status != LFR_SUCCESSFUL) | |
189 | { |
|
193 | { | |
190 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
194 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") | |
191 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
195 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
192 | } |
|
196 | } | |
193 | } |
|
197 | } | |
194 |
|
198 | |||
195 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date |
|
199 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date | |
196 | { |
|
200 | { | |
197 | status = check_transition_date( transitionCoarseTime ); |
|
201 | status = check_transition_date( transitionCoarseTime ); | |
198 | if (status != LFR_SUCCESSFUL) |
|
202 | if (status != LFR_SUCCESSFUL) | |
199 | { |
|
203 | { | |
200 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n"); |
|
204 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n"); | |
201 | send_tm_lfr_tc_exe_not_executable(TC, queue_id ); |
|
205 | send_tm_lfr_tc_exe_not_executable(TC, queue_id ); | |
202 | } |
|
206 | } | |
203 | } |
|
207 | } | |
204 |
|
208 | |||
205 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
209 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode | |
206 | { |
|
210 | { | |
207 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
211 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); | |
208 |
|
212 | |||
209 | switch(requestedMode) |
|
213 | switch(requestedMode) | |
210 | { |
|
214 | { | |
211 | case LFR_MODE_STANDBY: |
|
215 | case LFR_MODE_STANDBY: | |
212 | status = enter_mode_standby(); |
|
216 | status = enter_mode_standby(); | |
213 | break; |
|
217 | break; | |
214 | case LFR_MODE_NORMAL: |
|
218 | case LFR_MODE_NORMAL: | |
215 | status = enter_mode_normal( transitionCoarseTime ); |
|
219 | status = enter_mode_normal( transitionCoarseTime ); | |
216 | break; |
|
220 | break; | |
217 | case LFR_MODE_BURST: |
|
221 | case LFR_MODE_BURST: | |
218 | status = enter_mode_burst( transitionCoarseTime ); |
|
222 | status = enter_mode_burst( transitionCoarseTime ); | |
219 | break; |
|
223 | break; | |
220 | case LFR_MODE_SBM1: |
|
224 | case LFR_MODE_SBM1: | |
221 | status = enter_mode_sbm1( transitionCoarseTime ); |
|
225 | status = enter_mode_sbm1( transitionCoarseTime ); | |
222 | break; |
|
226 | break; | |
223 | case LFR_MODE_SBM2: |
|
227 | case LFR_MODE_SBM2: | |
224 | status = enter_mode_sbm2( transitionCoarseTime ); |
|
228 | status = enter_mode_sbm2( transitionCoarseTime ); | |
225 | break; |
|
229 | break; | |
226 | default: |
|
230 | default: | |
227 | break; |
|
231 | break; | |
228 | } |
|
232 | } | |
229 |
|
233 | |||
230 | if (status != RTEMS_SUCCESSFUL) |
|
234 | if (status != RTEMS_SUCCESSFUL) | |
231 | { |
|
235 | { | |
232 | status = LFR_EXE_ERROR; |
|
236 | status = LFR_EXE_ERROR; | |
233 | } |
|
237 | } | |
234 | } |
|
238 | } | |
235 |
|
239 | |||
236 | return status; |
|
240 | return status; | |
237 | } |
|
241 | } | |
238 |
|
242 | |||
239 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
243 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
240 | { |
|
244 | { | |
241 | /** 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. | |
242 | * |
|
246 | * | |
243 | * @param TC points to the TeleCommand packet that is being processed |
|
247 | * @param TC points to the TeleCommand packet that is being processed | |
244 | * @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 | |
245 | * |
|
249 | * | |
246 | * @return LFR directive status code: |
|
250 | * @return LFR directive status code: | |
247 | * - LFR_DEFAULT |
|
251 | * - LFR_DEFAULT | |
248 | * - LFR_SUCCESSFUL |
|
252 | * - LFR_SUCCESSFUL | |
249 | * |
|
253 | * | |
250 | */ |
|
254 | */ | |
251 |
|
255 | |||
252 | unsigned int val; |
|
256 | unsigned int val; | |
253 | int result; |
|
257 | int result; | |
254 | unsigned int status; |
|
258 | unsigned int status; | |
255 | unsigned char mode; |
|
259 | unsigned char mode; | |
256 | unsigned char * bytePosPtr; |
|
260 | unsigned char * bytePosPtr; | |
257 |
|
261 | |||
258 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
262 | bytePosPtr = (unsigned char *) &TC->packetID; | |
259 |
|
263 | |||
260 | // check LFR mode |
|
264 | // check LFR mode | |
261 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
265 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; | |
262 | status = check_update_info_hk_lfr_mode( mode ); |
|
266 | status = check_update_info_hk_lfr_mode( mode ); | |
263 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
267 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
264 | { |
|
268 | { | |
265 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
269 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; | |
266 | status = check_update_info_hk_tds_mode( mode ); |
|
270 | status = check_update_info_hk_tds_mode( mode ); | |
267 | } |
|
271 | } | |
268 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
272 | if (status == LFR_SUCCESSFUL) // check THR mode | |
269 | { |
|
273 | { | |
270 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
274 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); | |
271 | status = check_update_info_hk_thr_mode( mode ); |
|
275 | status = check_update_info_hk_thr_mode( mode ); | |
272 | } |
|
276 | } | |
273 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
277 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
274 | { |
|
278 | { | |
275 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
279 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
276 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
280 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
277 | val++; |
|
281 | val++; | |
278 | 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); | |
279 | 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); | |
280 | } |
|
284 | } | |
281 |
|
285 | |||
282 | // pa_bia_status_info |
|
286 | // pa_bia_status_info | |
283 | // => pa_bia_mode_mux_set 3 bits |
|
287 | // => pa_bia_mode_mux_set 3 bits | |
284 | // => pa_bia_mode_hv_enabled 1 bit |
|
288 | // => pa_bia_mode_hv_enabled 1 bit | |
285 | // => pa_bia_mode_bias1_enabled 1 bit |
|
289 | // => pa_bia_mode_bias1_enabled 1 bit | |
286 | // => pa_bia_mode_bias2_enabled 1 bit |
|
290 | // => pa_bia_mode_bias2_enabled 1 bit | |
287 | // => pa_bia_mode_bias3_enabled 1 bit |
|
291 | // => pa_bia_mode_bias3_enabled 1 bit | |
288 | // => pa_bia_on_off (cp_dpu_bias_on_off) |
|
292 | // => pa_bia_on_off (cp_dpu_bias_on_off) | |
289 | 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] | |
290 | pa_bia_status_info = pa_bia_status_info |
|
294 | pa_bia_status_info = pa_bia_status_info | |
291 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); |
|
295 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); | |
292 |
|
296 | |||
293 | result = status; |
|
297 | result = status; | |
294 |
|
298 | |||
295 | return result; |
|
299 | return result; | |
296 | } |
|
300 | } | |
297 |
|
301 | |||
298 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
302 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
299 | { |
|
303 | { | |
300 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
304 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
301 | * |
|
305 | * | |
302 | * @param TC points to the TeleCommand packet that is being processed |
|
306 | * @param TC points to the TeleCommand packet that is being processed | |
303 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
307 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
304 | * |
|
308 | * | |
305 | */ |
|
309 | */ | |
306 |
|
310 | |||
307 | int result; |
|
311 | int result; | |
308 |
|
312 | |||
309 | result = LFR_DEFAULT; |
|
313 | result = LFR_DEFAULT; | |
310 |
|
314 | |||
311 | setCalibration( true ); |
|
315 | setCalibration( true ); | |
312 |
|
316 | |||
313 | result = LFR_SUCCESSFUL; |
|
317 | result = LFR_SUCCESSFUL; | |
314 |
|
318 | |||
315 | return result; |
|
319 | return result; | |
316 | } |
|
320 | } | |
317 |
|
321 | |||
318 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
322 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
319 | { |
|
323 | { | |
320 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
324 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
321 | * |
|
325 | * | |
322 | * @param TC points to the TeleCommand packet that is being processed |
|
326 | * @param TC points to the TeleCommand packet that is being processed | |
323 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
327 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
324 | * |
|
328 | * | |
325 | */ |
|
329 | */ | |
326 |
|
330 | |||
327 | int result; |
|
331 | int result; | |
328 |
|
332 | |||
329 | result = LFR_DEFAULT; |
|
333 | result = LFR_DEFAULT; | |
330 |
|
334 | |||
331 | setCalibration( false ); |
|
335 | setCalibration( false ); | |
332 |
|
336 | |||
333 | result = LFR_SUCCESSFUL; |
|
337 | result = LFR_SUCCESSFUL; | |
334 |
|
338 | |||
335 | return result; |
|
339 | return result; | |
336 | } |
|
340 | } | |
337 |
|
341 | |||
338 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
342 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
339 | { |
|
343 | { | |
340 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
344 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
341 | * |
|
345 | * | |
342 | * @param TC points to the TeleCommand packet that is being processed |
|
346 | * @param TC points to the TeleCommand packet that is being processed | |
343 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
347 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
344 | * |
|
348 | * | |
345 | * @return LFR_SUCCESSFUL |
|
349 | * @return LFR_SUCCESSFUL | |
346 | * |
|
350 | * | |
347 | */ |
|
351 | */ | |
348 |
|
352 | |||
349 | unsigned int val; |
|
353 | unsigned int val; | |
350 |
|
354 | |||
351 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
355 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
352 | + (TC->dataAndCRC[1] << 16) |
|
356 | + (TC->dataAndCRC[1] << 16) | |
353 | + (TC->dataAndCRC[2] << 8) |
|
357 | + (TC->dataAndCRC[2] << 8) | |
354 | + TC->dataAndCRC[3]; |
|
358 | + TC->dataAndCRC[3]; | |
355 |
|
359 | |||
356 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
360 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
357 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
361 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
358 | val++; |
|
362 | val++; | |
359 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
363 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
360 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
364 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
361 |
|
365 | |||
362 | oneTcLfrUpdateTimeReceived = 1; |
|
366 | oneTcLfrUpdateTimeReceived = 1; | |
363 |
|
367 | |||
364 | return LFR_SUCCESSFUL; |
|
368 | return LFR_SUCCESSFUL; | |
365 | } |
|
369 | } | |
366 |
|
370 | |||
367 | //******************* |
|
371 | //******************* | |
368 | // ENTERING THE MODES |
|
372 | // ENTERING THE MODES | |
369 | int check_mode_value( unsigned char requestedMode ) |
|
373 | int check_mode_value( unsigned char requestedMode ) | |
370 | { |
|
374 | { | |
371 | int status; |
|
375 | int status; | |
372 |
|
376 | |||
373 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
377 | if ( (requestedMode != LFR_MODE_STANDBY) | |
374 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
378 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
375 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
379 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
376 | { |
|
380 | { | |
377 | status = LFR_DEFAULT; |
|
381 | status = LFR_DEFAULT; | |
378 | } |
|
382 | } | |
379 | else |
|
383 | else | |
380 | { |
|
384 | { | |
381 | status = LFR_SUCCESSFUL; |
|
385 | status = LFR_SUCCESSFUL; | |
382 | } |
|
386 | } | |
383 |
|
387 | |||
384 | return status; |
|
388 | return status; | |
385 | } |
|
389 | } | |
386 |
|
390 | |||
387 | int check_mode_transition( unsigned char requestedMode ) |
|
391 | int check_mode_transition( unsigned char requestedMode ) | |
388 | { |
|
392 | { | |
389 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
393 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
390 | * |
|
394 | * | |
391 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
395 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
392 | * |
|
396 | * | |
393 | * @return LFR directive status codes: |
|
397 | * @return LFR directive status codes: | |
394 | * - LFR_SUCCESSFUL - the transition is authorized |
|
398 | * - LFR_SUCCESSFUL - the transition is authorized | |
395 | * - LFR_DEFAULT - the transition is not authorized |
|
399 | * - LFR_DEFAULT - the transition is not authorized | |
396 | * |
|
400 | * | |
397 | */ |
|
401 | */ | |
398 |
|
402 | |||
399 | int status; |
|
403 | int status; | |
400 |
|
404 | |||
401 | switch (requestedMode) |
|
405 | switch (requestedMode) | |
402 | { |
|
406 | { | |
403 | case LFR_MODE_STANDBY: |
|
407 | case LFR_MODE_STANDBY: | |
404 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
408 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
405 | status = LFR_DEFAULT; |
|
409 | status = LFR_DEFAULT; | |
406 | } |
|
410 | } | |
407 | else |
|
411 | else | |
408 | { |
|
412 | { | |
409 | status = LFR_SUCCESSFUL; |
|
413 | status = LFR_SUCCESSFUL; | |
410 | } |
|
414 | } | |
411 | break; |
|
415 | break; | |
412 | case LFR_MODE_NORMAL: |
|
416 | case LFR_MODE_NORMAL: | |
413 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
417 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
414 | status = LFR_DEFAULT; |
|
418 | status = LFR_DEFAULT; | |
415 | } |
|
419 | } | |
416 | else { |
|
420 | else { | |
417 | status = LFR_SUCCESSFUL; |
|
421 | status = LFR_SUCCESSFUL; | |
418 | } |
|
422 | } | |
419 | break; |
|
423 | break; | |
420 | case LFR_MODE_BURST: |
|
424 | case LFR_MODE_BURST: | |
421 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
425 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
422 | status = LFR_DEFAULT; |
|
426 | status = LFR_DEFAULT; | |
423 | } |
|
427 | } | |
424 | else { |
|
428 | else { | |
425 | status = LFR_SUCCESSFUL; |
|
429 | status = LFR_SUCCESSFUL; | |
426 | } |
|
430 | } | |
427 | break; |
|
431 | break; | |
428 | case LFR_MODE_SBM1: |
|
432 | case LFR_MODE_SBM1: | |
429 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
433 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
430 | status = LFR_DEFAULT; |
|
434 | status = LFR_DEFAULT; | |
431 | } |
|
435 | } | |
432 | else { |
|
436 | else { | |
433 | status = LFR_SUCCESSFUL; |
|
437 | status = LFR_SUCCESSFUL; | |
434 | } |
|
438 | } | |
435 | break; |
|
439 | break; | |
436 | case LFR_MODE_SBM2: |
|
440 | case LFR_MODE_SBM2: | |
437 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
441 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
438 | status = LFR_DEFAULT; |
|
442 | status = LFR_DEFAULT; | |
439 | } |
|
443 | } | |
440 | else { |
|
444 | else { | |
441 | status = LFR_SUCCESSFUL; |
|
445 | status = LFR_SUCCESSFUL; | |
442 | } |
|
446 | } | |
443 | break; |
|
447 | break; | |
444 | default: |
|
448 | default: | |
445 | status = LFR_DEFAULT; |
|
449 | status = LFR_DEFAULT; | |
446 | break; |
|
450 | break; | |
447 | } |
|
451 | } | |
448 |
|
452 | |||
449 | return status; |
|
453 | return status; | |
450 | } |
|
454 | } | |
451 |
|
455 | |||
452 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ) |
|
456 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ) | |
453 | { |
|
457 | { | |
454 | if (transitionCoarseTime == 0) |
|
458 | if (transitionCoarseTime == 0) | |
455 | { |
|
459 | { | |
456 | lastValidEnterModeTime = time_management_regs->coarse_time + 1; |
|
460 | lastValidEnterModeTime = time_management_regs->coarse_time + 1; | |
457 | PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime); |
|
461 | PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime); | |
458 | } |
|
462 | } | |
459 | else |
|
463 | else | |
460 | { |
|
464 | { | |
461 | lastValidEnterModeTime = transitionCoarseTime; |
|
465 | lastValidEnterModeTime = transitionCoarseTime; | |
462 | PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime); |
|
466 | PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime); | |
463 | } |
|
467 | } | |
464 | } |
|
468 | } | |
465 |
|
469 | |||
466 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
470 | int check_transition_date( unsigned int transitionCoarseTime ) | |
467 | { |
|
471 | { | |
468 | int status; |
|
472 | int status; | |
469 | unsigned int localCoarseTime; |
|
473 | unsigned int localCoarseTime; | |
470 | unsigned int deltaCoarseTime; |
|
474 | unsigned int deltaCoarseTime; | |
471 |
|
475 | |||
472 | status = LFR_SUCCESSFUL; |
|
476 | status = LFR_SUCCESSFUL; | |
473 |
|
477 | |||
474 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
478 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
475 | { |
|
479 | { | |
476 | status = LFR_SUCCESSFUL; |
|
480 | status = LFR_SUCCESSFUL; | |
477 | } |
|
481 | } | |
478 | else |
|
482 | else | |
479 | { |
|
483 | { | |
480 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
484 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; | |
481 |
|
485 | |||
482 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime); |
|
486 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime); | |
483 |
|
487 | |||
484 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
488 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
485 | { |
|
489 | { | |
486 | status = LFR_DEFAULT; |
|
490 | status = LFR_DEFAULT; | |
487 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n"); |
|
491 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n"); | |
488 | } |
|
492 | } | |
489 |
|
493 | |||
490 | if (status == LFR_SUCCESSFUL) |
|
494 | if (status == LFR_SUCCESSFUL) | |
491 | { |
|
495 | { | |
492 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
496 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
493 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
497 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 | |
494 | { |
|
498 | { | |
495 | status = LFR_DEFAULT; |
|
499 | status = LFR_DEFAULT; | |
496 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
500 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
497 | } |
|
501 | } | |
498 | } |
|
502 | } | |
499 | } |
|
503 | } | |
500 |
|
504 | |||
501 | return status; |
|
505 | return status; | |
502 | } |
|
506 | } | |
503 |
|
507 | |||
504 | int restart_asm_activities( unsigned char lfrRequestedMode ) |
|
508 | int restart_asm_activities( unsigned char lfrRequestedMode ) | |
505 | { |
|
509 | { | |
506 | rtems_status_code status; |
|
510 | rtems_status_code status; | |
507 |
|
511 | |||
508 | status = stop_spectral_matrices(); |
|
512 | status = stop_spectral_matrices(); | |
509 |
|
513 | |||
510 | thisIsAnASMRestart = 1; |
|
514 | thisIsAnASMRestart = 1; | |
511 |
|
515 | |||
512 | status = restart_asm_tasks( lfrRequestedMode ); |
|
516 | status = restart_asm_tasks( lfrRequestedMode ); | |
513 |
|
517 | |||
514 | launch_spectral_matrix(); |
|
518 | launch_spectral_matrix(); | |
515 |
|
519 | |||
516 | return status; |
|
520 | return status; | |
517 | } |
|
521 | } | |
518 |
|
522 | |||
519 | int stop_spectral_matrices( void ) |
|
523 | int stop_spectral_matrices( void ) | |
520 | { |
|
524 | { | |
521 | /** This function stops and restarts the current mode average spectral matrices activities. |
|
525 | /** This function stops and restarts the current mode average spectral matrices activities. | |
522 | * |
|
526 | * | |
523 | * @return RTEMS directive status codes: |
|
527 | * @return RTEMS directive status codes: | |
524 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
528 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
525 | * - RTEMS_INVALID_ID - task id invalid |
|
529 | * - RTEMS_INVALID_ID - task id invalid | |
526 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
530 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
527 | * |
|
531 | * | |
528 | */ |
|
532 | */ | |
529 |
|
533 | |||
530 | rtems_status_code status; |
|
534 | rtems_status_code status; | |
531 |
|
535 | |||
532 | status = RTEMS_SUCCESSFUL; |
|
536 | status = RTEMS_SUCCESSFUL; | |
533 |
|
537 | |||
534 | // (1) mask interruptions |
|
538 | // (1) mask interruptions | |
535 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt |
|
539 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt | |
536 |
|
540 | |||
537 | // (2) reset spectral matrices registers |
|
541 | // (2) reset spectral matrices registers | |
538 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
542 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
539 | reset_sm_status(); |
|
543 | reset_sm_status(); | |
540 |
|
544 | |||
541 | // (3) clear interruptions |
|
545 | // (3) clear interruptions | |
542 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
546 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
543 |
|
547 | |||
544 | // suspend several tasks |
|
548 | // suspend several tasks | |
545 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
549 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
546 | status = suspend_asm_tasks(); |
|
550 | status = suspend_asm_tasks(); | |
547 | } |
|
551 | } | |
548 |
|
552 | |||
549 | if (status != RTEMS_SUCCESSFUL) |
|
553 | if (status != RTEMS_SUCCESSFUL) | |
550 | { |
|
554 | { | |
551 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
555 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
552 | } |
|
556 | } | |
553 |
|
557 | |||
554 | return status; |
|
558 | return status; | |
555 | } |
|
559 | } | |
556 |
|
560 | |||
557 | int stop_current_mode( void ) |
|
561 | int stop_current_mode( void ) | |
558 | { |
|
562 | { | |
559 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
563 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
560 | * |
|
564 | * | |
561 | * @return RTEMS directive status codes: |
|
565 | * @return RTEMS directive status codes: | |
562 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
566 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
563 | * - RTEMS_INVALID_ID - task id invalid |
|
567 | * - RTEMS_INVALID_ID - task id invalid | |
564 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
568 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
565 | * |
|
569 | * | |
566 | */ |
|
570 | */ | |
567 |
|
571 | |||
568 | rtems_status_code status; |
|
572 | rtems_status_code status; | |
569 |
|
573 | |||
570 | status = RTEMS_SUCCESSFUL; |
|
574 | status = RTEMS_SUCCESSFUL; | |
571 |
|
575 | |||
572 | // (1) mask interruptions |
|
576 | // (1) mask interruptions | |
573 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
577 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
574 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
578 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
575 |
|
579 | |||
576 | // (2) reset waveform picker registers |
|
580 | // (2) reset waveform picker registers | |
577 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
581 | reset_wfp_burst_enable(); // reset burst and enable bits | |
578 | reset_wfp_status(); // reset all the status bits |
|
582 | reset_wfp_status(); // reset all the status bits | |
579 |
|
583 | |||
580 | // (3) reset spectral matrices registers |
|
584 | // (3) reset spectral matrices registers | |
581 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
585 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
582 | reset_sm_status(); |
|
586 | reset_sm_status(); | |
583 |
|
587 | |||
584 | // reset lfr VHDL module |
|
588 | // reset lfr VHDL module | |
585 | reset_lfr(); |
|
589 | reset_lfr(); | |
586 |
|
590 | |||
587 | reset_extractSWF(); // reset the extractSWF flag to false |
|
591 | reset_extractSWF(); // reset the extractSWF flag to false | |
588 |
|
592 | |||
589 | // (4) clear interruptions |
|
593 | // (4) clear interruptions | |
590 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
594 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
591 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
595 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
592 |
|
596 | |||
593 | // suspend several tasks |
|
597 | // suspend several tasks | |
594 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
598 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
595 | status = suspend_science_tasks(); |
|
599 | status = suspend_science_tasks(); | |
596 | } |
|
600 | } | |
597 |
|
601 | |||
598 | if (status != RTEMS_SUCCESSFUL) |
|
602 | if (status != RTEMS_SUCCESSFUL) | |
599 | { |
|
603 | { | |
600 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
604 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
601 | } |
|
605 | } | |
602 |
|
606 | |||
603 | return status; |
|
607 | return status; | |
604 | } |
|
608 | } | |
605 |
|
609 | |||
606 | int enter_mode_standby( void ) |
|
610 | int enter_mode_standby( void ) | |
607 | { |
|
611 | { | |
608 | /** This function is used to put LFR in the STANDBY mode. |
|
612 | /** This function is used to put LFR in the STANDBY mode. | |
609 | * |
|
613 | * | |
610 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
614 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
611 | * |
|
615 | * | |
612 | * @return RTEMS directive status codes: |
|
616 | * @return RTEMS directive status codes: | |
613 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
617 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
614 | * - RTEMS_INVALID_ID - task id invalid |
|
618 | * - RTEMS_INVALID_ID - task id invalid | |
615 | * - RTEMS_INCORRECT_STATE - task never started |
|
619 | * - RTEMS_INCORRECT_STATE - task never started | |
616 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
620 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
617 | * |
|
621 | * | |
618 | * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE |
|
622 | * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE | |
619 | * is immediate. |
|
623 | * is immediate. | |
620 | * |
|
624 | * | |
621 | */ |
|
625 | */ | |
622 |
|
626 | |||
623 | int status; |
|
627 | int status; | |
624 |
|
628 | |||
625 | status = stop_current_mode(); // STOP THE CURRENT MODE |
|
629 | status = stop_current_mode(); // STOP THE CURRENT MODE | |
626 |
|
630 | |||
627 | #ifdef PRINT_TASK_STATISTICS |
|
631 | #ifdef PRINT_TASK_STATISTICS | |
628 | rtems_cpu_usage_report(); |
|
632 | rtems_cpu_usage_report(); | |
629 | #endif |
|
633 | #endif | |
630 |
|
634 | |||
631 | #ifdef PRINT_STACK_REPORT |
|
635 | #ifdef PRINT_STACK_REPORT | |
632 | PRINTF("stack report selected\n") |
|
636 | PRINTF("stack report selected\n") | |
633 | rtems_stack_checker_report_usage(); |
|
637 | rtems_stack_checker_report_usage(); | |
634 | #endif |
|
638 | #endif | |
635 |
|
639 | |||
636 | return status; |
|
640 | return status; | |
637 | } |
|
641 | } | |
638 |
|
642 | |||
639 | int enter_mode_normal( unsigned int transitionCoarseTime ) |
|
643 | int enter_mode_normal( unsigned int transitionCoarseTime ) | |
640 | { |
|
644 | { | |
641 | /** This function is used to start the NORMAL mode. |
|
645 | /** This function is used to start the NORMAL mode. | |
642 | * |
|
646 | * | |
643 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
647 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
644 | * |
|
648 | * | |
645 | * @return RTEMS directive status codes: |
|
649 | * @return RTEMS directive status codes: | |
646 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
650 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
647 | * - RTEMS_INVALID_ID - task id invalid |
|
651 | * - RTEMS_INVALID_ID - task id invalid | |
648 | * - RTEMS_INCORRECT_STATE - task never started |
|
652 | * - RTEMS_INCORRECT_STATE - task never started | |
649 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
653 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
650 | * |
|
654 | * | |
651 | * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2, |
|
655 | * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2, | |
652 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. |
|
656 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. | |
653 | * |
|
657 | * | |
654 | */ |
|
658 | */ | |
655 |
|
659 | |||
656 | int status; |
|
660 | int status; | |
657 |
|
661 | |||
658 | #ifdef PRINT_TASK_STATISTICS |
|
662 | #ifdef PRINT_TASK_STATISTICS | |
659 | rtems_cpu_usage_reset(); |
|
663 | rtems_cpu_usage_reset(); | |
660 | #endif |
|
664 | #endif | |
661 |
|
665 | |||
662 | status = RTEMS_UNSATISFIED; |
|
666 | status = RTEMS_UNSATISFIED; | |
663 |
|
667 | |||
664 | switch( lfrCurrentMode ) |
|
668 | switch( lfrCurrentMode ) | |
665 | { |
|
669 | { | |
666 | case LFR_MODE_STANDBY: |
|
670 | case LFR_MODE_STANDBY: | |
667 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks |
|
671 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks | |
668 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
672 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
669 | { |
|
673 | { | |
670 | launch_spectral_matrix( ); |
|
674 | launch_spectral_matrix( ); | |
671 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
675 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
672 | } |
|
676 | } | |
673 | break; |
|
677 | break; | |
674 | case LFR_MODE_BURST: |
|
678 | case LFR_MODE_BURST: | |
675 | status = stop_current_mode(); // stop the current mode |
|
679 | status = stop_current_mode(); // stop the current mode | |
676 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks |
|
680 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks | |
677 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
681 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
678 | { |
|
682 | { | |
679 | launch_spectral_matrix( ); |
|
683 | launch_spectral_matrix( ); | |
680 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
684 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
681 | } |
|
685 | } | |
682 | break; |
|
686 | break; | |
683 | case LFR_MODE_SBM1: |
|
687 | case LFR_MODE_SBM1: | |
684 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters |
|
688 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
685 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
689 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
686 | update_last_valid_transition_date( transitionCoarseTime ); |
|
690 | update_last_valid_transition_date( transitionCoarseTime ); | |
687 | break; |
|
691 | break; | |
688 | case LFR_MODE_SBM2: |
|
692 | case LFR_MODE_SBM2: | |
689 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters |
|
693 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
690 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
694 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
691 | update_last_valid_transition_date( transitionCoarseTime ); |
|
695 | update_last_valid_transition_date( transitionCoarseTime ); | |
692 | break; |
|
696 | break; | |
693 | default: |
|
697 | default: | |
694 | break; |
|
698 | break; | |
695 | } |
|
699 | } | |
696 |
|
700 | |||
697 | if (status != RTEMS_SUCCESSFUL) |
|
701 | if (status != RTEMS_SUCCESSFUL) | |
698 | { |
|
702 | { | |
699 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) |
|
703 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) | |
700 | status = RTEMS_UNSATISFIED; |
|
704 | status = RTEMS_UNSATISFIED; | |
701 | } |
|
705 | } | |
702 |
|
706 | |||
703 | return status; |
|
707 | return status; | |
704 | } |
|
708 | } | |
705 |
|
709 | |||
706 | int enter_mode_burst( unsigned int transitionCoarseTime ) |
|
710 | int enter_mode_burst( unsigned int transitionCoarseTime ) | |
707 | { |
|
711 | { | |
708 | /** This function is used to start the BURST mode. |
|
712 | /** This function is used to start the BURST mode. | |
709 | * |
|
713 | * | |
710 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
714 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
711 | * |
|
715 | * | |
712 | * @return RTEMS directive status codes: |
|
716 | * @return RTEMS directive status codes: | |
713 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
717 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
714 | * - RTEMS_INVALID_ID - task id invalid |
|
718 | * - RTEMS_INVALID_ID - task id invalid | |
715 | * - RTEMS_INCORRECT_STATE - task never started |
|
719 | * - RTEMS_INCORRECT_STATE - task never started | |
716 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
720 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
717 | * |
|
721 | * | |
718 | * The way the BURST mode is started does not depend on the LFR current mode. |
|
722 | * The way the BURST mode is started does not depend on the LFR current mode. | |
719 | * |
|
723 | * | |
720 | */ |
|
724 | */ | |
721 |
|
725 | |||
722 |
|
726 | |||
723 | int status; |
|
727 | int status; | |
724 |
|
728 | |||
725 | #ifdef PRINT_TASK_STATISTICS |
|
729 | #ifdef PRINT_TASK_STATISTICS | |
726 | rtems_cpu_usage_reset(); |
|
730 | rtems_cpu_usage_reset(); | |
727 | #endif |
|
731 | #endif | |
728 |
|
732 | |||
729 | status = stop_current_mode(); // stop the current mode |
|
733 | status = stop_current_mode(); // stop the current mode | |
730 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks |
|
734 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks | |
731 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
735 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
732 | { |
|
736 | { | |
733 | launch_spectral_matrix( ); |
|
737 | launch_spectral_matrix( ); | |
734 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); |
|
738 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); | |
735 | } |
|
739 | } | |
736 |
|
740 | |||
737 | if (status != RTEMS_SUCCESSFUL) |
|
741 | if (status != RTEMS_SUCCESSFUL) | |
738 | { |
|
742 | { | |
739 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) |
|
743 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) | |
740 | status = RTEMS_UNSATISFIED; |
|
744 | status = RTEMS_UNSATISFIED; | |
741 | } |
|
745 | } | |
742 |
|
746 | |||
743 | return status; |
|
747 | return status; | |
744 | } |
|
748 | } | |
745 |
|
749 | |||
746 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) |
|
750 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) | |
747 | { |
|
751 | { | |
748 | /** This function is used to start the SBM1 mode. |
|
752 | /** This function is used to start the SBM1 mode. | |
749 | * |
|
753 | * | |
750 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
754 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
751 | * |
|
755 | * | |
752 | * @return RTEMS directive status codes: |
|
756 | * @return RTEMS directive status codes: | |
753 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
757 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
754 | * - RTEMS_INVALID_ID - task id invalid |
|
758 | * - RTEMS_INVALID_ID - task id invalid | |
755 | * - RTEMS_INCORRECT_STATE - task never started |
|
759 | * - RTEMS_INCORRECT_STATE - task never started | |
756 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
760 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
757 | * |
|
761 | * | |
758 | * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2, |
|
762 | * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2, | |
759 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other |
|
763 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |
760 | * cases, the acquisition is completely restarted. |
|
764 | * cases, the acquisition is completely restarted. | |
761 | * |
|
765 | * | |
762 | */ |
|
766 | */ | |
763 |
|
767 | |||
764 | int status; |
|
768 | int status; | |
765 |
|
769 | |||
766 | #ifdef PRINT_TASK_STATISTICS |
|
770 | #ifdef PRINT_TASK_STATISTICS | |
767 | rtems_cpu_usage_reset(); |
|
771 | rtems_cpu_usage_reset(); | |
768 | #endif |
|
772 | #endif | |
769 |
|
773 | |||
770 | status = RTEMS_UNSATISFIED; |
|
774 | status = RTEMS_UNSATISFIED; | |
771 |
|
775 | |||
772 | switch( lfrCurrentMode ) |
|
776 | switch( lfrCurrentMode ) | |
773 | { |
|
777 | { | |
774 | case LFR_MODE_STANDBY: |
|
778 | case LFR_MODE_STANDBY: | |
775 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks |
|
779 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks | |
776 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
780 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
777 | { |
|
781 | { | |
778 | launch_spectral_matrix( ); |
|
782 | launch_spectral_matrix( ); | |
779 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
783 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
780 | } |
|
784 | } | |
781 | break; |
|
785 | break; | |
782 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action |
|
786 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action | |
783 | status = restart_asm_activities( LFR_MODE_SBM1 ); |
|
787 | status = restart_asm_activities( LFR_MODE_SBM1 ); | |
784 | status = LFR_SUCCESSFUL; |
|
788 | status = LFR_SUCCESSFUL; | |
785 | update_last_valid_transition_date( transitionCoarseTime ); |
|
789 | update_last_valid_transition_date( transitionCoarseTime ); | |
786 | break; |
|
790 | break; | |
787 | case LFR_MODE_BURST: |
|
791 | case LFR_MODE_BURST: | |
788 | status = stop_current_mode(); // stop the current mode |
|
792 | status = stop_current_mode(); // stop the current mode | |
789 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks |
|
793 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks | |
790 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
794 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
791 | { |
|
795 | { | |
792 | launch_spectral_matrix( ); |
|
796 | launch_spectral_matrix( ); | |
793 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
797 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
794 | } |
|
798 | } | |
795 | break; |
|
799 | break; | |
796 | case LFR_MODE_SBM2: |
|
800 | case LFR_MODE_SBM2: | |
797 | status = restart_asm_activities( LFR_MODE_SBM1 ); |
|
801 | status = restart_asm_activities( LFR_MODE_SBM1 ); | |
798 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
802 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
799 | update_last_valid_transition_date( transitionCoarseTime ); |
|
803 | update_last_valid_transition_date( transitionCoarseTime ); | |
800 | break; |
|
804 | break; | |
801 | default: |
|
805 | default: | |
802 | break; |
|
806 | break; | |
803 | } |
|
807 | } | |
804 |
|
808 | |||
805 | if (status != RTEMS_SUCCESSFUL) |
|
809 | if (status != RTEMS_SUCCESSFUL) | |
806 | { |
|
810 | { | |
807 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status); |
|
811 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status); | |
808 | status = RTEMS_UNSATISFIED; |
|
812 | status = RTEMS_UNSATISFIED; | |
809 | } |
|
813 | } | |
810 |
|
814 | |||
811 | return status; |
|
815 | return status; | |
812 | } |
|
816 | } | |
813 |
|
817 | |||
814 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) |
|
818 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) | |
815 | { |
|
819 | { | |
816 | /** This function is used to start the SBM2 mode. |
|
820 | /** This function is used to start the SBM2 mode. | |
817 | * |
|
821 | * | |
818 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
822 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
819 | * |
|
823 | * | |
820 | * @return RTEMS directive status codes: |
|
824 | * @return RTEMS directive status codes: | |
821 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
825 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
822 | * - RTEMS_INVALID_ID - task id invalid |
|
826 | * - RTEMS_INVALID_ID - task id invalid | |
823 | * - RTEMS_INCORRECT_STATE - task never started |
|
827 | * - RTEMS_INCORRECT_STATE - task never started | |
824 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
828 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
825 | * |
|
829 | * | |
826 | * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1, |
|
830 | * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1, | |
827 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other |
|
831 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |
828 | * cases, the acquisition is completely restarted. |
|
832 | * cases, the acquisition is completely restarted. | |
829 | * |
|
833 | * | |
830 | */ |
|
834 | */ | |
831 |
|
835 | |||
832 | int status; |
|
836 | int status; | |
833 |
|
837 | |||
834 | #ifdef PRINT_TASK_STATISTICS |
|
838 | #ifdef PRINT_TASK_STATISTICS | |
835 | rtems_cpu_usage_reset(); |
|
839 | rtems_cpu_usage_reset(); | |
836 | #endif |
|
840 | #endif | |
837 |
|
841 | |||
838 | status = RTEMS_UNSATISFIED; |
|
842 | status = RTEMS_UNSATISFIED; | |
839 |
|
843 | |||
840 | switch( lfrCurrentMode ) |
|
844 | switch( lfrCurrentMode ) | |
841 | { |
|
845 | { | |
842 | case LFR_MODE_STANDBY: |
|
846 | case LFR_MODE_STANDBY: | |
843 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks |
|
847 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks | |
844 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
848 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
845 | { |
|
849 | { | |
846 | launch_spectral_matrix( ); |
|
850 | launch_spectral_matrix( ); | |
847 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
851 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
848 | } |
|
852 | } | |
849 | break; |
|
853 | break; | |
850 | case LFR_MODE_NORMAL: |
|
854 | case LFR_MODE_NORMAL: | |
851 | status = restart_asm_activities( LFR_MODE_SBM2 ); |
|
855 | status = restart_asm_activities( LFR_MODE_SBM2 ); | |
852 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
856 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
853 | update_last_valid_transition_date( transitionCoarseTime ); |
|
857 | update_last_valid_transition_date( transitionCoarseTime ); | |
854 | break; |
|
858 | break; | |
855 | case LFR_MODE_BURST: |
|
859 | case LFR_MODE_BURST: | |
856 | status = stop_current_mode(); // stop the current mode |
|
860 | status = stop_current_mode(); // stop the current mode | |
857 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks |
|
861 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks | |
858 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
862 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
859 | { |
|
863 | { | |
860 | launch_spectral_matrix( ); |
|
864 | launch_spectral_matrix( ); | |
861 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
865 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
862 | } |
|
866 | } | |
863 | break; |
|
867 | break; | |
864 | case LFR_MODE_SBM1: |
|
868 | case LFR_MODE_SBM1: | |
865 | status = restart_asm_activities( LFR_MODE_SBM2 ); |
|
869 | status = restart_asm_activities( LFR_MODE_SBM2 ); | |
866 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
870 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
867 | update_last_valid_transition_date( transitionCoarseTime ); |
|
871 | update_last_valid_transition_date( transitionCoarseTime ); | |
868 | break; |
|
872 | break; | |
869 | default: |
|
873 | default: | |
870 | break; |
|
874 | break; | |
871 | } |
|
875 | } | |
872 |
|
876 | |||
873 | if (status != RTEMS_SUCCESSFUL) |
|
877 | if (status != RTEMS_SUCCESSFUL) | |
874 | { |
|
878 | { | |
875 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) |
|
879 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) | |
876 | status = RTEMS_UNSATISFIED; |
|
880 | status = RTEMS_UNSATISFIED; | |
877 | } |
|
881 | } | |
878 |
|
882 | |||
879 | return status; |
|
883 | return status; | |
880 | } |
|
884 | } | |
881 |
|
885 | |||
882 | int restart_science_tasks( unsigned char lfrRequestedMode ) |
|
886 | int restart_science_tasks( unsigned char lfrRequestedMode ) | |
883 | { |
|
887 | { | |
884 | /** This function is used to restart all science tasks. |
|
888 | /** This function is used to restart all science tasks. | |
885 | * |
|
889 | * | |
886 | * @return RTEMS directive status codes: |
|
890 | * @return RTEMS directive status codes: | |
887 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
891 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
888 | * - RTEMS_INVALID_ID - task id invalid |
|
892 | * - RTEMS_INVALID_ID - task id invalid | |
889 | * - RTEMS_INCORRECT_STATE - task never started |
|
893 | * - RTEMS_INCORRECT_STATE - task never started | |
890 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
894 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
891 | * |
|
895 | * | |
892 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
896 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
893 | * |
|
897 | * | |
894 | */ |
|
898 | */ | |
895 |
|
899 | |||
896 | rtems_status_code status[10]; |
|
900 | rtems_status_code status[10]; | |
897 | rtems_status_code ret; |
|
901 | rtems_status_code ret; | |
898 |
|
902 | |||
899 | ret = RTEMS_SUCCESSFUL; |
|
903 | ret = RTEMS_SUCCESSFUL; | |
900 |
|
904 | |||
901 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
905 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
902 | if (status[0] != RTEMS_SUCCESSFUL) |
|
906 | if (status[0] != RTEMS_SUCCESSFUL) | |
903 | { |
|
907 | { | |
904 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
908 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
905 | } |
|
909 | } | |
906 |
|
910 | |||
907 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
911 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
908 | if (status[1] != RTEMS_SUCCESSFUL) |
|
912 | if (status[1] != RTEMS_SUCCESSFUL) | |
909 | { |
|
913 | { | |
910 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
914 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
911 | } |
|
915 | } | |
912 |
|
916 | |||
913 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
917 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
914 | if (status[2] != RTEMS_SUCCESSFUL) |
|
918 | if (status[2] != RTEMS_SUCCESSFUL) | |
915 | { |
|
919 | { | |
916 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
920 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) | |
917 | } |
|
921 | } | |
918 |
|
922 | |||
919 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
923 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
920 | if (status[3] != RTEMS_SUCCESSFUL) |
|
924 | if (status[3] != RTEMS_SUCCESSFUL) | |
921 | { |
|
925 | { | |
922 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
926 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) | |
923 | } |
|
927 | } | |
924 |
|
928 | |||
925 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
929 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
926 | if (status[4] != RTEMS_SUCCESSFUL) |
|
930 | if (status[4] != RTEMS_SUCCESSFUL) | |
927 | { |
|
931 | { | |
928 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
932 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) | |
929 | } |
|
933 | } | |
930 |
|
934 | |||
931 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
935 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
932 | if (status[5] != RTEMS_SUCCESSFUL) |
|
936 | if (status[5] != RTEMS_SUCCESSFUL) | |
933 | { |
|
937 | { | |
934 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
938 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) | |
935 | } |
|
939 | } | |
936 |
|
940 | |||
937 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
941 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
938 | if (status[6] != RTEMS_SUCCESSFUL) |
|
942 | if (status[6] != RTEMS_SUCCESSFUL) | |
939 | { |
|
943 | { | |
940 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
944 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) | |
941 | } |
|
945 | } | |
942 |
|
946 | |||
943 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
947 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
944 | if (status[7] != RTEMS_SUCCESSFUL) |
|
948 | if (status[7] != RTEMS_SUCCESSFUL) | |
945 | { |
|
949 | { | |
946 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
950 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) | |
947 | } |
|
951 | } | |
948 |
|
952 | |||
949 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
953 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
950 | if (status[8] != RTEMS_SUCCESSFUL) |
|
954 | if (status[8] != RTEMS_SUCCESSFUL) | |
951 | { |
|
955 | { | |
952 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
956 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) | |
953 | } |
|
957 | } | |
954 |
|
958 | |||
955 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
959 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
956 | if (status[9] != RTEMS_SUCCESSFUL) |
|
960 | if (status[9] != RTEMS_SUCCESSFUL) | |
957 | { |
|
961 | { | |
958 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
962 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) | |
959 | } |
|
963 | } | |
960 |
|
964 | |||
961 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
965 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
962 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
966 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
963 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
967 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || | |
964 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
968 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || | |
965 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
969 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) | |
966 | { |
|
970 | { | |
967 | ret = RTEMS_UNSATISFIED; |
|
971 | ret = RTEMS_UNSATISFIED; | |
968 | } |
|
972 | } | |
969 |
|
973 | |||
970 | return ret; |
|
974 | return ret; | |
971 | } |
|
975 | } | |
972 |
|
976 | |||
973 | int restart_asm_tasks( unsigned char lfrRequestedMode ) |
|
977 | int restart_asm_tasks( unsigned char lfrRequestedMode ) | |
974 | { |
|
978 | { | |
975 | /** This function is used to restart average spectral matrices tasks. |
|
979 | /** This function is used to restart average spectral matrices tasks. | |
976 | * |
|
980 | * | |
977 | * @return RTEMS directive status codes: |
|
981 | * @return RTEMS directive status codes: | |
978 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
982 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
979 | * - RTEMS_INVALID_ID - task id invalid |
|
983 | * - RTEMS_INVALID_ID - task id invalid | |
980 | * - RTEMS_INCORRECT_STATE - task never started |
|
984 | * - RTEMS_INCORRECT_STATE - task never started | |
981 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
985 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
982 | * |
|
986 | * | |
983 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 |
|
987 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 | |
984 | * |
|
988 | * | |
985 | */ |
|
989 | */ | |
986 |
|
990 | |||
987 | rtems_status_code status[6]; |
|
991 | rtems_status_code status[6]; | |
988 | rtems_status_code ret; |
|
992 | rtems_status_code ret; | |
989 |
|
993 | |||
990 | ret = RTEMS_SUCCESSFUL; |
|
994 | ret = RTEMS_SUCCESSFUL; | |
991 |
|
995 | |||
992 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
996 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
993 | if (status[0] != RTEMS_SUCCESSFUL) |
|
997 | if (status[0] != RTEMS_SUCCESSFUL) | |
994 | { |
|
998 | { | |
995 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
999 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
996 | } |
|
1000 | } | |
997 |
|
1001 | |||
998 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
1002 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
999 | if (status[1] != RTEMS_SUCCESSFUL) |
|
1003 | if (status[1] != RTEMS_SUCCESSFUL) | |
1000 | { |
|
1004 | { | |
1001 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
1005 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
1002 | } |
|
1006 | } | |
1003 |
|
1007 | |||
1004 | status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
1008 | status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
1005 | if (status[2] != RTEMS_SUCCESSFUL) |
|
1009 | if (status[2] != RTEMS_SUCCESSFUL) | |
1006 | { |
|
1010 | { | |
1007 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2]) |
|
1011 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2]) | |
1008 | } |
|
1012 | } | |
1009 |
|
1013 | |||
1010 | status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
1014 | status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
1011 | if (status[3] != RTEMS_SUCCESSFUL) |
|
1015 | if (status[3] != RTEMS_SUCCESSFUL) | |
1012 | { |
|
1016 | { | |
1013 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3]) |
|
1017 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3]) | |
1014 | } |
|
1018 | } | |
1015 |
|
1019 | |||
1016 | status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
1020 | status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
1017 | if (status[4] != RTEMS_SUCCESSFUL) |
|
1021 | if (status[4] != RTEMS_SUCCESSFUL) | |
1018 | { |
|
1022 | { | |
1019 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4]) |
|
1023 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4]) | |
1020 | } |
|
1024 | } | |
1021 |
|
1025 | |||
1022 | status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
1026 | status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
1023 | if (status[5] != RTEMS_SUCCESSFUL) |
|
1027 | if (status[5] != RTEMS_SUCCESSFUL) | |
1024 | { |
|
1028 | { | |
1025 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5]) |
|
1029 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5]) | |
1026 | } |
|
1030 | } | |
1027 |
|
1031 | |||
1028 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
1032 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
1029 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
1033 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
1030 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) |
|
1034 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) | |
1031 | { |
|
1035 | { | |
1032 | ret = RTEMS_UNSATISFIED; |
|
1036 | ret = RTEMS_UNSATISFIED; | |
1033 | } |
|
1037 | } | |
1034 |
|
1038 | |||
1035 | return ret; |
|
1039 | return ret; | |
1036 | } |
|
1040 | } | |
1037 |
|
1041 | |||
1038 | int suspend_science_tasks( void ) |
|
1042 | int suspend_science_tasks( void ) | |
1039 | { |
|
1043 | { | |
1040 | /** This function suspends the science tasks. |
|
1044 | /** This function suspends the science tasks. | |
1041 | * |
|
1045 | * | |
1042 | * @return RTEMS directive status codes: |
|
1046 | * @return RTEMS directive status codes: | |
1043 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1047 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1044 | * - RTEMS_INVALID_ID - task id invalid |
|
1048 | * - RTEMS_INVALID_ID - task id invalid | |
1045 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1049 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1046 | * |
|
1050 | * | |
1047 | */ |
|
1051 | */ | |
1048 |
|
1052 | |||
1049 | rtems_status_code status; |
|
1053 | rtems_status_code status; | |
1050 |
|
1054 | |||
1051 | PRINTF("in suspend_science_tasks\n") |
|
1055 | PRINTF("in suspend_science_tasks\n") | |
1052 |
|
1056 | |||
1053 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1057 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1054 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1058 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1055 | { |
|
1059 | { | |
1056 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1060 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1057 | } |
|
1061 | } | |
1058 | else |
|
1062 | else | |
1059 | { |
|
1063 | { | |
1060 | status = RTEMS_SUCCESSFUL; |
|
1064 | status = RTEMS_SUCCESSFUL; | |
1061 | } |
|
1065 | } | |
1062 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1066 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1063 | { |
|
1067 | { | |
1064 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1068 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1065 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1069 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1066 | { |
|
1070 | { | |
1067 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1071 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1068 | } |
|
1072 | } | |
1069 | else |
|
1073 | else | |
1070 | { |
|
1074 | { | |
1071 | status = RTEMS_SUCCESSFUL; |
|
1075 | status = RTEMS_SUCCESSFUL; | |
1072 | } |
|
1076 | } | |
1073 | } |
|
1077 | } | |
1074 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1078 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1075 | { |
|
1079 | { | |
1076 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1080 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1077 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1081 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1078 | { |
|
1082 | { | |
1079 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1083 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1080 | } |
|
1084 | } | |
1081 | else |
|
1085 | else | |
1082 | { |
|
1086 | { | |
1083 | status = RTEMS_SUCCESSFUL; |
|
1087 | status = RTEMS_SUCCESSFUL; | |
1084 | } |
|
1088 | } | |
1085 | } |
|
1089 | } | |
1086 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1090 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1087 | { |
|
1091 | { | |
1088 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1092 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1089 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1093 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1090 | { |
|
1094 | { | |
1091 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1095 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1092 | } |
|
1096 | } | |
1093 | else |
|
1097 | else | |
1094 | { |
|
1098 | { | |
1095 | status = RTEMS_SUCCESSFUL; |
|
1099 | status = RTEMS_SUCCESSFUL; | |
1096 | } |
|
1100 | } | |
1097 | } |
|
1101 | } | |
1098 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1102 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1099 | { |
|
1103 | { | |
1100 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1104 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1101 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1105 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1102 | { |
|
1106 | { | |
1103 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1107 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1104 | } |
|
1108 | } | |
1105 | else |
|
1109 | else | |
1106 | { |
|
1110 | { | |
1107 | status = RTEMS_SUCCESSFUL; |
|
1111 | status = RTEMS_SUCCESSFUL; | |
1108 | } |
|
1112 | } | |
1109 | } |
|
1113 | } | |
1110 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1114 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1111 | { |
|
1115 | { | |
1112 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1116 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1113 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1117 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1114 | { |
|
1118 | { | |
1115 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1119 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1116 | } |
|
1120 | } | |
1117 | else |
|
1121 | else | |
1118 | { |
|
1122 | { | |
1119 | status = RTEMS_SUCCESSFUL; |
|
1123 | status = RTEMS_SUCCESSFUL; | |
1120 | } |
|
1124 | } | |
1121 | } |
|
1125 | } | |
1122 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
1126 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
1123 | { |
|
1127 | { | |
1124 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
1128 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
1125 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1129 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1126 | { |
|
1130 | { | |
1127 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
1131 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
1128 | } |
|
1132 | } | |
1129 | else |
|
1133 | else | |
1130 | { |
|
1134 | { | |
1131 | status = RTEMS_SUCCESSFUL; |
|
1135 | status = RTEMS_SUCCESSFUL; | |
1132 | } |
|
1136 | } | |
1133 | } |
|
1137 | } | |
1134 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
1138 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
1135 | { |
|
1139 | { | |
1136 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
1140 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
1137 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1141 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1138 | { |
|
1142 | { | |
1139 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
1143 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
1140 | } |
|
1144 | } | |
1141 | else |
|
1145 | else | |
1142 | { |
|
1146 | { | |
1143 | status = RTEMS_SUCCESSFUL; |
|
1147 | status = RTEMS_SUCCESSFUL; | |
1144 | } |
|
1148 | } | |
1145 | } |
|
1149 | } | |
1146 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
1150 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
1147 | { |
|
1151 | { | |
1148 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
1152 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
1149 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1153 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1150 | { |
|
1154 | { | |
1151 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
1155 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
1152 | } |
|
1156 | } | |
1153 | else |
|
1157 | else | |
1154 | { |
|
1158 | { | |
1155 | status = RTEMS_SUCCESSFUL; |
|
1159 | status = RTEMS_SUCCESSFUL; | |
1156 | } |
|
1160 | } | |
1157 | } |
|
1161 | } | |
1158 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
1162 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
1159 | { |
|
1163 | { | |
1160 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
1164 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
1161 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1165 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1162 | { |
|
1166 | { | |
1163 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
1167 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
1164 | } |
|
1168 | } | |
1165 | else |
|
1169 | else | |
1166 | { |
|
1170 | { | |
1167 | status = RTEMS_SUCCESSFUL; |
|
1171 | status = RTEMS_SUCCESSFUL; | |
1168 | } |
|
1172 | } | |
1169 | } |
|
1173 | } | |
1170 |
|
1174 | |||
1171 | return status; |
|
1175 | return status; | |
1172 | } |
|
1176 | } | |
1173 |
|
1177 | |||
1174 | int suspend_asm_tasks( void ) |
|
1178 | int suspend_asm_tasks( void ) | |
1175 | { |
|
1179 | { | |
1176 | /** This function suspends the science tasks. |
|
1180 | /** This function suspends the science tasks. | |
1177 | * |
|
1181 | * | |
1178 | * @return RTEMS directive status codes: |
|
1182 | * @return RTEMS directive status codes: | |
1179 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1183 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1180 | * - RTEMS_INVALID_ID - task id invalid |
|
1184 | * - RTEMS_INVALID_ID - task id invalid | |
1181 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1185 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1182 | * |
|
1186 | * | |
1183 | */ |
|
1187 | */ | |
1184 |
|
1188 | |||
1185 | rtems_status_code status; |
|
1189 | rtems_status_code status; | |
1186 |
|
1190 | |||
1187 | PRINTF("in suspend_science_tasks\n") |
|
1191 | PRINTF("in suspend_science_tasks\n") | |
1188 |
|
1192 | |||
1189 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1193 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1190 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1194 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1191 | { |
|
1195 | { | |
1192 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1196 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1193 | } |
|
1197 | } | |
1194 | else |
|
1198 | else | |
1195 | { |
|
1199 | { | |
1196 | status = RTEMS_SUCCESSFUL; |
|
1200 | status = RTEMS_SUCCESSFUL; | |
1197 | } |
|
1201 | } | |
1198 |
|
1202 | |||
1199 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1203 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1200 | { |
|
1204 | { | |
1201 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1205 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1202 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1206 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1203 | { |
|
1207 | { | |
1204 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1208 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1205 | } |
|
1209 | } | |
1206 | else |
|
1210 | else | |
1207 | { |
|
1211 | { | |
1208 | status = RTEMS_SUCCESSFUL; |
|
1212 | status = RTEMS_SUCCESSFUL; | |
1209 | } |
|
1213 | } | |
1210 | } |
|
1214 | } | |
1211 |
|
1215 | |||
1212 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1216 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1213 | { |
|
1217 | { | |
1214 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1218 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1215 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1219 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1216 | { |
|
1220 | { | |
1217 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1221 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1218 | } |
|
1222 | } | |
1219 | else |
|
1223 | else | |
1220 | { |
|
1224 | { | |
1221 | status = RTEMS_SUCCESSFUL; |
|
1225 | status = RTEMS_SUCCESSFUL; | |
1222 | } |
|
1226 | } | |
1223 | } |
|
1227 | } | |
1224 |
|
1228 | |||
1225 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1229 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1226 | { |
|
1230 | { | |
1227 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1231 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1228 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1232 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1229 | { |
|
1233 | { | |
1230 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1234 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1231 | } |
|
1235 | } | |
1232 | else |
|
1236 | else | |
1233 | { |
|
1237 | { | |
1234 | status = RTEMS_SUCCESSFUL; |
|
1238 | status = RTEMS_SUCCESSFUL; | |
1235 | } |
|
1239 | } | |
1236 | } |
|
1240 | } | |
1237 |
|
1241 | |||
1238 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1242 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1239 | { |
|
1243 | { | |
1240 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1244 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1241 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1245 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1242 | { |
|
1246 | { | |
1243 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1247 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1244 | } |
|
1248 | } | |
1245 | else |
|
1249 | else | |
1246 | { |
|
1250 | { | |
1247 | status = RTEMS_SUCCESSFUL; |
|
1251 | status = RTEMS_SUCCESSFUL; | |
1248 | } |
|
1252 | } | |
1249 | } |
|
1253 | } | |
1250 |
|
1254 | |||
1251 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1255 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1252 | { |
|
1256 | { | |
1253 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1257 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1254 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1258 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1255 | { |
|
1259 | { | |
1256 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1260 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1257 | } |
|
1261 | } | |
1258 | else |
|
1262 | else | |
1259 | { |
|
1263 | { | |
1260 | status = RTEMS_SUCCESSFUL; |
|
1264 | status = RTEMS_SUCCESSFUL; | |
1261 | } |
|
1265 | } | |
1262 | } |
|
1266 | } | |
1263 |
|
1267 | |||
1264 | return status; |
|
1268 | return status; | |
1265 | } |
|
1269 | } | |
1266 |
|
1270 | |||
1267 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
1271 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
1268 | { |
|
1272 | { | |
1269 |
|
1273 | |||
1270 | WFP_reset_current_ring_nodes(); |
|
1274 | WFP_reset_current_ring_nodes(); | |
1271 |
|
1275 | |||
1272 | reset_waveform_picker_regs(); |
|
1276 | reset_waveform_picker_regs(); | |
1273 |
|
1277 | |||
1274 | set_wfp_burst_enable_register( mode ); |
|
1278 | set_wfp_burst_enable_register( mode ); | |
1275 |
|
1279 | |||
1276 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1280 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1277 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1281 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1278 |
|
1282 | |||
1279 | if (transitionCoarseTime == 0) |
|
1283 | if (transitionCoarseTime == 0) | |
1280 | { |
|
1284 | { | |
1281 | // instant transition means transition on the next valid date |
|
1285 | // instant transition means transition on the next valid date | |
1282 | // this is mandatory to have a good snapshot period and a good correction of the snapshot period |
|
1286 | // this is mandatory to have a good snapshot period and a good correction of the snapshot period | |
1283 | waveform_picker_regs->start_date = time_management_regs->coarse_time + 1; |
|
1287 | waveform_picker_regs->start_date = time_management_regs->coarse_time + 1; | |
1284 | } |
|
1288 | } | |
1285 | else |
|
1289 | else | |
1286 | { |
|
1290 | { | |
1287 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
1291 | waveform_picker_regs->start_date = transitionCoarseTime; | |
1288 | } |
|
1292 | } | |
1289 |
|
1293 | |||
1290 | update_last_valid_transition_date(waveform_picker_regs->start_date); |
|
1294 | update_last_valid_transition_date(waveform_picker_regs->start_date); | |
1291 |
|
1295 | |||
1292 | } |
|
1296 | } | |
1293 |
|
1297 | |||
1294 | void launch_spectral_matrix( void ) |
|
1298 | void launch_spectral_matrix( void ) | |
1295 | { |
|
1299 | { | |
1296 | SM_reset_current_ring_nodes(); |
|
1300 | SM_reset_current_ring_nodes(); | |
1297 |
|
1301 | |||
1298 | reset_spectral_matrix_regs(); |
|
1302 | reset_spectral_matrix_regs(); | |
1299 |
|
1303 | |||
1300 | reset_nb_sm(); |
|
1304 | reset_nb_sm(); | |
1301 |
|
1305 | |||
1302 | set_sm_irq_onNewMatrix( 1 ); |
|
1306 | set_sm_irq_onNewMatrix( 1 ); | |
1303 |
|
1307 | |||
1304 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1308 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1305 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1309 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1306 |
|
1310 | |||
1307 | } |
|
1311 | } | |
1308 |
|
1312 | |||
1309 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
1313 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
1310 | { |
|
1314 | { | |
1311 | if (value == 1) |
|
1315 | if (value == 1) | |
1312 | { |
|
1316 | { | |
1313 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
1317 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; | |
1314 | } |
|
1318 | } | |
1315 | else |
|
1319 | else | |
1316 | { |
|
1320 | { | |
1317 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
1321 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 | |
1318 | } |
|
1322 | } | |
1319 | } |
|
1323 | } | |
1320 |
|
1324 | |||
1321 | void set_sm_irq_onError( unsigned char value ) |
|
1325 | void set_sm_irq_onError( unsigned char value ) | |
1322 | { |
|
1326 | { | |
1323 | if (value == 1) |
|
1327 | if (value == 1) | |
1324 | { |
|
1328 | { | |
1325 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; |
|
1329 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; | |
1326 | } |
|
1330 | } | |
1327 | else |
|
1331 | else | |
1328 | { |
|
1332 | { | |
1329 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 |
|
1333 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 | |
1330 | } |
|
1334 | } | |
1331 | } |
|
1335 | } | |
1332 |
|
1336 | |||
1333 | //***************************** |
|
1337 | //***************************** | |
1334 | // CONFIGURE CALIBRATION SIGNAL |
|
1338 | // CONFIGURE CALIBRATION SIGNAL | |
1335 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
1339 | void setCalibrationPrescaler( unsigned int prescaler ) | |
1336 | { |
|
1340 | { | |
1337 | // prescaling of the master clock (25 MHz) |
|
1341 | // prescaling of the master clock (25 MHz) | |
1338 | // master clock is divided by 2^prescaler |
|
1342 | // master clock is divided by 2^prescaler | |
1339 | time_management_regs->calPrescaler = prescaler; |
|
1343 | time_management_regs->calPrescaler = prescaler; | |
1340 | } |
|
1344 | } | |
1341 |
|
1345 | |||
1342 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
1346 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
1343 | { |
|
1347 | { | |
1344 | // division of the prescaled clock by the division factor |
|
1348 | // division of the prescaled clock by the division factor | |
1345 | time_management_regs->calDivisor = divisionFactor; |
|
1349 | time_management_regs->calDivisor = divisionFactor; | |
1346 | } |
|
1350 | } | |
1347 |
|
1351 | |||
1348 | void setCalibrationData( void ){ |
|
1352 | void setCalibrationData( void ){ | |
1349 | unsigned int k; |
|
1353 | unsigned int k; | |
1350 | unsigned short data; |
|
1354 | unsigned short data; | |
1351 | float val; |
|
1355 | float val; | |
1352 | float f0; |
|
1356 | float f0; | |
1353 | float f1; |
|
1357 | float f1; | |
1354 | float fs; |
|
1358 | float fs; | |
1355 | float Ts; |
|
1359 | float Ts; | |
1356 | float scaleFactor; |
|
1360 | float scaleFactor; | |
1357 |
|
1361 | |||
1358 | f0 = 625; |
|
1362 | f0 = 625; | |
1359 | f1 = 10000; |
|
1363 | f1 = 10000; | |
1360 | fs = 160256.410; |
|
1364 | fs = 160256.410; | |
1361 | Ts = 1. / fs; |
|
1365 | Ts = 1. / fs; | |
1362 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV |
|
1366 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
1363 |
|
1367 | |||
1364 | time_management_regs->calDataPtr = 0x00; |
|
1368 | time_management_regs->calDataPtr = 0x00; | |
1365 |
|
1369 | |||
1366 | // build the signal for the SCM calibration |
|
1370 | // build the signal for the SCM calibration | |
1367 | for (k=0; k<256; k++) |
|
1371 | for (k=0; k<256; k++) | |
1368 | { |
|
1372 | { | |
1369 | val = sin( 2 * pi * f0 * k * Ts ) |
|
1373 | val = sin( 2 * pi * f0 * k * Ts ) | |
1370 | + sin( 2 * pi * f1 * k * Ts ); |
|
1374 | + sin( 2 * pi * f1 * k * Ts ); | |
1371 | data = (unsigned short) ((val * scaleFactor) + 2048); |
|
1375 | data = (unsigned short) ((val * scaleFactor) + 2048); | |
1372 | time_management_regs->calData = data & 0xfff; |
|
1376 | time_management_regs->calData = data & 0xfff; | |
1373 | } |
|
1377 | } | |
1374 | } |
|
1378 | } | |
1375 |
|
1379 | |||
1376 | void setCalibrationDataInterleaved( void ){ |
|
1380 | void setCalibrationDataInterleaved( void ){ | |
1377 | unsigned int k; |
|
1381 | unsigned int k; | |
1378 | float val; |
|
1382 | float val; | |
1379 | float f0; |
|
1383 | float f0; | |
1380 | float f1; |
|
1384 | float f1; | |
1381 | float fs; |
|
1385 | float fs; | |
1382 | float Ts; |
|
1386 | float Ts; | |
1383 | unsigned short data[384]; |
|
1387 | unsigned short data[384]; | |
1384 | unsigned char *dataPtr; |
|
1388 | unsigned char *dataPtr; | |
1385 |
|
1389 | |||
1386 | f0 = 625; |
|
1390 | f0 = 625; | |
1387 | f1 = 10000; |
|
1391 | f1 = 10000; | |
1388 | fs = 240384.615; |
|
1392 | fs = 240384.615; | |
1389 | Ts = 1. / fs; |
|
1393 | Ts = 1. / fs; | |
1390 |
|
1394 | |||
1391 | time_management_regs->calDataPtr = 0x00; |
|
1395 | time_management_regs->calDataPtr = 0x00; | |
1392 |
|
1396 | |||
1393 | // build the signal for the SCM calibration |
|
1397 | // build the signal for the SCM calibration | |
1394 | for (k=0; k<384; k++) |
|
1398 | for (k=0; k<384; k++) | |
1395 | { |
|
1399 | { | |
1396 | val = sin( 2 * pi * f0 * k * Ts ) |
|
1400 | val = sin( 2 * pi * f0 * k * Ts ) | |
1397 | + sin( 2 * pi * f1 * k * Ts ); |
|
1401 | + sin( 2 * pi * f1 * k * Ts ); | |
1398 | data[k] = (unsigned short) (val * 512 + 2048); |
|
1402 | data[k] = (unsigned short) (val * 512 + 2048); | |
1399 | } |
|
1403 | } | |
1400 |
|
1404 | |||
1401 | // write the signal in interleaved mode |
|
1405 | // write the signal in interleaved mode | |
1402 | for (k=0; k<128; k++) |
|
1406 | for (k=0; k<128; k++) | |
1403 | { |
|
1407 | { | |
1404 | dataPtr = (unsigned char*) &data[k*3 + 2]; |
|
1408 | dataPtr = (unsigned char*) &data[k*3 + 2]; | |
1405 | time_management_regs->calData = (data[k*3] & 0xfff) |
|
1409 | time_management_regs->calData = (data[k*3] & 0xfff) | |
1406 | + ( (dataPtr[0] & 0x3f) << 12); |
|
1410 | + ( (dataPtr[0] & 0x3f) << 12); | |
1407 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) |
|
1411 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) | |
1408 | + ( (dataPtr[1] & 0x3f) << 12); |
|
1412 | + ( (dataPtr[1] & 0x3f) << 12); | |
1409 | } |
|
1413 | } | |
1410 | } |
|
1414 | } | |
1411 |
|
1415 | |||
1412 | void setCalibrationReload( bool state) |
|
1416 | void setCalibrationReload( bool state) | |
1413 | { |
|
1417 | { | |
1414 | if (state == true) |
|
1418 | if (state == true) | |
1415 | { |
|
1419 | { | |
1416 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] |
|
1420 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] | |
1417 | } |
|
1421 | } | |
1418 | else |
|
1422 | else | |
1419 | { |
|
1423 | { | |
1420 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] |
|
1424 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] | |
1421 | } |
|
1425 | } | |
1422 | } |
|
1426 | } | |
1423 |
|
1427 | |||
1424 | void setCalibrationEnable( bool state ) |
|
1428 | void setCalibrationEnable( bool state ) | |
1425 | { |
|
1429 | { | |
1426 | // this bit drives the multiplexer |
|
1430 | // this bit drives the multiplexer | |
1427 | if (state == true) |
|
1431 | if (state == true) | |
1428 | { |
|
1432 | { | |
1429 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] |
|
1433 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] | |
1430 | } |
|
1434 | } | |
1431 | else |
|
1435 | else | |
1432 | { |
|
1436 | { | |
1433 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] |
|
1437 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] | |
1434 | } |
|
1438 | } | |
1435 | } |
|
1439 | } | |
1436 |
|
1440 | |||
1437 | void setCalibrationInterleaved( bool state ) |
|
1441 | void setCalibrationInterleaved( bool state ) | |
1438 | { |
|
1442 | { | |
1439 | // this bit drives the multiplexer |
|
1443 | // this bit drives the multiplexer | |
1440 | if (state == true) |
|
1444 | if (state == true) | |
1441 | { |
|
1445 | { | |
1442 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] |
|
1446 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] | |
1443 | } |
|
1447 | } | |
1444 | else |
|
1448 | else | |
1445 | { |
|
1449 | { | |
1446 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] |
|
1450 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] | |
1447 | } |
|
1451 | } | |
1448 | } |
|
1452 | } | |
1449 |
|
1453 | |||
1450 | void setCalibration( bool state ) |
|
1454 | void setCalibration( bool state ) | |
1451 | { |
|
1455 | { | |
1452 | if (state == true) |
|
1456 | if (state == true) | |
1453 | { |
|
1457 | { | |
1454 | setCalibrationEnable( true ); |
|
1458 | setCalibrationEnable( true ); | |
1455 | setCalibrationReload( false ); |
|
1459 | setCalibrationReload( false ); | |
1456 | set_hk_lfr_calib_enable( true ); |
|
1460 | set_hk_lfr_calib_enable( true ); | |
1457 | } |
|
1461 | } | |
1458 | else |
|
1462 | else | |
1459 | { |
|
1463 | { | |
1460 | setCalibrationEnable( false ); |
|
1464 | setCalibrationEnable( false ); | |
1461 | setCalibrationReload( true ); |
|
1465 | setCalibrationReload( true ); | |
1462 | set_hk_lfr_calib_enable( false ); |
|
1466 | set_hk_lfr_calib_enable( false ); | |
1463 | } |
|
1467 | } | |
1464 | } |
|
1468 | } | |
1465 |
|
1469 | |||
1466 | void configureCalibration( bool interleaved ) |
|
1470 | void configureCalibration( bool interleaved ) | |
1467 | { |
|
1471 | { | |
1468 | setCalibration( false ); |
|
1472 | setCalibration( false ); | |
1469 | if ( interleaved == true ) |
|
1473 | if ( interleaved == true ) | |
1470 | { |
|
1474 | { | |
1471 | setCalibrationInterleaved( true ); |
|
1475 | setCalibrationInterleaved( true ); | |
1472 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1476 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1473 | setCalibrationDivisor( 26 ); // => 240 384 |
|
1477 | setCalibrationDivisor( 26 ); // => 240 384 | |
1474 | setCalibrationDataInterleaved(); |
|
1478 | setCalibrationDataInterleaved(); | |
1475 | } |
|
1479 | } | |
1476 | else |
|
1480 | else | |
1477 | { |
|
1481 | { | |
1478 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1482 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1479 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) |
|
1483 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) | |
1480 | setCalibrationData(); |
|
1484 | setCalibrationData(); | |
1481 | } |
|
1485 | } | |
1482 | } |
|
1486 | } | |
1483 |
|
1487 | |||
1484 | //**************** |
|
1488 | //**************** | |
1485 | // CLOSING ACTIONS |
|
1489 | // CLOSING ACTIONS | |
1486 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1490 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1487 | { |
|
1491 | { | |
1488 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1492 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1489 | * |
|
1493 | * | |
1490 | * @param TC points to the TC being processed |
|
1494 | * @param TC points to the TC being processed | |
1491 | * @param time is the time used to date the TC execution |
|
1495 | * @param time is the time used to date the TC execution | |
1492 | * |
|
1496 | * | |
1493 | */ |
|
1497 | */ | |
1494 |
|
1498 | |||
1495 | unsigned int val; |
|
1499 | unsigned int val; | |
1496 |
|
1500 | |||
1497 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1501 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1498 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1502 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1499 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1503 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
1500 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1504 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1501 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1505 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
1502 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1506 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1503 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
1507 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; | |
1504 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
1508 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; | |
1505 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
1509 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; | |
1506 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
1510 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; | |
1507 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
1511 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; | |
1508 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
1512 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; | |
1509 |
|
1513 | |||
1510 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1514 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1511 | val++; |
|
1515 | val++; | |
1512 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1516 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
1513 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1517 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1514 | } |
|
1518 | } | |
1515 |
|
1519 | |||
1516 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1520 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1517 | { |
|
1521 | { | |
1518 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1522 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1519 | * |
|
1523 | * | |
1520 | * @param TC points to the TC being processed |
|
1524 | * @param TC points to the TC being processed | |
1521 | * @param time is the time used to date the TC rejection |
|
1525 | * @param time is the time used to date the TC rejection | |
1522 | * |
|
1526 | * | |
1523 | */ |
|
1527 | */ | |
1524 |
|
1528 | |||
1525 | unsigned int val; |
|
1529 | unsigned int val; | |
1526 |
|
1530 | |||
1527 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1531 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1528 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1532 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1529 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1533 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
1530 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1534 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1531 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1535 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
1532 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1536 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1533 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
1537 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; | |
1534 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
1538 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; | |
1535 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
1539 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; | |
1536 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
1540 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; | |
1537 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
1541 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; | |
1538 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
1542 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; | |
1539 |
|
1543 | |||
1540 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1544 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1541 | val++; |
|
1545 | val++; | |
1542 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1546 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
1543 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1547 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1544 | } |
|
1548 | } | |
1545 |
|
1549 | |||
1546 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1550 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1547 | { |
|
1551 | { | |
1548 | /** This function is the last step of the TC execution workflow. |
|
1552 | /** This function is the last step of the TC execution workflow. | |
1549 | * |
|
1553 | * | |
1550 | * @param TC points to the TC being processed |
|
1554 | * @param TC points to the TC being processed | |
1551 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1555 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1552 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1556 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1553 | * @param time is the time used to date the TC execution |
|
1557 | * @param time is the time used to date the TC execution | |
1554 | * |
|
1558 | * | |
1555 | */ |
|
1559 | */ | |
1556 |
|
1560 | |||
1557 | unsigned char requestedMode; |
|
1561 | unsigned char requestedMode; | |
1558 |
|
1562 | |||
1559 | if (result == LFR_SUCCESSFUL) |
|
1563 | if (result == LFR_SUCCESSFUL) | |
1560 | { |
|
1564 | { | |
1561 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1565 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1562 | & |
|
1566 | & | |
1563 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1567 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1564 | ) |
|
1568 | ) | |
1565 | { |
|
1569 | { | |
1566 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1570 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1567 | } |
|
1571 | } | |
1568 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1572 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1569 | { |
|
1573 | { | |
1570 | //********************************** |
|
1574 | //********************************** | |
1571 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1575 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1572 | requestedMode = TC->dataAndCRC[1]; |
|
1576 | requestedMode = TC->dataAndCRC[1]; | |
1573 | updateLFRCurrentMode( requestedMode ); |
|
1577 | updateLFRCurrentMode( requestedMode ); | |
1574 | } |
|
1578 | } | |
1575 | } |
|
1579 | } | |
1576 | else if (result == LFR_EXE_ERROR) |
|
1580 | else if (result == LFR_EXE_ERROR) | |
1577 | { |
|
1581 | { | |
1578 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1582 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1579 | } |
|
1583 | } | |
1580 | } |
|
1584 | } | |
1581 |
|
1585 | |||
1582 | //*************************** |
|
1586 | //*************************** | |
1583 | // Interrupt Service Routines |
|
1587 | // Interrupt Service Routines | |
1584 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1588 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1585 | { |
|
1589 | { | |
1586 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1590 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1587 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") |
|
1591 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") | |
1588 | } |
|
1592 | } | |
1589 | } |
|
1593 | } | |
1590 |
|
1594 | |||
1591 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1595 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1592 | { |
|
1596 | { | |
1593 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1597 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1594 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") |
|
1598 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") | |
1595 | } |
|
1599 | } | |
1596 | } |
|
1600 | } | |
1597 |
|
1601 | |||
1598 | //**************** |
|
1602 | //**************** | |
1599 | // OTHER FUNCTIONS |
|
1603 | // OTHER FUNCTIONS | |
1600 | void updateLFRCurrentMode( unsigned char requestedMode ) |
|
1604 | void updateLFRCurrentMode( unsigned char requestedMode ) | |
1601 | { |
|
1605 | { | |
1602 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1606 | /** This function updates the value of the global variable lfrCurrentMode. | |
1603 | * |
|
1607 | * | |
1604 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1608 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1605 | * |
|
1609 | * | |
1606 | */ |
|
1610 | */ | |
1607 |
|
1611 | |||
1608 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1612 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1609 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
1613 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); | |
1610 | lfrCurrentMode = requestedMode; |
|
1614 | lfrCurrentMode = requestedMode; | |
1611 | } |
|
1615 | } | |
1612 |
|
1616 | |||
1613 | void set_lfr_soft_reset( unsigned char value ) |
|
1617 | void set_lfr_soft_reset( unsigned char value ) | |
1614 | { |
|
1618 | { | |
1615 | if (value == 1) |
|
1619 | if (value == 1) | |
1616 | { |
|
1620 | { | |
1617 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] |
|
1621 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] | |
1618 | } |
|
1622 | } | |
1619 | else |
|
1623 | else | |
1620 | { |
|
1624 | { | |
1621 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] |
|
1625 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] | |
1622 | } |
|
1626 | } | |
1623 | } |
|
1627 | } | |
1624 |
|
1628 | |||
1625 | void reset_lfr( void ) |
|
1629 | void reset_lfr( void ) | |
1626 | { |
|
1630 | { | |
1627 | set_lfr_soft_reset( 1 ); |
|
1631 | set_lfr_soft_reset( 1 ); | |
1628 |
|
1632 | |||
1629 | set_lfr_soft_reset( 0 ); |
|
1633 | set_lfr_soft_reset( 0 ); | |
1630 |
|
1634 | |||
1631 | set_hk_lfr_sc_potential_flag( true ); |
|
1635 | set_hk_lfr_sc_potential_flag( true ); | |
1632 | } |
|
1636 | } |
@@ -1,1201 +1,1280 | |||||
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_pas_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |||
|
314 | { | |||
|
315 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |||
|
316 | * | |||
|
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 | |||
|
319 | * | |||
|
320 | */ | |||
|
321 | ||||
|
322 | int flag; | |||
|
323 | ||||
|
324 | flag = LFR_DEFAULT; | |||
|
325 | ||||
|
326 | flag = check_sy_lfr_pas_filter_parameters( TC, queue_id ); | |||
|
327 | ||||
|
328 | if (flag == LFR_SUCCESSFUL) | |||
|
329 | { | |||
|
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 ]; | |||
|
332 | parameter_dump_packet.sy_lfr_pas_filter_nstd = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_NSTD ]; | |||
|
333 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |||
|
334 | } | |||
|
335 | ||||
|
336 | return flag; | |||
|
337 | } | |||
|
338 | ||||
313 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
339 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
314 | { |
|
340 | { | |
315 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
341 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
316 | * |
|
342 | * | |
317 | * @param TC points to the TeleCommand packet that is being processed |
|
343 | * @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 |
|
344 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
319 | * |
|
345 | * | |
320 | */ |
|
346 | */ | |
321 |
|
347 | |||
322 | unsigned int address; |
|
348 | unsigned int address; | |
323 | rtems_status_code status; |
|
349 | rtems_status_code status; | |
324 | unsigned int freq; |
|
350 | unsigned int freq; | |
325 | unsigned int bin; |
|
351 | unsigned int bin; | |
326 | unsigned int coeff; |
|
352 | unsigned int coeff; | |
327 | unsigned char *kCoeffPtr; |
|
353 | unsigned char *kCoeffPtr; | |
328 | unsigned char *kCoeffDumpPtr; |
|
354 | unsigned char *kCoeffDumpPtr; | |
329 |
|
355 | |||
330 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
356 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff | |
331 | // F0 => 11 bins |
|
357 | // F0 => 11 bins | |
332 | // F1 => 13 bins |
|
358 | // F1 => 13 bins | |
333 | // F2 => 12 bins |
|
359 | // F2 => 12 bins | |
334 | // 36 bins to dump in two packets (30 bins max per packet) |
|
360 | // 36 bins to dump in two packets (30 bins max per packet) | |
335 |
|
361 | |||
336 | //********* |
|
362 | //********* | |
337 | // PACKET 1 |
|
363 | // PACKET 1 | |
338 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
364 | // 11 F0 bins, 13 F1 bins and 6 F2 bins | |
339 | kcoefficients_dump_1.destinationID = TC->sourceID; |
|
365 | kcoefficients_dump_1.destinationID = TC->sourceID; | |
340 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); |
|
366 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); | |
341 | for( freq=0; |
|
367 | for( freq=0; | |
342 | freq<NB_BINS_COMPRESSED_SM_F0; |
|
368 | freq<NB_BINS_COMPRESSED_SM_F0; | |
343 | freq++ ) |
|
369 | freq++ ) | |
344 | { |
|
370 | { | |
345 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; |
|
371 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; | |
346 | bin = freq; |
|
372 | bin = freq; | |
347 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
373 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); | |
348 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
374 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
349 | { |
|
375 | { | |
350 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
376 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
351 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
377 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
352 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
378 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
353 | } |
|
379 | } | |
354 | } |
|
380 | } | |
355 | for( freq=NB_BINS_COMPRESSED_SM_F0; |
|
381 | for( freq=NB_BINS_COMPRESSED_SM_F0; | |
356 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
382 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
357 | freq++ ) |
|
383 | freq++ ) | |
358 | { |
|
384 | { | |
359 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
385 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
360 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
386 | bin = freq - NB_BINS_COMPRESSED_SM_F0; | |
361 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
387 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); | |
362 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
388 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
363 | { |
|
389 | { | |
364 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
390 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
365 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
391 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
366 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
392 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
367 | } |
|
393 | } | |
368 | } |
|
394 | } | |
369 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
395 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
370 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); |
|
396 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); | |
371 | freq++ ) |
|
397 | freq++ ) | |
372 | { |
|
398 | { | |
373 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
399 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
374 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
400 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
375 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
401 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
376 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
402 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
377 | { |
|
403 | { | |
378 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
404 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
379 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
405 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
380 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
406 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
381 | } |
|
407 | } | |
382 | } |
|
408 | } | |
383 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
409 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
384 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
410 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
385 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
411 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
386 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
412 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
387 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
413 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
388 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
414 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); | |
389 | // SEND DATA |
|
415 | // SEND DATA | |
390 | kcoefficient_node_1.status = 1; |
|
416 | kcoefficient_node_1.status = 1; | |
391 | address = (unsigned int) &kcoefficient_node_1; |
|
417 | address = (unsigned int) &kcoefficient_node_1; | |
392 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
418 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
393 | if (status != RTEMS_SUCCESSFUL) { |
|
419 | if (status != RTEMS_SUCCESSFUL) { | |
394 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
420 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) | |
395 | } |
|
421 | } | |
396 |
|
422 | |||
397 | //******** |
|
423 | //******** | |
398 | // PACKET 2 |
|
424 | // PACKET 2 | |
399 | // 6 F2 bins |
|
425 | // 6 F2 bins | |
400 | kcoefficients_dump_2.destinationID = TC->sourceID; |
|
426 | kcoefficients_dump_2.destinationID = TC->sourceID; | |
401 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); |
|
427 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); | |
402 | for( freq=0; freq<6; freq++ ) |
|
428 | for( freq=0; freq<6; freq++ ) | |
403 | { |
|
429 | { | |
404 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; |
|
430 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; | |
405 | bin = freq + 6; |
|
431 | bin = freq + 6; | |
406 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
432 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
407 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
433 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
408 | { |
|
434 | { | |
409 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
435 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
410 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
436 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
411 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
437 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
412 | } |
|
438 | } | |
413 | } |
|
439 | } | |
414 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
440 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
415 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
441 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
416 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
442 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
417 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
443 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
418 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
444 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
419 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
445 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); | |
420 | // SEND DATA |
|
446 | // SEND DATA | |
421 | kcoefficient_node_2.status = 1; |
|
447 | kcoefficient_node_2.status = 1; | |
422 | address = (unsigned int) &kcoefficient_node_2; |
|
448 | address = (unsigned int) &kcoefficient_node_2; | |
423 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
449 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
424 | if (status != RTEMS_SUCCESSFUL) { |
|
450 | if (status != RTEMS_SUCCESSFUL) { | |
425 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
451 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) | |
426 | } |
|
452 | } | |
427 |
|
453 | |||
428 | return status; |
|
454 | return status; | |
429 | } |
|
455 | } | |
430 |
|
456 | |||
431 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
457 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
432 | { |
|
458 | { | |
433 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
459 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
434 | * |
|
460 | * | |
435 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
461 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
436 | * |
|
462 | * | |
437 | * @return RTEMS directive status codes: |
|
463 | * @return RTEMS directive status codes: | |
438 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
464 | * - RTEMS_SUCCESSFUL - message sent successfully | |
439 | * - RTEMS_INVALID_ID - invalid queue id |
|
465 | * - RTEMS_INVALID_ID - invalid queue id | |
440 | * - RTEMS_INVALID_SIZE - invalid message size |
|
466 | * - RTEMS_INVALID_SIZE - invalid message size | |
441 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
467 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
442 | * - RTEMS_UNSATISFIED - out of message buffers |
|
468 | * - RTEMS_UNSATISFIED - out of message buffers | |
443 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
469 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
444 | * |
|
470 | * | |
445 | */ |
|
471 | */ | |
446 |
|
472 | |||
447 | int status; |
|
473 | int status; | |
448 |
|
474 | |||
449 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); |
|
475 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); | |
450 | parameter_dump_packet.destinationID = TC->sourceID; |
|
476 | parameter_dump_packet.destinationID = TC->sourceID; | |
451 |
|
477 | |||
452 | // UPDATE TIME |
|
478 | // UPDATE TIME | |
453 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
479 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
454 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
480 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
455 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
481 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
456 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
482 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
457 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
483 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
458 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
484 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
459 | // SEND DATA |
|
485 | // SEND DATA | |
460 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
486 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
461 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
487 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
462 | if (status != RTEMS_SUCCESSFUL) { |
|
488 | if (status != RTEMS_SUCCESSFUL) { | |
463 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
489 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
464 | } |
|
490 | } | |
465 |
|
491 | |||
466 | return status; |
|
492 | return status; | |
467 | } |
|
493 | } | |
468 |
|
494 | |||
469 | //*********************** |
|
495 | //*********************** | |
470 | // NORMAL MODE PARAMETERS |
|
496 | // NORMAL MODE PARAMETERS | |
471 |
|
497 | |||
472 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
498 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
473 | { |
|
499 | { | |
474 | unsigned char msb; |
|
500 | unsigned char msb; | |
475 | unsigned char lsb; |
|
501 | unsigned char lsb; | |
476 | int flag; |
|
502 | int flag; | |
477 | float aux; |
|
503 | float aux; | |
478 | rtems_status_code status; |
|
504 | rtems_status_code status; | |
479 |
|
505 | |||
480 | unsigned int sy_lfr_n_swf_l; |
|
506 | unsigned int sy_lfr_n_swf_l; | |
481 | unsigned int sy_lfr_n_swf_p; |
|
507 | unsigned int sy_lfr_n_swf_p; | |
482 | unsigned int sy_lfr_n_asm_p; |
|
508 | unsigned int sy_lfr_n_asm_p; | |
483 | unsigned char sy_lfr_n_bp_p0; |
|
509 | unsigned char sy_lfr_n_bp_p0; | |
484 | unsigned char sy_lfr_n_bp_p1; |
|
510 | unsigned char sy_lfr_n_bp_p1; | |
485 | unsigned char sy_lfr_n_cwf_long_f3; |
|
511 | unsigned char sy_lfr_n_cwf_long_f3; | |
486 |
|
512 | |||
487 | flag = LFR_SUCCESSFUL; |
|
513 | flag = LFR_SUCCESSFUL; | |
488 |
|
514 | |||
489 | //*************** |
|
515 | //*************** | |
490 | // get parameters |
|
516 | // get parameters | |
491 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
517 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
492 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
518 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
493 | sy_lfr_n_swf_l = msb * 256 + lsb; |
|
519 | sy_lfr_n_swf_l = msb * 256 + lsb; | |
494 |
|
520 | |||
495 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
521 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
496 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
522 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
497 | sy_lfr_n_swf_p = msb * 256 + lsb; |
|
523 | sy_lfr_n_swf_p = msb * 256 + lsb; | |
498 |
|
524 | |||
499 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
525 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
500 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
526 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
501 | sy_lfr_n_asm_p = msb * 256 + lsb; |
|
527 | sy_lfr_n_asm_p = msb * 256 + lsb; | |
502 |
|
528 | |||
503 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
529 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
504 |
|
530 | |||
505 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
531 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
506 |
|
532 | |||
507 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
533 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
508 |
|
534 | |||
509 | //****************** |
|
535 | //****************** | |
510 | // check consistency |
|
536 | // check consistency | |
511 | // sy_lfr_n_swf_l |
|
537 | // sy_lfr_n_swf_l | |
512 | if (sy_lfr_n_swf_l != 2048) |
|
538 | if (sy_lfr_n_swf_l != 2048) | |
513 | { |
|
539 | { | |
514 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); |
|
540 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); | |
515 | flag = WRONG_APP_DATA; |
|
541 | flag = WRONG_APP_DATA; | |
516 | } |
|
542 | } | |
517 | // sy_lfr_n_swf_p |
|
543 | // sy_lfr_n_swf_p | |
518 | if (flag == LFR_SUCCESSFUL) |
|
544 | if (flag == LFR_SUCCESSFUL) | |
519 | { |
|
545 | { | |
520 | if ( sy_lfr_n_swf_p < 22 ) |
|
546 | if ( sy_lfr_n_swf_p < 22 ) | |
521 | { |
|
547 | { | |
522 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); |
|
548 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); | |
523 | flag = WRONG_APP_DATA; |
|
549 | flag = WRONG_APP_DATA; | |
524 | } |
|
550 | } | |
525 | } |
|
551 | } | |
526 | // sy_lfr_n_bp_p0 |
|
552 | // sy_lfr_n_bp_p0 | |
527 | if (flag == LFR_SUCCESSFUL) |
|
553 | if (flag == LFR_SUCCESSFUL) | |
528 | { |
|
554 | { | |
529 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
555 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) | |
530 | { |
|
556 | { | |
531 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
557 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); | |
532 | flag = WRONG_APP_DATA; |
|
558 | flag = WRONG_APP_DATA; | |
533 | } |
|
559 | } | |
534 | } |
|
560 | } | |
535 | // sy_lfr_n_asm_p |
|
561 | // sy_lfr_n_asm_p | |
536 | if (flag == LFR_SUCCESSFUL) |
|
562 | if (flag == LFR_SUCCESSFUL) | |
537 | { |
|
563 | { | |
538 | if (sy_lfr_n_asm_p == 0) |
|
564 | if (sy_lfr_n_asm_p == 0) | |
539 | { |
|
565 | { | |
540 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
566 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
541 | flag = WRONG_APP_DATA; |
|
567 | flag = WRONG_APP_DATA; | |
542 | } |
|
568 | } | |
543 | } |
|
569 | } | |
544 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
570 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 | |
545 | if (flag == LFR_SUCCESSFUL) |
|
571 | if (flag == LFR_SUCCESSFUL) | |
546 | { |
|
572 | { | |
547 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
573 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); | |
548 | if (aux > FLOAT_EQUAL_ZERO) |
|
574 | if (aux > FLOAT_EQUAL_ZERO) | |
549 | { |
|
575 | { | |
550 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
576 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
551 | flag = WRONG_APP_DATA; |
|
577 | flag = WRONG_APP_DATA; | |
552 | } |
|
578 | } | |
553 | } |
|
579 | } | |
554 | // sy_lfr_n_bp_p1 |
|
580 | // sy_lfr_n_bp_p1 | |
555 | if (flag == LFR_SUCCESSFUL) |
|
581 | if (flag == LFR_SUCCESSFUL) | |
556 | { |
|
582 | { | |
557 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
583 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) | |
558 | { |
|
584 | { | |
559 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
585 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
560 | flag = WRONG_APP_DATA; |
|
586 | flag = WRONG_APP_DATA; | |
561 | } |
|
587 | } | |
562 | } |
|
588 | } | |
563 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
589 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 | |
564 | if (flag == LFR_SUCCESSFUL) |
|
590 | if (flag == LFR_SUCCESSFUL) | |
565 | { |
|
591 | { | |
566 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
592 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); | |
567 | if (aux > FLOAT_EQUAL_ZERO) |
|
593 | if (aux > FLOAT_EQUAL_ZERO) | |
568 | { |
|
594 | { | |
569 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
595 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
570 | flag = LFR_DEFAULT; |
|
596 | flag = LFR_DEFAULT; | |
571 | } |
|
597 | } | |
572 | } |
|
598 | } | |
573 | // sy_lfr_n_cwf_long_f3 |
|
599 | // sy_lfr_n_cwf_long_f3 | |
574 |
|
600 | |||
575 | return flag; |
|
601 | return flag; | |
576 | } |
|
602 | } | |
577 |
|
603 | |||
578 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
604 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) | |
579 | { |
|
605 | { | |
580 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
606 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
581 | * |
|
607 | * | |
582 | * @param TC points to the TeleCommand packet that is being processed |
|
608 | * @param TC points to the TeleCommand packet that is being processed | |
583 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
609 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
584 | * |
|
610 | * | |
585 | */ |
|
611 | */ | |
586 |
|
612 | |||
587 | int result; |
|
613 | int result; | |
588 |
|
614 | |||
589 | result = LFR_SUCCESSFUL; |
|
615 | result = LFR_SUCCESSFUL; | |
590 |
|
616 | |||
591 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
617 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
592 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
618 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
593 |
|
619 | |||
594 | return result; |
|
620 | return result; | |
595 | } |
|
621 | } | |
596 |
|
622 | |||
597 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
623 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) | |
598 | { |
|
624 | { | |
599 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
625 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
600 | * |
|
626 | * | |
601 | * @param TC points to the TeleCommand packet that is being processed |
|
627 | * @param TC points to the TeleCommand packet that is being processed | |
602 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
628 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
603 | * |
|
629 | * | |
604 | */ |
|
630 | */ | |
605 |
|
631 | |||
606 | int result; |
|
632 | int result; | |
607 |
|
633 | |||
608 | result = LFR_SUCCESSFUL; |
|
634 | result = LFR_SUCCESSFUL; | |
609 |
|
635 | |||
610 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
636 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
611 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
637 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
612 |
|
638 | |||
613 | return result; |
|
639 | return result; | |
614 | } |
|
640 | } | |
615 |
|
641 | |||
616 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
642 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) | |
617 | { |
|
643 | { | |
618 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
644 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). | |
619 | * |
|
645 | * | |
620 | * @param TC points to the TeleCommand packet that is being processed |
|
646 | * @param TC points to the TeleCommand packet that is being processed | |
621 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
647 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
622 | * |
|
648 | * | |
623 | */ |
|
649 | */ | |
624 |
|
650 | |||
625 | int result; |
|
651 | int result; | |
626 |
|
652 | |||
627 | result = LFR_SUCCESSFUL; |
|
653 | result = LFR_SUCCESSFUL; | |
628 |
|
654 | |||
629 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
655 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
630 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
656 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
631 |
|
657 | |||
632 | return result; |
|
658 | return result; | |
633 | } |
|
659 | } | |
634 |
|
660 | |||
635 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
661 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
636 | { |
|
662 | { | |
637 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
663 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). | |
638 | * |
|
664 | * | |
639 | * @param TC points to the TeleCommand packet that is being processed |
|
665 | * @param TC points to the TeleCommand packet that is being processed | |
640 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
666 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
641 | * |
|
667 | * | |
642 | */ |
|
668 | */ | |
643 |
|
669 | |||
644 | int status; |
|
670 | int status; | |
645 |
|
671 | |||
646 | status = LFR_SUCCESSFUL; |
|
672 | status = LFR_SUCCESSFUL; | |
647 |
|
673 | |||
648 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
674 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
649 |
|
675 | |||
650 | return status; |
|
676 | return status; | |
651 | } |
|
677 | } | |
652 |
|
678 | |||
653 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
679 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) | |
654 | { |
|
680 | { | |
655 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
681 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
656 | * |
|
682 | * | |
657 | * @param TC points to the TeleCommand packet that is being processed |
|
683 | * @param TC points to the TeleCommand packet that is being processed | |
658 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
684 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
659 | * |
|
685 | * | |
660 | */ |
|
686 | */ | |
661 |
|
687 | |||
662 | int status; |
|
688 | int status; | |
663 |
|
689 | |||
664 | status = LFR_SUCCESSFUL; |
|
690 | status = LFR_SUCCESSFUL; | |
665 |
|
691 | |||
666 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
692 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
667 |
|
693 | |||
668 | return status; |
|
694 | return status; | |
669 | } |
|
695 | } | |
670 |
|
696 | |||
671 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
697 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) | |
672 | { |
|
698 | { | |
673 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
699 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. | |
674 | * |
|
700 | * | |
675 | * @param TC points to the TeleCommand packet that is being processed |
|
701 | * @param TC points to the TeleCommand packet that is being processed | |
676 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
702 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
677 | * |
|
703 | * | |
678 | */ |
|
704 | */ | |
679 |
|
705 | |||
680 | int status; |
|
706 | int status; | |
681 |
|
707 | |||
682 | status = LFR_SUCCESSFUL; |
|
708 | status = LFR_SUCCESSFUL; | |
683 |
|
709 | |||
684 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
710 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
685 |
|
711 | |||
686 | return status; |
|
712 | return status; | |
687 | } |
|
713 | } | |
688 |
|
714 | |||
689 | //********************** |
|
715 | //********************** | |
690 | // BURST MODE PARAMETERS |
|
716 | // BURST MODE PARAMETERS | |
691 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
717 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) | |
692 | { |
|
718 | { | |
693 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
719 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). | |
694 | * |
|
720 | * | |
695 | * @param TC points to the TeleCommand packet that is being processed |
|
721 | * @param TC points to the TeleCommand packet that is being processed | |
696 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
722 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
697 | * |
|
723 | * | |
698 | */ |
|
724 | */ | |
699 |
|
725 | |||
700 | int status; |
|
726 | int status; | |
701 |
|
727 | |||
702 | status = LFR_SUCCESSFUL; |
|
728 | status = LFR_SUCCESSFUL; | |
703 |
|
729 | |||
704 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
730 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
705 |
|
731 | |||
706 | return status; |
|
732 | return status; | |
707 | } |
|
733 | } | |
708 |
|
734 | |||
709 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
735 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
710 | { |
|
736 | { | |
711 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
737 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). | |
712 | * |
|
738 | * | |
713 | * @param TC points to the TeleCommand packet that is being processed |
|
739 | * @param TC points to the TeleCommand packet that is being processed | |
714 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
740 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
715 | * |
|
741 | * | |
716 | */ |
|
742 | */ | |
717 |
|
743 | |||
718 | int status; |
|
744 | int status; | |
719 |
|
745 | |||
720 | status = LFR_SUCCESSFUL; |
|
746 | status = LFR_SUCCESSFUL; | |
721 |
|
747 | |||
722 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
748 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
723 |
|
749 | |||
724 | return status; |
|
750 | return status; | |
725 | } |
|
751 | } | |
726 |
|
752 | |||
727 | //********************* |
|
753 | //********************* | |
728 | // SBM1 MODE PARAMETERS |
|
754 | // SBM1 MODE PARAMETERS | |
729 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
755 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
730 | { |
|
756 | { | |
731 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
757 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). | |
732 | * |
|
758 | * | |
733 | * @param TC points to the TeleCommand packet that is being processed |
|
759 | * @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 |
|
760 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
735 | * |
|
761 | * | |
736 | */ |
|
762 | */ | |
737 |
|
763 | |||
738 | int status; |
|
764 | int status; | |
739 |
|
765 | |||
740 | status = LFR_SUCCESSFUL; |
|
766 | status = LFR_SUCCESSFUL; | |
741 |
|
767 | |||
742 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
768 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
743 |
|
769 | |||
744 | return status; |
|
770 | return status; | |
745 | } |
|
771 | } | |
746 |
|
772 | |||
747 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
773 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
748 | { |
|
774 | { | |
749 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
775 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). | |
750 | * |
|
776 | * | |
751 | * @param TC points to the TeleCommand packet that is being processed |
|
777 | * @param TC points to the TeleCommand packet that is being processed | |
752 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
778 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
753 | * |
|
779 | * | |
754 | */ |
|
780 | */ | |
755 |
|
781 | |||
756 | int status; |
|
782 | int status; | |
757 |
|
783 | |||
758 | status = LFR_SUCCESSFUL; |
|
784 | status = LFR_SUCCESSFUL; | |
759 |
|
785 | |||
760 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
786 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
761 |
|
787 | |||
762 | return status; |
|
788 | return status; | |
763 | } |
|
789 | } | |
764 |
|
790 | |||
765 | //********************* |
|
791 | //********************* | |
766 | // SBM2 MODE PARAMETERS |
|
792 | // SBM2 MODE PARAMETERS | |
767 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
793 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) | |
768 | { |
|
794 | { | |
769 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
795 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). | |
770 | * |
|
796 | * | |
771 | * @param TC points to the TeleCommand packet that is being processed |
|
797 | * @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 |
|
798 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
773 | * |
|
799 | * | |
774 | */ |
|
800 | */ | |
775 |
|
801 | |||
776 | int status; |
|
802 | int status; | |
777 |
|
803 | |||
778 | status = LFR_SUCCESSFUL; |
|
804 | status = LFR_SUCCESSFUL; | |
779 |
|
805 | |||
780 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
806 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
781 |
|
807 | |||
782 | return status; |
|
808 | return status; | |
783 | } |
|
809 | } | |
784 |
|
810 | |||
785 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
811 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
786 | { |
|
812 | { | |
787 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
813 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). | |
788 | * |
|
814 | * | |
789 | * @param TC points to the TeleCommand packet that is being processed |
|
815 | * @param TC points to the TeleCommand packet that is being processed | |
790 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
816 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
791 | * |
|
817 | * | |
792 | */ |
|
818 | */ | |
793 |
|
819 | |||
794 | int status; |
|
820 | int status; | |
795 |
|
821 | |||
796 | status = LFR_SUCCESSFUL; |
|
822 | status = LFR_SUCCESSFUL; | |
797 |
|
823 | |||
798 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
824 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
799 |
|
825 | |||
800 | return status; |
|
826 | return status; | |
801 | } |
|
827 | } | |
802 |
|
828 | |||
803 | //******************* |
|
829 | //******************* | |
804 | // TC_LFR_UPDATE_INFO |
|
830 | // TC_LFR_UPDATE_INFO | |
805 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
831 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) | |
806 | { |
|
832 | { | |
807 | unsigned int status; |
|
833 | unsigned int status; | |
808 |
|
834 | |||
809 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
835 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) | |
810 | || (mode == LFR_MODE_BURST) |
|
836 | || (mode == LFR_MODE_BURST) | |
811 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
837 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) | |
812 | { |
|
838 | { | |
813 | status = LFR_SUCCESSFUL; |
|
839 | status = LFR_SUCCESSFUL; | |
814 | } |
|
840 | } | |
815 | else |
|
841 | else | |
816 | { |
|
842 | { | |
817 | status = LFR_DEFAULT; |
|
843 | status = LFR_DEFAULT; | |
818 | } |
|
844 | } | |
819 |
|
845 | |||
820 | return status; |
|
846 | return status; | |
821 | } |
|
847 | } | |
822 |
|
848 | |||
823 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
849 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) | |
824 | { |
|
850 | { | |
825 | unsigned int status; |
|
851 | unsigned int status; | |
826 |
|
852 | |||
827 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
853 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) | |
828 | || (mode == TDS_MODE_BURST) |
|
854 | || (mode == TDS_MODE_BURST) | |
829 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
855 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) | |
830 | || (mode == TDS_MODE_LFM)) |
|
856 | || (mode == TDS_MODE_LFM)) | |
831 | { |
|
857 | { | |
832 | status = LFR_SUCCESSFUL; |
|
858 | status = LFR_SUCCESSFUL; | |
833 | } |
|
859 | } | |
834 | else |
|
860 | else | |
835 | { |
|
861 | { | |
836 | status = LFR_DEFAULT; |
|
862 | status = LFR_DEFAULT; | |
837 | } |
|
863 | } | |
838 |
|
864 | |||
839 | return status; |
|
865 | return status; | |
840 | } |
|
866 | } | |
841 |
|
867 | |||
842 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
868 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) | |
843 | { |
|
869 | { | |
844 | unsigned int status; |
|
870 | unsigned int status; | |
845 |
|
871 | |||
846 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
872 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) | |
847 | || (mode == THR_MODE_BURST)) |
|
873 | || (mode == THR_MODE_BURST)) | |
848 | { |
|
874 | { | |
849 | status = LFR_SUCCESSFUL; |
|
875 | status = LFR_SUCCESSFUL; | |
850 | } |
|
876 | } | |
851 | else |
|
877 | else | |
852 | { |
|
878 | { | |
853 | status = LFR_DEFAULT; |
|
879 | status = LFR_DEFAULT; | |
854 | } |
|
880 | } | |
855 |
|
881 | |||
856 | return status; |
|
882 | return status; | |
857 | } |
|
883 | } | |
858 |
|
884 | |||
859 | //*********** |
|
885 | //*********** | |
860 | // FBINS MASK |
|
886 | // FBINS MASK | |
861 |
|
887 | |||
862 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
888 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) | |
863 | { |
|
889 | { | |
864 | int status; |
|
890 | int status; | |
865 | unsigned int k; |
|
891 | unsigned int k; | |
866 | unsigned char *fbins_mask_dump; |
|
892 | unsigned char *fbins_mask_dump; | |
867 | unsigned char *fbins_mask_TC; |
|
893 | unsigned char *fbins_mask_TC; | |
868 |
|
894 | |||
869 | status = LFR_SUCCESSFUL; |
|
895 | status = LFR_SUCCESSFUL; | |
870 |
|
896 | |||
871 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
897 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
872 | fbins_mask_TC = TC->dataAndCRC; |
|
898 | fbins_mask_TC = TC->dataAndCRC; | |
873 |
|
899 | |||
874 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
900 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
875 | { |
|
901 | { | |
876 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
902 | fbins_mask_dump[k] = fbins_mask_TC[k]; | |
877 | } |
|
903 | } | |
878 | for (k=0; k < NB_FBINS_MASKS; k++) |
|
904 | for (k=0; k < NB_FBINS_MASKS; k++) | |
879 | { |
|
905 | { | |
880 | unsigned char *auxPtr; |
|
906 | unsigned char *auxPtr; | |
881 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; |
|
907 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; | |
882 | } |
|
908 | } | |
883 |
|
909 | |||
884 |
|
910 | |||
885 | return status; |
|
911 | return status; | |
886 | } |
|
912 | } | |
887 |
|
913 | |||
|
914 | //*************************** | |||
|
915 | // TC_LFR_LOAD_PAS_FILTER_PAR | |||
|
916 | ||||
|
917 | int check_sy_lfr_pas_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |||
|
918 | { | |||
|
919 | int flag; | |||
|
920 | rtems_status_code status; | |||
|
921 | ||||
|
922 | unsigned char sy_lfr_pas_filter_enabled; | |||
|
923 | unsigned char sy_lfr_pas_filter_modulus; | |||
|
924 | unsigned char sy_lfr_pas_filter_nstd; | |||
|
925 | unsigned char sy_lfr_pas_filter_offset; | |||
|
926 | ||||
|
927 | flag = LFR_SUCCESSFUL; | |||
|
928 | ||||
|
929 | //*************** | |||
|
930 | // get parameters | |||
|
931 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001] | |||
|
932 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; | |||
|
933 | sy_lfr_pas_filter_nstd = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_NSTD ]; | |||
|
934 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |||
|
935 | ||||
|
936 | //****************** | |||
|
937 | // check consistency | |||
|
938 | // sy_lfr_pas_filter_enabled | |||
|
939 | // sy_lfr_pas_filter_modulus | |||
|
940 | if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) ) | |||
|
941 | { | |||
|
942 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus ); | |||
|
943 | flag = WRONG_APP_DATA; | |||
|
944 | } | |||
|
945 | // sy_lfr_pas_filter_nstd | |||
|
946 | if (flag == LFR_SUCCESSFUL) | |||
|
947 | { | |||
|
948 | if ( sy_lfr_pas_filter_nstd > 8 ) | |||
|
949 | { | |||
|
950 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_NSTD+10, sy_lfr_pas_filter_nstd ); | |||
|
951 | flag = WRONG_APP_DATA; | |||
|
952 | } | |||
|
953 | } | |||
|
954 | // sy_lfr_pas_filter_offset | |||
|
955 | if (flag == LFR_SUCCESSFUL) | |||
|
956 | { | |||
|
957 | if (sy_lfr_pas_filter_offset > 7) | |||
|
958 | { | |||
|
959 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset ); | |||
|
960 | flag = WRONG_APP_DATA; | |||
|
961 | } | |||
|
962 | } | |||
|
963 | ||||
|
964 | return flag; | |||
|
965 | } | |||
|
966 | ||||
888 | //************** |
|
967 | //************** | |
889 | // KCOEFFICIENTS |
|
968 | // KCOEFFICIENTS | |
890 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
969 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) | |
891 | { |
|
970 | { | |
892 | unsigned int kcoeff; |
|
971 | unsigned int kcoeff; | |
893 | unsigned short sy_lfr_kcoeff_frequency; |
|
972 | unsigned short sy_lfr_kcoeff_frequency; | |
894 | unsigned short bin; |
|
973 | unsigned short bin; | |
895 | unsigned short *freqPtr; |
|
974 | unsigned short *freqPtr; | |
896 | float *kcoeffPtr_norm; |
|
975 | float *kcoeffPtr_norm; | |
897 | float *kcoeffPtr_sbm; |
|
976 | float *kcoeffPtr_sbm; | |
898 | int status; |
|
977 | int status; | |
899 | unsigned char *kcoeffLoadPtr; |
|
978 | unsigned char *kcoeffLoadPtr; | |
900 | unsigned char *kcoeffNormPtr; |
|
979 | unsigned char *kcoeffNormPtr; | |
901 | unsigned char *kcoeffSbmPtr_a; |
|
980 | unsigned char *kcoeffSbmPtr_a; | |
902 | unsigned char *kcoeffSbmPtr_b; |
|
981 | unsigned char *kcoeffSbmPtr_b; | |
903 |
|
982 | |||
904 | status = LFR_SUCCESSFUL; |
|
983 | status = LFR_SUCCESSFUL; | |
905 |
|
984 | |||
906 | kcoeffPtr_norm = NULL; |
|
985 | kcoeffPtr_norm = NULL; | |
907 | kcoeffPtr_sbm = NULL; |
|
986 | kcoeffPtr_sbm = NULL; | |
908 | bin = 0; |
|
987 | bin = 0; | |
909 |
|
988 | |||
910 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; |
|
989 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; | |
911 | sy_lfr_kcoeff_frequency = *freqPtr; |
|
990 | sy_lfr_kcoeff_frequency = *freqPtr; | |
912 |
|
991 | |||
913 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
992 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) | |
914 | { |
|
993 | { | |
915 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
994 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) | |
916 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, |
|
995 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, | |
917 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
996 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB | |
918 | status = LFR_DEFAULT; |
|
997 | status = LFR_DEFAULT; | |
919 | } |
|
998 | } | |
920 | else |
|
999 | else | |
921 | { |
|
1000 | { | |
922 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
1001 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) | |
923 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
1002 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) | |
924 | { |
|
1003 | { | |
925 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
1004 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; | |
926 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
1005 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; | |
927 | bin = sy_lfr_kcoeff_frequency; |
|
1006 | bin = sy_lfr_kcoeff_frequency; | |
928 | } |
|
1007 | } | |
929 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
1008 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) | |
930 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
1009 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) | |
931 | { |
|
1010 | { | |
932 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
1011 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; | |
933 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
1012 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; | |
934 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
1013 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; | |
935 | } |
|
1014 | } | |
936 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
1015 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) | |
937 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
1016 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) | |
938 | { |
|
1017 | { | |
939 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
1018 | kcoeffPtr_norm = k_coeff_intercalib_f2; | |
940 | kcoeffPtr_sbm = NULL; |
|
1019 | kcoeffPtr_sbm = NULL; | |
941 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
1020 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
942 | } |
|
1021 | } | |
943 | } |
|
1022 | } | |
944 |
|
1023 | |||
945 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
1024 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products | |
946 | { |
|
1025 | { | |
947 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1026 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
948 | { |
|
1027 | { | |
949 | // destination |
|
1028 | // destination | |
950 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
1029 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; | |
951 | // source |
|
1030 | // source | |
952 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
1031 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
953 | // copy source to destination |
|
1032 | // copy source to destination | |
954 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
1033 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); | |
955 | } |
|
1034 | } | |
956 | } |
|
1035 | } | |
957 |
|
1036 | |||
958 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
1037 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products | |
959 | { |
|
1038 | { | |
960 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1039 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
961 | { |
|
1040 | { | |
962 | // destination |
|
1041 | // destination | |
963 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; |
|
1042 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; | |
964 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; |
|
1043 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; | |
965 | // source |
|
1044 | // source | |
966 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
1045 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
967 | // copy source to destination |
|
1046 | // copy source to destination | |
968 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
1047 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); | |
969 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
1048 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); | |
970 | } |
|
1049 | } | |
971 | } |
|
1050 | } | |
972 |
|
1051 | |||
973 | // print_k_coeff(); |
|
1052 | // print_k_coeff(); | |
974 |
|
1053 | |||
975 | return status; |
|
1054 | return status; | |
976 | } |
|
1055 | } | |
977 |
|
1056 | |||
978 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
1057 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) | |
979 | { |
|
1058 | { | |
980 | destination[0] = source[0]; |
|
1059 | destination[0] = source[0]; | |
981 | destination[1] = source[1]; |
|
1060 | destination[1] = source[1]; | |
982 | destination[2] = source[2]; |
|
1061 | destination[2] = source[2]; | |
983 | destination[3] = source[3]; |
|
1062 | destination[3] = source[3]; | |
984 | } |
|
1063 | } | |
985 |
|
1064 | |||
986 | //********** |
|
1065 | //********** | |
987 | // init dump |
|
1066 | // init dump | |
988 |
|
1067 | |||
989 | void init_parameter_dump( void ) |
|
1068 | void init_parameter_dump( void ) | |
990 | { |
|
1069 | { | |
991 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
1070 | /** This function initialize the parameter_dump_packet global variable with default values. | |
992 | * |
|
1071 | * | |
993 | */ |
|
1072 | */ | |
994 |
|
1073 | |||
995 | unsigned int k; |
|
1074 | unsigned int k; | |
996 |
|
1075 | |||
997 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1076 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
998 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1077 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
999 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
1078 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
1000 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1079 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
1001 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
1080 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); | |
1002 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1081 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1003 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1082 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1004 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1083 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1005 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
1084 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); | |
1006 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1085 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
1007 | // DATA FIELD HEADER |
|
1086 | // DATA FIELD HEADER | |
1008 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1087 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1009 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1088 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
1010 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1089 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
1011 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1090 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
1012 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1091 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
1013 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1092 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
1014 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1093 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
1015 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1094 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
1016 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1095 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
1017 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1096 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
1018 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1097 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
1019 |
|
1098 | |||
1020 | //****************** |
|
1099 | //****************** | |
1021 | // COMMON PARAMETERS |
|
1100 | // COMMON PARAMETERS | |
1022 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1101 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; | |
1023 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1102 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; | |
1024 |
|
1103 | |||
1025 | //****************** |
|
1104 | //****************** | |
1026 | // NORMAL PARAMETERS |
|
1105 | // NORMAL PARAMETERS | |
1027 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); |
|
1106 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); | |
1028 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1107 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); | |
1029 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); |
|
1108 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); | |
1030 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1109 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); | |
1031 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); |
|
1110 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); | |
1032 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1111 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); | |
1033 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1112 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; | |
1034 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1113 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; | |
1035 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1114 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; | |
1036 |
|
1115 | |||
1037 | //***************** |
|
1116 | //***************** | |
1038 | // BURST PARAMETERS |
|
1117 | // BURST PARAMETERS | |
1039 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1118 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
1040 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1119 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
1041 |
|
1120 | |||
1042 | //**************** |
|
1121 | //**************** | |
1043 | // SBM1 PARAMETERS |
|
1122 | // SBM1 PARAMETERS | |
1044 | 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 |
|
1123 | 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 | |
1045 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1124 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
1046 |
|
1125 | |||
1047 | //**************** |
|
1126 | //**************** | |
1048 | // SBM2 PARAMETERS |
|
1127 | // SBM2 PARAMETERS | |
1049 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1128 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
1050 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1129 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
1051 |
|
1130 | |||
1052 | //************ |
|
1131 | //************ | |
1053 | // FBINS MASKS |
|
1132 | // FBINS MASKS | |
1054 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1133 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
1055 | { |
|
1134 | { | |
1056 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; |
|
1135 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; | |
1057 | } |
|
1136 | } | |
1058 | } |
|
1137 | } | |
1059 |
|
1138 | |||
1060 | void init_kcoefficients_dump( void ) |
|
1139 | void init_kcoefficients_dump( void ) | |
1061 | { |
|
1140 | { | |
1062 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); |
|
1141 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); | |
1063 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); |
|
1142 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); | |
1064 |
|
1143 | |||
1065 | kcoefficient_node_1.previous = NULL; |
|
1144 | kcoefficient_node_1.previous = NULL; | |
1066 | kcoefficient_node_1.next = NULL; |
|
1145 | kcoefficient_node_1.next = NULL; | |
1067 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1146 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; | |
1068 | kcoefficient_node_1.coarseTime = 0x00; |
|
1147 | kcoefficient_node_1.coarseTime = 0x00; | |
1069 | kcoefficient_node_1.fineTime = 0x00; |
|
1148 | kcoefficient_node_1.fineTime = 0x00; | |
1070 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1149 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; | |
1071 | kcoefficient_node_1.status = 0x00; |
|
1150 | kcoefficient_node_1.status = 0x00; | |
1072 |
|
1151 | |||
1073 | kcoefficient_node_2.previous = NULL; |
|
1152 | kcoefficient_node_2.previous = NULL; | |
1074 | kcoefficient_node_2.next = NULL; |
|
1153 | kcoefficient_node_2.next = NULL; | |
1075 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1154 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; | |
1076 | kcoefficient_node_2.coarseTime = 0x00; |
|
1155 | kcoefficient_node_2.coarseTime = 0x00; | |
1077 | kcoefficient_node_2.fineTime = 0x00; |
|
1156 | kcoefficient_node_2.fineTime = 0x00; | |
1078 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1157 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; | |
1079 | kcoefficient_node_2.status = 0x00; |
|
1158 | kcoefficient_node_2.status = 0x00; | |
1080 | } |
|
1159 | } | |
1081 |
|
1160 | |||
1082 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1161 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) | |
1083 | { |
|
1162 | { | |
1084 | unsigned int k; |
|
1163 | unsigned int k; | |
1085 | unsigned int packetLength; |
|
1164 | unsigned int packetLength; | |
1086 |
|
1165 | |||
1087 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1166 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header | |
1088 |
|
1167 | |||
1089 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1168 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1090 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1169 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1091 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1170 | kcoefficients_dump->reserved = CCSDS_RESERVED; | |
1092 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1171 | kcoefficients_dump->userApplication = CCSDS_USER_APP; | |
1093 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; |
|
1172 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; | |
1094 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; |
|
1173 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; | |
1095 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1174 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1096 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1175 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1097 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
1176 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); | |
1098 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1177 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; | |
1099 | // DATA FIELD HEADER |
|
1178 | // DATA FIELD HEADER | |
1100 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1179 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1101 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1180 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; | |
1102 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1181 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; | |
1103 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1182 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; | |
1104 | kcoefficients_dump->time[0] = 0x00; |
|
1183 | kcoefficients_dump->time[0] = 0x00; | |
1105 | kcoefficients_dump->time[1] = 0x00; |
|
1184 | kcoefficients_dump->time[1] = 0x00; | |
1106 | kcoefficients_dump->time[2] = 0x00; |
|
1185 | kcoefficients_dump->time[2] = 0x00; | |
1107 | kcoefficients_dump->time[3] = 0x00; |
|
1186 | kcoefficients_dump->time[3] = 0x00; | |
1108 | kcoefficients_dump->time[4] = 0x00; |
|
1187 | kcoefficients_dump->time[4] = 0x00; | |
1109 | kcoefficients_dump->time[5] = 0x00; |
|
1188 | kcoefficients_dump->time[5] = 0x00; | |
1110 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1189 | kcoefficients_dump->sid = SID_K_DUMP; | |
1111 |
|
1190 | |||
1112 | kcoefficients_dump->pkt_cnt = 2; |
|
1191 | kcoefficients_dump->pkt_cnt = 2; | |
1113 | kcoefficients_dump->pkt_nr = pkt_nr; |
|
1192 | kcoefficients_dump->pkt_nr = pkt_nr; | |
1114 | kcoefficients_dump->blk_nr = blk_nr; |
|
1193 | kcoefficients_dump->blk_nr = blk_nr; | |
1115 |
|
1194 | |||
1116 | //****************** |
|
1195 | //****************** | |
1117 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1196 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] | |
1118 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1197 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) | |
1119 | for (k=0; k<3900; k++) |
|
1198 | for (k=0; k<3900; k++) | |
1120 | { |
|
1199 | { | |
1121 | kcoefficients_dump->kcoeff_blks[k] = 0x00; |
|
1200 | kcoefficients_dump->kcoeff_blks[k] = 0x00; | |
1122 | } |
|
1201 | } | |
1123 | } |
|
1202 | } | |
1124 |
|
1203 | |||
1125 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) |
|
1204 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) | |
1126 | { |
|
1205 | { | |
1127 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. |
|
1206 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. | |
1128 | * |
|
1207 | * | |
1129 | * @param packet_sequence_control points to the packet sequence control which will be incremented |
|
1208 | * @param packet_sequence_control points to the packet sequence control which will be incremented | |
1130 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID |
|
1209 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID | |
1131 | * |
|
1210 | * | |
1132 | * If the destination ID is not known, a dedicated counter is incremented. |
|
1211 | * If the destination ID is not known, a dedicated counter is incremented. | |
1133 | * |
|
1212 | * | |
1134 | */ |
|
1213 | */ | |
1135 |
|
1214 | |||
1136 | unsigned short sequence_cnt; |
|
1215 | unsigned short sequence_cnt; | |
1137 | unsigned short segmentation_grouping_flag; |
|
1216 | unsigned short segmentation_grouping_flag; | |
1138 | unsigned short new_packet_sequence_control; |
|
1217 | unsigned short new_packet_sequence_control; | |
1139 | unsigned char i; |
|
1218 | unsigned char i; | |
1140 |
|
1219 | |||
1141 | switch (destination_id) |
|
1220 | switch (destination_id) | |
1142 | { |
|
1221 | { | |
1143 | case SID_TC_GROUND: |
|
1222 | case SID_TC_GROUND: | |
1144 | i = GROUND; |
|
1223 | i = GROUND; | |
1145 | break; |
|
1224 | break; | |
1146 | case SID_TC_MISSION_TIMELINE: |
|
1225 | case SID_TC_MISSION_TIMELINE: | |
1147 | i = MISSION_TIMELINE; |
|
1226 | i = MISSION_TIMELINE; | |
1148 | break; |
|
1227 | break; | |
1149 | case SID_TC_TC_SEQUENCES: |
|
1228 | case SID_TC_TC_SEQUENCES: | |
1150 | i = TC_SEQUENCES; |
|
1229 | i = TC_SEQUENCES; | |
1151 | break; |
|
1230 | break; | |
1152 | case SID_TC_RECOVERY_ACTION_CMD: |
|
1231 | case SID_TC_RECOVERY_ACTION_CMD: | |
1153 | i = RECOVERY_ACTION_CMD; |
|
1232 | i = RECOVERY_ACTION_CMD; | |
1154 | break; |
|
1233 | break; | |
1155 | case SID_TC_BACKUP_MISSION_TIMELINE: |
|
1234 | case SID_TC_BACKUP_MISSION_TIMELINE: | |
1156 | i = BACKUP_MISSION_TIMELINE; |
|
1235 | i = BACKUP_MISSION_TIMELINE; | |
1157 | break; |
|
1236 | break; | |
1158 | case SID_TC_DIRECT_CMD: |
|
1237 | case SID_TC_DIRECT_CMD: | |
1159 | i = DIRECT_CMD; |
|
1238 | i = DIRECT_CMD; | |
1160 | break; |
|
1239 | break; | |
1161 | case SID_TC_SPARE_GRD_SRC1: |
|
1240 | case SID_TC_SPARE_GRD_SRC1: | |
1162 | i = SPARE_GRD_SRC1; |
|
1241 | i = SPARE_GRD_SRC1; | |
1163 | break; |
|
1242 | break; | |
1164 | case SID_TC_SPARE_GRD_SRC2: |
|
1243 | case SID_TC_SPARE_GRD_SRC2: | |
1165 | i = SPARE_GRD_SRC2; |
|
1244 | i = SPARE_GRD_SRC2; | |
1166 | break; |
|
1245 | break; | |
1167 | case SID_TC_OBCP: |
|
1246 | case SID_TC_OBCP: | |
1168 | i = OBCP; |
|
1247 | i = OBCP; | |
1169 | break; |
|
1248 | break; | |
1170 | case SID_TC_SYSTEM_CONTROL: |
|
1249 | case SID_TC_SYSTEM_CONTROL: | |
1171 | i = SYSTEM_CONTROL; |
|
1250 | i = SYSTEM_CONTROL; | |
1172 | break; |
|
1251 | break; | |
1173 | case SID_TC_AOCS: |
|
1252 | case SID_TC_AOCS: | |
1174 | i = AOCS; |
|
1253 | i = AOCS; | |
1175 | break; |
|
1254 | break; | |
1176 | case SID_TC_RPW_INTERNAL: |
|
1255 | case SID_TC_RPW_INTERNAL: | |
1177 | i = RPW_INTERNAL; |
|
1256 | i = RPW_INTERNAL; | |
1178 | break; |
|
1257 | break; | |
1179 | default: |
|
1258 | default: | |
1180 | i = GROUND; |
|
1259 | i = GROUND; | |
1181 | break; |
|
1260 | break; | |
1182 | } |
|
1261 | } | |
1183 |
|
1262 | |||
1184 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1263 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
1185 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff; |
|
1264 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff; | |
1186 |
|
1265 | |||
1187 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; |
|
1266 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; | |
1188 |
|
1267 | |||
1189 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1268 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
1190 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1269 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1191 |
|
1270 | |||
1192 | // increment the sequence counter |
|
1271 | // increment the sequence counter | |
1193 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) |
|
1272 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) | |
1194 | { |
|
1273 | { | |
1195 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; |
|
1274 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; | |
1196 | } |
|
1275 | } | |
1197 | else |
|
1276 | else | |
1198 | { |
|
1277 | { | |
1199 | sequenceCounters_TM_DUMP[ i ] = 0; |
|
1278 | sequenceCounters_TM_DUMP[ i ] = 0; | |
1200 | } |
|
1279 | } | |
1201 | } |
|
1280 | } |
General Comments 0
You need to be logged in to leave comments.
Login now