@@ -1,2 +1,2 | |||||
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
2 | 6a30b7a924d9c3824f432332ed79bcee25954455 header/lfr_common_headers |
|
2 | 82603593a3f6185e68418200fe1fee7d81fe6e3d header/lfr_common_headers |
@@ -1,113 +1,113 | |||||
1 | TEMPLATE = app |
|
1 | TEMPLATE = app | |
2 | # CONFIG += console v8 sim |
|
2 | # CONFIG += console v8 sim | |
3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch |
|
3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch | |
4 | # lpp_dpu_destid |
|
4 | # lpp_dpu_destid | |
5 | CONFIG += console verbose lpp_dpu_destid |
|
5 | CONFIG += console verbose lpp_dpu_destid | |
6 | CONFIG -= qt |
|
6 | CONFIG -= qt | |
7 |
|
7 | |||
8 | include(./sparc.pri) |
|
8 | include(./sparc.pri) | |
9 |
|
9 | |||
10 | # flight software version |
|
10 | # flight software version | |
11 | SWVERSION=-1-0 |
|
11 | SWVERSION=-1-0 | |
12 | DEFINES += SW_VERSION_N1=3 # major |
|
12 | DEFINES += SW_VERSION_N1=3 # major | |
13 | DEFINES += SW_VERSION_N2=0 # minor |
|
13 | DEFINES += SW_VERSION_N2=0 # minor | |
14 | DEFINES += SW_VERSION_N3=0 # patch |
|
14 | DEFINES += SW_VERSION_N3=0 # patch | |
15 |
DEFINES += SW_VERSION_N4= |
|
15 | DEFINES += SW_VERSION_N4=10 # internal | |
16 |
|
16 | |||
17 | # <GCOV> |
|
17 | # <GCOV> | |
18 | #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage |
|
18 | #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage | |
19 | #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc |
|
19 | #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc | |
20 | #LIBS += -lgcov /opt/GCOV/HOWTO_gcov_for_lfr_test/01A/lib/overload.o -lc |
|
20 | #LIBS += -lgcov /opt/GCOV/HOWTO_gcov_for_lfr_test/01A/lib/overload.o -lc | |
21 | # </GCOV> |
|
21 | # </GCOV> | |
22 |
|
22 | |||
23 | # <CHANGE BEFORE FLIGHT> |
|
23 | # <CHANGE BEFORE FLIGHT> | |
24 | contains( CONFIG, lpp_dpu_destid ) { |
|
24 | contains( CONFIG, lpp_dpu_destid ) { | |
25 | DEFINES += LPP_DPU_DESTID |
|
25 | DEFINES += LPP_DPU_DESTID | |
26 | } |
|
26 | } | |
27 | # </CHANGE BEFORE FLIGHT> |
|
27 | # </CHANGE BEFORE FLIGHT> | |
28 |
|
28 | |||
29 | contains( CONFIG, debug_tch ) { |
|
29 | contains( CONFIG, debug_tch ) { | |
30 | DEFINES += DEBUG_TCH |
|
30 | DEFINES += DEBUG_TCH | |
31 | } |
|
31 | } | |
32 | DEFINES += MSB_FIRST_TCH |
|
32 | DEFINES += MSB_FIRST_TCH | |
33 |
|
33 | |||
34 | contains( CONFIG, vhdl_dev ) { |
|
34 | contains( CONFIG, vhdl_dev ) { | |
35 | DEFINES += VHDL_DEV |
|
35 | DEFINES += VHDL_DEV | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | contains( CONFIG, verbose ) { |
|
38 | contains( CONFIG, verbose ) { | |
39 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
39 | DEFINES += PRINT_MESSAGES_ON_CONSOLE | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | contains( CONFIG, debug_messages ) { |
|
42 | contains( CONFIG, debug_messages ) { | |
43 | DEFINES += DEBUG_MESSAGES |
|
43 | DEFINES += DEBUG_MESSAGES | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | contains( CONFIG, cpu_usage_report ) { |
|
46 | contains( CONFIG, cpu_usage_report ) { | |
47 | DEFINES += PRINT_TASK_STATISTICS |
|
47 | DEFINES += PRINT_TASK_STATISTICS | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | contains( CONFIG, stack_report ) { |
|
50 | contains( CONFIG, stack_report ) { | |
51 | DEFINES += PRINT_STACK_REPORT |
|
51 | DEFINES += PRINT_STACK_REPORT | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | contains( CONFIG, boot_messages ) { |
|
54 | contains( CONFIG, boot_messages ) { | |
55 | DEFINES += BOOT_MESSAGES |
|
55 | DEFINES += BOOT_MESSAGES | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | #doxygen.target = doxygen |
|
58 | #doxygen.target = doxygen | |
59 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
59 | #doxygen.commands = doxygen ../doc/Doxyfile | |
60 | #QMAKE_EXTRA_TARGETS += doxygen |
|
60 | #QMAKE_EXTRA_TARGETS += doxygen | |
61 |
|
61 | |||
62 | TARGET = fsw |
|
62 | TARGET = fsw | |
63 |
|
63 | |||
64 | INCLUDEPATH += \ |
|
64 | INCLUDEPATH += \ | |
65 | $${PWD}/../src \ |
|
65 | $${PWD}/../src \ | |
66 | $${PWD}/../header \ |
|
66 | $${PWD}/../header \ | |
67 | $${PWD}/../header/lfr_common_headers \ |
|
67 | $${PWD}/../header/lfr_common_headers \ | |
68 | $${PWD}/../header/processing \ |
|
68 | $${PWD}/../header/processing \ | |
69 | $${PWD}/../LFR_basic-parameters |
|
69 | $${PWD}/../LFR_basic-parameters | |
70 |
|
70 | |||
71 | SOURCES += \ |
|
71 | SOURCES += \ | |
72 | ../src/wf_handler.c \ |
|
72 | ../src/wf_handler.c \ | |
73 | ../src/tc_handler.c \ |
|
73 | ../src/tc_handler.c \ | |
74 | ../src/fsw_misc.c \ |
|
74 | ../src/fsw_misc.c \ | |
75 | ../src/fsw_init.c \ |
|
75 | ../src/fsw_init.c \ | |
76 | ../src/fsw_globals.c \ |
|
76 | ../src/fsw_globals.c \ | |
77 | ../src/fsw_spacewire.c \ |
|
77 | ../src/fsw_spacewire.c \ | |
78 | ../src/tc_load_dump_parameters.c \ |
|
78 | ../src/tc_load_dump_parameters.c \ | |
79 | ../src/tm_lfr_tc_exe.c \ |
|
79 | ../src/tm_lfr_tc_exe.c \ | |
80 | ../src/tc_acceptance.c \ |
|
80 | ../src/tc_acceptance.c \ | |
81 | ../src/processing/fsw_processing.c \ |
|
81 | ../src/processing/fsw_processing.c \ | |
82 | ../src/processing/avf0_prc0.c \ |
|
82 | ../src/processing/avf0_prc0.c \ | |
83 | ../src/processing/avf1_prc1.c \ |
|
83 | ../src/processing/avf1_prc1.c \ | |
84 | ../src/processing/avf2_prc2.c \ |
|
84 | ../src/processing/avf2_prc2.c \ | |
85 | ../src/lfr_cpu_usage_report.c \ |
|
85 | ../src/lfr_cpu_usage_report.c \ | |
86 | ../LFR_basic-parameters/basic_parameters.c |
|
86 | ../LFR_basic-parameters/basic_parameters.c | |
87 |
|
87 | |||
88 | HEADERS += \ |
|
88 | HEADERS += \ | |
89 | ../header/wf_handler.h \ |
|
89 | ../header/wf_handler.h \ | |
90 | ../header/tc_handler.h \ |
|
90 | ../header/tc_handler.h \ | |
91 | ../header/grlib_regs.h \ |
|
91 | ../header/grlib_regs.h \ | |
92 | ../header/fsw_misc.h \ |
|
92 | ../header/fsw_misc.h \ | |
93 | ../header/fsw_init.h \ |
|
93 | ../header/fsw_init.h \ | |
94 | ../header/fsw_spacewire.h \ |
|
94 | ../header/fsw_spacewire.h \ | |
95 | ../header/tc_load_dump_parameters.h \ |
|
95 | ../header/tc_load_dump_parameters.h \ | |
96 | ../header/tm_lfr_tc_exe.h \ |
|
96 | ../header/tm_lfr_tc_exe.h \ | |
97 | ../header/tc_acceptance.h \ |
|
97 | ../header/tc_acceptance.h \ | |
98 | ../header/processing/fsw_processing.h \ |
|
98 | ../header/processing/fsw_processing.h \ | |
99 | ../header/processing/avf0_prc0.h \ |
|
99 | ../header/processing/avf0_prc0.h \ | |
100 | ../header/processing/avf1_prc1.h \ |
|
100 | ../header/processing/avf1_prc1.h \ | |
101 | ../header/processing/avf2_prc2.h \ |
|
101 | ../header/processing/avf2_prc2.h \ | |
102 | ../header/fsw_params_wf_handler.h \ |
|
102 | ../header/fsw_params_wf_handler.h \ | |
103 | ../header/lfr_cpu_usage_report.h \ |
|
103 | ../header/lfr_cpu_usage_report.h \ | |
104 | ../header/lfr_common_headers/ccsds_types.h \ |
|
104 | ../header/lfr_common_headers/ccsds_types.h \ | |
105 | ../header/lfr_common_headers/fsw_params.h \ |
|
105 | ../header/lfr_common_headers/fsw_params.h \ | |
106 | ../header/lfr_common_headers/fsw_params_nb_bytes.h \ |
|
106 | ../header/lfr_common_headers/fsw_params_nb_bytes.h \ | |
107 | ../header/lfr_common_headers/fsw_params_processing.h \ |
|
107 | ../header/lfr_common_headers/fsw_params_processing.h \ | |
108 | ../header/lfr_common_headers/TC_types.h \ |
|
108 | ../header/lfr_common_headers/TC_types.h \ | |
109 | ../header/lfr_common_headers/tm_byte_positions.h \ |
|
109 | ../header/lfr_common_headers/tm_byte_positions.h \ | |
110 | ../LFR_basic-parameters/basic_parameters.h \ |
|
110 | ../LFR_basic-parameters/basic_parameters.h \ | |
111 | ../LFR_basic-parameters/basic_parameters_params.h \ |
|
111 | ../LFR_basic-parameters/basic_parameters_params.h \ | |
112 | ../header/GscMemoryLPP.hpp |
|
112 | ../header/GscMemoryLPP.hpp | |
113 |
|
113 |
@@ -1,1312 +1,1308 | |||||
1 | /** Functions related to the SpaceWire interface. |
|
1 | /** Functions related to the SpaceWire interface. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle SpaceWire transmissions: |
|
6 | * A group of functions to handle SpaceWire transmissions: | |
7 | * - configuration of the SpaceWire link |
|
7 | * - configuration of the SpaceWire link | |
8 | * - SpaceWire related interruption requests processing |
|
8 | * - SpaceWire related interruption requests processing | |
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task |
|
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task | |
10 | * - reception of TeleCommands by a dedicated RTEMS task |
|
10 | * - reception of TeleCommands by a dedicated RTEMS task | |
11 | * |
|
11 | * | |
12 | */ |
|
12 | */ | |
13 |
|
13 | |||
14 | #include "fsw_spacewire.h" |
|
14 | #include "fsw_spacewire.h" | |
15 |
|
15 | |||
16 | rtems_name semq_name; |
|
16 | rtems_name semq_name; | |
17 | rtems_id semq_id; |
|
17 | rtems_id semq_id; | |
18 |
|
18 | |||
19 | //***************** |
|
19 | //***************** | |
20 | // waveform headers |
|
20 | // waveform headers | |
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; |
|
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; | |
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; |
|
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; | |
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; | |
24 |
|
24 | |||
25 | //*********** |
|
25 | //*********** | |
26 | // RTEMS TASK |
|
26 | // RTEMS TASK | |
27 | rtems_task spiq_task(rtems_task_argument unused) |
|
27 | rtems_task spiq_task(rtems_task_argument unused) | |
28 | { |
|
28 | { | |
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. | |
30 | * |
|
30 | * | |
31 | * @param unused is the starting argument of the RTEMS task |
|
31 | * @param unused is the starting argument of the RTEMS task | |
32 | * |
|
32 | * | |
33 | */ |
|
33 | */ | |
34 |
|
34 | |||
35 | rtems_event_set event_out; |
|
35 | rtems_event_set event_out; | |
36 | rtems_status_code status; |
|
36 | rtems_status_code status; | |
37 | int linkStatus; |
|
37 | int linkStatus; | |
38 |
|
38 | |||
39 | BOOT_PRINTF("in SPIQ *** \n") |
|
39 | BOOT_PRINTF("in SPIQ *** \n") | |
40 |
|
40 | |||
41 | while(true){ |
|
41 | while(true){ | |
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT | |
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") | |
44 |
|
44 | |||
45 | // [0] SUSPEND RECV AND SEND TASKS |
|
45 | // [0] SUSPEND RECV AND SEND TASKS | |
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); | |
47 | if ( status != RTEMS_SUCCESSFUL ) { |
|
47 | if ( status != RTEMS_SUCCESSFUL ) { | |
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") | |
49 | } |
|
49 | } | |
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); | |
51 | if ( status != RTEMS_SUCCESSFUL ) { |
|
51 | if ( status != RTEMS_SUCCESSFUL ) { | |
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | // [1] CHECK THE LINK |
|
55 | // [1] CHECK THE LINK | |
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) | |
57 | if ( linkStatus != 5) { |
|
57 | if ( linkStatus != 5) { | |
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) | |
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT | |
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) | |
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link | |
65 | { |
|
65 | { | |
66 | spacewire_compute_stats_offsets(); |
|
66 | spacewire_compute_stats_offsets(); | |
67 | status = spacewire_reset_link( ); |
|
67 | status = spacewire_reset_link( ); | |
68 | } |
|
68 | } | |
69 | else // [2.b] in run state, start the link |
|
69 | else // [2.b] in run state, start the link | |
70 | { |
|
70 | { | |
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link |
|
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link | |
72 | if ( status != RTEMS_SUCCESSFUL) |
|
72 | if ( status != RTEMS_SUCCESSFUL) | |
73 | { |
|
73 | { | |
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) |
|
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) | |
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS | |
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully | |
80 | { |
|
80 | { | |
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
82 | if ( status != RTEMS_SUCCESSFUL ) { |
|
82 | if ( status != RTEMS_SUCCESSFUL ) { | |
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") | |
84 | } |
|
84 | } | |
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
86 | if ( status != RTEMS_SUCCESSFUL ) { |
|
86 | if ( status != RTEMS_SUCCESSFUL ) { | |
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") | |
88 | } |
|
88 | } | |
89 | } |
|
89 | } | |
90 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
90 | else // [3.b] the link is not in run state, go in STANDBY mode | |
91 | { |
|
91 | { | |
92 | status = enter_mode( LFR_MODE_STANDBY, 0 ); |
|
92 | status = enter_mode( LFR_MODE_STANDBY, 0 ); | |
93 | if ( status != RTEMS_SUCCESSFUL ) { |
|
93 | if ( status != RTEMS_SUCCESSFUL ) { | |
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) |
|
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) | |
95 | } |
|
95 | } | |
96 | // wake the WTDG task up to wait for the link recovery |
|
96 | // wake the WTDG task up to wait for the link recovery | |
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); | |
98 | status = rtems_task_suspend( RTEMS_SELF ); |
|
98 | status = rtems_task_suspend( RTEMS_SELF ); | |
99 | } |
|
99 | } | |
100 | } |
|
100 | } | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | rtems_task recv_task( rtems_task_argument unused ) |
|
103 | rtems_task recv_task( rtems_task_argument unused ) | |
104 | { |
|
104 | { | |
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. | |
106 | * |
|
106 | * | |
107 | * @param unused is the starting argument of the RTEMS task |
|
107 | * @param unused is the starting argument of the RTEMS task | |
108 | * |
|
108 | * | |
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: | |
110 | * 1. It reads the incoming data. |
|
110 | * 1. It reads the incoming data. | |
111 | * 2. Launches the acceptance procedure. |
|
111 | * 2. Launches the acceptance procedure. | |
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. |
|
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. | |
113 | * |
|
113 | * | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | int len; |
|
116 | int len; | |
117 | ccsdsTelecommandPacket_t currentTC; |
|
117 | ccsdsTelecommandPacket_t currentTC; | |
118 | unsigned char computed_CRC[ 2 ]; |
|
118 | unsigned char computed_CRC[ 2 ]; | |
119 | unsigned char currentTC_LEN_RCV[ 2 ]; |
|
119 | unsigned char currentTC_LEN_RCV[ 2 ]; | |
120 | unsigned char destinationID; |
|
120 | unsigned char destinationID; | |
121 | unsigned int estimatedPacketLength; |
|
121 | unsigned int estimatedPacketLength; | |
122 | unsigned int parserCode; |
|
122 | unsigned int parserCode; | |
123 | rtems_status_code status; |
|
123 | rtems_status_code status; | |
124 | rtems_id queue_recv_id; |
|
124 | rtems_id queue_recv_id; | |
125 | rtems_id queue_send_id; |
|
125 | rtems_id queue_send_id; | |
126 |
|
126 | |||
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes | |
128 |
|
128 | |||
129 | status = get_message_queue_id_recv( &queue_recv_id ); |
|
129 | status = get_message_queue_id_recv( &queue_recv_id ); | |
130 | if (status != RTEMS_SUCCESSFUL) |
|
130 | if (status != RTEMS_SUCCESSFUL) | |
131 | { |
|
131 | { | |
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) |
|
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | status = get_message_queue_id_send( &queue_send_id ); |
|
135 | status = get_message_queue_id_send( &queue_send_id ); | |
136 | if (status != RTEMS_SUCCESSFUL) |
|
136 | if (status != RTEMS_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) |
|
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | BOOT_PRINTF("in RECV *** \n") |
|
141 | BOOT_PRINTF("in RECV *** \n") | |
142 |
|
142 | |||
143 | while(1) |
|
143 | while(1) | |
144 | { |
|
144 | { | |
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking |
|
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking | |
146 | if (len == -1){ // error during the read call |
|
146 | if (len == -1){ // error during the read call | |
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) |
|
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) | |
148 | } |
|
148 | } | |
149 | else { |
|
149 | else { | |
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { | |
151 | PRINTF("in RECV *** packet lenght too short\n") |
|
151 | PRINTF("in RECV *** packet lenght too short\n") | |
152 | } |
|
152 | } | |
153 | else { |
|
153 | else { | |
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); |
|
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); | |
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); |
|
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); | |
157 | // CHECK THE TC |
|
157 | // CHECK THE TC | |
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; |
|
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; | |
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) |
|
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) | |
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) |
|
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) | |
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) |
|
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) | |
162 | || (parserCode == WRONG_SRC_ID) ) |
|
162 | || (parserCode == WRONG_SRC_ID) ) | |
163 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
163 | { // send TM_LFR_TC_EXE_CORRUPTED | |
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) |
|
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) | |
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
166 | && |
|
166 | && | |
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
168 | ) |
|
168 | ) | |
169 | { |
|
169 | { | |
170 | if ( parserCode == WRONG_SRC_ID ) |
|
170 | if ( parserCode == WRONG_SRC_ID ) | |
171 | { |
|
171 | { | |
172 | destinationID = SID_TC_GROUND; |
|
172 | destinationID = SID_TC_GROUND; | |
173 | } |
|
173 | } | |
174 | else |
|
174 | else | |
175 | { |
|
175 | { | |
176 | destinationID = currentTC.sourceID; |
|
176 | destinationID = currentTC.sourceID; | |
177 | } |
|
177 | } | |
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, |
|
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, | |
179 | computed_CRC, currentTC_LEN_RCV, |
|
179 | computed_CRC, currentTC_LEN_RCV, | |
180 | destinationID ); |
|
180 | destinationID ); | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 | else |
|
183 | else | |
184 | { // send valid TC to the action launcher |
|
184 | { // send valid TC to the action launcher | |
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, |
|
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, | |
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
187 | } |
|
187 | } | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); |
|
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); | |
192 |
|
192 | |||
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | rtems_task send_task( rtems_task_argument argument) |
|
196 | rtems_task send_task( rtems_task_argument argument) | |
197 | { |
|
197 | { | |
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. |
|
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. | |
199 | * |
|
199 | * | |
200 | * @param unused is the starting argument of the RTEMS task |
|
200 | * @param unused is the starting argument of the RTEMS task | |
201 | * |
|
201 | * | |
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: |
|
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: | |
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. |
|
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. | |
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After |
|
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After | |
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the |
|
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the | |
206 | * data it contains. |
|
206 | * data it contains. | |
207 | * |
|
207 | * | |
208 | */ |
|
208 | */ | |
209 |
|
209 | |||
210 | rtems_status_code status; // RTEMS status code |
|
210 | rtems_status_code status; // RTEMS status code | |
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
212 | ring_node *incomingRingNodePtr; |
|
212 | ring_node *incomingRingNodePtr; | |
213 | int ring_node_address; |
|
213 | int ring_node_address; | |
214 | char *charPtr; |
|
214 | char *charPtr; | |
215 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
215 | spw_ioctl_pkt_send *spw_ioctl_send; | |
216 | size_t size; // size of the incoming TC packet |
|
216 | size_t size; // size of the incoming TC packet | |
217 | rtems_id queue_send_id; |
|
217 | rtems_id queue_send_id; | |
218 | unsigned int sid; |
|
218 | unsigned int sid; | |
219 | unsigned char sidAsUnsignedChar; |
|
219 | unsigned char sidAsUnsignedChar; | |
|
220 | unsigned char type; | |||
220 |
|
221 | |||
221 | incomingRingNodePtr = NULL; |
|
222 | incomingRingNodePtr = NULL; | |
222 | ring_node_address = 0; |
|
223 | ring_node_address = 0; | |
223 | charPtr = (char *) &ring_node_address; |
|
224 | charPtr = (char *) &ring_node_address; | |
224 | sid = 0; |
|
225 | sid = 0; | |
225 | sidAsUnsignedChar = 0; |
|
226 | sidAsUnsignedChar = 0; | |
226 |
|
227 | |||
227 | init_header_cwf( &headerCWF ); |
|
228 | init_header_cwf( &headerCWF ); | |
228 | init_header_swf( &headerSWF ); |
|
229 | init_header_swf( &headerSWF ); | |
229 | init_header_asm( &headerASM ); |
|
230 | init_header_asm( &headerASM ); | |
230 |
|
231 | |||
231 | status = get_message_queue_id_send( &queue_send_id ); |
|
232 | status = get_message_queue_id_send( &queue_send_id ); | |
232 | if (status != RTEMS_SUCCESSFUL) |
|
233 | if (status != RTEMS_SUCCESSFUL) | |
233 | { |
|
234 | { | |
234 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
235 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
235 | } |
|
236 | } | |
236 |
|
237 | |||
237 | BOOT_PRINTF("in SEND *** \n") |
|
238 | BOOT_PRINTF("in SEND *** \n") | |
238 |
|
239 | |||
239 | while(1) |
|
240 | while(1) | |
240 | { |
|
241 | { | |
241 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, |
|
242 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, | |
242 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
243 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | |
243 |
|
244 | |||
244 | if (status!=RTEMS_SUCCESSFUL) |
|
245 | if (status!=RTEMS_SUCCESSFUL) | |
245 | { |
|
246 | { | |
246 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
247 | PRINTF1("in SEND *** (1) ERR = %d\n", status) | |
247 | } |
|
248 | } | |
248 | else |
|
249 | else | |
249 | { |
|
250 | { | |
250 | if ( size == sizeof(ring_node*) ) |
|
251 | if ( size == sizeof(ring_node*) ) | |
251 | { |
|
252 | { | |
252 | charPtr[0] = incomingData[0]; |
|
253 | charPtr[0] = incomingData[0]; | |
253 | charPtr[1] = incomingData[1]; |
|
254 | charPtr[1] = incomingData[1]; | |
254 | charPtr[2] = incomingData[2]; |
|
255 | charPtr[2] = incomingData[2]; | |
255 | charPtr[3] = incomingData[3]; |
|
256 | charPtr[3] = incomingData[3]; | |
256 | incomingRingNodePtr = (ring_node*) ring_node_address; |
|
257 | incomingRingNodePtr = (ring_node*) ring_node_address; | |
257 | sid = incomingRingNodePtr->sid; |
|
258 | sid = incomingRingNodePtr->sid; | |
258 | if ( (sid==SID_NORM_CWF_LONG_F3) |
|
259 | if ( (sid==SID_NORM_CWF_LONG_F3) | |
259 | || (sid==SID_BURST_CWF_F2 ) |
|
260 | || (sid==SID_BURST_CWF_F2 ) | |
260 | || (sid==SID_SBM1_CWF_F1 ) |
|
261 | || (sid==SID_SBM1_CWF_F1 ) | |
261 | || (sid==SID_SBM2_CWF_F2 )) |
|
262 | || (sid==SID_SBM2_CWF_F2 )) | |
262 | { |
|
263 | { | |
263 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); |
|
264 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); | |
264 | } |
|
265 | } | |
265 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) |
|
266 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) | |
266 | { |
|
267 | { | |
267 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); |
|
268 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); | |
268 | } |
|
269 | } | |
269 | else if ( (sid==SID_NORM_CWF_F3) ) |
|
270 | else if ( (sid==SID_NORM_CWF_F3) ) | |
270 | { |
|
271 | { | |
271 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); |
|
272 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); | |
272 | } |
|
273 | } | |
273 | else if (sid==SID_NORM_ASM_F0) |
|
274 | else if (sid==SID_NORM_ASM_F0) | |
274 | { |
|
275 | { | |
275 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); |
|
276 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); | |
276 | } |
|
277 | } | |
277 | else if (sid==SID_NORM_ASM_F1) |
|
278 | else if (sid==SID_NORM_ASM_F1) | |
278 | { |
|
279 | { | |
279 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); |
|
280 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); | |
280 | } |
|
281 | } | |
281 | else if (sid==SID_NORM_ASM_F2) |
|
282 | else if (sid==SID_NORM_ASM_F2) | |
282 | { |
|
283 | { | |
283 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); |
|
284 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); | |
284 | } |
|
285 | } | |
285 | else if ( sid==TM_CODE_K_DUMP ) |
|
286 | else if ( sid==TM_CODE_K_DUMP ) | |
286 | { |
|
287 | { | |
287 | spw_send_k_dump( incomingRingNodePtr ); |
|
288 | spw_send_k_dump( incomingRingNodePtr ); | |
288 | } |
|
289 | } | |
289 | else |
|
290 | else | |
290 | { |
|
291 | { | |
291 | PRINTF1("unexpected sid = %d\n", sid); |
|
292 | PRINTF1("unexpected sid = %d\n", sid); | |
292 | } |
|
293 | } | |
293 | } |
|
294 | } | |
294 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet |
|
295 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet | |
295 | { |
|
296 | { | |
296 | sidAsUnsignedChar = (unsigned char) incomingData[ PACKET_POS_PA_LFR_SID_PKT ]; |
|
297 | sidAsUnsignedChar = (unsigned char) incomingData[ PACKET_POS_PA_LFR_SID_PKT ]; | |
297 | sid = sidAsUnsignedChar; |
|
298 | sid = sidAsUnsignedChar; | |
|
299 | type = (unsigned char) incomingData[ PACKET_POS_SERVICE_TYPE ]; | |||
|
300 | if (type == TM_TYPE_LFR_SCIENCE) // this is a BP packet, all other types are handled differently | |||
298 | // SET THE SEQUENCE_CNT PARAMETER IN CASE OF BP0 OR BP1 PACKETS |
|
301 | // SET THE SEQUENCE_CNT PARAMETER IN CASE OF BP0 OR BP1 PACKETS | |
299 | if ( (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
|||
300 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
|||
301 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP1_F1) |
|
|||
302 | || (sid == SID_BURST_BP2_F0) || (sid == SID_BURST_BP2_F1) |
|
|||
303 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
|||
304 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP1_F1) |
|
|||
305 | || (sid == SID_SBM2_BP2_F0) || (sid == SID_SBM2_BP2_F1)) |
|
|||
306 | { |
|
302 | { | |
307 | increment_seq_counter_source_id( (unsigned char*) &incomingData[ PACKET_POS_SEQUENCE_CNT ], sid ); |
|
303 | increment_seq_counter_source_id( (unsigned char*) &incomingData[ PACKET_POS_SEQUENCE_CNT ], sid ); | |
308 | } |
|
304 | } | |
309 |
|
305 | |||
310 | status = write( fdSPW, incomingData, size ); |
|
306 | status = write( fdSPW, incomingData, size ); | |
311 | if (status == -1){ |
|
307 | if (status == -1){ | |
312 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
308 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
313 | } |
|
309 | } | |
314 | } |
|
310 | } | |
315 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
311 | else // the incoming message is a spw_ioctl_pkt_send structure | |
316 | { |
|
312 | { | |
317 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
313 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; | |
318 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
314 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |
319 | if (status == -1){ |
|
315 | if (status == -1){ | |
320 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
316 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) | |
321 | } |
|
317 | } | |
322 | } |
|
318 | } | |
323 | } |
|
319 | } | |
324 |
|
320 | |||
325 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); |
|
321 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); | |
326 |
|
322 | |||
327 | } |
|
323 | } | |
328 | } |
|
324 | } | |
329 |
|
325 | |||
330 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
326 | rtems_task wtdg_task( rtems_task_argument argument ) | |
331 | { |
|
327 | { | |
332 | rtems_event_set event_out; |
|
328 | rtems_event_set event_out; | |
333 | rtems_status_code status; |
|
329 | rtems_status_code status; | |
334 | int linkStatus; |
|
330 | int linkStatus; | |
335 |
|
331 | |||
336 | BOOT_PRINTF("in WTDG ***\n") |
|
332 | BOOT_PRINTF("in WTDG ***\n") | |
337 |
|
333 | |||
338 | while(1) |
|
334 | while(1) | |
339 | { |
|
335 | { | |
340 | // wait for an RTEMS_EVENT |
|
336 | // wait for an RTEMS_EVENT | |
341 | rtems_event_receive( RTEMS_EVENT_0, |
|
337 | rtems_event_receive( RTEMS_EVENT_0, | |
342 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
338 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
343 | PRINTF("in WTDG *** wait for the link\n") |
|
339 | PRINTF("in WTDG *** wait for the link\n") | |
344 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
340 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
345 | while( linkStatus != 5) // wait for the link |
|
341 | while( linkStatus != 5) // wait for the link | |
346 | { |
|
342 | { | |
347 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms |
|
343 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms | |
348 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
344 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
349 | } |
|
345 | } | |
350 |
|
346 | |||
351 | status = spacewire_stop_and_start_link( fdSPW ); |
|
347 | status = spacewire_stop_and_start_link( fdSPW ); | |
352 |
|
348 | |||
353 | if (status != RTEMS_SUCCESSFUL) |
|
349 | if (status != RTEMS_SUCCESSFUL) | |
354 | { |
|
350 | { | |
355 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
351 | PRINTF1("in WTDG *** ERR link not started %d\n", status) | |
356 | } |
|
352 | } | |
357 | else |
|
353 | else | |
358 | { |
|
354 | { | |
359 | PRINTF("in WTDG *** OK link started\n") |
|
355 | PRINTF("in WTDG *** OK link started\n") | |
360 | } |
|
356 | } | |
361 |
|
357 | |||
362 | // restart the SPIQ task |
|
358 | // restart the SPIQ task | |
363 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
359 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); | |
364 | if ( status != RTEMS_SUCCESSFUL ) { |
|
360 | if ( status != RTEMS_SUCCESSFUL ) { | |
365 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
361 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") | |
366 | } |
|
362 | } | |
367 |
|
363 | |||
368 | // restart RECV and SEND |
|
364 | // restart RECV and SEND | |
369 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
365 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
370 | if ( status != RTEMS_SUCCESSFUL ) { |
|
366 | if ( status != RTEMS_SUCCESSFUL ) { | |
371 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
367 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") | |
372 | } |
|
368 | } | |
373 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
369 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
374 | if ( status != RTEMS_SUCCESSFUL ) { |
|
370 | if ( status != RTEMS_SUCCESSFUL ) { | |
375 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
371 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") | |
376 | } |
|
372 | } | |
377 | } |
|
373 | } | |
378 | } |
|
374 | } | |
379 |
|
375 | |||
380 | //**************** |
|
376 | //**************** | |
381 | // OTHER FUNCTIONS |
|
377 | // OTHER FUNCTIONS | |
382 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] |
|
378 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] | |
383 | { |
|
379 | { | |
384 | /** This function opens the SpaceWire link. |
|
380 | /** This function opens the SpaceWire link. | |
385 | * |
|
381 | * | |
386 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
382 | * @return a valid file descriptor in case of success, -1 in case of a failure | |
387 | * |
|
383 | * | |
388 | */ |
|
384 | */ | |
389 | rtems_status_code status; |
|
385 | rtems_status_code status; | |
390 |
|
386 | |||
391 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
387 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware | |
392 | if ( fdSPW < 0 ) { |
|
388 | if ( fdSPW < 0 ) { | |
393 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
389 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) | |
394 | } |
|
390 | } | |
395 | else |
|
391 | else | |
396 | { |
|
392 | { | |
397 | status = RTEMS_SUCCESSFUL; |
|
393 | status = RTEMS_SUCCESSFUL; | |
398 | } |
|
394 | } | |
399 |
|
395 | |||
400 | return status; |
|
396 | return status; | |
401 | } |
|
397 | } | |
402 |
|
398 | |||
403 | int spacewire_start_link( int fd ) |
|
399 | int spacewire_start_link( int fd ) | |
404 | { |
|
400 | { | |
405 | rtems_status_code status; |
|
401 | rtems_status_code status; | |
406 |
|
402 | |||
407 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
403 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
408 | // -1 default hardcoded driver timeout |
|
404 | // -1 default hardcoded driver timeout | |
409 |
|
405 | |||
410 | return status; |
|
406 | return status; | |
411 | } |
|
407 | } | |
412 |
|
408 | |||
413 | int spacewire_stop_and_start_link( int fd ) |
|
409 | int spacewire_stop_and_start_link( int fd ) | |
414 | { |
|
410 | { | |
415 | rtems_status_code status; |
|
411 | rtems_status_code status; | |
416 |
|
412 | |||
417 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
413 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 | |
418 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
414 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
419 | // -1 default hardcoded driver timeout |
|
415 | // -1 default hardcoded driver timeout | |
420 |
|
416 | |||
421 | return status; |
|
417 | return status; | |
422 | } |
|
418 | } | |
423 |
|
419 | |||
424 | int spacewire_configure_link( int fd ) |
|
420 | int spacewire_configure_link( int fd ) | |
425 | { |
|
421 | { | |
426 | /** This function configures the SpaceWire link. |
|
422 | /** This function configures the SpaceWire link. | |
427 | * |
|
423 | * | |
428 | * @return GR-RTEMS-DRIVER directive status codes: |
|
424 | * @return GR-RTEMS-DRIVER directive status codes: | |
429 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
425 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. | |
430 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
426 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. | |
431 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
427 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. | |
432 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
428 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. | |
433 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
429 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. | |
434 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
430 | * - 5 EIO - Error when writing to grswp hardware registers. | |
435 | * - 2 ENOENT - No such file or directory |
|
431 | * - 2 ENOENT - No such file or directory | |
436 | */ |
|
432 | */ | |
437 |
|
433 | |||
438 | rtems_status_code status; |
|
434 | rtems_status_code status; | |
439 |
|
435 | |||
440 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
436 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force | |
441 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
437 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration | |
442 |
|
438 | |||
443 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
439 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |
444 | if (status!=RTEMS_SUCCESSFUL) { |
|
440 | if (status!=RTEMS_SUCCESSFUL) { | |
445 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
441 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
446 | } |
|
442 | } | |
447 | // |
|
443 | // | |
448 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
444 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a | |
449 | if (status!=RTEMS_SUCCESSFUL) { |
|
445 | if (status!=RTEMS_SUCCESSFUL) { | |
450 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
446 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
451 | } |
|
447 | } | |
452 | // |
|
448 | // | |
453 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
449 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts | |
454 | if (status!=RTEMS_SUCCESSFUL) { |
|
450 | if (status!=RTEMS_SUCCESSFUL) { | |
455 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
451 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
456 | } |
|
452 | } | |
457 | // |
|
453 | // | |
458 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
454 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |
459 | if (status!=RTEMS_SUCCESSFUL) { |
|
455 | if (status!=RTEMS_SUCCESSFUL) { | |
460 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
456 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
461 | } |
|
457 | } | |
462 | // |
|
458 | // | |
463 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks |
|
459 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks | |
464 | if (status!=RTEMS_SUCCESSFUL) { |
|
460 | if (status!=RTEMS_SUCCESSFUL) { | |
465 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
461 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
466 | } |
|
462 | } | |
467 | // |
|
463 | // | |
468 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
464 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available | |
469 | if (status!=RTEMS_SUCCESSFUL) { |
|
465 | if (status!=RTEMS_SUCCESSFUL) { | |
470 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
466 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
471 | } |
|
467 | } | |
472 | // |
|
468 | // | |
473 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
469 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] | |
474 | if (status!=RTEMS_SUCCESSFUL) { |
|
470 | if (status!=RTEMS_SUCCESSFUL) { | |
475 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
471 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
476 | } |
|
472 | } | |
477 |
|
473 | |||
478 | return status; |
|
474 | return status; | |
479 | } |
|
475 | } | |
480 |
|
476 | |||
481 | int spacewire_reset_link( void ) |
|
477 | int spacewire_reset_link( void ) | |
482 | { |
|
478 | { | |
483 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
479 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. | |
484 | * |
|
480 | * | |
485 | * @return RTEMS directive status code: |
|
481 | * @return RTEMS directive status code: | |
486 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
482 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. | |
487 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
483 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. | |
488 | * |
|
484 | * | |
489 | */ |
|
485 | */ | |
490 |
|
486 | |||
491 | rtems_status_code status_spw; |
|
487 | rtems_status_code status_spw; | |
492 | rtems_status_code status; |
|
488 | rtems_status_code status; | |
493 | int i; |
|
489 | int i; | |
494 |
|
490 | |||
495 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
491 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) | |
496 | { |
|
492 | { | |
497 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
493 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); | |
498 |
|
494 | |||
499 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
495 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM | |
500 |
|
496 | |||
501 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
497 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
502 |
|
498 | |||
503 | status_spw = spacewire_stop_and_start_link( fdSPW ); |
|
499 | status_spw = spacewire_stop_and_start_link( fdSPW ); | |
504 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
500 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
505 | { |
|
501 | { | |
506 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
502 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) | |
507 | } |
|
503 | } | |
508 |
|
504 | |||
509 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
505 | if ( status_spw == RTEMS_SUCCESSFUL) | |
510 | { |
|
506 | { | |
511 | break; |
|
507 | break; | |
512 | } |
|
508 | } | |
513 | } |
|
509 | } | |
514 |
|
510 | |||
515 | return status_spw; |
|
511 | return status_spw; | |
516 | } |
|
512 | } | |
517 |
|
513 | |||
518 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
514 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force | |
519 | { |
|
515 | { | |
520 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
516 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. | |
521 | * |
|
517 | * | |
522 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
518 | * @param val is the value, 0 or 1, used to set the value of the NP bit. | |
523 | * @param regAddr is the address of the GRSPW control register. |
|
519 | * @param regAddr is the address of the GRSPW control register. | |
524 | * |
|
520 | * | |
525 | * NP is the bit 20 of the GRSPW control register. |
|
521 | * NP is the bit 20 of the GRSPW control register. | |
526 | * |
|
522 | * | |
527 | */ |
|
523 | */ | |
528 |
|
524 | |||
529 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
525 | unsigned int *spwptr = (unsigned int*) regAddr; | |
530 |
|
526 | |||
531 | if (val == 1) { |
|
527 | if (val == 1) { | |
532 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
528 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit | |
533 | } |
|
529 | } | |
534 | if (val== 0) { |
|
530 | if (val== 0) { | |
535 | *spwptr = *spwptr & 0xffdfffff; |
|
531 | *spwptr = *spwptr & 0xffdfffff; | |
536 | } |
|
532 | } | |
537 | } |
|
533 | } | |
538 |
|
534 | |||
539 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
535 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable | |
540 | { |
|
536 | { | |
541 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
537 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. | |
542 | * |
|
538 | * | |
543 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
539 | * @param val is the value, 0 or 1, used to set the value of the RE bit. | |
544 | * @param regAddr is the address of the GRSPW control register. |
|
540 | * @param regAddr is the address of the GRSPW control register. | |
545 | * |
|
541 | * | |
546 | * RE is the bit 16 of the GRSPW control register. |
|
542 | * RE is the bit 16 of the GRSPW control register. | |
547 | * |
|
543 | * | |
548 | */ |
|
544 | */ | |
549 |
|
545 | |||
550 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
546 | unsigned int *spwptr = (unsigned int*) regAddr; | |
551 |
|
547 | |||
552 | if (val == 1) |
|
548 | if (val == 1) | |
553 | { |
|
549 | { | |
554 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
550 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit | |
555 | } |
|
551 | } | |
556 | if (val== 0) |
|
552 | if (val== 0) | |
557 | { |
|
553 | { | |
558 | *spwptr = *spwptr & 0xfffdffff; |
|
554 | *spwptr = *spwptr & 0xfffdffff; | |
559 | } |
|
555 | } | |
560 | } |
|
556 | } | |
561 |
|
557 | |||
562 | void spacewire_compute_stats_offsets( void ) |
|
558 | void spacewire_compute_stats_offsets( void ) | |
563 | { |
|
559 | { | |
564 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
560 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. | |
565 | * |
|
561 | * | |
566 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
562 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics | |
567 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it |
|
563 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it | |
568 | * during the open systel call). |
|
564 | * during the open systel call). | |
569 | * |
|
565 | * | |
570 | */ |
|
566 | */ | |
571 |
|
567 | |||
572 | spw_stats spacewire_stats_grspw; |
|
568 | spw_stats spacewire_stats_grspw; | |
573 | rtems_status_code status; |
|
569 | rtems_status_code status; | |
574 |
|
570 | |||
575 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
571 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
576 |
|
572 | |||
577 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
573 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received | |
578 | + spacewire_stats.packets_received; |
|
574 | + spacewire_stats.packets_received; | |
579 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
575 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent | |
580 | + spacewire_stats.packets_sent; |
|
576 | + spacewire_stats.packets_sent; | |
581 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
577 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err | |
582 | + spacewire_stats.parity_err; |
|
578 | + spacewire_stats.parity_err; | |
583 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
579 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err | |
584 | + spacewire_stats.disconnect_err; |
|
580 | + spacewire_stats.disconnect_err; | |
585 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
581 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err | |
586 | + spacewire_stats.escape_err; |
|
582 | + spacewire_stats.escape_err; | |
587 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
583 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err | |
588 | + spacewire_stats.credit_err; |
|
584 | + spacewire_stats.credit_err; | |
589 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
585 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err | |
590 | + spacewire_stats.write_sync_err; |
|
586 | + spacewire_stats.write_sync_err; | |
591 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
587 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err | |
592 | + spacewire_stats.rx_rmap_header_crc_err; |
|
588 | + spacewire_stats.rx_rmap_header_crc_err; | |
593 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
589 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err | |
594 | + spacewire_stats.rx_rmap_data_crc_err; |
|
590 | + spacewire_stats.rx_rmap_data_crc_err; | |
595 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
591 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep | |
596 | + spacewire_stats.early_ep; |
|
592 | + spacewire_stats.early_ep; | |
597 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
593 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address | |
598 | + spacewire_stats.invalid_address; |
|
594 | + spacewire_stats.invalid_address; | |
599 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
595 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err | |
600 | + spacewire_stats.rx_eep_err; |
|
596 | + spacewire_stats.rx_eep_err; | |
601 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
597 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated | |
602 | + spacewire_stats.rx_truncated; |
|
598 | + spacewire_stats.rx_truncated; | |
603 | } |
|
599 | } | |
604 |
|
600 | |||
605 | void spacewire_update_statistics( void ) |
|
601 | void spacewire_update_statistics( void ) | |
606 | { |
|
602 | { | |
607 | rtems_status_code status; |
|
603 | rtems_status_code status; | |
608 | spw_stats spacewire_stats_grspw; |
|
604 | spw_stats spacewire_stats_grspw; | |
609 |
|
605 | |||
610 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
606 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
611 |
|
607 | |||
612 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
608 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received | |
613 | + spacewire_stats_grspw.packets_received; |
|
609 | + spacewire_stats_grspw.packets_received; | |
614 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
610 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent | |
615 | + spacewire_stats_grspw.packets_sent; |
|
611 | + spacewire_stats_grspw.packets_sent; | |
616 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
612 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err | |
617 | + spacewire_stats_grspw.parity_err; |
|
613 | + spacewire_stats_grspw.parity_err; | |
618 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
614 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err | |
619 | + spacewire_stats_grspw.disconnect_err; |
|
615 | + spacewire_stats_grspw.disconnect_err; | |
620 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
616 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err | |
621 | + spacewire_stats_grspw.escape_err; |
|
617 | + spacewire_stats_grspw.escape_err; | |
622 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
618 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err | |
623 | + spacewire_stats_grspw.credit_err; |
|
619 | + spacewire_stats_grspw.credit_err; | |
624 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
620 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err | |
625 | + spacewire_stats_grspw.write_sync_err; |
|
621 | + spacewire_stats_grspw.write_sync_err; | |
626 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
622 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err | |
627 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
623 | + spacewire_stats_grspw.rx_rmap_header_crc_err; | |
628 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
624 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err | |
629 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
625 | + spacewire_stats_grspw.rx_rmap_data_crc_err; | |
630 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
626 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep | |
631 | + spacewire_stats_grspw.early_ep; |
|
627 | + spacewire_stats_grspw.early_ep; | |
632 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
628 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address | |
633 | + spacewire_stats_grspw.invalid_address; |
|
629 | + spacewire_stats_grspw.invalid_address; | |
634 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
630 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err | |
635 | + spacewire_stats_grspw.rx_eep_err; |
|
631 | + spacewire_stats_grspw.rx_eep_err; | |
636 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
632 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated | |
637 | + spacewire_stats_grspw.rx_truncated; |
|
633 | + spacewire_stats_grspw.rx_truncated; | |
638 | //spacewire_stats.tx_link_err; |
|
634 | //spacewire_stats.tx_link_err; | |
639 |
|
635 | |||
640 | //**************************** |
|
636 | //**************************** | |
641 | // DPU_SPACEWIRE_IF_STATISTICS |
|
637 | // DPU_SPACEWIRE_IF_STATISTICS | |
642 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
638 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); | |
643 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
639 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); | |
644 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
640 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); | |
645 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
641 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); | |
646 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
642 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; | |
647 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
643 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; | |
648 |
|
644 | |||
649 | //****************************************** |
|
645 | //****************************************** | |
650 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
646 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY | |
651 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
647 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; | |
652 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
648 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; | |
653 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
649 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; | |
654 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
650 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; | |
655 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
651 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; | |
656 |
|
652 | |||
657 | //********************************************* |
|
653 | //********************************************* | |
658 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
654 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY | |
659 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
655 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; | |
660 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
656 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; | |
661 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
657 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; | |
662 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
658 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; | |
663 | } |
|
659 | } | |
664 |
|
660 | |||
665 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
661 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) | |
666 | { |
|
662 | { | |
667 | // a valid timecode has been received, write it in the HK report |
|
663 | // a valid timecode has been received, write it in the HK report | |
668 | unsigned int *grspwPtr; |
|
664 | unsigned int *grspwPtr; | |
669 | unsigned char timecodeCtr; |
|
665 | unsigned char timecodeCtr; | |
670 | unsigned char updateTimeCtr; |
|
666 | unsigned char updateTimeCtr; | |
671 |
|
667 | |||
672 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); |
|
668 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); | |
673 |
|
669 | |||
674 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111] |
|
670 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111] | |
675 | timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111] |
|
671 | timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111] | |
676 | updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111] |
|
672 | updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111] | |
677 |
|
673 | |||
678 | // update the number of valid timecodes that have been received |
|
674 | // update the number of valid timecodes that have been received | |
679 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) |
|
675 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) | |
680 | { |
|
676 | { | |
681 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; |
|
677 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; | |
682 | } |
|
678 | } | |
683 | else |
|
679 | else | |
684 | { |
|
680 | { | |
685 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; |
|
681 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; | |
686 | } |
|
682 | } | |
687 |
|
683 | |||
688 | // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 |
|
684 | // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 | |
689 | if (timecodeCtr != updateTimeCtr) |
|
685 | if (timecodeCtr != updateTimeCtr) | |
690 | { |
|
686 | { | |
691 | if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255) |
|
687 | if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255) | |
692 | { |
|
688 | { | |
693 | housekeeping_packet.hk_lfr_time_timecode_ctr = 0; |
|
689 | housekeeping_packet.hk_lfr_time_timecode_ctr = 0; | |
694 | } |
|
690 | } | |
695 | else |
|
691 | else | |
696 | { |
|
692 | { | |
697 | housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1; |
|
693 | housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1; | |
698 | } |
|
694 | } | |
699 | } |
|
695 | } | |
700 | } |
|
696 | } | |
701 |
|
697 | |||
702 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
698 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) | |
703 | { |
|
699 | { | |
704 | int linkStatus; |
|
700 | int linkStatus; | |
705 | rtems_status_code status; |
|
701 | rtems_status_code status; | |
706 |
|
702 | |||
707 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
703 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
708 |
|
704 | |||
709 | if ( linkStatus == 5) { |
|
705 | if ( linkStatus == 5) { | |
710 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
706 | PRINTF("in spacewire_reset_link *** link is running\n") | |
711 | status = RTEMS_SUCCESSFUL; |
|
707 | status = RTEMS_SUCCESSFUL; | |
712 | } |
|
708 | } | |
713 | } |
|
709 | } | |
714 |
|
710 | |||
715 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
711 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) | |
716 | { |
|
712 | { | |
717 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
713 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
718 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
714 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
719 | header->reserved = DEFAULT_RESERVED; |
|
715 | header->reserved = DEFAULT_RESERVED; | |
720 | header->userApplication = CCSDS_USER_APP; |
|
716 | header->userApplication = CCSDS_USER_APP; | |
721 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; |
|
717 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; | |
722 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; |
|
718 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; | |
723 | header->packetLength[0] = 0x00; |
|
719 | header->packetLength[0] = 0x00; | |
724 | header->packetLength[1] = 0x00; |
|
720 | header->packetLength[1] = 0x00; | |
725 | // DATA FIELD HEADER |
|
721 | // DATA FIELD HEADER | |
726 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
722 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
727 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
723 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
728 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
724 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
729 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
725 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
730 | header->time[0] = 0x00; |
|
726 | header->time[0] = 0x00; | |
731 | header->time[0] = 0x00; |
|
727 | header->time[0] = 0x00; | |
732 | header->time[0] = 0x00; |
|
728 | header->time[0] = 0x00; | |
733 | header->time[0] = 0x00; |
|
729 | header->time[0] = 0x00; | |
734 | header->time[0] = 0x00; |
|
730 | header->time[0] = 0x00; | |
735 | header->time[0] = 0x00; |
|
731 | header->time[0] = 0x00; | |
736 | // AUXILIARY DATA HEADER |
|
732 | // AUXILIARY DATA HEADER | |
737 | header->sid = 0x00; |
|
733 | header->sid = 0x00; | |
738 | header->hkBIA = DEFAULT_HKBIA; |
|
734 | header->hkBIA = DEFAULT_HKBIA; | |
739 | header->blkNr[0] = 0x00; |
|
735 | header->blkNr[0] = 0x00; | |
740 | header->blkNr[1] = 0x00; |
|
736 | header->blkNr[1] = 0x00; | |
741 | } |
|
737 | } | |
742 |
|
738 | |||
743 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
739 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) | |
744 | { |
|
740 | { | |
745 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
741 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
746 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
742 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
747 | header->reserved = DEFAULT_RESERVED; |
|
743 | header->reserved = DEFAULT_RESERVED; | |
748 | header->userApplication = CCSDS_USER_APP; |
|
744 | header->userApplication = CCSDS_USER_APP; | |
749 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
745 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
750 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
746 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
751 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
747 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
752 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
748 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
753 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
749 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
754 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
750 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
755 | // DATA FIELD HEADER |
|
751 | // DATA FIELD HEADER | |
756 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
752 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
757 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
753 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
758 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
754 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
759 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
755 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
760 | header->time[0] = 0x00; |
|
756 | header->time[0] = 0x00; | |
761 | header->time[0] = 0x00; |
|
757 | header->time[0] = 0x00; | |
762 | header->time[0] = 0x00; |
|
758 | header->time[0] = 0x00; | |
763 | header->time[0] = 0x00; |
|
759 | header->time[0] = 0x00; | |
764 | header->time[0] = 0x00; |
|
760 | header->time[0] = 0x00; | |
765 | header->time[0] = 0x00; |
|
761 | header->time[0] = 0x00; | |
766 | // AUXILIARY DATA HEADER |
|
762 | // AUXILIARY DATA HEADER | |
767 | header->sid = 0x00; |
|
763 | header->sid = 0x00; | |
768 | header->hkBIA = DEFAULT_HKBIA; |
|
764 | header->hkBIA = DEFAULT_HKBIA; | |
769 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
765 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT | |
770 | header->pktNr = 0x00; |
|
766 | header->pktNr = 0x00; | |
771 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
767 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
772 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
768 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
773 | } |
|
769 | } | |
774 |
|
770 | |||
775 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
771 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) | |
776 | { |
|
772 | { | |
777 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
773 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
778 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
774 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
779 | header->reserved = DEFAULT_RESERVED; |
|
775 | header->reserved = DEFAULT_RESERVED; | |
780 | header->userApplication = CCSDS_USER_APP; |
|
776 | header->userApplication = CCSDS_USER_APP; | |
781 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
777 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
782 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
778 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
783 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
779 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
784 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
780 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
785 | header->packetLength[0] = 0x00; |
|
781 | header->packetLength[0] = 0x00; | |
786 | header->packetLength[1] = 0x00; |
|
782 | header->packetLength[1] = 0x00; | |
787 | // DATA FIELD HEADER |
|
783 | // DATA FIELD HEADER | |
788 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
784 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
789 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
785 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
790 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
786 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
791 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
787 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
792 | header->time[0] = 0x00; |
|
788 | header->time[0] = 0x00; | |
793 | header->time[0] = 0x00; |
|
789 | header->time[0] = 0x00; | |
794 | header->time[0] = 0x00; |
|
790 | header->time[0] = 0x00; | |
795 | header->time[0] = 0x00; |
|
791 | header->time[0] = 0x00; | |
796 | header->time[0] = 0x00; |
|
792 | header->time[0] = 0x00; | |
797 | header->time[0] = 0x00; |
|
793 | header->time[0] = 0x00; | |
798 | // AUXILIARY DATA HEADER |
|
794 | // AUXILIARY DATA HEADER | |
799 | header->sid = 0x00; |
|
795 | header->sid = 0x00; | |
800 | header->biaStatusInfo = 0x00; |
|
796 | header->biaStatusInfo = 0x00; | |
801 | header->pa_lfr_pkt_cnt_asm = 0x00; |
|
797 | header->pa_lfr_pkt_cnt_asm = 0x00; | |
802 | header->pa_lfr_pkt_nr_asm = 0x00; |
|
798 | header->pa_lfr_pkt_nr_asm = 0x00; | |
803 | header->pa_lfr_asm_blk_nr[0] = 0x00; |
|
799 | header->pa_lfr_asm_blk_nr[0] = 0x00; | |
804 | header->pa_lfr_asm_blk_nr[1] = 0x00; |
|
800 | header->pa_lfr_asm_blk_nr[1] = 0x00; | |
805 | } |
|
801 | } | |
806 |
|
802 | |||
807 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, |
|
803 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, | |
808 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
804 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
809 | { |
|
805 | { | |
810 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
806 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
811 | * |
|
807 | * | |
812 | * @param waveform points to the buffer containing the data that will be send. |
|
808 | * @param waveform points to the buffer containing the data that will be send. | |
813 | * @param sid is the source identifier of the data that will be sent. |
|
809 | * @param sid is the source identifier of the data that will be sent. | |
814 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
810 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
815 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
811 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
816 | * contain information to setup the transmission of the data packets. |
|
812 | * contain information to setup the transmission of the data packets. | |
817 | * |
|
813 | * | |
818 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
814 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
819 | * |
|
815 | * | |
820 | */ |
|
816 | */ | |
821 |
|
817 | |||
822 | unsigned int i; |
|
818 | unsigned int i; | |
823 | int ret; |
|
819 | int ret; | |
824 | unsigned int coarseTime; |
|
820 | unsigned int coarseTime; | |
825 | unsigned int fineTime; |
|
821 | unsigned int fineTime; | |
826 | rtems_status_code status; |
|
822 | rtems_status_code status; | |
827 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
823 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
828 | int *dataPtr; |
|
824 | int *dataPtr; | |
829 | unsigned char sid; |
|
825 | unsigned char sid; | |
830 |
|
826 | |||
831 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
827 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
832 | spw_ioctl_send_CWF.options = 0; |
|
828 | spw_ioctl_send_CWF.options = 0; | |
833 |
|
829 | |||
834 | ret = LFR_DEFAULT; |
|
830 | ret = LFR_DEFAULT; | |
835 | sid = (unsigned char) ring_node_to_send->sid; |
|
831 | sid = (unsigned char) ring_node_to_send->sid; | |
836 |
|
832 | |||
837 | coarseTime = ring_node_to_send->coarseTime; |
|
833 | coarseTime = ring_node_to_send->coarseTime; | |
838 | fineTime = ring_node_to_send->fineTime; |
|
834 | fineTime = ring_node_to_send->fineTime; | |
839 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
835 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
840 |
|
836 | |||
841 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
837 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
842 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
838 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
843 | header->hkBIA = pa_bia_status_info; |
|
839 | header->hkBIA = pa_bia_status_info; | |
844 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
840 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
845 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
841 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
846 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
842 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
847 |
|
843 | |||
848 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
844 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform | |
849 | { |
|
845 | { | |
850 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; |
|
846 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; | |
851 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
847 | spw_ioctl_send_CWF.hdr = (char*) header; | |
852 | // BUILD THE DATA |
|
848 | // BUILD THE DATA | |
853 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
849 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; | |
854 |
|
850 | |||
855 | // SET PACKET SEQUENCE CONTROL |
|
851 | // SET PACKET SEQUENCE CONTROL | |
856 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
852 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
857 |
|
853 | |||
858 | // SET SID |
|
854 | // SET SID | |
859 | header->sid = sid; |
|
855 | header->sid = sid; | |
860 |
|
856 | |||
861 | // SET PACKET TIME |
|
857 | // SET PACKET TIME | |
862 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); |
|
858 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); | |
863 | // |
|
859 | // | |
864 | header->time[0] = header->acquisitionTime[0]; |
|
860 | header->time[0] = header->acquisitionTime[0]; | |
865 | header->time[1] = header->acquisitionTime[1]; |
|
861 | header->time[1] = header->acquisitionTime[1]; | |
866 | header->time[2] = header->acquisitionTime[2]; |
|
862 | header->time[2] = header->acquisitionTime[2]; | |
867 | header->time[3] = header->acquisitionTime[3]; |
|
863 | header->time[3] = header->acquisitionTime[3]; | |
868 | header->time[4] = header->acquisitionTime[4]; |
|
864 | header->time[4] = header->acquisitionTime[4]; | |
869 | header->time[5] = header->acquisitionTime[5]; |
|
865 | header->time[5] = header->acquisitionTime[5]; | |
870 |
|
866 | |||
871 | // SET PACKET ID |
|
867 | // SET PACKET ID | |
872 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
868 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) | |
873 | { |
|
869 | { | |
874 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
870 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); | |
875 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
871 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); | |
876 | } |
|
872 | } | |
877 | else |
|
873 | else | |
878 | { |
|
874 | { | |
879 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
875 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
880 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
876 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
881 | } |
|
877 | } | |
882 |
|
878 | |||
883 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
879 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
884 | if (status != RTEMS_SUCCESSFUL) { |
|
880 | if (status != RTEMS_SUCCESSFUL) { | |
885 | ret = LFR_DEFAULT; |
|
881 | ret = LFR_DEFAULT; | |
886 | } |
|
882 | } | |
887 | } |
|
883 | } | |
888 |
|
884 | |||
889 | return ret; |
|
885 | return ret; | |
890 | } |
|
886 | } | |
891 |
|
887 | |||
892 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, |
|
888 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, | |
893 | Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
889 | Header_TM_LFR_SCIENCE_SWF_t *header ) | |
894 | { |
|
890 | { | |
895 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
891 | /** This function sends SWF CCSDS packets (F2, F1 or F0). | |
896 | * |
|
892 | * | |
897 | * @param waveform points to the buffer containing the data that will be send. |
|
893 | * @param waveform points to the buffer containing the data that will be send. | |
898 | * @param sid is the source identifier of the data that will be sent. |
|
894 | * @param sid is the source identifier of the data that will be sent. | |
899 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
895 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. | |
900 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
896 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
901 | * contain information to setup the transmission of the data packets. |
|
897 | * contain information to setup the transmission of the data packets. | |
902 | * |
|
898 | * | |
903 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
899 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
904 | * |
|
900 | * | |
905 | */ |
|
901 | */ | |
906 |
|
902 | |||
907 | unsigned int i; |
|
903 | unsigned int i; | |
908 | int ret; |
|
904 | int ret; | |
909 | unsigned int coarseTime; |
|
905 | unsigned int coarseTime; | |
910 | unsigned int fineTime; |
|
906 | unsigned int fineTime; | |
911 | rtems_status_code status; |
|
907 | rtems_status_code status; | |
912 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
908 | spw_ioctl_pkt_send spw_ioctl_send_SWF; | |
913 | int *dataPtr; |
|
909 | int *dataPtr; | |
914 | unsigned char sid; |
|
910 | unsigned char sid; | |
915 |
|
911 | |||
916 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; |
|
912 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; | |
917 | spw_ioctl_send_SWF.options = 0; |
|
913 | spw_ioctl_send_SWF.options = 0; | |
918 |
|
914 | |||
919 | ret = LFR_DEFAULT; |
|
915 | ret = LFR_DEFAULT; | |
920 |
|
916 | |||
921 | coarseTime = ring_node_to_send->coarseTime; |
|
917 | coarseTime = ring_node_to_send->coarseTime; | |
922 | fineTime = ring_node_to_send->fineTime; |
|
918 | fineTime = ring_node_to_send->fineTime; | |
923 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
919 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
924 | sid = ring_node_to_send->sid; |
|
920 | sid = ring_node_to_send->sid; | |
925 |
|
921 | |||
926 | header->hkBIA = pa_bia_status_info; |
|
922 | header->hkBIA = pa_bia_status_info; | |
927 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
923 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
928 |
|
924 | |||
929 | for (i=0; i<7; i++) // send waveform |
|
925 | for (i=0; i<7; i++) // send waveform | |
930 | { |
|
926 | { | |
931 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; |
|
927 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; | |
932 | spw_ioctl_send_SWF.hdr = (char*) header; |
|
928 | spw_ioctl_send_SWF.hdr = (char*) header; | |
933 |
|
929 | |||
934 | // SET PACKET SEQUENCE CONTROL |
|
930 | // SET PACKET SEQUENCE CONTROL | |
935 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
931 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
936 |
|
932 | |||
937 | // SET PACKET LENGTH AND BLKNR |
|
933 | // SET PACKET LENGTH AND BLKNR | |
938 | if (i == 6) |
|
934 | if (i == 6) | |
939 | { |
|
935 | { | |
940 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
936 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; | |
941 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
937 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); | |
942 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
938 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); | |
943 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
939 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); | |
944 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
940 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); | |
945 | } |
|
941 | } | |
946 | else |
|
942 | else | |
947 | { |
|
943 | { | |
948 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
944 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; | |
949 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
945 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); | |
950 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
946 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); | |
951 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
947 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); | |
952 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
948 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); | |
953 | } |
|
949 | } | |
954 |
|
950 | |||
955 | // SET PACKET TIME |
|
951 | // SET PACKET TIME | |
956 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); |
|
952 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); | |
957 | // |
|
953 | // | |
958 | header->time[0] = header->acquisitionTime[0]; |
|
954 | header->time[0] = header->acquisitionTime[0]; | |
959 | header->time[1] = header->acquisitionTime[1]; |
|
955 | header->time[1] = header->acquisitionTime[1]; | |
960 | header->time[2] = header->acquisitionTime[2]; |
|
956 | header->time[2] = header->acquisitionTime[2]; | |
961 | header->time[3] = header->acquisitionTime[3]; |
|
957 | header->time[3] = header->acquisitionTime[3]; | |
962 | header->time[4] = header->acquisitionTime[4]; |
|
958 | header->time[4] = header->acquisitionTime[4]; | |
963 | header->time[5] = header->acquisitionTime[5]; |
|
959 | header->time[5] = header->acquisitionTime[5]; | |
964 |
|
960 | |||
965 | // SET SID |
|
961 | // SET SID | |
966 | header->sid = sid; |
|
962 | header->sid = sid; | |
967 |
|
963 | |||
968 | // SET PKTNR |
|
964 | // SET PKTNR | |
969 | header->pktNr = i+1; // PKT_NR |
|
965 | header->pktNr = i+1; // PKT_NR | |
970 |
|
966 | |||
971 | // SEND PACKET |
|
967 | // SEND PACKET | |
972 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); |
|
968 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); | |
973 | if (status != RTEMS_SUCCESSFUL) { |
|
969 | if (status != RTEMS_SUCCESSFUL) { | |
974 | ret = LFR_DEFAULT; |
|
970 | ret = LFR_DEFAULT; | |
975 | } |
|
971 | } | |
976 | } |
|
972 | } | |
977 |
|
973 | |||
978 | return ret; |
|
974 | return ret; | |
979 | } |
|
975 | } | |
980 |
|
976 | |||
981 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, |
|
977 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, | |
982 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
978 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
983 | { |
|
979 | { | |
984 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
980 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
985 | * |
|
981 | * | |
986 | * @param waveform points to the buffer containing the data that will be send. |
|
982 | * @param waveform points to the buffer containing the data that will be send. | |
987 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
983 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
988 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
984 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
989 | * contain information to setup the transmission of the data packets. |
|
985 | * contain information to setup the transmission of the data packets. | |
990 | * |
|
986 | * | |
991 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
987 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
992 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
988 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
993 | * |
|
989 | * | |
994 | */ |
|
990 | */ | |
995 |
|
991 | |||
996 | unsigned int i; |
|
992 | unsigned int i; | |
997 | int ret; |
|
993 | int ret; | |
998 | unsigned int coarseTime; |
|
994 | unsigned int coarseTime; | |
999 | unsigned int fineTime; |
|
995 | unsigned int fineTime; | |
1000 | rtems_status_code status; |
|
996 | rtems_status_code status; | |
1001 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
997 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
1002 | char *dataPtr; |
|
998 | char *dataPtr; | |
1003 | unsigned char sid; |
|
999 | unsigned char sid; | |
1004 |
|
1000 | |||
1005 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
1001 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
1006 | spw_ioctl_send_CWF.options = 0; |
|
1002 | spw_ioctl_send_CWF.options = 0; | |
1007 |
|
1003 | |||
1008 | ret = LFR_DEFAULT; |
|
1004 | ret = LFR_DEFAULT; | |
1009 | sid = ring_node_to_send->sid; |
|
1005 | sid = ring_node_to_send->sid; | |
1010 |
|
1006 | |||
1011 | coarseTime = ring_node_to_send->coarseTime; |
|
1007 | coarseTime = ring_node_to_send->coarseTime; | |
1012 | fineTime = ring_node_to_send->fineTime; |
|
1008 | fineTime = ring_node_to_send->fineTime; | |
1013 | dataPtr = (char*) ring_node_to_send->buffer_address; |
|
1009 | dataPtr = (char*) ring_node_to_send->buffer_address; | |
1014 |
|
1010 | |||
1015 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
1011 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); | |
1016 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
1012 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); | |
1017 | header->hkBIA = pa_bia_status_info; |
|
1013 | header->hkBIA = pa_bia_status_info; | |
1018 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1014 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1019 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
1015 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); | |
1020 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
1016 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); | |
1021 |
|
1017 | |||
1022 | //********************* |
|
1018 | //********************* | |
1023 | // SEND CWF3_light DATA |
|
1019 | // SEND CWF3_light DATA | |
1024 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
1020 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform | |
1025 | { |
|
1021 | { | |
1026 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
1022 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; | |
1027 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
1023 | spw_ioctl_send_CWF.hdr = (char*) header; | |
1028 | // BUILD THE DATA |
|
1024 | // BUILD THE DATA | |
1029 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
1025 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; | |
1030 |
|
1026 | |||
1031 | // SET PACKET SEQUENCE COUNTER |
|
1027 | // SET PACKET SEQUENCE COUNTER | |
1032 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1028 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1033 |
|
1029 | |||
1034 | // SET SID |
|
1030 | // SET SID | |
1035 | header->sid = sid; |
|
1031 | header->sid = sid; | |
1036 |
|
1032 | |||
1037 | // SET PACKET TIME |
|
1033 | // SET PACKET TIME | |
1038 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); |
|
1034 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); | |
1039 | // |
|
1035 | // | |
1040 | header->time[0] = header->acquisitionTime[0]; |
|
1036 | header->time[0] = header->acquisitionTime[0]; | |
1041 | header->time[1] = header->acquisitionTime[1]; |
|
1037 | header->time[1] = header->acquisitionTime[1]; | |
1042 | header->time[2] = header->acquisitionTime[2]; |
|
1038 | header->time[2] = header->acquisitionTime[2]; | |
1043 | header->time[3] = header->acquisitionTime[3]; |
|
1039 | header->time[3] = header->acquisitionTime[3]; | |
1044 | header->time[4] = header->acquisitionTime[4]; |
|
1040 | header->time[4] = header->acquisitionTime[4]; | |
1045 | header->time[5] = header->acquisitionTime[5]; |
|
1041 | header->time[5] = header->acquisitionTime[5]; | |
1046 |
|
1042 | |||
1047 | // SET PACKET ID |
|
1043 | // SET PACKET ID | |
1048 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
1044 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
1049 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
1045 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
1050 |
|
1046 | |||
1051 | // SEND PACKET |
|
1047 | // SEND PACKET | |
1052 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
1048 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
1053 | if (status != RTEMS_SUCCESSFUL) { |
|
1049 | if (status != RTEMS_SUCCESSFUL) { | |
1054 | ret = LFR_DEFAULT; |
|
1050 | ret = LFR_DEFAULT; | |
1055 | } |
|
1051 | } | |
1056 | } |
|
1052 | } | |
1057 |
|
1053 | |||
1058 | return ret; |
|
1054 | return ret; | |
1059 | } |
|
1055 | } | |
1060 |
|
1056 | |||
1061 | void spw_send_asm_f0( ring_node *ring_node_to_send, |
|
1057 | void spw_send_asm_f0( ring_node *ring_node_to_send, | |
1062 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1058 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1063 | { |
|
1059 | { | |
1064 | unsigned int i; |
|
1060 | unsigned int i; | |
1065 | unsigned int length = 0; |
|
1061 | unsigned int length = 0; | |
1066 | rtems_status_code status; |
|
1062 | rtems_status_code status; | |
1067 | unsigned int sid; |
|
1063 | unsigned int sid; | |
1068 | float *spectral_matrix; |
|
1064 | float *spectral_matrix; | |
1069 | int coarseTime; |
|
1065 | int coarseTime; | |
1070 | int fineTime; |
|
1066 | int fineTime; | |
1071 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1067 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1072 |
|
1068 | |||
1073 | sid = ring_node_to_send->sid; |
|
1069 | sid = ring_node_to_send->sid; | |
1074 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1070 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1075 | coarseTime = ring_node_to_send->coarseTime; |
|
1071 | coarseTime = ring_node_to_send->coarseTime; | |
1076 | fineTime = ring_node_to_send->fineTime; |
|
1072 | fineTime = ring_node_to_send->fineTime; | |
1077 |
|
1073 | |||
1078 | header->biaStatusInfo = pa_bia_status_info; |
|
1074 | header->biaStatusInfo = pa_bia_status_info; | |
1079 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1075 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1080 |
|
1076 | |||
1081 | for (i=0; i<3; i++) |
|
1077 | for (i=0; i<3; i++) | |
1082 | { |
|
1078 | { | |
1083 | if ((i==0) || (i==1)) |
|
1079 | if ((i==0) || (i==1)) | |
1084 | { |
|
1080 | { | |
1085 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; |
|
1081 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; | |
1086 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1082 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1087 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1083 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1088 | ]; |
|
1084 | ]; | |
1089 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; |
|
1085 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; | |
1090 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1086 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1091 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB |
|
1087 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB | |
1092 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB |
|
1088 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB | |
1093 | } |
|
1089 | } | |
1094 | else |
|
1090 | else | |
1095 | { |
|
1091 | { | |
1096 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; |
|
1092 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; | |
1097 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1093 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1098 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1094 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1099 | ]; |
|
1095 | ]; | |
1100 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; |
|
1096 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; | |
1101 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1097 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1102 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB |
|
1098 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB | |
1103 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB |
|
1099 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB | |
1104 | } |
|
1100 | } | |
1105 |
|
1101 | |||
1106 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1102 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1107 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1103 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1108 | spw_ioctl_send_ASM.options = 0; |
|
1104 | spw_ioctl_send_ASM.options = 0; | |
1109 |
|
1105 | |||
1110 | // (2) BUILD THE HEADER |
|
1106 | // (2) BUILD THE HEADER | |
1111 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1107 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1112 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1108 | header->packetLength[0] = (unsigned char) (length>>8); | |
1113 | header->packetLength[1] = (unsigned char) (length); |
|
1109 | header->packetLength[1] = (unsigned char) (length); | |
1114 | header->sid = (unsigned char) sid; // SID |
|
1110 | header->sid = (unsigned char) sid; // SID | |
1115 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1111 | header->pa_lfr_pkt_cnt_asm = 3; | |
1116 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1112 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1117 |
|
1113 | |||
1118 | // (3) SET PACKET TIME |
|
1114 | // (3) SET PACKET TIME | |
1119 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1115 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1120 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1116 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1121 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1117 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1122 | header->time[3] = (unsigned char) (coarseTime); |
|
1118 | header->time[3] = (unsigned char) (coarseTime); | |
1123 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1119 | header->time[4] = (unsigned char) (fineTime>>8); | |
1124 | header->time[5] = (unsigned char) (fineTime); |
|
1120 | header->time[5] = (unsigned char) (fineTime); | |
1125 | // |
|
1121 | // | |
1126 | header->acquisitionTime[0] = header->time[0]; |
|
1122 | header->acquisitionTime[0] = header->time[0]; | |
1127 | header->acquisitionTime[1] = header->time[1]; |
|
1123 | header->acquisitionTime[1] = header->time[1]; | |
1128 | header->acquisitionTime[2] = header->time[2]; |
|
1124 | header->acquisitionTime[2] = header->time[2]; | |
1129 | header->acquisitionTime[3] = header->time[3]; |
|
1125 | header->acquisitionTime[3] = header->time[3]; | |
1130 | header->acquisitionTime[4] = header->time[4]; |
|
1126 | header->acquisitionTime[4] = header->time[4]; | |
1131 | header->acquisitionTime[5] = header->time[5]; |
|
1127 | header->acquisitionTime[5] = header->time[5]; | |
1132 |
|
1128 | |||
1133 | // (4) SEND PACKET |
|
1129 | // (4) SEND PACKET | |
1134 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1130 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1135 | if (status != RTEMS_SUCCESSFUL) { |
|
1131 | if (status != RTEMS_SUCCESSFUL) { | |
1136 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) |
|
1132 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1137 | } |
|
1133 | } | |
1138 | } |
|
1134 | } | |
1139 | } |
|
1135 | } | |
1140 |
|
1136 | |||
1141 | void spw_send_asm_f1( ring_node *ring_node_to_send, |
|
1137 | void spw_send_asm_f1( ring_node *ring_node_to_send, | |
1142 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1138 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1143 | { |
|
1139 | { | |
1144 | unsigned int i; |
|
1140 | unsigned int i; | |
1145 | unsigned int length = 0; |
|
1141 | unsigned int length = 0; | |
1146 | rtems_status_code status; |
|
1142 | rtems_status_code status; | |
1147 | unsigned int sid; |
|
1143 | unsigned int sid; | |
1148 | float *spectral_matrix; |
|
1144 | float *spectral_matrix; | |
1149 | int coarseTime; |
|
1145 | int coarseTime; | |
1150 | int fineTime; |
|
1146 | int fineTime; | |
1151 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1147 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1152 |
|
1148 | |||
1153 | sid = ring_node_to_send->sid; |
|
1149 | sid = ring_node_to_send->sid; | |
1154 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1150 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1155 | coarseTime = ring_node_to_send->coarseTime; |
|
1151 | coarseTime = ring_node_to_send->coarseTime; | |
1156 | fineTime = ring_node_to_send->fineTime; |
|
1152 | fineTime = ring_node_to_send->fineTime; | |
1157 |
|
1153 | |||
1158 | header->biaStatusInfo = pa_bia_status_info; |
|
1154 | header->biaStatusInfo = pa_bia_status_info; | |
1159 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1155 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1160 |
|
1156 | |||
1161 | for (i=0; i<3; i++) |
|
1157 | for (i=0; i<3; i++) | |
1162 | { |
|
1158 | { | |
1163 | if ((i==0) || (i==1)) |
|
1159 | if ((i==0) || (i==1)) | |
1164 | { |
|
1160 | { | |
1165 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; |
|
1161 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; | |
1166 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1162 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1167 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1163 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1168 | ]; |
|
1164 | ]; | |
1169 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; |
|
1165 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; | |
1170 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1166 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1171 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB |
|
1167 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB | |
1172 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB |
|
1168 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB | |
1173 | } |
|
1169 | } | |
1174 | else |
|
1170 | else | |
1175 | { |
|
1171 | { | |
1176 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; |
|
1172 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; | |
1177 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1173 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1178 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1174 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1179 | ]; |
|
1175 | ]; | |
1180 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; |
|
1176 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; | |
1181 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1177 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1182 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB |
|
1178 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB | |
1183 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB |
|
1179 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB | |
1184 | } |
|
1180 | } | |
1185 |
|
1181 | |||
1186 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1182 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1187 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1183 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1188 | spw_ioctl_send_ASM.options = 0; |
|
1184 | spw_ioctl_send_ASM.options = 0; | |
1189 |
|
1185 | |||
1190 | // (2) BUILD THE HEADER |
|
1186 | // (2) BUILD THE HEADER | |
1191 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1187 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1192 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1188 | header->packetLength[0] = (unsigned char) (length>>8); | |
1193 | header->packetLength[1] = (unsigned char) (length); |
|
1189 | header->packetLength[1] = (unsigned char) (length); | |
1194 | header->sid = (unsigned char) sid; // SID |
|
1190 | header->sid = (unsigned char) sid; // SID | |
1195 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1191 | header->pa_lfr_pkt_cnt_asm = 3; | |
1196 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1192 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1197 |
|
1193 | |||
1198 | // (3) SET PACKET TIME |
|
1194 | // (3) SET PACKET TIME | |
1199 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1195 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1200 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1196 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1201 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1197 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1202 | header->time[3] = (unsigned char) (coarseTime); |
|
1198 | header->time[3] = (unsigned char) (coarseTime); | |
1203 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1199 | header->time[4] = (unsigned char) (fineTime>>8); | |
1204 | header->time[5] = (unsigned char) (fineTime); |
|
1200 | header->time[5] = (unsigned char) (fineTime); | |
1205 | // |
|
1201 | // | |
1206 | header->acquisitionTime[0] = header->time[0]; |
|
1202 | header->acquisitionTime[0] = header->time[0]; | |
1207 | header->acquisitionTime[1] = header->time[1]; |
|
1203 | header->acquisitionTime[1] = header->time[1]; | |
1208 | header->acquisitionTime[2] = header->time[2]; |
|
1204 | header->acquisitionTime[2] = header->time[2]; | |
1209 | header->acquisitionTime[3] = header->time[3]; |
|
1205 | header->acquisitionTime[3] = header->time[3]; | |
1210 | header->acquisitionTime[4] = header->time[4]; |
|
1206 | header->acquisitionTime[4] = header->time[4]; | |
1211 | header->acquisitionTime[5] = header->time[5]; |
|
1207 | header->acquisitionTime[5] = header->time[5]; | |
1212 |
|
1208 | |||
1213 | // (4) SEND PACKET |
|
1209 | // (4) SEND PACKET | |
1214 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1210 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1215 | if (status != RTEMS_SUCCESSFUL) { |
|
1211 | if (status != RTEMS_SUCCESSFUL) { | |
1216 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) |
|
1212 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1217 | } |
|
1213 | } | |
1218 | } |
|
1214 | } | |
1219 | } |
|
1215 | } | |
1220 |
|
1216 | |||
1221 | void spw_send_asm_f2( ring_node *ring_node_to_send, |
|
1217 | void spw_send_asm_f2( ring_node *ring_node_to_send, | |
1222 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1218 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1223 | { |
|
1219 | { | |
1224 | unsigned int i; |
|
1220 | unsigned int i; | |
1225 | unsigned int length = 0; |
|
1221 | unsigned int length = 0; | |
1226 | rtems_status_code status; |
|
1222 | rtems_status_code status; | |
1227 | unsigned int sid; |
|
1223 | unsigned int sid; | |
1228 | float *spectral_matrix; |
|
1224 | float *spectral_matrix; | |
1229 | int coarseTime; |
|
1225 | int coarseTime; | |
1230 | int fineTime; |
|
1226 | int fineTime; | |
1231 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1227 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1232 |
|
1228 | |||
1233 | sid = ring_node_to_send->sid; |
|
1229 | sid = ring_node_to_send->sid; | |
1234 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1230 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1235 | coarseTime = ring_node_to_send->coarseTime; |
|
1231 | coarseTime = ring_node_to_send->coarseTime; | |
1236 | fineTime = ring_node_to_send->fineTime; |
|
1232 | fineTime = ring_node_to_send->fineTime; | |
1237 |
|
1233 | |||
1238 | header->biaStatusInfo = pa_bia_status_info; |
|
1234 | header->biaStatusInfo = pa_bia_status_info; | |
1239 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1235 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1240 |
|
1236 | |||
1241 | for (i=0; i<3; i++) |
|
1237 | for (i=0; i<3; i++) | |
1242 | { |
|
1238 | { | |
1243 |
|
1239 | |||
1244 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; |
|
1240 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; | |
1245 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1241 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1246 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) |
|
1242 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) | |
1247 | ]; |
|
1243 | ]; | |
1248 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; |
|
1244 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; | |
1249 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; |
|
1245 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; | |
1250 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB |
|
1246 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB | |
1251 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB |
|
1247 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB | |
1252 |
|
1248 | |||
1253 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1249 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1254 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1250 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1255 | spw_ioctl_send_ASM.options = 0; |
|
1251 | spw_ioctl_send_ASM.options = 0; | |
1256 |
|
1252 | |||
1257 | // (2) BUILD THE HEADER |
|
1253 | // (2) BUILD THE HEADER | |
1258 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1254 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1259 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1255 | header->packetLength[0] = (unsigned char) (length>>8); | |
1260 | header->packetLength[1] = (unsigned char) (length); |
|
1256 | header->packetLength[1] = (unsigned char) (length); | |
1261 | header->sid = (unsigned char) sid; // SID |
|
1257 | header->sid = (unsigned char) sid; // SID | |
1262 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1258 | header->pa_lfr_pkt_cnt_asm = 3; | |
1263 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1259 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1264 |
|
1260 | |||
1265 | // (3) SET PACKET TIME |
|
1261 | // (3) SET PACKET TIME | |
1266 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1262 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1267 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1263 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1268 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1264 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1269 | header->time[3] = (unsigned char) (coarseTime); |
|
1265 | header->time[3] = (unsigned char) (coarseTime); | |
1270 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1266 | header->time[4] = (unsigned char) (fineTime>>8); | |
1271 | header->time[5] = (unsigned char) (fineTime); |
|
1267 | header->time[5] = (unsigned char) (fineTime); | |
1272 | // |
|
1268 | // | |
1273 | header->acquisitionTime[0] = header->time[0]; |
|
1269 | header->acquisitionTime[0] = header->time[0]; | |
1274 | header->acquisitionTime[1] = header->time[1]; |
|
1270 | header->acquisitionTime[1] = header->time[1]; | |
1275 | header->acquisitionTime[2] = header->time[2]; |
|
1271 | header->acquisitionTime[2] = header->time[2]; | |
1276 | header->acquisitionTime[3] = header->time[3]; |
|
1272 | header->acquisitionTime[3] = header->time[3]; | |
1277 | header->acquisitionTime[4] = header->time[4]; |
|
1273 | header->acquisitionTime[4] = header->time[4]; | |
1278 | header->acquisitionTime[5] = header->time[5]; |
|
1274 | header->acquisitionTime[5] = header->time[5]; | |
1279 |
|
1275 | |||
1280 | // (4) SEND PACKET |
|
1276 | // (4) SEND PACKET | |
1281 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1277 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1282 | if (status != RTEMS_SUCCESSFUL) { |
|
1278 | if (status != RTEMS_SUCCESSFUL) { | |
1283 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) |
|
1279 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1284 | } |
|
1280 | } | |
1285 | } |
|
1281 | } | |
1286 | } |
|
1282 | } | |
1287 |
|
1283 | |||
1288 | void spw_send_k_dump( ring_node *ring_node_to_send ) |
|
1284 | void spw_send_k_dump( ring_node *ring_node_to_send ) | |
1289 | { |
|
1285 | { | |
1290 | rtems_status_code status; |
|
1286 | rtems_status_code status; | |
1291 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; |
|
1287 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; | |
1292 | unsigned int packetLength; |
|
1288 | unsigned int packetLength; | |
1293 | unsigned int size; |
|
1289 | unsigned int size; | |
1294 |
|
1290 | |||
1295 | PRINTF("spw_send_k_dump\n") |
|
1291 | PRINTF("spw_send_k_dump\n") | |
1296 |
|
1292 | |||
1297 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; |
|
1293 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; | |
1298 |
|
1294 | |||
1299 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; |
|
1295 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; | |
1300 |
|
1296 | |||
1301 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
1297 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
1302 |
|
1298 | |||
1303 | PRINTF2("packetLength %d, size %d\n", packetLength, size ) |
|
1299 | PRINTF2("packetLength %d, size %d\n", packetLength, size ) | |
1304 |
|
1300 | |||
1305 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); |
|
1301 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); | |
1306 |
|
1302 | |||
1307 | if (status == -1){ |
|
1303 | if (status == -1){ | |
1308 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
1304 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
1309 | } |
|
1305 | } | |
1310 |
|
1306 | |||
1311 | ring_node_to_send->status = 0x00; |
|
1307 | ring_node_to_send->status = 0x00; | |
1312 | } |
|
1308 | } |
@@ -1,404 +1,408 | |||||
1 | /** Functions related to data processing. |
|
1 | /** Functions related to data processing. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "avf0_prc0.h" |
|
10 | #include "avf0_prc0.h" | |
11 | #include "fsw_processing.h" |
|
11 | #include "fsw_processing.h" | |
12 |
|
12 | |||
13 | nb_sm_before_bp_asm_f0 nb_sm_before_f0; |
|
13 | nb_sm_before_bp_asm_f0 nb_sm_before_f0; | |
14 |
|
14 | |||
15 | //*** |
|
15 | //*** | |
16 | // F0 |
|
16 | // F0 | |
17 | ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ]; |
|
17 | ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ]; | |
18 | ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ]; |
|
18 | ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ]; | |
19 |
|
19 | |||
20 | ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ]; |
|
20 | ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ]; | |
21 | int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ]; |
|
21 | int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ]; | |
22 |
|
22 | |||
23 | float asm_f0_patched_norm [ TOTAL_SIZE_SM ]; |
|
23 | float asm_f0_patched_norm [ TOTAL_SIZE_SM ]; | |
24 | float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ]; |
|
24 | float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ]; | |
25 | float asm_f0_reorganized [ TOTAL_SIZE_SM ]; |
|
25 | float asm_f0_reorganized [ TOTAL_SIZE_SM ]; | |
26 |
|
26 | |||
27 | char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; |
|
27 | char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; | |
28 | float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0]; |
|
28 | float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0]; | |
29 | float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ]; |
|
29 | float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ]; | |
30 |
|
30 | |||
31 | float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352 |
|
31 | float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352 | |
32 | float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704 |
|
32 | float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704 | |
33 |
|
33 | |||
34 | //************ |
|
34 | //************ | |
35 | // RTEMS TASKS |
|
35 | // RTEMS TASKS | |
36 |
|
36 | |||
37 | rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) |
|
37 | rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) | |
38 | { |
|
38 | { | |
39 | int i; |
|
39 | int i; | |
40 |
|
40 | |||
41 | rtems_event_set event_out; |
|
41 | rtems_event_set event_out; | |
42 | rtems_status_code status; |
|
42 | rtems_status_code status; | |
43 | rtems_id queue_id_prc0; |
|
43 | rtems_id queue_id_prc0; | |
44 | asm_msg msgForMATR; |
|
44 | asm_msg msgForMATR; | |
45 | ring_node *nodeForAveraging; |
|
45 | ring_node *nodeForAveraging; | |
46 | ring_node *ring_node_tab[8]; |
|
46 | ring_node *ring_node_tab[8]; | |
47 | ring_node_asm *current_ring_node_asm_burst_sbm_f0; |
|
47 | ring_node_asm *current_ring_node_asm_burst_sbm_f0; | |
48 | ring_node_asm *current_ring_node_asm_norm_f0; |
|
48 | ring_node_asm *current_ring_node_asm_norm_f0; | |
49 |
|
49 | |||
50 | unsigned int nb_norm_bp1; |
|
50 | unsigned int nb_norm_bp1; | |
51 | unsigned int nb_norm_bp2; |
|
51 | unsigned int nb_norm_bp2; | |
52 | unsigned int nb_norm_asm; |
|
52 | unsigned int nb_norm_asm; | |
53 | unsigned int nb_sbm_bp1; |
|
53 | unsigned int nb_sbm_bp1; | |
54 | unsigned int nb_sbm_bp2; |
|
54 | unsigned int nb_sbm_bp2; | |
55 |
|
55 | |||
56 | nb_norm_bp1 = 0; |
|
56 | nb_norm_bp1 = 0; | |
57 | nb_norm_bp2 = 0; |
|
57 | nb_norm_bp2 = 0; | |
58 | nb_norm_asm = 0; |
|
58 | nb_norm_asm = 0; | |
59 | nb_sbm_bp1 = 0; |
|
59 | nb_sbm_bp1 = 0; | |
60 | nb_sbm_bp2 = 0; |
|
60 | nb_sbm_bp2 = 0; | |
61 |
|
61 | |||
62 | reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions |
|
62 | reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions | |
63 | ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 ); |
|
63 | ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 ); | |
64 | ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 ); |
|
64 | ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 ); | |
65 | current_ring_node_asm_norm_f0 = asm_ring_norm_f0; |
|
65 | current_ring_node_asm_norm_f0 = asm_ring_norm_f0; | |
66 | current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0; |
|
66 | current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0; | |
67 |
|
67 | |||
68 | BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
68 | BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
69 |
|
69 | |||
70 | status = get_message_queue_id_prc0( &queue_id_prc0 ); |
|
70 | status = get_message_queue_id_prc0( &queue_id_prc0 ); | |
71 | if (status != RTEMS_SUCCESSFUL) |
|
71 | if (status != RTEMS_SUCCESSFUL) | |
72 | { |
|
72 | { | |
73 | PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status) |
|
73 | PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status) | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | while(1){ |
|
76 | while(1){ | |
77 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
77 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
78 |
|
78 | |||
79 | //**************************************** |
|
79 | //**************************************** | |
80 | // initialize the mesage for the MATR task |
|
80 | // initialize the mesage for the MATR task | |
81 | msgForMATR.norm = current_ring_node_asm_norm_f0; |
|
81 | msgForMATR.norm = current_ring_node_asm_norm_f0; | |
82 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0; |
|
82 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0; | |
83 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task |
|
83 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task | |
84 | // |
|
84 | // | |
85 | //**************************************** |
|
85 | //**************************************** | |
86 |
|
86 | |||
87 | nodeForAveraging = getRingNodeForAveraging( 0 ); |
|
87 | nodeForAveraging = getRingNodeForAveraging( 0 ); | |
88 |
|
88 | |||
89 | ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging; |
|
89 | ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging; | |
90 | for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ ) |
|
90 | for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ ) | |
91 | { |
|
91 | { | |
92 | nodeForAveraging = nodeForAveraging->previous; |
|
92 | nodeForAveraging = nodeForAveraging->previous; | |
93 | ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging; |
|
93 | ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | // compute the average and store it in the averaged_sm_f1 buffer |
|
96 | // compute the average and store it in the averaged_sm_f1 buffer | |
97 | SM_average( current_ring_node_asm_norm_f0->matrix, |
|
97 | SM_average( current_ring_node_asm_norm_f0->matrix, | |
98 | current_ring_node_asm_burst_sbm_f0->matrix, |
|
98 | current_ring_node_asm_burst_sbm_f0->matrix, | |
99 | ring_node_tab, |
|
99 | ring_node_tab, | |
100 | nb_norm_bp1, nb_sbm_bp1, |
|
100 | nb_norm_bp1, nb_sbm_bp1, | |
101 | &msgForMATR ); |
|
101 | &msgForMATR ); | |
102 |
|
102 | |||
103 | // update nb_average |
|
103 | // update nb_average | |
104 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0; |
|
104 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0; | |
105 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0; |
|
105 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0; | |
106 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0; |
|
106 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0; | |
107 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0; |
|
107 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0; | |
108 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0; |
|
108 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0; | |
109 |
|
109 | |||
110 | if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1) |
|
110 | if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1) | |
111 | { |
|
111 | { | |
112 | nb_sbm_bp1 = 0; |
|
112 | nb_sbm_bp1 = 0; | |
113 | // set another ring for the ASM storage |
|
113 | // set another ring for the ASM storage | |
114 | current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next; |
|
114 | current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next; | |
115 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
115 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
116 | { |
|
116 | { | |
117 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0; |
|
117 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0; | |
118 | } |
|
118 | } | |
119 | else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
119 | else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
120 | { |
|
120 | { | |
121 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0; |
|
121 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0; | |
122 | } |
|
122 | } | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2) |
|
125 | if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2) | |
126 | { |
|
126 | { | |
127 | nb_sbm_bp2 = 0; |
|
127 | nb_sbm_bp2 = 0; | |
128 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
128 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
129 | { |
|
129 | { | |
130 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0; |
|
130 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0; | |
131 | } |
|
131 | } | |
132 | else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
132 | else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
133 | { |
|
133 | { | |
134 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0; |
|
134 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0; | |
135 | } |
|
135 | } | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1) |
|
138 | if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1) | |
139 | { |
|
139 | { | |
140 | nb_norm_bp1 = 0; |
|
140 | nb_norm_bp1 = 0; | |
141 | // set another ring for the ASM storage |
|
141 | // set another ring for the ASM storage | |
142 | current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next; |
|
142 | current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next; | |
143 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
143 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
144 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
144 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
145 | { |
|
145 | { | |
146 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0; |
|
146 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0; | |
147 | } |
|
147 | } | |
148 | } |
|
148 | } | |
149 |
|
149 | |||
150 | if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2) |
|
150 | if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2) | |
151 | { |
|
151 | { | |
152 | nb_norm_bp2 = 0; |
|
152 | nb_norm_bp2 = 0; | |
153 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
153 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
154 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
154 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
155 | { |
|
155 | { | |
156 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0; |
|
156 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0; | |
157 | } |
|
157 | } | |
158 | } |
|
158 | } | |
159 |
|
159 | |||
160 | if (nb_norm_asm == nb_sm_before_f0.norm_asm) |
|
160 | if (nb_norm_asm == nb_sm_before_f0.norm_asm) | |
161 | { |
|
161 | { | |
162 | nb_norm_asm = 0; |
|
162 | nb_norm_asm = 0; | |
163 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
163 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
164 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
164 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
165 | { |
|
165 | { | |
166 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0; |
|
166 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0; | |
167 | } |
|
167 | } | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | //************************* |
|
170 | //************************* | |
171 | // send the message to MATR |
|
171 | // send the message to MATR | |
172 | if (msgForMATR.event != 0x00) |
|
172 | if (msgForMATR.event != 0x00) | |
173 | { |
|
173 | { | |
174 | status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); |
|
174 | status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | if (status != RTEMS_SUCCESSFUL) { |
|
177 | if (status != RTEMS_SUCCESSFUL) { | |
178 | PRINTF1("in AVF0 *** Error sending message to MATR, code %d\n", status) |
|
178 | PRINTF1("in AVF0 *** Error sending message to MATR, code %d\n", status) | |
179 | } |
|
179 | } | |
180 | } |
|
180 | } | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | rtems_task prc0_task( rtems_task_argument lfrRequestedMode ) |
|
183 | rtems_task prc0_task( rtems_task_argument lfrRequestedMode ) | |
184 | { |
|
184 | { | |
185 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
185 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
186 | size_t size; // size of the incoming TC packet |
|
186 | size_t size; // size of the incoming TC packet | |
187 | asm_msg *incomingMsg; |
|
187 | asm_msg *incomingMsg; | |
188 | // |
|
188 | // | |
189 | unsigned char sid; |
|
189 | unsigned char sid; | |
190 | rtems_status_code status; |
|
190 | rtems_status_code status; | |
191 | rtems_id queue_id; |
|
191 | rtems_id queue_id; | |
192 | rtems_id queue_id_q_p0; |
|
192 | rtems_id queue_id_q_p0; | |
193 | bp_packet_with_spare packet_norm_bp1; |
|
193 | bp_packet_with_spare packet_norm_bp1; | |
194 | bp_packet packet_norm_bp2; |
|
194 | bp_packet packet_norm_bp2; | |
195 | bp_packet packet_sbm_bp1; |
|
195 | bp_packet packet_sbm_bp1; | |
196 | bp_packet packet_sbm_bp2; |
|
196 | bp_packet packet_sbm_bp2; | |
197 | ring_node *current_ring_node_to_send_asm_f0; |
|
197 | ring_node *current_ring_node_to_send_asm_f0; | |
198 |
|
198 | |||
199 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU |
|
199 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU | |
200 | init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM ); |
|
200 | init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM ); | |
201 | current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0; |
|
201 | current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0; | |
202 |
|
202 | |||
203 | //************* |
|
203 | //************* | |
204 | // NORM headers |
|
204 | // NORM headers | |
205 | BP_init_header_with_spare( &packet_norm_bp1, |
|
205 | BP_init_header_with_spare( &packet_norm_bp1, | |
206 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, |
|
206 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, | |
207 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); |
|
207 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); | |
208 | BP_init_header( &packet_norm_bp2, |
|
208 | BP_init_header( &packet_norm_bp2, | |
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, |
|
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, | |
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); |
|
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); | |
211 |
|
211 | |||
212 | //**************************** |
|
212 | //**************************** | |
213 | // BURST SBM1 and SBM2 headers |
|
213 | // BURST SBM1 and SBM2 headers | |
214 | if ( lfrRequestedMode == LFR_MODE_BURST ) |
|
214 | if ( lfrRequestedMode == LFR_MODE_BURST ) | |
215 | { |
|
215 | { | |
216 | BP_init_header( &packet_sbm_bp1, |
|
216 | BP_init_header( &packet_sbm_bp1, | |
217 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, |
|
217 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, | |
218 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
218 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
219 | BP_init_header( &packet_sbm_bp2, |
|
219 | BP_init_header( &packet_sbm_bp2, | |
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, |
|
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, | |
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
222 | } |
|
222 | } | |
223 | else if ( lfrRequestedMode == LFR_MODE_SBM1 ) |
|
223 | else if ( lfrRequestedMode == LFR_MODE_SBM1 ) | |
224 | { |
|
224 | { | |
225 | BP_init_header( &packet_sbm_bp1, |
|
225 | BP_init_header( &packet_sbm_bp1, | |
226 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, |
|
226 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, | |
227 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
227 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
228 | BP_init_header( &packet_sbm_bp2, |
|
228 | BP_init_header( &packet_sbm_bp2, | |
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, |
|
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, | |
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
231 | } |
|
231 | } | |
232 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) |
|
232 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) | |
233 | { |
|
233 | { | |
234 | BP_init_header( &packet_sbm_bp1, |
|
234 | BP_init_header( &packet_sbm_bp1, | |
235 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, |
|
235 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, | |
236 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
236 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
237 | BP_init_header( &packet_sbm_bp2, |
|
237 | BP_init_header( &packet_sbm_bp2, | |
238 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, |
|
238 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, | |
239 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
239 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
240 | } |
|
240 | } | |
241 | else |
|
241 | else | |
242 | { |
|
242 | { | |
243 | PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) |
|
243 | PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) | |
244 | } |
|
244 | } | |
245 |
|
245 | |||
246 | status = get_message_queue_id_send( &queue_id ); |
|
246 | status = get_message_queue_id_send( &queue_id ); | |
247 | if (status != RTEMS_SUCCESSFUL) |
|
247 | if (status != RTEMS_SUCCESSFUL) | |
248 | { |
|
248 | { | |
249 | PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status) |
|
249 | PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status) | |
250 | } |
|
250 | } | |
251 | status = get_message_queue_id_prc0( &queue_id_q_p0); |
|
251 | status = get_message_queue_id_prc0( &queue_id_q_p0); | |
252 | if (status != RTEMS_SUCCESSFUL) |
|
252 | if (status != RTEMS_SUCCESSFUL) | |
253 | { |
|
253 | { | |
254 | PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status) |
|
254 | PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status) | |
255 | } |
|
255 | } | |
256 |
|
256 | |||
257 | BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
257 | BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
258 |
|
258 | |||
259 | while(1){ |
|
259 | while(1){ | |
260 | status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************ |
|
260 | status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************ | |
261 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 |
|
261 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 | |
262 |
|
262 | |||
263 | incomingMsg = (asm_msg*) incomingData; |
|
263 | incomingMsg = (asm_msg*) incomingData; | |
264 |
|
264 | |||
265 | ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm ); |
|
265 | ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm ); | |
266 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm ); |
|
266 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm ); | |
267 |
|
267 | |||
268 | //**************** |
|
268 | //**************** | |
269 | //**************** |
|
269 | //**************** | |
270 | // BURST SBM1 SBM2 |
|
270 | // BURST SBM1 SBM2 | |
271 | //**************** |
|
271 | //**************** | |
272 | //**************** |
|
272 | //**************** | |
273 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) ) |
|
273 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) ) | |
274 | { |
|
274 | { | |
275 | sid = getSID( incomingMsg->event ); |
|
275 | sid = getSID( incomingMsg->event ); | |
276 | // 1) compress the matrix for Basic Parameters calculation |
|
276 | // 1) compress the matrix for Basic Parameters calculation | |
277 | ASM_compress_reorganize_and_divide( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0, |
|
277 | ASM_compress_reorganize_and_divide( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0, | |
278 | nb_sm_before_f0.burst_sbm_bp1, |
|
278 | nb_sm_before_f0.burst_sbm_bp1, | |
279 | NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, |
|
279 | NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, | |
280 | ASM_F0_INDICE_START); |
|
280 | ASM_F0_INDICE_START); | |
281 | // 2) compute the BP1 set |
|
281 | // 2) compute the BP1 set | |
282 | BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data ); |
|
282 | BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data ); | |
283 | // 3) send the BP1 set |
|
283 | // 3) send the BP1 set | |
284 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
284 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
285 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
285 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
|
286 | packet_sbm_bp1.biaStatusInfo = pa_bia_status_info; | |||
286 | packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
287 | packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
287 | BP_send( (char *) &packet_sbm_bp1, queue_id, |
|
288 | BP_send( (char *) &packet_sbm_bp1, queue_id, | |
288 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA, |
|
289 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA, | |
289 | sid); |
|
290 | sid); | |
290 | // 4) compute the BP2 set if needed |
|
291 | // 4) compute the BP2 set if needed | |
291 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) ) |
|
292 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) ) | |
292 | { |
|
293 | { | |
293 | // 1) compute the BP2 set |
|
294 | // 1) compute the BP2 set | |
294 | BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data ); |
|
295 | BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data ); | |
295 | // 2) send the BP2 set |
|
296 | // 2) send the BP2 set | |
296 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
297 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
297 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
298 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
|
299 | packet_sbm_bp2.biaStatusInfo = pa_bia_status_info; | |||
298 | packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
300 | packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
299 | BP_send( (char *) &packet_sbm_bp2, queue_id, |
|
301 | BP_send( (char *) &packet_sbm_bp2, queue_id, | |
300 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA, |
|
302 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA, | |
301 | sid); |
|
303 | sid); | |
302 | } |
|
304 | } | |
303 | } |
|
305 | } | |
304 |
|
306 | |||
305 | //***** |
|
307 | //***** | |
306 | //***** |
|
308 | //***** | |
307 | // NORM |
|
309 | // NORM | |
308 | //***** |
|
310 | //***** | |
309 | //***** |
|
311 | //***** | |
310 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) |
|
312 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) | |
311 | { |
|
313 | { | |
312 | // 1) compress the matrix for Basic Parameters calculation |
|
314 | // 1) compress the matrix for Basic Parameters calculation | |
313 | ASM_compress_reorganize_and_divide( asm_f0_patched_norm, compressed_sm_norm_f0, |
|
315 | ASM_compress_reorganize_and_divide( asm_f0_patched_norm, compressed_sm_norm_f0, | |
314 | nb_sm_before_f0.norm_bp1, |
|
316 | nb_sm_before_f0.norm_bp1, | |
315 | NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, |
|
317 | NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, | |
316 | ASM_F0_INDICE_START ); |
|
318 | ASM_F0_INDICE_START ); | |
317 | // 2) compute the BP1 set |
|
319 | // 2) compute the BP1 set | |
318 | BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data ); |
|
320 | BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data ); | |
319 | // 3) send the BP1 set |
|
321 | // 3) send the BP1 set | |
320 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
322 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
321 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
323 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
|
324 | packet_norm_bp1.biaStatusInfo = pa_bia_status_info; | |||
322 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
325 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
323 | BP_send( (char *) &packet_norm_bp1, queue_id, |
|
326 | BP_send( (char *) &packet_norm_bp1, queue_id, | |
324 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA, |
|
327 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA, | |
325 | SID_NORM_BP1_F0 ); |
|
328 | SID_NORM_BP1_F0 ); | |
326 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) |
|
329 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) | |
327 | { |
|
330 | { | |
328 | // 1) compute the BP2 set using the same ASM as the one used for BP1 |
|
331 | // 1) compute the BP2 set using the same ASM as the one used for BP1 | |
329 | BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data ); |
|
332 | BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data ); | |
330 | // 2) send the BP2 set |
|
333 | // 2) send the BP2 set | |
331 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
334 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
332 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
335 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
|
336 | packet_norm_bp2.biaStatusInfo = pa_bia_status_info; | |||
333 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
337 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
334 | BP_send( (char *) &packet_norm_bp2, queue_id, |
|
338 | BP_send( (char *) &packet_norm_bp2, queue_id, | |
335 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA, |
|
339 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA, | |
336 | SID_NORM_BP2_F0); |
|
340 | SID_NORM_BP2_F0); | |
337 | } |
|
341 | } | |
338 | } |
|
342 | } | |
339 |
|
343 | |||
340 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) |
|
344 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) | |
341 | { |
|
345 | { | |
342 | // 1) reorganize the ASM and divide |
|
346 | // 1) reorganize the ASM and divide | |
343 | ASM_reorganize_and_divide( asm_f0_patched_norm, |
|
347 | ASM_reorganize_and_divide( asm_f0_patched_norm, | |
344 | (float*) current_ring_node_to_send_asm_f0->buffer_address, |
|
348 | (float*) current_ring_node_to_send_asm_f0->buffer_address, | |
345 | nb_sm_before_f0.norm_bp1 ); |
|
349 | nb_sm_before_f0.norm_bp1 ); | |
346 | current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM; |
|
350 | current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM; | |
347 | current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM; |
|
351 | current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM; | |
348 | current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0; |
|
352 | current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0; | |
349 |
|
353 | |||
350 | // 3) send the spectral matrix packets |
|
354 | // 3) send the spectral matrix packets | |
351 | status = rtems_message_queue_send( queue_id, ¤t_ring_node_to_send_asm_f0, sizeof( ring_node* ) ); |
|
355 | status = rtems_message_queue_send( queue_id, ¤t_ring_node_to_send_asm_f0, sizeof( ring_node* ) ); | |
352 | // change asm ring node |
|
356 | // change asm ring node | |
353 | current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next; |
|
357 | current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next; | |
354 | } |
|
358 | } | |
355 |
|
359 | |||
356 | update_queue_max_count( queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max ); |
|
360 | update_queue_max_count( queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max ); | |
357 |
|
361 | |||
358 | } |
|
362 | } | |
359 | } |
|
363 | } | |
360 |
|
364 | |||
361 | //********** |
|
365 | //********** | |
362 | // FUNCTIONS |
|
366 | // FUNCTIONS | |
363 |
|
367 | |||
364 | void reset_nb_sm_f0( unsigned char lfrMode ) |
|
368 | void reset_nb_sm_f0( unsigned char lfrMode ) | |
365 | { |
|
369 | { | |
366 | nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96; |
|
370 | nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96; | |
367 | nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96; |
|
371 | nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96; | |
368 | nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96; |
|
372 | nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96; | |
369 | nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit |
|
373 | nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit | |
370 | nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96; |
|
374 | nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96; | |
371 | nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96; |
|
375 | nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96; | |
372 | nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96; |
|
376 | nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96; | |
373 | nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96; |
|
377 | nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96; | |
374 | nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96; |
|
378 | nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96; | |
375 |
|
379 | |||
376 | if (lfrMode == LFR_MODE_SBM1) |
|
380 | if (lfrMode == LFR_MODE_SBM1) | |
377 | { |
|
381 | { | |
378 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1; |
|
382 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1; | |
379 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2; |
|
383 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2; | |
380 | } |
|
384 | } | |
381 | else if (lfrMode == LFR_MODE_SBM2) |
|
385 | else if (lfrMode == LFR_MODE_SBM2) | |
382 | { |
|
386 | { | |
383 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1; |
|
387 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1; | |
384 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2; |
|
388 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2; | |
385 | } |
|
389 | } | |
386 | else if (lfrMode == LFR_MODE_BURST) |
|
390 | else if (lfrMode == LFR_MODE_BURST) | |
387 | { |
|
391 | { | |
388 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; |
|
392 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; | |
389 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; |
|
393 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; | |
390 | } |
|
394 | } | |
391 | else |
|
395 | else | |
392 | { |
|
396 | { | |
393 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; |
|
397 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; | |
394 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; |
|
398 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; | |
395 | } |
|
399 | } | |
396 | } |
|
400 | } | |
397 |
|
401 | |||
398 | void init_k_coefficients_prc0( void ) |
|
402 | void init_k_coefficients_prc0( void ) | |
399 | { |
|
403 | { | |
400 | init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 ); |
|
404 | init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 ); | |
401 |
|
405 | |||
402 | init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f0_norm, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_F0); |
|
406 | init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f0_norm, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_F0); | |
403 | } |
|
407 | } | |
404 |
|
408 |
@@ -1,390 +1,394 | |||||
1 | /** Functions related to data processing. |
|
1 | /** Functions related to data processing. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "avf1_prc1.h" |
|
10 | #include "avf1_prc1.h" | |
11 |
|
11 | |||
12 | nb_sm_before_bp_asm_f1 nb_sm_before_f1; |
|
12 | nb_sm_before_bp_asm_f1 nb_sm_before_f1; | |
13 |
|
13 | |||
14 | extern ring_node sm_ring_f1[ ]; |
|
14 | extern ring_node sm_ring_f1[ ]; | |
15 |
|
15 | |||
16 | //*** |
|
16 | //*** | |
17 | // F1 |
|
17 | // F1 | |
18 | ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ]; |
|
18 | ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ]; | |
19 | ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ]; |
|
19 | ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ]; | |
20 |
|
20 | |||
21 | ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ]; |
|
21 | ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ]; | |
22 | int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ]; |
|
22 | int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ]; | |
23 |
|
23 | |||
24 | float asm_f1_patched_norm [ TOTAL_SIZE_SM ]; |
|
24 | float asm_f1_patched_norm [ TOTAL_SIZE_SM ]; | |
25 | float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ]; |
|
25 | float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ]; | |
26 | float asm_f1_reorganized [ TOTAL_SIZE_SM ]; |
|
26 | float asm_f1_reorganized [ TOTAL_SIZE_SM ]; | |
27 |
|
27 | |||
28 | char asm_f1_char [ TOTAL_SIZE_SM * 2 ]; |
|
28 | char asm_f1_char [ TOTAL_SIZE_SM * 2 ]; | |
29 | float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1]; |
|
29 | float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1]; | |
30 | float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ]; |
|
30 | float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ]; | |
31 |
|
31 | |||
32 | float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ]; // 13 * 32 = 416 |
|
32 | float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ]; // 13 * 32 = 416 | |
33 | float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ]; // 26 * 32 = 832 |
|
33 | float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ]; // 26 * 32 = 832 | |
34 |
|
34 | |||
35 | //************ |
|
35 | //************ | |
36 | // RTEMS TASKS |
|
36 | // RTEMS TASKS | |
37 |
|
37 | |||
38 | rtems_task avf1_task( rtems_task_argument lfrRequestedMode ) |
|
38 | rtems_task avf1_task( rtems_task_argument lfrRequestedMode ) | |
39 | { |
|
39 | { | |
40 | int i; |
|
40 | int i; | |
41 |
|
41 | |||
42 | rtems_event_set event_out; |
|
42 | rtems_event_set event_out; | |
43 | rtems_status_code status; |
|
43 | rtems_status_code status; | |
44 | rtems_id queue_id_prc1; |
|
44 | rtems_id queue_id_prc1; | |
45 | asm_msg msgForMATR; |
|
45 | asm_msg msgForMATR; | |
46 | ring_node *nodeForAveraging; |
|
46 | ring_node *nodeForAveraging; | |
47 | ring_node *ring_node_tab[NB_SM_BEFORE_AVF0]; |
|
47 | ring_node *ring_node_tab[NB_SM_BEFORE_AVF0]; | |
48 | ring_node_asm *current_ring_node_asm_burst_sbm_f1; |
|
48 | ring_node_asm *current_ring_node_asm_burst_sbm_f1; | |
49 | ring_node_asm *current_ring_node_asm_norm_f1; |
|
49 | ring_node_asm *current_ring_node_asm_norm_f1; | |
50 |
|
50 | |||
51 | unsigned int nb_norm_bp1; |
|
51 | unsigned int nb_norm_bp1; | |
52 | unsigned int nb_norm_bp2; |
|
52 | unsigned int nb_norm_bp2; | |
53 | unsigned int nb_norm_asm; |
|
53 | unsigned int nb_norm_asm; | |
54 | unsigned int nb_sbm_bp1; |
|
54 | unsigned int nb_sbm_bp1; | |
55 | unsigned int nb_sbm_bp2; |
|
55 | unsigned int nb_sbm_bp2; | |
56 |
|
56 | |||
57 | nb_norm_bp1 = 0; |
|
57 | nb_norm_bp1 = 0; | |
58 | nb_norm_bp2 = 0; |
|
58 | nb_norm_bp2 = 0; | |
59 | nb_norm_asm = 0; |
|
59 | nb_norm_asm = 0; | |
60 | nb_sbm_bp1 = 0; |
|
60 | nb_sbm_bp1 = 0; | |
61 | nb_sbm_bp2 = 0; |
|
61 | nb_sbm_bp2 = 0; | |
62 |
|
62 | |||
63 | reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions |
|
63 | reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions | |
64 | ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 ); |
|
64 | ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 ); | |
65 | ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 ); |
|
65 | ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 ); | |
66 | current_ring_node_asm_norm_f1 = asm_ring_norm_f1; |
|
66 | current_ring_node_asm_norm_f1 = asm_ring_norm_f1; | |
67 | current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1; |
|
67 | current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1; | |
68 |
|
68 | |||
69 | BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
69 | BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
70 |
|
70 | |||
71 | status = get_message_queue_id_prc1( &queue_id_prc1 ); |
|
71 | status = get_message_queue_id_prc1( &queue_id_prc1 ); | |
72 | if (status != RTEMS_SUCCESSFUL) |
|
72 | if (status != RTEMS_SUCCESSFUL) | |
73 | { |
|
73 | { | |
74 | PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status) |
|
74 | PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status) | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | while(1){ |
|
77 | while(1){ | |
78 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
78 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
79 |
|
79 | |||
80 | //**************************************** |
|
80 | //**************************************** | |
81 | // initialize the mesage for the MATR task |
|
81 | // initialize the mesage for the MATR task | |
82 | msgForMATR.norm = current_ring_node_asm_norm_f1; |
|
82 | msgForMATR.norm = current_ring_node_asm_norm_f1; | |
83 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1; |
|
83 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1; | |
84 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task |
|
84 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task | |
85 | // |
|
85 | // | |
86 | //**************************************** |
|
86 | //**************************************** | |
87 |
|
87 | |||
88 | nodeForAveraging = getRingNodeForAveraging( 1 ); |
|
88 | nodeForAveraging = getRingNodeForAveraging( 1 ); | |
89 |
|
89 | |||
90 | ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging; |
|
90 | ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging; | |
91 | for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ ) |
|
91 | for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ ) | |
92 | { |
|
92 | { | |
93 | nodeForAveraging = nodeForAveraging->previous; |
|
93 | nodeForAveraging = nodeForAveraging->previous; | |
94 | ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging; |
|
94 | ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging; | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | // compute the average and store it in the averaged_sm_f1 buffer |
|
97 | // compute the average and store it in the averaged_sm_f1 buffer | |
98 | SM_average( current_ring_node_asm_norm_f1->matrix, |
|
98 | SM_average( current_ring_node_asm_norm_f1->matrix, | |
99 | current_ring_node_asm_burst_sbm_f1->matrix, |
|
99 | current_ring_node_asm_burst_sbm_f1->matrix, | |
100 | ring_node_tab, |
|
100 | ring_node_tab, | |
101 | nb_norm_bp1, nb_sbm_bp1, |
|
101 | nb_norm_bp1, nb_sbm_bp1, | |
102 | &msgForMATR ); |
|
102 | &msgForMATR ); | |
103 |
|
103 | |||
104 | // update nb_average |
|
104 | // update nb_average | |
105 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1; |
|
105 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1; | |
106 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1; |
|
106 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1; | |
107 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1; |
|
107 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1; | |
108 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1; |
|
108 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1; | |
109 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1; |
|
109 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1; | |
110 |
|
110 | |||
111 | if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1) |
|
111 | if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1) | |
112 | { |
|
112 | { | |
113 | nb_sbm_bp1 = 0; |
|
113 | nb_sbm_bp1 = 0; | |
114 | // set another ring for the ASM storage |
|
114 | // set another ring for the ASM storage | |
115 | current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next; |
|
115 | current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next; | |
116 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
116 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
117 | { |
|
117 | { | |
118 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1; |
|
118 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1; | |
119 | } |
|
119 | } | |
120 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) |
|
120 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) | |
121 | { |
|
121 | { | |
122 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1; |
|
122 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1; | |
123 | } |
|
123 | } | |
124 | } |
|
124 | } | |
125 |
|
125 | |||
126 | if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2) |
|
126 | if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2) | |
127 | { |
|
127 | { | |
128 | nb_sbm_bp2 = 0; |
|
128 | nb_sbm_bp2 = 0; | |
129 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
129 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
130 | { |
|
130 | { | |
131 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1; |
|
131 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1; | |
132 | } |
|
132 | } | |
133 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) |
|
133 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) | |
134 | { |
|
134 | { | |
135 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1; |
|
135 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1; | |
136 | } |
|
136 | } | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1) |
|
139 | if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1) | |
140 | { |
|
140 | { | |
141 | nb_norm_bp1 = 0; |
|
141 | nb_norm_bp1 = 0; | |
142 | // set another ring for the ASM storage |
|
142 | // set another ring for the ASM storage | |
143 | current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next; |
|
143 | current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next; | |
144 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
144 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
145 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
145 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
146 | { |
|
146 | { | |
147 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1; |
|
147 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1; | |
148 | } |
|
148 | } | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2) |
|
151 | if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2) | |
152 | { |
|
152 | { | |
153 | nb_norm_bp2 = 0; |
|
153 | nb_norm_bp2 = 0; | |
154 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
154 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
155 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
155 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
156 | { |
|
156 | { | |
157 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1; |
|
157 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1; | |
158 | } |
|
158 | } | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | if (nb_norm_asm == nb_sm_before_f1.norm_asm) |
|
161 | if (nb_norm_asm == nb_sm_before_f1.norm_asm) | |
162 | { |
|
162 | { | |
163 | nb_norm_asm = 0; |
|
163 | nb_norm_asm = 0; | |
164 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
164 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
165 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
165 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
166 | { |
|
166 | { | |
167 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1; |
|
167 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1; | |
168 | } |
|
168 | } | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | //************************* |
|
171 | //************************* | |
172 | // send the message to MATR |
|
172 | // send the message to MATR | |
173 | if (msgForMATR.event != 0x00) |
|
173 | if (msgForMATR.event != 0x00) | |
174 | { |
|
174 | { | |
175 | status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1); |
|
175 | status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1); | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | if (status != RTEMS_SUCCESSFUL) { |
|
178 | if (status != RTEMS_SUCCESSFUL) { | |
179 | PRINTF1("in AVF1 *** Error sending message to PRC1, code %d\n", status) |
|
179 | PRINTF1("in AVF1 *** Error sending message to PRC1, code %d\n", status) | |
180 | } |
|
180 | } | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | rtems_task prc1_task( rtems_task_argument lfrRequestedMode ) |
|
184 | rtems_task prc1_task( rtems_task_argument lfrRequestedMode ) | |
185 | { |
|
185 | { | |
186 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
186 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
187 | size_t size; // size of the incoming TC packet |
|
187 | size_t size; // size of the incoming TC packet | |
188 | asm_msg *incomingMsg; |
|
188 | asm_msg *incomingMsg; | |
189 | // |
|
189 | // | |
190 | unsigned char sid; |
|
190 | unsigned char sid; | |
191 | rtems_status_code status; |
|
191 | rtems_status_code status; | |
192 | rtems_id queue_id_send; |
|
192 | rtems_id queue_id_send; | |
193 | rtems_id queue_id_q_p1; |
|
193 | rtems_id queue_id_q_p1; | |
194 | bp_packet_with_spare packet_norm_bp1; |
|
194 | bp_packet_with_spare packet_norm_bp1; | |
195 | bp_packet packet_norm_bp2; |
|
195 | bp_packet packet_norm_bp2; | |
196 | bp_packet packet_sbm_bp1; |
|
196 | bp_packet packet_sbm_bp1; | |
197 | bp_packet packet_sbm_bp2; |
|
197 | bp_packet packet_sbm_bp2; | |
198 | ring_node *current_ring_node_to_send_asm_f1; |
|
198 | ring_node *current_ring_node_to_send_asm_f1; | |
199 |
|
199 | |||
200 | unsigned long long int localTime; |
|
200 | unsigned long long int localTime; | |
201 |
|
201 | |||
202 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU |
|
202 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU | |
203 | init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM ); |
|
203 | init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM ); | |
204 | current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1; |
|
204 | current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1; | |
205 |
|
205 | |||
206 | //************* |
|
206 | //************* | |
207 | // NORM headers |
|
207 | // NORM headers | |
208 | BP_init_header_with_spare( &packet_norm_bp1, |
|
208 | BP_init_header_with_spare( &packet_norm_bp1, | |
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1, |
|
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1, | |
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 ); |
|
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 ); | |
211 | BP_init_header( &packet_norm_bp2, |
|
211 | BP_init_header( &packet_norm_bp2, | |
212 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1, |
|
212 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1, | |
213 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1); |
|
213 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1); | |
214 |
|
214 | |||
215 | //*********************** |
|
215 | //*********************** | |
216 | // BURST and SBM2 headers |
|
216 | // BURST and SBM2 headers | |
217 | if ( lfrRequestedMode == LFR_MODE_BURST ) |
|
217 | if ( lfrRequestedMode == LFR_MODE_BURST ) | |
218 | { |
|
218 | { | |
219 | BP_init_header( &packet_sbm_bp1, |
|
219 | BP_init_header( &packet_sbm_bp1, | |
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1, |
|
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1, | |
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); |
|
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); | |
222 | BP_init_header( &packet_sbm_bp2, |
|
222 | BP_init_header( &packet_sbm_bp2, | |
223 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1, |
|
223 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1, | |
224 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); |
|
224 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); | |
225 | } |
|
225 | } | |
226 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) |
|
226 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) | |
227 | { |
|
227 | { | |
228 | BP_init_header( &packet_sbm_bp1, |
|
228 | BP_init_header( &packet_sbm_bp1, | |
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1, |
|
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1, | |
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); |
|
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); | |
231 | BP_init_header( &packet_sbm_bp2, |
|
231 | BP_init_header( &packet_sbm_bp2, | |
232 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1, |
|
232 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1, | |
233 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); |
|
233 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); | |
234 | } |
|
234 | } | |
235 | else |
|
235 | else | |
236 | { |
|
236 | { | |
237 | PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) |
|
237 | PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) | |
238 | } |
|
238 | } | |
239 |
|
239 | |||
240 | status = get_message_queue_id_send( &queue_id_send ); |
|
240 | status = get_message_queue_id_send( &queue_id_send ); | |
241 | if (status != RTEMS_SUCCESSFUL) |
|
241 | if (status != RTEMS_SUCCESSFUL) | |
242 | { |
|
242 | { | |
243 | PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status) |
|
243 | PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status) | |
244 | } |
|
244 | } | |
245 | status = get_message_queue_id_prc1( &queue_id_q_p1); |
|
245 | status = get_message_queue_id_prc1( &queue_id_q_p1); | |
246 | if (status != RTEMS_SUCCESSFUL) |
|
246 | if (status != RTEMS_SUCCESSFUL) | |
247 | { |
|
247 | { | |
248 | PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status) |
|
248 | PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status) | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
251 | BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
252 |
|
252 | |||
253 | while(1){ |
|
253 | while(1){ | |
254 | status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************ |
|
254 | status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************ | |
255 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 |
|
255 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 | |
256 |
|
256 | |||
257 | incomingMsg = (asm_msg*) incomingData; |
|
257 | incomingMsg = (asm_msg*) incomingData; | |
258 |
|
258 | |||
259 | ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm ); |
|
259 | ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm ); | |
260 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm ); |
|
260 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm ); | |
261 |
|
261 | |||
262 | localTime = getTimeAsUnsignedLongLongInt( ); |
|
262 | localTime = getTimeAsUnsignedLongLongInt( ); | |
263 | //*********** |
|
263 | //*********** | |
264 | //*********** |
|
264 | //*********** | |
265 | // BURST SBM2 |
|
265 | // BURST SBM2 | |
266 | //*********** |
|
266 | //*********** | |
267 | //*********** |
|
267 | //*********** | |
268 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) ) |
|
268 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) ) | |
269 | { |
|
269 | { | |
270 | sid = getSID( incomingMsg->event ); |
|
270 | sid = getSID( incomingMsg->event ); | |
271 | // 1) compress the matrix for Basic Parameters calculation |
|
271 | // 1) compress the matrix for Basic Parameters calculation | |
272 | ASM_compress_reorganize_and_divide( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1, |
|
272 | ASM_compress_reorganize_and_divide( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1, | |
273 | nb_sm_before_f1.burst_sbm_bp1, |
|
273 | nb_sm_before_f1.burst_sbm_bp1, | |
274 | NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1, |
|
274 | NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1, | |
275 | ASM_F1_INDICE_START); |
|
275 | ASM_F1_INDICE_START); | |
276 | // 2) compute the BP1 set |
|
276 | // 2) compute the BP1 set | |
277 | BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data ); |
|
277 | BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data ); | |
278 | // 3) send the BP1 set |
|
278 | // 3) send the BP1 set | |
279 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
279 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
280 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
280 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
|
281 | packet_sbm_bp1.biaStatusInfo = pa_bia_status_info; | |||
281 | packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
282 | packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
282 | BP_send( (char *) &packet_sbm_bp1, queue_id_send, |
|
283 | BP_send( (char *) &packet_sbm_bp1, queue_id_send, | |
283 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA, |
|
284 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA, | |
284 | sid ); |
|
285 | sid ); | |
285 | // 4) compute the BP2 set if needed |
|
286 | // 4) compute the BP2 set if needed | |
286 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) ) |
|
287 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) ) | |
287 | { |
|
288 | { | |
288 | // 1) compute the BP2 set |
|
289 | // 1) compute the BP2 set | |
289 | BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp2.data ); |
|
290 | BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp2.data ); | |
290 | // 2) send the BP2 set |
|
291 | // 2) send the BP2 set | |
291 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
292 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
292 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
293 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
|
294 | packet_sbm_bp2.biaStatusInfo = pa_bia_status_info; | |||
293 | packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
295 | packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
294 | BP_send( (char *) &packet_sbm_bp2, queue_id_send, |
|
296 | BP_send( (char *) &packet_sbm_bp2, queue_id_send, | |
295 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA, |
|
297 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA, | |
296 | sid ); |
|
298 | sid ); | |
297 | } |
|
299 | } | |
298 | } |
|
300 | } | |
299 |
|
301 | |||
300 | //***** |
|
302 | //***** | |
301 | //***** |
|
303 | //***** | |
302 | // NORM |
|
304 | // NORM | |
303 | //***** |
|
305 | //***** | |
304 | //***** |
|
306 | //***** | |
305 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1) |
|
307 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1) | |
306 | { |
|
308 | { | |
307 | // 1) compress the matrix for Basic Parameters calculation |
|
309 | // 1) compress the matrix for Basic Parameters calculation | |
308 | ASM_compress_reorganize_and_divide( asm_f1_patched_norm, compressed_sm_norm_f1, |
|
310 | ASM_compress_reorganize_and_divide( asm_f1_patched_norm, compressed_sm_norm_f1, | |
309 | nb_sm_before_f1.norm_bp1, |
|
311 | nb_sm_before_f1.norm_bp1, | |
310 | NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1, |
|
312 | NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1, | |
311 | ASM_F1_INDICE_START ); |
|
313 | ASM_F1_INDICE_START ); | |
312 | // 2) compute the BP1 set |
|
314 | // 2) compute the BP1 set | |
313 | BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data ); |
|
315 | BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data ); | |
314 | // 3) send the BP1 set |
|
316 | // 3) send the BP1 set | |
315 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
317 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
316 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
318 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
|
319 | packet_norm_bp1.biaStatusInfo = pa_bia_status_info; | |||
317 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
320 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
318 | BP_send( (char *) &packet_norm_bp1, queue_id_send, |
|
321 | BP_send( (char *) &packet_norm_bp1, queue_id_send, | |
319 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA, |
|
322 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA, | |
320 | SID_NORM_BP1_F1 ); |
|
323 | SID_NORM_BP1_F1 ); | |
321 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1) |
|
324 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1) | |
322 | { |
|
325 | { | |
323 | // 1) compute the BP2 set |
|
326 | // 1) compute the BP2 set | |
324 | BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data ); |
|
327 | BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data ); | |
325 | // 2) send the BP2 set |
|
328 | // 2) send the BP2 set | |
326 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
329 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
327 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
330 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
|
331 | packet_norm_bp2.biaStatusInfo = pa_bia_status_info; | |||
328 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
332 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
329 | BP_send( (char *) &packet_norm_bp2, queue_id_send, |
|
333 | BP_send( (char *) &packet_norm_bp2, queue_id_send, | |
330 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA, |
|
334 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA, | |
331 | SID_NORM_BP2_F1 ); |
|
335 | SID_NORM_BP2_F1 ); | |
332 | } |
|
336 | } | |
333 | } |
|
337 | } | |
334 |
|
338 | |||
335 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1) |
|
339 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1) | |
336 | { |
|
340 | { | |
337 | // 1) reorganize the ASM and divide |
|
341 | // 1) reorganize the ASM and divide | |
338 | ASM_reorganize_and_divide( asm_f1_patched_norm, |
|
342 | ASM_reorganize_and_divide( asm_f1_patched_norm, | |
339 | (float*) current_ring_node_to_send_asm_f1->buffer_address, |
|
343 | (float*) current_ring_node_to_send_asm_f1->buffer_address, | |
340 | nb_sm_before_f1.norm_bp1 ); |
|
344 | nb_sm_before_f1.norm_bp1 ); | |
341 | current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM; |
|
345 | current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM; | |
342 | current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM; |
|
346 | current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM; | |
343 | current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1; |
|
347 | current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1; | |
344 | // 3) send the spectral matrix packets |
|
348 | // 3) send the spectral matrix packets | |
345 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f1, sizeof( ring_node* ) ); |
|
349 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f1, sizeof( ring_node* ) ); | |
346 | // change asm ring node |
|
350 | // change asm ring node | |
347 | current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next; |
|
351 | current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next; | |
348 | } |
|
352 | } | |
349 |
|
353 | |||
350 | update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max ); |
|
354 | update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max ); | |
351 |
|
355 | |||
352 | } |
|
356 | } | |
353 | } |
|
357 | } | |
354 |
|
358 | |||
355 | //********** |
|
359 | //********** | |
356 | // FUNCTIONS |
|
360 | // FUNCTIONS | |
357 |
|
361 | |||
358 | void reset_nb_sm_f1( unsigned char lfrMode ) |
|
362 | void reset_nb_sm_f1( unsigned char lfrMode ) | |
359 | { |
|
363 | { | |
360 | nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16; |
|
364 | nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16; | |
361 | nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16; |
|
365 | nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16; | |
362 | nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16; |
|
366 | nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16; | |
363 | nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16; |
|
367 | nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16; | |
364 | nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16; |
|
368 | nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16; | |
365 | nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16; |
|
369 | nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16; | |
366 | nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16; |
|
370 | nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16; | |
367 |
|
371 | |||
368 | if (lfrMode == LFR_MODE_SBM2) |
|
372 | if (lfrMode == LFR_MODE_SBM2) | |
369 | { |
|
373 | { | |
370 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1; |
|
374 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1; | |
371 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2; |
|
375 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2; | |
372 | } |
|
376 | } | |
373 | else if (lfrMode == LFR_MODE_BURST) |
|
377 | else if (lfrMode == LFR_MODE_BURST) | |
374 | { |
|
378 | { | |
375 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; |
|
379 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; | |
376 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; |
|
380 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; | |
377 | } |
|
381 | } | |
378 | else |
|
382 | else | |
379 | { |
|
383 | { | |
380 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; |
|
384 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; | |
381 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; |
|
385 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; | |
382 | } |
|
386 | } | |
383 | } |
|
387 | } | |
384 |
|
388 | |||
385 | void init_k_coefficients_prc1( void ) |
|
389 | void init_k_coefficients_prc1( void ) | |
386 | { |
|
390 | { | |
387 | init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 ); |
|
391 | init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 ); | |
388 |
|
392 | |||
389 | init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f1_norm, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_F1); |
|
393 | init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f1_norm, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_F1); | |
390 | } |
|
394 | } |
@@ -1,279 +1,281 | |||||
1 | /** Functions related to data processing. |
|
1 | /** Functions related to data processing. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "avf2_prc2.h" |
|
10 | #include "avf2_prc2.h" | |
11 |
|
11 | |||
12 | nb_sm_before_bp_asm_f2 nb_sm_before_f2; |
|
12 | nb_sm_before_bp_asm_f2 nb_sm_before_f2; | |
13 |
|
13 | |||
14 | extern ring_node sm_ring_f2[ ]; |
|
14 | extern ring_node sm_ring_f2[ ]; | |
15 |
|
15 | |||
16 | //*** |
|
16 | //*** | |
17 | // F2 |
|
17 | // F2 | |
18 | ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ]; |
|
18 | ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ]; | |
19 |
|
19 | |||
20 | ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ]; |
|
20 | ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ]; | |
21 | int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ]; |
|
21 | int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ]; | |
22 |
|
22 | |||
23 | float asm_f2_patched_norm [ TOTAL_SIZE_SM ]; |
|
23 | float asm_f2_patched_norm [ TOTAL_SIZE_SM ]; | |
24 | float asm_f2_reorganized [ TOTAL_SIZE_SM ]; |
|
24 | float asm_f2_reorganized [ TOTAL_SIZE_SM ]; | |
25 |
|
25 | |||
26 | char asm_f2_char [ TOTAL_SIZE_SM * 2 ]; |
|
26 | char asm_f2_char [ TOTAL_SIZE_SM * 2 ]; | |
27 | float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2]; |
|
27 | float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2]; | |
28 |
|
28 | |||
29 | float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384 |
|
29 | float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384 | |
30 |
|
30 | |||
31 | //************ |
|
31 | //************ | |
32 | // RTEMS TASKS |
|
32 | // RTEMS TASKS | |
33 |
|
33 | |||
34 | //*** |
|
34 | //*** | |
35 | // F2 |
|
35 | // F2 | |
36 | rtems_task avf2_task( rtems_task_argument argument ) |
|
36 | rtems_task avf2_task( rtems_task_argument argument ) | |
37 | { |
|
37 | { | |
38 | rtems_event_set event_out; |
|
38 | rtems_event_set event_out; | |
39 | rtems_status_code status; |
|
39 | rtems_status_code status; | |
40 | rtems_id queue_id_prc2; |
|
40 | rtems_id queue_id_prc2; | |
41 | asm_msg msgForMATR; |
|
41 | asm_msg msgForMATR; | |
42 | ring_node *nodeForAveraging; |
|
42 | ring_node *nodeForAveraging; | |
43 | ring_node_asm *current_ring_node_asm_norm_f2; |
|
43 | ring_node_asm *current_ring_node_asm_norm_f2; | |
44 |
|
44 | |||
45 | unsigned int nb_norm_bp1; |
|
45 | unsigned int nb_norm_bp1; | |
46 | unsigned int nb_norm_bp2; |
|
46 | unsigned int nb_norm_bp2; | |
47 | unsigned int nb_norm_asm; |
|
47 | unsigned int nb_norm_asm; | |
48 |
|
48 | |||
49 | nb_norm_bp1 = 0; |
|
49 | nb_norm_bp1 = 0; | |
50 | nb_norm_bp2 = 0; |
|
50 | nb_norm_bp2 = 0; | |
51 | nb_norm_asm = 0; |
|
51 | nb_norm_asm = 0; | |
52 |
|
52 | |||
53 | reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions |
|
53 | reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions | |
54 | ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 ); |
|
54 | ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 ); | |
55 | current_ring_node_asm_norm_f2 = asm_ring_norm_f2; |
|
55 | current_ring_node_asm_norm_f2 = asm_ring_norm_f2; | |
56 |
|
56 | |||
57 | BOOT_PRINTF("in AVF2 ***\n") |
|
57 | BOOT_PRINTF("in AVF2 ***\n") | |
58 |
|
58 | |||
59 | status = get_message_queue_id_prc2( &queue_id_prc2 ); |
|
59 | status = get_message_queue_id_prc2( &queue_id_prc2 ); | |
60 | if (status != RTEMS_SUCCESSFUL) |
|
60 | if (status != RTEMS_SUCCESSFUL) | |
61 | { |
|
61 | { | |
62 | PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status) |
|
62 | PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status) | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | while(1){ |
|
65 | while(1){ | |
66 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
66 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
67 |
|
67 | |||
68 | //**************************************** |
|
68 | //**************************************** | |
69 | // initialize the mesage for the MATR task |
|
69 | // initialize the mesage for the MATR task | |
70 | msgForMATR.norm = current_ring_node_asm_norm_f2; |
|
70 | msgForMATR.norm = current_ring_node_asm_norm_f2; | |
71 | msgForMATR.burst_sbm = NULL; |
|
71 | msgForMATR.burst_sbm = NULL; | |
72 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC2 task |
|
72 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC2 task | |
73 | // |
|
73 | // | |
74 | //**************************************** |
|
74 | //**************************************** | |
75 |
|
75 | |||
76 | nodeForAveraging = getRingNodeForAveraging( 2 ); |
|
76 | nodeForAveraging = getRingNodeForAveraging( 2 ); | |
77 |
|
77 | |||
78 | // compute the average and store it in the averaged_sm_f2 buffer |
|
78 | // compute the average and store it in the averaged_sm_f2 buffer | |
79 | SM_average_f2( current_ring_node_asm_norm_f2->matrix, |
|
79 | SM_average_f2( current_ring_node_asm_norm_f2->matrix, | |
80 | nodeForAveraging, |
|
80 | nodeForAveraging, | |
81 | nb_norm_bp1, |
|
81 | nb_norm_bp1, | |
82 | &msgForMATR ); |
|
82 | &msgForMATR ); | |
83 |
|
83 | |||
84 | // update nb_average |
|
84 | // update nb_average | |
85 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2; |
|
85 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2; | |
86 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2; |
|
86 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2; | |
87 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2; |
|
87 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2; | |
88 |
|
88 | |||
89 | if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1) |
|
89 | if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1) | |
90 | { |
|
90 | { | |
91 | nb_norm_bp1 = 0; |
|
91 | nb_norm_bp1 = 0; | |
92 | // set another ring for the ASM storage |
|
92 | // set another ring for the ASM storage | |
93 | current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next; |
|
93 | current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next; | |
94 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
94 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) | |
95 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
95 | || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
96 | { |
|
96 | { | |
97 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2; |
|
97 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2; | |
98 | } |
|
98 | } | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2) |
|
101 | if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2) | |
102 | { |
|
102 | { | |
103 | nb_norm_bp2 = 0; |
|
103 | nb_norm_bp2 = 0; | |
104 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
104 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) | |
105 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
105 | || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
106 | { |
|
106 | { | |
107 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2; |
|
107 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2; | |
108 | } |
|
108 | } | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 | if (nb_norm_asm == nb_sm_before_f2.norm_asm) |
|
111 | if (nb_norm_asm == nb_sm_before_f2.norm_asm) | |
112 | { |
|
112 | { | |
113 | nb_norm_asm = 0; |
|
113 | nb_norm_asm = 0; | |
114 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
114 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) | |
115 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
115 | || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
116 | { |
|
116 | { | |
117 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2; |
|
117 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2; | |
118 | } |
|
118 | } | |
119 | } |
|
119 | } | |
120 |
|
120 | |||
121 | //************************* |
|
121 | //************************* | |
122 | // send the message to MATR |
|
122 | // send the message to MATR | |
123 | if (msgForMATR.event != 0x00) |
|
123 | if (msgForMATR.event != 0x00) | |
124 | { |
|
124 | { | |
125 | status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC2); |
|
125 | status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC2); | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | if (status != RTEMS_SUCCESSFUL) { |
|
128 | if (status != RTEMS_SUCCESSFUL) { | |
129 | PRINTF1("in AVF2 *** Error sending message to MATR, code %d\n", status) |
|
129 | PRINTF1("in AVF2 *** Error sending message to MATR, code %d\n", status) | |
130 | } |
|
130 | } | |
131 | } |
|
131 | } | |
132 | } |
|
132 | } | |
133 |
|
133 | |||
134 | rtems_task prc2_task( rtems_task_argument argument ) |
|
134 | rtems_task prc2_task( rtems_task_argument argument ) | |
135 | { |
|
135 | { | |
136 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
136 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
137 | size_t size; // size of the incoming TC packet |
|
137 | size_t size; // size of the incoming TC packet | |
138 | asm_msg *incomingMsg; |
|
138 | asm_msg *incomingMsg; | |
139 | // |
|
139 | // | |
140 | rtems_status_code status; |
|
140 | rtems_status_code status; | |
141 | rtems_id queue_id_send; |
|
141 | rtems_id queue_id_send; | |
142 | rtems_id queue_id_q_p2; |
|
142 | rtems_id queue_id_q_p2; | |
143 | bp_packet packet_norm_bp1; |
|
143 | bp_packet packet_norm_bp1; | |
144 | bp_packet packet_norm_bp2; |
|
144 | bp_packet packet_norm_bp2; | |
145 | ring_node *current_ring_node_to_send_asm_f2; |
|
145 | ring_node *current_ring_node_to_send_asm_f2; | |
146 |
|
146 | |||
147 | unsigned long long int localTime; |
|
147 | unsigned long long int localTime; | |
148 |
|
148 | |||
149 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU |
|
149 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU | |
150 | init_ring( ring_to_send_asm_f2, NB_RING_NODES_ASM_F2, (volatile int*) buffer_asm_f2, TOTAL_SIZE_SM ); |
|
150 | init_ring( ring_to_send_asm_f2, NB_RING_NODES_ASM_F2, (volatile int*) buffer_asm_f2, TOTAL_SIZE_SM ); | |
151 | current_ring_node_to_send_asm_f2 = ring_to_send_asm_f2; |
|
151 | current_ring_node_to_send_asm_f2 = ring_to_send_asm_f2; | |
152 |
|
152 | |||
153 | //************* |
|
153 | //************* | |
154 | // NORM headers |
|
154 | // NORM headers | |
155 | BP_init_header( &packet_norm_bp1, |
|
155 | BP_init_header( &packet_norm_bp1, | |
156 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2, |
|
156 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2, | |
157 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 ); |
|
157 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 ); | |
158 | BP_init_header( &packet_norm_bp2, |
|
158 | BP_init_header( &packet_norm_bp2, | |
159 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2, |
|
159 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2, | |
160 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 ); |
|
160 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 ); | |
161 |
|
161 | |||
162 | status = get_message_queue_id_send( &queue_id_send ); |
|
162 | status = get_message_queue_id_send( &queue_id_send ); | |
163 | if (status != RTEMS_SUCCESSFUL) |
|
163 | if (status != RTEMS_SUCCESSFUL) | |
164 | { |
|
164 | { | |
165 | PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status) |
|
165 | PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status) | |
166 | } |
|
166 | } | |
167 | status = get_message_queue_id_prc2( &queue_id_q_p2); |
|
167 | status = get_message_queue_id_prc2( &queue_id_q_p2); | |
168 | if (status != RTEMS_SUCCESSFUL) |
|
168 | if (status != RTEMS_SUCCESSFUL) | |
169 | { |
|
169 | { | |
170 | PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status) |
|
170 | PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status) | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | BOOT_PRINTF("in PRC2 ***\n") |
|
173 | BOOT_PRINTF("in PRC2 ***\n") | |
174 |
|
174 | |||
175 | while(1){ |
|
175 | while(1){ | |
176 | status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ |
|
176 | status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ | |
177 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2 |
|
177 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2 | |
178 |
|
178 | |||
179 | incomingMsg = (asm_msg*) incomingData; |
|
179 | incomingMsg = (asm_msg*) incomingData; | |
180 |
|
180 | |||
181 | ASM_patch( incomingMsg->norm->matrix, asm_f2_patched_norm ); |
|
181 | ASM_patch( incomingMsg->norm->matrix, asm_f2_patched_norm ); | |
182 |
|
182 | |||
183 | localTime = getTimeAsUnsignedLongLongInt( ); |
|
183 | localTime = getTimeAsUnsignedLongLongInt( ); | |
184 |
|
184 | |||
185 | //***** |
|
185 | //***** | |
186 | //***** |
|
186 | //***** | |
187 | // NORM |
|
187 | // NORM | |
188 | //***** |
|
188 | //***** | |
189 | //***** |
|
189 | //***** | |
190 | // 1) compress the matrix for Basic Parameters calculation |
|
190 | // 1) compress the matrix for Basic Parameters calculation | |
191 | ASM_compress_reorganize_and_divide( asm_f2_patched_norm, compressed_sm_norm_f2, |
|
191 | ASM_compress_reorganize_and_divide( asm_f2_patched_norm, compressed_sm_norm_f2, | |
192 | nb_sm_before_f2.norm_bp1, |
|
192 | nb_sm_before_f2.norm_bp1, | |
193 | NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, |
|
193 | NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, | |
194 | ASM_F2_INDICE_START ); |
|
194 | ASM_F2_INDICE_START ); | |
195 | // BP1_F2 |
|
195 | // BP1_F2 | |
196 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) |
|
196 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) | |
197 | { |
|
197 | { | |
198 | // 1) compute the BP1 set |
|
198 | // 1) compute the BP1 set | |
199 | BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data ); |
|
199 | BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data ); | |
200 | // 2) send the BP1 set |
|
200 | // 2) send the BP1 set | |
201 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
201 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
202 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
202 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
|
203 | packet_norm_bp1.biaStatusInfo = pa_bia_status_info; | |||
203 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
204 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
204 | BP_send( (char *) &packet_norm_bp1, queue_id_send, |
|
205 | BP_send( (char *) &packet_norm_bp1, queue_id_send, | |
205 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA, |
|
206 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA, | |
206 | SID_NORM_BP1_F2 ); |
|
207 | SID_NORM_BP1_F2 ); | |
207 | } |
|
208 | } | |
208 | // BP2_F2 |
|
209 | // BP2_F2 | |
209 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) |
|
210 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) | |
210 | { |
|
211 | { | |
211 | // 1) compute the BP2 set |
|
212 | // 1) compute the BP2 set | |
212 | BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data ); |
|
213 | BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data ); | |
213 | // 2) send the BP2 set |
|
214 | // 2) send the BP2 set | |
214 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
215 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
215 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
216 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
|
217 | packet_norm_bp2.biaStatusInfo = pa_bia_status_info; | |||
216 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
218 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
217 | BP_send( (char *) &packet_norm_bp2, queue_id_send, |
|
219 | BP_send( (char *) &packet_norm_bp2, queue_id_send, | |
218 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA, |
|
220 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA, | |
219 | SID_NORM_BP2_F2 ); |
|
221 | SID_NORM_BP2_F2 ); | |
220 | } |
|
222 | } | |
221 |
|
223 | |||
222 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) |
|
224 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) | |
223 | { |
|
225 | { | |
224 | // 1) reorganize the ASM and divide |
|
226 | // 1) reorganize the ASM and divide | |
225 | ASM_reorganize_and_divide( asm_f2_patched_norm, |
|
227 | ASM_reorganize_and_divide( asm_f2_patched_norm, | |
226 | (float*) current_ring_node_to_send_asm_f2->buffer_address, |
|
228 | (float*) current_ring_node_to_send_asm_f2->buffer_address, | |
227 | nb_sm_before_f2.norm_bp1 ); |
|
229 | nb_sm_before_f2.norm_bp1 ); | |
228 | current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM; |
|
230 | current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM; | |
229 | current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM; |
|
231 | current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM; | |
230 | current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2; |
|
232 | current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2; | |
231 | // 3) send the spectral matrix packets |
|
233 | // 3) send the spectral matrix packets | |
232 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f2, sizeof( ring_node* ) ); |
|
234 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f2, sizeof( ring_node* ) ); | |
233 | // change asm ring node |
|
235 | // change asm ring node | |
234 | current_ring_node_to_send_asm_f2 = current_ring_node_to_send_asm_f2->next; |
|
236 | current_ring_node_to_send_asm_f2 = current_ring_node_to_send_asm_f2->next; | |
235 | } |
|
237 | } | |
236 |
|
238 | |||
237 | update_queue_max_count( queue_id_q_p2, &hk_lfr_q_p2_fifo_size_max ); |
|
239 | update_queue_max_count( queue_id_q_p2, &hk_lfr_q_p2_fifo_size_max ); | |
238 |
|
240 | |||
239 | } |
|
241 | } | |
240 | } |
|
242 | } | |
241 |
|
243 | |||
242 | //********** |
|
244 | //********** | |
243 | // FUNCTIONS |
|
245 | // FUNCTIONS | |
244 |
|
246 | |||
245 | void reset_nb_sm_f2( void ) |
|
247 | void reset_nb_sm_f2( void ) | |
246 | { |
|
248 | { | |
247 | nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0; |
|
249 | nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0; | |
248 | nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1; |
|
250 | nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1; | |
249 | nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]; |
|
251 | nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]; | |
250 | } |
|
252 | } | |
251 |
|
253 | |||
252 | void SM_average_f2( float *averaged_spec_mat_f2, |
|
254 | void SM_average_f2( float *averaged_spec_mat_f2, | |
253 | ring_node *ring_node, |
|
255 | ring_node *ring_node, | |
254 | unsigned int nbAverageNormF2, |
|
256 | unsigned int nbAverageNormF2, | |
255 | asm_msg *msgForMATR ) |
|
257 | asm_msg *msgForMATR ) | |
256 | { |
|
258 | { | |
257 | float sum; |
|
259 | float sum; | |
258 | unsigned int i; |
|
260 | unsigned int i; | |
259 |
|
261 | |||
260 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
262 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
261 | { |
|
263 | { | |
262 | sum = ( (int *) (ring_node->buffer_address) ) [ i ]; |
|
264 | sum = ( (int *) (ring_node->buffer_address) ) [ i ]; | |
263 | if ( (nbAverageNormF2 == 0) ) |
|
265 | if ( (nbAverageNormF2 == 0) ) | |
264 | { |
|
266 | { | |
265 | averaged_spec_mat_f2[ i ] = sum; |
|
267 | averaged_spec_mat_f2[ i ] = sum; | |
266 | msgForMATR->coarseTimeNORM = ring_node->coarseTime; |
|
268 | msgForMATR->coarseTimeNORM = ring_node->coarseTime; | |
267 | msgForMATR->fineTimeNORM = ring_node->fineTime; |
|
269 | msgForMATR->fineTimeNORM = ring_node->fineTime; | |
268 | } |
|
270 | } | |
269 | else |
|
271 | else | |
270 | { |
|
272 | { | |
271 | averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); |
|
273 | averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); | |
272 | } |
|
274 | } | |
273 | } |
|
275 | } | |
274 | } |
|
276 | } | |
275 |
|
277 | |||
276 | void init_k_coefficients_prc2( void ) |
|
278 | void init_k_coefficients_prc2( void ) | |
277 | { |
|
279 | { | |
278 | init_k_coefficients( k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2); |
|
280 | init_k_coefficients( k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2); | |
279 | } |
|
281 | } |
General Comments 0
You need to be logged in to leave comments.
Login now