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