##// END OF EJS Templates
enter_mode removed...
paul -
r237:b287f3b429dd R3
parent child
Show More
@@ -1,112 +1,112
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 cpu_usage_report
5 CONFIG += console verbose lpp_dpu_destid cpu_usage_report stack_report
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=12 # internal
15 DEFINES += SW_VERSION_N4=12 # 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 # </GCOV>
20 # </GCOV>
21
21
22 # <CHANGE BEFORE FLIGHT>
22 # <CHANGE BEFORE FLIGHT>
23 contains( CONFIG, lpp_dpu_destid ) {
23 contains( CONFIG, lpp_dpu_destid ) {
24 DEFINES += LPP_DPU_DESTID
24 DEFINES += LPP_DPU_DESTID
25 }
25 }
26 # </CHANGE BEFORE FLIGHT>
26 # </CHANGE BEFORE FLIGHT>
27
27
28 contains( CONFIG, debug_tch ) {
28 contains( CONFIG, debug_tch ) {
29 DEFINES += DEBUG_TCH
29 DEFINES += DEBUG_TCH
30 }
30 }
31 DEFINES += MSB_FIRST_TCH
31 DEFINES += MSB_FIRST_TCH
32
32
33 contains( CONFIG, vhdl_dev ) {
33 contains( CONFIG, vhdl_dev ) {
34 DEFINES += VHDL_DEV
34 DEFINES += VHDL_DEV
35 }
35 }
36
36
37 contains( CONFIG, verbose ) {
37 contains( CONFIG, verbose ) {
38 DEFINES += PRINT_MESSAGES_ON_CONSOLE
38 DEFINES += PRINT_MESSAGES_ON_CONSOLE
39 }
39 }
40
40
41 contains( CONFIG, debug_messages ) {
41 contains( CONFIG, debug_messages ) {
42 DEFINES += DEBUG_MESSAGES
42 DEFINES += DEBUG_MESSAGES
43 }
43 }
44
44
45 contains( CONFIG, cpu_usage_report ) {
45 contains( CONFIG, cpu_usage_report ) {
46 DEFINES += PRINT_TASK_STATISTICS
46 DEFINES += PRINT_TASK_STATISTICS
47 }
47 }
48
48
49 contains( CONFIG, stack_report ) {
49 contains( CONFIG, stack_report ) {
50 DEFINES += PRINT_STACK_REPORT
50 DEFINES += PRINT_STACK_REPORT
51 }
51 }
52
52
53 contains( CONFIG, boot_messages ) {
53 contains( CONFIG, boot_messages ) {
54 DEFINES += BOOT_MESSAGES
54 DEFINES += BOOT_MESSAGES
55 }
55 }
56
56
57 #doxygen.target = doxygen
57 #doxygen.target = doxygen
58 #doxygen.commands = doxygen ../doc/Doxyfile
58 #doxygen.commands = doxygen ../doc/Doxyfile
59 #QMAKE_EXTRA_TARGETS += doxygen
59 #QMAKE_EXTRA_TARGETS += doxygen
60
60
61 TARGET = fsw
61 TARGET = fsw
62
62
63 INCLUDEPATH += \
63 INCLUDEPATH += \
64 $${PWD}/../src \
64 $${PWD}/../src \
65 $${PWD}/../header \
65 $${PWD}/../header \
66 $${PWD}/../header/lfr_common_headers \
66 $${PWD}/../header/lfr_common_headers \
67 $${PWD}/../header/processing \
67 $${PWD}/../header/processing \
68 $${PWD}/../LFR_basic-parameters
68 $${PWD}/../LFR_basic-parameters
69
69
70 SOURCES += \
70 SOURCES += \
71 ../src/wf_handler.c \
71 ../src/wf_handler.c \
72 ../src/tc_handler.c \
72 ../src/tc_handler.c \
73 ../src/fsw_misc.c \
73 ../src/fsw_misc.c \
74 ../src/fsw_init.c \
74 ../src/fsw_init.c \
75 ../src/fsw_globals.c \
75 ../src/fsw_globals.c \
76 ../src/fsw_spacewire.c \
76 ../src/fsw_spacewire.c \
77 ../src/tc_load_dump_parameters.c \
77 ../src/tc_load_dump_parameters.c \
78 ../src/tm_lfr_tc_exe.c \
78 ../src/tm_lfr_tc_exe.c \
79 ../src/tc_acceptance.c \
79 ../src/tc_acceptance.c \
80 ../src/processing/fsw_processing.c \
80 ../src/processing/fsw_processing.c \
81 ../src/processing/avf0_prc0.c \
81 ../src/processing/avf0_prc0.c \
82 ../src/processing/avf1_prc1.c \
82 ../src/processing/avf1_prc1.c \
83 ../src/processing/avf2_prc2.c \
83 ../src/processing/avf2_prc2.c \
84 ../src/lfr_cpu_usage_report.c \
84 ../src/lfr_cpu_usage_report.c \
85 ../LFR_basic-parameters/basic_parameters.c
85 ../LFR_basic-parameters/basic_parameters.c
86
86
87 HEADERS += \
87 HEADERS += \
88 ../header/wf_handler.h \
88 ../header/wf_handler.h \
89 ../header/tc_handler.h \
89 ../header/tc_handler.h \
90 ../header/grlib_regs.h \
90 ../header/grlib_regs.h \
91 ../header/fsw_misc.h \
91 ../header/fsw_misc.h \
92 ../header/fsw_init.h \
92 ../header/fsw_init.h \
93 ../header/fsw_spacewire.h \
93 ../header/fsw_spacewire.h \
94 ../header/tc_load_dump_parameters.h \
94 ../header/tc_load_dump_parameters.h \
95 ../header/tm_lfr_tc_exe.h \
95 ../header/tm_lfr_tc_exe.h \
96 ../header/tc_acceptance.h \
96 ../header/tc_acceptance.h \
97 ../header/processing/fsw_processing.h \
97 ../header/processing/fsw_processing.h \
98 ../header/processing/avf0_prc0.h \
98 ../header/processing/avf0_prc0.h \
99 ../header/processing/avf1_prc1.h \
99 ../header/processing/avf1_prc1.h \
100 ../header/processing/avf2_prc2.h \
100 ../header/processing/avf2_prc2.h \
101 ../header/fsw_params_wf_handler.h \
101 ../header/fsw_params_wf_handler.h \
102 ../header/lfr_cpu_usage_report.h \
102 ../header/lfr_cpu_usage_report.h \
103 ../header/lfr_common_headers/ccsds_types.h \
103 ../header/lfr_common_headers/ccsds_types.h \
104 ../header/lfr_common_headers/fsw_params.h \
104 ../header/lfr_common_headers/fsw_params.h \
105 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
105 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
106 ../header/lfr_common_headers/fsw_params_processing.h \
106 ../header/lfr_common_headers/fsw_params_processing.h \
107 ../header/lfr_common_headers/TC_types.h \
107 ../header/lfr_common_headers/TC_types.h \
108 ../header/lfr_common_headers/tm_byte_positions.h \
108 ../header/lfr_common_headers/tm_byte_positions.h \
109 ../LFR_basic-parameters/basic_parameters.h \
109 ../LFR_basic-parameters/basic_parameters.h \
110 ../LFR_basic-parameters/basic_parameters_params.h \
110 ../LFR_basic-parameters/basic_parameters_params.h \
111 ../header/GscMemoryLPP.hpp
111 ../header/GscMemoryLPP.hpp
112
112
@@ -1,97 +1,97
1 CONFIG += console
1 CONFIG += console
2 CONFIG -= qt
2 CONFIG -= qt
3 QMAKE_CC=sparc-rtems-gcc
3 QMAKE_CC=sparc-rtems-gcc
4 message(C compiler forced to: $$QMAKE_CC)
4 message(C compiler forced to: $$QMAKE_CC)
5 QMAKE_CXX=sparc-rtems-g++
5 QMAKE_CXX=sparc-rtems-g++
6 message(C++ compiler forced to: $$QMAKE_CXX)
6 message(C++ compiler forced to: $$QMAKE_CXX)
7 QMAKE_AR=sparc-rtems-ar rcs
7 QMAKE_AR=sparc-rtems-ar rcs
8 message(Archiver forced to: $$QMAKE_AR)
8 message(Archiver forced to: $$QMAKE_AR)
9 QMAKE_LINK=sparc-rtems-g++
9 QMAKE_LINK=sparc-rtems-g++
10 message(Linker forced to: $$QMAKE_LINK)
10 message(Linker forced to: $$QMAKE_LINK)
11 QMAKE_LINK_SHLIB=sparc-rtems-g++
11 QMAKE_LINK_SHLIB=sparc-rtems-g++
12 QMAKE_OBJCOPY= sparc-rtems-objcopy
12 QMAKE_OBJCOPY= sparc-rtems-objcopy
13 QMAKE_STRIP=sparc-rtems-strip
13 QMAKE_STRIP=sparc-rtems-strip
14 QMAKE_GDB=sparc-rtems-gdb
14 QMAKE_GDB=sparc-rtems-gdb
15
15
16 INCLUDEPATH += /opt/rtems-4.10
16 INCLUDEPATH += /opt/rtems-4.10
17
17
18 QMAKE_CFLAGS_DEBUG= -g
18 QMAKE_CFLAGS_DEBUG= -g
19 QMAKE_CFLAGS_RELEASE=""
19 QMAKE_CFLAGS_RELEASE=""
20 QMAKE_CXXFLAGS_DEBUG= -g
20 QMAKE_CXXFLAGS_DEBUG= -g
21 QMAKE_CXXFLAGS_RELEASE=""
21 QMAKE_CXXFLAGS_RELEASE=""
22 QMAKE_LFLAGS_RELEASE=""
22 QMAKE_LFLAGS_RELEASE=""
23 QMAKE_LFLAGS_DEBUG= -g
23 QMAKE_LFLAGS_DEBUG= -g
24 QMAKE_CXXFLAGS_DEPS =
24 QMAKE_CXXFLAGS_DEPS =
25 QMAKE_CXXFLAGS_WARN_ON = -Wall
25 QMAKE_CXXFLAGS_WARN_ON = -Wall
26 QMAKE_CXXFLAGS_WARN_OFF = -w
26 QMAKE_CXXFLAGS_WARN_OFF = -w
27 QMAKE_CXXFLAGS_RELEASE =
27 QMAKE_CXXFLAGS_RELEASE =
28 QMAKE_CXXFLAGS_DEBUG =
28 QMAKE_CXXFLAGS_DEBUG =
29 QMAKE_CXXFLAGS_YACC =
29 QMAKE_CXXFLAGS_YACC =
30 QMAKE_CXXFLAGS_THREAD =
30 QMAKE_CXXFLAGS_THREAD =
31 QMAKE_CXXFLAGS_RTTI_ON =
31 QMAKE_CXXFLAGS_RTTI_ON =
32 QMAKE_CXXFLAGS_RTTI_OFF =
32 QMAKE_CXXFLAGS_RTTI_OFF =
33 QMAKE_CXXFLAGS_EXCEPTIONS_ON =
33 QMAKE_CXXFLAGS_EXCEPTIONS_ON =
34 QMAKE_CXXFLAGS_EXCEPTIONS_OFF =
34 QMAKE_CXXFLAGS_EXCEPTIONS_OFF =
35 QMAKE_CFLAGS_WARN_ON = -Wall
35 QMAKE_CFLAGS_WARN_ON = -Wall
36 QMAKE_CFLAGS_WARN_OFF = -w
36 QMAKE_CFLAGS_WARN_OFF = -w
37 QMAKE_CFLAGS_RELEASE =
37 QMAKE_CFLAGS_RELEASE =
38 QMAKE_CFLAGS_YACC =
38 QMAKE_CFLAGS_YACC =
39 QMAKE_LFLAGS_EXCEPTIONS_ON =
39 QMAKE_LFLAGS_EXCEPTIONS_ON =
40 QMAKE_LFLAGS_EXCEPTIONS_OFF =
40 QMAKE_LFLAGS_EXCEPTIONS_OFF =
41 QMAKE_LFLAGS_RELEASE =
41 QMAKE_LFLAGS_RELEASE = -Xlinker -Map=output.map
42 QMAKE_LFLAGS_CONSOLE =
42 QMAKE_LFLAGS_CONSOLE =
43 QMAKE_LFLAGS_WINDOWS =
43 QMAKE_LFLAGS_WINDOWS =
44 QMAKE_LFLAGS_DLL =
44 QMAKE_LFLAGS_DLL =
45 QMAKE_INCDIR_QT =
45 QMAKE_INCDIR_QT =
46 QMAKE_INCDIR =
46 QMAKE_INCDIR =
47 QMAKE_CFLAGS_SHLIB =
47 QMAKE_CFLAGS_SHLIB =
48 QMAKE_CFLAGS_STATIC_LIB =
48 QMAKE_CFLAGS_STATIC_LIB =
49 QMAKE_CXXFLAGS_SHLIB =
49 QMAKE_CXXFLAGS_SHLIB =
50 QMAKE_CXXFLAGS_STATIC_LIB =
50 QMAKE_CXXFLAGS_STATIC_LIB =
51 QMAKE_LIBS=""
51 QMAKE_LIBS=""
52 INCLUDEPATH=""
52 INCLUDEPATH=""
53 DEFINES=""
53 DEFINES=""
54
54
55 contains( TEMPLATE, app ) {
55 contains( TEMPLATE, app ) {
56 OBJECTS_DIR=obj
56 OBJECTS_DIR=obj
57 DESTDIR=bin
57 DESTDIR=bin
58 }
58 }
59
59
60 #QMAKE_CFLAGS_RELEASE += -O0
60 #QMAKE_CFLAGS_RELEASE += -O0
61 #QMAKE_CFLAGS_DEBUG += -O0
61 #QMAKE_CFLAGS_DEBUG += -O0
62 #QMAKE_CXXFLAGS_RELEASE += -O0
62 #QMAKE_CXXFLAGS_RELEASE += -O0
63 #QMAKE_CXXFLAGS_DEBUG += -O0
63 #QMAKE_CXXFLAGS_DEBUG += -O0
64 QMAKE_CFLAGS_RELEASE += -O3
64 QMAKE_CFLAGS_RELEASE += -O3
65 QMAKE_CFLAGS_DEBUG += -O3
65 QMAKE_CFLAGS_DEBUG += -O3
66 QMAKE_CXXFLAGS_RELEASE += -O3
66 QMAKE_CXXFLAGS_RELEASE += -O3
67 QMAKE_CXXFLAGS_DEBUG += -O3
67 QMAKE_CXXFLAGS_DEBUG += -O3
68
68
69 #QMAKE_CFLAGS_RELEASE+= -O3 -std=c99
69 #QMAKE_CFLAGS_RELEASE+= -O3 -std=c99
70 #QMAKE_CFLAGS_DEBUG+= -O3 -std=c99
70 #QMAKE_CFLAGS_DEBUG+= -O3 -std=c99
71 #QMAKE_CXXFLAGS_RELEASE+= -O3 -std=c99
71 #QMAKE_CXXFLAGS_RELEASE+= -O3 -std=c99
72 #QMAKE_CXXFLAGS_DEBUG+= -O3 -std=c99
72 #QMAKE_CXXFLAGS_DEBUG+= -O3 -std=c99
73
73
74 contains( TEMPLATE, app ) {
74 contains( TEMPLATE, app ) {
75 grmon.target = grmon
75 grmon.target = grmon
76 grmon.commands = cd $$DESTDIR && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
76 grmon.commands = cd $$DESTDIR && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
77 QMAKE_EXTRA_TARGETS += grmon
77 QMAKE_EXTRA_TARGETS += grmon
78 }
78 }
79
79
80
80
81
81
82
82
83
83
84
84
85
85
86
86
87
87
88
88
89
89
90
90
91
91
92
92
93
93
94
94
95
95
96
96
97
97
@@ -1,71 +1,75
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "tc_load_dump_parameters.h"
7 #include "tc_load_dump_parameters.h"
8 #include "tc_acceptance.h"
8 #include "tc_acceptance.h"
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11 #include "fsw_processing.h"
11 #include "fsw_processing.h"
12
12
13 #include "lfr_cpu_usage_report.h"
13 #include "lfr_cpu_usage_report.h"
14
14
15 //****
15 //****
16 // ISR
16 // ISR
17 rtems_isr commutation_isr1( rtems_vector_number vector );
17 rtems_isr commutation_isr1( rtems_vector_number vector );
18 rtems_isr commutation_isr2( rtems_vector_number vector );
18 rtems_isr commutation_isr2( rtems_vector_number vector );
19
19
20 //***********
20 //***********
21 // RTEMS TASK
21 // RTEMS TASK
22 rtems_task actn_task( rtems_task_argument unused );
22 rtems_task actn_task( rtems_task_argument unused );
23
23
24 //***********
24 //***********
25 // TC ACTIONS
25 // TC ACTIONS
26 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
26 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
27 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
27 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
28 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
28 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
29 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
29 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
30 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
30 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
31 int action_update_time( ccsdsTelecommandPacket_t *TC);
31 int action_update_time( ccsdsTelecommandPacket_t *TC);
32
32
33 // mode transition
33 // mode transition
34 int check_mode_value( unsigned char requestedMode );
34 int check_mode_value( unsigned char requestedMode );
35 int check_mode_transition( unsigned char requestedMode );
35 int check_mode_transition( unsigned char requestedMode );
36 int check_transition_date( unsigned int transitionCoarseTime );
36 int check_transition_date( unsigned int transitionCoarseTime );
37 int stop_current_mode( void );
37 int stop_current_mode( void );
38 int enter_mode( unsigned char mode , unsigned int transitionCoarseTime );
38 int enter_mode_standby( void );
39 int enter_mode_normal( unsigned int transitionCoarseTime );
40 int enter_mode_burst( unsigned int transitionCoarseTime );
41 int enter_mode_sbm1( unsigned int transitionCoarseTime );
42 int enter_mode_sbm2( unsigned int transitionCoarseTime );
39 int restart_science_tasks( unsigned char lfrRequestedMode );
43 int restart_science_tasks( unsigned char lfrRequestedMode );
40 int suspend_science_tasks();
44 int suspend_science_tasks();
41 void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime );
45 void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime );
42 void launch_spectral_matrix( void );
46 void launch_spectral_matrix( void );
43 void launch_spectral_matrix_simu( void );
47 void launch_spectral_matrix_simu( void );
44 void set_sm_irq_onNewMatrix( unsigned char value );
48 void set_sm_irq_onNewMatrix( unsigned char value );
45 void set_sm_irq_onError( unsigned char value );
49 void set_sm_irq_onError( unsigned char value );
46
50
47 // other functions
51 // other functions
48 void updateLFRCurrentMode();
52 void updateLFRCurrentMode();
49 void set_lfr_soft_reset( unsigned char value );
53 void set_lfr_soft_reset( unsigned char value );
50 void reset_lfr( void );
54 void reset_lfr( void );
51 // CALIBRATION
55 // CALIBRATION
52 void setCalibrationPrescaler( unsigned int prescaler );
56 void setCalibrationPrescaler( unsigned int prescaler );
53 void setCalibrationDivisor( unsigned int divisionFactor );
57 void setCalibrationDivisor( unsigned int divisionFactor );
54 void setCalibrationData( void );
58 void setCalibrationData( void );
55 void setCalibrationReload( bool state);
59 void setCalibrationReload( bool state);
56 void setCalibrationEnable( bool state );
60 void setCalibrationEnable( bool state );
57 void setCalibrationInterleaved( bool state );
61 void setCalibrationInterleaved( bool state );
58 void setCalibration( bool state );
62 void setCalibration( bool state );
59 void configureCalibration( bool interleaved );
63 void configureCalibration( bool interleaved );
60 //
64 //
61 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
65 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
62 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
66 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
63 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
67 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
64
68
65 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
69 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
66 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
70 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
67
71
68 #endif // TC_HANDLER_H_INCLUDED
72 #endif // TC_HANDLER_H_INCLUDED
69
73
70
74
71
75
@@ -1,1308 +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_standby();
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*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
145 len = read( fdSPW, (char*) &currentTC, 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( &currentTC, estimatedPacketLength, computed_CRC ) ;
158 parserCode = tc_parser( &currentTC, 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( &currentTC, queue_send_id,
178 send_tm_lfr_tc_exe_corrupted( &currentTC, 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, &currentTC,
185 status = rtems_message_queue_send( queue_recv_id, &currentTC,
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 unsigned char type;
221
221
222 incomingRingNodePtr = NULL;
222 incomingRingNodePtr = NULL;
223 ring_node_address = 0;
223 ring_node_address = 0;
224 charPtr = (char *) &ring_node_address;
224 charPtr = (char *) &ring_node_address;
225 sid = 0;
225 sid = 0;
226 sidAsUnsignedChar = 0;
226 sidAsUnsignedChar = 0;
227
227
228 init_header_cwf( &headerCWF );
228 init_header_cwf( &headerCWF );
229 init_header_swf( &headerSWF );
229 init_header_swf( &headerSWF );
230 init_header_asm( &headerASM );
230 init_header_asm( &headerASM );
231
231
232 status = get_message_queue_id_send( &queue_send_id );
232 status = get_message_queue_id_send( &queue_send_id );
233 if (status != RTEMS_SUCCESSFUL)
233 if (status != RTEMS_SUCCESSFUL)
234 {
234 {
235 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)
236 }
236 }
237
237
238 BOOT_PRINTF("in SEND *** \n")
238 BOOT_PRINTF("in SEND *** \n")
239
239
240 while(1)
240 while(1)
241 {
241 {
242 status = rtems_message_queue_receive( queue_send_id, incomingData, &size,
242 status = rtems_message_queue_receive( queue_send_id, incomingData, &size,
243 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
243 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
244
244
245 if (status!=RTEMS_SUCCESSFUL)
245 if (status!=RTEMS_SUCCESSFUL)
246 {
246 {
247 PRINTF1("in SEND *** (1) ERR = %d\n", status)
247 PRINTF1("in SEND *** (1) ERR = %d\n", status)
248 }
248 }
249 else
249 else
250 {
250 {
251 if ( size == sizeof(ring_node*) )
251 if ( size == sizeof(ring_node*) )
252 {
252 {
253 charPtr[0] = incomingData[0];
253 charPtr[0] = incomingData[0];
254 charPtr[1] = incomingData[1];
254 charPtr[1] = incomingData[1];
255 charPtr[2] = incomingData[2];
255 charPtr[2] = incomingData[2];
256 charPtr[3] = incomingData[3];
256 charPtr[3] = incomingData[3];
257 incomingRingNodePtr = (ring_node*) ring_node_address;
257 incomingRingNodePtr = (ring_node*) ring_node_address;
258 sid = incomingRingNodePtr->sid;
258 sid = incomingRingNodePtr->sid;
259 if ( (sid==SID_NORM_CWF_LONG_F3)
259 if ( (sid==SID_NORM_CWF_LONG_F3)
260 || (sid==SID_BURST_CWF_F2 )
260 || (sid==SID_BURST_CWF_F2 )
261 || (sid==SID_SBM1_CWF_F1 )
261 || (sid==SID_SBM1_CWF_F1 )
262 || (sid==SID_SBM2_CWF_F2 ))
262 || (sid==SID_SBM2_CWF_F2 ))
263 {
263 {
264 spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF );
264 spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF );
265 }
265 }
266 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) )
267 {
267 {
268 spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF );
268 spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF );
269 }
269 }
270 else if ( (sid==SID_NORM_CWF_F3) )
270 else if ( (sid==SID_NORM_CWF_F3) )
271 {
271 {
272 spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF );
272 spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF );
273 }
273 }
274 else if (sid==SID_NORM_ASM_F0)
274 else if (sid==SID_NORM_ASM_F0)
275 {
275 {
276 spw_send_asm_f0( incomingRingNodePtr, &headerASM );
276 spw_send_asm_f0( incomingRingNodePtr, &headerASM );
277 }
277 }
278 else if (sid==SID_NORM_ASM_F1)
278 else if (sid==SID_NORM_ASM_F1)
279 {
279 {
280 spw_send_asm_f1( incomingRingNodePtr, &headerASM );
280 spw_send_asm_f1( incomingRingNodePtr, &headerASM );
281 }
281 }
282 else if (sid==SID_NORM_ASM_F2)
282 else if (sid==SID_NORM_ASM_F2)
283 {
283 {
284 spw_send_asm_f2( incomingRingNodePtr, &headerASM );
284 spw_send_asm_f2( incomingRingNodePtr, &headerASM );
285 }
285 }
286 else if ( sid==TM_CODE_K_DUMP )
286 else if ( sid==TM_CODE_K_DUMP )
287 {
287 {
288 spw_send_k_dump( incomingRingNodePtr );
288 spw_send_k_dump( incomingRingNodePtr );
289 }
289 }
290 else
290 else
291 {
291 {
292 PRINTF1("unexpected sid = %d\n", sid);
292 PRINTF1("unexpected sid = %d\n", sid);
293 }
293 }
294 }
294 }
295 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
296 {
296 {
297 sidAsUnsignedChar = (unsigned char) incomingData[ PACKET_POS_PA_LFR_SID_PKT ];
297 sidAsUnsignedChar = (unsigned char) incomingData[ PACKET_POS_PA_LFR_SID_PKT ];
298 sid = sidAsUnsignedChar;
298 sid = sidAsUnsignedChar;
299 type = (unsigned char) incomingData[ PACKET_POS_SERVICE_TYPE ];
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
300 if (type == TM_TYPE_LFR_SCIENCE) // this is a BP packet, all other types are handled differently
301 // 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
302 {
302 {
303 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 );
304 }
304 }
305
305
306 status = write( fdSPW, incomingData, size );
306 status = write( fdSPW, incomingData, size );
307 if (status == -1){
307 if (status == -1){
308 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)
309 }
309 }
310 }
310 }
311 else // the incoming message is a spw_ioctl_pkt_send structure
311 else // the incoming message is a spw_ioctl_pkt_send structure
312 {
312 {
313 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
313 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
314 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
314 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
315 if (status == -1){
315 if (status == -1){
316 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)