##// END OF EJS Templates
Minor modifications to meet Logiscope requirements
paul -
r77:4928e8d9328f VHDLib206
parent child
Show More
@@ -0,0 +1,22
1 #ifndef TM_BYTE_POSITIONS_H
2 #define TM_BYTE_POSITIONS_H
3
4 #define BYTE_POS_CP_LFR_MODE 11
5
6 // TC_LFR_LOAD_COMMON_PAR
7
8 // TC_LFR_LOAD_NORMAL_PAR
9 #define BYTE_POS_SY_LFR_N_SWF_L 0
10 #define BYTE_POS_SY_LFR_N_SWF_P 2
11 #define BYTE_POS_SY_LFR_N_ASM_P 4
12 #define BYTE_POS_SY_LFR_N_BP_P0 6
13 #define BYTE_POS_SY_LFR_N_BP_P1 7
14
15 // TC_LFR_LOAD_BURST_PAR
16
17 // TC_LFR_LOAD_SBM1_PAR
18
19 // TC_LFR_LOAD_SBM2_PAR
20
21
22 #endif // TM_BYTE_POSITIONS_H
@@ -1,248 +1,248
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Nov 14 12:02:16 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Nov 15 07:55:16 2013
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=23 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=24 -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_processing.c \
49 49 ../src/fsw_misc.c \
50 50 ../src/fsw_init.c \
51 51 ../src/fsw_globals.c \
52 52 ../src/fsw_spacewire.c \
53 53 ../src/tc_load_dump_parameters.c \
54 54 ../src/tm_lfr_tc_exe.c \
55 55 ../src/tc_acceptance.c
56 56 OBJECTS = obj/wf_handler.o \
57 57 obj/tc_handler.o \
58 58 obj/fsw_processing.o \
59 59 obj/fsw_misc.o \
60 60 obj/fsw_init.o \
61 61 obj/fsw_globals.o \
62 62 obj/fsw_spacewire.o \
63 63 obj/tc_load_dump_parameters.o \
64 64 obj/tm_lfr_tc_exe.o \
65 65 obj/tc_acceptance.o
66 66 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
67 67 /usr/lib64/qt4/mkspecs/common/linux.conf \
68 68 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
69 69 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
70 70 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
71 71 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
72 72 /usr/lib64/qt4/mkspecs/qconfig.pri \
73 73 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
74 74 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
75 75 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
76 76 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
77 77 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
78 78 sparc.pri \
79 79 /usr/lib64/qt4/mkspecs/features/release.prf \
80 80 /usr/lib64/qt4/mkspecs/features/default_post.prf \
81 81 /usr/lib64/qt4/mkspecs/features/shared.prf \
82 82 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
83 83 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
84 84 /usr/lib64/qt4/mkspecs/features/resources.prf \
85 85 /usr/lib64/qt4/mkspecs/features/uic.prf \
86 86 /usr/lib64/qt4/mkspecs/features/yacc.prf \
87 87 /usr/lib64/qt4/mkspecs/features/lex.prf \
88 88 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
89 89 fsw-qt.pro
90 90 QMAKE_TARGET = fsw
91 91 DESTDIR = bin/
92 92 TARGET = bin/fsw
93 93
94 94 first: all
95 95 ####### Implicit rules
96 96
97 97 .SUFFIXES: .o .c .cpp .cc .cxx .C
98 98
99 99 .cpp.o:
100 100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101 101
102 102 .cc.o:
103 103 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
104 104
105 105 .cxx.o:
106 106 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
107 107
108 108 .C.o:
109 109 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
110 110
111 111 .c.o:
112 112 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
113 113
114 114 ####### Build rules
115 115
116 116 all: Makefile $(TARGET)
117 117
118 118 $(TARGET): $(OBJECTS)
119 119 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
120 120 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
121 121
122 122 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
123 123 /usr/lib64/qt4/mkspecs/common/linux.conf \
124 124 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
125 125 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
126 126 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
127 127 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
128 128 /usr/lib64/qt4/mkspecs/qconfig.pri \
129 129 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
130 130 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
131 131 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
132 132 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
133 133 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
134 134 sparc.pri \
135 135 /usr/lib64/qt4/mkspecs/features/release.prf \
136 136 /usr/lib64/qt4/mkspecs/features/default_post.prf \
137 137 /usr/lib64/qt4/mkspecs/features/shared.prf \
138 138 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
139 139 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
140 140 /usr/lib64/qt4/mkspecs/features/resources.prf \
141 141 /usr/lib64/qt4/mkspecs/features/uic.prf \
142 142 /usr/lib64/qt4/mkspecs/features/yacc.prf \
143 143 /usr/lib64/qt4/mkspecs/features/lex.prf \
144 144 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
145 145 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
146 146 /usr/lib64/qt4/mkspecs/common/unix.conf:
147 147 /usr/lib64/qt4/mkspecs/common/linux.conf:
148 148 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
149 149 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
150 150 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
151 151 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
152 152 /usr/lib64/qt4/mkspecs/qconfig.pri:
153 153 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
154 154 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
155 155 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
156 156 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
157 157 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
158 158 sparc.pri:
159 159 /usr/lib64/qt4/mkspecs/features/release.prf:
160 160 /usr/lib64/qt4/mkspecs/features/default_post.prf:
161 161 /usr/lib64/qt4/mkspecs/features/shared.prf:
162 162 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
163 163 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
164 164 /usr/lib64/qt4/mkspecs/features/resources.prf:
165 165 /usr/lib64/qt4/mkspecs/features/uic.prf:
166 166 /usr/lib64/qt4/mkspecs/features/yacc.prf:
167 167 /usr/lib64/qt4/mkspecs/features/lex.prf:
168 168 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
169 169 qmake: FORCE
170 170 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
171 171
172 172 dist:
173 173 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
174 174 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
175 175
176 176
177 177 clean:compiler_clean
178 178 -$(DEL_FILE) $(OBJECTS)
179 179 -$(DEL_FILE) *~ core *.core
180 180
181 181
182 182 ####### Sub-libraries
183 183
184 184 distclean: clean
185 185 -$(DEL_FILE) $(TARGET)
186 186 -$(DEL_FILE) Makefile
187 187
188 188
189 189 grmon:
190 190 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
191 191
192 192 check: first
193 193
194 194 compiler_rcc_make_all:
195 195 compiler_rcc_clean:
196 196 compiler_uic_make_all:
197 197 compiler_uic_clean:
198 198 compiler_image_collection_make_all: qmake_image_collection.cpp
199 199 compiler_image_collection_clean:
200 200 -$(DEL_FILE) qmake_image_collection.cpp
201 201 compiler_yacc_decl_make_all:
202 202 compiler_yacc_decl_clean:
203 203 compiler_yacc_impl_make_all:
204 204 compiler_yacc_impl_clean:
205 205 compiler_lex_make_all:
206 206 compiler_lex_clean:
207 207 compiler_clean:
208 208
209 209 ####### Compile
210 210
211 211 obj/wf_handler.o: ../src/wf_handler.c
212 212 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
213 213
214 214 obj/tc_handler.o: ../src/tc_handler.c
215 215 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
216 216
217 217 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
218 218 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
219 219
220 220 obj/fsw_misc.o: ../src/fsw_misc.c
221 221 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
222 222
223 223 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
224 224 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
225 225
226 226 obj/fsw_globals.o: ../src/fsw_globals.c
227 227 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
228 228
229 229 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
230 230 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
231 231
232 232 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
233 233 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
234 234
235 235 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
236 236 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
237 237
238 238 obj/tc_acceptance.o: ../src/tc_acceptance.c
239 239 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
240 240
241 241 ####### Install
242 242
243 243 install: FORCE
244 244
245 245 uninstall: FORCE
246 246
247 247 FORCE:
248 248
@@ -1,78 +1,79
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa
4 4 CONFIG += console verbose
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 SWVERSION=-0-23
10 SWVERSION=-0-24
11 11 DEFINES += SW_VERSION_N1=0
12 12 DEFINES += SW_VERSION_N2=0
13 13 DEFINES += SW_VERSION_N3=0
14 DEFINES += SW_VERSION_N4=23
14 DEFINES += SW_VERSION_N4=24
15 15
16 16 contains( CONFIG, verbose ) {
17 17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
18 18 }
19 19
20 20 contains( CONFIG, debug_messages ) {
21 21 DEFINES += DEBUG_MESSAGES
22 22 }
23 23
24 24 contains( CONFIG, cpu_usage_report ) {
25 25 DEFINES += PRINT_TASK_STATISTICS
26 26 }
27 27
28 28 contains( CONFIG, stack_report ) {
29 29 DEFINES += PRINT_STACK_REPORT
30 30 }
31 31
32 32 contains( CONFIG, boot_messages ) {
33 33 DEFINES += BOOT_MESSAGES
34 34 }
35 35
36 36 #doxygen.target = doxygen
37 37 #doxygen.commands = doxygen ../doc/Doxyfile
38 38 #QMAKE_EXTRA_TARGETS += doxygen
39 39
40 40 TARGET = fsw
41 41 contains( CONFIG, gsa ) {
42 42 DEFINES += GSA
43 43 TARGET = fsw-gsa
44 44 }
45 45
46 46 INCLUDEPATH += \
47 47 ../src \
48 48 ../header
49 49
50 50 SOURCES += \
51 51 ../src/wf_handler.c \
52 52 ../src/tc_handler.c \
53 53 ../src/fsw_processing.c \
54 54 ../src/fsw_misc.c \
55 55 ../src/fsw_init.c \
56 56 ../src/fsw_globals.c \
57 57 ../src/fsw_spacewire.c \
58 58 ../src/tc_load_dump_parameters.c \
59 59 ../src/tm_lfr_tc_exe.c \
60 60 ../src/tc_acceptance.c
61 61
62 62
63 63 HEADERS += \
64 64 ../header/wf_handler.h \
65 65 ../header/tc_handler.h \
66 66 ../header/grlib_regs.h \
67 67 ../header/fsw_processing.h \
68 68 ../header/fsw_params.h \
69 69 ../header/fsw_misc.h \
70 70 ../header/fsw_init.h \
71 71 ../header/ccsds_types.h \
72 72 ../header/fsw_params_processing.h \
73 73 ../header/fsw_spacewire.h \
74 74 ../header/tm_byte_positions.h \
75 75 ../header/tc_load_dump_parameters.h \
76 76 ../header/tm_lfr_tc_exe.h \
77 ../header/tc_acceptance.h
77 ../header/tc_acceptance.h \
78 ../header/fsw_params_nb_bytes.h
78 79
@@ -1,305 +1,198
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 2.8.1, 2013-11-14T11:59:15. -->
3 <!-- Written by QtCreator 2.8.1, 2013-11-15T09:52:17. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QString" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
29 29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 45 </valuemap>
46 46 </data>
47 47 <data>
48 48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 49 <valuemap type="QVariantMap"/>
50 50 </data>
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{be73cf6a-f9d8-4d5a-8adf-adc2d83e2e44}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
63 63 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
64 64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
67 67 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
69 69 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
70 70 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
71 71 </valuemap>
72 72 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
73 73 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
74 74 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
77 77 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
78 78 <value type="QString">-w</value>
79 79 <value type="QString">-r</value>
80 80 </valuelist>
81 81 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w -j 4</value>
82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
84 84 </valuemap>
85 85 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
86 86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
89 89 </valuemap>
90 90 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
92 92 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
93 93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
96 96 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
97 97 <value type="QString">-w</value>
98 98 <value type="QString">-r</value>
99 99 </valuelist>
100 100 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
101 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
101 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
103 103 </valuemap>
104 104 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
105 105 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
108 108 </valuemap>
109 109 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
110 110 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
111 111 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
115 115 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
116 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
116 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/admin/opt/DEV_PLE/FSW-qt</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
118 118 </valuemap>
119 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
122 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
126 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
127 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
128 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
129 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
130 </valuemap>
131 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
132 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
133 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
134 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
136 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
137 <value type="QString">-w</value>
138 <value type="QString">-r</value>
139 </valuelist>
140 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
141 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
142 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
143 </valuemap>
144 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
146 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
147 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
148 </valuemap>
149 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
150 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
151 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
153 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
154 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
155 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
156 <value type="QString">-w</value>
157 <value type="QString">-r</value>
158 </valuelist>
159 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
160 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
161 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
162 </valuemap>
163 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
165 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
166 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
167 </valuemap>
168 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
169 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
170 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
174 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
175 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
176 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
177 </valuemap>
178 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
179 120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
180 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
181 122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
182 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
183 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
184 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
185 126 </valuemap>
186 127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
187 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
188 129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
189 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
190 131 </valuemap>
191 132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
192 133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
193 134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
194 135 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
195 136 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
196 137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
197 138 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
198 139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
199 140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
200 141 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
201 142 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
202 143 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
203 144 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
204 145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
205 146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
206 147 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
207 148 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
208 149 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
209 150 <value type="int">0</value>
210 151 <value type="int">1</value>
211 152 <value type="int">2</value>
212 153 <value type="int">3</value>
213 154 <value type="int">4</value>
214 155 <value type="int">5</value>
215 156 <value type="int">6</value>
216 157 <value type="int">7</value>
217 158 <value type="int">8</value>
218 159 <value type="int">9</value>
219 160 <value type="int">10</value>
220 161 <value type="int">11</value>
221 162 <value type="int">12</value>
222 163 <value type="int">13</value>
223 164 <value type="int">14</value>
224 165 </valuelist>
225 166 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
226 167 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
227 168 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
228 169 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
229 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
170 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/admin/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
230 171 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
231 172 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
232 173 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
233 174 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
234 175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
235 176 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
236 177 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
237 178 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
238 179 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
239 180 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
240 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
241 </valuemap>
242 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
243 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
244 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
245 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
246 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
247 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
248 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
249 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
250 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
251 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
252 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
253 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
254 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
255 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
256 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
257 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
258 <value type="int">0</value>
259 <value type="int">1</value>
260 <value type="int">2</value>
261 <value type="int">3</value>
262 <value type="int">4</value>
263 <value type="int">5</value>
264 <value type="int">6</value>
265 <value type="int">7</value>
266 <value type="int">8</value>
267 <value type="int">9</value>
268 <value type="int">10</value>
269 <value type="int">11</value>
270 <value type="int">12</value>
271 <value type="int">13</value>
272 <value type="int">14</value>
273 </valuelist>
274 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
275 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
276 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
277 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">doxygen</value>
278 <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">true</value>
279 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">/opt/DEV_PLE/doc</value>
280 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run doxygen</value>
281 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
282 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
283 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
284 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
285 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
286 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
287 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
288 181 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
289 182 </valuemap>
290 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
183 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
291 184 </valuemap>
292 185 </data>
293 186 <data>
294 187 <variable>ProjectExplorer.Project.TargetCount</variable>
295 188 <value type="int">1</value>
296 189 </data>
297 190 <data>
298 191 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
299 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
192 <value type="QByteArray">{cdbf9cdc-1e84-406e-889b-c4feef49e75c}</value>
300 193 </data>
301 194 <data>
302 195 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
303 196 <value type="int">14</value>
304 197 </data>
305 198 </qtcreator>
@@ -1,661 +1,600
1 1 #ifndef CCSDS_TYPES_H_INCLUDED
2 2 #define CCSDS_TYPES_H_INCLUDED
3 3
4 4 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
5 5 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
6 6 #define CCSDS_TM_PKT_MAX_SIZE 4412
7 7 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
8 8 #define CCSDS_TC_PKT_MAX_SIZE 256
9 9 #define CCSDS_TC_PKT_MIN_SIZE 16
10 10 #define CCSDS_TC_TM_PACKET_OFFSET 7
11 11 #define CCSDS_PROCESS_ID 76
12 12 #define CCSDS_PACKET_CATEGORY 12
13 13 #define CCSDS_NODE_ADDRESS 0xfe
14 14 #define CCSDS_USER_APP 0x00
15 15
16 16 #define DEFAULT_SPARE1_PUSVERSION_SPARE2 0x10
17 17 #define DEFAULT_RESERVED 0x00
18 18 #define DEFAULT_HKBIA 0x1e // 0001 1110
19 19
20 20 // PACKET ID
21 21 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
22 22 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
23 23 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
24 24 #define TM_PACKET_ID_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
25 25 #define TM_PACKET_ID_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
26 26 #define TM_PACKET_PID_DEFAULT 76
27 27 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
28 28 #define TM_PACKET_CAT_TC_EXE 1
29 29 #define TM_PACKET_CAT_HK 4
30 30 #define TM_PACKET_CAT_PARAMETER_DUMP 9
31 31 #define TM_PACKET_CAT_SCIENCE 12
32 32
33 33 // PACKET SEQUENCE CONTROL
34 34 #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000]
35 35 #define TM_PACKET_SEQ_CTRL_FIRST 0x40 // [0100 0000]
36 36 #define TM_PACKET_SEQ_CTRL_LAST 0x80 // [1000 0000]
37 37 #define TM_PACKET_SEQ_CTRL_STANDALONE 0xc0 // [1100 0000]
38 38 #define TM_PACKET_SEQ_CNT_DEFAULT 0x00 // [0000 0000]
39 39
40 40 // DESTINATION ID
41 41 #define TM_DESTINATION_ID_GROUND 0
42 42 #define TM_DESTINATION_ID_MISSION_TIMELINE 110
43 43 #define TM_DESTINATION_ID_TC_SEQUENCES 111
44 44 #define TM_DESTINATION_ID_RECOVERY_ACTION_COMMAND 112
45 45 #define TM_DESTINATION_ID_BACKUP_MISSION_TIMELINE 113
46 46 #define TM_DESTINATION_ID_DIRECT_CMD 120
47 47 #define TM_DESTINATION_ID_SPARE_GRD_SRC1 121
48 48 #define TM_DESTINATION_ID_SPARE_GRD_SRC2 122
49 49 #define TM_DESTINATION_ID_OBCP 15
50 50 #define TM_DESTINATION_ID_SYSTEM_CONTROL 14
51 51 #define TM_DESTINATION_ID_AOCS 11
52 52
53 53 #define CCSDS_DESTINATION_ID 0x01
54 54 #define CCSDS_PROTOCOLE_ID 0x02
55 55 #define CCSDS_RESERVED 0x00
56 56 #define CCSDS_USER_APP 0x00
57 57
58 58 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
59 59 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
60 60 #define SIZE_HK_PARAMETERS 112
61 61
62 62 // TC TYPES
63 63 #define TC_TYPE_GEN 181
64 64 #define TC_TYPE_TIME 9
65 65
66 66 // TC SUBTYPES
67 67 #define TC_SUBTYPE_RESET 1
68 68 #define TC_SUBTYPE_LOAD_COMM 11
69 69 #define TC_SUBTYPE_LOAD_NORM 13
70 70 #define TC_SUBTYPE_LOAD_BURST 19
71 71 #define TC_SUBTYPE_LOAD_SBM1 25
72 72 #define TC_SUBTYPE_LOAD_SBM2 27
73 73 #define TC_SUBTYPE_DUMP 31
74 74 #define TC_SUBTYPE_ENTER 41
75 75 #define TC_SUBTYPE_UPDT_INFO 51
76 76 #define TC_SUBTYPE_EN_CAL 61
77 77 #define TC_SUBTYPE_DIS_CAL 63
78 78 #define TC_SUBTYPE_UPDT_TIME 129
79 79
80 80 // TC LEN
81 81 #define TC_LEN_RESET 12
82 82 #define TC_LEN_LOAD_COMM 14
83 83 #define TC_LEN_LOAD_NORM 20
84 84 #define TC_LEN_LOAD_BURST 14
85 85 #define TC_LEN_LOAD_SBM1 14
86 86 #define TC_LEN_LOAD_SBM2 14
87 87 #define TC_LEN_DUMP 12
88 88 #define TC_LEN_ENTER 20
89 89 #define TC_LEN_UPDT_INFO 48
90 90 #define TC_LEN_EN_CAL 12
91 91 #define TC_LEN_DIS_CAL 12
92 92 #define TC_LEN_UPDT_TIME 18
93 93
94 94 // TM TYPES
95 95 #define TM_TYPE_TC_EXE 1
96 96 #define TM_TYPE_HK 3
97 97 #define TM_TYPE_PARAMETER_DUMP 3
98 98 #define TM_TYPE_LFR_SCIENCE 21
99 99
100 100 // TM SUBTYPES
101 101 #define TM_SUBTYPE_EXE_OK 7
102 102 #define TM_SUBTYPE_EXE_NOK 8
103 103 #define TM_SUBTYPE_HK 25
104 104 #define TM_SUBTYPE_PARAMETER_DUMP 25
105 105 #define TM_SUBTYPE_SCIENCE 3
106 106 #define TM_SUBTYPE_LFR_SCIENCE 3
107 107
108 108 // FAILURE CODES
109 109 #define ILLEGAL_APID 0
110 110 #define WRONG_LEN_PKT 1
111 111 #define INCOR_CHECKSUM 2
112 112 #define ILL_TYPE 3
113 113 #define ILL_SUBTYPE 4
114 114 #define WRONG_APP_DATA 5 // 0x00 0x05
115 115 #define TC_NOT_EXE 42000 // 0xa4 0x10
116 116 #define WRONG_SRC_ID 42001 // 0xa4 0x11
117 117 #define FUNCT_NOT_IMPL 42002 // 0xa4 0x12
118 118 #define FAIL_DETECTED 42003 // 0xa4 0x13
119 119 #define NOT_ALLOWED 42004 // 0xa4 0x14
120 120 #define CORRUPTED 42005 // 0xa4 0x15
121 121 #define CCSDS_TM_VALID 7
122 122
123 123 // TC SID
124 124 #define SID_TC_GROUND 0
125 125 #define SID_TC_MISSION_TIMELINE 110
126 126 #define SID_TC_TC_SEQUENCES 111
127 127 #define SID_TC_RECOVERY_ACTION_CMD 112
128 128 #define SID_TC_BACKUP_MISSION_TIMELINE 113
129 129 #define SID_TC_DIRECT_CMD 120
130 130 #define SID_TC_SPARE_GRD_SRC1 121
131 131 #define SID_TC_SPARE_GRD_SRC2 122
132 132 #define SID_TC_OBCP 15
133 133 #define SID_TC_SYSTEM_CONTROL 14
134 134 #define SID_TC_AOCS 11
135 135 #define SID_TC_RPW_INTERNAL 254
136 136
137 137 enum apid_destid{
138 138 GROUND,
139 139 MISSION_TIMELINE,
140 140 TC_SEQUENCES,
141 141 RECOVERY_ACTION_CMD,
142 142 BACKUP_MISSION_TIMELINE,
143 143 DIRECT_CMD,
144 144 SPARE_GRD_SRC1,
145 145 SPARE_GRD_SRC2,
146 146 OBCP,
147 147 SYSTEM_CONTROL,
148 148 AOCS,
149 149 RPW_INTERNAL,
150 150 UNKNOWN
151 151 };
152 152 // SEQUENCE COUNTERS
153 153 #define SEQ_CNT_MAX 16383
154 154 #define SEQ_CNT_NB_DEST_ID 12
155 155
156 156 // TM SID
157 157 #define SID_HK 1
158 158 #define SID_PARAMETER_DUMP 10
159 159
160 160 #define SID_NORM_SWF_F0 3
161 161 #define SID_NORM_SWF_F1 4
162 162 #define SID_NORM_SWF_F2 5
163 163 #define SID_NORM_CWF_F3 1
164 164 #define SID_BURST_CWF_F2 2
165 165 #define SID_SBM1_CWF_F1 24
166 166 #define SID_SBM2_CWF_F2 25
167 167 #define SID_NORM_ASM_F0 11
168 168 #define SID_NORM_ASM_F1 12
169 169 #define SID_NORM_ASM_F2 13
170 170 #define SID_NORM_BP1_F0 14
171 171 #define SID_NORM_BP1_F1 15
172 172 #define SID_NORM_BP1_F2 16
173 173 #define SID_NORM_BP2_F0 19
174 174 #define SID_NORM_BP2_F1 20
175 175 #define SID_NORM_BP2_F2 21
176 176 #define SID_BURST_BP1_F0 17
177 177 #define SID_BURST_BP2_F0 22
178 178 #define SID_BURST_BP1_F1 18
179 179 #define SID_BURST_BP2_F1 23
180 180 #define SID_SBM1_BP1_F0 28
181 181 #define SID_SBM1_BP2_F0 31
182 182 #define SID_SBM2_BP1_F0 29
183 183 #define SID_SBM2_BP2_F0 32
184 184 #define SID_SBM2_BP1_F1 30
185 185 #define SID_SBM2_BP2_F1 33
186 186
187 187 // LENGTH (BYTES)
188 188 #define LENGTH_TM_LFR_TC_EXE_MAX 32
189 189 #define LENGTH_TM_LFR_HK 126
190 190
191 191 // HEADER_LENGTH
192 192 #define TM_HEADER_LEN 16
193 193 #define HEADER_LENGTH_TM_LFR_SCIENCE_ASM 28
194 194 // PACKET_LENGTH
195 195 #define PACKET_LENGTH_TC_EXE_SUCCESS (20 - CCSDS_TC_TM_PACKET_OFFSET)
196 196 #define PACKET_LENGTH_TC_EXE_INCONSISTENT (26 - CCSDS_TC_TM_PACKET_OFFSET)
197 197 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE (26 - CCSDS_TC_TM_PACKET_OFFSET)
198 198 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED (24 - CCSDS_TC_TM_PACKET_OFFSET)
199 199 #define PACKET_LENGTH_TC_EXE_ERROR (24 - CCSDS_TC_TM_PACKET_OFFSET)
200 200 #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET)
201 201 #define PACKET_LENGTH_HK (126 - CCSDS_TC_TM_PACKET_OFFSET)
202 202 #define PACKET_LENGTH_PARAMETER_DUMP (34 - CCSDS_TC_TM_PACKET_OFFSET)
203 203 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM (TOTAL_SIZE_SM + HEADER_LENGTH_TM_LFR_SCIENCE_ASM - CCSDS_TC_TM_PACKET_OFFSET)
204 204
205 205 #define SPARE1_PUSVERSION_SPARE2 0x10
206 206
207 207 #define LEN_TM_LFR_HK 130 // 126 + 4
208 208 #define LEN_TM_LFR_TC_EXE_NOT_IMP 28 // 24 + 4
209 209
210 210 #define TM_LEN_SCI_SWF_340 4101 // 340 * 12 + 10 + 12 - 1
211 211 #define TM_LEN_SCI_SWF_8 117 // 8 * 12 + 10 + 12 - 1
212 212 #define TM_LEN_SCI_CWF_340 4099 // 340 * 12 + 10 + 10 - 1
213 213 #define TM_LEN_SCI_CWF_8 115 // 8 * 12 + 10 + 10 - 1
214 214 #define TM_LEN_SCI_CWF3_LIGHT_340 2059 // 340 * 6 + 10 + 10 - 1
215 215 #define TM_LEN_SCI_CWF3_LIGHT_8 67 // 8 * 6 + 10 + 10 - 1
216 216 #define DEFAULT_PKTCNT 0x07
217 217 #define BLK_NR_340 0x0154
218 218 #define BLK_NR_8 0x0008
219 219
220 220 enum TM_TYPE{
221 221 TM_LFR_TC_EXE_OK,
222 222 TM_LFR_TC_EXE_ERR,
223 223 TM_LFR_HK,
224 224 TM_LFR_SCI,
225 225 TM_LFR_SCI_SBM,
226 226 TM_LFR_PAR_DUMP
227 227 };
228 228
229 struct TMHeader_str
230 {
231 unsigned char targetLogicalAddress;
232 unsigned char protocolIdentifier;
233 unsigned char reserved;
234 unsigned char userApplication;
235 unsigned char packetID[2];
236 unsigned char packetSequenceControl[2];
237 unsigned char packetLength[2];
238 // DATA FIELD HEADER
239 unsigned char spare1_pusVersion_spare2;
240 unsigned char serviceType;
241 unsigned char serviceSubType;
242 unsigned char destinationID;
243 unsigned char time[6];
244 };
245 typedef struct TMHeader_str TMHeader_t;
246
247 struct Packet_TM_LFR_TC_EXE_str
248 {
249 unsigned char targetLogicalAddress;
250 unsigned char protocolIdentifier;
251 unsigned char reserved;
252 unsigned char userApplication;
253 unsigned char packetID[2];
254 unsigned char packetSequenceControl[2];
255 unsigned char packetLength[2];
256 // DATA FIELD HEADER
257 unsigned char spare1_pusVersion_spare2;
258 unsigned char serviceType;
259 unsigned char serviceSubType;
260 unsigned char destinationID;
261 unsigned char time[6];
262 unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1];
263 };
264 typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t;
265
266 struct Packet_TM_LFR_TC_EXE_SUCCESS_str
267 {
229 typedef struct {
268 230 unsigned char targetLogicalAddress;
269 231 unsigned char protocolIdentifier;
270 232 unsigned char reserved;
271 233 unsigned char userApplication;
272 234 // PACKET HEADER
273 235 unsigned char packetID[2];
274 236 unsigned char packetSequenceControl[2];
275 237 unsigned char packetLength[2];
276 238 // DATA FIELD HEADER
277 239 unsigned char spare1_pusVersion_spare2;
278 240 unsigned char serviceType;
279 241 unsigned char serviceSubType;
280 242 unsigned char destinationID;
281 243 unsigned char time[6];
282 244 //
283 245 unsigned char telecommand_pkt_id[2];
284 246 unsigned char pkt_seq_control[2];
285 };
286 typedef struct Packet_TM_LFR_TC_EXE_SUCCESS_str Packet_TM_LFR_TC_EXE_SUCCESS_t;
247 } Packet_TM_LFR_TC_EXE_SUCCESS_t;
287 248
288 struct Packet_TM_LFR_TC_EXE_INCONSISTENT_str
289 {
249 typedef struct {
290 250 unsigned char targetLogicalAddress;
291 251 unsigned char protocolIdentifier;
292 252 unsigned char reserved;
293 253 unsigned char userApplication;
294 254 // PACKET HEADER
295 255 unsigned char packetID[2];
296 256 unsigned char packetSequenceControl[2];
297 257 unsigned char packetLength[2];
298 258 // DATA FIELD HEADER
299 259 unsigned char spare1_pusVersion_spare2;
300 260 unsigned char serviceType;
301 261 unsigned char serviceSubType;
302 262 unsigned char destinationID;
303 263 unsigned char time[6];
304 264 //
305 265 unsigned char tc_failure_code[2];
306 266 unsigned char telecommand_pkt_id[2];
307 267 unsigned char pkt_seq_control[2];
308 268 unsigned char tc_service;
309 269 unsigned char tc_subtype;
310 270 unsigned char byte_position;
311 271 unsigned char rcv_value;
312 };
313 typedef struct Packet_TM_LFR_TC_EXE_INCONSISTENT_str Packet_TM_LFR_TC_EXE_INCONSISTENT_t;
272 } Packet_TM_LFR_TC_EXE_INCONSISTENT_t;
314 273
315 struct Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_str
316 {
274 typedef struct {
317 275 unsigned char targetLogicalAddress;
318 276 unsigned char protocolIdentifier;
319 277 unsigned char reserved;
320 278 unsigned char userApplication;
321 279 // PACKET HEADER
322 280 unsigned char packetID[2];
323 281 unsigned char packetSequenceControl[2];
324 282 unsigned char packetLength[2];
325 283 // DATA FIELD HEADER
326 284 unsigned char spare1_pusVersion_spare2;
327 285 unsigned char serviceType;
328 286 unsigned char serviceSubType;
329 287 unsigned char destinationID;
330 288 unsigned char time[6];
331 289 //
332 290 unsigned char tc_failure_code[2];
333 291 unsigned char telecommand_pkt_id[2];
334 292 unsigned char pkt_seq_control[2];
335 293 unsigned char tc_service;
336 294 unsigned char tc_subtype;
337 295 unsigned char lfr_status_word[2];
338 };
339 typedef struct Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_str Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t;
296 } Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t;
340 297
341 struct Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_str
342 {
298 typedef struct {
343 299 unsigned char targetLogicalAddress;
344 300 unsigned char protocolIdentifier;
345 301 unsigned char reserved;
346 302 unsigned char userApplication;
347 303 // PACKET HEADER
348 304 unsigned char packetID[2];
349 305 unsigned char packetSequenceControl[2];
350 306 unsigned char packetLength[2];
351 307 // DATA FIELD HEADER
352 308 unsigned char spare1_pusVersion_spare2;
353 309 unsigned char serviceType;
354 310 unsigned char serviceSubType;
355 311 unsigned char destinationID;
356 312 unsigned char time[6];
357 313 //
358 314 unsigned char tc_failure_code[2];
359 315 unsigned char telecommand_pkt_id[2];
360 316 unsigned char pkt_seq_control[2];
361 317 unsigned char tc_service;
362 318 unsigned char tc_subtype;
363 };
364 typedef struct Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_str Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t;
319 } Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t;
365 320
366 struct Packet_TM_LFR_TC_EXE_ERROR_str
367 {
321 typedef struct {
368 322 unsigned char targetLogicalAddress;
369 323 unsigned char protocolIdentifier;
370 324 unsigned char reserved;
371 325 unsigned char userApplication;
372 326 // PACKET HEADER
373 327 unsigned char packetID[2];
374 328 unsigned char packetSequenceControl[2];
375 329 unsigned char packetLength[2];
376 330 // DATA FIELD HEADER
377 331 unsigned char spare1_pusVersion_spare2;
378 332 unsigned char serviceType;
379 333 unsigned char serviceSubType;
380 334 unsigned char destinationID;
381 335 unsigned char time[6];
382 336 //
383 337 unsigned char tc_failure_code[2];
384 338 unsigned char telecommand_pkt_id[2];
385 339 unsigned char pkt_seq_control[2];
386 340 unsigned char tc_service;
387 341 unsigned char tc_subtype;
388 };
389 typedef struct Packet_TM_LFR_TC_EXE_ERROR_str Packet_TM_LFR_TC_EXE_ERROR_t;
342 } Packet_TM_LFR_TC_EXE_ERROR_t;
390 343
391 struct Packet_TM_LFR_TC_EXE_CORRUPTED_str
392 {
344 typedef struct {
393 345 unsigned char targetLogicalAddress;
394 346 unsigned char protocolIdentifier;
395 347 unsigned char reserved;
396 348 unsigned char userApplication;
397 349 // PACKET HEADER
398 350 unsigned char packetID[2];
399 351 unsigned char packetSequenceControl[2];
400 352 unsigned char packetLength[2];
401 353 // DATA FIELD HEADER
402 354 unsigned char spare1_pusVersion_spare2;
403 355 unsigned char serviceType;
404 356 unsigned char serviceSubType;
405 357 unsigned char destinationID;
406 358 unsigned char time[6];
407 359 //
408 360 unsigned char tc_failure_code[2];
409 361 unsigned char telecommand_pkt_id[2];
410 362 unsigned char pkt_seq_control[2];
411 363 unsigned char tc_service;
412 364 unsigned char tc_subtype;
413 365 unsigned char pkt_len_rcv_value[2];
414 366 unsigned char pkt_datafieldsize_cnt[2];
415 367 unsigned char rcv_crc[2];
416 368 unsigned char computed_crc[2];
417 };
418 typedef struct Packet_TM_LFR_TC_EXE_CORRUPTED_str Packet_TM_LFR_TC_EXE_CORRUPTED_t;
369 } Packet_TM_LFR_TC_EXE_CORRUPTED_t;
419 370
420 struct Header_TM_LFR_SCIENCE_SWF_str
421 {
371 typedef struct {
422 372 unsigned char targetLogicalAddress;
423 373 unsigned char protocolIdentifier;
424 374 unsigned char reserved;
425 375 unsigned char userApplication;
426 376 unsigned char packetID[2];
427 377 unsigned char packetSequenceControl[2];
428 378 unsigned char packetLength[2];
429 379 // DATA FIELD HEADER
430 380 unsigned char spare1_pusVersion_spare2;
431 381 unsigned char serviceType;
432 382 unsigned char serviceSubType;
433 383 unsigned char destinationID;
434 384 unsigned char time[6];
435 385 // AUXILIARY HEADER
436 386 unsigned char sid;
437 387 unsigned char hkBIA;
438 388 unsigned char pktCnt;
439 389 unsigned char pktNr;
440 390 unsigned char acquisitionTime[6];
441 391 unsigned char blkNr[2];
442 };
443 typedef struct Header_TM_LFR_SCIENCE_SWF_str Header_TM_LFR_SCIENCE_SWF_t;
392 } Header_TM_LFR_SCIENCE_SWF_t;
444 393
445 struct Header_TM_LFR_SCIENCE_CWF_str
446 {
394 typedef struct {
447 395 unsigned char targetLogicalAddress;
448 396 unsigned char protocolIdentifier;
449 397 unsigned char reserved;
450 398 unsigned char userApplication;
451 399 unsigned char packetID[2];
452 400 unsigned char packetSequenceControl[2];
453 401 unsigned char packetLength[2];
454 402 // DATA FIELD HEADER
455 403 unsigned char spare1_pusVersion_spare2;
456 404 unsigned char serviceType;
457 405 unsigned char serviceSubType;
458 406 unsigned char destinationID;
459 407 unsigned char time[6];
460 408 // AUXILIARY DATA HEADER
461 409 unsigned char sid;
462 410 unsigned char hkBIA;
463 411 unsigned char acquisitionTime[6];
464 412 unsigned char blkNr[2];
465 };
466 typedef struct Header_TM_LFR_SCIENCE_CWF_str Header_TM_LFR_SCIENCE_CWF_t;
413 } Header_TM_LFR_SCIENCE_CWF_t;
467 414
468 struct Header_TM_LFR_SCIENCE_ASM_str
469 {
415 typedef struct {
470 416 unsigned char targetLogicalAddress;
471 417 unsigned char protocolIdentifier;
472 418 unsigned char reserved;
473 419 unsigned char userApplication;
474 420 unsigned char packetID[2];
475 421 unsigned char packetSequenceControl[2];
476 422 unsigned char packetLength[2];
477 423 // DATA FIELD HEADER
478 424 unsigned char spare1_pusVersion_spare2;
479 425 unsigned char serviceType;
480 426 unsigned char serviceSubType;
481 427 unsigned char destinationID;
482 428 unsigned char time[6];
483 429 // AUXILIARY HEADER
484 430 unsigned char sid;
485 431 unsigned char biaStatusInfo;
486 432 unsigned char cntASM;
487 433 unsigned char nrASM;
488 434 unsigned char acquisitionTime[6];
489 435 unsigned char blkNr[2];
490 };
491 typedef struct Header_TM_LFR_SCIENCE_ASM_str Header_TM_LFR_SCIENCE_ASM_t;
436 } Header_TM_LFR_SCIENCE_ASM_t;
492 437
493 struct ccsdsTelecommandPacket_str
494 {
495 //unsigned char targetLogicalAddress; // removed by the grspw module
438 typedef struct {
439 //targetLogicalAddress is removed by the grspw module
496 440 unsigned char protocolIdentifier;
497 441 unsigned char reserved;
498 442 unsigned char userApplication;
499 443 unsigned char packetID[2];
500 444 unsigned char packetSequenceControl[2];
501 445 unsigned char packetLength[2];
502 446 // DATA FIELD HEADER
503 447 unsigned char headerFlag_pusVersion_Ack;
504 448 unsigned char serviceType;
505 449 unsigned char serviceSubType;
506 450 unsigned char sourceID;
507 451 unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
508 };
509 typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t;
452 } ccsdsTelecommandPacket_t;
510 453
511 struct Packet_TM_LFR_HK_str
512 {
454 typedef struct {
513 455 unsigned char targetLogicalAddress;
514 456 unsigned char protocolIdentifier;
515 457 unsigned char reserved;
516 458 unsigned char userApplication;
517 459 unsigned char packetID[2];
518 460 unsigned char packetSequenceControl[2];
519 461 unsigned char packetLength[2];
520 462 unsigned char spare1_pusVersion_spare2;
521 463 unsigned char serviceType;
522 464 unsigned char serviceSubType;
523 465 unsigned char destinationID;
524 466 unsigned char time[6];
525 467 unsigned char sid;
526 468
527 469 //**************
528 470 // HK PARAMETERS
529 471 unsigned char lfr_status_word[2];
530 472 unsigned char lfr_sw_version[4];
531 473 // tc statistics
532 474 unsigned char hk_lfr_update_info_tc_cnt[2];
533 475 unsigned char hk_lfr_update_time_tc_cnt[2];
534 476 unsigned char hk_dpu_exe_tc_lfr_cnt[2];
535 477 unsigned char hk_dpu_rej_tc_lfr_cnt[2];
536 478 unsigned char hk_lfr_last_exe_tc_id[2];
537 479 unsigned char hk_lfr_last_exe_tc_type[2];
538 480 unsigned char hk_lfr_last_exe_tc_subtype[2];
539 481 unsigned char hk_lfr_last_exe_tc_time[6];
540 482 unsigned char hk_lfr_last_rej_tc_id[2];
541 483 unsigned char hk_lfr_last_rej_tc_type[2];
542 484 unsigned char hk_lfr_last_rej_tc_subtype[2];
543 485 unsigned char hk_lfr_last_rej_tc_time[6];
544 486 // anomaly statistics
545 487 unsigned char hk_lfr_le_cnt[2];
546 488 unsigned char hk_lfr_me_cnt[2];
547 489 unsigned char hk_lfr_he_cnt[2];
548 490 unsigned char hk_lfr_last_er_rid[2];
549 491 unsigned char hk_lfr_last_er_code;
550 492 unsigned char hk_lfr_last_er_time[6];
551 493 // vhdl_blk_status
552 494 unsigned char hk_lfr_vhdl_aa_sm;
553 495 unsigned char hk_lfr_vhdl_fft_sr;
554 496 unsigned char hk_lfr_vhdl_cic_hk;
555 497 unsigned char hk_lfr_vhdl_iir_cal;
556 498 // spacewire_if_statistics
557 499 unsigned char hk_lfr_dpu_spw_pkt_rcv_cnt[2];
558 500 unsigned char hk_lfr_dpu_spw_pkt_sent_cnt[2];
559 501 unsigned char hk_lfr_dpu_spw_tick_out_cnt;
560 502 unsigned char hk_lfr_dpu_spw_last_time;
561 503 // ahb error statistics
562 504 unsigned int hk_lfr_last_fail_addr;
563 505 // temperatures
564 506 unsigned char hk_lfr_temp_scm[2];
565 507 unsigned char hk_lfr_temp_pcb[2];
566 508 unsigned char hk_lfr_temp_fpga[2];
567 509 // error counters
568 510 unsigned char hk_lfr_dpu_spw_parity;
569 511 unsigned char hk_lfr_dpu_spw_disconnect;
570 512 unsigned char hk_lfr_dpu_spw_escape;
571 513 unsigned char hk_lfr_dpu_spw_credit;
572 514 unsigned char hk_lfr_dpu_spw_write_sync;
573 515 unsigned char hk_lfr_dpu_spw_rx_ahb;
574 516 unsigned char hk_lfr_dpu_spw_tx_ahb;
575 517 unsigned char hk_lfr_dpu_spw_header_crc;
576 518 unsigned char hk_lfr_dpu_spw_data_crc;
577 519 unsigned char hk_lfr_dpu_spw_early_eop;
578 520 unsigned char hk_lfr_dpu_spw_invalid_addr;
579 521 unsigned char hk_lfr_dpu_spw_eep;
580 522 unsigned char hk_lfr_dpu_spw_rx_too_big;
581 523 // timecode
582 524 unsigned char hk_lfr_timecode_erroneous;
583 525 unsigned char hk_lfr_timecode_missing;
584 526 unsigned char hk_lfr_timecode_invalid;
585 527 // time
586 528 unsigned char hk_lfr_time_timecode_it;
587 529 unsigned char hk_lfr_time_not_synchro;
588 530 unsigned char hk_lfr_time_timecode_ctr;
589 531 // hk_lfr_buffer_dpu_
590 532 unsigned char hk_lfr_buffer_dpu_tc_fifo;
591 533 unsigned char hk_lfr_buffer_dpu_tm_fifo;
592 534 // hk_lfr_ahb_
593 535 unsigned char hk_lfr_ahb_correctable;
594 536 unsigned char hk_lfr_ahb_uncorrectable;
595 537 unsigned char hk_lfr_ahb_fails_trans;
596 538 // hk_lfr_adc_
597 539 unsigned char hk_lfr_adc_failure;
598 540 unsigned char hk_lfr_adc_timeout;
599 541 unsigned char hk_lfr_toomany_err;
600 542 // hk_lfr_cpu_
601 543 unsigned char hk_lfr_cpu_write_err;
602 544 unsigned char hk_lfr_cpu_ins_access_err;
603 545 unsigned char hk_lfr_cpu_illegal_ins;
604 546 unsigned char hk_lfr_cpu_privilegied_ins;
605 547 unsigned char hk_lfr_cpu_register_hw;
606 548 unsigned char hk_lfr_cpu_not_aligned;
607 549 unsigned char hk_lfr_cpu_data_exception;
608 550 unsigned char hk_lfr_cpu_div_exception;
609 551 unsigned char hk_lfr_cpu_arith_overflow;
610 };
611 typedef struct Packet_TM_LFR_HK_str Packet_TM_LFR_HK_t;
552 } Packet_TM_LFR_HK_t;
612 553
613 struct Packet_TM_LFR_PARAMETER_DUMP_str
614 {
554 typedef struct {
615 555 unsigned char targetLogicalAddress;
616 556 unsigned char protocolIdentifier;
617 557 unsigned char reserved;
618 558 unsigned char userApplication;
619 559 unsigned char packetID[2];
620 560 unsigned char packetSequenceControl[2];
621 561 unsigned char packetLength[2];
622 562 // DATA FIELD HEADER
623 563 unsigned char spare1_pusVersion_spare2;
624 564 unsigned char serviceType;
625 565 unsigned char serviceSubType;
626 566 unsigned char destinationID;
627 567 unsigned char time[6];
628 568 unsigned char sid;
629 569
630 570 //******************
631 571 // COMMON PARAMETERS
632 572 unsigned char unused0;
633 573 unsigned char bw_sp0_sp1_r0_r1;
634 574
635 575 //******************
636 576 // NORMAL PARAMETERS
637 577 unsigned char sy_lfr_n_swf_l[2];
638 578 unsigned char sy_lfr_n_swf_p[2];
639 579 unsigned char sy_lfr_n_asm_p[2];
640 580 unsigned char sy_lfr_n_bp_p0;
641 581 unsigned char sy_lfr_n_bp_p1;
642 582
643 583 //*****************
644 584 // BURST PARAMETERS
645 585 unsigned char sy_lfr_b_bp_p0;
646 586 unsigned char sy_lfr_b_bp_p1;
647 587
648 588 //****************
649 589 // SBM1 PARAMETERS
650 590 unsigned char sy_lfr_s1_bp_p0;
651 591 unsigned char sy_lfr_s1_bp_p1;
652 592
653 593 //****************
654 594 // SBM2 PARAMETERS
655 595 unsigned char sy_lfr_s2_bp_p0;
656 596 unsigned char sy_lfr_s2_bp_p1;
657 };
658 typedef struct Packet_TM_LFR_PARAMETER_DUMP_str Packet_TM_LFR_PARAMETER_DUMP_t;
597 } Packet_TM_LFR_PARAMETER_DUMP_t;
659 598
660 599
661 600 #endif // CCSDS_TYPES_H_INCLUDED
@@ -1,52 +1,35
1 1 #ifndef FSW_INIT_H_INCLUDED
2 2 #define FSW_INIT_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <leon.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "fsw_misc.h"
9 9 #include "fsw_processing.h"
10 10 #include "tc_handler.h"
11 11 #include "wf_handler.h"
12 12
13 13 #include "fsw_spacewire.h"
14 14
15 extern rtems_name misc_name[5];
16 extern rtems_id misc_id[5];
17 extern rtems_name Task_name[20]; /* array of task names */
18 extern rtems_id Task_id[20]; /* array of task ids */
19 extern unsigned int maxCount;
20 extern int fdSPW; // grspw file descriptor
21 extern int fdUART; // uart file descriptor
22 extern unsigned char lfrCurrentMode;
23
24 // MODE PARAMETERS
25 extern struct param_local_str param_local;
26 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
27 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
28 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
29 extern unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
30
31 15 // RTEMS TASKS
32 16 rtems_task Init( rtems_task_argument argument);
33 17
34 18 // OTHER functions
35 19 void create_names( void );
36 20 int create_all_tasks( void );
37 21 int start_all_tasks( void );
38 22 //
39 23 rtems_status_code create_message_queues( void );
40 24 //
41 25 int start_recv_send_tasks( void );
42 26 //
43 27 void init_local_mode_parameters( void );
44 28
45 29 extern int rtems_cpu_usage_report( void );
46 30 extern int rtems_cpu_usage_reset( void );
47 31 extern void rtems_stack_checker_report_usage( void );
48 32
49 33 extern int sched_yield( void );
50 extern int errno;
51 34
52 35 #endif // FSW_INIT_H_INCLUDED
@@ -1,39 +1,39
1 1 #ifndef FSW_MISC_H_INCLUDED
2 2 #define FSW_MISC_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6 #include <grspw.h>
7 7
8 8 #include "fsw_params.h"
9 9 #include "fsw_spacewire.h"
10 10
11 11 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
12 12 rtems_id HK_id; // id of the HK rate monotonic period
13 13
14 extern rtems_name misc_name[5];
15 time_management_regs_t *time_management_regs;
16 extern Packet_TM_LFR_HK_t housekeeping_packet;
14 //extern rtems_name misc_name[5];
15 //time_management_regs_t *time_management_regs;
16 //extern Packet_TM_LFR_HK_t housekeeping_packet;
17 17
18 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
18 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
19 19 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
20 int timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
21 int timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
22 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
20 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
21 void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
22 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
23 23
24 24 // SERIAL LINK
25 25 int send_console_outputs_on_apbuart_port( void );
26 26 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
27 27
28 28 // RTEMS TASKS
29 29 rtems_task stat_task( rtems_task_argument argument );
30 30 rtems_task hous_task( rtems_task_argument argument );
31 31 rtems_task dumb_task( rtems_task_argument unused );
32 32
33 33 void init_housekeeping_parameters( void );
34 34
35 35 void increment_seq_counter( unsigned char *packet_sequence_control);
36 36
37 37 void getTime( unsigned char *time);
38 38
39 39 #endif // FSW_MISC_H_INCLUDED
@@ -1,29 +1,26
1 1 #ifndef FSW_PARAMS_PROCESSING_H
2 2 #define FSW_PARAMS_PROCESSING_H
3 3
4 4 #define NB_BINS_PER_SM 128
5 5 #define NB_VALUES_PER_SM 25
6 //#define TOTAL_SIZE_SM (NB_BINS_PER_SM * NB_VALUES_PER_SM)
7 //#define SM_HEADER 4
8 6 #define TOTAL_SIZE_SM 0
9 7 #define SM_HEADER 0
10 8
11 9 #define NB_BINS_COMPRESSED_SM_F0 11
12 10 #define NB_BINS_COMPRESSED_SM_F1 13
13 11 #define NB_BINS_COMPRESSED_SM_F2 12
14 12 #define TOTAL_SIZE_COMPRESSED_MATRIX_f0 (NB_BINS_COMPRESSED_SM_F0 * NB_VALUES_PER_SM)
15 13 #define NB_AVERAGE_NORMAL_f0 96*4
16 14 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
17 15
18 struct BP1_str{
16 typedef struct {
19 17 volatile unsigned char PE[2];
20 18 volatile unsigned char PB[2];
21 19 volatile unsigned char V0;
22 20 volatile unsigned char V1;
23 21 volatile unsigned char V2_ELLIP_DOP;
24 22 volatile unsigned char SZ;
25 23 volatile unsigned char VPHI;
26 };
27 typedef struct BP1_str BP1_t;
24 } BP1_t;
28 25
29 26 #endif // FSW_PARAMS_PROCESSING_H
@@ -1,67 +1,66
1 1 #ifndef FSW_PROCESSING_H_INCLUDED
2 2 #define FSW_PROCESSING_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <math.h>
7 7 #include <stdlib.h> // abs() is in the stdlib
8 8 #include <stdio.h> // printf()
9 9 #include <math.h>
10 10
11 11 #include "fsw_params.h"
12 12 #include "fsw_spacewire.h"
13 13
14
15 14 extern volatile int spec_mat_f0_0[ ];
16 15 extern volatile int spec_mat_f0_1[ ];
17 16 extern volatile int spec_mat_f0_a[ ];
18 17 extern volatile int spec_mat_f0_b[ ];
19 18 extern volatile int spec_mat_f0_c[ ];
20 19 extern volatile int spec_mat_f0_d[ ];
21 20 extern volatile int spec_mat_f0_e[ ];
22 21 extern volatile int spec_mat_f0_f[ ];
23 22 extern volatile int spec_mat_f0_g[ ];
24 23 extern volatile int spec_mat_f0_h[ ];
25 24
26 25 extern volatile int spec_mat_f1[ ];
27 26 extern volatile int spec_mat_f2[ ];
28 27
29 28 extern volatile int spec_mat_f1_bis[ ];
30 29 extern volatile int spec_mat_f2_bis[ ];
31 30 extern volatile int spec_mat_f0_0_bis[ ];
32 31 extern volatile int spec_mat_f0_1_bis[ ];
33 32
34 33 // parameters
35 34 extern struct param_local_str param_local;
36 35
37 36 // registers
38 37 extern time_management_regs_t *time_management_regs;
39 38 extern spectral_matrix_regs_t *spectral_matrix_regs;
40 39
41 40 extern rtems_name misc_name[5];
42 41 extern rtems_id Task_id[20]; /* array of task ids */
43 42
44 43 // ISR
45 44 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
46 45 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
47 46
48 47 // RTEMS TASKS
49 48 rtems_task spw_bppr_task(rtems_task_argument argument);
50 49 rtems_task avf0_task(rtems_task_argument argument);
51 50 rtems_task bpf0_task(rtems_task_argument argument);
52 51 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
53 52 rtems_task matr_task(rtems_task_argument argument);
54 53
55 54 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat);
56 55 void matrix_reset(volatile float *averaged_spec_mat);
57 56 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
58 57 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
59 58 //
60 59 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
61 60 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
62 61 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
63 62 void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix);
64 63 void fill_averaged_spectral_matrix( void );
65 64 void reset_spectral_matrix_regs();
66 65
67 66 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,41 +1,39
1 1 #ifndef FSW_SPACEWIRE_H_INCLUDED
2 2 #define FSW_SPACEWIRE_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6
7 7 #include <fcntl.h> // for O_RDWR
8 8 #include <unistd.h> // for the read call
9 9 #include <sys/ioctl.h> // for the ioctl call
10 10 #include <errno.h>
11 11
12 12 #include "fsw_params.h"
13 13 #include "tc_handler.h"
14 14
15 15 extern spw_stats spacewire_stats;
16 16 extern spw_stats spacewire_stats_backup;
17 extern Packet_TM_LFR_HK_t housekeeping_packet;
18 extern rtems_id Task_id[20]; /* array of task ids */
19 17
20 18 // RTEMS TASK
21 19 rtems_task spiq_task( rtems_task_argument argument );
22 20 rtems_task recv_task( rtems_task_argument unused );
23 21 rtems_task send_task( rtems_task_argument argument );
24 22 rtems_task wtdg_task( rtems_task_argument argument );
25 23
26 24 int spacewire_open_link( void );
27 25 int spacewire_start_link( int fd );
28 26 int spacewire_stop_start_link( int fd );
29 27 int spacewire_configure_link(int fd );
30 28 int spacewire_reset_link( void );
31 29 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
32 30 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
33 31 void spacewire_compute_stats_offsets( void );
34 32 void spacewire_update_statistics( void );
35 33
36 34 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
37 35 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data );
38 36
39 37 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
40 38
41 39 #endif // FSW_SPACEWIRE_H_INCLUDED
@@ -1,93 +1,67
1 1 #ifndef GRLIB_REGS_H_INCLUDED
2 2 #define GRLIB_REGS_H_INCLUDED
3 3
4 4 #define NB_GPTIMER 3
5 5
6 6 struct apbuart_regs_str{
7 7 volatile unsigned int data;
8 8 volatile unsigned int status;
9 9 volatile unsigned int ctrl;
10 10 volatile unsigned int scaler;
11 11 volatile unsigned int fifoDebug;
12 12 };
13 13
14 14 struct ahbuart_regs_str{
15 15 volatile unsigned int unused;
16 16 volatile unsigned int status;
17 17 volatile unsigned int ctrl;
18 18 volatile unsigned int scaler;
19 19 };
20 20
21 struct timer_regs_str
22 {
21 typedef struct {
23 22 volatile unsigned int counter;
24 23 volatile unsigned int reload;
25 24 volatile unsigned int ctrl;
26 25 volatile unsigned int unused;
27 };
28 typedef struct timer_regs_str timer_regs_t;
26 } timer_regs_t;
29 27
30 struct gptimer_regs_str
31 {
28 typedef struct {
32 29 volatile unsigned int scaler_value;
33 30 volatile unsigned int scaler_reload;
34 31 volatile unsigned int conf;
35 32 volatile unsigned int unused0;
36 33 timer_regs_t timer[NB_GPTIMER];
37 };
38 typedef struct gptimer_regs_str gptimer_regs_t;
34 } gptimer_regs_t;
39 35
40 struct time_management_regs_str{
36 typedef struct {
41 37 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
42 38 volatile int coarse_time_load;
43 39 volatile int coarse_time;
44 40 volatile int fine_time;
45 };
46 typedef struct time_management_regs_str time_management_regs_t;
41 } time_management_regs_t;
47 42
48 struct waveform_picker_regs_str{
43 typedef struct {
49 44 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
50 45 volatile int burst_enable; // 0x04 01 *** burst f2, f1, f0 enable f3, f2, f1, f0
51 46 volatile int addr_data_f0; // 0x08 10 ***
52 47 volatile int addr_data_f1; // 0x0c 11 ***
53 48 volatile int addr_data_f2; // 0x10 100 ***
54 49 volatile int addr_data_f3; // 0x14 101 ***
55 50 volatile int status; // 0x18 110 ***
56 51 volatile int delta_snapshot; // 0x1c 111 ***
57 52 volatile int delta_f2_f1; // 0x20 0000 ***
58 53 volatile int delta_f2_f0; // 0x24 0001 ***
59 54 volatile int nb_burst_available;// 0x28 0010 ***
60 55 volatile int nb_snapshot_param; // 0x2c 0011 ***
61 };
62 typedef struct waveform_picker_regs_str waveform_picker_regs_t;
56 } waveform_picker_regs_t;
63 57
64 struct waveform_picker_regs_str_alt{
65 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
66 volatile int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
67 volatile int addr_data_f0; // 0x08
68 volatile int addr_data_f1; // 0x0c
69 volatile int addr_data_f2; // 0x10
70 volatile int addr_data_f3; // 0x14
71 volatile int status; // 0x18
72 volatile int delta_snapshot; // 0x1c
73 volatile int delta_f0; // 0x20
74 volatile int delta_f0_2;
75 volatile int delta_f1;
76 volatile int delta_f2;
77 volatile int nb_data_by_buffer;
78 volatile int snapshot_param;
79 volatile int start_date;
80 };
81 typedef struct waveform_picker_regs_str_alt waveform_picker_regs_t_alt;
82
83 struct spectral_matrix_regs_str{
58 typedef struct {
84 59 volatile int config;
85 60 volatile int status;
86 61 volatile int matrixF0_Address0;
87 62 volatile int matrixFO_Address1;
88 63 volatile int matrixF1_Address;
89 64 volatile int matrixF2_Address;
90 };
91 typedef struct spectral_matrix_regs_str spectral_matrix_regs_t;
65 } spectral_matrix_regs_t;
92 66
93 67 #endif // GRLIB_REGS_H_INCLUDED
@@ -1,63 +1,54
1 1 #ifndef TC_HANDLER_H_INCLUDED
2 2 #define TC_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <leon.h>
6 6
7 7 #include "tc_load_dump_parameters.h"
8 8 #include "tc_acceptance.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "wf_handler.h"
11 11
12 12 // MODE PARAMETERS
13 extern struct param_sbm1_str param_sbm1;
14 extern struct param_sbm2_str param_sbm2;
15 extern time_management_regs_t *time_management_regs;
16 extern waveform_picker_regs_t *waveform_picker_regs;
17 extern gptimer_regs_t *gptimer_regs;
18 extern rtems_name misc_name[5];
19 extern rtems_id Task_id[20]; /* array of task ids */
20 extern unsigned char lfrCurrentMode;
21 13 extern unsigned int maxCount;
22 14
23
24 15 //****
25 16 // ISR
26 17 rtems_isr commutation_isr1( rtems_vector_number vector );
27 18 rtems_isr commutation_isr2( rtems_vector_number vector );
28 19
29 20 //***********
30 21 // RTEMS TASK
31 22 rtems_task actn_task( rtems_task_argument unused );
32 23
33 24 //***********
34 25 // TC ACTIONS
35 26 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
36 27 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
37 28 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
38 29 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
39 30 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
40 31 int action_update_time(ccsdsTelecommandPacket_t *TC);
41 32
42 33 // mode transition
43 34 int transition_validation(unsigned char requestedMode);
44 35 int stop_current_mode();
45 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
36 int enter_mode(unsigned char mode);
46 37 int enter_standby_mode();
47 38 int enter_normal_mode();
48 39 int enter_burst_mode();
49 40 int enter_sbm1_mode();
50 41 int enter_sbm2_mode();
51 42 int restart_science_tasks();
52 43 int suspend_science_tasks();
53 44
54 45 // other functions
55 46 void updateLFRCurrentMode();
56 47 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time);
57 48 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time);
58 49 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time);
59 50
60 51 #endif // TC_HANDLER_H_INCLUDED
61 52
62 53
63 54
@@ -1,32 +1,27
1 1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 2 #define TC_LOAD_DUMP_PARAMETERS_H
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "wf_handler.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "fsw_misc.h"
11 11
12 extern int fdSPW;
13 extern unsigned char lfrCurrentMode;
14 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
15 extern Packet_TM_LFR_HK_t housekeeping_packet;
16
17 12 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
18 13 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
19 14 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
20 15 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
21 16 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
22 17 int action_dump_par(rtems_id queue_id );
23 18
24 19 int set_sy_lfr_n_swf_l(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
25 20 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
26 21 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
27 22 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
28 23 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
29 24
30 25 void init_parameter_dump( void );
31 26
32 27 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,28 +1,26
1 1 #ifndef TM_LFR_TC_EXE_H_INCLUDED
2 2 #define TM_LFR_TC_EXE_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "fsw_spacewire.h"
9 9
10 extern time_management_regs_t *time_management_regs;
11 extern Packet_TM_LFR_HK_t housekeeping_packet;
12 10 extern unsigned short sequenceCounters_TC_EXE[];
13 11
14 12 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
15 13 int send_tm_lfr_tc_exe_inconsistent(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
16 14 unsigned char byte_position, unsigned char rcv_value, unsigned char *time);
17 15 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
18 16 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
19 17 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
20 18 int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
21 19 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, unsigned char destinationID, unsigned char *time);
22 20
23 21 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id );
24 22
25 23 #endif // TM_LFR_TC_EXE_H_INCLUDED
26 24
27 25
28 26
@@ -1,88 +1,87
1 1 #ifndef WF_HANDLER_H_INCLUDED
2 2 #define WF_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <stdio.h>
7 7 #include <math.h>
8 8
9 9 #include "fsw_params.h"
10 10 #include "fsw_spacewire.h"
11 11 #include "fsw_misc.h"
12 12
13 13 #define pi 3.1415
14 14
15 15 extern int fdSPW;
16 16 extern volatile int wf_snap_f0[ ];
17 17 //
18 18 extern volatile int wf_snap_f1[ ];
19 19 extern volatile int wf_snap_f1_bis[ ];
20 20 extern volatile int wf_snap_f1_norm[ ];
21 21 //
22 22 extern volatile int wf_snap_f2[ ];
23 23 extern volatile int wf_snap_f2_bis[ ];
24 24 extern volatile int wf_snap_f2_norm[ ];
25 25 //
26 26 extern volatile int wf_cont_f3[ ];
27 27 extern volatile int wf_cont_f3_bis[ ];
28 28 extern char wf_cont_f3_light[ ];
29 29 extern waveform_picker_regs_t *waveform_picker_regs;
30 extern waveform_picker_regs_t_alt *waveform_picker_regs_alt;
31 30 extern time_management_regs_t *time_management_regs;
32 31 extern Packet_TM_LFR_HK_t housekeeping_packet;
33 32 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
34 33 extern struct param_local_str param_local;
35 34
36 35 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
37 36 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
38 37
39 38 extern rtems_name misc_name[5];
40 39 extern rtems_name Task_name[20]; /* array of task ids */
41 40 extern rtems_id Task_id[20]; /* array of task ids */
42 41
43 42 extern unsigned char lfrCurrentMode;
44 43
45 44 rtems_isr waveforms_isr( rtems_vector_number vector );
46 45 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
47 46 rtems_task wfrm_task( rtems_task_argument argument );
48 47 rtems_task cwf3_task( rtems_task_argument argument );
49 48 rtems_task cwf2_task( rtems_task_argument argument );
50 49 rtems_task cwf1_task( rtems_task_argument argument );
51 50
52 51 //******************
53 52 // general functions
54 53 void init_waveforms( void );
55 54 //
56 55 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
57 56 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
58 57 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
59 58 //
60 59 void reset_waveforms( void );
61 60 //
62 61 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
63 62 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 63 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 64 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
66 65 //
67 66 rtems_id get_pkts_queue_id( void );
68 67
69 68 //**************
70 69 // wfp registers
71 70 void set_wfp_data_shaping();
72 71 char set_wfp_delta_snapshot();
73 72 void set_wfp_burst_enable_register( unsigned char mode);
74 73 void reset_wfp_burst_enable();
75 74 void reset_wfp_status();
76 75 void reset_waveform_picker_regs();
77 76
78 77 //*****************
79 78 // local parameters
80 void set_local_sbm1_nb_cwf_max();
81 void set_local_sbm2_nb_cwf_max();
82 void set_local_nb_interrupt_f0_MAX();
83 void reset_local_sbm1_nb_cwf_sent();
84 void reset_local_sbm2_nb_cwf_sent();
79 void set_local_sbm1_nb_cwf_max( void );
80 void set_local_sbm2_nb_cwf_max( void );
81 void set_local_nb_interrupt_f0_MAX( void );
82 void reset_local_sbm1_nb_cwf_sent( void );
83 void reset_local_sbm2_nb_cwf_sent( void );
85 84
86 85 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
87 86
88 87 #endif // WF_HANDLER_H_INCLUDED
@@ -1,92 +1,91
1 1 /** Global variables of the LFR flight software.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * Among global variables, there are:
7 7 * - RTEMS names and id.
8 8 * - APB configuration registers.
9 9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 10 * - spectral matrices buffesr, used by the hardware module to store data.
11 11 * - variable related to LFR modes parameters.
12 12 * - the global HK packet buffer.
13 13 * - the global dump parameter buffer.
14 14 *
15 15 */
16 16
17 17 #include <rtems.h>
18 18 #include <grspw.h>
19 19
20 20 #include "ccsds_types.h"
21 21 #include "grlib_regs.h"
22 22 #include "fsw_params.h"
23 23
24 24 // RTEMS GLOBAL VARIABLES
25 25 rtems_name misc_name[5];
26 26 rtems_id misc_id[5];
27 27 rtems_name Task_name[20]; /* array of task names */
28 28 rtems_id Task_id[20]; /* array of task ids */
29 29 unsigned int maxCount;
30 30 int fdSPW = 0;
31 31 int fdUART = 0;
32 32 unsigned char lfrCurrentMode;
33 33
34 34 // APB CONFIGURATION REGISTERS
35 35 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
36 36 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
37 37 #ifdef GSA
38 38 #else
39 39 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
40 waveform_picker_regs_t_alt *waveform_picker_regs_alt = (waveform_picker_regs_t_alt*) REGS_ADDR_WAVEFORM_PICKER;
41 40 #endif
42 41 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
43 42
44 43 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
45 44 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
46 45 //
47 46 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
48 47 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
49 48 volatile int wf_snap_f1_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
50 49 //
51 50 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
52 51 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
53 52 volatile int wf_snap_f2_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
54 53 //
55 54 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
56 55 volatile int wf_cont_f3_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
57 56 char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ];
58 57
59 58 // SPECTRAL MATRICES GLOBAL VARIABLES
60 59 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
61 60 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
62 61 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
63 62 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
64 63 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
65 64 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
66 65 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
67 66 volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ];
68 67 volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ];
69 68 volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ];
70 69 volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ];
71 70 volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
72 71 //
73 72 volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ];
74 73 volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
75 74 //
76 75 volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ];
77 76 volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ];
78 77
79 78 // MODE PARAMETERS
80 79 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
81 80 struct param_local_str param_local;
82 81
83 82 // HK PACKETS
84 83 Packet_TM_LFR_HK_t housekeeping_packet;
85 84 // sequence counters are incremented by APID (PID + CAT) and destination ID
86 85 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
87 86 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
88 87 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
89 88 spw_stats spacewire_stats;
90 89 spw_stats spacewire_stats_backup;
91 90
92 91
@@ -1,333 +1,336
1 1 /** General usage functions and RTEMS tasks.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 */
7 7
8 8 #include "fsw_misc.h"
9 9
10 char *DumbMessages[7] = {"in DUMB *** default", // RTEMS_EVENT_0
11 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
12 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
13 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
14 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
15 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
16 "ERR HK" // RTEMS_EVENT_6
17 };
10 //char *DumbMessages[7] = {"in DUMB *** default", // RTEMS_EVENT_0
11 // "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
12 // "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
13 // "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
14 // "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
15 // "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
16 // "ERR HK" // RTEMS_EVENT_6
17 //};
18 18
19 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
19 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
20 20 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
21 21 {
22 22 /** This function configures a GPTIMER timer instantiated in the VHDL design.
23 23 *
24 24 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
25 25 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
26 26 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
27 27 * @param interrupt_level is the interrupt level that the timer drives.
28 28 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
29 29 *
30 * @return
31 *
32 30 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
33 31 *
34 32 */
35 33
36 34 rtems_status_code status;
37 35 rtems_isr_entry old_isr_handler;
38 36
39 37 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
40 38 if (status!=RTEMS_SUCCESSFUL)
41 39 {
42 40 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
43 41 }
44 42
45 43 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
46
47 return 1;
48 44 }
49 45
50 int timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
46 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
51 47 {
52 48 /** This function starts a GPTIMER timer.
53 49 *
54 50 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
55 51 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
56 52 *
57 * @return 1
58 *
59 53 */
60 54
61 55 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
62 56 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
63 57 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
64 58 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
65 59 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
66
67 return 1;
68 60 }
69 61
70 int timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
62 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
71 63 {
72 64 /** This function stops a GPTIMER timer.
73 65 *
74 66 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
75 67 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
76 68 *
77 * @return 1
78 *
79 69 */
80 70
81 71 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
82 72 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
83 73 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
84
85 return 1;
86 74 }
87 75
88 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
76 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
89 77 {
90 78 /** This function sets the clock divider of a GPTIMER timer.
91 79 *
92 80 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
93 81 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
94 82 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
95 83 *
96 * @return 1
97 *
98 84 */
99 85
100 86 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
101
102 return 1;
103 87 }
104 88
105 89 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
106 90 {
107 91 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
108 92
109 93 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
110 94 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
111 95
112 96 return 0;
113 97 }
114 98
115 99 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
116 100 {
117 101 /** This function sets the scaler reload register of the apbuart module
118 102 *
119 103 * @param regs is the address of the apbuart registers in memory
120 104 * @param value is the value that will be stored in the scaler register
121 105 *
122 106 * The value shall be set by the software to get data on the serial interface.
123 107 *
124 108 */
125 109
126 110 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
127 111
128 112 apbuart_regs->scaler = value;
129 113 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
130 114 }
131 115
132 116 //************
133 117 // RTEMS TASKS
134 118
135 119 rtems_task stat_task(rtems_task_argument argument)
136 120 {
137 121 int i;
138 122 int j;
139 123 i = 0;
140 124 j = 0;
141 125 BOOT_PRINTF("in STAT *** \n")
142 126 while(1){
143 127 rtems_task_wake_after(1000);
144 128 PRINTF1("%d\n", j)
145 129 if (i == CPU_USAGE_REPORT_PERIOD) {
146 130 // #ifdef PRINT_TASK_STATISTICS
147 131 // rtems_cpu_usage_report();
148 132 // rtems_cpu_usage_reset();
149 133 // #endif
150 134 i = 0;
151 135 }
152 136 else i++;
153 137 j++;
154 138 }
155 139 }
156 140
157 141 rtems_task hous_task(rtems_task_argument argument)
158 142 {
159 143 rtems_status_code status;
160 144 rtems_id queue_id;
161 145
162 146 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
163 147 if (status != RTEMS_SUCCESSFUL)
164 148 {
165 149 PRINTF1("in HOUS *** ERR %d\n", status)
166 150 }
167 151
168 152 BOOT_PRINTF("in HOUS ***\n")
169 153
170 154 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
171 155 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
172 156 if( status != RTEMS_SUCCESSFUL ) {
173 157 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
174 158 }
175 159 }
176 160
177 161 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
178 162 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
179 163 housekeeping_packet.reserved = DEFAULT_RESERVED;
180 164 housekeeping_packet.userApplication = CCSDS_USER_APP;
181 165 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
182 166 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
183 167 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
184 168 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
185 169 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
186 170 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
187 171 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
188 172 housekeeping_packet.serviceType = TM_TYPE_HK;
189 173 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
190 174 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
191 175
192 176 status = rtems_rate_monotonic_cancel(HK_id);
193 177 if( status != RTEMS_SUCCESSFUL ) {
194 178 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
195 179 }
196 180 else {
197 181 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
198 182 }
199 183
200 184 while(1){ // launch the rate monotonic task
201 185 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
202 186 if ( status != RTEMS_SUCCESSFUL ) {
203 187 PRINTF1( "in HOUS *** ERR period: %d\n", status);
204 188 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
205 189 }
206 190 else {
207 191 increment_seq_counter( housekeeping_packet.packetSequenceControl );
208 192 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
209 193 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
210 194 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
211 195 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
212 196 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
213 197 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
214 198 housekeeping_packet.sid = SID_HK;
215 199
216 200 spacewire_update_statistics();
217 201
218 202 // SEND PACKET
219 203 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
220 204 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
221 205 if (status != RTEMS_SUCCESSFUL) {
222 206 PRINTF1("in HOUS *** ERR send: %d\n", status)
223 207 }
224 208 }
225 209 }
226 210
227 211 PRINTF("in HOUS *** deleting task\n")
228 212
229 213 status = rtems_task_delete( RTEMS_SELF ); // should not return
230 214 printf( "rtems_task_delete returned with status of %d.\n", status );
231 215 return;
232 216 }
233 217
234 218 rtems_task dumb_task( rtems_task_argument unused )
235 219 {
236 220 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
237 221 *
238 222 * @param unused is the starting argument of the RTEMS task
239 223 *
240 224 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
241 225 *
242 226 */
243 227
244 228 unsigned int i;
245 229 unsigned int intEventOut;
246 230 unsigned int coarse_time = 0;
247 231 unsigned int fine_time = 0;
248 232 rtems_event_set event_out;
249 233
234 char *DumbMessages[7] = {"in DUMB *** default", // RTEMS_EVENT_0
235 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
236 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
237 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
238 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
239 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
240 "ERR HK" // RTEMS_EVENT_6
241 };
242
250 243 BOOT_PRINTF("in DUMB *** \n")
251 244
252 245 while(1){
253 246 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
254 247 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6,
255 248 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
256 249 intEventOut = (unsigned int) event_out;
257 250 for ( i=0; i<32; i++)
258 251 {
259 252 if ( ((intEventOut >> i) & 0x0001) != 0)
260 253 {
261 254 coarse_time = time_management_regs->coarse_time;
262 255 fine_time = time_management_regs->fine_time;
263 256 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
264 257 }
265 258 }
266 259 }
267 260 }
268 261
269 262 //*****************************
270 263 // init housekeeping parameters
271 264
272 265 void init_housekeeping_parameters( void )
273 266 {
274 267 /** This function initialize the housekeeping_packet global variable with default values.
275 268 *
276 269 */
277 270
278 271 unsigned int i = 0;
279 272 char *parameters;
280 273
281 274 parameters = (char*) &housekeeping_packet.lfr_status_word;
282 275 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
283 276 {
284 277 parameters[i] = 0x00;
285 278 }
286 279 // init status word
287 280 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
288 281 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
289 282 // init software version
290 283 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
291 284 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
292 285 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
293 286 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
294 287
295 288 }
296 289
297 290 void increment_seq_counter( unsigned char *packet_sequence_control)
298 291 {
292 /** This function increment the sequence counter psased in argument.
293 *
294 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
295 *
296 */
297
299 298 unsigned short sequence_cnt;
300 299 unsigned short segmentation_grouping_flag;
301 300 unsigned short new_packet_sequence_control;
302 301
303 302 segmentation_grouping_flag = (unsigned short) ( (packet_sequence_control[0] & 0xc0) << 8 ); // keep bits 7 downto 6
304 303 sequence_cnt = (unsigned short) (
305 304 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
306 305 + packet_sequence_control[1]
307 306 );
308 307
309 308 if ( sequence_cnt < SEQ_CNT_MAX)
310 309 {
311 310 sequence_cnt = sequence_cnt + 1;
312 311 }
313 312 else
314 313 {
315 314 sequence_cnt = 0;
316 315 }
317 316
318 317 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
319 318
320 319 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
321 320 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
322 321 }
323 322
324 323 void getTime( unsigned char *time)
325 324 {
325 /** This function write the current local time in the time buffer passed in argument.
326 *
327 */
328
326 329 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
327 330 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
328 331 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
329 332 time[3] = (unsigned char) (time_management_regs->coarse_time);
330 333 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
331 334 time[5] = (unsigned char) (time_management_regs->fine_time);
332 335 }
333 336
@@ -1,677 +1,656
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include <fsw_processing.h>
11 11
12 12 #include "fsw_processing_globals.c"
13 13
14 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_SM_F0 * 9 ];
15 14 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
16 15 float averaged_spec_mat_f0[ TOTAL_SIZE_SM ];
17 16 char averaged_spec_mat_f0_char[ TOTAL_SIZE_SM * 2 ];
18 17 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
19 18
20 19 //***********************************************************
21 20 // Interrupt Service Routine for spectral matrices processing
22 21 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
23 22 {
24 23 unsigned char status;
25 24 unsigned char i;
26 25
27 26 status = spectral_matrix_regs->status; //[f2 f1 f0_1 f0_0]
28 27 for (i=0; i<4; i++)
29 28 {
30 29 if ( ( (status >> i) & 0x01) == 1) // (1) buffer rotation
31 30 {
32 31 switch(i)
33 32 {
34 33 case 0:
35 34 if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0)
36 35 {
37 36 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0_bis;
38 37 }
39 38 else
40 39 {
41 40 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
42 41 }
43 42 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
44 43 break;
45 44 case 1:
46 45 if (spectral_matrix_regs->matrixFO_Address1 == (int) spec_mat_f0_1)
47 46 {
48 47 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1_bis;
49 48 }
50 49 else
51 50 {
52 51 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1;
53 52 }
54 53 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd;
55 54 break;
56 55 case 2:
57 56 if (spectral_matrix_regs->matrixF1_Address == (int) spec_mat_f1)
58 57 {
59 58 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1_bis;
60 59 }
61 60 else
62 61 {
63 62 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1;
64 63 }
65 64 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb;
66 65 break;
67 66 case 3:
68 67 if (spectral_matrix_regs->matrixF2_Address == (int) spec_mat_f2)
69 68 {
70 69 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2_bis;
71 70 }
72 71 else
73 72 {
74 73 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2;
75 74 }
76 75 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7;
77 76 break;
78 77 default:
79 78 break;
80 79 }
81 80 }
82 81 }
83 82
84 83 // reset error codes to 0
85 84 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // [1100 1111]
86 85
87 86 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
88 87 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
89 88 }
90 89 }
91 90
92 91 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
93 92 {
94 93 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
95 94 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
96 95 }
97 96 }
98 97
99 98 //************
100 99 // RTEMS TASKS
101 100
102 101 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
103 102 {
104 103 rtems_event_set event_out;
105 104 unsigned int nb_interrupt_f0 = 0;
106 105
107 106 BOOT_PRINTF("in SMIQ *** \n")
108 107
109 108 while(1){
110 109 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
111 110 nb_interrupt_f0 = nb_interrupt_f0 + 1;
112 111 if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){
113 112 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
114 113 {
115 114 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
116 115 }
117 116 nb_interrupt_f0 = 0;
118 117 }
119 118 }
120 119 }
121 120
122 //rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
123 //{
124 // rtems_event_set event_out;
125 // unsigned int nb_interrupt_f0 = 0;
126
127 // PRINTF("in SMIQ *** \n")
128
129 // while(1){
130 // rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
131 // nb_interrupt_f0 = nb_interrupt_f0 + 1;
132 // if (nb_interrupt_f0 == param_local.local_nb_interrupt_f0_MAX ){
133 // if (rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
134 // {
135 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
136 // }
137 // nb_interrupt_f0 = 0;
138 // }
139 // }
140 //}
141
142 121 rtems_task spw_bppr_task(rtems_task_argument argument)
143 122 {
144 123 rtems_status_code status;
145 124 rtems_event_set event_out;
146 125
147 126 BOOT_PRINTF("in BPPR ***\n");
148 127
149 128 while( true ){ // wait for an event to begin with the processing
150 129 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
151 130 }
152 131 }
153 132
154 133 rtems_task avf0_task(rtems_task_argument argument)
155 134 {
156 135 int i;
157 136 static int nb_average;
158 137 rtems_event_set event_out;
159 138 rtems_status_code status;
160 139
161 140 nb_average = 0;
162 141
163 142 BOOT_PRINTF("in AVFO *** \n")
164 143
165 144 while(1){
166 145 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
167 146 for(i=0; i<TOTAL_SIZE_SM; i++){
168 147 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
169 148 + spec_mat_f0_b[i]
170 149 + spec_mat_f0_c[i]
171 150 + spec_mat_f0_d[i]
172 151 + spec_mat_f0_e[i]
173 152 + spec_mat_f0_f[i]
174 153 + spec_mat_f0_g[i]
175 154 + spec_mat_f0_h[i];
176 155 }
177 156 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
178 157 if (nb_average == NB_AVERAGE_NORMAL_f0) {
179 158 nb_average = 0;
180 159 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
181 160 if (status != RTEMS_SUCCESSFUL) {
182 161 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
183 162 }
184 163 }
185 164 }
186 165 }
187 166
188 167 rtems_task bpf0_task(rtems_task_argument argument)
189 168 {
190 169 rtems_event_set event_out;
170 static unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_SM_F0 * 9 ];
191 171
192 172 BOOT_PRINTF("in BPFO *** \n")
193 173
194 174 while(1){
195 175 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
196 176 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
197 177 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0);
198 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
199 178 }
200 179 }
201 180
202 181 rtems_task matr_task(rtems_task_argument argument)
203 182 {
204 183 spw_ioctl_pkt_send spw_ioctl_send_ASM;
205 184 rtems_event_set event_out;
206 185 rtems_status_code status;
207 186 rtems_id queue_id;
208 187 Header_TM_LFR_SCIENCE_ASM_t headerASM;
209 188
210 189 init_header_asm( &headerASM );
211 190
212 191 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
213 192 if (status != RTEMS_SUCCESSFUL)
214 193 {
215 194 PRINTF1("in MATR *** ERR getting queue id, %d\n", status)
216 195 }
217 196
218 197 BOOT_PRINTF("in MATR *** \n")
219 198
220 199 fill_averaged_spectral_matrix( );
221 200
222 201 while(1){
223 202 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
224 203
225 204 #ifdef GSA
226 205 #else
227 206 fill_averaged_spectral_matrix( );
228 207 #endif
229 208 convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char);
230 209
231 210 send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
232 211 }
233 212 }
234 213
235 214 //*****************************
236 215 // Spectral matrices processing
237 216
238 217 void matrix_reset(volatile float *averaged_spec_mat)
239 218 {
240 // int i;
241 // for(i=0; i<TOTAL_SIZE_SM; i++){
242 // averaged_spec_mat_f0[i] = 0;
243 // }
219 int i;
220 for(i=0; i<TOTAL_SIZE_SM; i++){
221 averaged_spec_mat[i] = 0;
222 }
244 223 }
245 224
246 225 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
247 226 {
248 227 int i;
249 228 int j;
250 229 switch (fChannel){
251 230 case 0:
252 231 for(i=0;i<NB_BINS_COMPRESSED_SM_F0;i++){
253 232 j = 17 + (i * 8);
254 233 compressed_spec_mat[i] = (averaged_spec_mat[j]
255 234 + averaged_spec_mat[j+1]
256 235 + averaged_spec_mat[j+2]
257 236 + averaged_spec_mat[j+3]
258 237 + averaged_spec_mat[j+4]
259 238 + averaged_spec_mat[j+5]
260 239 + averaged_spec_mat[j+6]
261 240 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
262 241 }
263 242 break;
264 243 case 1:
265 244 // case fChannel = f1 to be completed later
266 245 break;
267 246 case 2:
268 247 // case fChannel = f1 to be completed later
269 248 break;
270 249 default:
271 250 break;
272 251 }
273 252 }
274 253
275 254 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
276 255 int i;
277 256 int j;
278 257 unsigned char tmp_u_char;
279 258 unsigned char * pt_char = NULL;
280 259 float PSDB, PSDE;
281 260 float NVEC_V0;
282 261 float NVEC_V1;
283 262 float NVEC_V2;
284 263 //float significand;
285 264 //int exponent;
286 265 float aux;
287 266 float tr_SB_SB;
288 267 float tmp;
289 268 float sx_re;
290 269 float sx_im;
291 270 float nebx_re = 0;
292 271 float nebx_im = 0;
293 272 float ny = 0;
294 273 float nz = 0;
295 274 float bx_bx_star = 0;
296 275 for(i=0; i<nb_bins_compressed_spec_mat; i++){
297 276 //==============================================
298 277 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
299 278 PSDB = compressed_spec_mat[i*30] // S11
300 279 + compressed_spec_mat[(i*30) + 10] // S22
301 280 + compressed_spec_mat[(i*30) + 18]; // S33
302 281 //significand = frexp(PSDB, &exponent);
303 282 pt_char = (unsigned char*) &PSDB;
304 283 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
305 284 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
306 285 //==============================================
307 286 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
308 287 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
309 288 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
310 289 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
311 290 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
312 291 pt_char = (unsigned char*) &PSDE;
313 292 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
314 293 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
315 294 //==============================================================================
316 295 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
317 296 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
318 297 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
319 298 tmp = sqrt(
320 299 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
321 300 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
322 301 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
323 302 );
324 303 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
325 304 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
326 305 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
327 306 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
328 307 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
329 308 pt_char = (unsigned char*) &NVEC_V2;
330 309 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
331 310 //=======================================================
332 311 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
333 312 aux = 2*tmp / PSDB; // compute the ellipticity
334 313 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
335 314 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
336 315 //==============================================================
337 316 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
338 317 for(j = 0; j<NB_VALUES_PER_SM;j++){
339 318 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
340 319 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
341 320 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
342 321 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
343 322 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
344 323 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
345 324 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
346 325 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
347 326 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
348 327 }
349 328 aux = PSDB*PSDB;
350 329 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
351 330 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
352 331 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
353 332 //=======================================================================================
354 333 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
355 334 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
356 335 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
357 336 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
358 337 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
359 338 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
360 339 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
361 340 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
362 341 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
363 342 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
364 343 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
365 344 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
366 345 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
367 346 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
368 347 if ( abs(sx_re) > abs(sx_im) ) {
369 348 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
370 349 }
371 350 else {
372 351 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
373 352 }
374 353 //======================================================================
375 354 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
376 355 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
377 356 nz = NVEC_V0;
378 357 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
379 358 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
380 359 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
381 360 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
382 361 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
383 362 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
384 363 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
385 364 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
386 365 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
387 366 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
388 367 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
389 368 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
390 369 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
391 370 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
392 371 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
393 372 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
394 373 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
395 374 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
396 375 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
397 376 tmp = nebx_re / bx_bx_star;
398 377 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
399 378 if ( abs(nebx_re) > abs(nebx_im) ) {
400 379 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
401 380 }
402 381 else {
403 382 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
404 383 }
405 384 }
406 385
407 386 }
408 387
409 388 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
410 389 // BP2 autocorrelation
411 390 int i;
412 391 int aux = 0;
413 392
414 393 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
415 394 // S12
416 395 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
417 396 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
418 397 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
419 398 // S13
420 399 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
421 400 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
422 401 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
423 402 // S23
424 403 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
425 404 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
426 405 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
427 406 // S45
428 407 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
429 408 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
430 409 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
431 410 // S14
432 411 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
433 412 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
434 413 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
435 414 // S15
436 415 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
437 416 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
438 417 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
439 418 // S24
440 419 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
441 420 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
442 421 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
443 422 // S25
444 423 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
445 424 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
446 425 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
447 426 // S34
448 427 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
449 428 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
450 429 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
451 430 // S35
452 431 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
453 432 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
454 433 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
455 434 }
456 435 }
457 436
458 437 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header)
459 438 {
460 439 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
461 440 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
462 441 header->reserved = 0x00;
463 442 header->userApplication = CCSDS_USER_APP;
464 443 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
465 444 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
466 445 header->packetSequenceControl[0] = 0xc0;
467 446 header->packetSequenceControl[1] = 0x00;
468 447 header->packetLength[0] = 0x00;
469 448 header->packetLength[1] = 0x00;
470 449 // DATA FIELD HEADER
471 450 header->spare1_pusVersion_spare2 = 0x10;
472 451 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
473 452 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
474 453 header->destinationID = TM_DESTINATION_ID_GROUND;
475 454 // AUXILIARY DATA HEADER
476 455 header->sid = 0x00;
477 456 header->biaStatusInfo = 0x00;
478 457 header->cntASM = 0x00;
479 458 header->nrASM = 0x00;
480 459 header->time[0] = 0x00;
481 460 header->time[0] = 0x00;
482 461 header->time[0] = 0x00;
483 462 header->time[0] = 0x00;
484 463 header->time[0] = 0x00;
485 464 header->time[0] = 0x00;
486 465 header->blkNr[0] = 0x00; // BLK_NR MSB
487 466 header->blkNr[1] = 0x00; // BLK_NR LSB
488 467 }
489 468
490 469 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
491 470 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
492 471 {
493 472 unsigned int i;
494 473 unsigned int length = 0;
495 474 rtems_status_code status;
496 475
497 476 header->sid = (unsigned char) sid;
498 477
499 478 for (i=0; i<2; i++)
500 479 {
501 480 // BUILD THE DATA
502 481 spw_ioctl_send->dlen = TOTAL_SIZE_SM;
503 482 spw_ioctl_send->data = &spectral_matrix[ i * TOTAL_SIZE_SM];
504 483 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
505 484 spw_ioctl_send->hdr = (char *) header;
506 485 spw_ioctl_send->options = 0;
507 486
508 487 // BUILD THE HEADER
509 488 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM;
510 489 header->packetLength[0] = (unsigned char) (length>>8);
511 490 header->packetLength[1] = (unsigned char) (length);
512 491 header->sid = (unsigned char) sid; // SID
513 492 header->cntASM = 2;
514 493 header->nrASM = (unsigned char) (i+1);
515 494 header->blkNr[0] =(unsigned char) ( (NB_BINS_PER_SM/2) >> 8 ); // BLK_NR MSB
516 495 header->blkNr[1] = (unsigned char) (NB_BINS_PER_SM/2); // BLK_NR LSB
517 496 // SET PACKET TIME
518 497 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
519 498 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
520 499 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
521 500 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
522 501 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
523 502 header->time[5] = (unsigned char) (time_management_regs->fine_time);
524 503 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
525 504 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
526 505 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
527 506 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
528 507 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
529 508 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
530 509 // SEND PACKET
531 510 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
532 511 if (status != RTEMS_SUCCESSFUL) {
533 512 printf("in send_spectral_matrix *** ERR %d\n", (int) status);
534 513 }
535 514 }
536 515 }
537 516
538 517 void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix)
539 518 {
540 519 unsigned int i;
541 520 unsigned int j;
542 521 char * pt_char_input;
543 522 char * pt_char_output;
544 523
545 524 pt_char_input = NULL;
546 525 pt_char_output = NULL;
547 526
548 527 for( i=0; i<NB_BINS_PER_SM; i++)
549 528 {
550 529 for ( j=0; j<NB_VALUES_PER_SM; j++)
551 530 {
552 531 pt_char_input = (char*) &input_matrix[ (i*NB_VALUES_PER_SM) + j ];
553 532 pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ];
554 533 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
555 534 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
556 535 }
557 536 }
558 537 }
559 538
560 539 void fill_averaged_spectral_matrix(void)
561 540 {
562 541 /** This function fills spectral matrices related buffers with arbitrary data.
563 542 *
564 543 * This function is for testing purpose only.
565 544 *
566 545 */
567 546
568 547 #ifdef GSA
569 548 float offset = 10.;
570 549 float coeff = 100000.;
571 550
572 551 averaged_spec_mat_f0[ 0 + 25 * 0 ] = 0. + offset;
573 552 averaged_spec_mat_f0[ 0 + 25 * 1 ] = 1. + offset;
574 553 averaged_spec_mat_f0[ 0 + 25 * 2 ] = 2. + offset;
575 554 averaged_spec_mat_f0[ 0 + 25 * 3 ] = 3. + offset;
576 555 averaged_spec_mat_f0[ 0 + 25 * 4 ] = 4. + offset;
577 556 averaged_spec_mat_f0[ 0 + 25 * 5 ] = 5. + offset;
578 557 averaged_spec_mat_f0[ 0 + 25 * 6 ] = 6. + offset;
579 558 averaged_spec_mat_f0[ 0 + 25 * 7 ] = 7. + offset;
580 559 averaged_spec_mat_f0[ 0 + 25 * 8 ] = 8. + offset;
581 560 averaged_spec_mat_f0[ 0 + 25 * 9 ] = 9. + offset;
582 561 averaged_spec_mat_f0[ 0 + 25 * 10 ] = 10. + offset;
583 562 averaged_spec_mat_f0[ 0 + 25 * 11 ] = 11. + offset;
584 563 averaged_spec_mat_f0[ 0 + 25 * 12 ] = 12. + offset;
585 564 averaged_spec_mat_f0[ 0 + 25 * 13 ] = 13. + offset;
586 565 averaged_spec_mat_f0[ 0 + 25 * 14 ] = 14. + offset;
587 566 averaged_spec_mat_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff;
588 567 averaged_spec_mat_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff;
589 568 averaged_spec_mat_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff;
590 569 averaged_spec_mat_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff;
591 570 averaged_spec_mat_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff;
592 571 averaged_spec_mat_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff;
593 572 averaged_spec_mat_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff;
594 573 averaged_spec_mat_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff;
595 574 averaged_spec_mat_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff;
596 575 averaged_spec_mat_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff;
597 576 averaged_spec_mat_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff;
598 577 averaged_spec_mat_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff;
599 578 averaged_spec_mat_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff;
600 579 averaged_spec_mat_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff;
601 580 averaged_spec_mat_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff;
602 581 offset = 10000000;
603 582 averaged_spec_mat_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff;
604 583 averaged_spec_mat_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff;
605 584 averaged_spec_mat_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff;
606 585 averaged_spec_mat_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff;
607 586 averaged_spec_mat_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff;
608 587 averaged_spec_mat_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff;
609 588 averaged_spec_mat_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff;
610 589 averaged_spec_mat_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff;
611 590 averaged_spec_mat_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff;
612 591 averaged_spec_mat_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff;
613 592 averaged_spec_mat_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff;
614 593 averaged_spec_mat_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff;
615 594 averaged_spec_mat_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff;
616 595 averaged_spec_mat_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff;
617 596 averaged_spec_mat_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff;
618 597
619 598 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_spec_mat_f0[ 0 ];
620 599 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_spec_mat_f0[ 1 ];
621 600 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_spec_mat_f0[ 2 ];
622 601 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_spec_mat_f0[ 3 ];
623 602 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_spec_mat_f0[ 4 ];
624 603 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_spec_mat_f0[ 5 ];
625 604 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_spec_mat_f0[ 6 ];
626 605 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_spec_mat_f0[ 7 ];
627 606 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_spec_mat_f0[ 8 ];
628 607 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_spec_mat_f0[ 9 ];
629 608 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_spec_mat_f0[ 10 ];
630 609 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_spec_mat_f0[ 11 ];
631 610 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_spec_mat_f0[ 12 ];
632 611 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_spec_mat_f0[ 13 ];
633 612 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_spec_mat_f0[ 14 ];
634 613 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_spec_mat_f0[ 15 ];
635 614 #else
636 615 unsigned int i;
637 616
638 617 for(i=0; i<TOTAL_SIZE_SM; i++)
639 618 {
640 619 if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0)
641 620 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0_bis[ SM_HEADER + i ];
642 621 else
643 622 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0[ SM_HEADER + i ];
644 623 }
645 624 #endif
646 625 }
647 626
648 627 void reset_spectral_matrix_regs()
649 628 {
650 629 /** This function resets the spectral matrices module registers.
651 630 *
652 631 * The registers affected by this function are located at the following offset addresses:
653 632 *
654 633 * - 0x00 config
655 634 * - 0x04 status
656 635 * - 0x08 matrixF0_Address0
657 636 * - 0x10 matrixFO_Address1
658 637 * - 0x14 matrixF1_Address
659 638 * - 0x18 matrixF2_Address
660 639 *
661 640 */
662 641
663 642 #ifdef GSA
664 643 #else
665 644 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
666 645 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1;
667 646 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1;
668 647 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2;
669 648 #endif
670 649 }
671 650
672 651 //******************
673 652 // general functions
674 653
675 654
676 655
677 656
@@ -1,626 +1,624
1 1 /** Functions related to the SpaceWire interface.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle SpaceWire transmissions:
7 7 * - configuration of the SpaceWire link
8 8 * - SpaceWire related interruption requests processing
9 9 * - transmission of TeleMetry packets by a dedicated RTEMS task
10 10 * - reception of TeleCommands by a dedicated RTEMS task
11 11 *
12 12 */
13 13
14 14 #include "fsw_spacewire.h"
15 15
16 char *lstates[6] = {"Error-reset",
17 "Error-wait",
18 "Ready",
19 "Started",
20 "Connecting",
21 "Run"
22 };
23
24 16 rtems_name semq_name;
25 17 rtems_id semq_id;
26 18
27 19 //***********
28 20 // RTEMS TASK
29 21 rtems_task spiq_task(rtems_task_argument unused)
30 22 {
31 23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
32 24 *
33 25 * @param unused is the starting argument of the RTEMS task
34 26 *
35 27 */
36 28
37 29 rtems_event_set event_out;
38 30 rtems_status_code status;
39 31 int linkStatus;
40 32
41 33 BOOT_PRINTF("in SPIQ *** \n")
42 34
43 35 while(true){
44 36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
45 37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
46 38
47 39 // [0] SUSPEND RECV AND SEND TASKS
48 rtems_task_suspend( Task_id[ TASKID_RECV ] );
49 rtems_task_suspend( Task_id[ TASKID_SEND ] );
40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
41 if ( status != RTEMS_SUCCESSFUL ) {
42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
43 }
44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
45 if ( status != RTEMS_SUCCESSFUL ) {
46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
47 }
50 48
51 49 // [1] CHECK THE LINK
52 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
53 51 if ( linkStatus != 5) {
54 52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
55 rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
56 54 }
57 55
58 56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
59 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
60 58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
61 59 {
62 60 spacewire_compute_stats_offsets();
63 61 status = spacewire_reset_link( );
64 62 }
65 63 else // [2.b] in run state, start the link
66 64 {
67 65 status = spacewire_stop_start_link( fdSPW ); // start the link
68 66 if ( status != RTEMS_SUCCESSFUL)
69 67 {
70 68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
71 69 }
72 70 }
73 71
74 72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
75 73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
76 74 {
77 75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
78 76 if ( status != RTEMS_SUCCESSFUL ) {
79 77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
80 78 }
81 79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
82 80 if ( status != RTEMS_SUCCESSFUL ) {
83 81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
84 82 }
85 83 }
86 84 else // [3.b] the link is not in run state, go in STANDBY mode
87 85 {
88 86 status = stop_current_mode();
89 87 if ( status != RTEMS_SUCCESSFUL ) {
90 88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
91 89 }
92 90 status = enter_standby_mode();
93 91 if ( status != RTEMS_SUCCESSFUL ) {
94 92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
95 93 }
96 94 // wake the WTDG task up to wait for the link recovery
97 95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
98 rtems_task_suspend( RTEMS_SELF );
96 status = rtems_task_suspend( RTEMS_SELF );
99 97 }
100 98 }
101 99 }
102 100
103 101 rtems_task recv_task( rtems_task_argument unused )
104 102 {
105 103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
106 104 *
107 105 * @param unused is the starting argument of the RTEMS task
108 106 *
109 107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
110 108 * 1. It reads the incoming data.
111 109 * 2. Launches the acceptance procedure.
112 110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
113 111 *
114 112 */
115 113
116 114 int len;
117 115 ccsdsTelecommandPacket_t currentTC;
118 116 unsigned char computed_CRC[ 2 ];
119 117 unsigned char currentTC_LEN_RCV[ 2 ];
120 118 unsigned char destinationID;
121 119 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
122 120 unsigned int parserCode;
123 121 unsigned char time[6];
124 122 rtems_status_code status;
125 123 rtems_id queue_recv_id;
126 124 rtems_id queue_send_id;
127 125
128 126 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
129 127
130 128 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_recv_id );
131 129 if (status != RTEMS_SUCCESSFUL)
132 130 {
133 131 PRINTF1("in RECV *** ERR getting QUEUE_RECV id, %d\n", status)
134 132 }
135 133
136 134 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_send_id );
137 135 if (status != RTEMS_SUCCESSFUL)
138 136 {
139 137 PRINTF1("in RECV *** ERR getting QUEUE_SEND id, %d\n", status)
140 138 }
141 139
142 140 BOOT_PRINTF("in RECV *** \n")
143 141
144 142 while(1)
145 143 {
146 144 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
147 145 if (len == -1){ // error during the read call
148 146 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
149 147 }
150 148 else {
151 149 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
152 150 PRINTF("in RECV *** packet lenght too short\n")
153 151 }
154 152 else {
155 153 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
156 154 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
157 155 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
158 156 // CHECK THE TC
159 157 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
160 158 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
161 159 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
162 160 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
163 161 || (parserCode == WRONG_SRC_ID) )
164 162 { // send TM_LFR_TC_EXE_CORRUPTED
165 163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
166 164 &&
167 165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
168 166 )
169 167 {
170 168 if ( parserCode == WRONG_SRC_ID )
171 169 {
172 170 destinationID = SID_TC_GROUND;
173 171 }
174 172 else
175 173 {
176 174 destinationID = currentTC.sourceID;
177 175 }
178 176 getTime( time );
179 177 close_action( &currentTC, LFR_DEFAULT, queue_send_id, time);
180 178 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
181 179 computed_CRC, currentTC_LEN_RCV,
182 180 destinationID, time );
183 181 }
184 182 }
185 183 else
186 184 { // send valid TC to the action launcher
187 185 status = rtems_message_queue_send( queue_recv_id, &currentTC,
188 186 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
189 187 }
190 188 }
191 189 }
192 190 }
193 191 }
194 192
195 193 rtems_task send_task( rtems_task_argument argument)
196 194 {
197 195 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
198 196 *
199 197 * @param unused is the starting argument of the RTEMS task
200 198 *
201 199 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
202 200 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
203 201 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
204 202 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
205 203 * data it contains.
206 204 *
207 205 */
208 206
209 207 rtems_status_code status; // RTEMS status code
210 208 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
211 209 spw_ioctl_pkt_send *spw_ioctl_send;
212 210 size_t size; // size of the incoming TC packet
213 211 u_int32_t count;
214 212 rtems_id queue_id;
215 213
216 214 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
217 215 if (status != RTEMS_SUCCESSFUL)
218 216 {
219 217 PRINTF1("in SEND *** ERR getting queue id, %d\n", status)
220 218 }
221 219
222 220 BOOT_PRINTF("in SEND *** \n")
223 221
224 222 while(1)
225 223 {
226 224 status = rtems_message_queue_receive( queue_id, incomingData, &size,
227 225 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
228 226
229 227 if (status!=RTEMS_SUCCESSFUL)
230 228 {
231 229 PRINTF1("in SEND *** (1) ERR = %d\n", status)
232 230 }
233 231 else
234 232 {
235 233 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
236 234 {
237 235 status = write( fdSPW, incomingData, size );
238 236 if (status == -1){
239 237 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
240 238 }
241 239 }
242 240 else // the incoming message is a spw_ioctl_pkt_send structure
243 241 {
244 242 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
245 243 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
246 244 if (status == -1){
247 245 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
248 246 }
249 247 }
250 248 }
251 249
252 250 status = rtems_message_queue_get_number_pending( queue_id, &count );
253 251 if (status != RTEMS_SUCCESSFUL)
254 252 {
255 253 PRINTF1("in SEND *** (3) ERR = %d\n", status)
256 254 }
257 255 else
258 256 {
259 257 if (count > maxCount)
260 258 {
261 259 maxCount = count;
262 260 }
263 261 }
264 262 }
265 263 }
266 264
267 265 rtems_task wtdg_task( rtems_task_argument argument )
268 266 {
269 267 rtems_event_set event_out;
270 268 rtems_status_code status;
271 269 int linkStatus;
272 270
273 271 BOOT_PRINTF("in WTDG ***\n")
274 272
275 273 while(1)
276 274 {
277 275 // wait for an RTEMS_EVENT
278 276 rtems_event_receive( RTEMS_EVENT_0,
279 277 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
280 278 PRINTF("in WTDG *** wait for the link\n")
281 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
279 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
282 280 while( linkStatus != 5) // wait for the link
283 281 {
284 282 rtems_task_wake_after( 10 );
285 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
283 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
286 284 }
287 285
288 286 status = spacewire_stop_start_link( fdSPW );
289 287
290 288 if (status != RTEMS_SUCCESSFUL)
291 289 {
292 290 PRINTF1("in WTDG *** ERR link not started %d\n", status)
293 291 }
294 292 else
295 293 {
296 294 PRINTF("in WTDG *** OK link started\n")
297 295 }
298 296
299 297 // restart the SPIQ task
300 298 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
301 299 if ( status != RTEMS_SUCCESSFUL ) {
302 300 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
303 301 }
304 302
305 303 // restart RECV and SEND
306 304 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
307 305 if ( status != RTEMS_SUCCESSFUL ) {
308 306 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
309 307 }
310 308 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
311 309 if ( status != RTEMS_SUCCESSFUL ) {
312 310 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
313 311 }
314 312 }
315 313 }
316 314
317 315 //****************
318 316 // OTHER FUNCTIONS
319 317 int spacewire_open_link( void )
320 318 {
321 319 /** This function opens the SpaceWire link.
322 320 *
323 321 * @return a valid file descriptor in case of success, -1 in case of a failure
324 322 *
325 323 */
326 324 rtems_status_code status;
327 325
328 326 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
329 327 if ( fdSPW < 0 ) {
330 328 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
331 329 }
332 330 else
333 331 {
334 332 status = RTEMS_SUCCESSFUL;
335 333 }
336 334
337 335 return status;
338 336 }
339 337
340 338 int spacewire_start_link( int fd )
341 339 {
342 340 rtems_status_code status;
343 341
344 342 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
345 343 // -1 default hardcoded driver timeout
346 344
347 345 return status;
348 346 }
349 347
350 348 int spacewire_stop_start_link( int fd )
351 349 {
352 350 rtems_status_code status;
353 351
354 352 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
355 353 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
356 354 // -1 default hardcoded driver timeout
357 355
358 356 return status;
359 357 }
360 358
361 359 int spacewire_configure_link( int fd )
362 360 {
363 361 /** This function configures the SpaceWire link.
364 362 *
365 363 * @return GR-RTEMS-DRIVER directive status codes:
366 364 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
367 365 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
368 366 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
369 367 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
370 368 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
371 369 * - 5 EIO - Error when writing to grswp hardware registers.
372 370 * - 2 ENOENT - No such file or directory
373 371 */
374 372
375 373 rtems_status_code status;
376 374
377 375 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
378 376 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
379 377
380 378 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
381 379 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
382 380 //
383 381 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
384 382 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
385 383 //
386 384 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
387 385 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
388 386 //
389 387 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
390 388 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
391 389 //
392 390 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
393 391 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
394 392 //
395 393 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
396 394 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
397 395 //
398 396 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
399 397 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
400 398
401 399 return status;
402 400 }
403 401
404 402 int spacewire_reset_link( void )
405 403 {
406 404 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
407 405 *
408 406 * @return RTEMS directive status code:
409 407 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
410 408 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
411 409 *
412 410 */
413 411
414 412 rtems_status_code status_spw;
415 413 int i;
416 414
417 415 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
418 416 {
419 417 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
420 418
421 419 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
422 420
423 421 status_spw = spacewire_stop_start_link( fdSPW );
424 422 if ( status_spw != RTEMS_SUCCESSFUL )
425 423 {
426 424 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
427 425 }
428 426
429 427 if ( status_spw == RTEMS_SUCCESSFUL)
430 428 {
431 429 break;
432 430 }
433 431 }
434 432
435 433 return status_spw;
436 434 }
437 435
438 436 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
439 437 {
440 438 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
441 439 *
442 440 * @param val is the value, 0 or 1, used to set the value of the NP bit.
443 441 * @param regAddr is the address of the GRSPW control register.
444 442 *
445 443 * NP is the bit 20 of the GRSPW control register.
446 444 *
447 445 */
448 446
449 447 unsigned int *spwptr = (unsigned int*) regAddr;
450 448
451 449 if (val == 1) {
452 450 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
453 451 }
454 452 if (val== 0) {
455 453 *spwptr = *spwptr & 0xffdfffff;
456 454 }
457 455 }
458 456
459 457 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
460 458 {
461 459 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
462 460 *
463 461 * @param val is the value, 0 or 1, used to set the value of the RE bit.
464 462 * @param regAddr is the address of the GRSPW control register.
465 463 *
466 464 * RE is the bit 16 of the GRSPW control register.
467 465 *
468 466 */
469 467
470 468 unsigned int *spwptr = (unsigned int*) regAddr;
471 469
472 470 if (val == 1)
473 471 {
474 472 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
475 473 }
476 474 if (val== 0)
477 475 {
478 476 *spwptr = *spwptr & 0xfffdffff;
479 477 }
480 478 }
481 479
482 480 void spacewire_compute_stats_offsets( void )
483 481 {
484 482 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
485 483 *
486 484 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
487 485 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
488 486 * during the open systel call).
489 487 *
490 488 */
491 489
492 490 spw_stats spacewire_stats_grspw;
493 491 rtems_status_code status;
494 492
495 493 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
496 494
497 495 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
498 496 + spacewire_stats.packets_received;
499 497 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
500 498 + spacewire_stats.packets_sent;
501 499 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
502 500 + spacewire_stats.parity_err;
503 501 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
504 502 + spacewire_stats.disconnect_err;
505 503 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
506 504 + spacewire_stats.escape_err;
507 505 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
508 506 + spacewire_stats.credit_err;
509 507 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
510 508 + spacewire_stats.write_sync_err;
511 509 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
512 510 + spacewire_stats.rx_rmap_header_crc_err;
513 511 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
514 512 + spacewire_stats.rx_rmap_data_crc_err;
515 513 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
516 514 + spacewire_stats.early_ep;
517 515 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
518 516 + spacewire_stats.invalid_address;
519 517 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
520 518 + spacewire_stats.rx_eep_err;
521 519 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
522 520 + spacewire_stats.rx_truncated;
523 521 }
524 522
525 523 void spacewire_update_statistics( void )
526 524 {
527 525 rtems_status_code status;
528 526 spw_stats spacewire_stats_grspw;
529 527
530 528 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
531 529
532 530 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
533 531 + spacewire_stats_grspw.packets_received;
534 532 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
535 533 + spacewire_stats_grspw.packets_sent;
536 534 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
537 535 + spacewire_stats_grspw.parity_err;
538 536 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
539 537 + spacewire_stats_grspw.disconnect_err;
540 538 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
541 539 + spacewire_stats_grspw.escape_err;
542 540 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
543 541 + spacewire_stats_grspw.credit_err;
544 542 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
545 543 + spacewire_stats_grspw.write_sync_err;
546 544 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
547 545 + spacewire_stats_grspw.rx_rmap_header_crc_err;
548 546 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
549 547 + spacewire_stats_grspw.rx_rmap_data_crc_err;
550 548 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
551 549 + spacewire_stats_grspw.early_ep;
552 550 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
553 551 + spacewire_stats_grspw.invalid_address;
554 552 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
555 553 + spacewire_stats_grspw.rx_eep_err;
556 554 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
557 555 + spacewire_stats_grspw.rx_truncated;
558 556 //spacewire_stats.tx_link_err;
559 557
560 558 //****************************
561 559 // DPU_SPACEWIRE_IF_STATISTICS
562 560 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
563 561 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
564 562 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
565 563 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
566 564 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
567 565 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
568 566
569 567 //******************************************
570 568 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
571 569 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
572 570 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
573 571 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
574 572 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
575 573 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
576 574 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
577 575 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
578 576 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
579 577 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
580 578
581 579 //*********************************************
582 580 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
583 581 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
584 582 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
585 583 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
586 584 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
587 585
588 586 }
589 587
590 588 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
591 589 {
592 590 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
593 591 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
594 592 //}
595 593 }
596 594
597 595 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
598 596 {
599 597 int linkStatus;
600 598 rtems_status_code status;
601 599
602 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
600 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
603 601
604 602 if ( linkStatus == 5) {
605 603 PRINTF("in spacewire_reset_link *** link is running\n")
606 604 status = RTEMS_SUCCESSFUL;
607 605 }
608 606 }
609 607
610 608 rtems_status_code rtems_message_queue_send_lfr( rtems_id id, const void *buffer, size_t size )
611 609 {
612 610 rtems_status_code status;
613 611 rtems_mode previous_mode_set;
614 612
615 613 // set the preemption OFF
616 614 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &previous_mode_set );
617 615
618 616 // use the message queue
619 617 status = rtems_message_queue_send_lfr( id, buffer, size );
620 618
621 619 // set the preemption ON
622 620 status = rtems_task_mode( RTEMS_PREEMPT , RTEMS_PREEMPT_MASK, &previous_mode_set );
623 621
624 622 return status;
625 623 }
626 624
@@ -1,771 +1,862
1 1 /** Functions and tasks related to TeleCommand handling.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TeleCommands:\n
7 7 * action launching\n
8 8 * TC parsing\n
9 9 * ...
10 10 *
11 11 */
12 12
13 13 #include "tc_handler.h"
14 14
15 15 //***********
16 16 // RTEMS TASK
17 17
18 18 rtems_task actn_task( rtems_task_argument unused )
19 19 {
20 20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 21 *
22 22 * @param unused is the starting argument of the RTEMS task
23 23 *
24 24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 25 * on the incoming TeleCommand.
26 26 *
27 27 */
28 28
29 29 int result;
30 30 rtems_status_code status; // RTEMS status code
31 31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 32 size_t size; // size of the incoming TC packet
33 33 unsigned char subtype; // subtype of the current TC packet
34 34 unsigned char time[6];
35 35 rtems_id queue_rcv_id;
36 36 rtems_id queue_snd_id;
37 37
38 38 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_rcv_id );
39 39 if (status != RTEMS_SUCCESSFUL)
40 40 {
41 41 PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status)
42 42 }
43 43
44 44 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_snd_id );
45 45 if (status != RTEMS_SUCCESSFUL)
46 46 {
47 47 PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status)
48 48 }
49 49
50 50 result = LFR_SUCCESSFUL;
51 51 subtype = 0; // subtype of the current TC packet
52 52
53 53 BOOT_PRINTF("in ACTN *** \n")
54 54
55 55 while(1)
56 56 {
57 57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 59 getTime( time ); // set time to the current time
60 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
60 if (status!=RTEMS_SUCCESSFUL)
61 {
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 }
61 64 else
62 65 {
63 66 subtype = TC.serviceSubType;
64 67 switch(subtype)
65 68 {
66 69 case TC_SUBTYPE_RESET:
67 70 result = action_reset( &TC, queue_snd_id, time );
68 71 close_action( &TC, result, queue_snd_id, time );
69 72 break;
70 73 //
71 74 case TC_SUBTYPE_LOAD_COMM:
72 75 result = action_load_common_par( &TC );
73 76 close_action( &TC, result, queue_snd_id, time );
74 77 break;
75 78 //
76 79 case TC_SUBTYPE_LOAD_NORM:
77 80 result = action_load_normal_par( &TC, queue_snd_id, time );
78 81 close_action( &TC, result, queue_snd_id, time );
79 82 break;
80 83 //
81 84 case TC_SUBTYPE_LOAD_BURST:
82 85 result = action_load_burst_par( &TC, queue_snd_id, time );
83 86 close_action( &TC, result, queue_snd_id, time );
84 87 break;
85 88 //
86 89 case TC_SUBTYPE_LOAD_SBM1:
87 90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
88 91 close_action( &TC, result, queue_snd_id, time );
89 92 break;
90 93 //
91 94 case TC_SUBTYPE_LOAD_SBM2:
92 95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
93 96 close_action( &TC, result, queue_snd_id, time );
94 97 break;
95 98 //
96 99 case TC_SUBTYPE_DUMP:
97 100 result = action_dump_par( queue_snd_id );
98 101 close_action( &TC, result, queue_snd_id, time );
99 102 break;
100 103 //
101 104 case TC_SUBTYPE_ENTER:
102 105 result = action_enter_mode( &TC, queue_snd_id, time );
103 106 close_action( &TC, result, queue_snd_id, time );
104 107 break;
105 108 //
106 109 case TC_SUBTYPE_UPDT_INFO:
107 110 result = action_update_info( &TC, queue_snd_id );
108 111 close_action( &TC, result, queue_snd_id, time );
109 112 break;
110 113 //
111 114 case TC_SUBTYPE_EN_CAL:
112 115 result = action_enable_calibration( &TC, queue_snd_id, time );
113 116 close_action( &TC, result, queue_snd_id, time );
114 117 break;
115 118 //
116 119 case TC_SUBTYPE_DIS_CAL:
117 120 result = action_disable_calibration( &TC, queue_snd_id, time );
118 121 close_action( &TC, result, queue_snd_id, time );
119 122 break;
120 123 //
121 124 case TC_SUBTYPE_UPDT_TIME:
122 125 result = action_update_time( &TC );
123 126 close_action( &TC, result, queue_snd_id, time );
124 127 break;
125 128 //
126 129 default:
127 130 break;
128 131 }
129 132 }
130 133 }
131 134 }
132 135
133 136 //***********
134 137 // TC ACTIONS
135 138
136 139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
137 140 {
138 141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
139 142 *
140 143 * @param TC points to the TeleCommand packet that is being processed
141 144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
142 145 *
143 146 */
144 147
145 148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
146 149 return LFR_DEFAULT;
147 150 }
148 151
149 152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
150 153 {
151 154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
152 155 *
153 156 * @param TC points to the TeleCommand packet that is being processed
154 157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
155 158 *
156 159 */
157 160
158 161 rtems_status_code status;
159 162 unsigned char requestedMode;
160 163
161 164 requestedMode = TC->dataAndCRC[1];
162 165
163 166 if ( (requestedMode != LFR_MODE_STANDBY)
164 167 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
165 168 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
166 169 {
167 170 status = RTEMS_UNSATISFIED;
168 171 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode, time );
169 172 }
170 173 else
171 174 {
172 175 printf("try to enter mode %d\n", requestedMode);
173 176
174 177 #ifdef PRINT_TASK_STATISTICS
175 178 if (requestedMode != LFR_MODE_STANDBY)
176 179 {
177 180 rtems_cpu_usage_reset();
178 181 maxCount = 0;
179 182 }
180 183 #endif
181 184
182 185 status = transition_validation(requestedMode);
183 186
184 187 if ( status == LFR_SUCCESSFUL ) {
185 188 if ( lfrCurrentMode != LFR_MODE_STANDBY)
186 189 {
187 190 status = stop_current_mode();
188 191 }
189 192 if (status != RTEMS_SUCCESSFUL)
190 193 {
191 194 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
192 195 }
193 status = enter_mode(requestedMode, TC);
196 status = enter_mode( requestedMode );
194 197 }
195 198 else
196 199 {
197 200 PRINTF("ERR *** in action_enter *** transition rejected\n")
198 201 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
199 202 }
200 203 }
201 204
202 205 return status;
203 206 }
204 207
205 208 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
206 209 {
207 210 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
208 211 *
209 212 * @param TC points to the TeleCommand packet that is being processed
210 213 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
211 214 *
212 215 * @return LFR directive status code:
213 216 * - LFR_DEFAULT
214 217 * - LFR_SUCCESSFUL
215 218 *
216 219 */
217 220
218 221 unsigned int val;
219 222 int result;
220 223
221 224 result = LFR_SUCCESSFUL;
222 225
223 226 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
224 227 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
225 228 val++;
226 229 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
227 230 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
228 231
229 232 return result;
230 233 }
231 234
232 235 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
233 236 {
234 237 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
235 238 *
236 239 * @param TC points to the TeleCommand packet that is being processed
237 240 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
238 241 *
239 242 */
240 243
241 244 int result;
242 245 unsigned char lfrMode;
243 246
244 247 result = LFR_DEFAULT;
245 248 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
246 249
247 250 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
248 251 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
249 252 result = LFR_DEFAULT;
250 253 }
251 254 else {
252 255 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
253 256 result = LFR_DEFAULT;
254 257 }
255 258 return result;
256 259 }
257 260
258 261 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
259 262 {
260 263 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
261 264 *
262 265 * @param TC points to the TeleCommand packet that is being processed
263 266 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
264 267 *
265 268 */
266 269
267 270 int result;
268 271 unsigned char lfrMode;
269 272
270 273 result = LFR_DEFAULT;
271 274 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
272 275
273 276 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
274 277 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
275 278 result = LFR_DEFAULT;
276 279 }
277 280 else {
278 281 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
279 282 result = LFR_DEFAULT;
280 283 }
281 284 return result;
282 285 }
283 286
284 287 int action_update_time(ccsdsTelecommandPacket_t *TC)
285 288 {
286 289 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
287 290 *
288 291 * @param TC points to the TeleCommand packet that is being processed
289 292 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
290 293 *
291 294 * @return LFR_SUCCESSFUL
292 295 *
293 296 */
294 297
295 298 unsigned int val;
296 299
297 300 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
298 301 + (TC->dataAndCRC[1] << 16)
299 302 + (TC->dataAndCRC[2] << 8)
300 303 + TC->dataAndCRC[3];
301 304 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
302 305 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
303 306 val++;
304 307 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
305 308 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
306 309 time_management_regs->ctrl = time_management_regs->ctrl | 1;
307 310
308 311 return LFR_SUCCESSFUL;
309 312 }
310 313
311 314 //*******************
312 315 // ENTERING THE MODES
313 316
314 317 int transition_validation(unsigned char requestedMode)
315 318 {
319 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
320 *
321 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
322 *
323 * @return LFR directive status codes:
324 * - LFR_SUCCESSFUL - the transition is authorized
325 * - LFR_DEFAULT - the transition is not authorized
326 *
327 */
328
316 329 int status;
317 330
318 331 switch (requestedMode)
319 332 {
320 333 case LFR_MODE_STANDBY:
321 334 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
322 335 status = LFR_DEFAULT;
323 336 }
324 337 else
325 338 {
326 339 status = LFR_SUCCESSFUL;
327 340 }
328 341 break;
329 342 case LFR_MODE_NORMAL:
330 343 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
331 344 status = LFR_DEFAULT;
332 345 }
333 346 else {
334 347 status = LFR_SUCCESSFUL;
335 348 }
336 349 break;
337 350 case LFR_MODE_BURST:
338 351 if ( lfrCurrentMode == LFR_MODE_BURST ) {
339 352 status = LFR_DEFAULT;
340 353 }
341 354 else {
342 355 status = LFR_SUCCESSFUL;
343 356 }
344 357 break;
345 358 case LFR_MODE_SBM1:
346 359 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
347 360 status = LFR_DEFAULT;
348 361 }
349 362 else {
350 363 status = LFR_SUCCESSFUL;
351 364 }
352 365 break;
353 366 case LFR_MODE_SBM2:
354 367 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
355 368 status = LFR_DEFAULT;
356 369 }
357 370 else {
358 371 status = LFR_SUCCESSFUL;
359 372 }
360 373 break;
361 374 default:
362 375 status = LFR_DEFAULT;
363 376 break;
364 377 }
365 378
366 379 return status;
367 380 }
368 381
369 382 int stop_current_mode()
370 383 {
371 384 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
372 385 *
373 386 * @return RTEMS directive status codes:
374 387 * - RTEMS_SUCCESSFUL - task restarted successfully
375 388 * - RTEMS_INVALID_ID - task id invalid
376 389 * - RTEMS_ALREADY_SUSPENDED - task already suspended
377 390 *
378 391 */
379 392
380 393 rtems_status_code status;
381 394
382 395 status = RTEMS_SUCCESSFUL;
383 396
384 397 #ifdef GSA
385 398 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
386 399 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
387 400 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
388 401 #else
389 402 // mask interruptions
390 403 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
391 404 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
392 405 // reset registers
393 406 reset_wfp_burst_enable(); // reset burst and enable bits
394 407 reset_wfp_status(); // reset all the status bits
395 408 // creal interruptions
396 409 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
397 410 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectarl matrix interrupt
398 411 #endif
399 412 //**********************
400 413 // suspend several tasks
401 414 if (lfrCurrentMode != LFR_MODE_STANDBY) {
402 415 status = suspend_science_tasks();
403 416 }
404 417
405 418 if (status != RTEMS_SUCCESSFUL)
406 419 {
407 420 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
408 421 }
409 422
410 423 return status;
411 424 }
412 425
413 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC )
426 int enter_mode(unsigned char mode )
414 427 {
428 /** This function is launched after a mode transition validation.
429 *
430 * @param mode is the mode in which LFR will be put.
431 *
432 * @return RTEMS directive status codes:
433 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
434 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
435 *
436 */
437
415 438 rtems_status_code status;
416 439
417 440 status = RTEMS_UNSATISFIED;
418 441
419 442 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
420 443 updateLFRCurrentMode();
421 444
422 445 switch(mode){
423 446 case LFR_MODE_STANDBY:
424 447 status = enter_standby_mode( );
425 448 break;
426 449 case LFR_MODE_NORMAL:
427 450 status = enter_normal_mode( );
428 451 break;
429 452 case LFR_MODE_BURST:
430 453 status = enter_burst_mode( );
431 454 break;
432 455 case LFR_MODE_SBM1:
433 456 status = enter_sbm1_mode( );
434 457 break;
435 458 case LFR_MODE_SBM2:
436 459 status = enter_sbm2_mode( );
437 460 break;
438 461 default:
439 462 status = RTEMS_UNSATISFIED;
440 463 }
441 464
442 465 if (status != RTEMS_SUCCESSFUL)
443 466 {
444 467 PRINTF("in enter_mode *** ERR\n")
445 468 status = RTEMS_UNSATISFIED;
446 469 }
447 470
448 471 return status;
449 472 }
450 473
451 474 int enter_standby_mode()
452 475 {
476 /** This function is used to enter the STANDBY mode.
477 *
478 * @return RTEMS directive status codes:
479 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
480 *
481 */
482
453 483 PRINTF1("maxCount = %d\n", maxCount)
454 484
455 485 #ifdef PRINT_TASK_STATISTICS
456 486 rtems_cpu_usage_report();
457 487 #endif
458 488
459 489 #ifdef PRINT_STACK_REPORT
460 490 rtems_stack_checker_report_usage();
461 491 #endif
462 492
463 493 return LFR_SUCCESSFUL;
464 494 }
465 495
466 496 int enter_normal_mode()
467 497 {
468 498 rtems_status_code status;
469 499
470 500 status = restart_science_tasks();
471 501
472 502 #ifdef GSA
473 503 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
474 504 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
475 505 LEON_Clear_interrupt( IRQ_WF );
476 506 LEON_Unmask_interrupt( IRQ_WF );
477 507 //
478 508 set_local_nb_interrupt_f0_MAX();
479 509 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
480 510 LEON_Unmask_interrupt( IRQ_SM );
481 511 #else
482 512 //****************
483 513 // waveform picker
484 514 reset_waveform_picker_regs();
485 515 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
486 516 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
487 517 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
488 518 //****************
489 519 // spectral matrix
490 520 #endif
491 521
492 522 return status;
493 523 }
494 524
495 525 int enter_burst_mode()
496 526 {
527 /** This function is used to enter the STANDBY mode.
528 *
529 * @return RTEMS directive status codes:
530 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
531 * - RTEMS_INVALID_ID - task id invalid
532 * - RTEMS_INCORRECT_STATE - task never started
533 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
534 *
535 */
536
497 537 rtems_status_code status;
498 538
499 539 status = restart_science_tasks();
500 540
501 541 #ifdef GSA
502 542 LEON_Unmask_interrupt( IRQ_SM );
503 543 #else
504 544 reset_waveform_picker_regs();
505 545 set_wfp_burst_enable_register(LFR_MODE_BURST);
506 546 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
507 547 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
508 548 #endif
509 549
510 550 return status;
511 551 }
512 552
513 553 int enter_sbm1_mode()
514 554 {
555 /** This function is used to enter the SBM1 mode.
556 *
557 * @return RTEMS directive status codes:
558 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
559 * - RTEMS_INVALID_ID - task id invalid
560 * - RTEMS_INCORRECT_STATE - task never started
561 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
562 *
563 */
564
515 565 rtems_status_code status;
516 566
517 567 status = restart_science_tasks();
518 568
519 569 set_local_sbm1_nb_cwf_max();
520 570
521 571 reset_local_sbm1_nb_cwf_sent();
522 572
523 573 #ifdef GSA
524 574 LEON_Unmask_interrupt( IRQ_SM );
525 575 #else
526 576 reset_waveform_picker_regs();
527 577 set_wfp_burst_enable_register(LFR_MODE_SBM1);
528 578 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
529 579 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
530 // SM simulation
531 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
532 // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
533 // LEON_Unmask_interrupt( IRQ_SM );
534 580 #endif
535 581
536 582 return status;
537 583 }
538 584
539 585 int enter_sbm2_mode()
540 586 {
587 /** This function is used to enter the SBM2 mode.
588 *
589 * @return RTEMS directive status codes:
590 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
591 * - RTEMS_INVALID_ID - task id invalid
592 * - RTEMS_INCORRECT_STATE - task never started
593 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
594 *
595 */
596
541 597 rtems_status_code status;
542 598
543 599 status = restart_science_tasks();
544 600
545 601 set_local_sbm2_nb_cwf_max();
546 602
547 603 reset_local_sbm2_nb_cwf_sent();
548 604
549 605 #ifdef GSA
550 606 LEON_Unmask_interrupt( IRQ_SM );
551 607 #else
552 608 reset_waveform_picker_regs();
553 609 set_wfp_burst_enable_register(LFR_MODE_SBM2);
554 610 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
555 611 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
556 612 #endif
557 613
558 614 return status;
559 615 }
560 616
561 617 int restart_science_tasks()
562 618 {
619 /** This function is used to restart all science tasks.
620 *
621 * @return RTEMS directive status codes:
622 * - RTEMS_SUCCESSFUL - task restarted successfully
623 * - RTEMS_INVALID_ID - task id invalid
624 * - RTEMS_INCORRECT_STATE - task never started
625 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
626 *
627 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
628 *
629 */
630
563 631 rtems_status_code status[6];
564 632 rtems_status_code ret;
565 633
566 634 ret = RTEMS_SUCCESSFUL;
567 635
568 636 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
569 637 if (status[0] != RTEMS_SUCCESSFUL)
570 638 {
571 639 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
572 640 }
573 641
574 642 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
575 643 if (status[1] != RTEMS_SUCCESSFUL)
576 644 {
577 645 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
578 646 }
579 647
580 648 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
581 649 if (status[2] != RTEMS_SUCCESSFUL)
582 650 {
583 651 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
584 652 }
585 653
586 654 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
587 655 if (status[3] != RTEMS_SUCCESSFUL)
588 656 {
589 657 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
590 658 }
591 659
592 660 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
593 661 if (status[4] != RTEMS_SUCCESSFUL)
594 662 {
595 663 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
596 664 }
597 665
598 666 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
599 667 if (status[5] != RTEMS_SUCCESSFUL)
600 668 {
601 669 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
602 670 }
603 671
604 672 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
605 673 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
606 674 {
607 675 ret = RTEMS_UNSATISFIED;
608 676 }
609 677
610 678 return ret;
611 679 }
612 680
613 681 int suspend_science_tasks()
614 682 {
615 683 /** This function suspends the science tasks.
616 684 *
617 685 * @return RTEMS directive status codes:
618 686 * - RTEMS_SUCCESSFUL - task restarted successfully
619 687 * - RTEMS_INVALID_ID - task id invalid
620 688 * - RTEMS_ALREADY_SUSPENDED - task already suspended
621 689 *
622 690 */
623 691
624 692 rtems_status_code status;
625 693
626 694 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
627 695 if (status != RTEMS_SUCCESSFUL)
628 696 {
629 697 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
630 698 }
631 699
632 700 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
633 701 {
634 702 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
635 703 if (status != RTEMS_SUCCESSFUL)
636 704 {
637 705 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
638 706 }
639 707 }
640 708
641 709 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
642 710 {
643 711 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
644 712 if (status != RTEMS_SUCCESSFUL)
645 713 {
646 714 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
647 715 }
648 716 }
649 717
650 718 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
651 719 {
652 720 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
653 721 if (status != RTEMS_SUCCESSFUL)
654 722 {
655 723 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
656 724 }
657 725 }
658 726
659 727 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
660 728 {
661 729 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
662 730 if (status != RTEMS_SUCCESSFUL)
663 731 {
664 732 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
665 733 }
666 734 }
667 735
668 736 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
669 737 {
670 738 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
671 739 if (status != RTEMS_SUCCESSFUL)
672 740 {
673 741 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
674 742 }
675 743 }
676 744
677 745 return status;
678 746 }
679 747
680 748 //****************
681 749 // CLOSING ACTIONS
682 750 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time)
683 751 {
752 /** This function is used to update the HK packets statistics after a successful TC execution.
753 *
754 * @param TC points to the TC being processed
755 * @param time is the time used to date the TC execution
756 *
757 */
758
684 759 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
685 760 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
686 761 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
687 762 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
688 763 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
689 764 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
690 765 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
691 766 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
692 767 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
693 768 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
694 769 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
695 770 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
696 771 }
697 772
698 773 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time)
699 774 {
775 /** This function is used to update the HK packets statistics after a TC rejection.
776 *
777 * @param TC points to the TC being processed
778 * @param time is the time used to date the TC rejection
779 *
780 */
781
700 782 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
701 783 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
702 784 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
703 785 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
704 786 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
705 787 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
706 788 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
707 789 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
708 790 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
709 791 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
710 792 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
711 793 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
712 794 }
713 795
714 796 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time)
715 797 {
798 /** This function is the last step of the TC execution workflow.
799 *
800 * @param TC points to the TC being processed
801 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
802 * @param queue_id is the id of the RTEMS message queue used to send TM packets
803 * @param time is the time used to date the TC execution
804 *
805 */
806
716 807 unsigned int val = 0;
717 808
718 809 if (result == LFR_SUCCESSFUL)
719 810 {
720 811 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
721 812 &&
722 813 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
723 814 )
724 815 {
725 816 send_tm_lfr_tc_exe_success( TC, queue_id, time );
726 817 }
727 818 update_last_TC_exe( TC, time );
728 819 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
729 820 val++;
730 821 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
731 822 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
732 823 }
733 824 else
734 825 {
735 826 update_last_TC_rej( TC, time );
736 827 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
737 828 val++;
738 829 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
739 830 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
740 831 }
741 832 }
742 833
743 834 //***************************
744 835 // Interrupt Service Routines
745 836 rtems_isr commutation_isr1( rtems_vector_number vector )
746 837 {
747 838 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
748 839 printf("In commutation_isr1 *** Error sending event to DUMB\n");
749 840 }
750 841 }
751 842
752 843 rtems_isr commutation_isr2( rtems_vector_number vector )
753 844 {
754 845 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
755 846 printf("In commutation_isr2 *** Error sending event to DUMB\n");
756 847 }
757 848 }
758 849
759 850 //****************
760 851 // OTHER FUNCTIONS
761 852 void updateLFRCurrentMode()
762 853 {
763 854 /** This function updates the value of the global variable lfrCurrentMode.
764 855 *
765 856 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
766 857 *
767 858 */
768 859 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
769 860 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
770 861 }
771 862
@@ -1,492 +1,501
1 1 /** Functions to send TM packets related to TC parsing and execution.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to send appropriate TM packets after parsing and execution:
7 7 * - TM_LFR_TC_EXE_SUCCESS
8 8 * - TM_LFR_TC_EXE_INCONSISTENT
9 9 * - TM_LFR_TC_EXE_NOT_EXECUTABLE
10 10 * - TM_LFR_TC_EXE_NOT_IMPLEMENTED
11 11 * - TM_LFR_TC_EXE_ERROR
12 12 * - TM_LFR_TC_EXE_CORRUPTED
13 13 *
14 14 */
15 15
16 16 #include "tm_lfr_tc_exe.h"
17 17
18 18 int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
19 19 {
20 20 /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue.
21 21 *
22 22 * @param TC points to the TeleCommand packet that is being processed
23 23 * @param queue_id is the id of the queue which handles TM
24 24 *
25 25 * @return RTEMS directive status code:
26 26 * - RTEMS_SUCCESSFUL - message sent successfully
27 27 * - RTEMS_INVALID_ID - invalid queue id
28 28 * - RTEMS_INVALID_SIZE - invalid message size
29 29 * - RTEMS_INVALID_ADDRESS - buffer is NULL
30 30 * - RTEMS_UNSATISFIED - out of message buffers
31 31 * - RTEMS_TOO_MANY - queue s limit has been reached
32 32 *
33 33 */
34 34
35 35 rtems_status_code status;
36 36 Packet_TM_LFR_TC_EXE_SUCCESS_t TM;
37 37 unsigned char messageSize;
38 38
39 39 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
40 40 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
41 41 TM.reserved = DEFAULT_RESERVED;
42 42 TM.userApplication = CCSDS_USER_APP;
43 43 // PACKET HEADER
44 44 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
45 45 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
46 46 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
47 47 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
48 48 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
49 49 // DATA FIELD HEADER
50 50 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
51 51 TM.serviceType = TM_TYPE_TC_EXE;
52 52 TM.serviceSubType = TM_SUBTYPE_EXE_OK;
53 53 TM.destinationID = TC->sourceID;
54 54 TM.time[0] = time[0];
55 55 TM.time[1] = time[1];
56 56 TM.time[2] = time[2];
57 57 TM.time[3] = time[3];
58 58 TM.time[4] = time[4];
59 59 TM.time[5] = time[5];
60 60 //
61 61 TM.telecommand_pkt_id[0] = TC->packetID[0];
62 62 TM.telecommand_pkt_id[1] = TC->packetID[1];
63 63 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
64 64 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
65 65
66 66 messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
67 67
68 68 // SEND DATA
69 69 status = rtems_message_queue_send( queue_id, &TM, messageSize);
70 70 if (status != RTEMS_SUCCESSFUL) {
71 71 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
72 72 }
73 73
74 74 return status;
75 75 }
76 76
77 77 int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
78 78 unsigned char byte_position, unsigned char rcv_value,
79 79 unsigned char *time)
80 80 {
81 81 /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue.
82 82 *
83 83 * @param TC points to the TeleCommand packet that is being processed
84 84 * @param queue_id is the id of the queue which handles TM
85 85 * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent
86 86 * @param rcv_value is the value of the LSB of the parameter that has been deteced as inconsistent
87 87 *
88 88 * @return RTEMS directive status code:
89 89 * - RTEMS_SUCCESSFUL - message sent successfully
90 90 * - RTEMS_INVALID_ID - invalid queue id
91 91 * - RTEMS_INVALID_SIZE - invalid message size
92 92 * - RTEMS_INVALID_ADDRESS - buffer is NULL
93 93 * - RTEMS_UNSATISFIED - out of message buffers
94 94 * - RTEMS_TOO_MANY - queue s limit has been reached
95 95 *
96 96 */
97 97
98 98 rtems_status_code status;
99 99 Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
100 100 unsigned char messageSize;
101 101
102 102 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
103 103 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
104 104 TM.reserved = DEFAULT_RESERVED;
105 105 TM.userApplication = CCSDS_USER_APP;
106 106 // PACKET HEADER
107 107 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
108 108 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
109 109 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
110 110 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
111 111 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
112 112 // DATA FIELD HEADER
113 113 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
114 114 TM.serviceType = TM_TYPE_TC_EXE;
115 115 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
116 116 TM.destinationID = TC->sourceID;
117 117 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
118 118 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
119 119 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
120 120 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
121 121 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
122 122 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
123 123 //
124 124 TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> 8);
125 125 TM.tc_failure_code[1] = (char) (WRONG_APP_DATA );
126 126 TM.telecommand_pkt_id[0] = TC->packetID[0];
127 127 TM.telecommand_pkt_id[1] = TC->packetID[1];
128 128 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
129 129 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
130 130 TM.tc_service = TC->serviceType; // type of the rejected TC
131 131 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
132 132 TM.byte_position = byte_position;
133 133 TM.rcv_value = rcv_value;
134 134
135 135 messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
136 136
137 137 // SEND DATA
138 138 status = rtems_message_queue_send( queue_id, &TM, messageSize);
139 139 if (status != RTEMS_SUCCESSFUL) {
140 140 PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n")
141 141 }
142 142
143 143 return status;
144 144 }
145 145
146 146 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
147 147 {
148 148 /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue.
149 149 *
150 150 * @param TC points to the TeleCommand packet that is being processed
151 151 * @param queue_id is the id of the queue which handles TM
152 152 *
153 153 * @return RTEMS directive status code:
154 154 * - RTEMS_SUCCESSFUL - message sent successfully
155 155 * - RTEMS_INVALID_ID - invalid queue id
156 156 * - RTEMS_INVALID_SIZE - invalid message size
157 157 * - RTEMS_INVALID_ADDRESS - buffer is NULL
158 158 * - RTEMS_UNSATISFIED - out of message buffers
159 159 * - RTEMS_TOO_MANY - queue s limit has been reached
160 160 *
161 161 */
162 162
163 163 rtems_status_code status;
164 164 Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
165 165 unsigned char messageSize;
166 166
167 167 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
168 168 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
169 169 TM.reserved = DEFAULT_RESERVED;
170 170 TM.userApplication = CCSDS_USER_APP;
171 171 // PACKET HEADER
172 172 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
173 173 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
174 174 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
175 175 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
176 176 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
177 177 // DATA FIELD HEADER
178 178 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
179 179 TM.serviceType = TM_TYPE_TC_EXE;
180 180 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
181 181 TM.destinationID = TC->sourceID; // default destination id
182 182 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
183 183 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
184 184 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
185 185 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
186 186 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
187 187 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
188 188 //
189 189 TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> 8);
190 190 TM.tc_failure_code[1] = (char) (TC_NOT_EXE );
191 191 TM.telecommand_pkt_id[0] = TC->packetID[0];
192 192 TM.telecommand_pkt_id[1] = TC->packetID[1];
193 193 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
194 194 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
195 195 TM.tc_service = TC->serviceType; // type of the rejected TC
196 196 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
197 197 TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
198 198 TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
199 199
200 200 messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
201 201
202 202 // SEND DATA
203 203 status = rtems_message_queue_send( queue_id, &TM, messageSize);
204 204 if (status != RTEMS_SUCCESSFUL) {
205 205 PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n")
206 206 }
207 207
208 208 return status;
209 209 }
210 210
211 211 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
212 212 {
213 213 /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue.
214 214 *
215 215 * @param TC points to the TeleCommand packet that is being processed
216 216 * @param queue_id is the id of the queue which handles TM
217 217 *
218 218 * @return RTEMS directive status code:
219 219 * - RTEMS_SUCCESSFUL - message sent successfully
220 220 * - RTEMS_INVALID_ID - invalid queue id
221 221 * - RTEMS_INVALID_SIZE - invalid message size
222 222 * - RTEMS_INVALID_ADDRESS - buffer is NULL
223 223 * - RTEMS_UNSATISFIED - out of message buffers
224 224 * - RTEMS_TOO_MANY - queue s limit has been reached
225 225 *
226 226 */
227 227
228 228 rtems_status_code status;
229 229 Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM;
230 230 unsigned char messageSize;
231 231
232 232 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
233 233 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
234 234 TM.reserved = DEFAULT_RESERVED;
235 235 TM.userApplication = CCSDS_USER_APP;
236 236 // PACKET HEADER
237 237 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
238 238 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
239 239 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
240 240 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
241 241 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
242 242 // DATA FIELD HEADER
243 243 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
244 244 TM.serviceType = TM_TYPE_TC_EXE;
245 245 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
246 246 TM.destinationID = TC->sourceID; // default destination id
247 247 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
248 248 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
249 249 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
250 250 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
251 251 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
252 252 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
253 253 //
254 254 TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> 8);
255 255 TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL );
256 256 TM.telecommand_pkt_id[0] = TC->packetID[0];
257 257 TM.telecommand_pkt_id[1] = TC->packetID[1];
258 258 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
259 259 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
260 260 TM.tc_service = TC->serviceType; // type of the rejected TC
261 261 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
262 262
263 263 messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
264 264
265 265 // SEND DATA
266 266 status = rtems_message_queue_send( queue_id, &TM, messageSize);
267 267 if (status != RTEMS_SUCCESSFUL) {
268 268 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
269 269 }
270 270
271 271 return status;
272 272 }
273 273
274 274 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
275 275 {
276 276 /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue.
277 277 *
278 278 * @param TC points to the TeleCommand packet that is being processed
279 279 * @param queue_id is the id of the queue which handles TM
280 280 *
281 281 * @return RTEMS directive status code:
282 282 * - RTEMS_SUCCESSFUL - message sent successfully
283 283 * - RTEMS_INVALID_ID - invalid queue id
284 284 * - RTEMS_INVALID_SIZE - invalid message size
285 285 * - RTEMS_INVALID_ADDRESS - buffer is NULL
286 286 * - RTEMS_UNSATISFIED - out of message buffers
287 287 * - RTEMS_TOO_MANY - queue s limit has been reached
288 288 *
289 289 */
290 290
291 291 rtems_status_code status;
292 292 Packet_TM_LFR_TC_EXE_ERROR_t TM;
293 293 unsigned char messageSize;
294 294
295 295 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
296 296 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
297 297 TM.reserved = DEFAULT_RESERVED;
298 298 TM.userApplication = CCSDS_USER_APP;
299 299 // PACKET HEADER
300 300 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
301 301 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
302 302 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
303 303 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
304 304 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
305 305 // DATA FIELD HEADER
306 306 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
307 307 TM.serviceType = TM_TYPE_TC_EXE;
308 308 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
309 309 TM.destinationID = TC->sourceID; // default destination id
310 310 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
311 311 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
312 312 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
313 313 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
314 314 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
315 315 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
316 316 //
317 317 TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> 8);
318 318 TM.tc_failure_code[1] = (char) (FAIL_DETECTED );
319 319 TM.telecommand_pkt_id[0] = TC->packetID[0];
320 320 TM.telecommand_pkt_id[1] = TC->packetID[1];
321 321 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
322 322 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
323 323 TM.tc_service = TC->serviceType; // type of the rejected TC
324 324 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
325 325
326 326 messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
327 327
328 328 // SEND DATA
329 329 status = rtems_message_queue_send( queue_id, &TM, messageSize);
330 330 if (status != RTEMS_SUCCESSFUL) {
331 331 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
332 332 }
333 333
334 334 return status;
335 335 }
336 336
337 337 int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
338 338 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV,
339 339 unsigned char destinationID, unsigned char *time)
340 340 {
341 341 /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue.
342 342 *
343 343 * @param TC points to the TeleCommand packet that is being processed
344 344 * @param queue_id is the id of the queue which handles TM
345 345 * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand
346 346 * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data
347 347 *
348 348 * @return RTEMS directive status code:
349 349 * - RTEMS_SUCCESSFUL - message sent successfully
350 350 * - RTEMS_INVALID_ID - invalid queue id
351 351 * - RTEMS_INVALID_SIZE - invalid message size
352 352 * - RTEMS_INVALID_ADDRESS - buffer is NULL
353 353 * - RTEMS_UNSATISFIED - out of message buffers
354 354 * - RTEMS_TOO_MANY - queue s limit has been reached
355 355 *
356 356 */
357 357
358 358 rtems_status_code status;
359 359 Packet_TM_LFR_TC_EXE_CORRUPTED_t TM;
360 360 unsigned char messageSize;
361 361 unsigned int packetLength;
362 362 unsigned char *packetDataField;
363 363
364 364 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter
365 365 packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
366 366
367 367 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
368 368 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
369 369 TM.reserved = DEFAULT_RESERVED;
370 370 TM.userApplication = CCSDS_USER_APP;
371 371 // PACKET HEADER
372 372 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
373 373 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
374 374 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
375 375 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
376 376 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
377 377 // DATA FIELD HEADER
378 378 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
379 379 TM.serviceType = TM_TYPE_TC_EXE;
380 380 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
381 381 TM.destinationID = destinationID;
382 382 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
383 383 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
384 384 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
385 385 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
386 386 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
387 387 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
388 388 //
389 389 TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> 8);
390 390 TM.tc_failure_code[1] = (unsigned char) (CORRUPTED );
391 391 TM.telecommand_pkt_id[0] = TC->packetID[0];
392 392 TM.telecommand_pkt_id[1] = TC->packetID[1];
393 393 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
394 394 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
395 395 TM.tc_service = TC->serviceType; // type of the rejected TC
396 396 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
397 397 TM.pkt_len_rcv_value[0] = TC->packetLength[0];
398 398 TM.pkt_len_rcv_value[1] = TC->packetLength[1];
399 399 TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
400 400 TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
401 401 TM.rcv_crc[0] = packetDataField[ packetLength - 1 ];
402 402 TM.rcv_crc[1] = packetDataField[ packetLength ];
403 403 TM.computed_crc[0] = computed_CRC[0];
404 404 TM.computed_crc[1] = computed_CRC[1];
405 405
406 406 messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
407 407
408 408 // SEND DATA
409 409 status = rtems_message_queue_send( queue_id, &TM, messageSize);
410 410 if (status != RTEMS_SUCCESSFUL) {
411 411 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
412 412 }
413 413
414 414 return status;
415 415 }
416 416
417 417 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id )
418 418 {
419 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
420 *
421 * @param packet_sequence_control points to the packet sequence control which will be incremented
422 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
423 *
424 * If the destination ID is not known, a dedicated counter is incremented.
425 *
426 */
427
419 428 unsigned short sequence_cnt;
420 429 unsigned short segmentation_grouping_flag;
421 430 unsigned short new_packet_sequence_control;
422 431 unsigned char i;
423 432
424 433 switch (destination_id)
425 434 {
426 435 case SID_TC_GROUND:
427 436 i = GROUND;
428 437 break;
429 438 case SID_TC_MISSION_TIMELINE:
430 439 i = MISSION_TIMELINE;
431 440 break;
432 441 case SID_TC_TC_SEQUENCES:
433 442 i = TC_SEQUENCES;
434 443 break;
435 444 case SID_TC_RECOVERY_ACTION_CMD:
436 445 i = RECOVERY_ACTION_CMD;
437 446 break;
438 447 case SID_TC_BACKUP_MISSION_TIMELINE:
439 448 i = BACKUP_MISSION_TIMELINE;
440 449 break;
441 450 case SID_TC_DIRECT_CMD:
442 451 i = DIRECT_CMD;
443 452 break;
444 453 case SID_TC_SPARE_GRD_SRC1:
445 454 i = SPARE_GRD_SRC1;
446 455 break;
447 456 case SID_TC_SPARE_GRD_SRC2:
448 457 i = SPARE_GRD_SRC2;
449 458 break;
450 459 case SID_TC_OBCP:
451 460 i = OBCP;
452 461 break;
453 462 case SID_TC_SYSTEM_CONTROL:
454 463 i = SYSTEM_CONTROL;
455 464 break;
456 465 case SID_TC_AOCS:
457 466 i = AOCS;
458 467 break;
459 468 case SID_TC_RPW_INTERNAL:
460 469 i = RPW_INTERNAL;
461 470 break;
462 471 default:
463 472 i = UNKNOWN;
464 473 break;
465 474 }
466 475
467 476 if (i != UNKNOWN)
468 477 {
469 478 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
470 479 sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff;
471 480
472 481 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
473 482
474 483 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
475 484 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
476 485
477 486 // increment the sequence counter for the next packet
478 487 if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX)
479 488 {
480 489 sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1;
481 490 }
482 491 else
483 492 {
484 493 sequenceCounters_TC_EXE[ i ] = 0;
485 494 }
486 495 }
487 496 else
488 497 {
489 498 DEBUG_PRINTF1("in increment_seq_counter_destination_id *** ERR destination ID %d not known\n", destination_id)
490 499 }
491 500
492 501 }
@@ -1,1219 +1,1219
1 1 /** Functions and tasks related to waveform packet generation.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 7 *
8 8 */
9 9
10 10 #include "wf_handler.h"
11 11
12 12 // SWF
13 13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
14 14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
16 16 // CWF
17 17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
18 18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
22 22
23 23 unsigned char doubleSendCWF1 = 0;
24 24 unsigned char doubleSendCWF2 = 0;
25 25
26 26 rtems_isr waveforms_isr( rtems_vector_number vector )
27 27 {
28 28 /** This is the interrupt sub routine called by the waveform picker core.
29 29 *
30 30 * This ISR launch different actions depending mainly on two pieces of information:
31 31 * 1. the values read in the registers of the waveform picker.
32 32 * 2. the current LFR mode.
33 33 *
34 34 */
35 35
36 36 #ifdef GSA
37 37 #else
38 38 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
39 39 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
40 40 { // in modes other than STANDBY and BURST, send the CWF_F3 data
41 41 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
42 42 // (1) change the receiving buffer for the waveform picker
43 43 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
44 44 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
45 45 }
46 46 else {
47 47 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
48 48 }
49 49 // (2) send an event for the waveforms transmission
50 50 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
51 51 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
52 52 }
53 53 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
54 54 }
55 55 }
56 56 #endif
57 57
58 58 switch(lfrCurrentMode)
59 59 {
60 60 //********
61 61 // STANDBY
62 62 case(LFR_MODE_STANDBY):
63 63 break;
64 64
65 65 //******
66 66 // NORMAL
67 67 case(LFR_MODE_NORMAL):
68 68 #ifdef GSA
69 69 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
70 70 #else
71 71 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable
72 72 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
73 73 }
74 74 else {
75 75 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
76 76 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08;
77 77 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
78 78 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
79 79 }
80 80 // waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
81 81 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888;
82 82 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0
83 83 }
84 84 }
85 85 #endif
86 86 break;
87 87
88 88 //******
89 89 // BURST
90 90 case(LFR_MODE_BURST):
91 91 #ifdef GSA
92 92 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
93 93 #else
94 94 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
95 95 // (1) change the receiving buffer for the waveform picker
96 96 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
97 97 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
98 98 }
99 99 else {
100 100 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
101 101 }
102 102 // (2) send an event for the waveforms transmission
103 103 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
104 104 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
105 105 }
106 106 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
107 107 }
108 108 #endif
109 109 break;
110 110
111 111 //*****
112 112 // SBM1
113 113 case(LFR_MODE_SBM1):
114 114 #ifdef GSA
115 115 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
116 116 #else
117 117 if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
118 118 // (1) change the receiving buffer for the waveform picker
119 119 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
120 120 {
121 121 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
122 122 }
123 123 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
124 124 {
125 125 doubleSendCWF1 = 1;
126 126 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
127 127 }
128 128 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
129 129 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
130 130 }
131 131 else {
132 132 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
133 133 }
134 134 // (2) send an event for the waveforms transmission
135 135 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
136 136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
137 137 }
138 138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
139 139 }
140 140 if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
141 141 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
142 142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
143 143 }
144 144 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
145 145 reset_local_sbm1_nb_cwf_sent();
146 146 }
147 147
148 148 #endif
149 149 break;
150 150
151 151 //*****
152 152 // SBM2
153 153 case(LFR_MODE_SBM2):
154 154 #ifdef GSA
155 155 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
156 156 #else
157 157 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
158 158 // (1) change the receiving buffer for the waveform picker
159 159 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
160 160 {
161 161 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
162 162 }
163 163 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
164 164 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
165 165 doubleSendCWF2 = 1;
166 166 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
167 167 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
168 168 }
169 169 reset_local_sbm2_nb_cwf_sent();
170 170 }
171 171 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
172 172 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
173 173 }
174 174 else {
175 175 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
176 176 }
177 177 // (2) send an event for the waveforms transmission
178 178 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
179 179 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
180 180 }
181 181 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
182 182 }
183 183 if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
184 184 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
185 185 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
186 186 }
187 187 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
188 188 }
189 189 #endif
190 190 break;
191 191
192 192 //********
193 193 // DEFAULT
194 194 default:
195 195 break;
196 196 }
197 197 }
198 198
199 199 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
200 200 {
201 201 /** This is the interrupt sub routine called by the waveform picker simulator.
202 202 *
203 203 * This ISR is for debug purpose only.
204 204 *
205 205 */
206 206
207 207 unsigned char lfrMode;
208 208 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
209 209
210 210 switch(lfrMode) {
211 211 case (LFR_MODE_STANDBY):
212 212 break;
213 213 case (LFR_MODE_NORMAL):
214 214 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
215 215 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
216 216 }
217 217 break;
218 218 case (LFR_MODE_BURST):
219 219 break;
220 220 case (LFR_MODE_SBM1):
221 221 break;
222 222 case (LFR_MODE_SBM2):
223 223 break;
224 224 }
225 225 }
226 226
227 227 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
228 228 {
229 229 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
230 230 *
231 231 * @param unused is the starting argument of the RTEMS task
232 232 *
233 233 * The following data packets are sent by this task:
234 234 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
235 235 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
236 236 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
237 237 *
238 238 */
239 239
240 240 rtems_event_set event_out;
241 241 rtems_id queue_id;
242 242
243 243 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
244 244 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
245 245 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
246 246
247 247 init_waveforms();
248 248
249 249 queue_id = get_pkts_queue_id();
250 250
251 251 BOOT_PRINTF("in WFRM ***\n")
252 252
253 253 while(1){
254 254 // wait for an RTEMS_EVENT
255 255 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
256 256 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
257 257 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
258 258
259 259 if (event_out == RTEMS_EVENT_MODE_NORMAL)
260 260 {
261 261 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
262 262 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
263 263 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
264 264 #ifdef GSA
265 265 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
266 266 #endif
267 267 }
268 268 else if (event_out == RTEMS_EVENT_MODE_SBM1)
269 269 {
270 270 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
271 271 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
272 272 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
273 273 #ifdef GSA
274 274 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
275 275 #endif
276 276 }
277 277 else if (event_out == RTEMS_EVENT_MODE_SBM2)
278 278 {
279 279 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
280 280 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
281 281 #ifdef GSA
282 282 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
283 283 #endif
284 284 }
285 285 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
286 286 {
287 287 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
288 288 }
289 289 else
290 290 {
291 291 PRINTF("in WFRM *** unexpected event")
292 292 }
293 293
294 294
295 295 #ifdef GSA
296 296 // irq processed, reset the related register of the timer unit
297 297 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
298 298 // clear the interruption
299 299 LEON_Unmask_interrupt( IRQ_WF );
300 300 #endif
301 301 }
302 302 }
303 303
304 304 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
305 305 {
306 306 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
307 307 *
308 308 * @param unused is the starting argument of the RTEMS task
309 309 *
310 310 * The following data packet is sent by this task:
311 311 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
312 312 *
313 313 */
314 314
315 315 rtems_event_set event_out;
316 316 rtems_id queue_id;
317 317
318 318 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
319 319 init_header_continuous_wf3_light_table( headerCWF_F3_light );
320 320
321 321 queue_id = get_pkts_queue_id();
322 322
323 323 BOOT_PRINTF("in CWF3 ***\n")
324 324
325 325 while(1){
326 326 // wait for an RTEMS_EVENT
327 327 rtems_event_receive( RTEMS_EVENT_0,
328 328 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
329 329 PRINTF("send CWF F3 \n")
330 330 #ifdef GSA
331 331 #else
332 332 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
333 333 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
334 334 }
335 335 else {
336 336 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
337 337 }
338 338 #endif
339 339 }
340 340 }
341 341
342 342 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
343 343 {
344 344 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
345 345 *
346 346 * @param unused is the starting argument of the RTEMS task
347 347 *
348 348 * The following data packet is sent by this function:
349 349 * - TM_LFR_SCIENCE_BURST_CWF_F2
350 350 * - TM_LFR_SCIENCE_SBM2_CWF_F2
351 351 *
352 352 */
353 353
354 354 rtems_event_set event_out;
355 355 rtems_id queue_id;
356 356
357 357 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
358 358 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
359 359
360 360 queue_id = get_pkts_queue_id();
361 361
362 362 BOOT_PRINTF("in CWF2 ***\n")
363 363
364 364 while(1){
365 365 // wait for an RTEMS_EVENT
366 366 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
367 367 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
368 368
369 369 if (event_out == RTEMS_EVENT_MODE_BURST)
370 370 {
371 371 // F2
372 372 #ifdef GSA
373 373 #else
374 374 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
375 375 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
376 376 }
377 377 else {
378 378 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
379 379 }
380 380 #endif
381 381 }
382 382
383 383 else if (event_out == RTEMS_EVENT_MODE_SBM2)
384 384 {
385 385 #ifdef GSA
386 386 #else
387 387 if (doubleSendCWF2 == 1)
388 388 {
389 389 doubleSendCWF2 = 0;
390 390 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
391 391 }
392 392 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
393 393 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
394 394 }
395 395 else {
396 396 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
397 397 }
398 398 param_local.local_sbm2_nb_cwf_sent ++;
399 399 #endif
400 400 }
401 401 else
402 402 {
403 403 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
404 404 }
405 405 }
406 406 }
407 407
408 408 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
409 409 {
410 410 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
411 411 *
412 412 * @param unused is the starting argument of the RTEMS task
413 413 *
414 414 * The following data packet is sent by this function:
415 415 * - TM_LFR_SCIENCE_SBM1_CWF_F1
416 416 *
417 417 */
418 418
419 419 rtems_event_set event_out;
420 420 rtems_id queue_id;
421 421
422 422 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
423 423
424 424 queue_id = get_pkts_queue_id();
425 425
426 426 BOOT_PRINTF("in CWF1 ***\n")
427 427
428 428 while(1){
429 429 // wait for an RTEMS_EVENT
430 430 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
431 431 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
432 432 if (event_out == RTEMS_EVENT_MODE_SBM1)
433 433 {
434 434 #ifdef GSA
435 435 #else
436 436 if (doubleSendCWF1 == 1)
437 437 {
438 438 doubleSendCWF1 = 0;
439 439 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
440 440 }
441 441 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
442 442 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
443 443 }
444 444 else {
445 445 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
446 446 }
447 447 param_local.local_sbm1_nb_cwf_sent ++;
448 448 #endif
449 449 }
450 450 else
451 451 {
452 452 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
453 453 }
454 454 }
455 455 }
456 456
457 457 //******************
458 458 // general functions
459 459 void init_waveforms( void )
460 460 {
461 461 int i = 0;
462 462
463 463 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
464 464 {
465 465 //***
466 466 // F0
467 467 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
468 468 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
469 469 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
470 470
471 471 //***
472 472 // F1
473 473 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
474 474 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
475 475 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
476 476
477 477 //***
478 478 // F2
479 479 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
480 480 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
481 481 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
482 482
483 483 //***
484 484 // F3
485 485 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
486 486 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
487 487 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
488 488 }
489 489 }
490 490
491 491 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
492 492 {
493 493 unsigned char i;
494 494
495 495 for (i=0; i<7; i++)
496 496 {
497 497 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
498 498 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
499 499 headerSWF[ i ].reserved = DEFAULT_RESERVED;
500 500 headerSWF[ i ].userApplication = CCSDS_USER_APP;
501 501 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
502 502 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
503 503 if (i == 0)
504 504 {
505 505 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
506 506 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
507 507 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
508 508 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
509 509 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
510 510 }
511 511 else if (i == 6)
512 512 {
513 513 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
514 514 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
515 515 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
516 516 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
517 517 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
518 518 }
519 519 else
520 520 {
521 521 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
522 522 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
523 523 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
524 524 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
525 525 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
526 526 }
527 527 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
528 528 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
529 529 headerSWF[ i ].pktNr = i+1; // PKT_NR
530 530 // DATA FIELD HEADER
531 531 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
532 532 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
533 533 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
534 534 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
535 535 // AUXILIARY DATA HEADER
536 536 headerSWF[ i ].time[0] = 0x00;
537 537 headerSWF[ i ].time[0] = 0x00;
538 538 headerSWF[ i ].time[0] = 0x00;
539 539 headerSWF[ i ].time[0] = 0x00;
540 540 headerSWF[ i ].time[0] = 0x00;
541 541 headerSWF[ i ].time[0] = 0x00;
542 542 headerSWF[ i ].sid = sid;
543 543 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
544 544 }
545 545 return LFR_SUCCESSFUL;
546 546 }
547 547
548 548 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
549 549 {
550 550 unsigned int i;
551 551
552 552 for (i=0; i<7; i++)
553 553 {
554 554 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
555 555 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
556 556 headerCWF[ i ].reserved = DEFAULT_RESERVED;
557 557 headerCWF[ i ].userApplication = CCSDS_USER_APP;
558 558 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
559 559 {
560 560 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
561 561 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
562 562 }
563 563 else
564 564 {
565 565 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
566 566 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
567 567 }
568 568 if (i == 0)
569 569 {
570 570 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
571 571 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
572 572 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
573 573 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
574 574 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
575 575 }
576 576 else if (i == 6)
577 577 {
578 578 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
579 579 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
580 580 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
581 581 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
582 582 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
583 583 }
584 584 else
585 585 {
586 586 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
587 587 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
588 588 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
589 589 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
590 590 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
591 591 }
592 592 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
593 593 // PKT_CNT
594 594 // PKT_NR
595 595 // DATA FIELD HEADER
596 596 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
597 597 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
598 598 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
599 599 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
600 600 // AUXILIARY DATA HEADER
601 601 headerCWF[ i ].sid = sid;
602 602 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
603 603 headerCWF[ i ].time[0] = 0x00;
604 604 headerCWF[ i ].time[0] = 0x00;
605 605 headerCWF[ i ].time[0] = 0x00;
606 606 headerCWF[ i ].time[0] = 0x00;
607 607 headerCWF[ i ].time[0] = 0x00;
608 608 headerCWF[ i ].time[0] = 0x00;
609 609 }
610 610 return LFR_SUCCESSFUL;
611 611 }
612 612
613 613 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
614 614 {
615 615 unsigned int i;
616 616
617 617 for (i=0; i<7; i++)
618 618 {
619 619 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
620 620 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
621 621 headerCWF[ i ].reserved = DEFAULT_RESERVED;
622 622 headerCWF[ i ].userApplication = CCSDS_USER_APP;
623 623
624 624 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
625 625 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
626 626 if (i == 0)
627 627 {
628 628 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
629 629 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
630 630 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
631 631 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
632 632 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
633 633 }
634 634 else if (i == 6)
635 635 {
636 636 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
637 637 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
638 638 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
639 639 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
640 640 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
641 641 }
642 642 else
643 643 {
644 644 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
645 645 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
646 646 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
647 647 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
648 648 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
649 649 }
650 650 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
651 651 // DATA FIELD HEADER
652 652 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
653 653 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
654 654 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
655 655 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
656 656 // AUXILIARY DATA HEADER
657 657 headerCWF[ i ].sid = SID_NORM_CWF_F3;
658 658 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
659 659 headerCWF[ i ].time[0] = 0x00;
660 660 headerCWF[ i ].time[0] = 0x00;
661 661 headerCWF[ i ].time[0] = 0x00;
662 662 headerCWF[ i ].time[0] = 0x00;
663 663 headerCWF[ i ].time[0] = 0x00;
664 664 headerCWF[ i ].time[0] = 0x00;
665 665 }
666 666 return LFR_SUCCESSFUL;
667 667 }
668 668
669 669 void reset_waveforms( void )
670 670 {
671 671 int i = 0;
672 672
673 673 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
674 674 {
675 675 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
676 676 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
677 677 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
678 678
679 679 //***
680 680 // F1
681 681 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
682 682 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
683 683 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
684 684
685 685 //***
686 686 // F2
687 687 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
688 688 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
689 689 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
690 690
691 691 //***
692 692 // F3
693 693 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
694 694 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
695 695 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
696 696 }
697 697 }
698 698
699 699 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
700 700 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
701 701 {
702 702 /** This function sends SWF CCSDS packets (F2, F1 or F0).
703 703 *
704 704 * @param waveform points to the buffer containing the data that will be send.
705 705 * @param sid is the source identifier of the data that will be sent.
706 706 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
707 707 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
708 708 * contain information to setup the transmission of the data packets.
709 709 *
710 710 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
711 711 *
712 712 */
713 713
714 714 unsigned int i;
715 715 int ret;
716 716 rtems_status_code status;
717 717 spw_ioctl_pkt_send spw_ioctl_send_SWF;
718 718
719 719 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
720 720 spw_ioctl_send_SWF.options = 0;
721 721
722 722 ret = LFR_DEFAULT;
723 723
724 724 for (i=0; i<7; i++) // send waveform
725 725 {
726 726 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
727 727 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
728 728 // BUILD THE DATA
729 729 if (i==6) {
730 730 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
731 731 }
732 732 else {
733 733 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
734 734 }
735 735 // SET PACKET SEQUENCE COUNTER
736 736 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
737 737 // SET PACKET TIME
738 738 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
739 739 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
740 740 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
741 741 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
742 742 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
743 743 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
744 744 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
745 745 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
746 746 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
747 747 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
748 748 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
749 749 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
750 750 // SEND PACKET
751 751 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
752 752 if (status != RTEMS_SUCCESSFUL) {
753 753 printf("%d-%d, ERR %d\n", sid, i, (int) status);
754 754 ret = LFR_DEFAULT;
755 755 }
756 756 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
757 757 }
758 758
759 759 return ret;
760 760 }
761 761
762 762 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
763 763 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
764 764 {
765 765 /** This function sends CWF CCSDS packets (F2, F1 or F0).
766 766 *
767 767 * @param waveform points to the buffer containing the data that will be send.
768 768 * @param sid is the source identifier of the data that will be sent.
769 769 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
770 770 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
771 771 * contain information to setup the transmission of the data packets.
772 772 *
773 773 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
774 774 *
775 775 */
776 776
777 777 unsigned int i;
778 778 int ret;
779 779 rtems_status_code status;
780 780 spw_ioctl_pkt_send spw_ioctl_send_CWF;
781 781
782 782 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
783 783 spw_ioctl_send_CWF.options = 0;
784 784
785 785 ret = LFR_DEFAULT;
786 786
787 787 for (i=0; i<7; i++) // send waveform
788 788 {
789 789 int coarseTime = 0x00;
790 790 int fineTime = 0x00;
791 791 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
792 792 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
793 793 // BUILD THE DATA
794 794 if (i==6) {
795 795 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
796 796 }
797 797 else {
798 798 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
799 799 }
800 800 // SET PACKET SEQUENCE COUNTER
801 801 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
802 802 // SET PACKET TIME
803 803 coarseTime = time_management_regs->coarse_time;
804 804 fineTime = time_management_regs->fine_time;
805 805 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
806 806 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
807 807 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
808 808 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
809 809 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
810 810 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
811 811 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
812 812 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
813 813 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
814 814 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
815 815 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
816 816 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
817 817 // SEND PACKET
818 818 if (sid == SID_NORM_CWF_F3)
819 819 {
820 820 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
821 821 if (status != RTEMS_SUCCESSFUL) {
822 822 printf("%d-%d, ERR %d\n", sid, i, (int) status);
823 823 ret = LFR_DEFAULT;
824 824 }
825 825 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
826 826 }
827 827 else
828 828 {
829 829 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
830 830 if (status != RTEMS_SUCCESSFUL) {
831 831 printf("%d-%d, ERR %d\n", sid, i, (int) status);
832 832 ret = LFR_DEFAULT;
833 833 }
834 834 }
835 835 }
836 836
837 837 return ret;
838 838 }
839 839
840 840 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
841 841 {
842 842 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
843 843 *
844 844 * @param waveform points to the buffer containing the data that will be send.
845 845 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
846 846 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
847 847 * contain information to setup the transmission of the data packets.
848 848 *
849 849 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
850 850 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
851 851 *
852 852 */
853 853
854 854 unsigned int i;
855 855 int ret;
856 856 rtems_status_code status;
857 857 spw_ioctl_pkt_send spw_ioctl_send_CWF;
858 858 char *sample;
859 859
860 860 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
861 861 spw_ioctl_send_CWF.options = 0;
862 862
863 863 ret = LFR_DEFAULT;
864 864
865 865 //**********************
866 866 // BUILD CWF3_light DATA
867 867 for ( i=0; i< 2048; i++)
868 868 {
869 869 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
870 870 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
871 871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
872 872 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
873 873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
874 874 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
875 875 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
876 876 }
877 877
878 878 //*********************
879 879 // SEND CWF3_light DATA
880 880
881 881 for (i=0; i<7; i++) // send waveform
882 882 {
883 883 int coarseTime = 0x00;
884 884 int fineTime = 0x00;
885 885 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
886 886 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
887 887 // BUILD THE DATA
888 888 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
889 889 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
890 890 }
891 891 else {
892 892 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
893 893 }
894 894 // SET PACKET SEQUENCE COUNTER
895 895 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
896 896 // SET PACKET TIME
897 897 coarseTime = time_management_regs->coarse_time;
898 898 fineTime = time_management_regs->fine_time;
899 899 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
900 900 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
901 901 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
902 902 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
903 903 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
904 904 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
905 905 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
906 906 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
907 907 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
908 908 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
909 909 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
910 910 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
911 911 // SEND PACKET
912 912 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
913 913 if (status != RTEMS_SUCCESSFUL) {
914 914 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
915 915 ret = LFR_DEFAULT;
916 916 }
917 917 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
918 918 }
919 919
920 920 return ret;
921 921 }
922 922
923 923
924 924 //**************
925 925 // wfp registers
926 926 void set_wfp_data_shaping()
927 927 {
928 928 /** This function sets the data_shaping register of the waveform picker module.
929 929 *
930 930 * The value is read from one field of the parameter_dump_packet structure:\n
931 931 * bw_sp0_sp1_r0_r1
932 932 *
933 933 */
934 934
935 935 unsigned char data_shaping;
936 936
937 937 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
938 938 // waveform picker : [R1 R0 SP1 SP0 BW]
939 939
940 940 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
941 941
942 942 #ifdef GSA
943 943 #else
944 944 waveform_picker_regs->data_shaping =
945 945 ( (data_shaping & 0x10) >> 4 ) // BW
946 946 + ( (data_shaping & 0x08) >> 2 ) // SP0
947 947 + ( (data_shaping & 0x04) ) // SP1
948 948 + ( (data_shaping & 0x02) << 2 ) // R0
949 949 + ( (data_shaping & 0x01) << 4 ); // R1
950 950 #endif
951 951 }
952 952
953 953 char set_wfp_delta_snapshot()
954 954 {
955 955 /** This function sets the delta_snapshot register of the waveform picker module.
956 956 *
957 957 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
958 958 * - sy_lfr_n_swf_p[0]
959 959 * - sy_lfr_n_swf_p[1]
960 960 *
961 961 */
962 962
963 963 char ret;
964 964 unsigned int delta_snapshot;
965 965 unsigned int aux;
966 966
967 967 aux = 0;
968 968 ret = LFR_DEFAULT;
969 969
970 970 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
971 971 + parameter_dump_packet.sy_lfr_n_swf_p[1];
972 972
973 973 #ifdef GSA
974 974 #else
975 975 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
976 976 {
977 977 aux = MIN_DELTA_SNAPSHOT;
978 978 ret = LFR_DEFAULT;
979 979 }
980 980 else
981 981 {
982 982 aux = delta_snapshot ;
983 983 ret = LFR_SUCCESSFUL;
984 984 }
985 985 waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
986 986 #endif
987 987
988 988 return ret;
989 989 }
990 990
991 991 void set_wfp_burst_enable_register( unsigned char mode)
992 992 {
993 993 /** This function sets the waveform picker burst_enable register depending on the mode.
994 994 *
995 995 * @param mode is the LFR mode to launch.
996 996 *
997 997 * The burst bits shall be before the enable bits.
998 998 *
999 999 */
1000 1000
1001 1001 #ifdef GSA
1002 1002 #else
1003 1003 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1004 1004 // the burst bits shall be set first, before the enable bits
1005 1005 switch(mode) {
1006 1006 case(LFR_MODE_NORMAL):
1007 1007 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
1008 1008 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1009 1009 break;
1010 1010 case(LFR_MODE_BURST):
1011 1011 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1012 1012 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
1013 1013 break;
1014 1014 case(LFR_MODE_SBM1):
1015 1015 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
1016 1016 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1017 1017 break;
1018 1018 case(LFR_MODE_SBM2):
1019 1019 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1020 1020 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1021 1021 break;
1022 1022 default:
1023 1023 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1024 1024 break;
1025 1025 }
1026 1026 #endif
1027 1027 }
1028 1028
1029 1029 void reset_wfp_burst_enable()
1030 1030 {
1031 1031 /** This function resets the waveform picker burst_enable register.
1032 1032 *
1033 1033 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1034 1034 *
1035 1035 */
1036 1036
1037 1037 #ifdef GSA
1038 1038 #else
1039 1039 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1040 1040 #endif
1041 1041 }
1042 1042
1043 1043 void reset_wfp_status()
1044 1044 {
1045 1045 /** This function resets the waveform picker status register.
1046 1046 *
1047 1047 * All status bits are set to 0 [new_err full_err full].
1048 1048 *
1049 1049 */
1050 1050
1051 1051 #ifdef GSA
1052 1052 #else
1053 1053 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1054 1054 #endif
1055 1055 }
1056 1056
1057 1057 void reset_waveform_picker_regs()
1058 1058 {
1059 1059 /** This function resets the waveform picker module registers.
1060 1060 *
1061 1061 * The registers affected by this function are located at the following offset addresses:
1062 1062 * - 0x00 data_shaping
1063 1063 * - 0x04 burst_enable
1064 1064 * - 0x08 addr_data_f0
1065 1065 * - 0x0C addr_data_f1
1066 1066 * - 0x10 addr_data_f2
1067 1067 * - 0x14 addr_data_f3
1068 1068 * - 0x18 status
1069 1069 * - 0x1C delta_snapshot
1070 1070 * - 0x20 delta_f2_f1
1071 1071 * - 0x24 delta_f2_f0
1072 1072 * - 0x28 nb_burst
1073 1073 * - 0x2C nb_snapshot
1074 1074 *
1075 1075 */
1076 1076
1077 1077 #ifdef GSA
1078 1078 #else
1079 1079 reset_wfp_burst_enable();
1080 1080 reset_wfp_status();
1081 1081 // set buffer addresses
1082 1082 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
1083 1083 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
1084 1084 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
1085 1085 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
1086 1086 // set other parameters
1087 1087 set_wfp_data_shaping();
1088 1088 set_wfp_delta_snapshot(); // time in seconds between two snapshots
1089 1089 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
1090 1090 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
1091 1091 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1092 1092 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
1093 1093 #endif
1094 1094 }
1095 1095
1096 1096 //*****************
1097 1097 // local parameters
1098 void set_local_sbm1_nb_cwf_max()
1098 void set_local_sbm1_nb_cwf_max( void )
1099 1099 {
1100 1100 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1101 1101 *
1102 1102 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1103 1103 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1104 1104 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1105 1105 *
1106 1106 */
1107 1107 param_local.local_sbm1_nb_cwf_max = 2 *
1108 1108 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1109 1109 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1110 1110 }
1111 1111
1112 void set_local_sbm2_nb_cwf_max()
1112 void set_local_sbm2_nb_cwf_max(void)
1113 1113 {
1114 1114 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1115 1115 *
1116 1116 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1117 1117 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1118 1118 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1119 1119 *
1120 1120 */
1121 1121
1122 1122 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1123 1123 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1124 1124 }
1125 1125
1126 void set_local_nb_interrupt_f0_MAX()
1126 void set_local_nb_interrupt_f0_MAX( void )
1127 1127 {
1128 1128 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1129 1129 *
1130 1130 * This parameter is used for the SM validation only.\n
1131 1131 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1132 1132 * module before launching a basic processing.
1133 1133 *
1134 1134 */
1135 1135
1136 1136 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1137 1137 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1138 1138 }
1139 1139
1140 void reset_local_sbm1_nb_cwf_sent()
1140 void reset_local_sbm1_nb_cwf_sent( void )
1141 1141 {
1142 1142 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1143 1143 *
1144 1144 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1145 1145 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1146 1146 *
1147 1147 */
1148 1148
1149 1149 param_local.local_sbm1_nb_cwf_sent = 0;
1150 1150 }
1151 1151
1152 void reset_local_sbm2_nb_cwf_sent()
1152 void reset_local_sbm2_nb_cwf_sent( void )
1153 1153 {
1154 1154 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1155 1155 *
1156 1156 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1157 1157 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1158 1158 *
1159 1159 */
1160 1160
1161 1161 param_local.local_sbm2_nb_cwf_sent = 0;
1162 1162 }
1163 1163
1164 1164 rtems_id get_pkts_queue_id( void )
1165 1165 {
1166 1166 rtems_id queue_id;
1167 1167 rtems_status_code status;
1168 1168 rtems_name queue_send_name;
1169 1169
1170 1170 queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' );
1171 1171
1172 1172 status = rtems_message_queue_ident( queue_send_name, 0, &queue_id );
1173 1173 if (status != RTEMS_SUCCESSFUL)
1174 1174 {
1175 1175 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1176 1176 }
1177 1177 return queue_id;
1178 1178 }
1179 1179
1180 1180 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1181 1181 {
1182 1182 unsigned short *sequence_cnt;
1183 1183 unsigned short segmentation_grouping_flag;
1184 1184 unsigned short new_packet_sequence_control;
1185 1185
1186 1186 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1187 1187 || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) )
1188 1188 {
1189 1189 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1190 1190 }
1191 1191 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1192 1192 {
1193 1193 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1194 1194 }
1195 1195 else
1196 1196 {
1197 1197 sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ];
1198 1198 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1199 1199 }
1200 1200
1201 1201 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1202 1202 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1203 1203
1204 1204 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1205 1205
1206 1206 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1207 1207 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1208 1208
1209 1209 // increment the seuqence counter for the next packet
1210 1210 if ( *sequence_cnt < SEQ_CNT_MAX)
1211 1211 {
1212 1212 *sequence_cnt = *sequence_cnt + 1;
1213 1213 }
1214 1214 else
1215 1215 {
1216 1216 *sequence_cnt = 0;
1217 1217 }
1218 1218
1219 1219 }
General Comments 0
You need to be logged in to leave comments. Login now