##// END OF EJS Templates
fsw-0-23...
paul -
r75:1aca4e63f8e6 VHDLib206
parent child
Show More
@@ -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 08:56:42 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Nov 14 12:02: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 13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=23 -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,305 +1,305
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 2.8.1, 2013-11-14T09:19:44. -->
3 <!-- Written by QtCreator 2.8.1, 2013-11-14T11:59:15. -->
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 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</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 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</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 82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w -j 4</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 101 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w 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 112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) 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 116 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
118 118 </valuemap>
119 119 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
122 122 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
126 126 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
127 127 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
128 128 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
129 129 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
130 130 </valuemap>
131 131 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
132 132 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
133 133 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
134 134 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
135 135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
136 136 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
137 137 <value type="QString">-w</value>
138 138 <value type="QString">-r</value>
139 139 </valuelist>
140 140 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
141 141 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
142 142 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
143 143 </valuemap>
144 144 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
145 145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
146 146 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
147 147 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
148 148 </valuemap>
149 149 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
150 150 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
151 151 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
152 152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
153 153 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
154 154 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
155 155 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
156 156 <value type="QString">-w</value>
157 157 <value type="QString">-r</value>
158 158 </valuelist>
159 159 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
160 160 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
161 161 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
162 162 </valuemap>
163 163 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
164 164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
165 165 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
166 166 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
167 167 </valuemap>
168 168 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
169 169 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
170 170 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
174 174 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
177 177 </valuemap>
178 178 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
179 179 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
180 180 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
181 181 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
182 182 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
183 183 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
184 184 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
187 187 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
188 188 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
189 189 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
190 190 </valuemap>
191 191 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
192 192 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
193 193 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
194 194 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
195 195 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
196 196 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
197 197 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
198 198 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
199 199 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
200 200 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
201 201 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
202 202 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
203 203 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
204 204 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
205 205 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
206 206 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
207 207 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
208 208 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
209 209 <value type="int">0</value>
210 210 <value type="int">1</value>
211 211 <value type="int">2</value>
212 212 <value type="int">3</value>
213 213 <value type="int">4</value>
214 214 <value type="int">5</value>
215 215 <value type="int">6</value>
216 216 <value type="int">7</value>
217 217 <value type="int">8</value>
218 218 <value type="int">9</value>
219 219 <value type="int">10</value>
220 220 <value type="int">11</value>
221 221 <value type="int">12</value>
222 222 <value type="int">13</value>
223 223 <value type="int">14</value>
224 224 </valuelist>
225 225 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
226 226 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
227 227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
228 228 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
229 229 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
230 230 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
231 231 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
232 232 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
233 233 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
234 234 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
235 235 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
236 236 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
237 237 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
238 238 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
239 239 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
240 240 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
241 241 </valuemap>
242 242 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
243 243 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
244 244 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
245 245 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
246 246 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
247 247 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
248 248 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
249 249 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
250 250 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
251 251 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
252 252 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
253 253 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
254 254 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
255 255 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
256 256 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
257 257 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
258 258 <value type="int">0</value>
259 259 <value type="int">1</value>
260 260 <value type="int">2</value>
261 261 <value type="int">3</value>
262 262 <value type="int">4</value>
263 263 <value type="int">5</value>
264 264 <value type="int">6</value>
265 265 <value type="int">7</value>
266 266 <value type="int">8</value>
267 267 <value type="int">9</value>
268 268 <value type="int">10</value>
269 269 <value type="int">11</value>
270 270 <value type="int">12</value>
271 271 <value type="int">13</value>
272 272 <value type="int">14</value>
273 273 </valuelist>
274 274 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
275 275 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
276 276 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
277 277 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">doxygen</value>
278 278 <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">true</value>
279 279 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">/opt/DEV_PLE/doc</value>
280 280 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run doxygen</value>
281 281 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
282 282 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
283 283 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
284 284 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
285 285 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
286 286 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
287 287 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
288 288 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
289 289 </valuemap>
290 290 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
291 291 </valuemap>
292 292 </data>
293 293 <data>
294 294 <variable>ProjectExplorer.Project.TargetCount</variable>
295 295 <value type="int">1</value>
296 296 </data>
297 297 <data>
298 298 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
299 299 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
300 300 </data>
301 301 <data>
302 302 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
303 303 <value type="int">14</value>
304 304 </data>
305 305 </qtcreator>
@@ -1,37 +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 14 extern rtems_name misc_name[5];
15 15 time_management_regs_t *time_management_regs;
16 16 extern Packet_TM_LFR_HK_t housekeeping_packet;
17 17
18 18 int 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 20 int timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
21 21 int timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
22 22 int 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 void getTime( unsigned char *time);
38
37 39 #endif // FSW_MISC_H_INCLUDED
@@ -1,63 +1,63
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 13 extern struct param_sbm1_str param_sbm1;
14 14 extern struct param_sbm2_str param_sbm2;
15 15 extern time_management_regs_t *time_management_regs;
16 16 extern waveform_picker_regs_t *waveform_picker_regs;
17 17 extern gptimer_regs_t *gptimer_regs;
18 18 extern rtems_name misc_name[5];
19 19 extern rtems_id Task_id[20]; /* array of task ids */
20 20 extern unsigned char lfrCurrentMode;
21 21 extern unsigned int maxCount;
22 22
23 23
24 24 //****
25 25 // ISR
26 26 rtems_isr commutation_isr1( rtems_vector_number vector );
27 27 rtems_isr commutation_isr2( rtems_vector_number vector );
28 28
29 29 //***********
30 30 // RTEMS TASK
31 31 rtems_task actn_task( rtems_task_argument unused );
32 32
33 33 //***********
34 34 // TC ACTIONS
35 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
36 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
35 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
36 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
37 37 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
38 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
39 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
38 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
39 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
40 40 int action_update_time(ccsdsTelecommandPacket_t *TC);
41 41
42 42 // mode transition
43 43 int transition_validation(unsigned char requestedMode);
44 44 int stop_current_mode();
45 45 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
46 46 int enter_standby_mode();
47 47 int enter_normal_mode();
48 48 int enter_burst_mode();
49 49 int enter_sbm1_mode();
50 50 int enter_sbm2_mode();
51 51 int restart_science_tasks();
52 52 int suspend_science_tasks();
53 53
54 54 // other functions
55 55 void updateLFRCurrentMode();
56 56 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time);
57 57 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time);
58 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
58 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time);
59 59
60 60 #endif // TC_HANDLER_H_INCLUDED
61 61
62 62
63 63
@@ -1,32 +1,32
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 12 extern int fdSPW;
13 13 extern unsigned char lfrCurrentMode;
14 14 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
15 15 extern Packet_TM_LFR_HK_t housekeeping_packet;
16 16
17 17 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
18 int action_load_normal_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
19 int action_load_burst_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
20 int action_load_sbm1_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
21 int action_load_sbm2_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
18 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
19 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
20 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
21 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
22 22 int action_dump_par(rtems_id queue_id );
23 23
24 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
25 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
24 int set_sy_lfr_n_swf_l(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
25 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
26 26 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
27 27 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
28 28 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
29 29
30 30 void init_parameter_dump( void );
31 31
32 32 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,28 +1,28
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 10 extern time_management_regs_t *time_management_regs;
11 11 extern Packet_TM_LFR_HK_t housekeeping_packet;
12 12 extern unsigned short sequenceCounters_TC_EXE[];
13 13
14 14 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
15 15 int send_tm_lfr_tc_exe_inconsistent(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
16 unsigned char byte_position, unsigned char rcv_value);
17 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
18 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
19 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
16 unsigned char byte_position, unsigned char rcv_value, unsigned char *time);
17 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
18 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
19 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
20 20 int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
21 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, unsigned char destinationID);
21 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, unsigned char destinationID, unsigned char *time);
22 22
23 23 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id );
24 24
25 25 #endif // TM_LFR_TC_EXE_H_INCLUDED
26 26
27 27
28 28
@@ -1,325 +1,333
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 10 char *DumbMessages[7] = {"in DUMB *** default", // RTEMS_EVENT_0
11 11 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
12 12 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
13 13 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
14 14 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
15 15 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
16 16 "ERR HK" // RTEMS_EVENT_6
17 17 };
18 18
19 19 int 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 30 * @return
31 31 *
32 32 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
33 33 *
34 34 */
35 35
36 36 rtems_status_code status;
37 37 rtems_isr_entry old_isr_handler;
38 38
39 39 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
40 40 if (status!=RTEMS_SUCCESSFUL)
41 41 {
42 42 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
43 43 }
44 44
45 45 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
46 46
47 47 return 1;
48 48 }
49 49
50 50 int timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
51 51 {
52 52 /** This function starts a GPTIMER timer.
53 53 *
54 54 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
55 55 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
56 56 *
57 57 * @return 1
58 58 *
59 59 */
60 60
61 61 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
62 62 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
63 63 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
64 64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
65 65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
66 66
67 67 return 1;
68 68 }
69 69
70 70 int timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
71 71 {
72 72 /** This function stops a GPTIMER timer.
73 73 *
74 74 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
75 75 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
76 76 *
77 77 * @return 1
78 78 *
79 79 */
80 80
81 81 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
82 82 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
83 83 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
84 84
85 85 return 1;
86 86 }
87 87
88 88 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
89 89 {
90 90 /** This function sets the clock divider of a GPTIMER timer.
91 91 *
92 92 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
93 93 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
94 94 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
95 95 *
96 96 * @return 1
97 97 *
98 98 */
99 99
100 100 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
101 101
102 102 return 1;
103 103 }
104 104
105 105 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
106 106 {
107 107 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
108 108
109 109 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
110 110 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
111 111
112 112 return 0;
113 113 }
114 114
115 115 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
116 116 {
117 117 /** This function sets the scaler reload register of the apbuart module
118 118 *
119 119 * @param regs is the address of the apbuart registers in memory
120 120 * @param value is the value that will be stored in the scaler register
121 121 *
122 122 * The value shall be set by the software to get data on the serial interface.
123 123 *
124 124 */
125 125
126 126 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
127 127
128 128 apbuart_regs->scaler = value;
129 129 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
130 130 }
131 131
132 132 //************
133 133 // RTEMS TASKS
134 134
135 135 rtems_task stat_task(rtems_task_argument argument)
136 136 {
137 137 int i;
138 138 int j;
139 139 i = 0;
140 140 j = 0;
141 141 BOOT_PRINTF("in STAT *** \n")
142 142 while(1){
143 143 rtems_task_wake_after(1000);
144 144 PRINTF1("%d\n", j)
145 145 if (i == CPU_USAGE_REPORT_PERIOD) {
146 146 // #ifdef PRINT_TASK_STATISTICS
147 147 // rtems_cpu_usage_report();
148 148 // rtems_cpu_usage_reset();
149 149 // #endif
150 150 i = 0;
151 151 }
152 152 else i++;
153 153 j++;
154 154 }
155 155 }
156 156
157 157 rtems_task hous_task(rtems_task_argument argument)
158 158 {
159 159 rtems_status_code status;
160 160 rtems_id queue_id;
161 161
162 162 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
163 163 if (status != RTEMS_SUCCESSFUL)
164 164 {
165 165 PRINTF1("in HOUS *** ERR %d\n", status)
166 166 }
167 167
168 168 BOOT_PRINTF("in HOUS ***\n")
169 169
170 170 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
171 171 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
172 172 if( status != RTEMS_SUCCESSFUL ) {
173 173 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
174 174 }
175 175 }
176 176
177 177 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
178 178 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
179 179 housekeeping_packet.reserved = DEFAULT_RESERVED;
180 180 housekeeping_packet.userApplication = CCSDS_USER_APP;
181 181 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
182 182 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
183 183 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
184 184 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
185 185 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
186 186 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
187 187 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
188 188 housekeeping_packet.serviceType = TM_TYPE_HK;
189 189 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
190 190 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
191 191
192 192 status = rtems_rate_monotonic_cancel(HK_id);
193 193 if( status != RTEMS_SUCCESSFUL ) {
194 194 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
195 195 }
196 196 else {
197 197 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
198 198 }
199 199
200 200 while(1){ // launch the rate monotonic task
201 201 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
202 202 if ( status != RTEMS_SUCCESSFUL ) {
203 203 PRINTF1( "in HOUS *** ERR period: %d\n", status);
204 204 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
205 205 }
206 206 else {
207 207 increment_seq_counter( housekeeping_packet.packetSequenceControl );
208 208 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
209 209 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
210 210 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
211 211 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
212 212 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
213 213 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
214 214 housekeeping_packet.sid = SID_HK;
215 215
216 216 spacewire_update_statistics();
217 217
218 218 // SEND PACKET
219 219 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
220 220 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
221 221 if (status != RTEMS_SUCCESSFUL) {
222 222 PRINTF1("in HOUS *** ERR send: %d\n", status)
223 223 }
224 224 }
225 225 }
226 226
227 227 PRINTF("in HOUS *** deleting task\n")
228 228
229 229 status = rtems_task_delete( RTEMS_SELF ); // should not return
230 230 printf( "rtems_task_delete returned with status of %d.\n", status );
231 231 return;
232 232 }
233 233
234 234 rtems_task dumb_task( rtems_task_argument unused )
235 235 {
236 236 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
237 237 *
238 238 * @param unused is the starting argument of the RTEMS task
239 239 *
240 240 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
241 241 *
242 242 */
243 243
244 244 unsigned int i;
245 245 unsigned int intEventOut;
246 246 unsigned int coarse_time = 0;
247 247 unsigned int fine_time = 0;
248 248 rtems_event_set event_out;
249 249
250 250 BOOT_PRINTF("in DUMB *** \n")
251 251
252 252 while(1){
253 253 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
254 254 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6,
255 255 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
256 256 intEventOut = (unsigned int) event_out;
257 257 for ( i=0; i<32; i++)
258 258 {
259 259 if ( ((intEventOut >> i) & 0x0001) != 0)
260 260 {
261 261 coarse_time = time_management_regs->coarse_time;
262 262 fine_time = time_management_regs->fine_time;
263 263 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
264 264 }
265 265 }
266 266 }
267 267 }
268 268
269 269 //*****************************
270 270 // init housekeeping parameters
271 271
272 272 void init_housekeeping_parameters( void )
273 273 {
274 274 /** This function initialize the housekeeping_packet global variable with default values.
275 275 *
276 276 */
277 277
278 278 unsigned int i = 0;
279 279 char *parameters;
280 280
281 281 parameters = (char*) &housekeeping_packet.lfr_status_word;
282 282 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
283 283 {
284 284 parameters[i] = 0x00;
285 285 }
286 286 // init status word
287 287 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
288 288 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
289 289 // init software version
290 290 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
291 291 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
292 292 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
293 293 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
294 294
295 295 }
296 296
297 297 void increment_seq_counter( unsigned char *packet_sequence_control)
298 298 {
299 299 unsigned short sequence_cnt;
300 300 unsigned short segmentation_grouping_flag;
301 301 unsigned short new_packet_sequence_control;
302 302
303 303 segmentation_grouping_flag = (unsigned short) ( (packet_sequence_control[0] & 0xc0) << 8 ); // keep bits 7 downto 6
304 304 sequence_cnt = (unsigned short) (
305 305 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
306 306 + packet_sequence_control[1]
307 307 );
308 308
309 309 if ( sequence_cnt < SEQ_CNT_MAX)
310 310 {
311 311 sequence_cnt = sequence_cnt + 1;
312 312 }
313 313 else
314 314 {
315 315 sequence_cnt = 0;
316 316 }
317 317
318 318 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
319 319
320 320 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
321 321 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
322 322 }
323 323
324 void getTime( unsigned char *time)
325 {
326 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
327 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
328 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
329 time[3] = (unsigned char) (time_management_regs->coarse_time);
330 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
331 time[5] = (unsigned char) (time_management_regs->fine_time);
332 }
324 333
325
@@ -1,621 +1,626
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 16 char *lstates[6] = {"Error-reset",
17 17 "Error-wait",
18 18 "Ready",
19 19 "Started",
20 20 "Connecting",
21 21 "Run"
22 22 };
23 23
24 24 rtems_name semq_name;
25 25 rtems_id semq_id;
26 26
27 27 //***********
28 28 // RTEMS TASK
29 29 rtems_task spiq_task(rtems_task_argument unused)
30 30 {
31 31 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
32 32 *
33 33 * @param unused is the starting argument of the RTEMS task
34 34 *
35 35 */
36 36
37 37 rtems_event_set event_out;
38 38 rtems_status_code status;
39 39 int linkStatus;
40 40
41 41 BOOT_PRINTF("in SPIQ *** \n")
42 42
43 43 while(true){
44 44 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
45 45 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
46 46
47 47 // [0] SUSPEND RECV AND SEND TASKS
48 48 rtems_task_suspend( Task_id[ TASKID_RECV ] );
49 49 rtems_task_suspend( Task_id[ TASKID_SEND ] );
50 50
51 51 // [1] CHECK THE LINK
52 52 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
53 53 if ( linkStatus != 5) {
54 54 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
55 55 rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
56 56 }
57 57
58 58 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
59 59 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
60 60 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
61 61 {
62 62 spacewire_compute_stats_offsets();
63 63 status = spacewire_reset_link( );
64 64 }
65 65 else // [2.b] in run state, start the link
66 66 {
67 67 status = spacewire_stop_start_link( fdSPW ); // start the link
68 68 if ( status != RTEMS_SUCCESSFUL)
69 69 {
70 70 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
71 71 }
72 72 }
73 73
74 74 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
75 75 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
76 76 {
77 77 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
78 78 if ( status != RTEMS_SUCCESSFUL ) {
79 79 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
80 80 }
81 81 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
82 82 if ( status != RTEMS_SUCCESSFUL ) {
83 83 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
84 84 }
85 85 }
86 86 else // [3.b] the link is not in run state, go in STANDBY mode
87 87 {
88 88 status = stop_current_mode();
89 89 if ( status != RTEMS_SUCCESSFUL ) {
90 90 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
91 91 }
92 92 status = enter_standby_mode();
93 93 if ( status != RTEMS_SUCCESSFUL ) {
94 94 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
95 95 }
96 96 // wake the WTDG task up to wait for the link recovery
97 97 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
98 98 rtems_task_suspend( RTEMS_SELF );
99 99 }
100 100 }
101 101 }
102 102
103 103 rtems_task recv_task( rtems_task_argument unused )
104 104 {
105 105 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
106 106 *
107 107 * @param unused is the starting argument of the RTEMS task
108 108 *
109 109 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
110 110 * 1. It reads the incoming data.
111 111 * 2. Launches the acceptance procedure.
112 112 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
113 113 *
114 114 */
115 115
116 116 int len;
117 117 ccsdsTelecommandPacket_t currentTC;
118 118 unsigned char computed_CRC[ 2 ];
119 119 unsigned char currentTC_LEN_RCV[ 2 ];
120 120 unsigned char destinationID;
121 121 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
122 122 unsigned int parserCode;
123 unsigned char time[6];
123 124 rtems_status_code status;
124 125 rtems_id queue_recv_id;
125 126 rtems_id queue_send_id;
126 127
127 128 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
128 129
129 130 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_recv_id );
130 131 if (status != RTEMS_SUCCESSFUL)
131 132 {
132 133 PRINTF1("in RECV *** ERR getting QUEUE_RECV id, %d\n", status)
133 134 }
134 135
135 136 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_send_id );
136 137 if (status != RTEMS_SUCCESSFUL)
137 138 {
138 139 PRINTF1("in RECV *** ERR getting QUEUE_SEND id, %d\n", status)
139 140 }
140 141
141 142 BOOT_PRINTF("in RECV *** \n")
142 143
143 144 while(1)
144 145 {
145 146 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
146 147 if (len == -1){ // error during the read call
147 148 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
148 149 }
149 150 else {
150 151 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
151 152 PRINTF("in RECV *** packet lenght too short\n")
152 153 }
153 154 else {
154 155 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
155 156 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
156 157 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
157 158 // CHECK THE TC
158 159 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
159 160 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
160 161 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
161 162 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
162 163 || (parserCode == WRONG_SRC_ID) )
163 164 { // send TM_LFR_TC_EXE_CORRUPTED
164 165 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
165 166 &&
166 167 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
167 168 )
168 169 {
169 170 if ( parserCode == WRONG_SRC_ID )
170 171 {
171 172 destinationID = SID_TC_GROUND;
172 173 }
173 174 else
174 175 {
175 176 destinationID = currentTC.sourceID;
176 177 }
177 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id, computed_CRC, currentTC_LEN_RCV, destinationID );
178 getTime( time );
179 close_action( &currentTC, LFR_DEFAULT, queue_send_id, time);
180 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
181 computed_CRC, currentTC_LEN_RCV,
182 destinationID, time );
178 183 }
179 184 }
180 185 else
181 186 { // send valid TC to the action launcher
182 187 status = rtems_message_queue_send( queue_recv_id, &currentTC,
183 188 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
184 189 }
185 190 }
186 191 }
187 192 }
188 193 }
189 194
190 195 rtems_task send_task( rtems_task_argument argument)
191 196 {
192 197 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
193 198 *
194 199 * @param unused is the starting argument of the RTEMS task
195 200 *
196 201 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
197 202 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
198 203 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
199 204 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
200 205 * data it contains.
201 206 *
202 207 */
203 208
204 209 rtems_status_code status; // RTEMS status code
205 210 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
206 211 spw_ioctl_pkt_send *spw_ioctl_send;
207 212 size_t size; // size of the incoming TC packet
208 213 u_int32_t count;
209 214 rtems_id queue_id;
210 215
211 216 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
212 217 if (status != RTEMS_SUCCESSFUL)
213 218 {
214 219 PRINTF1("in SEND *** ERR getting queue id, %d\n", status)
215 220 }
216 221
217 222 BOOT_PRINTF("in SEND *** \n")
218 223
219 224 while(1)
220 225 {
221 226 status = rtems_message_queue_receive( queue_id, incomingData, &size,
222 227 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
223 228
224 229 if (status!=RTEMS_SUCCESSFUL)
225 230 {
226 231 PRINTF1("in SEND *** (1) ERR = %d\n", status)
227 232 }
228 233 else
229 234 {
230 235 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
231 236 {
232 237 status = write( fdSPW, incomingData, size );
233 238 if (status == -1){
234 239 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
235 240 }
236 241 }
237 242 else // the incoming message is a spw_ioctl_pkt_send structure
238 243 {
239 244 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
240 245 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
241 246 if (status == -1){
242 247 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
243 248 }
244 249 }
245 250 }
246 251
247 252 status = rtems_message_queue_get_number_pending( queue_id, &count );
248 253 if (status != RTEMS_SUCCESSFUL)
249 254 {
250 255 PRINTF1("in SEND *** (3) ERR = %d\n", status)
251 256 }
252 257 else
253 258 {
254 259 if (count > maxCount)
255 260 {
256 261 maxCount = count;
257 262 }
258 263 }
259 264 }
260 265 }
261 266
262 267 rtems_task wtdg_task( rtems_task_argument argument )
263 268 {
264 269 rtems_event_set event_out;
265 270 rtems_status_code status;
266 271 int linkStatus;
267 272
268 273 BOOT_PRINTF("in WTDG ***\n")
269 274
270 275 while(1)
271 276 {
272 277 // wait for an RTEMS_EVENT
273 278 rtems_event_receive( RTEMS_EVENT_0,
274 279 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
275 280 PRINTF("in WTDG *** wait for the link\n")
276 281 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
277 282 while( linkStatus != 5) // wait for the link
278 283 {
279 284 rtems_task_wake_after( 10 );
280 285 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
281 286 }
282 287
283 288 status = spacewire_stop_start_link( fdSPW );
284 289
285 290 if (status != RTEMS_SUCCESSFUL)
286 291 {
287 292 PRINTF1("in WTDG *** ERR link not started %d\n", status)
288 293 }
289 294 else
290 295 {
291 296 PRINTF("in WTDG *** OK link started\n")
292 297 }
293 298
294 299 // restart the SPIQ task
295 300 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
296 301 if ( status != RTEMS_SUCCESSFUL ) {
297 302 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
298 303 }
299 304
300 305 // restart RECV and SEND
301 306 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
302 307 if ( status != RTEMS_SUCCESSFUL ) {
303 308 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
304 309 }
305 310 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
306 311 if ( status != RTEMS_SUCCESSFUL ) {
307 312 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
308 313 }
309 314 }
310 315 }
311 316
312 317 //****************
313 318 // OTHER FUNCTIONS
314 319 int spacewire_open_link( void )
315 320 {
316 321 /** This function opens the SpaceWire link.
317 322 *
318 323 * @return a valid file descriptor in case of success, -1 in case of a failure
319 324 *
320 325 */
321 326 rtems_status_code status;
322 327
323 328 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
324 329 if ( fdSPW < 0 ) {
325 330 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
326 331 }
327 332 else
328 333 {
329 334 status = RTEMS_SUCCESSFUL;
330 335 }
331 336
332 337 return status;
333 338 }
334 339
335 340 int spacewire_start_link( int fd )
336 341 {
337 342 rtems_status_code status;
338 343
339 344 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
340 345 // -1 default hardcoded driver timeout
341 346
342 347 return status;
343 348 }
344 349
345 350 int spacewire_stop_start_link( int fd )
346 351 {
347 352 rtems_status_code status;
348 353
349 354 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
350 355 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
351 356 // -1 default hardcoded driver timeout
352 357
353 358 return status;
354 359 }
355 360
356 361 int spacewire_configure_link( int fd )
357 362 {
358 363 /** This function configures the SpaceWire link.
359 364 *
360 365 * @return GR-RTEMS-DRIVER directive status codes:
361 366 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
362 367 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
363 368 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
364 369 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
365 370 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
366 371 * - 5 EIO - Error when writing to grswp hardware registers.
367 372 * - 2 ENOENT - No such file or directory
368 373 */
369 374
370 375 rtems_status_code status;
371 376
372 377 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
373 378 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
374 379
375 380 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
376 381 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
377 382 //
378 383 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
379 384 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
380 385 //
381 386 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
382 387 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
383 388 //
384 389 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
385 390 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
386 391 //
387 392 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
388 393 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
389 394 //
390 395 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
391 396 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
392 397 //
393 398 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
394 399 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
395 400
396 401 return status;
397 402 }
398 403
399 404 int spacewire_reset_link( void )
400 405 {
401 406 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
402 407 *
403 408 * @return RTEMS directive status code:
404 409 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
405 410 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
406 411 *
407 412 */
408 413
409 414 rtems_status_code status_spw;
410 415 int i;
411 416
412 417 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
413 418 {
414 419 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
415 420
416 421 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
417 422
418 423 status_spw = spacewire_stop_start_link( fdSPW );
419 424 if ( status_spw != RTEMS_SUCCESSFUL )
420 425 {
421 426 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
422 427 }
423 428
424 429 if ( status_spw == RTEMS_SUCCESSFUL)
425 430 {
426 431 break;
427 432 }
428 433 }
429 434
430 435 return status_spw;
431 436 }
432 437
433 438 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
434 439 {
435 440 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
436 441 *
437 442 * @param val is the value, 0 or 1, used to set the value of the NP bit.
438 443 * @param regAddr is the address of the GRSPW control register.
439 444 *
440 445 * NP is the bit 20 of the GRSPW control register.
441 446 *
442 447 */
443 448
444 449 unsigned int *spwptr = (unsigned int*) regAddr;
445 450
446 451 if (val == 1) {
447 452 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
448 453 }
449 454 if (val== 0) {
450 455 *spwptr = *spwptr & 0xffdfffff;
451 456 }
452 457 }
453 458
454 459 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
455 460 {
456 461 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
457 462 *
458 463 * @param val is the value, 0 or 1, used to set the value of the RE bit.
459 464 * @param regAddr is the address of the GRSPW control register.
460 465 *
461 466 * RE is the bit 16 of the GRSPW control register.
462 467 *
463 468 */
464 469
465 470 unsigned int *spwptr = (unsigned int*) regAddr;
466 471
467 472 if (val == 1)
468 473 {
469 474 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
470 475 }
471 476 if (val== 0)
472 477 {
473 478 *spwptr = *spwptr & 0xfffdffff;
474 479 }
475 480 }
476 481
477 482 void spacewire_compute_stats_offsets( void )
478 483 {
479 484 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
480 485 *
481 486 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
482 487 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
483 488 * during the open systel call).
484 489 *
485 490 */
486 491
487 492 spw_stats spacewire_stats_grspw;
488 493 rtems_status_code status;
489 494
490 495 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
491 496
492 497 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
493 498 + spacewire_stats.packets_received;
494 499 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
495 500 + spacewire_stats.packets_sent;
496 501 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
497 502 + spacewire_stats.parity_err;
498 503 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
499 504 + spacewire_stats.disconnect_err;
500 505 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
501 506 + spacewire_stats.escape_err;
502 507 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
503 508 + spacewire_stats.credit_err;
504 509 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
505 510 + spacewire_stats.write_sync_err;
506 511 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
507 512 + spacewire_stats.rx_rmap_header_crc_err;
508 513 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
509 514 + spacewire_stats.rx_rmap_data_crc_err;
510 515 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
511 516 + spacewire_stats.early_ep;
512 517 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
513 518 + spacewire_stats.invalid_address;
514 519 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
515 520 + spacewire_stats.rx_eep_err;
516 521 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
517 522 + spacewire_stats.rx_truncated;
518 523 }
519 524
520 525 void spacewire_update_statistics( void )
521 526 {
522 527 rtems_status_code status;
523 528 spw_stats spacewire_stats_grspw;
524 529
525 530 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
526 531
527 532 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
528 533 + spacewire_stats_grspw.packets_received;
529 534 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
530 535 + spacewire_stats_grspw.packets_sent;
531 536 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
532 537 + spacewire_stats_grspw.parity_err;
533 538 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
534 539 + spacewire_stats_grspw.disconnect_err;
535 540 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
536 541 + spacewire_stats_grspw.escape_err;
537 542 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
538 543 + spacewire_stats_grspw.credit_err;
539 544 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
540 545 + spacewire_stats_grspw.write_sync_err;
541 546 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
542 547 + spacewire_stats_grspw.rx_rmap_header_crc_err;
543 548 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
544 549 + spacewire_stats_grspw.rx_rmap_data_crc_err;
545 550 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
546 551 + spacewire_stats_grspw.early_ep;
547 552 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
548 553 + spacewire_stats_grspw.invalid_address;
549 554 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
550 555 + spacewire_stats_grspw.rx_eep_err;
551 556 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
552 557 + spacewire_stats_grspw.rx_truncated;
553 558 //spacewire_stats.tx_link_err;
554 559
555 560 //****************************
556 561 // DPU_SPACEWIRE_IF_STATISTICS
557 562 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
558 563 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
559 564 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
560 565 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
561 566 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
562 567 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
563 568
564 569 //******************************************
565 570 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
566 571 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
567 572 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
568 573 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
569 574 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
570 575 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
571 576 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
572 577 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
573 578 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
574 579 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
575 580
576 581 //*********************************************
577 582 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
578 583 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
579 584 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
580 585 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
581 586 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
582 587
583 588 }
584 589
585 590 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
586 591 {
587 592 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
588 593 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
589 594 //}
590 595 }
591 596
592 597 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
593 598 {
594 599 int linkStatus;
595 600 rtems_status_code status;
596 601
597 602 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
598 603
599 604 if ( linkStatus == 5) {
600 605 PRINTF("in spacewire_reset_link *** link is running\n")
601 606 status = RTEMS_SUCCESSFUL;
602 607 }
603 608 }
604 609
605 610 rtems_status_code rtems_message_queue_send_lfr( rtems_id id, const void *buffer, size_t size )
606 611 {
607 612 rtems_status_code status;
608 613 rtems_mode previous_mode_set;
609 614
610 615 // set the preemption OFF
611 616 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &previous_mode_set );
612 617
613 618 // use the message queue
614 619 status = rtems_message_queue_send_lfr( id, buffer, size );
615 620
616 621 // set the preemption ON
617 622 status = rtems_task_mode( RTEMS_PREEMPT , RTEMS_PREEMPT_MASK, &previous_mode_set );
618 623
619 624 return status;
620 625 }
621 626
@@ -1,777 +1,771
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 unsigned char time[6];
34 35 rtems_id queue_rcv_id;
35 36 rtems_id queue_snd_id;
36 37
37 38 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_rcv_id );
38 39 if (status != RTEMS_SUCCESSFUL)
39 40 {
40 41 PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status)
41 42 }
42 43
43 44 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_snd_id );
44 45 if (status != RTEMS_SUCCESSFUL)
45 46 {
46 47 PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status)
47 48 }
48 49
49 50 result = LFR_SUCCESSFUL;
50 51 subtype = 0; // subtype of the current TC packet
51 52
52 53 BOOT_PRINTF("in ACTN *** \n")
53 54
54 55 while(1)
55 56 {
56 57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
57 58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 getTime( time ); // set time to the current time
58 60 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
59 61 else
60 62 {
61 63 subtype = TC.serviceSubType;
62 64 switch(subtype)
63 65 {
64 66 case TC_SUBTYPE_RESET:
65 result = action_reset( &TC, queue_snd_id );
66 close_action( &TC, result, queue_snd_id );
67 result = action_reset( &TC, queue_snd_id, time );
68 close_action( &TC, result, queue_snd_id, time );
67 69 break;
68 70 //
69 71 case TC_SUBTYPE_LOAD_COMM:
70 72 result = action_load_common_par( &TC );
71 close_action( &TC, result, queue_snd_id );
73 close_action( &TC, result, queue_snd_id, time );
72 74 break;
73 75 //
74 76 case TC_SUBTYPE_LOAD_NORM:
75 result = action_load_normal_par( &TC, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
77 result = action_load_normal_par( &TC, queue_snd_id, time );
78 close_action( &TC, result, queue_snd_id, time );
77 79 break;
78 80 //
79 81 case TC_SUBTYPE_LOAD_BURST:
80 result = action_load_burst_par( &TC, queue_snd_id );
81 close_action( &TC, result, queue_snd_id );
82 result = action_load_burst_par( &TC, queue_snd_id, time );
83 close_action( &TC, result, queue_snd_id, time );
82 84 break;
83 85 //
84 86 case TC_SUBTYPE_LOAD_SBM1:
85 result = action_load_sbm1_par( &TC, queue_snd_id );
86 close_action( &TC, result, queue_snd_id );
87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
88 close_action( &TC, result, queue_snd_id, time );
87 89 break;
88 90 //
89 91 case TC_SUBTYPE_LOAD_SBM2:
90 result = action_load_sbm2_par( &TC, queue_snd_id );
91 close_action( &TC, result, queue_snd_id );
92 result = action_load_sbm2_par( &TC, queue_snd_id, time );
93 close_action( &TC, result, queue_snd_id, time );
92 94 break;
93 95 //
94 96 case TC_SUBTYPE_DUMP:
95 97 result = action_dump_par( queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
98 close_action( &TC, result, queue_snd_id, time );
97 99 break;
98 100 //
99 101 case TC_SUBTYPE_ENTER:
100 result = action_enter_mode( &TC, queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
102 result = action_enter_mode( &TC, queue_snd_id, time );
103 close_action( &TC, result, queue_snd_id, time );
102 104 break;
103 105 //
104 106 case TC_SUBTYPE_UPDT_INFO:
105 107 result = action_update_info( &TC, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
108 close_action( &TC, result, queue_snd_id, time );
107 109 break;
108 110 //
109 111 case TC_SUBTYPE_EN_CAL:
110 result = action_enable_calibration( &TC, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
112 result = action_enable_calibration( &TC, queue_snd_id, time );
113 close_action( &TC, result, queue_snd_id, time );
112 114 break;
113 115 //
114 116 case TC_SUBTYPE_DIS_CAL:
115 result = action_disable_calibration( &TC, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
117 result = action_disable_calibration( &TC, queue_snd_id, time );
118 close_action( &TC, result, queue_snd_id, time );
117 119 break;
118 120 //
119 121 case TC_SUBTYPE_UPDT_TIME:
120 122 result = action_update_time( &TC );
121 close_action( &TC, result, queue_snd_id );
123 close_action( &TC, result, queue_snd_id, time );
122 124 break;
123 125 //
124 126 default:
125 127 break;
126 128 }
127 129 }
128 130 }
129 131 }
130 132
131 133 //***********
132 134 // TC ACTIONS
133 135
134 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
136 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
135 137 {
136 138 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
137 139 *
138 140 * @param TC points to the TeleCommand packet that is being processed
139 141 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
140 142 *
141 143 */
142 144
143 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
145 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
144 146 return LFR_DEFAULT;
145 147 }
146 148
147 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
149 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
148 150 {
149 151 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
150 152 *
151 153 * @param TC points to the TeleCommand packet that is being processed
152 154 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
153 155 *
154 156 */
155 157
156 158 rtems_status_code status;
157 159 unsigned char requestedMode;
158 160
159 161 requestedMode = TC->dataAndCRC[1];
160 162
161 163 if ( (requestedMode != LFR_MODE_STANDBY)
162 164 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
163 165 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
164 166 {
165 167 status = RTEMS_UNSATISFIED;
166 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
168 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode, time );
167 169 }
168 170 else
169 171 {
170 172 printf("try to enter mode %d\n", requestedMode);
171 173
172 174 #ifdef PRINT_TASK_STATISTICS
173 175 if (requestedMode != LFR_MODE_STANDBY)
174 176 {
175 177 rtems_cpu_usage_reset();
176 178 maxCount = 0;
177 179 }
178 180 #endif
179 181
180 182 status = transition_validation(requestedMode);
181 183
182 184 if ( status == LFR_SUCCESSFUL ) {
183 185 if ( lfrCurrentMode != LFR_MODE_STANDBY)
184 186 {
185 187 status = stop_current_mode();
186 188 }
187 189 if (status != RTEMS_SUCCESSFUL)
188 190 {
189 191 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
190 192 }
191 193 status = enter_mode(requestedMode, TC);
192 194 }
193 195 else
194 196 {
195 197 PRINTF("ERR *** in action_enter *** transition rejected\n")
196 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
198 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
197 199 }
198 200 }
199 201
200 202 return status;
201 203 }
202 204
203 205 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
204 206 {
205 207 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
206 208 *
207 209 * @param TC points to the TeleCommand packet that is being processed
208 210 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
209 211 *
210 212 * @return LFR directive status code:
211 213 * - LFR_DEFAULT
212 214 * - LFR_SUCCESSFUL
213 215 *
214 216 */
215 217
216 218 unsigned int val;
217 219 int result;
218 220
219 221 result = LFR_DEFAULT;
220 222
221 223 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
222 224 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
223 225 val++;
224 226 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
225 227 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
226 228
227 229 return result;
228 230 }
229 231
230 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
232 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
231 233 {
232 234 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
233 235 *
234 236 * @param TC points to the TeleCommand packet that is being processed
235 237 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
236 238 *
237 239 */
238 240
239 241 int result;
240 242 unsigned char lfrMode;
241 243
242 244 result = LFR_DEFAULT;
243 245 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
244 246
245 247 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
246 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
248 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
247 249 result = LFR_DEFAULT;
248 250 }
249 251 else {
250 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
252 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
251 253 result = LFR_DEFAULT;
252 254 }
253 255 return result;
254 256 }
255 257
256 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
258 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
257 259 {
258 260 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
259 261 *
260 262 * @param TC points to the TeleCommand packet that is being processed
261 263 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
262 264 *
263 265 */
264 266
265 267 int result;
266 268 unsigned char lfrMode;
267 269
268 270 result = LFR_DEFAULT;
269 271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
270 272
271 273 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
272 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
274 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
273 275 result = LFR_DEFAULT;
274 276 }
275 277 else {
276 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
278 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
277 279 result = LFR_DEFAULT;
278 280 }
279 281 return result;
280 282 }
281 283
282 284 int action_update_time(ccsdsTelecommandPacket_t *TC)
283 285 {
284 286 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
285 287 *
286 288 * @param TC points to the TeleCommand packet that is being processed
287 289 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
288 290 *
289 291 * @return LFR_SUCCESSFUL
290 292 *
291 293 */
292 294
293 295 unsigned int val;
294 296
295 297 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
296 298 + (TC->dataAndCRC[1] << 16)
297 299 + (TC->dataAndCRC[2] << 8)
298 300 + TC->dataAndCRC[3];
299 301 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
300 302 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
301 303 val++;
302 304 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
303 305 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
304 306 time_management_regs->ctrl = time_management_regs->ctrl | 1;
305 307
306 308 return LFR_SUCCESSFUL;
307 309 }
308 310
309 311 //*******************
310 312 // ENTERING THE MODES
311 313
312 314 int transition_validation(unsigned char requestedMode)
313 315 {
314 316 int status;
315 317
316 318 switch (requestedMode)
317 319 {
318 320 case LFR_MODE_STANDBY:
319 321 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
320 322 status = LFR_DEFAULT;
321 323 }
322 324 else
323 325 {
324 326 status = LFR_SUCCESSFUL;
325 327 }
326 328 break;
327 329 case LFR_MODE_NORMAL:
328 330 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
329 331 status = LFR_DEFAULT;
330 332 }
331 333 else {
332 334 status = LFR_SUCCESSFUL;
333 335 }
334 336 break;
335 337 case LFR_MODE_BURST:
336 338 if ( lfrCurrentMode == LFR_MODE_BURST ) {
337 339 status = LFR_DEFAULT;
338 340 }
339 341 else {
340 342 status = LFR_SUCCESSFUL;
341 343 }
342 344 break;
343 345 case LFR_MODE_SBM1:
344 346 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
345 347 status = LFR_DEFAULT;
346 348 }
347 349 else {
348 350 status = LFR_SUCCESSFUL;
349 351 }
350 352 break;
351 353 case LFR_MODE_SBM2:
352 354 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
353 355 status = LFR_DEFAULT;
354 356 }
355 357 else {
356 358 status = LFR_SUCCESSFUL;
357 359 }
358 360 break;
359 361 default:
360 362 status = LFR_DEFAULT;
361 363 break;
362 364 }
363 365
364 366 return status;
365 367 }
366 368
367 369 int stop_current_mode()
368 370 {
369 371 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
370 372 *
371 373 * @return RTEMS directive status codes:
372 374 * - RTEMS_SUCCESSFUL - task restarted successfully
373 375 * - RTEMS_INVALID_ID - task id invalid
374 376 * - RTEMS_ALREADY_SUSPENDED - task already suspended
375 377 *
376 378 */
377 379
378 380 rtems_status_code status;
379 381
380 382 status = RTEMS_SUCCESSFUL;
381 383
382 384 #ifdef GSA
383 385 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
384 386 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
385 387 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
386 388 #else
387 389 // mask interruptions
388 390 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
389 391 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
390 392 // reset registers
391 393 reset_wfp_burst_enable(); // reset burst and enable bits
392 394 reset_wfp_status(); // reset all the status bits
393 395 // creal interruptions
394 396 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
395 397 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectarl matrix interrupt
396 398 #endif
397 399 //**********************
398 400 // suspend several tasks
399 401 if (lfrCurrentMode != LFR_MODE_STANDBY) {
400 402 status = suspend_science_tasks();
401 403 }
402 404
403 405 if (status != RTEMS_SUCCESSFUL)
404 406 {
405 407 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
406 408 }
407 409
408 410 return status;
409 411 }
410 412
411 413 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC )
412 414 {
413 415 rtems_status_code status;
414 416
415 417 status = RTEMS_UNSATISFIED;
416 418
417 419 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
418 420 updateLFRCurrentMode();
419 421
420 422 switch(mode){
421 423 case LFR_MODE_STANDBY:
422 424 status = enter_standby_mode( );
423 425 break;
424 426 case LFR_MODE_NORMAL:
425 427 status = enter_normal_mode( );
426 428 break;
427 429 case LFR_MODE_BURST:
428 430 status = enter_burst_mode( );
429 431 break;
430 432 case LFR_MODE_SBM1:
431 433 status = enter_sbm1_mode( );
432 434 break;
433 435 case LFR_MODE_SBM2:
434 436 status = enter_sbm2_mode( );
435 437 break;
436 438 default:
437 439 status = RTEMS_UNSATISFIED;
438 440 }
439 441
440 442 if (status != RTEMS_SUCCESSFUL)
441 443 {
442 444 PRINTF("in enter_mode *** ERR\n")
443 445 status = RTEMS_UNSATISFIED;
444 446 }
445 447
446 448 return status;
447 449 }
448 450
449 451 int enter_standby_mode()
450 452 {
451 453 PRINTF1("maxCount = %d\n", maxCount)
452 454
453 455 #ifdef PRINT_TASK_STATISTICS
454 456 rtems_cpu_usage_report();
455 457 #endif
456 458
457 459 #ifdef PRINT_STACK_REPORT
458 460 rtems_stack_checker_report_usage();
459 461 #endif
460 462
461 463 return LFR_SUCCESSFUL;
462 464 }
463 465
464 466 int enter_normal_mode()
465 467 {
466 468 rtems_status_code status;
467 469
468 470 status = restart_science_tasks();
469 471
470 472 #ifdef GSA
471 473 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
472 474 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
473 475 LEON_Clear_interrupt( IRQ_WF );
474 476 LEON_Unmask_interrupt( IRQ_WF );
475 477 //
476 478 set_local_nb_interrupt_f0_MAX();
477 479 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
478 480 LEON_Unmask_interrupt( IRQ_SM );
479 481 #else
480 482 //****************
481 483 // waveform picker
482 484 reset_waveform_picker_regs();
483 485 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
484 486 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
485 487 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
486 488 //****************
487 489 // spectral matrix
488 490 #endif
489 491
490 492 return status;
491 493 }
492 494
493 495 int enter_burst_mode()
494 496 {
495 497 rtems_status_code status;
496 498
497 499 status = restart_science_tasks();
498 500
499 501 #ifdef GSA
500 502 LEON_Unmask_interrupt( IRQ_SM );
501 503 #else
502 504 reset_waveform_picker_regs();
503 505 set_wfp_burst_enable_register(LFR_MODE_BURST);
504 506 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
505 507 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
506 508 #endif
507 509
508 510 return status;
509 511 }
510 512
511 513 int enter_sbm1_mode()
512 514 {
513 515 rtems_status_code status;
514 516
515 517 status = restart_science_tasks();
516 518
517 519 set_local_sbm1_nb_cwf_max();
518 520
519 521 reset_local_sbm1_nb_cwf_sent();
520 522
521 523 #ifdef GSA
522 524 LEON_Unmask_interrupt( IRQ_SM );
523 525 #else
524 526 reset_waveform_picker_regs();
525 527 set_wfp_burst_enable_register(LFR_MODE_SBM1);
526 528 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
527 529 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
528 530 // SM simulation
529 531 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
530 532 // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
531 533 // LEON_Unmask_interrupt( IRQ_SM );
532 534 #endif
533 535
534 536 return status;
535 537 }
536 538
537 539 int enter_sbm2_mode()
538 540 {
539 541 rtems_status_code status;
540 542
541 543 status = restart_science_tasks();
542 544
543 545 set_local_sbm2_nb_cwf_max();
544 546
545 547 reset_local_sbm2_nb_cwf_sent();
546 548
547 549 #ifdef GSA
548 550 LEON_Unmask_interrupt( IRQ_SM );
549 551 #else
550 552 reset_waveform_picker_regs();
551 553 set_wfp_burst_enable_register(LFR_MODE_SBM2);
552 554 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
553 555 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
554 556 #endif
555 557
556 558 return status;
557 559 }
558 560
559 561 int restart_science_tasks()
560 562 {
561 563 rtems_status_code status[6];
562 564 rtems_status_code ret;
563 565
564 566 ret = RTEMS_SUCCESSFUL;
565 567
566 568 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
567 569 if (status[0] != RTEMS_SUCCESSFUL)
568 570 {
569 571 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
570 572 }
571 573
572 574 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
573 575 if (status[1] != RTEMS_SUCCESSFUL)
574 576 {
575 577 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
576 578 }
577 579
578 580 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
579 581 if (status[2] != RTEMS_SUCCESSFUL)
580 582 {
581 583 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
582 584 }
583 585
584 586 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
585 587 if (status[3] != RTEMS_SUCCESSFUL)
586 588 {
587 589 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
588 590 }
589 591
590 592 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
591 593 if (status[4] != RTEMS_SUCCESSFUL)
592 594 {
593 595 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
594 596 }
595 597
596 598 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
597 599 if (status[5] != RTEMS_SUCCESSFUL)
598 600 {
599 601 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
600 602 }
601 603
602 604 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
603 605 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
604 606 {
605 607 ret = RTEMS_UNSATISFIED;
606 608 }
607 609
608 610 return ret;
609 611 }
610 612
611 613 int suspend_science_tasks()
612 614 {
613 615 /** This function suspends the science tasks.
614 616 *
615 617 * @return RTEMS directive status codes:
616 618 * - RTEMS_SUCCESSFUL - task restarted successfully
617 619 * - RTEMS_INVALID_ID - task id invalid
618 620 * - RTEMS_ALREADY_SUSPENDED - task already suspended
619 621 *
620 622 */
621 623
622 624 rtems_status_code status;
623 625
624 626 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
625 627 if (status != RTEMS_SUCCESSFUL)
626 628 {
627 629 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
628 630 }
629 631
630 632 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
631 633 {
632 634 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
633 635 if (status != RTEMS_SUCCESSFUL)
634 636 {
635 637 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
636 638 }
637 639 }
638 640
639 641 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
640 642 {
641 643 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
642 644 if (status != RTEMS_SUCCESSFUL)
643 645 {
644 646 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
645 647 }
646 648 }
647 649
648 650 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
649 651 {
650 652 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
651 653 if (status != RTEMS_SUCCESSFUL)
652 654 {
653 655 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
654 656 }
655 657 }
656 658
657 659 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
658 660 {
659 661 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
660 662 if (status != RTEMS_SUCCESSFUL)
661 663 {
662 664 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
663 665 }
664 666 }
665 667
666 668 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
667 669 {
668 670 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
669 671 if (status != RTEMS_SUCCESSFUL)
670 672 {
671 673 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
672 674 }
673 675 }
674 676
675 677 return status;
676 678 }
677 679
678 680 //****************
679 681 // CLOSING ACTIONS
680 682 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time)
681 683 {
682 684 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
683 685 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
684 686 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
685 687 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
686 688 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
687 689 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
688 690 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
689 691 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
690 692 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
691 693 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
692 694 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
693 695 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
694 696 }
695 697
696 698 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time)
697 699 {
698 700 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
699 701 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
700 702 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
701 703 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
702 704 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
703 705 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
704 706 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
705 707 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
706 708 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
707 709 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
708 710 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
709 711 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
710 712 }
711 713
712 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id)
714 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time)
713 715 {
714 716 unsigned int val = 0;
715 unsigned char time[6];
716
717 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
718 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
719 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
720 time[3] = (unsigned char) (time_management_regs->coarse_time);
721 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
722 time[5] = (unsigned char) (time_management_regs->fine_time);
723 717
724 718 if (result == LFR_SUCCESSFUL)
725 719 {
726 720 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
727 721 &&
728 722 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
729 723 )
730 724 {
731 725 send_tm_lfr_tc_exe_success( TC, queue_id, time );
732 726 }
733 727 update_last_TC_exe( TC, time );
734 728 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
735 729 val++;
736 730 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
737 731 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
738 732 }
739 733 else
740 734 {
741 735 update_last_TC_rej( TC, time );
742 736 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
743 737 val++;
744 738 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
745 739 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
746 740 }
747 741 }
748 742
749 743 //***************************
750 744 // Interrupt Service Routines
751 745 rtems_isr commutation_isr1( rtems_vector_number vector )
752 746 {
753 747 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
754 748 printf("In commutation_isr1 *** Error sending event to DUMB\n");
755 749 }
756 750 }
757 751
758 752 rtems_isr commutation_isr2( rtems_vector_number vector )
759 753 {
760 754 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
761 755 printf("In commutation_isr2 *** Error sending event to DUMB\n");
762 756 }
763 757 }
764 758
765 759 //****************
766 760 // OTHER FUNCTIONS
767 761 void updateLFRCurrentMode()
768 762 {
769 763 /** This function updates the value of the global variable lfrCurrentMode.
770 764 *
771 765 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
772 766 *
773 767 */
774 768 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
775 769 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
776 770 }
777 771
@@ -1,449 +1,449
1 1 /** Functions to load and dump parameters in the LFR registers.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 7 * TC_LFR_LOAD_COMMON_PAR\n
8 8 * TC_LFR_LOAD_NORMAL_PAR\n
9 9 * TC_LFR_LOAD_BURST_PAR\n
10 10 * TC_LFR_LOAD_SBM1_PAR\n
11 11 * TC_LFR_LOAD_SBM2_PAR\n
12 12 *
13 13 */
14 14
15 15 #include "tc_load_dump_parameters.h"
16 16
17 17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 18 {
19 19 /** This function updates the LFR registers with the incoming common parameters.
20 20 *
21 21 * @param TC points to the TeleCommand packet that is being processed
22 22 *
23 23 *
24 24 */
25 25
26 26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
27 27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
28 28 set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1);
29 29 return LFR_SUCCESSFUL;
30 30 }
31 31
32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
33 33 {
34 34 /** This function updates the LFR registers with the incoming normal parameters.
35 35 *
36 36 * @param TC points to the TeleCommand packet that is being processed
37 37 * @param queue_id is the id of the queue which handles TM related to this execution step
38 38 *
39 39 */
40 40
41 41 int result;
42 42 int flag;
43 43
44 44 flag = LFR_SUCCESSFUL;
45 45
46 46 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
47 47 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
48 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
48 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
49 49 flag = LFR_DEFAULT;
50 50 }
51 51
52 52 //***************
53 53 // sy_lfr_n_swf_l
54 54 if (flag == LFR_SUCCESSFUL)
55 55 {
56 result = set_sy_lfr_n_swf_l( TC, queue_id );
56 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
57 57 if (result != LFR_SUCCESSFUL)
58 58 {
59 59 flag = LFR_DEFAULT;
60 60 }
61 61 }
62 62
63 63 //***************
64 64 // sy_lfr_n_swf_p
65 65 if (flag == LFR_SUCCESSFUL)
66 66 {
67 result = set_sy_lfr_n_swf_p( TC, queue_id );
67 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
68 68 if (result != LFR_SUCCESSFUL)
69 69 {
70 70 flag = LFR_DEFAULT;
71 71 }
72 72 }
73 73
74 74 //***************
75 75 // SY_LFR_N_ASM_P
76 76 if (flag == LFR_SUCCESSFUL)
77 77 {
78 78 result = set_sy_lfr_n_asm_p( TC, queue_id );
79 79 if (result != LFR_SUCCESSFUL)
80 80 {
81 81 flag = LFR_DEFAULT;
82 82 }
83 83 }
84 84
85 85 //***************
86 86 // SY_LFR_N_BP_P0
87 87 if (flag == LFR_SUCCESSFUL)
88 88 {
89 89 result = set_sy_lfr_n_bp_p0( TC, queue_id );
90 90 if (result != LFR_SUCCESSFUL)
91 91 {
92 92 flag = LFR_DEFAULT;
93 93 }
94 94 }
95 95
96 96 //***************
97 97 // sy_lfr_n_bp_p1
98 98 if (flag == LFR_SUCCESSFUL)
99 99 {
100 100 result = set_sy_lfr_n_bp_p1( TC, queue_id );
101 101 if (result != LFR_SUCCESSFUL)
102 102 {
103 103 flag = LFR_DEFAULT;
104 104 }
105 105 }
106 106
107 107 return flag;
108 108 }
109 109
110 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
110 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
111 111 {
112 112 /** This function updates the LFR registers with the incoming burst parameters.
113 113 *
114 114 * @param TC points to the TeleCommand packet that is being processed
115 115 * @param queue_id is the id of the queue which handles TM related to this execution step
116 116 *
117 117 */
118 118
119 119 int result;
120 120 unsigned char lfrMode;
121 121
122 122 result = LFR_DEFAULT;
123 123 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
124 124
125 125 if ( lfrMode == LFR_MODE_BURST ) {
126 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
126 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
127 127 result = LFR_DEFAULT;
128 128 }
129 129 else {
130 130 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
131 131 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
132 132
133 133 result = LFR_SUCCESSFUL;
134 134 }
135 135
136 136 return result;
137 137 }
138 138
139 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
139 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 140 {
141 141 /** This function updates the LFR registers with the incoming sbm1 parameters.
142 142 *
143 143 * @param TC points to the TeleCommand packet that is being processed
144 144 * @param queue_id is the id of the queue which handles TM related to this execution step
145 145 *
146 146 */
147 147 int result;
148 148 unsigned char lfrMode;
149 149
150 150 result = LFR_DEFAULT;
151 151 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
152 152
153 153 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
154 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
154 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
155 155 result = LFR_DEFAULT;
156 156 }
157 157 else {
158 158 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
159 159 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
160 160
161 161 result = LFR_SUCCESSFUL;
162 162 }
163 163
164 164 return result;
165 165 }
166 166
167 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
167 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
168 168 {
169 169 /** This function updates the LFR registers with the incoming sbm2 parameters.
170 170 *
171 171 * @param TC points to the TeleCommand packet that is being processed
172 172 * @param queue_id is the id of the queue which handles TM related to this execution step
173 173 *
174 174 */
175 175
176 176 int result;
177 177 unsigned char lfrMode;
178 178
179 179 result = LFR_DEFAULT;
180 180 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
181 181
182 182 if ( (lfrMode == LFR_MODE_SBM2) || (lfrMode == LFR_MODE_SBM2) ) {
183 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
183 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
184 184 result = LFR_DEFAULT;
185 185 }
186 186 else {
187 187 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
188 188 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
189 189
190 190 result = LFR_SUCCESSFUL;
191 191 }
192 192
193 193 return result;
194 194 }
195 195
196 196 int action_dump_par( rtems_id queue_id )
197 197 {
198 198 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
199 199 *
200 200 * @param queue_id is the id of the queue which handles TM related to this execution step.
201 201 *
202 202 * @return RTEMS directive status codes:
203 203 * - RTEMS_SUCCESSFUL - message sent successfully
204 204 * - RTEMS_INVALID_ID - invalid queue id
205 205 * - RTEMS_INVALID_SIZE - invalid message size
206 206 * - RTEMS_INVALID_ADDRESS - buffer is NULL
207 207 * - RTEMS_UNSATISFIED - out of message buffers
208 208 * - RTEMS_TOO_MANY - queue s limit has been reached
209 209 *
210 210 */
211 211
212 212 int status;
213 213
214 214 // UPDATE TIME
215 215 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
216 216 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
217 217 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
218 218 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
219 219 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
220 220 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
221 221 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
222 222 // SEND DATA
223 223 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
224 224 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
225 225 if (status != RTEMS_SUCCESSFUL) {
226 226 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
227 227 }
228 228
229 229 return status;
230 230 }
231 231
232 232 //***********************
233 233 // NORMAL MODE PARAMETERS
234 234
235 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
235 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
236 236 {
237 237 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
238 238 *
239 239 * @param TC points to the TeleCommand packet that is being processed
240 240 * @param queue_id is the id of the queue which handles TM related to this execution step
241 241 *
242 242 */
243 243
244 244 unsigned int tmp;
245 245 int result;
246 246 unsigned char msb;
247 247 unsigned char lsb;
248 248
249 249 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ];
250 250 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ];
251 251
252 252 tmp = ( unsigned int ) floor(
253 253 ( ( msb*256 ) + lsb ) / 16
254 254 ) * 16;
255 255
256 256 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
257 257 { // 2048 is the maximum limit due to the size of the buffers
258 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb );
258 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb, time );
259 259 result = WRONG_APP_DATA;
260 260 }
261 261 else if (tmp != 2048)
262 262 {
263 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
263 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
264 264 result = FUNCT_NOT_IMPL;
265 265 }
266 266 else
267 267 {
268 268 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
269 269 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
270 270 result = LFR_SUCCESSFUL;
271 271 }
272 272
273 273 return result;
274 274 }
275 275
276 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
276 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
277 277 {
278 278 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
279 279 *
280 280 * @param TC points to the TeleCommand packet that is being processed
281 281 * @param queue_id is the id of the queue which handles TM related to this execution step
282 282 *
283 283 */
284 284
285 285 unsigned int tmp;
286 286 int result;
287 287 unsigned char msb;
288 288 unsigned char lsb;
289 289
290 290 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ];
291 291 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ];
292 292
293 293 tmp = ( unsigned int ) floor(
294 294 ( ( msb*256 ) + lsb ) / 8
295 295 ) * 8;
296 296
297 297 if ( (tmp < 16) || (tmp > 65528) )
298 298 {
299 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb );
299 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb, time );
300 300 result = WRONG_APP_DATA;
301 301 }
302 302 else
303 303 {
304 304 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
305 305 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
306 306 result = LFR_SUCCESSFUL;
307 307 }
308 308
309 309 return result;
310 310 }
311 311
312 312 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
313 313 {
314 314 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
315 315 *
316 316 * @param TC points to the TeleCommand packet that is being processed
317 317 * @param queue_id is the id of the queue which handles TM related to this execution step
318 318 *
319 319 */
320 320
321 321 int result;
322 322 unsigned char msb;
323 323 unsigned char lsb;
324 324
325 325 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ];
326 326 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ];
327 327
328 328 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
329 329 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
330 330 result = LFR_SUCCESSFUL;
331 331
332 332 return result;
333 333 }
334 334
335 335 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
336 336 {
337 337 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
338 338 *
339 339 * @param TC points to the TeleCommand packet that is being processed
340 340 * @param queue_id is the id of the queue which handles TM related to this execution step
341 341 *
342 342 */
343 343
344 344 int status;
345 345
346 346 status = LFR_SUCCESSFUL;
347 347
348 348 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ];
349 349
350 350 return status;
351 351 }
352 352
353 353 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
354 354 {
355 355 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
356 356 *
357 357 * @param TC points to the TeleCommand packet that is being processed
358 358 * @param queue_id is the id of the queue which handles TM related to this execution step
359 359 *
360 360 */
361 361
362 362 int status;
363 363
364 364 status = LFR_SUCCESSFUL;
365 365
366 366 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ];
367 367
368 368 return status;
369 369 }
370 370
371 371 //**********************
372 372 // BURST MODE PARAMETERS
373 373
374 374 //*********************
375 375 // SBM1 MODE PARAMETERS
376 376
377 377 //*********************
378 378 // SBM2 MODE PARAMETERS
379 379
380 380 //**********
381 381 // init dump
382 382
383 383 void init_parameter_dump( void )
384 384 {
385 385 /** This function initialize the parameter_dump_packet global variable with default values.
386 386 *
387 387 */
388 388
389 389 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
390 390 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
391 391 parameter_dump_packet.reserved = CCSDS_RESERVED;
392 392 parameter_dump_packet.userApplication = CCSDS_USER_APP;
393 393 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
394 394 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
395 395 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
396 396 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
397 397 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
398 398 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
399 399 // DATA FIELD HEADER
400 400 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
401 401 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
402 402 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
403 403 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
404 404 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
405 405 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
406 406 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
407 407 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
408 408 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
409 409 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
410 410 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
411 411
412 412 //******************
413 413 // COMMON PARAMETERS
414 414 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
415 415 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
416 416
417 417 //******************
418 418 // NORMAL PARAMETERS
419 419 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
420 420 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
421 421 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
422 422 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
423 423 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
424 424 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
425 425 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
426 426 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
427 427
428 428 //*****************
429 429 // BURST PARAMETERS
430 430 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
431 431 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
432 432
433 433 //****************
434 434 // SBM1 PARAMETERS
435 435 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
436 436 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
437 437
438 438 //****************
439 439 // SBM2 PARAMETERS
440 440 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
441 441 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
442 442 }
443 443
444 444
445 445
446 446
447 447
448 448
449 449
@@ -1,491 +1,492
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 unsigned char byte_position, unsigned char rcv_value )
78 unsigned char byte_position, unsigned char rcv_value,
79 unsigned char *time)
79 80 {
80 81 /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue.
81 82 *
82 83 * @param TC points to the TeleCommand packet that is being processed
83 84 * @param queue_id is the id of the queue which handles TM
84 85 * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent
85 86 * @param rcv_value is the value of the LSB of the parameter that has been deteced as inconsistent
86 87 *
87 88 * @return RTEMS directive status code:
88 89 * - RTEMS_SUCCESSFUL - message sent successfully
89 90 * - RTEMS_INVALID_ID - invalid queue id
90 91 * - RTEMS_INVALID_SIZE - invalid message size
91 92 * - RTEMS_INVALID_ADDRESS - buffer is NULL
92 93 * - RTEMS_UNSATISFIED - out of message buffers
93 94 * - RTEMS_TOO_MANY - queue s limit has been reached
94 95 *
95 96 */
96 97
97 98 rtems_status_code status;
98 99 Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
99 100 unsigned char messageSize;
100 101
101 102 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
102 103 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
103 104 TM.reserved = DEFAULT_RESERVED;
104 105 TM.userApplication = CCSDS_USER_APP;
105 106 // PACKET HEADER
106 107 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
107 108 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
108 109 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
109 110 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
110 111 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
111 112 // DATA FIELD HEADER
112 113 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
113 114 TM.serviceType = TM_TYPE_TC_EXE;
114 115 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
115 116 TM.destinationID = TC->sourceID;
116 117 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
117 118 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
118 119 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
119 120 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
120 121 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
121 122 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
122 123 //
123 124 TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> 8);
124 125 TM.tc_failure_code[1] = (char) (WRONG_APP_DATA );
125 126 TM.telecommand_pkt_id[0] = TC->packetID[0];
126 127 TM.telecommand_pkt_id[1] = TC->packetID[1];
127 128 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
128 129 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
129 130 TM.tc_service = TC->serviceType; // type of the rejected TC
130 131 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
131 132 TM.byte_position = byte_position;
132 133 TM.rcv_value = rcv_value;
133 134
134 135 messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
135 136
136 137 // SEND DATA
137 138 status = rtems_message_queue_send( queue_id, &TM, messageSize);
138 139 if (status != RTEMS_SUCCESSFUL) {
139 140 PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n")
140 141 }
141 142
142 143 return status;
143 144 }
144 145
145 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
146 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
146 147 {
147 148 /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue.
148 149 *
149 150 * @param TC points to the TeleCommand packet that is being processed
150 151 * @param queue_id is the id of the queue which handles TM
151 152 *
152 153 * @return RTEMS directive status code:
153 154 * - RTEMS_SUCCESSFUL - message sent successfully
154 155 * - RTEMS_INVALID_ID - invalid queue id
155 156 * - RTEMS_INVALID_SIZE - invalid message size
156 157 * - RTEMS_INVALID_ADDRESS - buffer is NULL
157 158 * - RTEMS_UNSATISFIED - out of message buffers
158 159 * - RTEMS_TOO_MANY - queue s limit has been reached
159 160 *
160 161 */
161 162
162 163 rtems_status_code status;
163 164 Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
164 165 unsigned char messageSize;
165 166
166 167 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
167 168 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
168 169 TM.reserved = DEFAULT_RESERVED;
169 170 TM.userApplication = CCSDS_USER_APP;
170 171 // PACKET HEADER
171 172 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
172 173 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
173 174 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
174 175 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
175 176 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
176 177 // DATA FIELD HEADER
177 178 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
178 179 TM.serviceType = TM_TYPE_TC_EXE;
179 180 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
180 181 TM.destinationID = TC->sourceID; // default destination id
181 182 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
182 183 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
183 184 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
184 185 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
185 186 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
186 187 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
187 188 //
188 189 TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> 8);
189 190 TM.tc_failure_code[1] = (char) (TC_NOT_EXE );
190 191 TM.telecommand_pkt_id[0] = TC->packetID[0];
191 192 TM.telecommand_pkt_id[1] = TC->packetID[1];
192 193 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
193 194 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
194 195 TM.tc_service = TC->serviceType; // type of the rejected TC
195 196 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
196 197 TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
197 198 TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
198 199
199 200 messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
200 201
201 202 // SEND DATA
202 203 status = rtems_message_queue_send( queue_id, &TM, messageSize);
203 204 if (status != RTEMS_SUCCESSFUL) {
204 205 PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n")
205 206 }
206 207
207 208 return status;
208 209 }
209 210
210 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
211 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
211 212 {
212 213 /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue.
213 214 *
214 215 * @param TC points to the TeleCommand packet that is being processed
215 216 * @param queue_id is the id of the queue which handles TM
216 217 *
217 218 * @return RTEMS directive status code:
218 219 * - RTEMS_SUCCESSFUL - message sent successfully
219 220 * - RTEMS_INVALID_ID - invalid queue id
220 221 * - RTEMS_INVALID_SIZE - invalid message size
221 222 * - RTEMS_INVALID_ADDRESS - buffer is NULL
222 223 * - RTEMS_UNSATISFIED - out of message buffers
223 224 * - RTEMS_TOO_MANY - queue s limit has been reached
224 225 *
225 226 */
226 227
227 228 rtems_status_code status;
228 229 Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM;
229 230 unsigned char messageSize;
230 231
231 232 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
232 233 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
233 234 TM.reserved = DEFAULT_RESERVED;
234 235 TM.userApplication = CCSDS_USER_APP;
235 236 // PACKET HEADER
236 237 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
237 238 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
238 239 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
239 240 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
240 241 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
241 242 // DATA FIELD HEADER
242 243 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
243 244 TM.serviceType = TM_TYPE_TC_EXE;
244 245 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
245 246 TM.destinationID = TC->sourceID; // default destination id
246 247 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
247 248 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
248 249 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
249 250 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
250 251 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
251 252 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
252 253 //
253 254 TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> 8);
254 255 TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL );
255 256 TM.telecommand_pkt_id[0] = TC->packetID[0];
256 257 TM.telecommand_pkt_id[1] = TC->packetID[1];
257 258 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
258 259 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
259 260 TM.tc_service = TC->serviceType; // type of the rejected TC
260 261 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
261 262
262 263 messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
263 264
264 265 // SEND DATA
265 266 status = rtems_message_queue_send( queue_id, &TM, messageSize);
266 267 if (status != RTEMS_SUCCESSFUL) {
267 268 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
268 269 }
269 270
270 271 return status;
271 272 }
272 273
273 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
274 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
274 275 {
275 276 /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue.
276 277 *
277 278 * @param TC points to the TeleCommand packet that is being processed
278 279 * @param queue_id is the id of the queue which handles TM
279 280 *
280 281 * @return RTEMS directive status code:
281 282 * - RTEMS_SUCCESSFUL - message sent successfully
282 283 * - RTEMS_INVALID_ID - invalid queue id
283 284 * - RTEMS_INVALID_SIZE - invalid message size
284 285 * - RTEMS_INVALID_ADDRESS - buffer is NULL
285 286 * - RTEMS_UNSATISFIED - out of message buffers
286 287 * - RTEMS_TOO_MANY - queue s limit has been reached
287 288 *
288 289 */
289 290
290 291 rtems_status_code status;
291 292 Packet_TM_LFR_TC_EXE_ERROR_t TM;
292 293 unsigned char messageSize;
293 294
294 295 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
295 296 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
296 297 TM.reserved = DEFAULT_RESERVED;
297 298 TM.userApplication = CCSDS_USER_APP;
298 299 // PACKET HEADER
299 300 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
300 301 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
301 302 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
302 303 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
303 304 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
304 305 // DATA FIELD HEADER
305 306 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
306 307 TM.serviceType = TM_TYPE_TC_EXE;
307 308 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
308 309 TM.destinationID = TC->sourceID; // default destination id
309 310 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
310 311 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
311 312 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
312 313 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
313 314 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
314 315 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
315 316 //
316 317 TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> 8);
317 318 TM.tc_failure_code[1] = (char) (FAIL_DETECTED );
318 319 TM.telecommand_pkt_id[0] = TC->packetID[0];
319 320 TM.telecommand_pkt_id[1] = TC->packetID[1];
320 321 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
321 322 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
322 323 TM.tc_service = TC->serviceType; // type of the rejected TC
323 324 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
324 325
325 326 messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
326 327
327 328 // SEND DATA
328 329 status = rtems_message_queue_send( queue_id, &TM, messageSize);
329 330 if (status != RTEMS_SUCCESSFUL) {
330 331 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
331 332 }
332 333
333 334 return status;
334 335 }
335 336
336 337 int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
337 338 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV,
338 unsigned char destinationID)
339 unsigned char destinationID, unsigned char *time)
339 340 {
340 341 /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue.
341 342 *
342 343 * @param TC points to the TeleCommand packet that is being processed
343 344 * @param queue_id is the id of the queue which handles TM
344 345 * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand
345 346 * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data
346 347 *
347 348 * @return RTEMS directive status code:
348 349 * - RTEMS_SUCCESSFUL - message sent successfully
349 350 * - RTEMS_INVALID_ID - invalid queue id
350 351 * - RTEMS_INVALID_SIZE - invalid message size
351 352 * - RTEMS_INVALID_ADDRESS - buffer is NULL
352 353 * - RTEMS_UNSATISFIED - out of message buffers
353 354 * - RTEMS_TOO_MANY - queue s limit has been reached
354 355 *
355 356 */
356 357
357 358 rtems_status_code status;
358 359 Packet_TM_LFR_TC_EXE_CORRUPTED_t TM;
359 360 unsigned char messageSize;
360 361 unsigned int packetLength;
361 362 unsigned char *packetDataField;
362 363
363 364 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter
364 365 packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
365 366
366 367 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
367 368 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
368 369 TM.reserved = DEFAULT_RESERVED;
369 370 TM.userApplication = CCSDS_USER_APP;
370 371 // PACKET HEADER
371 372 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
372 373 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
373 374 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
374 375 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
375 376 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
376 377 // DATA FIELD HEADER
377 378 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
378 379 TM.serviceType = TM_TYPE_TC_EXE;
379 380 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
380 381 TM.destinationID = destinationID;
381 382 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
382 383 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
383 384 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
384 385 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
385 386 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
386 387 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
387 388 //
388 389 TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> 8);
389 390 TM.tc_failure_code[1] = (unsigned char) (CORRUPTED );
390 391 TM.telecommand_pkt_id[0] = TC->packetID[0];
391 392 TM.telecommand_pkt_id[1] = TC->packetID[1];
392 393 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
393 394 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
394 395 TM.tc_service = TC->serviceType; // type of the rejected TC
395 396 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
396 397 TM.pkt_len_rcv_value[0] = TC->packetLength[0];
397 398 TM.pkt_len_rcv_value[1] = TC->packetLength[1];
398 399 TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
399 400 TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
400 401 TM.rcv_crc[0] = packetDataField[ packetLength - 1 ];
401 402 TM.rcv_crc[1] = packetDataField[ packetLength ];
402 403 TM.computed_crc[0] = computed_CRC[0];
403 404 TM.computed_crc[1] = computed_CRC[1];
404 405
405 406 messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
406 407
407 408 // SEND DATA
408 409 status = rtems_message_queue_send( queue_id, &TM, messageSize);
409 410 if (status != RTEMS_SUCCESSFUL) {
410 411 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
411 412 }
412 413
413 414 return status;
414 415 }
415 416
416 417 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id )
417 418 {
418 419 unsigned short sequence_cnt;
419 420 unsigned short segmentation_grouping_flag;
420 421 unsigned short new_packet_sequence_control;
421 422 unsigned char i;
422 423
423 424 switch (destination_id)
424 425 {
425 426 case SID_TC_GROUND:
426 427 i = GROUND;
427 428 break;
428 429 case SID_TC_MISSION_TIMELINE:
429 430 i = MISSION_TIMELINE;
430 431 break;
431 432 case SID_TC_TC_SEQUENCES:
432 433 i = TC_SEQUENCES;
433 434 break;
434 435 case SID_TC_RECOVERY_ACTION_CMD:
435 436 i = RECOVERY_ACTION_CMD;
436 437 break;
437 438 case SID_TC_BACKUP_MISSION_TIMELINE:
438 439 i = BACKUP_MISSION_TIMELINE;
439 440 break;
440 441 case SID_TC_DIRECT_CMD:
441 442 i = DIRECT_CMD;
442 443 break;
443 444 case SID_TC_SPARE_GRD_SRC1:
444 445 i = SPARE_GRD_SRC1;
445 446 break;
446 447 case SID_TC_SPARE_GRD_SRC2:
447 448 i = SPARE_GRD_SRC2;
448 449 break;
449 450 case SID_TC_OBCP:
450 451 i = OBCP;
451 452 break;
452 453 case SID_TC_SYSTEM_CONTROL:
453 454 i = SYSTEM_CONTROL;
454 455 break;
455 456 case SID_TC_AOCS:
456 457 i = AOCS;
457 458 break;
458 459 case SID_TC_RPW_INTERNAL:
459 460 i = RPW_INTERNAL;
460 461 break;
461 462 default:
462 463 i = UNKNOWN;
463 464 break;
464 465 }
465 466
466 467 if (i != UNKNOWN)
467 468 {
468 469 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
469 470 sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff;
470 471
471 472 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
472 473
473 474 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
474 475 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
475 476
476 477 // increment the sequence counter for the next packet
477 478 if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX)
478 479 {
479 480 sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1;
480 481 }
481 482 else
482 483 {
483 484 sequenceCounters_TC_EXE[ i ] = 0;
484 485 }
485 486 }
486 487 else
487 488 {
488 489 DEBUG_PRINTF1("in increment_seq_counter_destination_id *** ERR destination ID %d not known\n", destination_id)
489 490 }
490 491
491 492 }
General Comments 0
You need to be logged in to leave comments. Login now