@@ -1,339 +1,339 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <!DOCTYPE QtCreatorProject> |
|
3 |
<!-- Written by QtCreator 3.0.1, 2014-03- |
|
|
3 | <!-- Written by QtCreator 3.0.1, 2014-03-31T06:56:28. --> | |
|
4 | 4 | <qtcreator> |
|
5 | 5 | <data> |
|
6 | 6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
|
7 | 7 | <value type="int">1</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="QByteArray" 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="QByteArray" 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">UTF-8</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</value> |
|
55 | 55 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value> |
|
56 | 56 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e04e3924-0bd8-4708-be18-f1474e45608e}</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">0</value> |
|
60 | 60 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
61 | 61 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value> |
|
62 | 62 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
63 | 63 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
64 | 64 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
65 | 65 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
66 | 66 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
67 | 67 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
68 | 68 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
69 | 69 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value> |
|
70 | 70 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
71 | 71 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
72 | 72 | </valuemap> |
|
73 | 73 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
74 | 74 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
75 | 75 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
76 | 76 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
77 | 77 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
78 | 78 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
79 | 79 | <value type="QString">-w</value> |
|
80 | 80 | <value type="QString">-r</value> |
|
81 | 81 | </valuelist> |
|
82 | 82 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
83 | 83 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
84 | 84 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
85 | 85 | </valuemap> |
|
86 | 86 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
87 | 87 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
88 | 88 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
89 | 89 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
90 | 90 | </valuemap> |
|
91 | 91 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
92 | 92 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
93 | 93 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
94 | 94 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
95 | 95 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
96 | 96 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
97 | 97 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
98 | 98 | <value type="QString">-w</value> |
|
99 | 99 | <value type="QString">-r</value> |
|
100 | 100 | </valuelist> |
|
101 | 101 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
102 | 102 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
103 | 103 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
104 | 104 | </valuemap> |
|
105 | 105 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
106 | 106 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
107 | 107 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
108 | 108 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
109 | 109 | </valuemap> |
|
110 | 110 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
111 | 111 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
112 | 112 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
113 | 113 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|
114 | 114 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
115 | 115 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
116 | 116 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
117 | 117 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
118 | 118 | </valuemap> |
|
119 | 119 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value> |
|
120 | 120 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
121 | 121 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
122 | 122 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
123 | 123 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
124 | 124 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
125 | 125 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
126 | 126 | </valuemap> |
|
127 | 127 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
128 | 128 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|
129 | 129 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
130 | 130 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
131 | 131 | </valuemap> |
|
132 | 132 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
133 | 133 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
134 | 134 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
135 | 135 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
136 | 136 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
137 | 137 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
138 | 138 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
139 | 139 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
140 | 140 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
141 | 141 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
142 | 142 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
143 | 143 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
144 | 144 | <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|
145 | 145 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
146 | 146 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
147 | 147 | <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|
148 | 148 | <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|
149 | 149 | <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|
150 | 150 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
151 | 151 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
152 | 152 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
153 | 153 | <value type="int">0</value> |
|
154 | 154 | <value type="int">1</value> |
|
155 | 155 | <value type="int">2</value> |
|
156 | 156 | <value type="int">3</value> |
|
157 | 157 | <value type="int">4</value> |
|
158 | 158 | <value type="int">5</value> |
|
159 | 159 | <value type="int">6</value> |
|
160 | 160 | <value type="int">7</value> |
|
161 | 161 | <value type="int">8</value> |
|
162 | 162 | <value type="int">9</value> |
|
163 | 163 | <value type="int">10</value> |
|
164 | 164 | <value type="int">11</value> |
|
165 | 165 | <value type="int">12</value> |
|
166 | 166 | <value type="int">13</value> |
|
167 | 167 | <value type="int">14</value> |
|
168 | 168 | </valuelist> |
|
169 | 169 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
170 | 170 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
171 | 171 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value> |
|
172 | 172 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
173 | 173 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value> |
|
174 | 174 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
175 | 175 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value> |
|
176 | 176 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
177 | 177 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
178 | 178 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
179 | 179 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
180 | 180 | <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> |
|
181 | 181 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> |
|
182 | 182 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
183 | 183 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
184 | 184 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|
185 | 185 | </valuemap> |
|
186 | 186 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|
187 | 187 | </valuemap> |
|
188 | 188 | </data> |
|
189 | 189 | <data> |
|
190 | 190 | <variable>ProjectExplorer.Project.Target.1</variable> |
|
191 | 191 | <valuemap type="QVariantMap"> |
|
192 | 192 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
193 | 193 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
194 | 194 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value> |
|
195 | 195 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|
196 | 196 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|
197 | 197 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
|
198 | 198 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
199 | 199 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value> |
|
200 | 200 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
201 | 201 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
202 | 202 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
203 | 203 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
204 | 204 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
205 | 205 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
206 | 206 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
207 | 207 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value> |
|
208 | 208 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
209 | 209 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
210 | 210 | </valuemap> |
|
211 | 211 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
212 | 212 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
213 | 213 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
214 | 214 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
215 | 215 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
216 | 216 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
217 | 217 | <value type="QString">-w</value> |
|
218 | 218 | <value type="QString">-r</value> |
|
219 | 219 | </valuelist> |
|
220 | 220 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
221 | 221 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
222 | 222 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
223 | 223 | </valuemap> |
|
224 | 224 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
225 | 225 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
226 | 226 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
227 | 227 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
228 | 228 | </valuemap> |
|
229 | 229 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
230 | 230 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
231 | 231 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
232 | 232 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
233 | 233 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
234 | 234 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
235 | 235 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
236 | 236 | <value type="QString">-w</value> |
|
237 | 237 | <value type="QString">-r</value> |
|
238 | 238 | </valuelist> |
|
239 | 239 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
240 | 240 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
241 | 241 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
242 | 242 | </valuemap> |
|
243 | 243 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
244 | 244 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
245 | 245 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
246 | 246 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
247 | 247 | </valuemap> |
|
248 | 248 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
249 | 249 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
250 | 250 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
251 | 251 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|
252 | 252 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
253 | 253 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
254 | 254 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
255 | 255 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
256 | 256 | </valuemap> |
|
257 | 257 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value> |
|
258 | 258 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
259 | 259 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
260 | 260 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
261 | 261 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
262 | 262 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
263 | 263 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
264 | 264 | </valuemap> |
|
265 | 265 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
266 | 266 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|
267 | 267 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
268 | 268 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
269 | 269 | </valuemap> |
|
270 | 270 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
271 | 271 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
272 | 272 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
273 | 273 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
274 | 274 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
275 | 275 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
276 | 276 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
277 | 277 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
278 | 278 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
279 | 279 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
280 | 280 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
281 | 281 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
282 | 282 | <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|
283 | 283 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
284 | 284 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
285 | 285 | <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|
286 | 286 | <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|
287 | 287 | <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|
288 | 288 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
289 | 289 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
290 | 290 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
291 | 291 | <value type="int">0</value> |
|
292 | 292 | <value type="int">1</value> |
|
293 | 293 | <value type="int">2</value> |
|
294 | 294 | <value type="int">3</value> |
|
295 | 295 | <value type="int">4</value> |
|
296 | 296 | <value type="int">5</value> |
|
297 | 297 | <value type="int">6</value> |
|
298 | 298 | <value type="int">7</value> |
|
299 | 299 | <value type="int">8</value> |
|
300 | 300 | <value type="int">9</value> |
|
301 | 301 | <value type="int">10</value> |
|
302 | 302 | <value type="int">11</value> |
|
303 | 303 | <value type="int">12</value> |
|
304 | 304 | <value type="int">13</value> |
|
305 | 305 | <value type="int">14</value> |
|
306 | 306 | </valuelist> |
|
307 | 307 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
308 | 308 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
309 | 309 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value> |
|
310 | 310 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
311 | 311 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value> |
|
312 | 312 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
313 | 313 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value> |
|
314 | 314 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
315 | 315 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
316 | 316 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
317 | 317 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
318 | 318 | <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> |
|
319 | 319 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value> |
|
320 | 320 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
321 | 321 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
322 | 322 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|
323 | 323 | </valuemap> |
|
324 | 324 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|
325 | 325 | </valuemap> |
|
326 | 326 | </data> |
|
327 | 327 | <data> |
|
328 | 328 | <variable>ProjectExplorer.Project.TargetCount</variable> |
|
329 | 329 | <value type="int">2</value> |
|
330 | 330 | </data> |
|
331 | 331 | <data> |
|
332 | 332 | <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable> |
|
333 | 333 | <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value> |
|
334 | 334 | </data> |
|
335 | 335 | <data> |
|
336 | 336 | <variable>ProjectExplorer.Project.Updater.FileVersion</variable> |
|
337 | 337 | <value type="int">15</value> |
|
338 | 338 | </data> |
|
339 | 339 | </qtcreator> |
@@ -1,230 +1,225 | |||
|
1 | 1 | #ifndef FSW_PARAMS_H_INCLUDED |
|
2 | 2 | #define FSW_PARAMS_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include "grlib_regs.h" |
|
5 | 5 | #include "fsw_params_processing.h" |
|
6 | 6 | #include "fsw_params_nb_bytes.h" |
|
7 | 7 | #include "tm_byte_positions.h" |
|
8 | 8 | #include "ccsds_types.h" |
|
9 | 9 | |
|
10 | 10 | #define GRSPW_DEVICE_NAME "/dev/grspw0" |
|
11 | 11 | #define UART_DEVICE_NAME "/dev/console" |
|
12 | 12 | |
|
13 | 13 | typedef struct ring_node |
|
14 | 14 | { |
|
15 | 15 | struct ring_node *previous; |
|
16 | 16 | int buffer_address; |
|
17 | 17 | struct ring_node *next; |
|
18 | 18 | unsigned int status; |
|
19 | 19 | } ring_node; |
|
20 | 20 | |
|
21 | 21 | //************************ |
|
22 | 22 | // flight software version |
|
23 | 23 | // this parameters is handled by the Qt project options |
|
24 | 24 | |
|
25 | 25 | #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk |
|
26 | 26 | #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk |
|
27 | 27 | #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688 |
|
28 | 28 | #define TIME_OFFSET 2 |
|
29 | 29 | #define TIME_OFFSET_IN_BYTES 8 |
|
30 | 30 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 |
|
31 | 31 | #define NB_BYTES_SWF_BLK (2 * 6) |
|
32 | 32 | #define NB_WORDS_SWF_BLK 3 |
|
33 | 33 | #define NB_BYTES_CWF3_LIGHT_BLK 6 |
|
34 | 34 | #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 |
|
35 | 35 | #define NB_RING_NODES_F0 3 // AT LEAST 3 |
|
36 | 36 | #define NB_RING_NODES_F1 5 // AT LEAST 3 |
|
37 | 37 | #define NB_RING_NODES_F2 5 // AT LEAST 3 |
|
38 | 38 | |
|
39 | 39 | //********** |
|
40 | 40 | // LFR MODES |
|
41 | 41 | #define LFR_MODE_STANDBY 0 |
|
42 | 42 | #define LFR_MODE_NORMAL 1 |
|
43 | 43 | #define LFR_MODE_BURST 2 |
|
44 | 44 | #define LFR_MODE_SBM1 3 |
|
45 | 45 | #define LFR_MODE_SBM2 4 |
|
46 | 46 | |
|
47 | 47 | #define TDS_MODE_LFM 5 |
|
48 | 48 | #define TDS_MODE_STANDBY 0 |
|
49 | 49 | #define TDS_MODE_NORMAL 1 |
|
50 | 50 | #define TDS_MODE_BURST 2 |
|
51 | 51 | #define TDS_MODE_SBM1 3 |
|
52 | 52 | #define TDS_MODE_SBM2 4 |
|
53 | 53 | |
|
54 | 54 | #define THR_MODE_STANDBY 0 |
|
55 |
#define THR_MODE_NORMAL |
|
|
55 | #define THR_MODE_NORMAL 1 | |
|
56 | 56 | #define THR_MODE_BURST 2 |
|
57 | 57 | |
|
58 | 58 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 |
|
59 | 59 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 |
|
60 | 60 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 |
|
61 | 61 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 |
|
62 | 62 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 |
|
63 | 63 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 |
|
64 | 64 | #define RTEMS_EVENT_MODE_NORMAL_SWF_F0 RTEMS_EVENT_6 |
|
65 | 65 | #define RTEMS_EVENT_MODE_NORMAL_SWF_F1 RTEMS_EVENT_7 |
|
66 | 66 | #define RTEMS_EVENT_MODE_NORMAL_SWF_F2 RTEMS_EVENT_8 |
|
67 | 67 | |
|
68 | 68 | //**************************** |
|
69 | 69 | // LFR DEFAULT MODE PARAMETERS |
|
70 | 70 | // COMMON |
|
71 | 71 | #define DEFAULT_SY_LFR_COMMON0 0x00 |
|
72 | 72 | #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 |
|
73 | 73 | // NORM |
|
74 | 74 | #define SY_LFR_N_SWF_L 2048 // nb sample |
|
75 | 75 | #define SY_LFR_N_SWF_P 300 // sec |
|
76 | 76 | #define SY_LFR_N_ASM_P 3600 // sec |
|
77 | 77 | #define SY_LFR_N_BP_P0 4 // sec |
|
78 | 78 | #define SY_LFR_N_BP_P1 20 // sec |
|
79 | 79 | #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3 |
|
80 | 80 | #define MIN_DELTA_SNAPSHOT 16 // sec |
|
81 | 81 | // BURST |
|
82 | 82 | #define DEFAULT_SY_LFR_B_BP_P0 1 // sec |
|
83 | 83 | #define DEFAULT_SY_LFR_B_BP_P1 5 // sec |
|
84 | 84 | // SBM1 |
|
85 | 85 | #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec |
|
86 | 86 | #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec |
|
87 | 87 | // SBM2 |
|
88 | 88 | #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec |
|
89 | 89 | #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec |
|
90 | 90 | // ADDITIONAL PARAMETERS |
|
91 | 91 | #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms |
|
92 | 92 | #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s |
|
93 | 93 | // STATUS WORD |
|
94 | 94 | #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits |
|
95 | 95 | #define DEFAULT_STATUS_WORD_BYTE1 0x00 |
|
96 | 96 | // |
|
97 | 97 | #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s |
|
98 | 98 | #define SY_LFR_DPU_CONNECT_ATTEMPT 3 |
|
99 | 99 | //**************************** |
|
100 | 100 | |
|
101 | 101 | //***************************** |
|
102 | 102 | // APB REGISTERS BASE ADDRESSES |
|
103 | 103 | #define REGS_ADDR_APBUART 0x80000100 |
|
104 | 104 | #define REGS_ADDR_GPTIMER 0x80000300 |
|
105 | 105 | #define REGS_ADDR_GRSPW 0x80000500 |
|
106 | 106 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 |
|
107 | 107 | #define REGS_ADDR_GRGPIO 0x80000b00 |
|
108 | 108 | |
|
109 | #ifdef VHDL_DEV | |
|
110 | 109 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 |
|
111 | 110 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40 |
|
112 | #else | |
|
113 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 | |
|
114 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 | |
|
115 | #endif | |
|
116 | 111 | |
|
117 | 112 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff |
|
118 | 113 | #define APBUART_CTRL_REG_MASK_TE 0x00000002 |
|
119 | 114 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) |
|
120 | 115 | |
|
121 | 116 | //********** |
|
122 | 117 | // IRQ LINES |
|
123 | 118 | #define IRQ_SM_SIMULATOR 9 |
|
124 | 119 | #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
125 | 120 | #define IRQ_WAVEFORM_PICKER 14 |
|
126 | 121 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels |
|
127 | 122 | #define IRQ_SPECTRAL_MATRIX 6 |
|
128 | 123 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels |
|
129 | 124 | |
|
130 | 125 | //***** |
|
131 | 126 | // TIME |
|
132 | 127 | #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms |
|
133 | 128 | #define TIMER_SM_SIMULATOR 1 |
|
134 | 129 | #define HK_PERIOD 100 // 100 * 10ms => 1s |
|
135 | 130 | #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000 |
|
136 | 131 | #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s |
|
137 | 132 | |
|
138 | 133 | //********** |
|
139 | 134 | // LPP CODES |
|
140 | 135 | #define LFR_SUCCESSFUL 0 |
|
141 | 136 | #define LFR_DEFAULT 1 |
|
142 | 137 | |
|
143 | 138 | //****** |
|
144 | 139 | // RTEMS |
|
145 | 140 | #define TASKID_RECV 1 |
|
146 | 141 | #define TASKID_ACTN 2 |
|
147 | 142 | #define TASKID_SPIQ 3 |
|
148 | 143 | #define TASKID_SMIQ 4 |
|
149 | 144 | #define TASKID_STAT 5 |
|
150 | 145 | #define TASKID_AVF0 6 |
|
151 | 146 | #define TASKID_SWBD 7 |
|
152 | 147 | #define TASKID_WFRM 8 |
|
153 | 148 | #define TASKID_DUMB 9 |
|
154 | 149 | #define TASKID_HOUS 10 |
|
155 | 150 | #define TASKID_MATR 11 |
|
156 | 151 | #define TASKID_CWF3 12 |
|
157 | 152 | #define TASKID_CWF2 13 |
|
158 | 153 | #define TASKID_CWF1 14 |
|
159 | 154 | #define TASKID_SEND 15 |
|
160 | 155 | #define TASKID_WTDG 16 |
|
161 | 156 | |
|
162 | 157 | #define TASK_PRIORITY_SPIQ 5 |
|
163 | 158 | #define TASK_PRIORITY_SMIQ 10 |
|
164 | 159 | #define TASK_PRIORITY_WTDG 20 |
|
165 | 160 | #define TASK_PRIORITY_HOUS 30 |
|
166 | 161 | #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together |
|
167 | 162 | #define TASK_PRIORITY_CWF2 35 // |
|
168 | 163 | #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it |
|
169 | 164 | #define TASK_PRIORITY_WFRM 40 |
|
170 | 165 | #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1 |
|
171 | 166 | #define TASK_PRIORITY_SEND 45 |
|
172 | 167 | #define TASK_PRIORITY_RECV 50 |
|
173 | 168 | #define TASK_PRIORITY_ACTN 50 |
|
174 | 169 | #define TASK_PRIORITY_AVF0 60 |
|
175 | 170 | #define TASK_PRIORITY_BPF0 60 |
|
176 | 171 | #define TASK_PRIORITY_MATR 100 |
|
177 | 172 | #define TASK_PRIORITY_STAT 200 |
|
178 | 173 | #define TASK_PRIORITY_DUMB 200 |
|
179 | 174 | |
|
180 | 175 | #define ACTION_MSG_QUEUE_COUNT 10 |
|
181 | 176 | #define ACTION_MSG_PKTS_COUNT 50 |
|
182 | 177 | #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) |
|
183 | 178 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options |
|
184 | 179 | |
|
185 | 180 | #define QUEUE_RECV 0 |
|
186 | 181 | #define QUEUE_SEND 1 |
|
187 | 182 | |
|
188 | 183 | //******* |
|
189 | 184 | // MACROS |
|
190 | 185 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
191 | 186 | #define PRINTF(x) printf(x); |
|
192 | 187 | #define PRINTF1(x,y) printf(x,y); |
|
193 | 188 | #define PRINTF2(x,y,z) printf(x,y,z); |
|
194 | 189 | #else |
|
195 | 190 | #define PRINTF(x) ; |
|
196 | 191 | #define PRINTF1(x,y) ; |
|
197 | 192 | #define PRINTF2(x,y,z) ; |
|
198 | 193 | #endif |
|
199 | 194 | |
|
200 | 195 | #ifdef BOOT_MESSAGES |
|
201 | 196 | #define BOOT_PRINTF(x) printf(x); |
|
202 | 197 | #define BOOT_PRINTF1(x,y) printf(x,y); |
|
203 | 198 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); |
|
204 | 199 | #else |
|
205 | 200 | #define BOOT_PRINTF(x) ; |
|
206 | 201 | #define BOOT_PRINTF1(x,y) ; |
|
207 | 202 | #define BOOT_PRINTF2(x,y,z) ; |
|
208 | 203 | #endif |
|
209 | 204 | |
|
210 | 205 | #ifdef DEBUG_MESSAGES |
|
211 | 206 | #define DEBUG_PRINTF(x) printf(x); |
|
212 | 207 | #define DEBUG_PRINTF1(x,y) printf(x,y); |
|
213 | 208 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); |
|
214 | 209 | #else |
|
215 | 210 | #define DEBUG_PRINTF(x) ; |
|
216 | 211 | #define DEBUG_PRINTF1(x,y) ; |
|
217 | 212 | #define DEBUG_PRINTF2(x,y,z) ; |
|
218 | 213 | #endif |
|
219 | 214 | |
|
220 | 215 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period |
|
221 | 216 | |
|
222 | 217 | struct param_local_str{ |
|
223 | 218 | unsigned int local_sbm1_nb_cwf_sent; |
|
224 | 219 | unsigned int local_sbm1_nb_cwf_max; |
|
225 | 220 | unsigned int local_sbm2_nb_cwf_sent; |
|
226 | 221 | unsigned int local_sbm2_nb_cwf_max; |
|
227 | 222 | unsigned int local_nb_interrupt_f0_MAX; |
|
228 | 223 | }; |
|
229 | 224 | |
|
230 | 225 | #endif // FSW_PARAMS_H_INCLUDED |
@@ -1,29 +1,28 | |||
|
1 | 1 | #ifndef TM_BYTE_POSITIONS_H |
|
2 | 2 | #define TM_BYTE_POSITIONS_H |
|
3 | 3 | |
|
4 | #define BYTE_POS_CP_LFR_MODE 11 | |
|
5 | ||
|
6 | 4 | // TC_LFR_LOAD_COMMON_PAR |
|
7 | 5 | |
|
8 | 6 | // TC_LFR_LOAD_NORMAL_PAR |
|
9 | 7 | #define BYTE_POS_SY_LFR_N_SWF_L 0 |
|
10 | 8 | #define BYTE_POS_SY_LFR_N_SWF_P 2 |
|
11 | 9 | #define BYTE_POS_SY_LFR_N_ASM_P 4 |
|
12 | 10 | #define BYTE_POS_SY_LFR_N_BP_P0 6 |
|
13 | 11 | #define BYTE_POS_SY_LFR_N_BP_P1 7 |
|
14 | 12 | #define BYTE_POS_SY_LFR_N_CWF_LONG_F3 8 |
|
15 | 13 | |
|
16 | 14 | // TC_LFR_LOAD_BURST_PAR |
|
17 | 15 | |
|
18 | 16 | // TC_LFR_LOAD_SBM1_PAR |
|
19 | 17 | |
|
20 | 18 | // TC_LFR_LOAD_SBM2_PAR |
|
21 | 19 | |
|
22 | 20 | // TC_LFR_UPDATE_INFO |
|
23 |
#define BYTE_POS_ |
|
|
24 |
#define BYTE_POS_ |
|
|
21 | #define BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 34 | |
|
22 | #define BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 35 | |
|
25 | 23 | |
|
26 | 24 | // TC_LFR_ENTER_MODE |
|
27 |
#define BYTE_POS_CP_ |
|
|
25 | #define BYTE_POS_CP_MODE_LFR_SET 11 | |
|
26 | #define BYTE_POS_CP_LFR_ENTER_MODE_TIME 12 | |
|
28 | 27 | |
|
29 | 28 | #endif // TM_BYTE_POSITIONS_H |
@@ -1,25 +1,25 | |||
|
1 | 1 | #ifndef TC_ACCEPTANCE_H_INCLUDED |
|
2 | 2 | #define TC_ACCEPTANCE_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | //#include "tm_lfr_tc_exe.h" |
|
5 | 5 | #include "fsw_params.h" |
|
6 | 6 | |
|
7 | 7 | //********************** |
|
8 | 8 | // GENERAL USE FUNCTIONS |
|
9 | 9 | unsigned int Crc_opt( unsigned char D, unsigned int Chk); |
|
10 | 10 | void initLookUpTableForCRC( void ); |
|
11 | 11 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData); |
|
12 | 12 | |
|
13 | 13 | //********************* |
|
14 | 14 | // ACCEPTANCE FUNCTIONS |
|
15 |
int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int |
|
|
15 | int tc_parser( ccsdsTelecommandPacket_t * TCPacket, unsigned int estimatedPacketLength, unsigned char *computed_CRC ); | |
|
16 | 16 | int tc_check_type( unsigned char packetType ); |
|
17 | 17 | int tc_check_type_subtype( unsigned char packetType, unsigned char packetSubType ); |
|
18 | 18 | int tc_check_sid( unsigned char sid ); |
|
19 | 19 | int tc_check_length( unsigned char packetType, unsigned int length ); |
|
20 | 20 | int tc_check_crc(ccsdsTelecommandPacket_t * TCPacket, unsigned int length , unsigned char *computed_CRC); |
|
21 | 21 | |
|
22 | 22 | #endif // TC_ACCEPTANCE_H_INCLUDED |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 |
@@ -1,26 +1,26 | |||
|
1 | 1 | #ifndef TM_LFR_TC_EXE_H_INCLUDED |
|
2 | 2 | #define TM_LFR_TC_EXE_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <stdio.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "fsw_spacewire.h" |
|
9 | 9 | |
|
10 | 10 | extern unsigned short sequenceCounters_TC_EXE[]; |
|
11 | 11 | |
|
12 | 12 | int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
13 | 13 | int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, |
|
14 | 14 | unsigned char byte_position, unsigned char rcv_value ); |
|
15 | 15 | int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
16 | 16 | int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
17 |
int send_tm_lfr_tc_exe_error( |
|
|
17 | int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
18 | 18 | int send_tm_lfr_tc_exe_corrupted( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, |
|
19 | 19 | unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, unsigned char destinationID ); |
|
20 | 20 | |
|
21 | 21 | void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id ); |
|
22 | 22 | |
|
23 | 23 | #endif // TM_LFR_TC_EXE_H_INCLUDED |
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 |
@@ -1,644 +1,644 | |||
|
1 | 1 | /** This is the RTEMS initialization module. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * This module contains two very different information: |
|
7 | 7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
8 | 8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
9 | 9 | * |
|
10 | 10 | */ |
|
11 | 11 | |
|
12 | 12 | //************************* |
|
13 | 13 | // GPL reminder to be added |
|
14 | 14 | //************************* |
|
15 | 15 | |
|
16 | 16 | #include <rtems.h> |
|
17 | 17 | |
|
18 | 18 | /* configuration information */ |
|
19 | 19 | |
|
20 | 20 | #define CONFIGURE_INIT |
|
21 | 21 | |
|
22 | 22 | #include <bsp.h> /* for device driver prototypes */ |
|
23 | 23 | |
|
24 | 24 | /* configuration information */ |
|
25 | 25 | |
|
26 | 26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
27 | 27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
28 | 28 | |
|
29 | 29 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
30 | 30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
31 | 31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
32 | 32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
33 | 33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
34 | 34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
35 | 35 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
36 | 36 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
37 | 37 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
38 | 38 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2 |
|
39 | 39 | #ifdef PRINT_STACK_REPORT |
|
40 | 40 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
41 | 41 | #endif |
|
42 | 42 | |
|
43 | 43 | #include <rtems/confdefs.h> |
|
44 | 44 | |
|
45 | 45 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
46 | 46 | #ifdef RTEMS_DRVMGR_STARTUP |
|
47 | 47 | #ifdef LEON3 |
|
48 | 48 | /* Add Timer and UART Driver */ |
|
49 | 49 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
50 | 50 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
51 | 51 | #endif |
|
52 | 52 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
53 | 53 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
54 | 54 | #endif |
|
55 | 55 | #endif |
|
56 | 56 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
57 | 57 | #include <drvmgr/drvmgr_confdefs.h> |
|
58 | 58 | #endif |
|
59 | 59 | |
|
60 | 60 | #include "fsw_init.h" |
|
61 | 61 | #include "fsw_config.c" |
|
62 | 62 | |
|
63 | 63 | rtems_task Init( rtems_task_argument ignored ) |
|
64 | 64 | { |
|
65 | 65 | /** This is the RTEMS INIT taks, it the first task launched by the system. |
|
66 | 66 | * |
|
67 | 67 | * @param unused is the starting argument of the RTEMS task |
|
68 | 68 | * |
|
69 | 69 | * The INIT task create and run all other RTEMS tasks. |
|
70 | 70 | * |
|
71 | 71 | */ |
|
72 | 72 | |
|
73 | 73 | reset_local_time(); |
|
74 | 74 | |
|
75 | 75 | rtems_status_code status; |
|
76 | 76 | rtems_status_code status_spw; |
|
77 | 77 | rtems_isr_entry old_isr_handler; |
|
78 | 78 | |
|
79 | 79 | // UART settings |
|
80 | 80 | send_console_outputs_on_apbuart_port(); |
|
81 | 81 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
82 | 82 | enable_apbuart_transmitter(); |
|
83 | 83 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
84 | 84 | |
|
85 | 85 | PRINTF("\n\n\n\n\n") |
|
86 | 86 | PRINTF("*************************\n") |
|
87 | 87 | PRINTF("** LFR Flight Software **\n") |
|
88 | 88 | PRINTF1("** %d.", SW_VERSION_N1) |
|
89 | 89 | PRINTF1("%d.", SW_VERSION_N2) |
|
90 | 90 | PRINTF1("%d.", SW_VERSION_N3) |
|
91 | 91 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
92 | 92 | PRINTF("*************************\n") |
|
93 | 93 | PRINTF("\n\n") |
|
94 | 94 | |
|
95 | 95 | init_parameter_dump(); |
|
96 | 96 | init_local_mode_parameters(); |
|
97 | 97 | init_housekeeping_parameters(); |
|
98 | 98 | |
|
99 | 99 | init_waveform_rings(); // initialize the waveform rings |
|
100 | 100 | init_sm_rings(); // initialize spectral matrices rings |
|
101 | 101 | |
|
102 | 102 | reset_wfp_burst_enable(); |
|
103 | 103 | reset_wfp_status(); |
|
104 | 104 | set_wfp_data_shaping(); |
|
105 | 105 | |
|
106 | 106 | updateLFRCurrentMode(); |
|
107 | 107 | |
|
108 | 108 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
109 | 109 | |
|
110 | 110 | create_names(); // create all names |
|
111 | 111 | |
|
112 | 112 | status = create_message_queues(); // create message queues |
|
113 | 113 | if (status != RTEMS_SUCCESSFUL) |
|
114 | 114 | { |
|
115 | 115 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
116 | 116 | } |
|
117 | 117 | |
|
118 | 118 | status = create_all_tasks(); // create all tasks |
|
119 | 119 | if (status != RTEMS_SUCCESSFUL) |
|
120 | 120 | { |
|
121 | 121 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status) |
|
122 | 122 | } |
|
123 | 123 | |
|
124 | 124 | // ************************** |
|
125 | 125 | // <SPACEWIRE INITIALIZATION> |
|
126 | 126 | grspw_timecode_callback = &timecode_irq_handler; |
|
127 | 127 | |
|
128 | 128 | status_spw = spacewire_open_link(); // (1) open the link |
|
129 | 129 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
130 | 130 | { |
|
131 | 131 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
135 | 135 | { |
|
136 | 136 | status_spw = spacewire_configure_link( fdSPW ); |
|
137 | 137 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
138 | 138 | { |
|
139 | 139 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
140 | 140 | } |
|
141 | 141 | } |
|
142 | 142 | |
|
143 | 143 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
144 | 144 | { |
|
145 | 145 | status_spw = spacewire_start_link( fdSPW ); |
|
146 | 146 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
147 | 147 | { |
|
148 | 148 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
149 | 149 | } |
|
150 | 150 | } |
|
151 | 151 | // </SPACEWIRE INITIALIZATION> |
|
152 | 152 | // *************************** |
|
153 | 153 | |
|
154 | 154 | status = start_all_tasks(); // start all tasks |
|
155 | 155 | if (status != RTEMS_SUCCESSFUL) |
|
156 | 156 | { |
|
157 | 157 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
158 | 158 | } |
|
159 | 159 | |
|
160 | 160 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
161 | 161 | status = start_recv_send_tasks(); |
|
162 | 162 | if ( status != RTEMS_SUCCESSFUL ) |
|
163 | 163 | { |
|
164 | 164 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
165 | 165 | } |
|
166 | 166 | |
|
167 | 167 | // suspend science tasks, they will be restarted later depending on the mode |
|
168 | 168 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
169 | 169 | if (status != RTEMS_SUCCESSFUL) |
|
170 | 170 | { |
|
171 | 171 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
172 | 172 | } |
|
173 | 173 | |
|
174 | 174 | //****************************** |
|
175 | 175 | // <SPECTRAL MATRICES SIMULATOR> |
|
176 | 176 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); |
|
177 | 177 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
178 | 178 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); |
|
179 | 179 | // </SPECTRAL MATRICES SIMULATOR> |
|
180 | 180 | //******************************* |
|
181 | 181 | |
|
182 | 182 | // configure IRQ handling for the waveform picker unit |
|
183 | 183 | status = rtems_interrupt_catch( waveforms_isr, |
|
184 | 184 | IRQ_SPARC_WAVEFORM_PICKER, |
|
185 | 185 | &old_isr_handler) ; |
|
186 | 186 | // configure IRQ handling for the spectral matrices unit |
|
187 | 187 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
188 | 188 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
189 | 189 | &old_isr_handler) ; |
|
190 | 190 | |
|
191 | 191 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
192 | 192 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
193 | 193 | { |
|
194 | 194 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
195 | 195 | if ( status != RTEMS_SUCCESSFUL ) { |
|
196 | 196 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
197 | 197 | } |
|
198 | 198 | } |
|
199 | 199 | |
|
200 | 200 | BOOT_PRINTF("delete INIT\n") |
|
201 | 201 | |
|
202 | 202 | send_dumb_hk(); |
|
203 | 203 | |
|
204 | 204 | status = rtems_task_delete(RTEMS_SELF); |
|
205 | 205 | |
|
206 | 206 | } |
|
207 | 207 | |
|
208 | 208 | void init_local_mode_parameters( void ) |
|
209 | 209 | { |
|
210 | 210 | /** This function initialize the param_local global variable with default values. |
|
211 | 211 | * |
|
212 | 212 | */ |
|
213 | 213 | |
|
214 | 214 | unsigned int i; |
|
215 | 215 | |
|
216 | 216 | // LOCAL PARAMETERS |
|
217 | 217 | set_local_nb_interrupt_f0_MAX(); |
|
218 | 218 | |
|
219 | 219 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
220 | 220 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
221 | 221 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
222 | 222 | |
|
223 | 223 | // init sequence counters |
|
224 | 224 | |
|
225 | 225 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
226 | 226 | { |
|
227 | 227 | sequenceCounters_TC_EXE[i] = 0x00; |
|
228 | 228 | } |
|
229 | 229 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
230 | 230 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
231 | 231 | } |
|
232 | 232 | |
|
233 | 233 | void reset_local_time( void ) |
|
234 | 234 | { |
|
235 | ||
|
235 | time_management_regs->coarse_time_load = 0x80000000; | |
|
236 | 236 | } |
|
237 | 237 | |
|
238 | 238 | void create_names( void ) // create all names for tasks and queues |
|
239 | 239 | { |
|
240 | 240 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
241 | 241 | * |
|
242 | 242 | * @return RTEMS directive status codes: |
|
243 | 243 | * - RTEMS_SUCCESSFUL - successful completion |
|
244 | 244 | * |
|
245 | 245 | */ |
|
246 | 246 | |
|
247 | 247 | // task names |
|
248 | 248 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
249 | 249 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
250 | 250 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
251 | 251 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); |
|
252 | 252 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
253 | 253 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
254 | 254 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
255 | 255 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
256 | 256 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
257 | 257 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
258 | 258 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); |
|
259 | 259 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
260 | 260 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
261 | 261 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
262 | 262 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
263 | 263 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
264 | 264 | |
|
265 | 265 | // rate monotonic period names |
|
266 | 266 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
267 | 267 | |
|
268 | 268 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
269 | 269 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
270 | 270 | } |
|
271 | 271 | |
|
272 | 272 | int create_all_tasks( void ) // create all tasks which run in the software |
|
273 | 273 | { |
|
274 | 274 | /** This function creates all RTEMS tasks used in the software. |
|
275 | 275 | * |
|
276 | 276 | * @return RTEMS directive status codes: |
|
277 | 277 | * - RTEMS_SUCCESSFUL - task created successfully |
|
278 | 278 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
279 | 279 | * - RTEMS_INVALID_NAME - invalid task name |
|
280 | 280 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
281 | 281 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
282 | 282 | * - RTEMS_TOO_MANY - too many tasks created |
|
283 | 283 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
284 | 284 | * - RTEMS_TOO_MANY - too many global objects |
|
285 | 285 | * |
|
286 | 286 | */ |
|
287 | 287 | |
|
288 | 288 | rtems_status_code status; |
|
289 | 289 | |
|
290 | 290 | //********** |
|
291 | 291 | // SPACEWIRE |
|
292 | 292 | // RECV |
|
293 | 293 | status = rtems_task_create( |
|
294 | 294 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
295 | 295 | RTEMS_DEFAULT_MODES, |
|
296 | 296 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
297 | 297 | ); |
|
298 | 298 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
299 | 299 | { |
|
300 | 300 | status = rtems_task_create( |
|
301 | 301 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, |
|
302 | 302 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
303 | 303 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] |
|
304 | 304 | ); |
|
305 | 305 | } |
|
306 | 306 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
307 | 307 | { |
|
308 | 308 | status = rtems_task_create( |
|
309 | 309 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
310 | 310 | RTEMS_DEFAULT_MODES, |
|
311 | 311 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
312 | 312 | ); |
|
313 | 313 | } |
|
314 | 314 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
315 | 315 | { |
|
316 | 316 | status = rtems_task_create( |
|
317 | 317 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
318 | 318 | RTEMS_DEFAULT_MODES, |
|
319 | 319 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
320 | 320 | ); |
|
321 | 321 | } |
|
322 | 322 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
323 | 323 | { |
|
324 | 324 | status = rtems_task_create( |
|
325 | 325 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
326 | 326 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
327 | 327 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
328 | 328 | ); |
|
329 | 329 | } |
|
330 | 330 | |
|
331 | 331 | //****************** |
|
332 | 332 | // SPECTRAL MATRICES |
|
333 | 333 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
334 | 334 | { |
|
335 | 335 | status = rtems_task_create( |
|
336 | 336 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
337 | 337 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
338 | 338 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] |
|
339 | 339 | ); |
|
340 | 340 | } |
|
341 | 341 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
342 | 342 | { |
|
343 | 343 | status = rtems_task_create( |
|
344 | 344 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
345 | 345 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
346 | 346 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
347 | 347 | ); |
|
348 | 348 | } |
|
349 | 349 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
350 | 350 | { |
|
351 | 351 | status = rtems_task_create( |
|
352 | 352 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, |
|
353 | 353 | RTEMS_DEFAULT_MODES, |
|
354 | 354 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] |
|
355 | 355 | ); |
|
356 | 356 | } |
|
357 | 357 | |
|
358 | 358 | //**************** |
|
359 | 359 | // WAVEFORM PICKER |
|
360 | 360 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
361 | 361 | { |
|
362 | 362 | status = rtems_task_create( |
|
363 | 363 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
364 | 364 | RTEMS_DEFAULT_MODES, |
|
365 | 365 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
366 | 366 | ); |
|
367 | 367 | } |
|
368 | 368 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
369 | 369 | { |
|
370 | 370 | status = rtems_task_create( |
|
371 | 371 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
372 | 372 | RTEMS_DEFAULT_MODES, |
|
373 | 373 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
374 | 374 | ); |
|
375 | 375 | } |
|
376 | 376 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
377 | 377 | { |
|
378 | 378 | status = rtems_task_create( |
|
379 | 379 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
380 | 380 | RTEMS_DEFAULT_MODES, |
|
381 | 381 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
382 | 382 | ); |
|
383 | 383 | } |
|
384 | 384 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
385 | 385 | { |
|
386 | 386 | status = rtems_task_create( |
|
387 | 387 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
388 | 388 | RTEMS_DEFAULT_MODES, |
|
389 | 389 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
390 | 390 | ); |
|
391 | 391 | } |
|
392 | 392 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
393 | 393 | { |
|
394 | 394 | status = rtems_task_create( |
|
395 | 395 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
396 | 396 | RTEMS_DEFAULT_MODES, |
|
397 | 397 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
398 | 398 | ); |
|
399 | 399 | } |
|
400 | 400 | |
|
401 | 401 | //***** |
|
402 | 402 | // MISC |
|
403 | 403 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
404 | 404 | { |
|
405 | 405 | status = rtems_task_create( |
|
406 | 406 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
407 | 407 | RTEMS_DEFAULT_MODES, |
|
408 | 408 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
409 | 409 | ); |
|
410 | 410 | } |
|
411 | 411 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
412 | 412 | { |
|
413 | 413 | status = rtems_task_create( |
|
414 | 414 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
415 | 415 | RTEMS_DEFAULT_MODES, |
|
416 | 416 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
417 | 417 | ); |
|
418 | 418 | } |
|
419 | 419 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
420 | 420 | { |
|
421 | 421 | status = rtems_task_create( |
|
422 | 422 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
423 | 423 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
424 | 424 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] |
|
425 | 425 | ); |
|
426 | 426 | } |
|
427 | 427 | |
|
428 | 428 | return status; |
|
429 | 429 | } |
|
430 | 430 | |
|
431 | 431 | int start_recv_send_tasks( void ) |
|
432 | 432 | { |
|
433 | 433 | rtems_status_code status; |
|
434 | 434 | |
|
435 | 435 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
436 | 436 | if (status!=RTEMS_SUCCESSFUL) { |
|
437 | 437 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
438 | 438 | } |
|
439 | 439 | |
|
440 | 440 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
441 | 441 | { |
|
442 | 442 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
443 | 443 | if (status!=RTEMS_SUCCESSFUL) { |
|
444 | 444 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
445 | 445 | } |
|
446 | 446 | } |
|
447 | 447 | |
|
448 | 448 | return status; |
|
449 | 449 | } |
|
450 | 450 | |
|
451 | 451 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
452 | 452 | { |
|
453 | 453 | /** This function starts all RTEMS tasks used in the software. |
|
454 | 454 | * |
|
455 | 455 | * @return RTEMS directive status codes: |
|
456 | 456 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
457 | 457 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
458 | 458 | * - RTEMS_INVALID_ID - invalid task id |
|
459 | 459 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
460 | 460 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
461 | 461 | * |
|
462 | 462 | */ |
|
463 | 463 | // starts all the tasks fot eh flight software |
|
464 | 464 | |
|
465 | 465 | rtems_status_code status; |
|
466 | 466 | |
|
467 | 467 | //********** |
|
468 | 468 | // SPACEWIRE |
|
469 | 469 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
470 | 470 | if (status!=RTEMS_SUCCESSFUL) { |
|
471 | 471 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
472 | 472 | } |
|
473 | 473 | |
|
474 | 474 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
475 | 475 | { |
|
476 | 476 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
477 | 477 | if (status!=RTEMS_SUCCESSFUL) { |
|
478 | 478 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
479 | 479 | } |
|
480 | 480 | } |
|
481 | 481 | |
|
482 | 482 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
483 | 483 | { |
|
484 | 484 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
485 | 485 | if (status!=RTEMS_SUCCESSFUL) { |
|
486 | 486 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
487 | 487 | } |
|
488 | 488 | } |
|
489 | 489 | |
|
490 | 490 | //****************** |
|
491 | 491 | // SPECTRAL MATRICES |
|
492 | 492 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
493 | 493 | { |
|
494 | 494 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); |
|
495 | 495 | if (status!=RTEMS_SUCCESSFUL) { |
|
496 | 496 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") |
|
497 | 497 | } |
|
498 | 498 | } |
|
499 | 499 | |
|
500 | 500 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
501 | 501 | { |
|
502 | 502 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); |
|
503 | 503 | if (status!=RTEMS_SUCCESSFUL) { |
|
504 | 504 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
505 | 505 | } |
|
506 | 506 | } |
|
507 | 507 | |
|
508 | 508 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
509 | 509 | { |
|
510 | 510 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); |
|
511 | 511 | if (status!=RTEMS_SUCCESSFUL) { |
|
512 | 512 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") |
|
513 | 513 | } |
|
514 | 514 | } |
|
515 | 515 | |
|
516 | 516 | //**************** |
|
517 | 517 | // WAVEFORM PICKER |
|
518 | 518 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
519 | 519 | { |
|
520 | 520 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
521 | 521 | if (status!=RTEMS_SUCCESSFUL) { |
|
522 | 522 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
523 | 523 | } |
|
524 | 524 | } |
|
525 | 525 | |
|
526 | 526 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
527 | 527 | { |
|
528 | 528 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
529 | 529 | if (status!=RTEMS_SUCCESSFUL) { |
|
530 | 530 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
531 | 531 | } |
|
532 | 532 | } |
|
533 | 533 | |
|
534 | 534 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
535 | 535 | { |
|
536 | 536 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
537 | 537 | if (status!=RTEMS_SUCCESSFUL) { |
|
538 | 538 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
539 | 539 | } |
|
540 | 540 | } |
|
541 | 541 | |
|
542 | 542 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
543 | 543 | { |
|
544 | 544 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
545 | 545 | if (status!=RTEMS_SUCCESSFUL) { |
|
546 | 546 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
547 | 547 | } |
|
548 | 548 | } |
|
549 | 549 | |
|
550 | 550 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
551 | 551 | { |
|
552 | 552 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
553 | 553 | if (status!=RTEMS_SUCCESSFUL) { |
|
554 | 554 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
555 | 555 | } |
|
556 | 556 | } |
|
557 | 557 | |
|
558 | 558 | //***** |
|
559 | 559 | // MISC |
|
560 | 560 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
561 | 561 | { |
|
562 | 562 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
563 | 563 | if (status!=RTEMS_SUCCESSFUL) { |
|
564 | 564 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
565 | 565 | } |
|
566 | 566 | } |
|
567 | 567 | |
|
568 | 568 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
569 | 569 | { |
|
570 | 570 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
571 | 571 | if (status!=RTEMS_SUCCESSFUL) { |
|
572 | 572 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
573 | 573 | } |
|
574 | 574 | } |
|
575 | 575 | |
|
576 | 576 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
577 | 577 | { |
|
578 | 578 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
579 | 579 | if (status!=RTEMS_SUCCESSFUL) { |
|
580 | 580 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") |
|
581 | 581 | } |
|
582 | 582 | } |
|
583 | 583 | |
|
584 | 584 | return status; |
|
585 | 585 | } |
|
586 | 586 | |
|
587 | 587 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
588 | 588 | { |
|
589 | 589 | rtems_status_code status_recv; |
|
590 | 590 | rtems_status_code status_send; |
|
591 | 591 | rtems_status_code ret; |
|
592 | 592 | rtems_id queue_id; |
|
593 | 593 | |
|
594 | 594 | // create the queue for handling valid TCs |
|
595 | 595 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
596 | 596 | ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, |
|
597 | 597 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
598 | 598 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
599 | 599 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
600 | 600 | } |
|
601 | 601 | |
|
602 | 602 | // create the queue for handling TM packet sending |
|
603 | 603 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
604 | 604 | ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE, |
|
605 | 605 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
606 | 606 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
607 | 607 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
608 | 608 | } |
|
609 | 609 | |
|
610 | 610 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
611 | 611 | { |
|
612 | 612 | ret = status_recv; |
|
613 | 613 | } |
|
614 | 614 | else |
|
615 | 615 | { |
|
616 | 616 | ret = status_send; |
|
617 | 617 | } |
|
618 | 618 | |
|
619 | 619 | return ret; |
|
620 | 620 | } |
|
621 | 621 | |
|
622 | 622 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
623 | 623 | { |
|
624 | 624 | rtems_status_code status; |
|
625 | 625 | rtems_name queue_name; |
|
626 | 626 | |
|
627 | 627 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
628 | 628 | |
|
629 | 629 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
630 | 630 | |
|
631 | 631 | return status; |
|
632 | 632 | } |
|
633 | 633 | |
|
634 | 634 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
635 | 635 | { |
|
636 | 636 | rtems_status_code status; |
|
637 | 637 | rtems_name queue_name; |
|
638 | 638 | |
|
639 | 639 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
640 | 640 | |
|
641 | 641 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
642 | 642 | |
|
643 | 643 | return status; |
|
644 | 644 | } |
@@ -1,610 +1,610 | |||
|
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 | rtems_name semq_name; |
|
17 | 17 | rtems_id semq_id; |
|
18 | 18 | |
|
19 | 19 | //*********** |
|
20 | 20 | // RTEMS TASK |
|
21 | 21 | rtems_task spiq_task(rtems_task_argument unused) |
|
22 | 22 | { |
|
23 | 23 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
24 | 24 | * |
|
25 | 25 | * @param unused is the starting argument of the RTEMS task |
|
26 | 26 | * |
|
27 | 27 | */ |
|
28 | 28 | |
|
29 | 29 | rtems_event_set event_out; |
|
30 | 30 | rtems_status_code status; |
|
31 | 31 | int linkStatus; |
|
32 | 32 | |
|
33 | 33 | BOOT_PRINTF("in SPIQ *** \n") |
|
34 | 34 | |
|
35 | 35 | while(true){ |
|
36 | 36 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
37 | 37 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
38 | 38 | |
|
39 | 39 | // [0] SUSPEND RECV AND SEND TASKS |
|
40 | 40 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
41 | 41 | if ( status != RTEMS_SUCCESSFUL ) { |
|
42 | 42 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
43 | 43 | } |
|
44 | 44 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
45 | 45 | if ( status != RTEMS_SUCCESSFUL ) { |
|
46 | 46 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
47 | 47 | } |
|
48 | 48 | |
|
49 | 49 | // [1] CHECK THE LINK |
|
50 | 50 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
51 | 51 | if ( linkStatus != 5) { |
|
52 | 52 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
53 | 53 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
57 | 57 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
58 | 58 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
59 | 59 | { |
|
60 | 60 | spacewire_compute_stats_offsets(); |
|
61 | 61 | status = spacewire_reset_link( ); |
|
62 | 62 | } |
|
63 | 63 | else // [2.b] in run state, start the link |
|
64 | 64 | { |
|
65 | 65 | status = spacewire_stop_start_link( fdSPW ); // start the link |
|
66 | 66 | if ( status != RTEMS_SUCCESSFUL) |
|
67 | 67 | { |
|
68 | 68 | PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status) |
|
69 | 69 | } |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
73 | 73 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
74 | 74 | { |
|
75 | 75 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
76 | 76 | if ( status != RTEMS_SUCCESSFUL ) { |
|
77 | 77 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
78 | 78 | } |
|
79 | 79 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
80 | 80 | if ( status != RTEMS_SUCCESSFUL ) { |
|
81 | 81 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
82 | 82 | } |
|
83 | 83 | } |
|
84 | 84 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
85 | 85 | { |
|
86 | 86 | status = stop_current_mode(); |
|
87 | 87 | if ( status != RTEMS_SUCCESSFUL ) { |
|
88 | 88 | PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status) |
|
89 | 89 | } |
|
90 | 90 | status = enter_mode( LFR_MODE_STANDBY, 0 ); |
|
91 | 91 | if ( status != RTEMS_SUCCESSFUL ) { |
|
92 | 92 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) |
|
93 | 93 | } |
|
94 | 94 | // wake the WTDG task up to wait for the link recovery |
|
95 | 95 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
96 | 96 | status = rtems_task_suspend( RTEMS_SELF ); |
|
97 | 97 | } |
|
98 | 98 | } |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | rtems_task recv_task( rtems_task_argument unused ) |
|
102 | 102 | { |
|
103 | 103 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
104 | 104 | * |
|
105 | 105 | * @param unused is the starting argument of the RTEMS task |
|
106 | 106 | * |
|
107 | 107 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
108 | 108 | * 1. It reads the incoming data. |
|
109 | 109 | * 2. Launches the acceptance procedure. |
|
110 | 110 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. |
|
111 | 111 | * |
|
112 | 112 | */ |
|
113 | 113 | |
|
114 | 114 | int len; |
|
115 | 115 | ccsdsTelecommandPacket_t currentTC; |
|
116 | 116 | unsigned char computed_CRC[ 2 ]; |
|
117 | 117 | unsigned char currentTC_LEN_RCV[ 2 ]; |
|
118 | 118 | unsigned char destinationID; |
|
119 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; | |
|
119 | unsigned int estimatedPacketLength; | |
|
120 | 120 | unsigned int parserCode; |
|
121 | 121 | rtems_status_code status; |
|
122 | 122 | rtems_id queue_recv_id; |
|
123 | 123 | rtems_id queue_send_id; |
|
124 | 124 | |
|
125 | 125 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
126 | 126 | |
|
127 | 127 | status = get_message_queue_id_recv( &queue_recv_id ); |
|
128 | 128 | if (status != RTEMS_SUCCESSFUL) |
|
129 | 129 | { |
|
130 | 130 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) |
|
131 | 131 | } |
|
132 | 132 | |
|
133 | 133 | status = get_message_queue_id_send( &queue_send_id ); |
|
134 | 134 | if (status != RTEMS_SUCCESSFUL) |
|
135 | 135 | { |
|
136 | 136 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | BOOT_PRINTF("in RECV *** \n") |
|
140 | 140 | |
|
141 | 141 | while(1) |
|
142 | 142 | { |
|
143 | 143 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking |
|
144 | 144 | if (len == -1){ // error during the read call |
|
145 | 145 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) |
|
146 | 146 | } |
|
147 | 147 | else { |
|
148 | 148 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
149 | 149 | PRINTF("in RECV *** packet lenght too short\n") |
|
150 | 150 | } |
|
151 | 151 | else { |
|
152 |
|
|
|
153 |
currentTC_LEN_RCV[ 0 ] = (unsigned char) ( |
|
|
154 |
currentTC_LEN_RCV[ 1 ] = (unsigned char) ( |
|
|
152 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
|
153 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); | |
|
154 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); | |
|
155 | 155 | // CHECK THE TC |
|
156 |
parserCode = tc_parser( ¤tTC, |
|
|
156 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; | |
|
157 | 157 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) |
|
158 | 158 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) |
|
159 | 159 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) |
|
160 | 160 | || (parserCode == WRONG_SRC_ID) ) |
|
161 | 161 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
162 | 162 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) |
|
163 | 163 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
164 | 164 | && |
|
165 | 165 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
166 | 166 | ) |
|
167 | 167 | { |
|
168 | 168 | if ( parserCode == WRONG_SRC_ID ) |
|
169 | 169 | { |
|
170 | 170 | destinationID = SID_TC_GROUND; |
|
171 | 171 | } |
|
172 | 172 | else |
|
173 | 173 | { |
|
174 | 174 | destinationID = currentTC.sourceID; |
|
175 | 175 | } |
|
176 | 176 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, |
|
177 | 177 | computed_CRC, currentTC_LEN_RCV, |
|
178 | 178 | destinationID ); |
|
179 | 179 | } |
|
180 | 180 | } |
|
181 | 181 | else |
|
182 | 182 | { // send valid TC to the action launcher |
|
183 | 183 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, |
|
184 |
|
|
|
184 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
|
185 | 185 | } |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | } |
|
189 | 189 | } |
|
190 | 190 | |
|
191 | 191 | rtems_task send_task( rtems_task_argument argument) |
|
192 | 192 | { |
|
193 | 193 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. |
|
194 | 194 | * |
|
195 | 195 | * @param unused is the starting argument of the RTEMS task |
|
196 | 196 | * |
|
197 | 197 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: |
|
198 | 198 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. |
|
199 | 199 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After |
|
200 | 200 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the |
|
201 | 201 | * data it contains. |
|
202 | 202 | * |
|
203 | 203 | */ |
|
204 | 204 | |
|
205 | 205 | rtems_status_code status; // RTEMS status code |
|
206 | 206 | char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer |
|
207 | 207 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
208 | 208 | size_t size; // size of the incoming TC packet |
|
209 | 209 | u_int32_t count; |
|
210 | 210 | rtems_id queue_id; |
|
211 | 211 | |
|
212 | 212 | status = get_message_queue_id_send( &queue_id ); |
|
213 | 213 | if (status != RTEMS_SUCCESSFUL) |
|
214 | 214 | { |
|
215 | 215 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
216 | 216 | } |
|
217 | 217 | |
|
218 | 218 | BOOT_PRINTF("in SEND *** \n") |
|
219 | 219 | |
|
220 | 220 | while(1) |
|
221 | 221 | { |
|
222 | 222 | status = rtems_message_queue_receive( queue_id, incomingData, &size, |
|
223 | 223 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
224 | 224 | |
|
225 | 225 | if (status!=RTEMS_SUCCESSFUL) |
|
226 | 226 | { |
|
227 | 227 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
228 | 228 | } |
|
229 | 229 | else |
|
230 | 230 | { |
|
231 | 231 | if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet |
|
232 | 232 | { |
|
233 | 233 | status = write( fdSPW, incomingData, size ); |
|
234 | 234 | if (status == -1){ |
|
235 | 235 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
236 | 236 | } |
|
237 | 237 | } |
|
238 | 238 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
239 | 239 | { |
|
240 | 240 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
241 | 241 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
242 | 242 | if (status == -1){ |
|
243 | 243 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
244 | 244 | } |
|
245 | 245 | } |
|
246 | 246 | } |
|
247 | 247 | |
|
248 | 248 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
249 | 249 | if (status != RTEMS_SUCCESSFUL) |
|
250 | 250 | { |
|
251 | 251 | PRINTF1("in SEND *** (3) ERR = %d\n", status) |
|
252 | 252 | } |
|
253 | 253 | else |
|
254 | 254 | { |
|
255 | 255 | if (count > maxCount) |
|
256 | 256 | { |
|
257 | 257 | maxCount = count; |
|
258 | 258 | } |
|
259 | 259 | } |
|
260 | 260 | } |
|
261 | 261 | } |
|
262 | 262 | |
|
263 | 263 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
264 | 264 | { |
|
265 | 265 | rtems_event_set event_out; |
|
266 | 266 | rtems_status_code status; |
|
267 | 267 | int linkStatus; |
|
268 | 268 | |
|
269 | 269 | BOOT_PRINTF("in WTDG ***\n") |
|
270 | 270 | |
|
271 | 271 | while(1) |
|
272 | 272 | { |
|
273 | 273 | // wait for an RTEMS_EVENT |
|
274 | 274 | rtems_event_receive( RTEMS_EVENT_0, |
|
275 | 275 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
276 | 276 | PRINTF("in WTDG *** wait for the link\n") |
|
277 | 277 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
278 | 278 | while( linkStatus != 5) // wait for the link |
|
279 | 279 | { |
|
280 | 280 | rtems_task_wake_after( 10 ); |
|
281 | 281 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
282 | 282 | } |
|
283 | 283 | |
|
284 | 284 | status = spacewire_stop_start_link( fdSPW ); |
|
285 | 285 | |
|
286 | 286 | if (status != RTEMS_SUCCESSFUL) |
|
287 | 287 | { |
|
288 | 288 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
289 | 289 | } |
|
290 | 290 | else |
|
291 | 291 | { |
|
292 | 292 | PRINTF("in WTDG *** OK link started\n") |
|
293 | 293 | } |
|
294 | 294 | |
|
295 | 295 | // restart the SPIQ task |
|
296 | 296 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
297 | 297 | if ( status != RTEMS_SUCCESSFUL ) { |
|
298 | 298 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
299 | 299 | } |
|
300 | 300 | |
|
301 | 301 | // restart RECV and SEND |
|
302 | 302 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
303 | 303 | if ( status != RTEMS_SUCCESSFUL ) { |
|
304 | 304 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
305 | 305 | } |
|
306 | 306 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
307 | 307 | if ( status != RTEMS_SUCCESSFUL ) { |
|
308 | 308 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
309 | 309 | } |
|
310 | 310 | } |
|
311 | 311 | } |
|
312 | 312 | |
|
313 | 313 | //**************** |
|
314 | 314 | // OTHER FUNCTIONS |
|
315 | 315 | int spacewire_open_link( void ) |
|
316 | 316 | { |
|
317 | 317 | /** This function opens the SpaceWire link. |
|
318 | 318 | * |
|
319 | 319 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
320 | 320 | * |
|
321 | 321 | */ |
|
322 | 322 | rtems_status_code status; |
|
323 | 323 | |
|
324 | 324 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
325 | 325 | if ( fdSPW < 0 ) { |
|
326 | 326 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
327 | 327 | } |
|
328 | 328 | else |
|
329 | 329 | { |
|
330 | 330 | status = RTEMS_SUCCESSFUL; |
|
331 | 331 | } |
|
332 | 332 | |
|
333 | 333 | return status; |
|
334 | 334 | } |
|
335 | 335 | |
|
336 | 336 | int spacewire_start_link( int fd ) |
|
337 | 337 | { |
|
338 | 338 | rtems_status_code status; |
|
339 | 339 | |
|
340 | 340 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
341 | 341 | // -1 default hardcoded driver timeout |
|
342 | 342 | |
|
343 | 343 | return status; |
|
344 | 344 | } |
|
345 | 345 | |
|
346 | 346 | int spacewire_stop_start_link( int fd ) |
|
347 | 347 | { |
|
348 | 348 | rtems_status_code status; |
|
349 | 349 | |
|
350 | 350 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
351 | 351 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
352 | 352 | // -1 default hardcoded driver timeout |
|
353 | 353 | |
|
354 | 354 | return status; |
|
355 | 355 | } |
|
356 | 356 | |
|
357 | 357 | int spacewire_configure_link( int fd ) |
|
358 | 358 | { |
|
359 | 359 | /** This function configures the SpaceWire link. |
|
360 | 360 | * |
|
361 | 361 | * @return GR-RTEMS-DRIVER directive status codes: |
|
362 | 362 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
363 | 363 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
364 | 364 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
365 | 365 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
366 | 366 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
367 | 367 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
368 | 368 | * - 2 ENOENT - No such file or directory |
|
369 | 369 | */ |
|
370 | 370 | |
|
371 | 371 | rtems_status_code status; |
|
372 | 372 | |
|
373 | 373 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
374 | 374 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
375 | 375 | |
|
376 | 376 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
377 | 377 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
378 | 378 | // |
|
379 | 379 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
380 | 380 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
381 | 381 | // |
|
382 | 382 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
383 | 383 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
384 | 384 | // |
|
385 | 385 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
386 | 386 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
387 | 387 | // |
|
388 | 388 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks |
|
389 | 389 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
390 | 390 | // |
|
391 | 391 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
392 | 392 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
393 | 393 | // |
|
394 | 394 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
395 | 395 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
396 | 396 | |
|
397 | 397 | return status; |
|
398 | 398 | } |
|
399 | 399 | |
|
400 | 400 | int spacewire_reset_link( void ) |
|
401 | 401 | { |
|
402 | 402 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
403 | 403 | * |
|
404 | 404 | * @return RTEMS directive status code: |
|
405 | 405 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
406 | 406 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
407 | 407 | * |
|
408 | 408 | */ |
|
409 | 409 | |
|
410 | 410 | rtems_status_code status_spw; |
|
411 | 411 | int i; |
|
412 | 412 | |
|
413 | 413 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
414 | 414 | { |
|
415 | 415 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
416 | 416 | |
|
417 | 417 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
418 | 418 | |
|
419 | 419 | status_spw = spacewire_stop_start_link( fdSPW ); |
|
420 | 420 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
421 | 421 | { |
|
422 | 422 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
423 | 423 | } |
|
424 | 424 | |
|
425 | 425 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
426 | 426 | { |
|
427 | 427 | break; |
|
428 | 428 | } |
|
429 | 429 | } |
|
430 | 430 | |
|
431 | 431 | return status_spw; |
|
432 | 432 | } |
|
433 | 433 | |
|
434 | 434 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
435 | 435 | { |
|
436 | 436 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
437 | 437 | * |
|
438 | 438 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
439 | 439 | * @param regAddr is the address of the GRSPW control register. |
|
440 | 440 | * |
|
441 | 441 | * NP is the bit 20 of the GRSPW control register. |
|
442 | 442 | * |
|
443 | 443 | */ |
|
444 | 444 | |
|
445 | 445 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
446 | 446 | |
|
447 | 447 | if (val == 1) { |
|
448 | 448 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
449 | 449 | } |
|
450 | 450 | if (val== 0) { |
|
451 | 451 | *spwptr = *spwptr & 0xffdfffff; |
|
452 | 452 | } |
|
453 | 453 | } |
|
454 | 454 | |
|
455 | 455 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
456 | 456 | { |
|
457 | 457 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
458 | 458 | * |
|
459 | 459 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
460 | 460 | * @param regAddr is the address of the GRSPW control register. |
|
461 | 461 | * |
|
462 | 462 | * RE is the bit 16 of the GRSPW control register. |
|
463 | 463 | * |
|
464 | 464 | */ |
|
465 | 465 | |
|
466 | 466 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
467 | 467 | |
|
468 | 468 | if (val == 1) |
|
469 | 469 | { |
|
470 | 470 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
471 | 471 | } |
|
472 | 472 | if (val== 0) |
|
473 | 473 | { |
|
474 | 474 | *spwptr = *spwptr & 0xfffdffff; |
|
475 | 475 | } |
|
476 | 476 | } |
|
477 | 477 | |
|
478 | 478 | void spacewire_compute_stats_offsets( void ) |
|
479 | 479 | { |
|
480 | 480 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
481 | 481 | * |
|
482 | 482 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
483 | 483 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it |
|
484 | 484 | * during the open systel call). |
|
485 | 485 | * |
|
486 | 486 | */ |
|
487 | 487 | |
|
488 | 488 | spw_stats spacewire_stats_grspw; |
|
489 | 489 | rtems_status_code status; |
|
490 | 490 | |
|
491 | 491 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
492 | 492 | |
|
493 | 493 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
494 | 494 | + spacewire_stats.packets_received; |
|
495 | 495 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
496 | 496 | + spacewire_stats.packets_sent; |
|
497 | 497 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
498 | 498 | + spacewire_stats.parity_err; |
|
499 | 499 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
500 | 500 | + spacewire_stats.disconnect_err; |
|
501 | 501 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
502 | 502 | + spacewire_stats.escape_err; |
|
503 | 503 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
504 | 504 | + spacewire_stats.credit_err; |
|
505 | 505 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
506 | 506 | + spacewire_stats.write_sync_err; |
|
507 | 507 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
508 | 508 | + spacewire_stats.rx_rmap_header_crc_err; |
|
509 | 509 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
510 | 510 | + spacewire_stats.rx_rmap_data_crc_err; |
|
511 | 511 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
512 | 512 | + spacewire_stats.early_ep; |
|
513 | 513 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
514 | 514 | + spacewire_stats.invalid_address; |
|
515 | 515 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
516 | 516 | + spacewire_stats.rx_eep_err; |
|
517 | 517 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
518 | 518 | + spacewire_stats.rx_truncated; |
|
519 | 519 | } |
|
520 | 520 | |
|
521 | 521 | void spacewire_update_statistics( void ) |
|
522 | 522 | { |
|
523 | 523 | rtems_status_code status; |
|
524 | 524 | spw_stats spacewire_stats_grspw; |
|
525 | 525 | |
|
526 | 526 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
527 | 527 | |
|
528 | 528 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
529 | 529 | + spacewire_stats_grspw.packets_received; |
|
530 | 530 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
531 | 531 | + spacewire_stats_grspw.packets_sent; |
|
532 | 532 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
533 | 533 | + spacewire_stats_grspw.parity_err; |
|
534 | 534 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
535 | 535 | + spacewire_stats_grspw.disconnect_err; |
|
536 | 536 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
537 | 537 | + spacewire_stats_grspw.escape_err; |
|
538 | 538 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
539 | 539 | + spacewire_stats_grspw.credit_err; |
|
540 | 540 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
541 | 541 | + spacewire_stats_grspw.write_sync_err; |
|
542 | 542 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
543 | 543 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
544 | 544 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
545 | 545 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
546 | 546 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
547 | 547 | + spacewire_stats_grspw.early_ep; |
|
548 | 548 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
549 | 549 | + spacewire_stats_grspw.invalid_address; |
|
550 | 550 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
551 | 551 | + spacewire_stats_grspw.rx_eep_err; |
|
552 | 552 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
553 | 553 | + spacewire_stats_grspw.rx_truncated; |
|
554 | 554 | //spacewire_stats.tx_link_err; |
|
555 | 555 | |
|
556 | 556 | //**************************** |
|
557 | 557 | // DPU_SPACEWIRE_IF_STATISTICS |
|
558 | 558 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
559 | 559 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
560 | 560 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
561 | 561 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
562 | 562 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
563 | 563 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
564 | 564 | |
|
565 | 565 | //****************************************** |
|
566 | 566 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
567 | 567 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
568 | 568 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
569 | 569 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
570 | 570 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
571 | 571 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
572 | 572 | |
|
573 | 573 | //********************************************* |
|
574 | 574 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
575 | 575 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
576 | 576 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
577 | 577 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
578 | 578 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
579 | 579 | } |
|
580 | 580 | |
|
581 | 581 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
582 | 582 | { |
|
583 | 583 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 ); |
|
584 | 584 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
585 | 585 | |
|
586 | 586 | grgpio_regs->io_port_direction_register = |
|
587 | 587 | grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled |
|
588 | 588 | |
|
589 | 589 | if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 ) |
|
590 | 590 | { |
|
591 | 591 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7; |
|
592 | 592 | } |
|
593 | 593 | else |
|
594 | 594 | { |
|
595 | 595 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08; |
|
596 | 596 | } |
|
597 | 597 | } |
|
598 | 598 | |
|
599 | 599 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
600 | 600 | { |
|
601 | 601 | int linkStatus; |
|
602 | 602 | rtems_status_code status; |
|
603 | 603 | |
|
604 | 604 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
605 | 605 | |
|
606 | 606 | if ( linkStatus == 5) { |
|
607 | 607 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
608 | 608 | status = RTEMS_SUCCESSFUL; |
|
609 | 609 | } |
|
610 | 610 | } |
@@ -1,437 +1,437 | |||
|
1 | 1 | /** Functions related to TeleCommand acceptance. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TeleCommands parsing.\n |
|
7 | 7 | * |
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include "tc_acceptance.h" |
|
11 | 11 | |
|
12 | 12 | unsigned int lookUpTableForCRC[256]; |
|
13 | 13 | |
|
14 | 14 | //********************** |
|
15 | 15 | // GENERAL USE FUNCTIONS |
|
16 | 16 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) |
|
17 | 17 | { |
|
18 | 18 | /** This function generate the CRC for one byte and returns the value of the new syndrome. |
|
19 | 19 | * |
|
20 | 20 | * @param D is the current byte of data. |
|
21 | 21 | * @param Chk is the current syndrom value. |
|
22 | 22 | * |
|
23 | 23 | * @return the value of the new syndrome on two bytes. |
|
24 | 24 | * |
|
25 | 25 | */ |
|
26 | 26 | |
|
27 | 27 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); |
|
28 | 28 | } |
|
29 | 29 | |
|
30 | 30 | void initLookUpTableForCRC( void ) |
|
31 | 31 | { |
|
32 | 32 | /** This function is used to initiates the look-up table for fast CRC computation. |
|
33 | 33 | * |
|
34 | 34 | * The global table lookUpTableForCRC[256] is initiated. |
|
35 | 35 | * |
|
36 | 36 | */ |
|
37 | 37 | |
|
38 | 38 | unsigned int i; |
|
39 | 39 | unsigned int tmp; |
|
40 | 40 | |
|
41 | 41 | for (i=0; i<256; i++) |
|
42 | 42 | { |
|
43 | 43 | tmp = 0; |
|
44 | 44 | if((i & 1) != 0) { |
|
45 | 45 | tmp = tmp ^ 0x1021; |
|
46 | 46 | } |
|
47 | 47 | if((i & 2) != 0) { |
|
48 | 48 | tmp = tmp ^ 0x2042; |
|
49 | 49 | } |
|
50 | 50 | if((i & 4) != 0) { |
|
51 | 51 | tmp = tmp ^ 0x4084; |
|
52 | 52 | } |
|
53 | 53 | if((i & 8) != 0) { |
|
54 | 54 | tmp = tmp ^ 0x8108; |
|
55 | 55 | } |
|
56 | 56 | if((i & 16) != 0) { |
|
57 | 57 | tmp = tmp ^ 0x1231; |
|
58 | 58 | } |
|
59 | 59 | if((i & 32) != 0) { |
|
60 | 60 | tmp = tmp ^ 0x2462; |
|
61 | 61 | } |
|
62 | 62 | if((i & 64) != 0) { |
|
63 | 63 | tmp = tmp ^ 0x48c4; |
|
64 | 64 | } |
|
65 | 65 | if((i & 128) != 0) { |
|
66 | 66 | tmp = tmp ^ 0x9188; |
|
67 | 67 | } |
|
68 | 68 | lookUpTableForCRC[i] = tmp; |
|
69 | 69 | } |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) |
|
73 | 73 | { |
|
74 | 74 | /** This function calculates a two bytes Cyclic Redundancy Code. |
|
75 | 75 | * |
|
76 | 76 | * @param data points to a buffer containing the data on which to compute the CRC. |
|
77 | 77 | * @param crcAsTwoBytes points points to a two bytes buffer in which the CRC is stored. |
|
78 | 78 | * @param sizeOfData is the number of bytes of *data* used to compute the CRC. |
|
79 | 79 | * |
|
80 | 80 | * The specification of the Cyclic Redundancy Code is described in the following document: ECSS-E-70-41-A. |
|
81 | 81 | * |
|
82 | 82 | */ |
|
83 | 83 | |
|
84 | 84 | unsigned int Chk; |
|
85 | 85 | int j; |
|
86 | 86 | Chk = 0xffff; // reset the syndrom to all ones |
|
87 | 87 | for (j=0; j<sizeOfData; j++) { |
|
88 | 88 | Chk = Crc_opt(data[j], Chk); |
|
89 | 89 | } |
|
90 | 90 | crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); |
|
91 | 91 | crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); |
|
92 | 92 | } |
|
93 | 93 | |
|
94 | 94 | //********************* |
|
95 | 95 | // ACCEPTANCE FUNCTIONS |
|
96 |
int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int |
|
|
96 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int estimatedPacketLength, unsigned char *computed_CRC) | |
|
97 | 97 | { |
|
98 | 98 | /** This function parses TeleCommands. |
|
99 | 99 | * |
|
100 | 100 | * @param TC points to the TeleCommand that will be parsed. |
|
101 | * @param TC_LEN_RCV is the received packet length. | |
|
101 | * @param estimatedPacketLength is the PACKET_LENGTH field calculated from the effective length of the received packet. | |
|
102 | 102 | * |
|
103 | 103 | * @return Status code of the parsing. |
|
104 | 104 | * |
|
105 | 105 | * The parsing checks: |
|
106 | 106 | * - process id |
|
107 | 107 | * - category |
|
108 | 108 | * - length: a global check is performed and a per subtype check also |
|
109 | 109 | * - type |
|
110 | 110 | * - subtype |
|
111 | 111 | * - crc |
|
112 | 112 | * |
|
113 | 113 | */ |
|
114 | 114 | |
|
115 | 115 | int status; |
|
116 | 116 | int status_crc; |
|
117 | 117 | unsigned char pid; |
|
118 | 118 | unsigned char category; |
|
119 |
unsigned int |
|
|
119 | unsigned int packetLength; | |
|
120 | 120 | unsigned char packetType; |
|
121 | 121 | unsigned char packetSubtype; |
|
122 | 122 | unsigned char sid; |
|
123 | 123 | |
|
124 | 124 | status = CCSDS_TM_VALID; |
|
125 | 125 | |
|
126 | 126 | // APID check *** APID on 2 bytes |
|
127 | pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx | |
|
128 | category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 | |
|
129 |
|
|
|
130 | packetType = TCPacket->serviceType; | |
|
131 | packetSubtype = TCPacket->serviceSubType; | |
|
132 | sid = TCPacket->sourceID; | |
|
127 | pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx | |
|
128 | category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 | |
|
129 | packetLength = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1]; | |
|
130 | packetType = TCPacket->serviceType; | |
|
131 | packetSubtype = TCPacket->serviceSubType; | |
|
132 | sid = TCPacket->sourceID; | |
|
133 | 133 | |
|
134 | 134 | if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID |
|
135 | 135 | { |
|
136 | 136 | status = ILLEGAL_APID; |
|
137 | 137 | } |
|
138 | 138 | if (status == CCSDS_TM_VALID) // CHECK THE CATEGORY |
|
139 | 139 | { |
|
140 | 140 | if ( category != CCSDS_PACKET_CATEGORY ) |
|
141 | 141 | { |
|
142 | 142 | status = ILLEGAL_APID; |
|
143 | 143 | } |
|
144 | 144 | } |
|
145 |
if (status == CCSDS_TM_VALID) // CHECK THE PACKET |
|
|
145 | if (status == CCSDS_TM_VALID) // CHECK THE PACKET_LENGTH FIELD AND THE ESTIMATED PACKET_LENGTH COMPLIANCE | |
|
146 | 146 | { |
|
147 | if (length != TC_LEN_RCV ) { | |
|
147 | if (packetLength != estimatedPacketLength ) { | |
|
148 | 148 | status = WRONG_LEN_PKT; |
|
149 | 149 | } |
|
150 | 150 | } |
|
151 | 151 | if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE |
|
152 | 152 | { |
|
153 |
if ( |
|
|
153 | if ( packetLength >= CCSDS_TC_PKT_MAX_SIZE ) { | |
|
154 | 154 | status = WRONG_LEN_PKT; |
|
155 | 155 | } |
|
156 | 156 | } |
|
157 | 157 | if (status == CCSDS_TM_VALID) // CHECK THE TYPE |
|
158 | 158 | { |
|
159 | 159 | status = tc_check_type( packetType ); |
|
160 | 160 | } |
|
161 | 161 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE |
|
162 | 162 | { |
|
163 | 163 | status = tc_check_type_subtype( packetType, packetSubtype ); |
|
164 | 164 | } |
|
165 | 165 | if (status == CCSDS_TM_VALID) // CHECK THE SID |
|
166 | 166 | { |
|
167 | 167 | status = tc_check_sid( sid ); |
|
168 | 168 | } |
|
169 | 169 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE |
|
170 | 170 | { |
|
171 |
status = tc_check_length( packetSubtype, |
|
|
171 | status = tc_check_length( packetSubtype, packetLength ); | |
|
172 | 172 | } |
|
173 |
status_crc = tc_check_crc( TCPacket, |
|
|
173 | status_crc = tc_check_crc( TCPacket, estimatedPacketLength, computed_CRC ); | |
|
174 | 174 | if (status == CCSDS_TM_VALID ) // CHECK CRC |
|
175 | 175 | { |
|
176 | 176 | status = status_crc; |
|
177 | 177 | } |
|
178 | 178 | |
|
179 | 179 | return status; |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | int tc_check_type( unsigned char packetType ) |
|
183 | 183 | { |
|
184 | 184 | /** This function checks that the type of a TeleCommand is valid. |
|
185 | 185 | * |
|
186 | 186 | * @param packetType is the type to check. |
|
187 | 187 | * |
|
188 | 188 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. |
|
189 | 189 | * |
|
190 | 190 | */ |
|
191 | 191 | |
|
192 | 192 | int status; |
|
193 | 193 | |
|
194 | 194 | if ( (packetType == TC_TYPE_GEN) || (packetType == TC_TYPE_TIME)) |
|
195 | 195 | { |
|
196 | 196 | status = CCSDS_TM_VALID; |
|
197 | 197 | } |
|
198 | 198 | else |
|
199 | 199 | { |
|
200 | 200 | status = ILL_TYPE; |
|
201 | 201 | } |
|
202 | 202 | |
|
203 | 203 | return status; |
|
204 | 204 | } |
|
205 | 205 | |
|
206 | 206 | int tc_check_type_subtype( unsigned char packetType, unsigned char packetSubType ) |
|
207 | 207 | { |
|
208 | 208 | /** This function checks that the subtype of a TeleCommand is valid and coherent with the type. |
|
209 | 209 | * |
|
210 | 210 | * @param packetType is the type of the TC. |
|
211 | 211 | * @param packetSubType is the subtype to check. |
|
212 | 212 | * |
|
213 | 213 | * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE. |
|
214 | 214 | * |
|
215 | 215 | */ |
|
216 | 216 | |
|
217 | 217 | int status; |
|
218 | 218 | |
|
219 | 219 | switch(packetType) |
|
220 | 220 | { |
|
221 | 221 | case TC_TYPE_GEN: |
|
222 | 222 | if ( (packetSubType == TC_SUBTYPE_RESET) |
|
223 | 223 | || (packetSubType == TC_SUBTYPE_LOAD_COMM) |
|
224 | 224 | || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST) |
|
225 | 225 | || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2) |
|
226 | 226 | || (packetSubType == TC_SUBTYPE_DUMP) |
|
227 | 227 | || (packetSubType == TC_SUBTYPE_ENTER) |
|
228 | 228 | || (packetSubType == TC_SUBTYPE_UPDT_INFO) |
|
229 | 229 | || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) ) |
|
230 | 230 | { |
|
231 | 231 | status = CCSDS_TM_VALID; |
|
232 | 232 | } |
|
233 | 233 | else |
|
234 | 234 | { |
|
235 | 235 | status = ILL_SUBTYPE; |
|
236 | 236 | } |
|
237 | 237 | break; |
|
238 | 238 | |
|
239 | 239 | case TC_TYPE_TIME: |
|
240 | 240 | if (packetSubType == TC_SUBTYPE_UPDT_TIME) |
|
241 | 241 | { |
|
242 | 242 | status = CCSDS_TM_VALID; |
|
243 | 243 | } |
|
244 | 244 | else |
|
245 | 245 | { |
|
246 | 246 | status = ILL_SUBTYPE; |
|
247 | 247 | } |
|
248 | 248 | break; |
|
249 | 249 | |
|
250 | 250 | default: |
|
251 | 251 | status = ILL_SUBTYPE; |
|
252 | 252 | break; |
|
253 | 253 | } |
|
254 | 254 | |
|
255 | 255 | return status; |
|
256 | 256 | } |
|
257 | 257 | |
|
258 | 258 | int tc_check_sid( unsigned char sid ) |
|
259 | 259 | { |
|
260 | 260 | /** This function checks that the sid of a TeleCommand is valid. |
|
261 | 261 | * |
|
262 | 262 | * @param sid is the sid to check. |
|
263 | 263 | * |
|
264 | 264 | * @return Status code CCSDS_TM_VALID or CORRUPTED. |
|
265 | 265 | * |
|
266 | 266 | */ |
|
267 | 267 | |
|
268 | 268 | int status; |
|
269 | 269 | |
|
270 | 270 | if ( (sid == SID_TC_MISSION_TIMELINE) || (sid == SID_TC_TC_SEQUENCES) || (sid == SID_TC_RECOVERY_ACTION_CMD) |
|
271 | 271 | || (sid == SID_TC_BACKUP_MISSION_TIMELINE) |
|
272 | 272 | || (sid == SID_TC_DIRECT_CMD) || (sid == SID_TC_SPARE_GRD_SRC1) || (sid == SID_TC_SPARE_GRD_SRC2) |
|
273 | 273 | || (sid == SID_TC_OBCP) || (sid == SID_TC_SYSTEM_CONTROL) || (sid == SID_TC_AOCS) |
|
274 | 274 | || (sid == SID_TC_RPW_INTERNAL)) |
|
275 | 275 | { |
|
276 | 276 | status = CCSDS_TM_VALID; |
|
277 | 277 | } |
|
278 | 278 | else |
|
279 | 279 | { |
|
280 | 280 | status = WRONG_SRC_ID; |
|
281 | 281 | } |
|
282 | 282 | |
|
283 | 283 | return status; |
|
284 | 284 | } |
|
285 | 285 | |
|
286 | 286 | int tc_check_length( unsigned char packetSubType, unsigned int length ) |
|
287 | 287 | { |
|
288 | 288 | /** This function checks that the subtype and the length are compliant. |
|
289 | 289 | * |
|
290 | 290 | * @param packetSubType is the subtype to check. |
|
291 | 291 | * @param length is the length to check. |
|
292 | 292 | * |
|
293 | 293 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. |
|
294 | 294 | * |
|
295 | 295 | */ |
|
296 | 296 | |
|
297 | 297 | int status; |
|
298 | 298 | |
|
299 | 299 | status = LFR_SUCCESSFUL; |
|
300 | 300 | |
|
301 | 301 | switch(packetSubType) |
|
302 | 302 | { |
|
303 | 303 | case TC_SUBTYPE_RESET: |
|
304 | 304 | if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
305 | 305 | status = WRONG_LEN_PKT; |
|
306 | 306 | } |
|
307 | 307 | else { |
|
308 | 308 | status = CCSDS_TM_VALID; |
|
309 | 309 | } |
|
310 | 310 | break; |
|
311 | 311 | case TC_SUBTYPE_LOAD_COMM: |
|
312 | 312 | if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
313 | 313 | status = WRONG_LEN_PKT; |
|
314 | 314 | } |
|
315 | 315 | else { |
|
316 | 316 | status = CCSDS_TM_VALID; |
|
317 | 317 | } |
|
318 | 318 | break; |
|
319 | 319 | case TC_SUBTYPE_LOAD_NORM: |
|
320 | 320 | if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
321 | 321 | status = WRONG_LEN_PKT; |
|
322 | 322 | } |
|
323 | 323 | else { |
|
324 | 324 | status = CCSDS_TM_VALID; |
|
325 | 325 | } |
|
326 | 326 | break; |
|
327 | 327 | case TC_SUBTYPE_LOAD_BURST: |
|
328 | 328 | if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
329 | 329 | status = WRONG_LEN_PKT; |
|
330 | 330 | } |
|
331 | 331 | else { |
|
332 | 332 | status = CCSDS_TM_VALID; |
|
333 | 333 | } |
|
334 | 334 | break; |
|
335 | 335 | case TC_SUBTYPE_LOAD_SBM1: |
|
336 | 336 | if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
337 | 337 | status = WRONG_LEN_PKT; |
|
338 | 338 | } |
|
339 | 339 | else { |
|
340 | 340 | status = CCSDS_TM_VALID; |
|
341 | 341 | } |
|
342 | 342 | break; |
|
343 | 343 | case TC_SUBTYPE_LOAD_SBM2: |
|
344 | 344 | if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
345 | 345 | status = WRONG_LEN_PKT; |
|
346 | 346 | } |
|
347 | 347 | else { |
|
348 | 348 | status = CCSDS_TM_VALID; |
|
349 | 349 | } |
|
350 | 350 | break; |
|
351 | 351 | case TC_SUBTYPE_DUMP: |
|
352 | 352 | if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
353 | 353 | status = WRONG_LEN_PKT; |
|
354 | 354 | } |
|
355 | 355 | else { |
|
356 | 356 | status = CCSDS_TM_VALID; |
|
357 | 357 | } |
|
358 | 358 | break; |
|
359 | 359 | case TC_SUBTYPE_ENTER: |
|
360 | 360 | if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
361 | 361 | status = WRONG_LEN_PKT; |
|
362 | 362 | } |
|
363 | 363 | else { |
|
364 | 364 | status = CCSDS_TM_VALID; |
|
365 | 365 | } |
|
366 | 366 | break; |
|
367 | 367 | case TC_SUBTYPE_UPDT_INFO: |
|
368 | 368 | if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
369 | 369 | status = WRONG_LEN_PKT; |
|
370 | 370 | } |
|
371 | 371 | else { |
|
372 | 372 | status = CCSDS_TM_VALID; |
|
373 | 373 | } |
|
374 | 374 | break; |
|
375 | 375 | case TC_SUBTYPE_EN_CAL: |
|
376 | 376 | if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
377 | 377 | status = WRONG_LEN_PKT; |
|
378 | 378 | } |
|
379 | 379 | else { |
|
380 | 380 | status = CCSDS_TM_VALID; |
|
381 | 381 | } |
|
382 | 382 | break; |
|
383 | 383 | case TC_SUBTYPE_DIS_CAL: |
|
384 | 384 | if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
385 | 385 | status = WRONG_LEN_PKT; |
|
386 | 386 | } |
|
387 | 387 | else { |
|
388 | 388 | status = CCSDS_TM_VALID; |
|
389 | 389 | } |
|
390 | 390 | break; |
|
391 | 391 | case TC_SUBTYPE_UPDT_TIME: |
|
392 | 392 | if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
393 | 393 | status = WRONG_LEN_PKT; |
|
394 | 394 | } |
|
395 | 395 | else { |
|
396 | 396 | status = CCSDS_TM_VALID; |
|
397 | 397 | } |
|
398 | 398 | break; |
|
399 | 399 | default: // if the subtype is not a legal value, return ILL_SUBTYPE |
|
400 | 400 | status = ILL_SUBTYPE; |
|
401 | 401 | break ; |
|
402 | 402 | } |
|
403 | 403 | |
|
404 | 404 | return status; |
|
405 | 405 | } |
|
406 | 406 | |
|
407 | 407 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length, unsigned char *computed_CRC ) |
|
408 | 408 | { |
|
409 | 409 | /** This function checks the CRC validity of the corresponding TeleCommand packet. |
|
410 | 410 | * |
|
411 | 411 | * @param TCPacket points to the TeleCommand packet to check. |
|
412 | 412 | * @param length is the length of the TC packet. |
|
413 | 413 | * |
|
414 | 414 | * @return Status code CCSDS_TM_VALID or INCOR_CHECKSUM. |
|
415 | 415 | * |
|
416 | 416 | */ |
|
417 | 417 | |
|
418 | 418 | int status; |
|
419 | 419 | unsigned char * CCSDSContent; |
|
420 | 420 | |
|
421 | 421 | CCSDSContent = (unsigned char*) TCPacket->packetID; |
|
422 | 422 | GetCRCAsTwoBytes(CCSDSContent, computed_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC |
|
423 | 423 | if (computed_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { |
|
424 | 424 | status = INCOR_CHECKSUM; |
|
425 | 425 | } |
|
426 | 426 | else if (computed_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { |
|
427 | 427 | status = INCOR_CHECKSUM; |
|
428 | 428 | } |
|
429 | 429 | else { |
|
430 | 430 | status = CCSDS_TM_VALID; |
|
431 | 431 | } |
|
432 | 432 | |
|
433 | 433 | return status; |
|
434 | 434 | } |
|
435 | 435 | |
|
436 | 436 | |
|
437 | 437 |
@@ -1,873 +1,885 | |||
|
1 | 1 | /** Functions and tasks related to TeleCommand handling. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TeleCommands:\n |
|
7 | 7 | * action launching\n |
|
8 | 8 | * TC parsing\n |
|
9 | 9 | * ... |
|
10 | 10 | * |
|
11 | 11 | */ |
|
12 | 12 | |
|
13 | 13 | #include "tc_handler.h" |
|
14 | 14 | |
|
15 | 15 | //*********** |
|
16 | 16 | // RTEMS TASK |
|
17 | 17 | |
|
18 | 18 | rtems_task actn_task( rtems_task_argument unused ) |
|
19 | 19 | { |
|
20 | 20 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
21 | 21 | * |
|
22 | 22 | * @param unused is the starting argument of the RTEMS task |
|
23 | 23 | * |
|
24 | 24 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
25 | 25 | * on the incoming TeleCommand. |
|
26 | 26 | * |
|
27 | 27 | */ |
|
28 | 28 | |
|
29 | 29 | int result; |
|
30 | 30 | rtems_status_code status; // RTEMS status code |
|
31 | 31 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
32 | 32 | size_t size; // size of the incoming TC packet |
|
33 | 33 | unsigned char subtype; // subtype of the current TC packet |
|
34 | 34 | unsigned char time[6]; |
|
35 | 35 | rtems_id queue_rcv_id; |
|
36 | 36 | rtems_id queue_snd_id; |
|
37 | 37 | |
|
38 | 38 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
39 | 39 | if (status != RTEMS_SUCCESSFUL) |
|
40 | 40 | { |
|
41 | 41 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | status = get_message_queue_id_send( &queue_snd_id ); |
|
45 | 45 | if (status != RTEMS_SUCCESSFUL) |
|
46 | 46 | { |
|
47 | 47 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | result = LFR_SUCCESSFUL; |
|
51 | 51 | subtype = 0; // subtype of the current TC packet |
|
52 | 52 | |
|
53 | 53 | BOOT_PRINTF("in ACTN *** \n") |
|
54 | 54 | |
|
55 | 55 | while(1) |
|
56 | 56 | { |
|
57 | 57 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
58 | 58 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
59 | 59 | getTime( time ); // set time to the current time |
|
60 | 60 | if (status!=RTEMS_SUCCESSFUL) |
|
61 | 61 | { |
|
62 | 62 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
63 | 63 | } |
|
64 | 64 | else |
|
65 | 65 | { |
|
66 | 66 | subtype = TC.serviceSubType; |
|
67 | 67 | switch(subtype) |
|
68 | 68 | { |
|
69 | 69 | case TC_SUBTYPE_RESET: |
|
70 | 70 | result = action_reset( &TC, queue_snd_id, time ); |
|
71 | 71 | close_action( &TC, result, queue_snd_id ); |
|
72 | 72 | break; |
|
73 | 73 | // |
|
74 | 74 | case TC_SUBTYPE_LOAD_COMM: |
|
75 | 75 | result = action_load_common_par( &TC ); |
|
76 | 76 | close_action( &TC, result, queue_snd_id ); |
|
77 | 77 | break; |
|
78 | 78 | // |
|
79 | 79 | case TC_SUBTYPE_LOAD_NORM: |
|
80 | 80 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
81 | 81 | close_action( &TC, result, queue_snd_id ); |
|
82 | 82 | break; |
|
83 | 83 | // |
|
84 | 84 | case TC_SUBTYPE_LOAD_BURST: |
|
85 | 85 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
86 | 86 | close_action( &TC, result, queue_snd_id ); |
|
87 | 87 | break; |
|
88 | 88 | // |
|
89 | 89 | case TC_SUBTYPE_LOAD_SBM1: |
|
90 | 90 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
91 | 91 | close_action( &TC, result, queue_snd_id ); |
|
92 | 92 | break; |
|
93 | 93 | // |
|
94 | 94 | case TC_SUBTYPE_LOAD_SBM2: |
|
95 | 95 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
96 | 96 | close_action( &TC, result, queue_snd_id ); |
|
97 | 97 | break; |
|
98 | 98 | // |
|
99 | 99 | case TC_SUBTYPE_DUMP: |
|
100 | 100 | result = action_dump_par( queue_snd_id ); |
|
101 | 101 | close_action( &TC, result, queue_snd_id ); |
|
102 | 102 | break; |
|
103 | 103 | // |
|
104 | 104 | case TC_SUBTYPE_ENTER: |
|
105 | 105 | result = action_enter_mode( &TC, queue_snd_id ); |
|
106 | 106 | close_action( &TC, result, queue_snd_id ); |
|
107 | 107 | break; |
|
108 | 108 | // |
|
109 | 109 | case TC_SUBTYPE_UPDT_INFO: |
|
110 | 110 | result = action_update_info( &TC, queue_snd_id ); |
|
111 | 111 | close_action( &TC, result, queue_snd_id ); |
|
112 | 112 | break; |
|
113 | 113 | // |
|
114 | 114 | case TC_SUBTYPE_EN_CAL: |
|
115 | 115 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
116 | 116 | close_action( &TC, result, queue_snd_id ); |
|
117 | 117 | break; |
|
118 | 118 | // |
|
119 | 119 | case TC_SUBTYPE_DIS_CAL: |
|
120 | 120 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
121 | 121 | close_action( &TC, result, queue_snd_id ); |
|
122 | 122 | break; |
|
123 | 123 | // |
|
124 | 124 | case TC_SUBTYPE_UPDT_TIME: |
|
125 | 125 | result = action_update_time( &TC ); |
|
126 | 126 | close_action( &TC, result, queue_snd_id ); |
|
127 | 127 | break; |
|
128 | 128 | // |
|
129 | 129 | default: |
|
130 | 130 | break; |
|
131 | 131 | } |
|
132 | 132 | } |
|
133 | 133 | } |
|
134 | 134 | } |
|
135 | 135 | |
|
136 | 136 | //*********** |
|
137 | 137 | // TC ACTIONS |
|
138 | 138 | |
|
139 | 139 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | 140 | { |
|
141 | 141 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
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 transmission by the SpaceWire driver |
|
145 | 145 | * |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | 148 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
149 | 149 | return LFR_DEFAULT; |
|
150 | 150 | } |
|
151 | 151 | |
|
152 | 152 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
153 | 153 | { |
|
154 | 154 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
155 | 155 | * |
|
156 | 156 | * @param TC points to the TeleCommand packet that is being processed |
|
157 | 157 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
158 | 158 | * |
|
159 | 159 | */ |
|
160 | 160 | |
|
161 | 161 | rtems_status_code status; |
|
162 | 162 | unsigned char requestedMode; |
|
163 | 163 | unsigned int *transitionCoarseTime_ptr; |
|
164 | 164 | unsigned int transitionCoarseTime; |
|
165 | unsigned char * bytePosPtr; | |
|
165 | 166 | |
|
166 | requestedMode = TC->dataAndCRC[1]; | |
|
167 | transitionCoarseTime_ptr = (unsigned int *) (&TC->dataAndCRC[BYTE_POS_CP_LFR_ENTER_MODE_TIME]); | |
|
167 | bytePosPtr = (unsigned char *) &TC->packetID; | |
|
168 | ||
|
169 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; | |
|
170 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); | |
|
168 | 171 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
169 | 172 | |
|
170 | 173 | status = check_mode_value( requestedMode ); |
|
171 | 174 | |
|
172 | if ( status != LFR_SUCCESSFUL ) | |
|
175 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent | |
|
173 | 176 | { |
|
174 |
send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_ |
|
|
177 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); | |
|
175 | 178 | } |
|
176 | 179 | else // the mode value is consistent, check the transition |
|
177 | 180 | { |
|
178 | 181 | status = check_mode_transition(requestedMode); |
|
179 | 182 | if (status != LFR_SUCCESSFUL) |
|
180 | 183 | { |
|
181 | 184 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
182 | 185 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
183 | 186 | } |
|
184 | 187 | } |
|
185 | 188 | |
|
186 | 189 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode |
|
187 | 190 | { |
|
188 | 191 | status = check_transition_date( transitionCoarseTime ); |
|
189 | 192 | if (status != LFR_SUCCESSFUL) |
|
190 | 193 | { |
|
191 | 194 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") |
|
192 |
send_tm_lfr_tc_exe_ |
|
|
195 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, | |
|
196 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, | |
|
197 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); | |
|
193 | 198 | } |
|
194 | 199 | } |
|
195 | 200 | |
|
196 | 201 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
197 | 202 | { |
|
198 | 203 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
199 | 204 | status = enter_mode( requestedMode, transitionCoarseTime ); |
|
200 | 205 | } |
|
201 | 206 | |
|
202 | 207 | return status; |
|
203 | 208 | } |
|
204 | 209 | |
|
205 | 210 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
206 | 211 | { |
|
207 | 212 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
208 | 213 | * |
|
209 | 214 | * @param TC points to the TeleCommand packet that is being processed |
|
210 | 215 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
211 | 216 | * |
|
212 | 217 | * @return LFR directive status code: |
|
213 | 218 | * - LFR_DEFAULT |
|
214 | 219 | * - LFR_SUCCESSFUL |
|
215 | 220 | * |
|
216 | 221 | */ |
|
217 | 222 | |
|
218 | 223 | unsigned int val; |
|
219 | 224 | int result; |
|
220 | 225 | unsigned int status; |
|
221 | 226 | unsigned char mode; |
|
227 | unsigned char * bytePosPtr; | |
|
228 | ||
|
229 | bytePosPtr = (unsigned char *) &TC->packetID; | |
|
222 | 230 | |
|
223 | 231 | // check LFR mode |
|
224 |
mode = ( |
|
|
232 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; | |
|
225 | 233 | status = check_update_info_hk_lfr_mode( mode ); |
|
226 | 234 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
227 | 235 | { |
|
228 |
mode = ( |
|
|
236 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; | |
|
229 | 237 | status = check_update_info_hk_tds_mode( mode ); |
|
230 | 238 | } |
|
231 | 239 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
232 | 240 | { |
|
233 |
mode = ( |
|
|
241 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); | |
|
234 | 242 | status = check_update_info_hk_thr_mode( mode ); |
|
235 | 243 | } |
|
236 | 244 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
237 | 245 | { |
|
238 | 246 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
239 | 247 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
240 | 248 | val++; |
|
241 | 249 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
242 | 250 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
243 | 251 | } |
|
244 | 252 | |
|
245 | 253 | result = status; |
|
246 | 254 | |
|
247 | 255 | return result; |
|
248 | 256 | } |
|
249 | 257 | |
|
250 | 258 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
251 | 259 | { |
|
252 | 260 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
253 | 261 | * |
|
254 | 262 | * @param TC points to the TeleCommand packet that is being processed |
|
255 | 263 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
256 | 264 | * |
|
257 | 265 | */ |
|
258 | 266 | |
|
259 | 267 | int result; |
|
260 | 268 | unsigned char lfrMode; |
|
261 | 269 | |
|
262 | 270 | result = LFR_DEFAULT; |
|
263 | 271 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
264 | 272 | |
|
265 | 273 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
266 | 274 | result = LFR_DEFAULT; |
|
267 | 275 | |
|
268 | 276 | return result; |
|
269 | 277 | } |
|
270 | 278 | |
|
271 | 279 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
272 | 280 | { |
|
273 | 281 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
274 | 282 | * |
|
275 | 283 | * @param TC points to the TeleCommand packet that is being processed |
|
276 | 284 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
277 | 285 | * |
|
278 | 286 | */ |
|
279 | 287 | |
|
280 | 288 | int result; |
|
281 | 289 | unsigned char lfrMode; |
|
282 | 290 | |
|
283 | 291 | result = LFR_DEFAULT; |
|
284 | 292 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
285 | 293 | |
|
286 | 294 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
287 | 295 | result = LFR_DEFAULT; |
|
288 | 296 | |
|
289 | 297 | return result; |
|
290 | 298 | } |
|
291 | 299 | |
|
292 | 300 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
293 | 301 | { |
|
294 | 302 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
295 | 303 | * |
|
296 | 304 | * @param TC points to the TeleCommand packet that is being processed |
|
297 | 305 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
298 | 306 | * |
|
299 | 307 | * @return LFR_SUCCESSFUL |
|
300 | 308 | * |
|
301 | 309 | */ |
|
302 | 310 | |
|
303 | 311 | unsigned int val; |
|
304 | 312 | |
|
305 | 313 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
306 | 314 | + (TC->dataAndCRC[1] << 16) |
|
307 | 315 | + (TC->dataAndCRC[2] << 8) |
|
308 | 316 | + TC->dataAndCRC[3]; |
|
309 | 317 | |
|
310 | 318 | PRINTF1("time received: %x\n", time_management_regs->coarse_time_load) |
|
311 | 319 | |
|
312 | 320 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
313 | 321 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
314 | 322 | val++; |
|
315 | 323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
316 | 324 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
317 | 325 | // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick |
|
318 | 326 | |
|
319 | 327 | return LFR_SUCCESSFUL; |
|
320 | 328 | } |
|
321 | 329 | |
|
322 | 330 | //******************* |
|
323 | 331 | // ENTERING THE MODES |
|
324 | 332 | int check_mode_value( unsigned char requestedMode ) |
|
325 | 333 | { |
|
326 | 334 | int status; |
|
327 | 335 | |
|
328 | 336 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
329 | 337 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
330 | 338 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
331 | 339 | { |
|
332 | 340 | status = LFR_DEFAULT; |
|
333 | 341 | } |
|
334 | 342 | else |
|
335 | 343 | { |
|
336 | 344 | status = LFR_SUCCESSFUL; |
|
337 | 345 | } |
|
338 | 346 | |
|
339 | 347 | return status; |
|
340 | 348 | } |
|
341 | 349 | |
|
342 | 350 | int check_mode_transition( unsigned char requestedMode ) |
|
343 | 351 | { |
|
344 | 352 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
345 | 353 | * |
|
346 | 354 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
347 | 355 | * |
|
348 | 356 | * @return LFR directive status codes: |
|
349 | 357 | * - LFR_SUCCESSFUL - the transition is authorized |
|
350 | 358 | * - LFR_DEFAULT - the transition is not authorized |
|
351 | 359 | * |
|
352 | 360 | */ |
|
353 | 361 | |
|
354 | 362 | int status; |
|
355 | 363 | |
|
356 | 364 | switch (requestedMode) |
|
357 | 365 | { |
|
358 | 366 | case LFR_MODE_STANDBY: |
|
359 | 367 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
360 | 368 | status = LFR_DEFAULT; |
|
361 | 369 | } |
|
362 | 370 | else |
|
363 | 371 | { |
|
364 | 372 | status = LFR_SUCCESSFUL; |
|
365 | 373 | } |
|
366 | 374 | break; |
|
367 | 375 | case LFR_MODE_NORMAL: |
|
368 | 376 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
369 | 377 | status = LFR_DEFAULT; |
|
370 | 378 | } |
|
371 | 379 | else { |
|
372 | 380 | status = LFR_SUCCESSFUL; |
|
373 | 381 | } |
|
374 | 382 | break; |
|
375 | 383 | case LFR_MODE_BURST: |
|
376 | 384 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
377 | 385 | status = LFR_DEFAULT; |
|
378 | 386 | } |
|
379 | 387 | else { |
|
380 | 388 | status = LFR_SUCCESSFUL; |
|
381 | 389 | } |
|
382 | 390 | break; |
|
383 | 391 | case LFR_MODE_SBM1: |
|
384 | 392 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
385 | 393 | status = LFR_DEFAULT; |
|
386 | 394 | } |
|
387 | 395 | else { |
|
388 | 396 | status = LFR_SUCCESSFUL; |
|
389 | 397 | } |
|
390 | 398 | break; |
|
391 | 399 | case LFR_MODE_SBM2: |
|
392 | 400 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
393 | 401 | status = LFR_DEFAULT; |
|
394 | 402 | } |
|
395 | 403 | else { |
|
396 | 404 | status = LFR_SUCCESSFUL; |
|
397 | 405 | } |
|
398 | 406 | break; |
|
399 | 407 | default: |
|
400 | 408 | status = LFR_DEFAULT; |
|
401 | 409 | break; |
|
402 | 410 | } |
|
403 | 411 | |
|
404 | 412 | return status; |
|
405 | 413 | } |
|
406 | 414 | |
|
407 | 415 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
408 | 416 | { |
|
409 | 417 | int status; |
|
410 | 418 | unsigned int localCoarseTime; |
|
411 | 419 | unsigned int deltaCoarseTime; |
|
412 | 420 | |
|
413 | 421 | status = LFR_SUCCESSFUL; |
|
414 | 422 | |
|
415 | 423 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
416 | 424 | { |
|
417 | 425 | status = LFR_SUCCESSFUL; |
|
418 | 426 | } |
|
419 | 427 | else |
|
420 | 428 | { |
|
421 | 429 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
422 | 430 | |
|
423 | if ( transitionCoarseTime < localCoarseTime ) // SSS-CP-EQS-322 | |
|
431 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
|
424 | 432 | { |
|
425 | 433 | status = LFR_DEFAULT; |
|
426 | 434 | PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime) |
|
427 | 435 | } |
|
428 | 436 | |
|
429 | 437 | if (status == LFR_SUCCESSFUL) |
|
430 | 438 | { |
|
431 | 439 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
432 | 440 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
433 | 441 | { |
|
434 | 442 | status = LFR_DEFAULT; |
|
435 | 443 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
436 | 444 | } |
|
437 | 445 | } |
|
438 | 446 | } |
|
439 | 447 | |
|
440 | 448 | return status; |
|
441 | 449 | } |
|
442 | 450 | |
|
443 | 451 | int stop_current_mode( void ) |
|
444 | 452 | { |
|
445 | 453 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
446 | 454 | * |
|
447 | 455 | * @return RTEMS directive status codes: |
|
448 | 456 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
449 | 457 | * - RTEMS_INVALID_ID - task id invalid |
|
450 | 458 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
451 | 459 | * |
|
452 | 460 | */ |
|
453 | 461 | |
|
454 | 462 | rtems_status_code status; |
|
455 | 463 | |
|
456 | 464 | status = RTEMS_SUCCESSFUL; |
|
457 | 465 | |
|
458 | 466 | // (1) mask interruptions |
|
459 | 467 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
460 | 468 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
461 | 469 | |
|
462 | 470 | // (2) clear interruptions |
|
463 | 471 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
464 | 472 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
465 | 473 | |
|
466 | 474 | // (3) reset waveform picker registers |
|
467 | 475 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
468 | 476 | reset_wfp_status(); // reset all the status bits |
|
469 | 477 | |
|
470 | 478 | // (4) reset spectral matrices registers |
|
471 | 479 | set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices |
|
472 | 480 | set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0 |
|
473 | 481 | reset_extractSWF(); // reset the extractSWF flag to false |
|
474 | 482 | |
|
475 | 483 | // <Spectral Matrices simulator> |
|
476 | 484 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
477 | 485 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
478 | 486 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
479 | 487 | // </Spectral Matrices simulator> |
|
480 | 488 | |
|
481 | 489 | // suspend several tasks |
|
482 | 490 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
483 | 491 | status = suspend_science_tasks(); |
|
484 | 492 | } |
|
485 | 493 | |
|
486 | 494 | if (status != RTEMS_SUCCESSFUL) |
|
487 | 495 | { |
|
488 | 496 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
489 | 497 | } |
|
490 | 498 | |
|
491 | 499 | return status; |
|
492 | 500 | } |
|
493 | 501 | |
|
494 | 502 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) |
|
495 | 503 | { |
|
496 | 504 | /** This function is launched after a mode transition validation. |
|
497 | 505 | * |
|
498 | 506 | * @param mode is the mode in which LFR will be put. |
|
499 | 507 | * |
|
500 | 508 | * @return RTEMS directive status codes: |
|
501 | 509 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
502 | 510 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
503 | 511 | * |
|
504 | 512 | */ |
|
505 | 513 | |
|
506 | 514 | rtems_status_code status; |
|
507 | 515 | |
|
508 | 516 | //********************** |
|
509 | 517 | // STOP THE CURRENT MODE |
|
510 | 518 | status = stop_current_mode(); |
|
511 | 519 | if (status != RTEMS_SUCCESSFUL) |
|
512 | 520 | { |
|
513 | 521 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) |
|
514 | 522 | } |
|
515 | 523 | |
|
516 | 524 | //************************* |
|
517 | 525 | // ENTER THE REQUESTED MODE |
|
518 | 526 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) |
|
519 | 527 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) |
|
520 | 528 | { |
|
521 | 529 | #ifdef PRINT_TASK_STATISTICS |
|
522 | 530 | rtems_cpu_usage_reset(); |
|
523 | 531 | maxCount = 0; |
|
524 | 532 | #endif |
|
525 | 533 | status = restart_science_tasks(); |
|
526 | 534 | launch_waveform_picker( mode, transitionCoarseTime ); |
|
527 | 535 | // launch_spectral_matrix( mode ); |
|
528 | 536 | } |
|
529 | 537 | else if ( mode == LFR_MODE_STANDBY ) |
|
530 | 538 | { |
|
531 | 539 | #ifdef PRINT_TASK_STATISTICS |
|
532 | 540 | rtems_cpu_usage_report(); |
|
533 | 541 | #endif |
|
534 | 542 | |
|
535 | 543 | #ifdef PRINT_STACK_REPORT |
|
536 | 544 | rtems_stack_checker_report_usage(); |
|
537 | 545 | #endif |
|
538 | 546 | PRINTF1("maxCount = %d\n", maxCount) |
|
539 | 547 | } |
|
540 | 548 | else |
|
541 | 549 | { |
|
542 | 550 | status = RTEMS_UNSATISFIED; |
|
543 | 551 | } |
|
544 | 552 | |
|
545 | 553 | if (status != RTEMS_SUCCESSFUL) |
|
546 | 554 | { |
|
547 | 555 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) |
|
548 | 556 | status = RTEMS_UNSATISFIED; |
|
549 | 557 | } |
|
550 | 558 | |
|
551 | 559 | return status; |
|
552 | 560 | } |
|
553 | 561 | |
|
554 | 562 | int restart_science_tasks() |
|
555 | 563 | { |
|
556 | 564 | /** This function is used to restart all science tasks. |
|
557 | 565 | * |
|
558 | 566 | * @return RTEMS directive status codes: |
|
559 | 567 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
560 | 568 | * - RTEMS_INVALID_ID - task id invalid |
|
561 | 569 | * - RTEMS_INCORRECT_STATE - task never started |
|
562 | 570 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
563 | 571 | * |
|
564 | 572 | * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1 |
|
565 | 573 | * |
|
566 | 574 | */ |
|
567 | 575 | |
|
568 | 576 | rtems_status_code status[6]; |
|
569 | 577 | rtems_status_code ret; |
|
570 | 578 | |
|
571 | 579 | ret = RTEMS_SUCCESSFUL; |
|
572 | 580 | |
|
573 | 581 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 ); |
|
574 | 582 | if (status[0] != RTEMS_SUCCESSFUL) |
|
575 | 583 | { |
|
576 | 584 | PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0]) |
|
577 | 585 | } |
|
578 | 586 | |
|
579 | 587 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
580 | 588 | if (status[2] != RTEMS_SUCCESSFUL) |
|
581 | 589 | { |
|
582 | 590 | PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2]) |
|
583 | 591 | } |
|
584 | 592 | |
|
585 | 593 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
586 | 594 | if (status[3] != RTEMS_SUCCESSFUL) |
|
587 | 595 | { |
|
588 | 596 | PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3]) |
|
589 | 597 | } |
|
590 | 598 | |
|
591 | 599 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
592 | 600 | if (status[4] != RTEMS_SUCCESSFUL) |
|
593 | 601 | { |
|
594 | 602 | PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4]) |
|
595 | 603 | } |
|
596 | 604 | |
|
597 | 605 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
598 | 606 | if (status[5] != RTEMS_SUCCESSFUL) |
|
599 | 607 | { |
|
600 | 608 | PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5]) |
|
601 | 609 | } |
|
602 | 610 | |
|
603 | 611 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || |
|
604 | 612 | (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) |
|
605 | 613 | { |
|
606 | 614 | ret = RTEMS_UNSATISFIED; |
|
607 | 615 | } |
|
608 | 616 | |
|
609 | 617 | return ret; |
|
610 | 618 | } |
|
611 | 619 | |
|
612 | 620 | int suspend_science_tasks() |
|
613 | 621 | { |
|
614 | 622 | /** This function suspends the science tasks. |
|
615 | 623 | * |
|
616 | 624 | * @return RTEMS directive status codes: |
|
617 | 625 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
618 | 626 | * - RTEMS_INVALID_ID - task id invalid |
|
619 | 627 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
620 | 628 | * |
|
621 | 629 | */ |
|
622 | 630 | |
|
623 | 631 | rtems_status_code status; |
|
624 | 632 | |
|
625 | 633 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); |
|
626 | 634 | if (status != RTEMS_SUCCESSFUL) |
|
627 | 635 | { |
|
628 | 636 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
629 | 637 | } |
|
630 | 638 | |
|
631 | 639 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
632 | 640 | { |
|
633 | 641 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
634 | 642 | if (status != RTEMS_SUCCESSFUL) |
|
635 | 643 | { |
|
636 | 644 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
637 | 645 | } |
|
638 | 646 | } |
|
639 | 647 | |
|
640 | 648 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
641 | 649 | { |
|
642 | 650 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
643 | 651 | if (status != RTEMS_SUCCESSFUL) |
|
644 | 652 | { |
|
645 | 653 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
646 | 654 | } |
|
647 | 655 | } |
|
648 | 656 | |
|
649 | 657 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
650 | 658 | { |
|
651 | 659 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
652 | 660 | if (status != RTEMS_SUCCESSFUL) |
|
653 | 661 | { |
|
654 | 662 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
655 | 663 | } |
|
656 | 664 | } |
|
657 | 665 | |
|
658 | 666 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
659 | 667 | { |
|
660 | 668 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
661 | 669 | if (status != RTEMS_SUCCESSFUL) |
|
662 | 670 | { |
|
663 | 671 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
664 | 672 | } |
|
665 | 673 | } |
|
666 | 674 | |
|
667 | 675 | return status; |
|
668 | 676 | } |
|
669 | 677 | |
|
670 | 678 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
671 | 679 | { |
|
672 | 680 | reset_current_ring_nodes(); |
|
673 | 681 | reset_waveform_picker_regs(); |
|
674 | 682 | set_wfp_burst_enable_register( mode ); |
|
675 | 683 | |
|
676 | 684 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
677 | 685 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
678 | 686 | |
|
679 | 687 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000] |
|
680 | 688 | if (transitionCoarseTime == 0) |
|
681 | 689 | { |
|
682 | 690 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
683 | 691 | } |
|
684 | 692 | else |
|
685 | 693 | { |
|
686 | 694 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
687 | 695 | } |
|
688 | 696 | } |
|
689 | 697 | |
|
690 | 698 | void launch_spectral_matrix( unsigned char mode ) |
|
691 | 699 | { |
|
692 | 700 | reset_nb_sm_f0(); |
|
693 | 701 | reset_current_sm_ring_nodes(); |
|
694 | 702 | reset_spectral_matrix_regs(); |
|
695 | 703 | |
|
696 | 704 | #ifdef VHDL_DEV |
|
697 | 705 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
698 | 706 | grgpio_regs->io_port_direction_register = |
|
699 | 707 | grgpio_regs->io_port_direction_register | 0x01; // [0001 1000], 0 = output disabled, 1 = output enabled |
|
700 | 708 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x00; // set the bit 0 to 1 |
|
701 | 709 | set_irq_on_new_ready_matrix( 1 ); |
|
702 | 710 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
703 | 711 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
704 | 712 | set_run_matrix_spectral( 1 ); |
|
705 | 713 | #else |
|
706 | 714 | // Spectral Matrices simulator |
|
707 | 715 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
708 | 716 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); |
|
709 | 717 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); |
|
710 | 718 | #endif |
|
711 | 719 | } |
|
712 | 720 | |
|
713 | 721 | void set_irq_on_new_ready_matrix( unsigned char value ) |
|
714 | 722 | { |
|
715 | 723 | if (value == 1) |
|
716 | 724 | { |
|
717 | 725 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
718 | 726 | } |
|
719 | 727 | else |
|
720 | 728 | { |
|
721 | 729 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
722 | 730 | } |
|
723 | 731 | } |
|
724 | 732 | |
|
725 | 733 | void set_run_matrix_spectral( unsigned char value ) |
|
726 | 734 | { |
|
727 | 735 | if (value == 1) |
|
728 | 736 | { |
|
729 | 737 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1 |
|
730 | 738 | } |
|
731 | 739 | else |
|
732 | 740 | { |
|
733 | 741 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0 |
|
734 | 742 | } |
|
735 | 743 | } |
|
736 | 744 | |
|
737 | 745 | void launch_spectral_matrix_simu( unsigned char mode ) |
|
738 | 746 | { |
|
739 | 747 | reset_nb_sm_f0(); |
|
740 | 748 | reset_current_sm_ring_nodes(); |
|
741 | 749 | reset_spectral_matrix_regs(); |
|
742 | 750 | |
|
743 | 751 | // Spectral Matrices simulator |
|
744 | 752 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
745 | 753 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); |
|
746 | 754 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); |
|
747 | 755 | set_local_nb_interrupt_f0_MAX(); |
|
748 | 756 | } |
|
749 | 757 | |
|
750 | 758 | //**************** |
|
751 | 759 | // CLOSING ACTIONS |
|
752 | 760 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
753 | 761 | { |
|
754 | 762 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
755 | 763 | * |
|
756 | 764 | * @param TC points to the TC being processed |
|
757 | 765 | * @param time is the time used to date the TC execution |
|
758 | 766 | * |
|
759 | 767 | */ |
|
760 | 768 | |
|
761 | 769 | unsigned int val; |
|
762 | 770 | |
|
763 | 771 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
764 | 772 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
765 | 773 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
766 | 774 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
767 | 775 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
768 | 776 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
769 | 777 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
770 | 778 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
771 | 779 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
772 | 780 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
773 | 781 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
774 | 782 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
775 | 783 | |
|
776 | 784 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
777 | 785 | val++; |
|
778 | 786 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
779 | 787 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
780 | 788 | } |
|
781 | 789 | |
|
782 | 790 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
783 | 791 | { |
|
784 | 792 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
785 | 793 | * |
|
786 | 794 | * @param TC points to the TC being processed |
|
787 | 795 | * @param time is the time used to date the TC rejection |
|
788 | 796 | * |
|
789 | 797 | */ |
|
790 | 798 | |
|
791 | 799 | unsigned int val; |
|
792 | 800 | |
|
793 | 801 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
794 | 802 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
795 | 803 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
796 | 804 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
797 | 805 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
798 | 806 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
799 | 807 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
800 | 808 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
801 | 809 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
802 | 810 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
803 | 811 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
804 | 812 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
805 | 813 | |
|
806 | 814 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
807 | 815 | val++; |
|
808 | 816 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
809 | 817 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
810 | 818 | } |
|
811 | 819 | |
|
812 | 820 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
813 | 821 | { |
|
814 | 822 | /** This function is the last step of the TC execution workflow. |
|
815 | 823 | * |
|
816 | 824 | * @param TC points to the TC being processed |
|
817 | 825 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
818 | 826 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
819 | 827 | * @param time is the time used to date the TC execution |
|
820 | 828 | * |
|
821 | 829 | */ |
|
822 | 830 | |
|
823 | 831 | unsigned char requestedMode; |
|
824 | 832 | |
|
825 | 833 | if (result == LFR_SUCCESSFUL) |
|
826 | 834 | { |
|
827 | 835 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
828 | 836 | & |
|
829 | 837 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
830 | 838 | ) |
|
831 | 839 | { |
|
832 | 840 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
833 | 841 | } |
|
834 | 842 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
835 | 843 | { |
|
836 | 844 | //********************************** |
|
837 | 845 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
838 | 846 | requestedMode = TC->dataAndCRC[1]; |
|
839 | 847 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
840 | 848 | updateLFRCurrentMode(); |
|
841 | 849 | } |
|
842 | 850 | } |
|
851 | else | |
|
852 | { | |
|
853 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
|
854 | } | |
|
843 | 855 | } |
|
844 | 856 | |
|
845 | 857 | //*************************** |
|
846 | 858 | // Interrupt Service Routines |
|
847 | 859 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
848 | 860 | { |
|
849 | 861 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
850 | 862 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
851 | 863 | } |
|
852 | 864 | } |
|
853 | 865 | |
|
854 | 866 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
855 | 867 | { |
|
856 | 868 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
857 | 869 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
858 | 870 | } |
|
859 | 871 | } |
|
860 | 872 | |
|
861 | 873 | //**************** |
|
862 | 874 | // OTHER FUNCTIONS |
|
863 | 875 | void updateLFRCurrentMode() |
|
864 | 876 | { |
|
865 | 877 | /** This function updates the value of the global variable lfrCurrentMode. |
|
866 | 878 | * |
|
867 | 879 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
868 | 880 | * |
|
869 | 881 | */ |
|
870 | 882 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
871 | 883 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
872 | 884 | } |
|
873 | 885 |
@@ -1,539 +1,539 | |||
|
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( ); |
|
29 | 29 | return LFR_SUCCESSFUL; |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 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 | rtems_status_code status; |
|
44 | 44 | |
|
45 | 45 | flag = LFR_SUCCESSFUL; |
|
46 | 46 | |
|
47 | 47 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
48 | 48 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
49 | 49 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
50 | 50 | flag = LFR_DEFAULT; |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | 53 | //*************** |
|
54 | 54 | // sy_lfr_n_swf_l |
|
55 | 55 | if (flag == LFR_SUCCESSFUL) |
|
56 | 56 | { |
|
57 | 57 | result = set_sy_lfr_n_swf_l( TC, queue_id, time ); |
|
58 | 58 | if (result != LFR_SUCCESSFUL) |
|
59 | 59 | { |
|
60 | 60 | flag = LFR_DEFAULT; |
|
61 | 61 | } |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | //*************** |
|
65 | 65 | // sy_lfr_n_swf_p |
|
66 | 66 | if (flag == LFR_SUCCESSFUL) |
|
67 | 67 | { |
|
68 | 68 | result = set_sy_lfr_n_swf_p( TC, queue_id, time ); |
|
69 | 69 | if (result != LFR_SUCCESSFUL) |
|
70 | 70 | { |
|
71 | 71 | flag = LFR_DEFAULT; |
|
72 | 72 | } |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | //*************** |
|
76 | 76 | // sy_lfr_n_asm_p |
|
77 | 77 | if (flag == LFR_SUCCESSFUL) |
|
78 | 78 | { |
|
79 | 79 | result = set_sy_lfr_n_asm_p( TC, queue_id ); |
|
80 | 80 | if (result != LFR_SUCCESSFUL) |
|
81 | 81 | { |
|
82 | 82 | flag = LFR_DEFAULT; |
|
83 | 83 | } |
|
84 | 84 | } |
|
85 | 85 | |
|
86 | 86 | //*************** |
|
87 | 87 | // sy_lfr_n_bp_p0 |
|
88 | 88 | if (flag == LFR_SUCCESSFUL) |
|
89 | 89 | { |
|
90 | 90 | result = set_sy_lfr_n_bp_p0( TC, queue_id ); |
|
91 | 91 | if (result != LFR_SUCCESSFUL) |
|
92 | 92 | { |
|
93 | 93 | flag = LFR_DEFAULT; |
|
94 | 94 | } |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | //*************** |
|
98 | 98 | // sy_lfr_n_bp_p1 |
|
99 | 99 | if (flag == LFR_SUCCESSFUL) |
|
100 | 100 | { |
|
101 | 101 | result = set_sy_lfr_n_bp_p1( TC, queue_id ); |
|
102 | 102 | if (result != LFR_SUCCESSFUL) |
|
103 | 103 | { |
|
104 | 104 | flag = LFR_DEFAULT; |
|
105 | 105 | } |
|
106 | 106 | } |
|
107 | 107 | |
|
108 | 108 | //********************* |
|
109 | 109 | // sy_lfr_n_cwf_long_f3 |
|
110 | 110 | if (flag == LFR_SUCCESSFUL) |
|
111 | 111 | { |
|
112 | 112 | result = set_sy_lfr_n_cwf_long_f3( TC, queue_id ); |
|
113 | 113 | if (result != LFR_SUCCESSFUL) |
|
114 | 114 | { |
|
115 | 115 | flag = LFR_DEFAULT; |
|
116 | 116 | } |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | return flag; |
|
120 | 120 | } |
|
121 | 121 | |
|
122 | 122 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
123 | 123 | { |
|
124 | 124 | /** This function updates the LFR registers with the incoming burst parameters. |
|
125 | 125 | * |
|
126 | 126 | * @param TC points to the TeleCommand packet that is being processed |
|
127 | 127 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
128 | 128 | * |
|
129 | 129 | */ |
|
130 | 130 | |
|
131 | 131 | int result; |
|
132 | 132 | unsigned char lfrMode; |
|
133 | 133 | rtems_status_code status; |
|
134 | 134 | |
|
135 | 135 | result = LFR_DEFAULT; |
|
136 | 136 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
137 | 137 | |
|
138 | 138 | if ( lfrMode == LFR_MODE_BURST ) { |
|
139 | 139 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
140 | 140 | result = LFR_DEFAULT; |
|
141 | 141 | } |
|
142 | 142 | else { |
|
143 | 143 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0]; |
|
144 | 144 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1]; |
|
145 | 145 | |
|
146 | 146 | result = LFR_SUCCESSFUL; |
|
147 | 147 | } |
|
148 | 148 | |
|
149 | 149 | return result; |
|
150 | 150 | } |
|
151 | 151 | |
|
152 | 152 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
153 | 153 | { |
|
154 | 154 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
155 | 155 | * |
|
156 | 156 | * @param TC points to the TeleCommand packet that is being processed |
|
157 | 157 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
158 | 158 | * |
|
159 | 159 | */ |
|
160 | 160 | int result; |
|
161 | 161 | unsigned char lfrMode; |
|
162 | 162 | rtems_status_code status; |
|
163 | 163 | |
|
164 | 164 | result = LFR_DEFAULT; |
|
165 | 165 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
166 | 166 | |
|
167 |
if ( |
|
|
167 | if ( lfrMode == LFR_MODE_SBM1 ) { | |
|
168 | 168 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
169 | 169 | result = LFR_DEFAULT; |
|
170 | 170 | } |
|
171 | 171 | else { |
|
172 | 172 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0]; |
|
173 | 173 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1]; |
|
174 | 174 | |
|
175 | 175 | result = LFR_SUCCESSFUL; |
|
176 | 176 | } |
|
177 | 177 | |
|
178 | 178 | return result; |
|
179 | 179 | } |
|
180 | 180 | |
|
181 | 181 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
182 | 182 | { |
|
183 | 183 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
184 | 184 | * |
|
185 | 185 | * @param TC points to the TeleCommand packet that is being processed |
|
186 | 186 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
187 | 187 | * |
|
188 | 188 | */ |
|
189 | 189 | |
|
190 | 190 | int result; |
|
191 | 191 | unsigned char lfrMode; |
|
192 | 192 | rtems_status_code status; |
|
193 | 193 | |
|
194 | 194 | result = LFR_DEFAULT; |
|
195 | 195 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
196 | 196 | |
|
197 |
if ( |
|
|
197 | if ( lfrMode == LFR_MODE_SBM2 ) { | |
|
198 | 198 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
199 | 199 | result = LFR_DEFAULT; |
|
200 | 200 | } |
|
201 | 201 | else { |
|
202 | 202 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0]; |
|
203 | 203 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1]; |
|
204 | 204 | |
|
205 | 205 | result = LFR_SUCCESSFUL; |
|
206 | 206 | } |
|
207 | 207 | |
|
208 | 208 | return result; |
|
209 | 209 | } |
|
210 | 210 | |
|
211 | 211 | int action_dump_par( rtems_id queue_id ) |
|
212 | 212 | { |
|
213 | 213 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
214 | 214 | * |
|
215 | 215 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
216 | 216 | * |
|
217 | 217 | * @return RTEMS directive status codes: |
|
218 | 218 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
219 | 219 | * - RTEMS_INVALID_ID - invalid queue id |
|
220 | 220 | * - RTEMS_INVALID_SIZE - invalid message size |
|
221 | 221 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
222 | 222 | * - RTEMS_UNSATISFIED - out of message buffers |
|
223 | 223 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
224 | 224 | * |
|
225 | 225 | */ |
|
226 | 226 | |
|
227 | 227 | int status; |
|
228 | 228 | |
|
229 | 229 | // UPDATE TIME |
|
230 | 230 | increment_seq_counter( parameter_dump_packet.packetSequenceControl ); |
|
231 | 231 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
232 | 232 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
233 | 233 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
234 | 234 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
235 | 235 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
236 | 236 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
237 | 237 | // SEND DATA |
|
238 | 238 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
239 | 239 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
240 | 240 | if (status != RTEMS_SUCCESSFUL) { |
|
241 | 241 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
242 | 242 | } |
|
243 | 243 | |
|
244 | 244 | return status; |
|
245 | 245 | } |
|
246 | 246 | |
|
247 | 247 | //*********************** |
|
248 | 248 | // NORMAL MODE PARAMETERS |
|
249 | 249 | |
|
250 | 250 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) |
|
251 | 251 | { |
|
252 | 252 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
253 | 253 | * |
|
254 | 254 | * @param TC points to the TeleCommand packet that is being processed |
|
255 | 255 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
256 | 256 | * |
|
257 | 257 | */ |
|
258 | 258 | |
|
259 | 259 | unsigned int tmp; |
|
260 | 260 | int result; |
|
261 | 261 | unsigned char msb; |
|
262 | 262 | unsigned char lsb; |
|
263 | 263 | rtems_status_code status; |
|
264 | 264 | |
|
265 | 265 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ]; |
|
266 | 266 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ]; |
|
267 | 267 | |
|
268 | 268 | tmp = ( unsigned int ) floor( |
|
269 | 269 | ( ( msb*256 ) + lsb ) / 16 |
|
270 | 270 | ) * 16; |
|
271 | 271 | |
|
272 | 272 | if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16 |
|
273 | 273 | { // 2048 is the maximum limit due to the size of the buffers |
|
274 | 274 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb ); |
|
275 | 275 | result = WRONG_APP_DATA; |
|
276 | 276 | } |
|
277 | 277 | else if (tmp != 2048) |
|
278 | 278 | { |
|
279 | 279 | status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
280 | 280 | result = FUNCT_NOT_IMPL; |
|
281 | 281 | } |
|
282 | 282 | else |
|
283 | 283 | { |
|
284 | 284 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8); |
|
285 | 285 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp ); |
|
286 | 286 | result = LFR_SUCCESSFUL; |
|
287 | 287 | } |
|
288 | 288 | |
|
289 | 289 | return result; |
|
290 | 290 | } |
|
291 | 291 | |
|
292 | 292 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time) |
|
293 | 293 | { |
|
294 | 294 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
295 | 295 | * |
|
296 | 296 | * @param TC points to the TeleCommand packet that is being processed |
|
297 | 297 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
298 | 298 | * |
|
299 | 299 | */ |
|
300 | 300 | |
|
301 | 301 | unsigned int tmp; |
|
302 | 302 | int result; |
|
303 | 303 | unsigned char msb; |
|
304 | 304 | unsigned char lsb; |
|
305 | 305 | rtems_status_code status; |
|
306 | 306 | |
|
307 | 307 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ]; |
|
308 | 308 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ]; |
|
309 | 309 | |
|
310 | 310 | tmp = msb * 256 + lsb; |
|
311 | 311 | |
|
312 | 312 | if ( tmp < 16 ) |
|
313 | 313 | { |
|
314 | 314 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb ); |
|
315 | 315 | result = WRONG_APP_DATA; |
|
316 | 316 | } |
|
317 | 317 | else |
|
318 | 318 | { |
|
319 | 319 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8); |
|
320 | 320 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp ); |
|
321 | 321 | result = LFR_SUCCESSFUL; |
|
322 | 322 | } |
|
323 | 323 | |
|
324 | 324 | return result; |
|
325 | 325 | } |
|
326 | 326 | |
|
327 | 327 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
328 | 328 | { |
|
329 | 329 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
330 | 330 | * |
|
331 | 331 | * @param TC points to the TeleCommand packet that is being processed |
|
332 | 332 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
333 | 333 | * |
|
334 | 334 | */ |
|
335 | 335 | |
|
336 | 336 | int result; |
|
337 | 337 | unsigned char msb; |
|
338 | 338 | unsigned char lsb; |
|
339 | 339 | |
|
340 | 340 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ]; |
|
341 | 341 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ]; |
|
342 | 342 | |
|
343 | 343 | parameter_dump_packet.sy_lfr_n_asm_p[0] = msb; |
|
344 | 344 | parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb; |
|
345 | 345 | result = LFR_SUCCESSFUL; |
|
346 | 346 | |
|
347 | 347 | return result; |
|
348 | 348 | } |
|
349 | 349 | |
|
350 | 350 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
351 | 351 | { |
|
352 | 352 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0). |
|
353 | 353 | * |
|
354 | 354 | * @param TC points to the TeleCommand packet that is being processed |
|
355 | 355 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
356 | 356 | * |
|
357 | 357 | */ |
|
358 | 358 | |
|
359 | 359 | int status; |
|
360 | 360 | |
|
361 | 361 | status = LFR_SUCCESSFUL; |
|
362 | 362 | |
|
363 | 363 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ]; |
|
364 | 364 | |
|
365 | 365 | return status; |
|
366 | 366 | } |
|
367 | 367 | |
|
368 | 368 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
369 | 369 | { |
|
370 | 370 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
371 | 371 | * |
|
372 | 372 | * @param TC points to the TeleCommand packet that is being processed |
|
373 | 373 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
374 | 374 | * |
|
375 | 375 | */ |
|
376 | 376 | |
|
377 | 377 | int status; |
|
378 | 378 | |
|
379 | 379 | status = LFR_SUCCESSFUL; |
|
380 | 380 | |
|
381 | 381 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ]; |
|
382 | 382 | |
|
383 | 383 | return status; |
|
384 | 384 | } |
|
385 | 385 | |
|
386 | 386 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
387 | 387 | { |
|
388 | 388 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
389 | 389 | * |
|
390 | 390 | * @param TC points to the TeleCommand packet that is being processed |
|
391 | 391 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
392 | 392 | * |
|
393 | 393 | */ |
|
394 | 394 | |
|
395 | 395 | int status; |
|
396 | 396 | |
|
397 | 397 | status = LFR_SUCCESSFUL; |
|
398 | 398 | |
|
399 | 399 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
400 | 400 | |
|
401 | 401 | return status; |
|
402 | 402 | } |
|
403 | 403 | |
|
404 | 404 | //********************** |
|
405 | 405 | // BURST MODE PARAMETERS |
|
406 | 406 | |
|
407 | 407 | //********************* |
|
408 | 408 | // SBM1 MODE PARAMETERS |
|
409 | 409 | |
|
410 | 410 | //********************* |
|
411 | 411 | // SBM2 MODE PARAMETERS |
|
412 | 412 | |
|
413 | 413 | //******************* |
|
414 | 414 | // TC_LFR_UPDATE_INFO |
|
415 | 415 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
416 | 416 | { |
|
417 | 417 | unsigned int status; |
|
418 | 418 | |
|
419 | 419 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
420 | 420 | || (mode == LFR_MODE_BURST) |
|
421 | 421 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
422 | 422 | { |
|
423 | 423 | status = LFR_SUCCESSFUL; |
|
424 | 424 | } |
|
425 | 425 | else |
|
426 | 426 | { |
|
427 | 427 | status = LFR_DEFAULT; |
|
428 | 428 | } |
|
429 | 429 | |
|
430 | 430 | return status; |
|
431 | 431 | } |
|
432 | 432 | |
|
433 | 433 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
434 | 434 | { |
|
435 | 435 | unsigned int status; |
|
436 | 436 | |
|
437 | 437 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
438 | 438 | || (mode == TDS_MODE_BURST) |
|
439 | 439 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
440 | 440 | || (mode == TDS_MODE_LFM)) |
|
441 | 441 | { |
|
442 | 442 | status = LFR_SUCCESSFUL; |
|
443 | 443 | } |
|
444 | 444 | else |
|
445 | 445 | { |
|
446 | 446 | status = LFR_DEFAULT; |
|
447 | 447 | } |
|
448 | 448 | |
|
449 | 449 | return status; |
|
450 | 450 | } |
|
451 | 451 | |
|
452 | 452 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
453 | 453 | { |
|
454 | 454 | unsigned int status; |
|
455 | 455 | |
|
456 | 456 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
457 | 457 | || (mode == THR_MODE_BURST)) |
|
458 | 458 | { |
|
459 | 459 | status = LFR_SUCCESSFUL; |
|
460 | 460 | } |
|
461 | 461 | else |
|
462 | 462 | { |
|
463 | 463 | status = LFR_DEFAULT; |
|
464 | 464 | } |
|
465 | 465 | |
|
466 | 466 | return status; |
|
467 | 467 | } |
|
468 | 468 | |
|
469 | 469 | //********** |
|
470 | 470 | // init dump |
|
471 | 471 | |
|
472 | 472 | void init_parameter_dump( void ) |
|
473 | 473 | { |
|
474 | 474 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
475 | 475 | * |
|
476 | 476 | */ |
|
477 | 477 | |
|
478 | 478 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
479 | 479 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
480 | 480 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
481 | 481 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
482 | 482 | parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8); |
|
483 | 483 | parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP; |
|
484 | 484 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
485 | 485 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
486 | 486 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
487 | 487 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
488 | 488 | // DATA FIELD HEADER |
|
489 | 489 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
490 | 490 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
491 | 491 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
492 | 492 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
493 | 493 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
494 | 494 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
495 | 495 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
496 | 496 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
497 | 497 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
498 | 498 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
499 | 499 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
500 | 500 | |
|
501 | 501 | //****************** |
|
502 | 502 | // COMMON PARAMETERS |
|
503 | 503 | parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0; |
|
504 | 504 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1; |
|
505 | 505 | |
|
506 | 506 | //****************** |
|
507 | 507 | // NORMAL PARAMETERS |
|
508 | 508 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8); |
|
509 | 509 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L ); |
|
510 | 510 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8); |
|
511 | 511 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P ); |
|
512 | 512 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8); |
|
513 | 513 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P ); |
|
514 | 514 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0; |
|
515 | 515 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1; |
|
516 | 516 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3; |
|
517 | 517 | |
|
518 | 518 | //***************** |
|
519 | 519 | // BURST PARAMETERS |
|
520 | 520 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
521 | 521 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
522 | 522 | |
|
523 | 523 | //**************** |
|
524 | 524 | // SBM1 PARAMETERS |
|
525 | 525 | 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 |
|
526 | 526 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
527 | 527 | |
|
528 | 528 | //**************** |
|
529 | 529 | // SBM2 PARAMETERS |
|
530 | 530 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
531 | 531 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
532 | 532 | } |
|
533 | 533 | |
|
534 | 534 | |
|
535 | 535 | |
|
536 | 536 | |
|
537 | 537 | |
|
538 | 538 | |
|
539 | 539 |
@@ -1,511 +1,511 | |||
|
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 ) |
|
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] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
55 | 55 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
56 | 56 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
57 | 57 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
58 | 58 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
59 | 59 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
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 | // UPDATE HK FIELDS |
|
75 | 75 | update_last_TC_exe( TC, TM.time ); |
|
76 | 76 | |
|
77 | 77 | return status; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, |
|
81 | 81 | unsigned char byte_position, unsigned char rcv_value ) |
|
82 | 82 | { |
|
83 | 83 | /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue. |
|
84 | 84 | * |
|
85 | 85 | * @param TC points to the TeleCommand packet that is being processed |
|
86 | 86 | * @param queue_id is the id of the queue which handles TM |
|
87 | 87 | * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent |
|
88 | 88 | * @param rcv_value is the value of the LSB of the parameter that has been deteced as inconsistent |
|
89 | 89 | * |
|
90 | 90 | * @return RTEMS directive status code: |
|
91 | 91 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
92 | 92 | * - RTEMS_INVALID_ID - invalid queue id |
|
93 | 93 | * - RTEMS_INVALID_SIZE - invalid message size |
|
94 | 94 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
95 | 95 | * - RTEMS_UNSATISFIED - out of message buffers |
|
96 | 96 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
97 | 97 | * |
|
98 | 98 | */ |
|
99 | 99 | |
|
100 | 100 | rtems_status_code status; |
|
101 | 101 | Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM; |
|
102 | 102 | unsigned char messageSize; |
|
103 | 103 | |
|
104 | 104 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
105 | 105 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
106 | 106 | TM.reserved = DEFAULT_RESERVED; |
|
107 | 107 | TM.userApplication = CCSDS_USER_APP; |
|
108 | 108 | // PACKET HEADER |
|
109 | 109 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); |
|
110 | 110 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); |
|
111 | 111 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
112 | 112 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8); |
|
113 | 113 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT ); |
|
114 | 114 | // DATA FIELD HEADER |
|
115 | 115 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
116 | 116 | TM.serviceType = TM_TYPE_TC_EXE; |
|
117 | 117 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
118 | 118 | TM.destinationID = TC->sourceID; |
|
119 | 119 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
120 | 120 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
121 | 121 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
122 | 122 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
123 | 123 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
124 | 124 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
125 | 125 | // |
|
126 | 126 | TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> 8); |
|
127 | 127 | TM.tc_failure_code[1] = (char) (WRONG_APP_DATA ); |
|
128 | 128 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
129 | 129 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
130 | 130 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
131 | 131 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
132 | 132 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
133 | 133 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
134 | 134 | TM.byte_position = byte_position; |
|
135 | 135 | TM.rcv_value = rcv_value; |
|
136 | 136 | |
|
137 | 137 | messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
138 | 138 | |
|
139 | 139 | // SEND DATA |
|
140 | 140 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
141 | 141 | if (status != RTEMS_SUCCESSFUL) { |
|
142 | 142 | PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n") |
|
143 | 143 | } |
|
144 | 144 | |
|
145 | 145 | // UPDATE HK FIELDS |
|
146 | 146 | update_last_TC_rej( TC, TM.time ); |
|
147 | 147 | |
|
148 | 148 | return status; |
|
149 | 149 | } |
|
150 | 150 | |
|
151 | 151 | int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
152 | 152 | { |
|
153 | 153 | /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue. |
|
154 | 154 | * |
|
155 | 155 | * @param TC points to the TeleCommand packet that is being processed |
|
156 | 156 | * @param queue_id is the id of the queue which handles TM |
|
157 | 157 | * |
|
158 | 158 | * @return RTEMS directive status code: |
|
159 | 159 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
160 | 160 | * - RTEMS_INVALID_ID - invalid queue id |
|
161 | 161 | * - RTEMS_INVALID_SIZE - invalid message size |
|
162 | 162 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
163 | 163 | * - RTEMS_UNSATISFIED - out of message buffers |
|
164 | 164 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
165 | 165 | * |
|
166 | 166 | */ |
|
167 | 167 | |
|
168 | 168 | rtems_status_code status; |
|
169 | 169 | Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM; |
|
170 | 170 | unsigned char messageSize; |
|
171 | 171 | |
|
172 | 172 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
173 | 173 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
174 | 174 | TM.reserved = DEFAULT_RESERVED; |
|
175 | 175 | TM.userApplication = CCSDS_USER_APP; |
|
176 | 176 | // PACKET HEADER |
|
177 | 177 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); |
|
178 | 178 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); |
|
179 | 179 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
180 | 180 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8); |
|
181 | 181 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE ); |
|
182 | 182 | // DATA FIELD HEADER |
|
183 | 183 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
184 | 184 | TM.serviceType = TM_TYPE_TC_EXE; |
|
185 | 185 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
186 | 186 | TM.destinationID = TC->sourceID; // default destination id |
|
187 | 187 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
188 | 188 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
189 | 189 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
190 | 190 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
191 | 191 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
192 | 192 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
193 | 193 | // |
|
194 | 194 | TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> 8); |
|
195 | 195 | TM.tc_failure_code[1] = (char) (TC_NOT_EXE ); |
|
196 | 196 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
197 | 197 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
198 | 198 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
199 | 199 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
200 | 200 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
201 | 201 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
202 | 202 | TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0]; |
|
203 | 203 | TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]; |
|
204 | 204 | |
|
205 | 205 | messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
206 | 206 | |
|
207 | 207 | // SEND DATA |
|
208 | 208 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
209 | 209 | if (status != RTEMS_SUCCESSFUL) { |
|
210 | 210 | PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n") |
|
211 | 211 | } |
|
212 | 212 | |
|
213 | 213 | // UPDATE HK FIELDS |
|
214 | 214 | update_last_TC_rej( TC, TM.time ); |
|
215 | 215 | |
|
216 | 216 | return status; |
|
217 | 217 | } |
|
218 | 218 | |
|
219 | 219 | int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) |
|
220 | 220 | { |
|
221 | 221 | /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue. |
|
222 | 222 | * |
|
223 | 223 | * @param TC points to the TeleCommand packet that is being processed |
|
224 | 224 | * @param queue_id is the id of the queue which handles TM |
|
225 | 225 | * |
|
226 | 226 | * @return RTEMS directive status code: |
|
227 | 227 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
228 | 228 | * - RTEMS_INVALID_ID - invalid queue id |
|
229 | 229 | * - RTEMS_INVALID_SIZE - invalid message size |
|
230 | 230 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
231 | 231 | * - RTEMS_UNSATISFIED - out of message buffers |
|
232 | 232 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
233 | 233 | * |
|
234 | 234 | */ |
|
235 | 235 | |
|
236 | 236 | rtems_status_code status; |
|
237 | 237 | Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM; |
|
238 | 238 | unsigned char messageSize; |
|
239 | 239 | |
|
240 | 240 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
241 | 241 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
242 | 242 | TM.reserved = DEFAULT_RESERVED; |
|
243 | 243 | TM.userApplication = CCSDS_USER_APP; |
|
244 | 244 | // PACKET HEADER |
|
245 | 245 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); |
|
246 | 246 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); |
|
247 | 247 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
248 | 248 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8); |
|
249 | 249 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED ); |
|
250 | 250 | // DATA FIELD HEADER |
|
251 | 251 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
252 | 252 | TM.serviceType = TM_TYPE_TC_EXE; |
|
253 | 253 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
254 | 254 | TM.destinationID = TC->sourceID; // default destination id |
|
255 | 255 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
256 | 256 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
257 | 257 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
258 | 258 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
259 | 259 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
260 | 260 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
261 | 261 | // |
|
262 | 262 | TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> 8); |
|
263 | 263 | TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL ); |
|
264 | 264 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
265 | 265 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
266 | 266 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
267 | 267 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
268 | 268 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
269 | 269 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
270 | 270 | |
|
271 | 271 | messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
272 | 272 | |
|
273 | 273 | // SEND DATA |
|
274 | 274 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
275 | 275 | if (status != RTEMS_SUCCESSFUL) { |
|
276 | 276 | PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n") |
|
277 | 277 | } |
|
278 | 278 | |
|
279 | 279 | // UPDATE HK FIELDS |
|
280 | 280 | update_last_TC_rej( TC, TM.time ); |
|
281 | 281 | |
|
282 | 282 | return status; |
|
283 | 283 | } |
|
284 | 284 | |
|
285 |
int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id |
|
|
285 | int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
|
286 | 286 | { |
|
287 | 287 | /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue. |
|
288 | 288 | * |
|
289 | 289 | * @param TC points to the TeleCommand packet that is being processed |
|
290 | 290 | * @param queue_id is the id of the queue which handles TM |
|
291 | 291 | * |
|
292 | 292 | * @return RTEMS directive status code: |
|
293 | 293 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
294 | 294 | * - RTEMS_INVALID_ID - invalid queue id |
|
295 | 295 | * - RTEMS_INVALID_SIZE - invalid message size |
|
296 | 296 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
297 | 297 | * - RTEMS_UNSATISFIED - out of message buffers |
|
298 | 298 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
299 | 299 | * |
|
300 | 300 | */ |
|
301 | 301 | |
|
302 | 302 | rtems_status_code status; |
|
303 | 303 | Packet_TM_LFR_TC_EXE_ERROR_t TM; |
|
304 | 304 | unsigned char messageSize; |
|
305 | 305 | |
|
306 | 306 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
307 | 307 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
308 | 308 | TM.reserved = DEFAULT_RESERVED; |
|
309 | 309 | TM.userApplication = CCSDS_USER_APP; |
|
310 | 310 | // PACKET HEADER |
|
311 | 311 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); |
|
312 | 312 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); |
|
313 | 313 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
314 | 314 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8); |
|
315 | 315 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR ); |
|
316 | 316 | // DATA FIELD HEADER |
|
317 | 317 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
318 | 318 | TM.serviceType = TM_TYPE_TC_EXE; |
|
319 | 319 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
320 | 320 | TM.destinationID = TC->sourceID; // default destination id |
|
321 | 321 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
322 | 322 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
323 | 323 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
324 | 324 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
325 | 325 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
326 | 326 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
327 | 327 | // |
|
328 | 328 | TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> 8); |
|
329 | 329 | TM.tc_failure_code[1] = (char) (FAIL_DETECTED ); |
|
330 | 330 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
331 | 331 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
332 | 332 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
333 | 333 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
334 | 334 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
335 | 335 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
336 | 336 | |
|
337 | 337 | messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
338 | 338 | |
|
339 | 339 | // SEND DATA |
|
340 | 340 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
341 | 341 | if (status != RTEMS_SUCCESSFUL) { |
|
342 | 342 | PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n") |
|
343 | 343 | } |
|
344 | 344 | |
|
345 | 345 | // UPDATE HK FIELDS |
|
346 | 346 | update_last_TC_rej( TC, TM.time ); |
|
347 | 347 | |
|
348 | 348 | return status; |
|
349 | 349 | } |
|
350 | 350 | |
|
351 | 351 | int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, |
|
352 | 352 | unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, |
|
353 | 353 | unsigned char destinationID ) |
|
354 | 354 | { |
|
355 | 355 | /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue. |
|
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 |
|
359 | 359 | * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand |
|
360 | 360 | * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data |
|
361 | 361 | * |
|
362 | 362 | * @return RTEMS directive status code: |
|
363 | 363 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
364 | 364 | * - RTEMS_INVALID_ID - invalid queue id |
|
365 | 365 | * - RTEMS_INVALID_SIZE - invalid message size |
|
366 | 366 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
367 | 367 | * - RTEMS_UNSATISFIED - out of message buffers |
|
368 | 368 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
369 | 369 | * |
|
370 | 370 | */ |
|
371 | 371 | |
|
372 | 372 | rtems_status_code status; |
|
373 | 373 | Packet_TM_LFR_TC_EXE_CORRUPTED_t TM; |
|
374 | 374 | unsigned char messageSize; |
|
375 | 375 | unsigned int packetLength; |
|
376 | 376 | unsigned char *packetDataField; |
|
377 | 377 | |
|
378 | 378 | packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter |
|
379 | 379 | packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field |
|
380 | 380 | |
|
381 | 381 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
382 | 382 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
383 | 383 | TM.reserved = DEFAULT_RESERVED; |
|
384 | 384 | TM.userApplication = CCSDS_USER_APP; |
|
385 | 385 | // PACKET HEADER |
|
386 | 386 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); |
|
387 | 387 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); |
|
388 | 388 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
389 | 389 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8); |
|
390 | 390 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED ); |
|
391 | 391 | // DATA FIELD HEADER |
|
392 | 392 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
393 | 393 | TM.serviceType = TM_TYPE_TC_EXE; |
|
394 | 394 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
395 | 395 | TM.destinationID = destinationID; |
|
396 | 396 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
397 | 397 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
398 | 398 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
399 | 399 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
400 | 400 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
401 | 401 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
402 | 402 | // |
|
403 | 403 | TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> 8); |
|
404 | 404 | TM.tc_failure_code[1] = (unsigned char) (CORRUPTED ); |
|
405 | 405 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
406 | 406 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
407 | 407 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
408 | 408 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
409 | 409 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
410 | 410 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
411 | 411 | TM.pkt_len_rcv_value[0] = TC->packetLength[0]; |
|
412 | 412 | TM.pkt_len_rcv_value[1] = TC->packetLength[1]; |
|
413 | 413 | TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0]; |
|
414 | 414 | TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1]; |
|
415 | 415 | TM.rcv_crc[0] = packetDataField[ packetLength - 1 ]; |
|
416 | 416 | TM.rcv_crc[1] = packetDataField[ packetLength ]; |
|
417 | 417 | TM.computed_crc[0] = computed_CRC[0]; |
|
418 | 418 | TM.computed_crc[1] = computed_CRC[1]; |
|
419 | 419 | |
|
420 | 420 | messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
421 | 421 | |
|
422 | 422 | // SEND DATA |
|
423 | 423 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
424 | 424 | if (status != RTEMS_SUCCESSFUL) { |
|
425 | 425 | PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n") |
|
426 | 426 | } |
|
427 | 427 | |
|
428 | 428 | // UPDATE HK FIELDS |
|
429 | 429 | update_last_TC_rej( TC, TM.time ); |
|
430 | 430 | |
|
431 | 431 | return status; |
|
432 | 432 | } |
|
433 | 433 | |
|
434 | 434 | void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id ) |
|
435 | 435 | { |
|
436 | 436 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. |
|
437 | 437 | * |
|
438 | 438 | * @param packet_sequence_control points to the packet sequence control which will be incremented |
|
439 | 439 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID |
|
440 | 440 | * |
|
441 | 441 | * If the destination ID is not known, a dedicated counter is incremented. |
|
442 | 442 | * |
|
443 | 443 | */ |
|
444 | 444 | |
|
445 | 445 | unsigned short sequence_cnt; |
|
446 | 446 | unsigned short segmentation_grouping_flag; |
|
447 | 447 | unsigned short new_packet_sequence_control; |
|
448 | 448 | unsigned char i; |
|
449 | 449 | |
|
450 | 450 | switch (destination_id) |
|
451 | 451 | { |
|
452 | 452 | case SID_TC_GROUND: |
|
453 | 453 | i = GROUND; |
|
454 | 454 | break; |
|
455 | 455 | case SID_TC_MISSION_TIMELINE: |
|
456 | 456 | i = MISSION_TIMELINE; |
|
457 | 457 | break; |
|
458 | 458 | case SID_TC_TC_SEQUENCES: |
|
459 | 459 | i = TC_SEQUENCES; |
|
460 | 460 | break; |
|
461 | 461 | case SID_TC_RECOVERY_ACTION_CMD: |
|
462 | 462 | i = RECOVERY_ACTION_CMD; |
|
463 | 463 | break; |
|
464 | 464 | case SID_TC_BACKUP_MISSION_TIMELINE: |
|
465 | 465 | i = BACKUP_MISSION_TIMELINE; |
|
466 | 466 | break; |
|
467 | 467 | case SID_TC_DIRECT_CMD: |
|
468 | 468 | i = DIRECT_CMD; |
|
469 | 469 | break; |
|
470 | 470 | case SID_TC_SPARE_GRD_SRC1: |
|
471 | 471 | i = SPARE_GRD_SRC1; |
|
472 | 472 | break; |
|
473 | 473 | case SID_TC_SPARE_GRD_SRC2: |
|
474 | 474 | i = SPARE_GRD_SRC2; |
|
475 | 475 | break; |
|
476 | 476 | case SID_TC_OBCP: |
|
477 | 477 | i = OBCP; |
|
478 | 478 | break; |
|
479 | 479 | case SID_TC_SYSTEM_CONTROL: |
|
480 | 480 | i = SYSTEM_CONTROL; |
|
481 | 481 | break; |
|
482 | 482 | case SID_TC_AOCS: |
|
483 | 483 | i = AOCS; |
|
484 | 484 | break; |
|
485 | 485 | case SID_TC_RPW_INTERNAL: |
|
486 | 486 | i = RPW_INTERNAL; |
|
487 | 487 | break; |
|
488 | 488 | default: |
|
489 | 489 | i = GROUND; |
|
490 | 490 | break; |
|
491 | 491 | } |
|
492 | 492 | |
|
493 | 493 | // increment the sequence counter |
|
494 | 494 | if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX ) |
|
495 | 495 | { |
|
496 | 496 | sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1; |
|
497 | 497 | } |
|
498 | 498 | else |
|
499 | 499 | { |
|
500 | 500 | sequenceCounters_TC_EXE[ i ] = 0; |
|
501 | 501 | } |
|
502 | 502 | |
|
503 | 503 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
504 | 504 | sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff; |
|
505 | 505 | |
|
506 | 506 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; |
|
507 | 507 | |
|
508 | 508 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
509 | 509 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
510 | 510 | |
|
511 | 511 | } |
@@ -1,1356 +1,1351 | |||
|
1 | 1 | /** Functions and tasks related to waveform packet generation. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
7 | 7 | * |
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include "wf_handler.h" |
|
11 | 11 | |
|
12 | 12 | //***************** |
|
13 | 13 | // waveform headers |
|
14 | 14 | // SWF |
|
15 | 15 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7]; |
|
16 | 16 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; |
|
17 | 17 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; |
|
18 | 18 | // CWF |
|
19 | 19 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
20 | 20 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
21 | 21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
22 | 22 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
23 | 23 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ]; |
|
24 | 24 | |
|
25 | 25 | //************** |
|
26 | 26 | // waveform ring |
|
27 | 27 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; |
|
28 | 28 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; |
|
29 | 29 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; |
|
30 | 30 | ring_node *current_ring_node_f0; |
|
31 | 31 | ring_node *ring_node_to_send_swf_f0; |
|
32 | 32 | ring_node *current_ring_node_f1; |
|
33 | 33 | ring_node *ring_node_to_send_swf_f1; |
|
34 | 34 | ring_node *ring_node_to_send_cwf_f1; |
|
35 | 35 | ring_node *current_ring_node_f2; |
|
36 | 36 | ring_node *ring_node_to_send_swf_f2; |
|
37 | 37 | ring_node *ring_node_to_send_cwf_f2; |
|
38 | 38 | |
|
39 | 39 | bool extractSWF = false; |
|
40 | 40 | bool swf_f0_ready = false; |
|
41 | 41 | bool swf_f1_ready = false; |
|
42 | 42 | bool swf_f2_ready = false; |
|
43 | 43 | |
|
44 | 44 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
45 | 45 | |
|
46 | 46 | //********************* |
|
47 | 47 | // Interrupt SubRoutine |
|
48 | 48 | |
|
49 | 49 | void reset_extractSWF( void ) |
|
50 | 50 | { |
|
51 | 51 | extractSWF = false; |
|
52 | 52 | swf_f0_ready = false; |
|
53 | 53 | swf_f1_ready = false; |
|
54 | 54 | swf_f2_ready = false; |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
58 | 58 | { |
|
59 | 59 | /** This is the interrupt sub routine called by the waveform picker core. |
|
60 | 60 | * |
|
61 | 61 | * This ISR launch different actions depending mainly on two pieces of information: |
|
62 | 62 | * 1. the values read in the registers of the waveform picker. |
|
63 | 63 | * 2. the current LFR mode. |
|
64 | 64 | * |
|
65 | 65 | */ |
|
66 | 66 | |
|
67 | 67 | rtems_status_code status; |
|
68 | 68 | static unsigned char nb_swf = 0; |
|
69 | 69 | |
|
70 | 70 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
71 | 71 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
72 | 72 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
73 | 73 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full |
|
74 | 74 | // (1) change the receiving buffer for the waveform picker |
|
75 | 75 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { |
|
76 | 76 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b); |
|
77 | 77 | } |
|
78 | 78 | else { |
|
79 | 79 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); |
|
80 | 80 | } |
|
81 | 81 | // (2) send an event for the waveforms transmission |
|
82 | 82 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
83 | 83 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
84 | 84 | } |
|
85 | 85 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] |
|
86 | 86 | } |
|
87 | 87 | } |
|
88 | 88 | |
|
89 | 89 | switch(lfrCurrentMode) |
|
90 | 90 | { |
|
91 | 91 | //******** |
|
92 | 92 | // STANDBY |
|
93 | 93 | case(LFR_MODE_STANDBY): |
|
94 | 94 | break; |
|
95 | 95 | |
|
96 | 96 | //****** |
|
97 | 97 | // NORMAL |
|
98 | 98 | case(LFR_MODE_NORMAL): |
|
99 | 99 | if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits |
|
100 | 100 | { |
|
101 | 101 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
102 | 102 | } |
|
103 | 103 | if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits |
|
104 | 104 | { |
|
105 | 105 | // change F0 ring node |
|
106 | 106 | ring_node_to_send_swf_f0 = current_ring_node_f0; |
|
107 | 107 | current_ring_node_f0 = current_ring_node_f0->next; |
|
108 | 108 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; |
|
109 | 109 | // change F1 ring node |
|
110 | 110 | ring_node_to_send_swf_f1 = current_ring_node_f1; |
|
111 | 111 | current_ring_node_f1 = current_ring_node_f1->next; |
|
112 | 112 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
113 | 113 | // change F2 ring node |
|
114 | 114 | ring_node_to_send_swf_f2 = current_ring_node_f2; |
|
115 | 115 | current_ring_node_f2 = current_ring_node_f2->next; |
|
116 | 116 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
117 | 117 | // |
|
118 | 118 | // if (nb_swf < 2) |
|
119 | 119 | if (true) |
|
120 | 120 | { |
|
121 | 121 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
122 | 122 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
123 | 123 | } |
|
124 | 124 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] |
|
125 | 125 | nb_swf = nb_swf + 1; |
|
126 | 126 | } |
|
127 | 127 | else |
|
128 | 128 | { |
|
129 | 129 | reset_wfp_burst_enable(); |
|
130 | 130 | nb_swf = 0; |
|
131 | 131 | } |
|
132 | 132 | |
|
133 | 133 | } |
|
134 | 134 | |
|
135 | 135 | break; |
|
136 | 136 | |
|
137 | 137 | //****** |
|
138 | 138 | // BURST |
|
139 | 139 | case(LFR_MODE_BURST): |
|
140 | 140 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
141 | 141 | // (1) change the receiving buffer for the waveform picker |
|
142 | 142 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
143 | 143 | current_ring_node_f2 = current_ring_node_f2->next; |
|
144 | 144 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
145 | 145 | // (2) send an event for the waveforms transmission |
|
146 | 146 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
147 | 147 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
148 | 148 | } |
|
149 | 149 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
150 | 150 | } |
|
151 | 151 | break; |
|
152 | 152 | |
|
153 | 153 | //***** |
|
154 | 154 | // SBM1 |
|
155 | 155 | case(LFR_MODE_SBM1): |
|
156 | 156 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
157 | // (0) launch snapshot extraction if needed | |
|
158 | if (extractSWF == true) | |
|
159 | { | |
|
160 | ring_node_to_send_swf_f1 = current_ring_node_f1; | |
|
161 | // extract the snapshot | |
|
162 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); | |
|
163 | extractSWF = false; | |
|
164 | swf_f1_ready = true; | |
|
165 | } | |
|
166 | 157 | // (1) change the receiving buffer for the waveform picker |
|
167 | 158 | ring_node_to_send_cwf_f1 = current_ring_node_f1; |
|
168 | 159 | current_ring_node_f1 = current_ring_node_f1->next; |
|
169 | 160 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
170 | // (2) send an event for the the CWF1 task for transmission | |
|
161 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) | |
|
171 | 162 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); |
|
172 | 163 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0 |
|
173 | if (swf_f0_ready == true) | |
|
174 | { | |
|
175 | extractSWF = true; | |
|
176 | swf_f0_ready = false; | |
|
177 | } | |
|
178 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) | |
|
179 | { | |
|
180 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); | |
|
181 | swf_f1_ready = false; | |
|
182 | swf_f2_ready = false; | |
|
183 | } | |
|
184 | 164 | } |
|
185 | 165 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
186 | 166 | swf_f0_ready = true; |
|
187 | 167 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
188 | 168 | } |
|
189 | 169 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit |
|
190 | 170 | swf_f2_ready = true; |
|
191 | 171 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0 |
|
192 | 172 | } |
|
193 | 173 | break; |
|
194 | 174 | |
|
195 | 175 | //***** |
|
196 | 176 | // SBM2 |
|
197 | 177 | case(LFR_MODE_SBM2): |
|
198 | 178 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
199 | // (0) launch snapshot extraction if needed | |
|
200 | if (extractSWF == true) | |
|
201 | { | |
|
202 | ring_node_to_send_swf_f2 = current_ring_node_f2; | |
|
203 | // extract the snapshot | |
|
204 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM2 ); | |
|
205 | // send the snapshot when build, SWBD priority < WFRM priority | |
|
206 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); | |
|
207 | extractSWF = false; | |
|
208 | } | |
|
209 | 179 | // (1) change the receiving buffer for the waveform picker |
|
210 | 180 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
211 | 181 | current_ring_node_f2 = current_ring_node_f2->next; |
|
212 | 182 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
213 | 183 | // (2) send an event for the waveforms transmission |
|
214 | 184 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); |
|
215 | 185 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
216 | // (3) check whether swf_fo and swf_f& are ready or not | |
|
217 | if (swf_f0_ready && swf_f1_ready) | |
|
218 | { | |
|
219 | extractSWF = true; | |
|
220 | swf_f0_ready = false; | |
|
221 | swf_f1_ready = false; | |
|
222 | } | |
|
223 | 186 | } |
|
224 | 187 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
225 | 188 | swf_f0_ready = true; |
|
226 | 189 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
227 | 190 | } |
|
228 | 191 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
229 | 192 | swf_f1_ready = true; |
|
230 | 193 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0 |
|
231 | 194 | } |
|
232 | 195 | break; |
|
233 | 196 | |
|
234 | 197 | //******** |
|
235 | 198 | // DEFAULT |
|
236 | 199 | default: |
|
237 | 200 | break; |
|
238 | 201 | } |
|
239 | 202 | } |
|
240 | 203 | |
|
241 | 204 | //************ |
|
242 | 205 | // RTEMS TASKS |
|
243 | 206 | |
|
244 | 207 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
245 | 208 | { |
|
246 | 209 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
247 | 210 | * |
|
248 | 211 | * @param unused is the starting argument of the RTEMS task |
|
249 | 212 | * |
|
250 | 213 | * The following data packets are sent by this task: |
|
251 | 214 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
252 | 215 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
253 | 216 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
254 | 217 | * |
|
255 | 218 | */ |
|
256 | 219 | |
|
257 | 220 | rtems_event_set event_out; |
|
258 | 221 | rtems_id queue_id; |
|
259 | 222 | rtems_status_code status; |
|
260 | 223 | |
|
261 | 224 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); |
|
262 | 225 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); |
|
263 | 226 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); |
|
264 | 227 | |
|
265 | 228 | init_waveforms(); |
|
266 | 229 | |
|
267 | 230 | status = get_message_queue_id_send( &queue_id ); |
|
268 | 231 | if (status != RTEMS_SUCCESSFUL) |
|
269 | 232 | { |
|
270 | 233 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) |
|
271 | 234 | } |
|
272 | 235 | |
|
273 | 236 | BOOT_PRINTF("in WFRM ***\n") |
|
274 | 237 | |
|
275 | 238 | while(1){ |
|
276 | 239 | // wait for an RTEMS_EVENT |
|
277 | 240 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
278 | 241 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
279 | 242 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
280 | 243 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
281 | 244 | { |
|
282 | 245 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") |
|
283 | 246 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
284 | 247 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
285 | 248 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
286 | 249 | } |
|
287 | 250 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
288 | 251 | { |
|
289 | 252 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") |
|
290 | 253 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
291 | 254 | send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
292 | 255 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
293 | 256 | } |
|
294 | 257 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
295 | 258 | { |
|
296 | 259 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") |
|
297 | 260 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
298 | 261 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
299 | 262 | send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
300 | 263 | } |
|
301 | 264 | } |
|
302 | 265 | } |
|
303 | 266 | |
|
304 | 267 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
305 | 268 | { |
|
306 | 269 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
307 | 270 | * |
|
308 | 271 | * @param unused is the starting argument of the RTEMS task |
|
309 | 272 | * |
|
310 | 273 | * The following data packet is sent by this task: |
|
311 | 274 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
312 | 275 | * |
|
313 | 276 | */ |
|
314 | 277 | |
|
315 | 278 | rtems_event_set event_out; |
|
316 | 279 | rtems_id queue_id; |
|
317 | 280 | rtems_status_code status; |
|
318 | 281 | |
|
319 | 282 | init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 ); |
|
320 | 283 | init_header_continuous_cwf3_light_table( headerCWF_F3_light ); |
|
321 | 284 | |
|
322 | 285 | status = get_message_queue_id_send( &queue_id ); |
|
323 | 286 | if (status != RTEMS_SUCCESSFUL) |
|
324 | 287 | { |
|
325 | 288 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
326 | 289 | } |
|
327 | 290 | |
|
328 | 291 | BOOT_PRINTF("in CWF3 ***\n") |
|
329 | 292 | |
|
330 | 293 | while(1){ |
|
331 | 294 | // wait for an RTEMS_EVENT |
|
332 | 295 | rtems_event_receive( RTEMS_EVENT_0, |
|
333 | 296 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
334 | 297 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
335 | 298 | { |
|
336 | 299 | PRINTF("send CWF_LONG_F3\n") |
|
337 | 300 | } |
|
338 | 301 | else |
|
339 | 302 | { |
|
340 | 303 | PRINTF("send CWF_F3 (light)\n") |
|
341 | 304 | } |
|
342 | 305 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { |
|
343 | 306 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
344 | 307 | { |
|
345 | 308 | send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); |
|
346 | 309 | } |
|
347 | 310 | else |
|
348 | 311 | { |
|
349 | 312 | send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id ); |
|
350 | 313 | } |
|
351 | 314 | } |
|
352 | 315 | else |
|
353 | 316 | { |
|
354 | 317 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
355 | 318 | { |
|
356 | 319 | send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); |
|
357 | 320 | } |
|
358 | 321 | else |
|
359 | 322 | { |
|
360 | 323 | send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id ); |
|
361 | 324 | } |
|
362 | 325 | |
|
363 | 326 | } |
|
364 | 327 | } |
|
365 | 328 | } |
|
366 | 329 | |
|
367 | 330 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
368 | 331 | { |
|
369 | 332 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
370 | 333 | * |
|
371 | 334 | * @param unused is the starting argument of the RTEMS task |
|
372 | 335 | * |
|
373 | 336 | * The following data packet is sent by this function: |
|
374 | 337 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
375 | 338 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
376 | 339 | * |
|
377 | 340 | */ |
|
378 | 341 | |
|
379 | 342 | rtems_event_set event_out; |
|
380 | 343 | rtems_id queue_id; |
|
381 | 344 | rtems_status_code status; |
|
382 | 345 | |
|
383 | 346 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); |
|
384 | 347 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); |
|
385 | 348 | |
|
386 | 349 | status = get_message_queue_id_send( &queue_id ); |
|
387 | 350 | if (status != RTEMS_SUCCESSFUL) |
|
388 | 351 | { |
|
389 | 352 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
390 | 353 | } |
|
391 | 354 | |
|
392 | 355 | BOOT_PRINTF("in CWF2 ***\n") |
|
393 | 356 | |
|
394 | 357 | while(1){ |
|
395 | 358 | // wait for an RTEMS_EVENT |
|
396 | 359 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
397 | 360 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
398 | 361 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
399 | 362 | { |
|
400 | 363 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); |
|
401 | 364 | } |
|
402 | 365 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
403 | 366 | { |
|
404 | 367 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
368 | // launch snapshot extraction if needed | |
|
369 | if (extractSWF == true) | |
|
370 | { | |
|
371 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; | |
|
372 | // extract the snapshot | |
|
373 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 ); | |
|
374 | // send the snapshot when built | |
|
375 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); | |
|
376 | extractSWF = false; | |
|
377 | } | |
|
378 | if (swf_f0_ready && swf_f1_ready) | |
|
379 | { | |
|
380 | extractSWF = true; | |
|
381 | swf_f0_ready = false; | |
|
382 | swf_f1_ready = false; | |
|
383 | } | |
|
405 | 384 | } |
|
406 | 385 | } |
|
407 | 386 | } |
|
408 | 387 | |
|
409 | 388 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
410 | 389 | { |
|
411 | 390 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
412 | 391 | * |
|
413 | 392 | * @param unused is the starting argument of the RTEMS task |
|
414 | 393 | * |
|
415 | 394 | * The following data packet is sent by this function: |
|
416 | 395 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
417 | 396 | * |
|
418 | 397 | */ |
|
419 | 398 | |
|
420 | 399 | rtems_event_set event_out; |
|
421 | 400 | rtems_id queue_id; |
|
422 | 401 | rtems_status_code status; |
|
423 | 402 | |
|
424 | 403 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); |
|
425 | 404 | |
|
426 | 405 | status = get_message_queue_id_send( &queue_id ); |
|
427 | 406 | if (status != RTEMS_SUCCESSFUL) |
|
428 | 407 | { |
|
429 | 408 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
430 | 409 | } |
|
431 | 410 | |
|
432 | 411 | BOOT_PRINTF("in CWF1 ***\n") |
|
433 | 412 | |
|
434 | 413 | while(1){ |
|
435 | 414 | // wait for an RTEMS_EVENT |
|
436 | 415 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
437 | 416 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
438 | 417 | send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
418 | // launch snapshot extraction if needed | |
|
419 | if (extractSWF == true) | |
|
420 | { | |
|
421 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1; | |
|
422 | // launch the snapshot extraction | |
|
423 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); | |
|
424 | extractSWF = false; | |
|
425 | } | |
|
426 | if (swf_f0_ready == true) | |
|
427 | { | |
|
428 | extractSWF = true; | |
|
429 | swf_f0_ready = false; // this step shall be executed only one time | |
|
430 | } | |
|
431 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction | |
|
432 | { | |
|
433 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); | |
|
434 | swf_f1_ready = false; | |
|
435 | swf_f2_ready = false; | |
|
436 | } | |
|
439 | 437 | } |
|
440 | 438 | } |
|
441 | 439 | |
|
442 | 440 | rtems_task swbd_task(rtems_task_argument argument) |
|
443 | 441 | { |
|
444 | 442 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
445 | 443 | * |
|
446 | 444 | * @param unused is the starting argument of the RTEMS task |
|
447 | 445 | * |
|
448 | 446 | */ |
|
449 | 447 | |
|
450 | 448 | rtems_event_set event_out; |
|
451 | 449 | |
|
452 | 450 | BOOT_PRINTF("in SWBD ***\n") |
|
453 | 451 | |
|
454 | 452 | while(1){ |
|
455 | 453 | // wait for an RTEMS_EVENT |
|
456 | 454 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, |
|
457 | 455 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
458 | 456 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
459 | 457 | { |
|
460 | 458 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 ); |
|
461 | } | |
|
462 | else if (event_out == RTEMS_EVENT_MODE_SBM2) | |
|
463 | { | |
|
464 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 ); | |
|
459 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent | |
|
465 | 460 | } |
|
466 | 461 | else |
|
467 | 462 | { |
|
468 | 463 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
469 | 464 | } |
|
470 | 465 | } |
|
471 | 466 | } |
|
472 | 467 | |
|
473 | 468 | //****************** |
|
474 | 469 | // general functions |
|
475 | 470 | void init_waveforms( void ) |
|
476 | 471 | { |
|
477 | 472 | int i = 0; |
|
478 | 473 | |
|
479 | 474 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
480 | 475 | { |
|
481 | 476 | //*** |
|
482 | 477 | // F0 |
|
483 | 478 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; // |
|
484 | 479 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; // |
|
485 | 480 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; // |
|
486 | 481 | |
|
487 | 482 | //*** |
|
488 | 483 | // F1 |
|
489 | 484 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111; |
|
490 | 485 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333; |
|
491 | 486 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
492 | 487 | |
|
493 | 488 | //*** |
|
494 | 489 | // F2 |
|
495 | 490 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333; |
|
496 | 491 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; |
|
497 | 492 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
498 | 493 | |
|
499 | 494 | //*** |
|
500 | 495 | // F3 |
|
501 | 496 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1; |
|
502 | 497 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2; |
|
503 | 498 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000; |
|
504 | 499 | } |
|
505 | 500 | } |
|
506 | 501 | |
|
507 | 502 | void init_waveform_rings( void ) |
|
508 | 503 | { |
|
509 | 504 | unsigned char i; |
|
510 | 505 | |
|
511 | 506 | // F0 RING |
|
512 | 507 | waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1]; |
|
513 | 508 | waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1]; |
|
514 | 509 | waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0]; |
|
515 | 510 | |
|
516 | 511 | waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0]; |
|
517 | 512 | waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2]; |
|
518 | 513 | waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0]; |
|
519 | 514 | |
|
520 | 515 | for(i=1; i<NB_RING_NODES_F0-1; i++) |
|
521 | 516 | { |
|
522 | 517 | waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1]; |
|
523 | 518 | waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1]; |
|
524 | 519 | waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0]; |
|
525 | 520 | } |
|
526 | 521 | |
|
527 | 522 | // F1 RING |
|
528 | 523 | waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1]; |
|
529 | 524 | waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1]; |
|
530 | 525 | waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0]; |
|
531 | 526 | |
|
532 | 527 | waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0]; |
|
533 | 528 | waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2]; |
|
534 | 529 | waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0]; |
|
535 | 530 | |
|
536 | 531 | for(i=1; i<NB_RING_NODES_F1-1; i++) |
|
537 | 532 | { |
|
538 | 533 | waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1]; |
|
539 | 534 | waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1]; |
|
540 | 535 | waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0]; |
|
541 | 536 | } |
|
542 | 537 | |
|
543 | 538 | // F2 RING |
|
544 | 539 | waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1]; |
|
545 | 540 | waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1]; |
|
546 | 541 | waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0]; |
|
547 | 542 | |
|
548 | 543 | waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0]; |
|
549 | 544 | waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2]; |
|
550 | 545 | waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0]; |
|
551 | 546 | |
|
552 | 547 | for(i=1; i<NB_RING_NODES_F2-1; i++) |
|
553 | 548 | { |
|
554 | 549 | waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1]; |
|
555 | 550 | waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1]; |
|
556 | 551 | waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0]; |
|
557 | 552 | } |
|
558 | 553 | |
|
559 | 554 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
560 | 555 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
561 | 556 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
562 | 557 | |
|
563 | 558 | } |
|
564 | 559 | |
|
565 | 560 | void reset_current_ring_nodes( void ) |
|
566 | 561 | { |
|
567 | 562 | current_ring_node_f0 = waveform_ring_f0; |
|
568 | 563 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
569 | 564 | |
|
570 | 565 | current_ring_node_f1 = waveform_ring_f1; |
|
571 | 566 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
572 | 567 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
573 | 568 | |
|
574 | 569 | current_ring_node_f2 = waveform_ring_f2; |
|
575 | 570 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
576 | 571 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
577 | 572 | } |
|
578 | 573 | |
|
579 | 574 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) |
|
580 | 575 | { |
|
581 | 576 | unsigned char i; |
|
582 | 577 | |
|
583 | 578 | for (i=0; i<7; i++) |
|
584 | 579 | { |
|
585 | 580 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
586 | 581 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
587 | 582 | headerSWF[ i ].reserved = DEFAULT_RESERVED; |
|
588 | 583 | headerSWF[ i ].userApplication = CCSDS_USER_APP; |
|
589 | 584 | headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
590 | 585 | headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
591 | 586 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
592 | 587 | if (i == 6) |
|
593 | 588 | { |
|
594 | 589 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
595 | 590 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
596 | 591 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
597 | 592 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
598 | 593 | } |
|
599 | 594 | else |
|
600 | 595 | { |
|
601 | 596 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
602 | 597 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
603 | 598 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
604 | 599 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
605 | 600 | } |
|
606 | 601 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
607 | 602 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
608 | 603 | headerSWF[ i ].pktNr = i+1; // PKT_NR |
|
609 | 604 | // DATA FIELD HEADER |
|
610 | 605 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
611 | 606 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
612 | 607 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
613 | 608 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
614 | 609 | // AUXILIARY DATA HEADER |
|
615 | 610 | headerSWF[ i ].time[0] = 0x00; |
|
616 | 611 | headerSWF[ i ].time[0] = 0x00; |
|
617 | 612 | headerSWF[ i ].time[0] = 0x00; |
|
618 | 613 | headerSWF[ i ].time[0] = 0x00; |
|
619 | 614 | headerSWF[ i ].time[0] = 0x00; |
|
620 | 615 | headerSWF[ i ].time[0] = 0x00; |
|
621 | 616 | headerSWF[ i ].sid = sid; |
|
622 | 617 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
623 | 618 | } |
|
624 | 619 | return LFR_SUCCESSFUL; |
|
625 | 620 | } |
|
626 | 621 | |
|
627 | 622 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
628 | 623 | { |
|
629 | 624 | unsigned int i; |
|
630 | 625 | |
|
631 | 626 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) |
|
632 | 627 | { |
|
633 | 628 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
634 | 629 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
635 | 630 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
636 | 631 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
637 | 632 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
638 | 633 | { |
|
639 | 634 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8); |
|
640 | 635 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2); |
|
641 | 636 | } |
|
642 | 637 | else |
|
643 | 638 | { |
|
644 | 639 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
645 | 640 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
646 | 641 | } |
|
647 | 642 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
648 | 643 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
649 | 644 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
650 | 645 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
651 | 646 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
652 | 647 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
653 | 648 | // DATA FIELD HEADER |
|
654 | 649 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
655 | 650 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
656 | 651 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
657 | 652 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
658 | 653 | // AUXILIARY DATA HEADER |
|
659 | 654 | headerCWF[ i ].sid = sid; |
|
660 | 655 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
661 | 656 | headerCWF[ i ].time[0] = 0x00; |
|
662 | 657 | headerCWF[ i ].time[0] = 0x00; |
|
663 | 658 | headerCWF[ i ].time[0] = 0x00; |
|
664 | 659 | headerCWF[ i ].time[0] = 0x00; |
|
665 | 660 | headerCWF[ i ].time[0] = 0x00; |
|
666 | 661 | headerCWF[ i ].time[0] = 0x00; |
|
667 | 662 | } |
|
668 | 663 | return LFR_SUCCESSFUL; |
|
669 | 664 | } |
|
670 | 665 | |
|
671 | 666 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
672 | 667 | { |
|
673 | 668 | unsigned int i; |
|
674 | 669 | |
|
675 | 670 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) |
|
676 | 671 | { |
|
677 | 672 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
678 | 673 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
679 | 674 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
680 | 675 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
681 | 676 | |
|
682 | 677 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
683 | 678 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
684 | 679 | |
|
685 | 680 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
686 | 681 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
687 | 682 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
688 | 683 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
689 | 684 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
690 | 685 | |
|
691 | 686 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
692 | 687 | // DATA FIELD HEADER |
|
693 | 688 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
694 | 689 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
695 | 690 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
696 | 691 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
697 | 692 | // AUXILIARY DATA HEADER |
|
698 | 693 | headerCWF[ i ].sid = SID_NORM_CWF_F3; |
|
699 | 694 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
700 | 695 | headerCWF[ i ].time[0] = 0x00; |
|
701 | 696 | headerCWF[ i ].time[0] = 0x00; |
|
702 | 697 | headerCWF[ i ].time[0] = 0x00; |
|
703 | 698 | headerCWF[ i ].time[0] = 0x00; |
|
704 | 699 | headerCWF[ i ].time[0] = 0x00; |
|
705 | 700 | headerCWF[ i ].time[0] = 0x00; |
|
706 | 701 | } |
|
707 | 702 | return LFR_SUCCESSFUL; |
|
708 | 703 | } |
|
709 | 704 | |
|
710 | 705 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, |
|
711 | 706 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) |
|
712 | 707 | { |
|
713 | 708 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
714 | 709 | * |
|
715 | 710 | * @param waveform points to the buffer containing the data that will be send. |
|
716 | 711 | * @param sid is the source identifier of the data that will be sent. |
|
717 | 712 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
718 | 713 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
719 | 714 | * contain information to setup the transmission of the data packets. |
|
720 | 715 | * |
|
721 | 716 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
722 | 717 | * |
|
723 | 718 | */ |
|
724 | 719 | |
|
725 | 720 | unsigned int i; |
|
726 | 721 | int ret; |
|
727 | 722 | unsigned int coarseTime; |
|
728 | 723 | unsigned int fineTime; |
|
729 | 724 | rtems_status_code status; |
|
730 | 725 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
731 | 726 | |
|
732 | 727 | spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header |
|
733 | 728 | spw_ioctl_send_SWF.options = 0; |
|
734 | 729 | |
|
735 | 730 | ret = LFR_DEFAULT; |
|
736 | 731 | |
|
737 | 732 | coarseTime = waveform[0]; |
|
738 | 733 | fineTime = waveform[1]; |
|
739 | 734 | |
|
740 | 735 | for (i=0; i<7; i++) // send waveform |
|
741 | 736 | { |
|
742 | 737 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
743 | 738 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; |
|
744 | 739 | // BUILD THE DATA |
|
745 | 740 | if (i==6) { |
|
746 | 741 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
747 | 742 | } |
|
748 | 743 | else { |
|
749 | 744 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
750 | 745 | } |
|
751 | 746 | // SET PACKET SEQUENCE COUNTER |
|
752 | 747 | increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); |
|
753 | 748 | // SET PACKET TIME |
|
754 | 749 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime ); |
|
755 | 750 | // |
|
756 | 751 | headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
757 | 752 | headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
758 | 753 | headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
759 | 754 | headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
760 | 755 | headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
761 | 756 | headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); |
|
762 | 757 | // SEND PACKET |
|
763 | 758 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
764 | 759 | if (status != RTEMS_SUCCESSFUL) { |
|
765 | 760 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
766 | 761 | ret = LFR_DEFAULT; |
|
767 | 762 | } |
|
768 | 763 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds |
|
769 | 764 | } |
|
770 | 765 | |
|
771 | 766 | return ret; |
|
772 | 767 | } |
|
773 | 768 | |
|
774 | 769 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, |
|
775 | 770 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
776 | 771 | { |
|
777 | 772 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
778 | 773 | * |
|
779 | 774 | * @param waveform points to the buffer containing the data that will be send. |
|
780 | 775 | * @param sid is the source identifier of the data that will be sent. |
|
781 | 776 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
782 | 777 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
783 | 778 | * contain information to setup the transmission of the data packets. |
|
784 | 779 | * |
|
785 | 780 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
786 | 781 | * |
|
787 | 782 | */ |
|
788 | 783 | |
|
789 | 784 | unsigned int i; |
|
790 | 785 | int ret; |
|
791 | 786 | unsigned int coarseTime; |
|
792 | 787 | unsigned int fineTime; |
|
793 | 788 | rtems_status_code status; |
|
794 | 789 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
795 | 790 | |
|
796 | 791 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
797 | 792 | spw_ioctl_send_CWF.options = 0; |
|
798 | 793 | |
|
799 | 794 | ret = LFR_DEFAULT; |
|
800 | 795 | |
|
801 | 796 | coarseTime = waveform[0]; |
|
802 | 797 | fineTime = waveform[1]; |
|
803 | 798 | |
|
804 | 799 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
805 | 800 | { |
|
806 | 801 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
807 | 802 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
808 | 803 | // BUILD THE DATA |
|
809 | 804 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
810 | 805 | // SET PACKET SEQUENCE COUNTER |
|
811 | 806 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); |
|
812 | 807 | // SET PACKET TIME |
|
813 | 808 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime); |
|
814 | 809 | // |
|
815 | 810 | headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
816 | 811 | headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
817 | 812 | headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
818 | 813 | headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
819 | 814 | headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
820 | 815 | headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); |
|
821 | 816 | // SEND PACKET |
|
822 | 817 | if (sid == SID_NORM_CWF_LONG_F3) |
|
823 | 818 | { |
|
824 | 819 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
825 | 820 | if (status != RTEMS_SUCCESSFUL) { |
|
826 | 821 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
827 | 822 | ret = LFR_DEFAULT; |
|
828 | 823 | } |
|
829 | 824 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
830 | 825 | } |
|
831 | 826 | else |
|
832 | 827 | { |
|
833 | 828 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
834 | 829 | if (status != RTEMS_SUCCESSFUL) { |
|
835 | 830 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
836 | 831 | ret = LFR_DEFAULT; |
|
837 | 832 | } |
|
838 | 833 | } |
|
839 | 834 | } |
|
840 | 835 | |
|
841 | 836 | return ret; |
|
842 | 837 | } |
|
843 | 838 | |
|
844 | 839 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
845 | 840 | { |
|
846 | 841 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
847 | 842 | * |
|
848 | 843 | * @param waveform points to the buffer containing the data that will be send. |
|
849 | 844 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
850 | 845 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
851 | 846 | * contain information to setup the transmission of the data packets. |
|
852 | 847 | * |
|
853 | 848 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
854 | 849 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
855 | 850 | * |
|
856 | 851 | */ |
|
857 | 852 | |
|
858 | 853 | unsigned int i; |
|
859 | 854 | int ret; |
|
860 | 855 | unsigned int coarseTime; |
|
861 | 856 | unsigned int fineTime; |
|
862 | 857 | rtems_status_code status; |
|
863 | 858 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
864 | 859 | char *sample; |
|
865 | 860 | |
|
866 | 861 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
867 | 862 | spw_ioctl_send_CWF.options = 0; |
|
868 | 863 | |
|
869 | 864 | ret = LFR_DEFAULT; |
|
870 | 865 | |
|
871 | 866 | //********************** |
|
872 | 867 | // BUILD CWF3_light DATA |
|
873 | 868 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
874 | 869 | { |
|
875 | 870 | sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
876 | 871 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ]; |
|
877 | 872 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ]; |
|
878 | 873 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ]; |
|
879 | 874 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ]; |
|
880 | 875 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ]; |
|
881 | 876 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ]; |
|
882 | 877 | } |
|
883 | 878 | |
|
884 | 879 | coarseTime = waveform[0]; |
|
885 | 880 | fineTime = waveform[1]; |
|
886 | 881 | |
|
887 | 882 | //********************* |
|
888 | 883 | // SEND CWF3_light DATA |
|
889 | 884 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
890 | 885 | { |
|
891 | 886 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES]; |
|
892 | 887 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
893 | 888 | // BUILD THE DATA |
|
894 | 889 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
895 | 890 | // SET PACKET SEQUENCE COUNTER |
|
896 | 891 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); |
|
897 | 892 | // SET PACKET TIME |
|
898 | 893 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime ); |
|
899 | 894 | // |
|
900 | 895 | headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
901 | 896 | headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
902 | 897 | headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
903 | 898 | headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
904 | 899 | headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
905 | 900 | headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); |
|
906 | 901 | // SEND PACKET |
|
907 | 902 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
908 | 903 | if (status != RTEMS_SUCCESSFUL) { |
|
909 | 904 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
910 | 905 | ret = LFR_DEFAULT; |
|
911 | 906 | } |
|
912 | 907 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
913 | 908 | } |
|
914 | 909 | |
|
915 | 910 | return ret; |
|
916 | 911 | } |
|
917 | 912 | |
|
918 | 913 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
919 | 914 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
920 | 915 | { |
|
921 | 916 | unsigned long long int acquisitionTimeAsLong; |
|
922 | 917 | unsigned char localAcquisitionTime[6]; |
|
923 | 918 | double deltaT; |
|
924 | 919 | |
|
925 | 920 | deltaT = 0.; |
|
926 | 921 | |
|
927 | 922 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 ); |
|
928 | 923 | localAcquisitionTime[1] = (unsigned char) ( coarseTime ); |
|
929 | 924 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 ); |
|
930 | 925 | localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 ); |
|
931 | 926 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 ); |
|
932 | 927 | localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 ); |
|
933 | 928 | |
|
934 | 929 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) |
|
935 | 930 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) |
|
936 | 931 | + ( localAcquisitionTime[2] << 24 ) |
|
937 | 932 | + ( localAcquisitionTime[3] << 16 ) |
|
938 | 933 | + ( localAcquisitionTime[4] << 8 ) |
|
939 | 934 | + ( localAcquisitionTime[5] ); |
|
940 | 935 | |
|
941 | 936 | switch( sid ) |
|
942 | 937 | { |
|
943 | 938 | case SID_NORM_SWF_F0: |
|
944 | 939 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; |
|
945 | 940 | break; |
|
946 | 941 | |
|
947 | 942 | case SID_NORM_SWF_F1: |
|
948 | 943 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; |
|
949 | 944 | break; |
|
950 | 945 | |
|
951 | 946 | case SID_NORM_SWF_F2: |
|
952 | 947 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; |
|
953 | 948 | break; |
|
954 | 949 | |
|
955 | 950 | case SID_SBM1_CWF_F1: |
|
956 | 951 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; |
|
957 | 952 | break; |
|
958 | 953 | |
|
959 | 954 | case SID_SBM2_CWF_F2: |
|
960 | 955 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
961 | 956 | break; |
|
962 | 957 | |
|
963 | 958 | case SID_BURST_CWF_F2: |
|
964 | 959 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
965 | 960 | break; |
|
966 | 961 | |
|
967 | 962 | case SID_NORM_CWF_F3: |
|
968 | 963 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; |
|
969 | 964 | break; |
|
970 | 965 | |
|
971 | 966 | case SID_NORM_CWF_LONG_F3: |
|
972 | 967 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; |
|
973 | 968 | break; |
|
974 | 969 | |
|
975 | 970 | default: |
|
976 | 971 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid) |
|
977 | 972 | deltaT = 0.; |
|
978 | 973 | break; |
|
979 | 974 | } |
|
980 | 975 | |
|
981 | 976 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
982 | 977 | // |
|
983 | 978 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); |
|
984 | 979 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); |
|
985 | 980 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); |
|
986 | 981 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); |
|
987 | 982 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); |
|
988 | 983 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); |
|
989 | 984 | |
|
990 | 985 | } |
|
991 | 986 | |
|
992 | 987 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel ) |
|
993 | 988 | { |
|
994 | 989 | unsigned int i; |
|
995 | 990 | unsigned long long int centerTime_asLong; |
|
996 | 991 | unsigned long long int acquisitionTimeF0_asLong; |
|
997 | 992 | unsigned long long int acquisitionTime_asLong; |
|
998 | 993 | unsigned long long int bufferAcquisitionTime_asLong; |
|
999 | 994 | unsigned char *ptr1; |
|
1000 | 995 | unsigned char *ptr2; |
|
1001 | 996 | unsigned char nb_ring_nodes; |
|
1002 | 997 | unsigned long long int frequency_asLong; |
|
1003 | 998 | unsigned long long int nbTicksPerSample_asLong; |
|
1004 | 999 | unsigned long long int nbSamplesPart1_asLong; |
|
1005 | 1000 | unsigned long long int sampleOffset_asLong; |
|
1006 | 1001 | |
|
1007 | 1002 | unsigned int deltaT_F0; |
|
1008 | 1003 | unsigned int deltaT_F1; |
|
1009 | 1004 | unsigned long long int deltaT_F2; |
|
1010 | 1005 | |
|
1011 | 1006 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
1012 | 1007 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; |
|
1013 | 1008 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; |
|
1014 | 1009 | sampleOffset_asLong = 0x00; |
|
1015 | 1010 | |
|
1016 | 1011 | // (1) get the f0 acquisition time |
|
1017 | 1012 | build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 ); |
|
1018 | 1013 | |
|
1019 | 1014 | // (2) compute the central reference time |
|
1020 | 1015 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
1021 | 1016 | |
|
1022 | 1017 | // (3) compute the acquisition time of the current snapshot |
|
1023 | 1018 | switch(frequencyChannel) |
|
1024 | 1019 | { |
|
1025 | 1020 | case 1: // 1 is for F1 = 4096 Hz |
|
1026 | 1021 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
1027 | 1022 | nb_ring_nodes = NB_RING_NODES_F1; |
|
1028 | 1023 | frequency_asLong = 4096; |
|
1029 | 1024 | nbTicksPerSample_asLong = 16; // 65536 / 4096; |
|
1030 | 1025 | break; |
|
1031 | 1026 | case 2: // 2 is for F2 = 256 Hz |
|
1032 | 1027 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
1033 | 1028 | nb_ring_nodes = NB_RING_NODES_F2; |
|
1034 | 1029 | frequency_asLong = 256; |
|
1035 | 1030 | nbTicksPerSample_asLong = 256; // 65536 / 256; |
|
1036 | 1031 | break; |
|
1037 | 1032 | default: |
|
1038 | 1033 | acquisitionTime_asLong = centerTime_asLong; |
|
1039 | 1034 | frequency_asLong = 256; |
|
1040 | 1035 | nbTicksPerSample_asLong = 256; |
|
1041 | 1036 | break; |
|
1042 | 1037 | } |
|
1043 | 1038 | |
|
1044 | 1039 | //**************************************************************************** |
|
1045 | 1040 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
1046 | 1041 | for (i=0; i<nb_ring_nodes; i++) |
|
1047 | 1042 | { |
|
1048 | 1043 | PRINTF1("%d ... ", i) |
|
1049 | 1044 | build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send ); |
|
1050 | 1045 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
1051 | 1046 | { |
|
1052 | 1047 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) |
|
1053 | 1048 | break; |
|
1054 | 1049 | } |
|
1055 | 1050 | ring_node_to_send = ring_node_to_send->previous; |
|
1056 | 1051 | } |
|
1057 | 1052 | |
|
1058 | 1053 | // (5) compute the number of samples to take in the current buffer |
|
1059 | 1054 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; |
|
1060 | 1055 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
1061 | 1056 | PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong) |
|
1062 | 1057 | |
|
1063 | 1058 | // (6) compute the final acquisition time |
|
1064 | 1059 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
1065 | 1060 | sampleOffset_asLong * nbTicksPerSample_asLong; |
|
1066 | 1061 | |
|
1067 | 1062 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
1068 | 1063 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
1069 | 1064 | ptr2 = (unsigned char*) wf_snap_extracted; |
|
1070 | 1065 | ptr2[0] = ptr1[ 2 + 2 ]; |
|
1071 | 1066 | ptr2[1] = ptr1[ 3 + 2 ]; |
|
1072 | 1067 | ptr2[2] = ptr1[ 0 + 2 ]; |
|
1073 | 1068 | ptr2[3] = ptr1[ 1 + 2 ]; |
|
1074 | 1069 | ptr2[4] = ptr1[ 4 + 2 ]; |
|
1075 | 1070 | ptr2[5] = ptr1[ 5 + 2 ]; |
|
1076 | 1071 | |
|
1077 | 1072 | // re set the synchronization bit |
|
1078 | 1073 | |
|
1079 | 1074 | |
|
1080 | 1075 | // copy the part 1 of the snapshot in the extracted buffer |
|
1081 | 1076 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
1082 | 1077 | { |
|
1083 | 1078 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1084 | 1079 | ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
1085 | 1080 | } |
|
1086 | 1081 | // copy the part 2 of the snapshot in the extracted buffer |
|
1087 | 1082 | ring_node_to_send = ring_node_to_send->next; |
|
1088 | 1083 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
1089 | 1084 | { |
|
1090 | 1085 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1091 | 1086 | ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET]; |
|
1092 | 1087 | } |
|
1093 | 1088 | } |
|
1094 | 1089 | |
|
1095 | 1090 | void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node ) |
|
1096 | 1091 | { |
|
1097 | 1092 | unsigned char *acquisitionTimeCharPtr; |
|
1098 | 1093 | |
|
1099 | 1094 | acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address; |
|
1100 | 1095 | |
|
1101 | 1096 | *acquisitionTimeAslong = 0x00; |
|
1102 | 1097 | *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 ) |
|
1103 | 1098 | + ( acquisitionTimeCharPtr[1] << 16 ) |
|
1104 | 1099 | + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit |
|
1105 | 1100 | + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 ) |
|
1106 | 1101 | + ( acquisitionTimeCharPtr[4] << 8 ) |
|
1107 | 1102 | + ( acquisitionTimeCharPtr[5] ); |
|
1108 | 1103 | } |
|
1109 | 1104 | |
|
1110 | 1105 | //************** |
|
1111 | 1106 | // wfp registers |
|
1112 | 1107 | void reset_wfp_burst_enable(void) |
|
1113 | 1108 | { |
|
1114 | 1109 | /** This function resets the waveform picker burst_enable register. |
|
1115 | 1110 | * |
|
1116 | 1111 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1117 | 1112 | * |
|
1118 | 1113 | */ |
|
1119 | 1114 | |
|
1120 | 1115 | waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1121 | 1116 | } |
|
1122 | 1117 | |
|
1123 | 1118 | void reset_wfp_status( void ) |
|
1124 | 1119 | { |
|
1125 | 1120 | /** This function resets the waveform picker status register. |
|
1126 | 1121 | * |
|
1127 | 1122 | * All status bits are set to 0 [new_err full_err full]. |
|
1128 | 1123 | * |
|
1129 | 1124 | */ |
|
1130 | 1125 | |
|
1131 | 1126 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1132 | 1127 | } |
|
1133 | 1128 | |
|
1134 | 1129 | void reset_waveform_picker_regs(void) |
|
1135 | 1130 | { |
|
1136 | 1131 | /** This function resets the waveform picker module registers. |
|
1137 | 1132 | * |
|
1138 | 1133 | * The registers affected by this function are located at the following offset addresses: |
|
1139 | 1134 | * - 0x00 data_shaping |
|
1140 | 1135 | * - 0x04 run_burst_enable |
|
1141 | 1136 | * - 0x08 addr_data_f0 |
|
1142 | 1137 | * - 0x0C addr_data_f1 |
|
1143 | 1138 | * - 0x10 addr_data_f2 |
|
1144 | 1139 | * - 0x14 addr_data_f3 |
|
1145 | 1140 | * - 0x18 status |
|
1146 | 1141 | * - 0x1C delta_snapshot |
|
1147 | 1142 | * - 0x20 delta_f0 |
|
1148 | 1143 | * - 0x24 delta_f0_2 |
|
1149 | 1144 | * - 0x28 delta_f1 |
|
1150 | 1145 | * - 0x2c delta_f2 |
|
1151 | 1146 | * - 0x30 nb_data_by_buffer |
|
1152 | 1147 | * - 0x34 nb_snapshot_param |
|
1153 | 1148 | * - 0x38 start_date |
|
1154 | 1149 | * - 0x3c nb_word_in_buffer |
|
1155 | 1150 | * |
|
1156 | 1151 | */ |
|
1157 | 1152 | |
|
1158 | 1153 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1159 | 1154 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1160 | 1155 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08 |
|
1161 | 1156 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c |
|
1162 | 1157 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10 |
|
1163 | 1158 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14 |
|
1164 | 1159 | reset_wfp_status(); // 0x18 |
|
1165 | 1160 | // |
|
1166 | 1161 | set_wfp_delta_snapshot(); // 0x1c |
|
1167 | 1162 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1168 | 1163 | set_wfp_delta_f1(); // 0x28 |
|
1169 | 1164 | set_wfp_delta_f2(); // 0x2c |
|
1170 | 1165 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) |
|
1171 | 1166 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) |
|
1172 | 1167 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) |
|
1173 | 1168 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) |
|
1174 | 1169 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) |
|
1175 | 1170 | // 2688 = 8 * 336 |
|
1176 | 1171 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1177 | 1172 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples |
|
1178 | 1173 | waveform_picker_regs->start_date = 0x00; // 0x38 |
|
1179 | 1174 | waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066 |
|
1180 | 1175 | } |
|
1181 | 1176 | |
|
1182 | 1177 | void set_wfp_data_shaping( void ) |
|
1183 | 1178 | { |
|
1184 | 1179 | /** This function sets the data_shaping register of the waveform picker module. |
|
1185 | 1180 | * |
|
1186 | 1181 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1187 | 1182 | * bw_sp0_sp1_r0_r1 |
|
1188 | 1183 | * |
|
1189 | 1184 | */ |
|
1190 | 1185 | |
|
1191 | 1186 | unsigned char data_shaping; |
|
1192 | 1187 | |
|
1193 | 1188 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1194 | 1189 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1195 | 1190 | |
|
1196 | 1191 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; |
|
1197 | 1192 | |
|
1198 | 1193 | waveform_picker_regs->data_shaping = |
|
1199 | 1194 | ( (data_shaping & 0x10) >> 4 ) // BW |
|
1200 | 1195 | + ( (data_shaping & 0x08) >> 2 ) // SP0 |
|
1201 | 1196 | + ( (data_shaping & 0x04) ) // SP1 |
|
1202 | 1197 | + ( (data_shaping & 0x02) << 2 ) // R0 |
|
1203 | 1198 | + ( (data_shaping & 0x01) << 4 ); // R1 |
|
1204 | 1199 | } |
|
1205 | 1200 | |
|
1206 | 1201 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1207 | 1202 | { |
|
1208 | 1203 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1209 | 1204 | * |
|
1210 | 1205 | * @param mode is the LFR mode to launch. |
|
1211 | 1206 | * |
|
1212 | 1207 | * The burst bits shall be before the enable bits. |
|
1213 | 1208 | * |
|
1214 | 1209 | */ |
|
1215 | 1210 | |
|
1216 | 1211 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1217 | 1212 | // the burst bits shall be set first, before the enable bits |
|
1218 | 1213 | switch(mode) { |
|
1219 | 1214 | case(LFR_MODE_NORMAL): |
|
1220 | 1215 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable |
|
1221 | 1216 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
1222 | 1217 | break; |
|
1223 | 1218 | case(LFR_MODE_BURST): |
|
1224 | 1219 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1225 | 1220 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 |
|
1226 | 1221 | break; |
|
1227 | 1222 | case(LFR_MODE_SBM1): |
|
1228 | 1223 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1229 | 1224 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1230 | 1225 | break; |
|
1231 | 1226 | case(LFR_MODE_SBM2): |
|
1232 | 1227 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1233 | 1228 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1234 | 1229 | break; |
|
1235 | 1230 | default: |
|
1236 | 1231 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1237 | 1232 | break; |
|
1238 | 1233 | } |
|
1239 | 1234 | } |
|
1240 | 1235 | |
|
1241 | 1236 | void set_wfp_delta_snapshot( void ) |
|
1242 | 1237 | { |
|
1243 | 1238 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1244 | 1239 | * |
|
1245 | 1240 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1246 | 1241 | * - sy_lfr_n_swf_p[0] |
|
1247 | 1242 | * - sy_lfr_n_swf_p[1] |
|
1248 | 1243 | * |
|
1249 | 1244 | */ |
|
1250 | 1245 | |
|
1251 | 1246 | unsigned int delta_snapshot; |
|
1252 | 1247 | unsigned int delta_snapshot_in_T2; |
|
1253 | 1248 | |
|
1254 | 1249 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1255 | 1250 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1256 | 1251 | |
|
1257 | 1252 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1258 | 1253 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes |
|
1259 | 1254 | } |
|
1260 | 1255 | |
|
1261 | 1256 | void set_wfp_delta_f0_f0_2( void ) |
|
1262 | 1257 | { |
|
1263 | 1258 | unsigned int delta_snapshot; |
|
1264 | 1259 | unsigned int nb_samples_per_snapshot; |
|
1265 | 1260 | float delta_f0_in_float; |
|
1266 | 1261 | |
|
1267 | 1262 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1268 | 1263 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1269 | 1264 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1270 | 1265 | |
|
1271 | 1266 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1272 | 1267 | waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits |
|
1273 | 1268 | } |
|
1274 | 1269 | |
|
1275 | 1270 | void set_wfp_delta_f1( void ) |
|
1276 | 1271 | { |
|
1277 | 1272 | unsigned int delta_snapshot; |
|
1278 | 1273 | unsigned int nb_samples_per_snapshot; |
|
1279 | 1274 | float delta_f1_in_float; |
|
1280 | 1275 | |
|
1281 | 1276 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1282 | 1277 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1283 | 1278 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1284 | 1279 | |
|
1285 | 1280 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1286 | 1281 | } |
|
1287 | 1282 | |
|
1288 | 1283 | void set_wfp_delta_f2() |
|
1289 | 1284 | { |
|
1290 | 1285 | unsigned int delta_snapshot; |
|
1291 | 1286 | unsigned int nb_samples_per_snapshot; |
|
1292 | 1287 | |
|
1293 | 1288 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1294 | 1289 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1295 | 1290 | |
|
1296 | 1291 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; |
|
1297 | 1292 | } |
|
1298 | 1293 | |
|
1299 | 1294 | //***************** |
|
1300 | 1295 | // local parameters |
|
1301 | 1296 | void set_local_nb_interrupt_f0_MAX( void ) |
|
1302 | 1297 | { |
|
1303 | 1298 | /** This function sets the value of the nb_interrupt_f0_MAX local parameter. |
|
1304 | 1299 | * |
|
1305 | 1300 | * This parameter is used for the SM validation only.\n |
|
1306 | 1301 | * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices |
|
1307 | 1302 | * module before launching a basic processing. |
|
1308 | 1303 | * |
|
1309 | 1304 | */ |
|
1310 | 1305 | |
|
1311 | 1306 | param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256 |
|
1312 | 1307 | + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100; |
|
1313 | 1308 | } |
|
1314 | 1309 | |
|
1315 | 1310 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1316 | 1311 | { |
|
1317 | 1312 | unsigned short *sequence_cnt; |
|
1318 | 1313 | unsigned short segmentation_grouping_flag; |
|
1319 | 1314 | unsigned short new_packet_sequence_control; |
|
1320 | 1315 | |
|
1321 | 1316 | if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2) |
|
1322 | 1317 | || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) ) |
|
1323 | 1318 | { |
|
1324 | 1319 | sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1325 | 1320 | } |
|
1326 | 1321 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) ) |
|
1327 | 1322 | { |
|
1328 | 1323 | sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1329 | 1324 | } |
|
1330 | 1325 | else |
|
1331 | 1326 | { |
|
1332 | 1327 | sequence_cnt = NULL; |
|
1333 | 1328 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1334 | 1329 | } |
|
1335 | 1330 | |
|
1336 | 1331 | if (sequence_cnt != NULL) |
|
1337 | 1332 | { |
|
1338 | 1333 | segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8; |
|
1339 | 1334 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1340 | 1335 | |
|
1341 | 1336 | new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ; |
|
1342 | 1337 | |
|
1343 | 1338 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1344 | 1339 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1345 | 1340 | |
|
1346 | 1341 | // increment the sequence counter for the next packet |
|
1347 | 1342 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1348 | 1343 | { |
|
1349 | 1344 | *sequence_cnt = *sequence_cnt + 1; |
|
1350 | 1345 | } |
|
1351 | 1346 | else |
|
1352 | 1347 | { |
|
1353 | 1348 | *sequence_cnt = 0; |
|
1354 | 1349 | } |
|
1355 | 1350 | } |
|
1356 | 1351 | } |
General Comments 0
You need to be logged in to leave comments.
Login now