##// END OF EJS Templates
3.1.0.3...
paul -
r296:fb16b781e584 R3_plus draft
parent child
Show More
@@ -1,125 +1,125
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options =
3 # CONFIG options =
4 # verbose
4 # verbose
5 # boot_messages
5 # boot_messages
6 # debug_messages
6 # debug_messages
7 # cpu_usage_report
7 # cpu_usage_report
8 # stack_report
8 # stack_report
9 # vhdl_dev
9 # vhdl_dev
10 # debug_tch
10 # debug_tch
11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
12 # debug_watchdog
12 # debug_watchdog
13 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
13 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
14 CONFIG -= qt
14 CONFIG -= qt
15
15
16 include(./sparc.pri)
16 include(./sparc.pri)
17
17
18 INCLUDEPATH += /opt/rtems-4.10/sparc-rtems/leon3/lib/include
18 INCLUDEPATH += /opt/rtems-4.10/sparc-rtems/leon3/lib/include
19
19
20 # flight software version
20 # flight software version
21 SWVERSION=-1-0
21 SWVERSION=-1-0
22 DEFINES += SW_VERSION_N1=3 # major
22 DEFINES += SW_VERSION_N1=3 # major
23 DEFINES += SW_VERSION_N2=1 # minor
23 DEFINES += SW_VERSION_N2=1 # minor
24 DEFINES += SW_VERSION_N3=0 # patch
24 DEFINES += SW_VERSION_N3=0 # patch
25 DEFINES += SW_VERSION_N4=2 # internal
25 DEFINES += SW_VERSION_N4=3 # internal
26
26
27 # <GCOV>
27 # <GCOV>
28 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
28 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
29 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
29 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
30 # </GCOV>
30 # </GCOV>
31
31
32 # <CHANGE BEFORE FLIGHT>
32 # <CHANGE BEFORE FLIGHT>
33 contains( CONFIG, lpp_dpu_destid ) {
33 contains( CONFIG, lpp_dpu_destid ) {
34 DEFINES += LPP_DPU_DESTID
34 DEFINES += LPP_DPU_DESTID
35 }
35 }
36 # </CHANGE BEFORE FLIGHT>
36 # </CHANGE BEFORE FLIGHT>
37
37
38 contains( CONFIG, debug_tch ) {
38 contains( CONFIG, debug_tch ) {
39 DEFINES += DEBUG_TCH
39 DEFINES += DEBUG_TCH
40 }
40 }
41 DEFINES += MSB_FIRST_TCH
41 DEFINES += MSB_FIRST_TCH
42
42
43 contains( CONFIG, vhdl_dev ) {
43 contains( CONFIG, vhdl_dev ) {
44 DEFINES += VHDL_DEV
44 DEFINES += VHDL_DEV
45 }
45 }
46
46
47 contains( CONFIG, verbose ) {
47 contains( CONFIG, verbose ) {
48 DEFINES += PRINT_MESSAGES_ON_CONSOLE
48 DEFINES += PRINT_MESSAGES_ON_CONSOLE
49 }
49 }
50
50
51 contains( CONFIG, debug_messages ) {
51 contains( CONFIG, debug_messages ) {
52 DEFINES += DEBUG_MESSAGES
52 DEFINES += DEBUG_MESSAGES
53 }
53 }
54
54
55 contains( CONFIG, cpu_usage_report ) {
55 contains( CONFIG, cpu_usage_report ) {
56 DEFINES += PRINT_TASK_STATISTICS
56 DEFINES += PRINT_TASK_STATISTICS
57 }
57 }
58
58
59 contains( CONFIG, stack_report ) {
59 contains( CONFIG, stack_report ) {
60 DEFINES += PRINT_STACK_REPORT
60 DEFINES += PRINT_STACK_REPORT
61 }
61 }
62
62
63 contains( CONFIG, boot_messages ) {
63 contains( CONFIG, boot_messages ) {
64 DEFINES += BOOT_MESSAGES
64 DEFINES += BOOT_MESSAGES
65 }
65 }
66
66
67 contains( CONFIG, debug_watchdog ) {
67 contains( CONFIG, debug_watchdog ) {
68 DEFINES += DEBUG_WATCHDOG
68 DEFINES += DEBUG_WATCHDOG
69 }
69 }
70
70
71 #doxygen.target = doxygen
71 #doxygen.target = doxygen
72 #doxygen.commands = doxygen ../doc/Doxyfile
72 #doxygen.commands = doxygen ../doc/Doxyfile
73 #QMAKE_EXTRA_TARGETS += doxygen
73 #QMAKE_EXTRA_TARGETS += doxygen
74
74
75 TARGET = fsw
75 TARGET = fsw
76
76
77 INCLUDEPATH += \
77 INCLUDEPATH += \
78 $${PWD}/../src \
78 $${PWD}/../src \
79 $${PWD}/../header \
79 $${PWD}/../header \
80 $${PWD}/../header/lfr_common_headers \
80 $${PWD}/../header/lfr_common_headers \
81 $${PWD}/../header/processing \
81 $${PWD}/../header/processing \
82 $${PWD}/../LFR_basic-parameters
82 $${PWD}/../LFR_basic-parameters
83
83
84 SOURCES += \
84 SOURCES += \
85 ../src/wf_handler.c \
85 ../src/wf_handler.c \
86 ../src/tc_handler.c \
86 ../src/tc_handler.c \
87 ../src/fsw_misc.c \
87 ../src/fsw_misc.c \
88 ../src/fsw_init.c \
88 ../src/fsw_init.c \
89 ../src/fsw_globals.c \
89 ../src/fsw_globals.c \
90 ../src/fsw_spacewire.c \
90 ../src/fsw_spacewire.c \
91 ../src/tc_load_dump_parameters.c \
91 ../src/tc_load_dump_parameters.c \
92 ../src/tm_lfr_tc_exe.c \
92 ../src/tm_lfr_tc_exe.c \
93 ../src/tc_acceptance.c \
93 ../src/tc_acceptance.c \
94 ../src/processing/fsw_processing.c \
94 ../src/processing/fsw_processing.c \
95 ../src/processing/avf0_prc0.c \
95 ../src/processing/avf0_prc0.c \
96 ../src/processing/avf1_prc1.c \
96 ../src/processing/avf1_prc1.c \
97 ../src/processing/avf2_prc2.c \
97 ../src/processing/avf2_prc2.c \
98 ../src/lfr_cpu_usage_report.c \
98 ../src/lfr_cpu_usage_report.c \
99 ../LFR_basic-parameters/basic_parameters.c
99 ../LFR_basic-parameters/basic_parameters.c
100
100
101 HEADERS += \
101 HEADERS += \
102 ../header/wf_handler.h \
102 ../header/wf_handler.h \
103 ../header/tc_handler.h \
103 ../header/tc_handler.h \
104 ../header/grlib_regs.h \
104 ../header/grlib_regs.h \
105 ../header/fsw_misc.h \
105 ../header/fsw_misc.h \
106 ../header/fsw_init.h \
106 ../header/fsw_init.h \
107 ../header/fsw_spacewire.h \
107 ../header/fsw_spacewire.h \
108 ../header/tc_load_dump_parameters.h \
108 ../header/tc_load_dump_parameters.h \
109 ../header/tm_lfr_tc_exe.h \
109 ../header/tm_lfr_tc_exe.h \
110 ../header/tc_acceptance.h \
110 ../header/tc_acceptance.h \
111 ../header/processing/fsw_processing.h \
111 ../header/processing/fsw_processing.h \
112 ../header/processing/avf0_prc0.h \
112 ../header/processing/avf0_prc0.h \
113 ../header/processing/avf1_prc1.h \
113 ../header/processing/avf1_prc1.h \
114 ../header/processing/avf2_prc2.h \
114 ../header/processing/avf2_prc2.h \
115 ../header/fsw_params_wf_handler.h \
115 ../header/fsw_params_wf_handler.h \
116 ../header/lfr_cpu_usage_report.h \
116 ../header/lfr_cpu_usage_report.h \
117 ../header/lfr_common_headers/ccsds_types.h \
117 ../header/lfr_common_headers/ccsds_types.h \
118 ../header/lfr_common_headers/fsw_params.h \
118 ../header/lfr_common_headers/fsw_params.h \
119 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
119 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
120 ../header/lfr_common_headers/fsw_params_processing.h \
120 ../header/lfr_common_headers/fsw_params_processing.h \
121 ../header/lfr_common_headers/tm_byte_positions.h \
121 ../header/lfr_common_headers/tm_byte_positions.h \
122 ../LFR_basic-parameters/basic_parameters.h \
122 ../LFR_basic-parameters/basic_parameters.h \
123 ../LFR_basic-parameters/basic_parameters_params.h \
123 ../LFR_basic-parameters/basic_parameters_params.h \
124 ../header/GscMemoryLPP.hpp
124 ../header/GscMemoryLPP.hpp
125
125
@@ -1,1599 +1,1599
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 unsigned char previousTimecodeCtr = 0;
25 unsigned char previousTimecodeCtr = 0;
26 unsigned int *grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER);
26 unsigned int *grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER);
27
27
28 //***********
28 //***********
29 // RTEMS TASK
29 // RTEMS TASK
30 rtems_task spiq_task(rtems_task_argument unused)
30 rtems_task spiq_task(rtems_task_argument unused)
31 {
31 {
32 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
32 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
33 *
33 *
34 * @param unused is the starting argument of the RTEMS task
34 * @param unused is the starting argument of the RTEMS task
35 *
35 *
36 */
36 */
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 int linkStatus;
40 int linkStatus;
41
41
42 BOOT_PRINTF("in SPIQ *** \n")
42 BOOT_PRINTF("in SPIQ *** \n")
43
43
44 while(true){
44 while(true){
45 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
45 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
46 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
46 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
47
47
48 // [0] SUSPEND RECV AND SEND TASKS
48 // [0] SUSPEND RECV AND SEND TASKS
49 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
49 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
50 if ( status != RTEMS_SUCCESSFUL ) {
50 if ( status != RTEMS_SUCCESSFUL ) {
51 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
51 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
52 }
52 }
53 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
53 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
54 if ( status != RTEMS_SUCCESSFUL ) {
54 if ( status != RTEMS_SUCCESSFUL ) {
55 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
55 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
56 }
56 }
57
57
58 // [1] CHECK THE LINK
58 // [1] CHECK THE LINK
59 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
59 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
60 if ( linkStatus != 5) {
60 if ( linkStatus != 5) {
61 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
61 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
62 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
62 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
63 }
63 }
64
64
65 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
65 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
66 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
66 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
67 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
67 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
68 {
68 {
69 spacewire_read_statistics();
69 spacewire_read_statistics();
70 status = spacewire_several_connect_attemps( );
70 status = spacewire_several_connect_attemps( );
71 }
71 }
72 else // [2.b] in run state, start the link
72 else // [2.b] in run state, start the link
73 {
73 {
74 status = spacewire_stop_and_start_link( fdSPW ); // start the link
74 status = spacewire_stop_and_start_link( fdSPW ); // start the link
75 if ( status != RTEMS_SUCCESSFUL)
75 if ( status != RTEMS_SUCCESSFUL)
76 {
76 {
77 PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status)
77 PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status)
78 }
78 }
79 }
79 }
80
80
81 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
81 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
82 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
82 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
83 {
83 {
84 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
84 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
85 if ( status != RTEMS_SUCCESSFUL ) {
85 if ( status != RTEMS_SUCCESSFUL ) {
86 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
86 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
87 }
87 }
88 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
88 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
89 if ( status != RTEMS_SUCCESSFUL ) {
89 if ( status != RTEMS_SUCCESSFUL ) {
90 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
90 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
91 }
91 }
92 }
92 }
93 else // [3.b] the link is not in run state, go in STANDBY mode
93 else // [3.b] the link is not in run state, go in STANDBY mode
94 {
94 {
95 status = enter_mode_standby();
95 status = enter_mode_standby();
96 if ( status != RTEMS_SUCCESSFUL )
96 if ( status != RTEMS_SUCCESSFUL )
97 {
97 {
98 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
98 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
99 }
99 }
100 {
100 {
101 updateLFRCurrentMode( LFR_MODE_STANDBY );
101 updateLFRCurrentMode( LFR_MODE_STANDBY );
102 }
102 }
103 // wake the LINK task up to wait for the link recovery
103 // wake the LINK task up to wait for the link recovery
104 status = rtems_event_send ( Task_id[TASKID_LINK], RTEMS_EVENT_0 );
104 status = rtems_event_send ( Task_id[TASKID_LINK], RTEMS_EVENT_0 );
105 status = rtems_task_suspend( RTEMS_SELF );
105 status = rtems_task_suspend( RTEMS_SELF );
106 }
106 }
107 }
107 }
108 }
108 }
109
109
110 rtems_task recv_task( rtems_task_argument unused )
110 rtems_task recv_task( rtems_task_argument unused )
111 {
111 {
112 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
112 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
113 *
113 *
114 * @param unused is the starting argument of the RTEMS task
114 * @param unused is the starting argument of the RTEMS task
115 *
115 *
116 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
116 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
117 * 1. It reads the incoming data.
117 * 1. It reads the incoming data.
118 * 2. Launches the acceptance procedure.
118 * 2. Launches the acceptance procedure.
119 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
119 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
120 *
120 *
121 */
121 */
122
122
123 int len;
123 int len;
124 ccsdsTelecommandPacket_t currentTC;
124 ccsdsTelecommandPacket_t currentTC;
125 unsigned char computed_CRC[ 2 ];
125 unsigned char computed_CRC[ 2 ];
126 unsigned char currentTC_LEN_RCV[ 2 ];
126 unsigned char currentTC_LEN_RCV[ 2 ];
127 unsigned char destinationID;
127 unsigned char destinationID;
128 unsigned int estimatedPacketLength;
128 unsigned int estimatedPacketLength;
129 unsigned int parserCode;
129 unsigned int parserCode;
130 rtems_status_code status;
130 rtems_status_code status;
131 rtems_id queue_recv_id;
131 rtems_id queue_recv_id;
132 rtems_id queue_send_id;
132 rtems_id queue_send_id;
133
133
134 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
134 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
135
135
136 status = get_message_queue_id_recv( &queue_recv_id );
136 status = get_message_queue_id_recv( &queue_recv_id );
137 if (status != RTEMS_SUCCESSFUL)
137 if (status != RTEMS_SUCCESSFUL)
138 {
138 {
139 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
139 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
140 }
140 }
141
141
142 status = get_message_queue_id_send( &queue_send_id );
142 status = get_message_queue_id_send( &queue_send_id );
143 if (status != RTEMS_SUCCESSFUL)
143 if (status != RTEMS_SUCCESSFUL)
144 {
144 {
145 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
145 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
146 }
146 }
147
147
148 BOOT_PRINTF("in RECV *** \n")
148 BOOT_PRINTF("in RECV *** \n")
149
149
150 while(1)
150 while(1)
151 {
151 {
152 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
152 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
153 if (len == -1){ // error during the read call
153 if (len == -1){ // error during the read call
154 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
154 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
155 }
155 }
156 else {
156 else {
157 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
157 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
158 PRINTF("in RECV *** packet lenght too short\n")
158 PRINTF("in RECV *** packet lenght too short\n")
159 }
159 }
160 else {
160 else {
161 PRINTF1("incoming TC with len: %d\n", len);
161 // PRINTF1("incoming TC with len: %d\n", len);
162 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
162 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
163 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
163 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
164 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
164 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
165 // CHECK THE TC
165 // CHECK THE TC
166 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
166 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
167 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
167 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
168 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
168 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
169 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
169 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
170 || (parserCode == WRONG_SRC_ID) )
170 || (parserCode == WRONG_SRC_ID) )
171 { // send TM_LFR_TC_EXE_CORRUPTED
171 { // send TM_LFR_TC_EXE_CORRUPTED
172 PRINTF1("TC corrupted received, with code: %d\n", parserCode);
172 PRINTF1("TC corrupted received, with code: %d\n", parserCode);
173 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
173 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
174 &&
174 &&
175 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
175 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
176 )
176 )
177 {
177 {
178 if ( parserCode == WRONG_SRC_ID )
178 if ( parserCode == WRONG_SRC_ID )
179 {
179 {
180 destinationID = SID_TC_GROUND;
180 destinationID = SID_TC_GROUND;
181 }
181 }
182 else
182 else
183 {
183 {
184 destinationID = currentTC.sourceID;
184 destinationID = currentTC.sourceID;
185 }
185 }
186 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
186 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
187 computed_CRC, currentTC_LEN_RCV,
187 computed_CRC, currentTC_LEN_RCV,
188 destinationID );
188 destinationID );
189 }
189 }
190 }
190 }
191 else
191 else
192 { // send valid TC to the action launcher
192 { // send valid TC to the action launcher
193 status = rtems_message_queue_send( queue_recv_id, &currentTC,
193 status = rtems_message_queue_send( queue_recv_id, &currentTC,
194 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
194 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
195 }
195 }
196 }
196 }
197 }
197 }
198
198
199 update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max );
199 update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max );
200
200
201 }
201 }
202 }
202 }
203
203
204 rtems_task send_task( rtems_task_argument argument)
204 rtems_task send_task( rtems_task_argument argument)
205 {
205 {
206 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
206 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
207 *
207 *
208 * @param unused is the starting argument of the RTEMS task
208 * @param unused is the starting argument of the RTEMS task
209 *
209 *
210 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
210 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
211 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
211 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
212 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
212 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
213 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
213 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
214 * data it contains.
214 * data it contains.
215 *
215 *
216 */
216 */
217
217
218 rtems_status_code status; // RTEMS status code
218 rtems_status_code status; // RTEMS status code
219 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
219 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
220 ring_node *incomingRingNodePtr;
220 ring_node *incomingRingNodePtr;
221 int ring_node_address;
221 int ring_node_address;
222 char *charPtr;
222 char *charPtr;
223 spw_ioctl_pkt_send *spw_ioctl_send;
223 spw_ioctl_pkt_send *spw_ioctl_send;
224 size_t size; // size of the incoming TC packet
224 size_t size; // size of the incoming TC packet
225 rtems_id queue_send_id;
225 rtems_id queue_send_id;
226 unsigned int sid;
226 unsigned int sid;
227 unsigned char sidAsUnsignedChar;
227 unsigned char sidAsUnsignedChar;
228 unsigned char type;
228 unsigned char type;
229
229
230 incomingRingNodePtr = NULL;
230 incomingRingNodePtr = NULL;
231 ring_node_address = 0;
231 ring_node_address = 0;
232 charPtr = (char *) &ring_node_address;
232 charPtr = (char *) &ring_node_address;
233 sid = 0;
233 sid = 0;
234 sidAsUnsignedChar = 0;
234 sidAsUnsignedChar = 0;
235
235
236 init_header_cwf( &headerCWF );
236 init_header_cwf( &headerCWF );
237 init_header_swf( &headerSWF );
237 init_header_swf( &headerSWF );
238 init_header_asm( &headerASM );
238 init_header_asm( &headerASM );
239
239
240 status = get_message_queue_id_send( &queue_send_id );
240 status = get_message_queue_id_send( &queue_send_id );
241 if (status != RTEMS_SUCCESSFUL)
241 if (status != RTEMS_SUCCESSFUL)
242 {
242 {
243 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
243 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
244 }
244 }
245
245
246 BOOT_PRINTF("in SEND *** \n")
246 BOOT_PRINTF("in SEND *** \n")
247
247
248 while(1)
248 while(1)
249 {
249 {
250 status = rtems_message_queue_receive( queue_send_id, incomingData, &size,
250 status = rtems_message_queue_receive( queue_send_id, incomingData, &size,
251 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
251 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
252
252
253 if (status!=RTEMS_SUCCESSFUL)
253 if (status!=RTEMS_SUCCESSFUL)
254 {
254 {
255 PRINTF1("in SEND *** (1) ERR = %d\n", status)
255 PRINTF1("in SEND *** (1) ERR = %d\n", status)
256 }
256 }
257 else
257 else
258 {
258 {
259 if ( size == sizeof(ring_node*) )
259 if ( size == sizeof(ring_node*) )
260 {
260 {
261 charPtr[0] = incomingData[0];
261 charPtr[0] = incomingData[0];
262 charPtr[1] = incomingData[1];
262 charPtr[1] = incomingData[1];
263 charPtr[2] = incomingData[2];
263 charPtr[2] = incomingData[2];
264 charPtr[3] = incomingData[3];
264 charPtr[3] = incomingData[3];
265 incomingRingNodePtr = (ring_node*) ring_node_address;
265 incomingRingNodePtr = (ring_node*) ring_node_address;
266 sid = incomingRingNodePtr->sid;
266 sid = incomingRingNodePtr->sid;
267 if ( (sid==SID_NORM_CWF_LONG_F3)
267 if ( (sid==SID_NORM_CWF_LONG_F3)
268 || (sid==SID_BURST_CWF_F2 )
268 || (sid==SID_BURST_CWF_F2 )
269 || (sid==SID_SBM1_CWF_F1 )
269 || (sid==SID_SBM1_CWF_F1 )
270 || (sid==SID_SBM2_CWF_F2 ))
270 || (sid==SID_SBM2_CWF_F2 ))
271 {
271 {
272 spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF );
272 spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF );
273 }
273 }
274 else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) )
274 else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) )
275 {
275 {
276 spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF );
276 spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF );
277 }
277 }
278 else if ( (sid==SID_NORM_CWF_F3) )
278 else if ( (sid==SID_NORM_CWF_F3) )
279 {
279 {
280 spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF );
280 spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF );
281 }
281 }
282 else if (sid==SID_NORM_ASM_F0)
282 else if (sid==SID_NORM_ASM_F0)
283 {
283 {
284 spw_send_asm_f0( incomingRingNodePtr, &headerASM );
284 spw_send_asm_f0( incomingRingNodePtr, &headerASM );
285 }
285 }
286 else if (sid==SID_NORM_ASM_F1)
286 else if (sid==SID_NORM_ASM_F1)
287 {
287 {
288 spw_send_asm_f1( incomingRingNodePtr, &headerASM );
288 spw_send_asm_f1( incomingRingNodePtr, &headerASM );
289 }
289 }
290 else if (sid==SID_NORM_ASM_F2)
290 else if (sid==SID_NORM_ASM_F2)
291 {
291 {
292 spw_send_asm_f2( incomingRingNodePtr, &headerASM );
292 spw_send_asm_f2( incomingRingNodePtr, &headerASM );
293 }
293 }
294 else if ( sid==TM_CODE_K_DUMP )
294 else if ( sid==TM_CODE_K_DUMP )
295 {
295 {
296 spw_send_k_dump( incomingRingNodePtr );
296 spw_send_k_dump( incomingRingNodePtr );
297 }
297 }
298 else
298 else
299 {
299 {
300 PRINTF1("unexpected sid = %d\n", sid);
300 PRINTF1("unexpected sid = %d\n", sid);
301 }
301 }
302 }
302 }
303 else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet
303 else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet
304 {
304 {
305 sidAsUnsignedChar = (unsigned char) incomingData[ PACKET_POS_PA_LFR_SID_PKT ];
305 sidAsUnsignedChar = (unsigned char) incomingData[ PACKET_POS_PA_LFR_SID_PKT ];
306 sid = sidAsUnsignedChar;
306 sid = sidAsUnsignedChar;
307 type = (unsigned char) incomingData[ PACKET_POS_SERVICE_TYPE ];
307 type = (unsigned char) incomingData[ PACKET_POS_SERVICE_TYPE ];
308 if (type == TM_TYPE_LFR_SCIENCE) // this is a BP packet, all other types are handled differently
308 if (type == TM_TYPE_LFR_SCIENCE) // this is a BP packet, all other types are handled differently
309 // SET THE SEQUENCE_CNT PARAMETER IN CASE OF BP0 OR BP1 PACKETS
309 // SET THE SEQUENCE_CNT PARAMETER IN CASE OF BP0 OR BP1 PACKETS
310 {
310 {
311 increment_seq_counter_source_id( (unsigned char*) &incomingData[ PACKET_POS_SEQUENCE_CNT ], sid );
311 increment_seq_counter_source_id( (unsigned char*) &incomingData[ PACKET_POS_SEQUENCE_CNT ], sid );
312 }
312 }
313
313
314 status = write( fdSPW, incomingData, size );
314 status = write( fdSPW, incomingData, size );
315 if (status == -1){
315 if (status == -1){
316 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
316 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
317 }
317 }
318 }
318 }
319 else // the incoming message is a spw_ioctl_pkt_send structure
319 else // the incoming message is a spw_ioctl_pkt_send structure
320 {
320 {
321 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
321 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
322 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
322 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
323 if (status == -1){
323 if (status == -1){
324 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
324 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
325 }
325 }
326 }
326 }
327 }
327 }
328
328
329 update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max );
329 update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max );
330
330
331 }
331 }
332 }
332 }
333
333
334 rtems_task link_task( rtems_task_argument argument )
334 rtems_task link_task( rtems_task_argument argument )
335 {
335 {
336 rtems_event_set event_out;
336 rtems_event_set event_out;
337 rtems_status_code status;
337 rtems_status_code status;
338 int linkStatus;
338 int linkStatus;
339
339
340 BOOT_PRINTF("in LINK ***\n")
340 BOOT_PRINTF("in LINK ***\n")
341
341
342 while(1)
342 while(1)
343 {
343 {
344 // wait for an RTEMS_EVENT
344 // wait for an RTEMS_EVENT
345 rtems_event_receive( RTEMS_EVENT_0,
345 rtems_event_receive( RTEMS_EVENT_0,
346 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
346 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
347 PRINTF("in LINK *** wait for the link\n")
347 PRINTF("in LINK *** wait for the link\n")
348 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
348 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
349 while( linkStatus != 5) // wait for the link
349 while( linkStatus != 5) // wait for the link
350 {
350 {
351 status = rtems_task_wake_after( 10 ); // monitor the link each 100ms
351 status = rtems_task_wake_after( 10 ); // monitor the link each 100ms
352 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
352 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
353 watchdog_reload();
353 watchdog_reload();
354 }
354 }
355
355
356 spacewire_read_statistics();
356 spacewire_read_statistics();
357 status = spacewire_stop_and_start_link( fdSPW );
357 status = spacewire_stop_and_start_link( fdSPW );
358
358
359 if (status != RTEMS_SUCCESSFUL)
359 if (status != RTEMS_SUCCESSFUL)
360 {
360 {
361 PRINTF1("in LINK *** ERR link not started %d\n", status)
361 PRINTF1("in LINK *** ERR link not started %d\n", status)
362 }
362 }
363 else
363 else
364 {
364 {
365 PRINTF("in LINK *** OK link started\n")
365 PRINTF("in LINK *** OK link started\n")
366 }
366 }
367
367
368 // restart the SPIQ task
368 // restart the SPIQ task
369 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
369 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
370 if ( status != RTEMS_SUCCESSFUL ) {
370 if ( status != RTEMS_SUCCESSFUL ) {
371 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
371 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
372 }
372 }
373
373
374 // restart RECV and SEND
374 // restart RECV and SEND
375 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
375 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
376 if ( status != RTEMS_SUCCESSFUL ) {
376 if ( status != RTEMS_SUCCESSFUL ) {
377 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
377 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
378 }
378 }
379 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
379 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
380 if ( status != RTEMS_SUCCESSFUL ) {
380 if ( status != RTEMS_SUCCESSFUL ) {
381 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
381 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
382 }
382 }
383 }
383 }
384 }
384 }
385
385
386 //****************
386 //****************
387 // OTHER FUNCTIONS
387 // OTHER FUNCTIONS
388 int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);]
388 int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);]
389 {
389 {
390 /** This function opens the SpaceWire link.
390 /** This function opens the SpaceWire link.
391 *
391 *
392 * @return a valid file descriptor in case of success, -1 in case of a failure
392 * @return a valid file descriptor in case of success, -1 in case of a failure
393 *
393 *
394 */
394 */
395 rtems_status_code status;
395 rtems_status_code status;
396
396
397 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
397 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
398 if ( fdSPW < 0 ) {
398 if ( fdSPW < 0 ) {
399 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
399 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
400 }
400 }
401 else
401 else
402 {
402 {
403 status = RTEMS_SUCCESSFUL;
403 status = RTEMS_SUCCESSFUL;
404 }
404 }
405
405
406 return status;
406 return status;
407 }
407 }
408
408
409 int spacewire_start_link( int fd )
409 int spacewire_start_link( int fd )
410 {
410 {
411 rtems_status_code status;
411 rtems_status_code status;
412
412
413 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
413 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
414 // -1 default hardcoded driver timeout
414 // -1 default hardcoded driver timeout
415
415
416 return status;
416 return status;
417 }
417 }
418
418
419 int spacewire_stop_and_start_link( int fd )
419 int spacewire_stop_and_start_link( int fd )
420 {
420 {
421 rtems_status_code status;
421 rtems_status_code status;
422
422
423 status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
423 status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
424 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
424 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
425 // -1 default hardcoded driver timeout
425 // -1 default hardcoded driver timeout
426
426
427 return status;
427 return status;
428 }
428 }
429
429
430 int spacewire_configure_link( int fd )
430 int spacewire_configure_link( int fd )
431 {
431 {
432 /** This function configures the SpaceWire link.
432 /** This function configures the SpaceWire link.
433 *
433 *
434 * @return GR-RTEMS-DRIVER directive status codes:
434 * @return GR-RTEMS-DRIVER directive status codes:
435 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
435 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
436 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
436 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
437 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
437 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
438 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
438 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
439 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
439 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
440 * - 5 EIO - Error when writing to grswp hardware registers.
440 * - 5 EIO - Error when writing to grswp hardware registers.
441 * - 2 ENOENT - No such file or directory
441 * - 2 ENOENT - No such file or directory
442 */
442 */
443
443
444 rtems_status_code status;
444 rtems_status_code status;
445
445
446 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
446 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
447 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
447 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
448
448
449 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
449 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
450 if (status!=RTEMS_SUCCESSFUL) {
450 if (status!=RTEMS_SUCCESSFUL) {
451 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
451 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
452 }
452 }
453 //
453 //
454 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
454 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
455 if (status!=RTEMS_SUCCESSFUL) {
455 if (status!=RTEMS_SUCCESSFUL) {
456 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
456 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
457 }
457 }
458 //
458 //
459 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
459 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
460 if (status!=RTEMS_SUCCESSFUL) {
460 if (status!=RTEMS_SUCCESSFUL) {
461 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
461 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
462 }
462 }
463 //
463 //
464 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
464 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
465 if (status!=RTEMS_SUCCESSFUL) {
465 if (status!=RTEMS_SUCCESSFUL) {
466 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
466 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
467 }
467 }
468 //
468 //
469