##// END OF EJS Templates
Minor updates
leroy -
r3:bf349cb3902d default
parent child
Show More
@@ -1,264 +1,264
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by Qt Creator 2.4.1, 2012-12-06T08:47:47. -->
3 <!-- Written by Qt Creator 2.4.1, 2012-12-07T14:08:53. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
15 15 <value type="QString" key="language">Cpp</value>
16 16 <valuemap type="QVariantMap" key="value">
17 17 <value type="QString" key="CurrentPreferences">CppGlobal</value>
18 18 </valuemap>
19 19 </valuemap>
20 20 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
21 21 <value type="QString" key="language">QmlJS</value>
22 22 <valuemap type="QVariantMap" key="value">
23 23 <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
24 24 </valuemap>
25 25 </valuemap>
26 26 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
27 27 <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
28 28 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
29 29 <value type="int" key="EditorConfiguration.IndentSize">4</value>
30 30 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
31 31 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
32 32 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
33 33 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
34 34 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
35 35 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
36 36 <value type="int" key="EditorConfiguration.TabSize">8</value>
37 37 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
38 38 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
39 39 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
40 40 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
41 41 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
42 42 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
43 43 </valuemap>
44 44 </data>
45 45 <data>
46 46 <variable>ProjectExplorer.Project.PluginSettings</variable>
47 47 <valuemap type="QVariantMap"/>
48 48 </data>
49 49 <data>
50 50 <variable>ProjectExplorer.Project.Target.0</variable>
51 51 <valuemap type="QVariantMap">
52 52 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
53 53 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
54 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
55 55 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
56 56 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
58 58 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
59 59 <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
61 61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
62 62 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
63 63 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
64 64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
65 65 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
66 66 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
67 67 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
69 69 </valuemap>
70 70 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
71 71 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
72 72 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
73 73 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
74 74 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
75 75 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
76 76 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
77 77 </valuemap>
78 78 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
79 79 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
80 80 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
81 81 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
82 82 </valuemap>
83 83 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
84 84 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
85 85 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
86 86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
88 88 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
89 89 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
90 90 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
91 91 </valuemap>
92 92 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
93 93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
96 96 </valuemap>
97 97 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
98 98 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
99 99 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
100 100 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
101 101 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
102 102 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
103 103 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
104 104 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/LPPMON_PLUGINS_PAUL</value>
105 105 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
106 106 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
107 107 </valuemap>
108 108 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
109 109 <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb</value>
110 110 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
111 111 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
112 112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
115 115 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
116 116 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
117 117 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
118 118 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
119 119 </valuemap>
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
121 121 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
122 122 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
124 124 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
125 125 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
126 126 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
127 127 </valuemap>
128 128 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
129 129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
130 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
131 131 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
132 132 </valuemap>
133 133 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
134 134 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
135 135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
136 136 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
137 137 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
138 138 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
139 139 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
140 140 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
141 141 </valuemap>
142 142 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
143 143 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
144 144 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
145 145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
146 146 </valuemap>
147 147 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
148 148 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
149 149 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
150 150 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
151 151 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
152 152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
153 153 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
154 154 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/LPPMON_PLUGINS_PAUL</value>
155 155 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
156 156 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
157 157 </valuemap>
158 158 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
159 159 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
160 160 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
161 161 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
162 162 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
163 163 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
164 164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
165 165 </valuemap>
166 166 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
167 167 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
168 168 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
169 169 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
170 170 </valuemap>
171 171 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
172 172 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
173 173 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
174 174 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
175 175 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
176 176 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
177 177 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
178 178 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
179 179 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
180 180 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
181 181 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
182 182 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
183 183 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
184 184 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
185 185 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
186 186 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
187 187 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
188 188 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
189 189 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
190 190 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
191 191 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
192 192 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
193 193 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
194 194 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
195 195 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
196 196 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
197 197 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
198 198 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
199 199 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
200 200 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
201 201 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
202 202 <value type="int">0</value>
203 203 <value type="int">1</value>
204 204 <value type="int">2</value>
205 205 <value type="int">3</value>
206 206 <value type="int">4</value>
207 207 <value type="int">5</value>
208 208 <value type="int">6</value>
209 209 <value type="int">7</value>
210 210 <value type="int">8</value>
211 211 <value type="int">9</value>
212 212 <value type="int">10</value>
213 213 <value type="int">11</value>
214 214 <value type="int">12</value>
215 215 <value type="int">13</value>
216 216 <value type="int">14</value>
217 217 </valuelist>
218 218 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
219 219 <value type="int">0</value>
220 220 <value type="int">1</value>
221 221 <value type="int">2</value>
222 222 <value type="int">3</value>
223 223 <value type="int">4</value>
224 224 <value type="int">5</value>
225 225 <value type="int">6</value>
226 226 <value type="int">7</value>
227 227 <value type="int">8</value>
228 228 <value type="int">9</value>
229 229 <value type="int">10</value>
230 230 <value type="int">11</value>
231 231 <value type="int">12</value>
232 232 <value type="int">13</value>
233 233 <value type="int">14</value>
234 234 </valuelist>
235 235 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
236 236 <value type="int" key="ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase">2</value>
237 237 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">lppmon</value>
238 238 <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
239 239 <valuelist type="QVariantList" key="ProjectExplorer.CustomExecutableRunConfiguration.UserEnvironmentChanges"/>
240 240 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
241 241 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run lppmon</value>
242 242 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
243 243 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
244 244 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
245 245 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
246 246 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
247 247 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
248 248 </valuemap>
249 249 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
250 250 </valuemap>
251 251 </data>
252 252 <data>
253 253 <variable>ProjectExplorer.Project.TargetCount</variable>
254 254 <value type="int">1</value>
255 255 </data>
256 256 <data>
257 257 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
258 258 <value type="QString">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
259 259 </data>
260 260 <data>
261 261 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
262 262 <value type="int">10</value>
263 263 </data>
264 264 </qtcreator>
@@ -1,936 +1,923
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the LPPMON Software
3 3 -- Copyright (C) 2012, Laboratory of Plasma Physics - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Paul LEROY
20 20 -- Mail : paul.leroy@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "rmapplugin.h"
23 23 #include <QHostAddress>
24 24 #include <QIODevice>
25 25 #include <QApplication>
26 26 #include <rmappluginpythonwrapper.h>
27 27
28 28 rmapplugin::rmapplugin(QWidget *parent)
29 29 :lppmonplugin(parent,false)
30 30 {
31 31 this->UI = new rmapPluginUI();
32 32 this->setWindowTitle(tr("RMAP and SPW Communication"));
33 33 this->setWidget((QWidget*)this->UI);
34 34 RMAPSend_SOCKET = new QTcpSocket;
35 35 RMAPReceive_SOCKET = new QTcpSocket;
36 36 GRESBStatusQuery_SOCKET = new QTcpSocket;
37 37 spwPacketReceiverOBJECT = new spwpacketreceiver;
38 38 spwPacketReceiverOBJECT->gresbReceptionSocket = RMAPReceive_SOCKET;
39 39 timeCode = 0;
40 40 time_COARSE = 0;
41 41 time_FINE = 0;
42 42 currentBridge = selectedBridgeIsUnknown;
43 43
44 44 /*Python wrapper*/
45 45 this->pyObject = new rmappluginPythonWrapper();
46 46 connect(this->pyObject,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint)));
47 47 connect(this->pyObject,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint)));
48 48 /*==============*/
49 49
50 //connect(UI->rmapOpenCommunicationButton, SIGNAL(clicked()), this, SLOT(RMAP_CONNECT()));
51 //connect(UI->rmapCloseCommunicationButton, SIGNAL(clicked()), this, SLOT(RMAP_DISCONNECT()));
52 50 connect(UI->rmapOpenCommunicationButton, SIGNAL(clicked()), this, SLOT(openBridge()));
53 51 connect(UI->rmapCloseCommunicationButton, SIGNAL(clicked()), this, SLOT(closeBridge()));
54 52 connect(RMAPSend_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(RMAPSendConnectionState(QAbstractSocket::SocketState)));
55 53 connect(RMAPReceive_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(RMAPReceiveConnectionState(QAbstractSocket::SocketState)));
56 54 connect(GRESBStatusQuery_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(GRESBConnectionState(QAbstractSocket::SocketState)));
57 55 connect(UI->gresbStatusQueryRetryButton, SIGNAL(clicked()), this, SLOT(reTestSPWLink()));
58 56 connect(this->UI->spwLinkStatusEnquiry->readSPWStatusButton, SIGNAL(clicked()), this, SLOT(GRESBStatusQuery()));
59 57 connect(this->RMAPReceive_SOCKET, SIGNAL(readyRead()), this->spwPacketReceiverOBJECT, SLOT(receiveSPWPacket()));
60 58
61 59 // CCSDS
62 60 connect(this->UI->sendCCSDSCommandButton, SIGNAL(clicked()), this, SLOT(sendCCSDS()));
63 61 connect(this->UI->send_TC_LFR_UPDATE_TIME_Button, SIGNAL(clicked()), this, SLOT(send_TC_LFR_UPDATE_TIME()));
64 62 connect(this->UI->reset_TC_LFR_UPDATE_TIME_Button, SIGNAL(clicked()), this, SLOT(reset_TC_LFR_UPDATE_TIME()));
65 63
66 64 // CONSOLE
67 65 connect(this->spwPacketReceiverOBJECT, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString)));
68 66 connect(this->UI->starDundee, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString)));
69 67
70 68 // spectralMAtricesDMASimulator
71 69 connect(this->UI->spectralMatricesDMASimulator, SIGNAL(rmapplugginRead(uint*,uint,uint)), this, SLOT(Read(uint*,uint,uint)));
72 70 connect(this->UI->spectralMatricesDMASimulator, SIGNAL(rmapplugginWrite(uint*,uint,uint)), this, SLOT(Write(uint*,uint,uint)));
73 71 connect(this->UI->spectralMatricesDMASimulator, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString)));
74 72
75 73 // GRESB
76 74 connect(this, SIGNAL(gresbIsOpen(bool)), this, SLOT(gresbSelection(bool)));
77 75
78 76 // Star Dundee
79 connect(this->UI->starDundee, SIGNAL(starDundeeIsOpen(bool)), this, SLOT(activatePluginViaStarDundee(bool)));
77 connect(this->UI->starDundee, SIGNAL(isOpen(bool)), this, SLOT(activatePluginViaStarDundee(bool)));
80 78 connect(this->UI->starDundee, SIGNAL(RMAP_write_reply_setText(QString)), this, SLOT(RMAP_write_reply_setText(QString)));
81 79 connect(this->UI->starDundee, SIGNAL(appendToLog(QString)), this, SLOT(appendToLog(QString)));
82 80
83 81 connect(this->UI, SIGNAL(bridgeHasChanged(selectedBridge)), this, SLOT(bridgeHasChanged(selectedBridge)));
84 82 }
85 83
86 84 rmapplugin::~rmapplugin()
87 85 {
88 86 if (!RMAPSend_SOCKET->isOpen()) RMAPSend_SOCKET->disconnectFromHost();
89 87 if (!RMAPReceive_SOCKET->isOpen()) RMAPReceive_SOCKET->disconnectFromHost();
90 88 if (!GRESBStatusQuery_SOCKET->isOpen()) GRESBStatusQuery_SOCKET->disconnectFromHost();
91 89 }
92 90
93 91 unsigned int rmapplugin::Write(unsigned int *Value, unsigned int count, unsigned int address)
94 92 {
95 93 unsigned int result;
96 94 switch(currentBridge)
97 95 {
98 96 case selectedBridgeIsGRESB :
99 97 result = WriteGRESB(Value, count, address);
100 98 break;
101 99 case selectedBridgeIsStarDundee :
102 result = this->WriteStarDundee(Value, count, address);
100 result = UI->starDundee->Write(Value, count, address);
103 101 break;
104 102 default:
105 103 result = 1;
106 104 break;
107 105 }
108 106 return result;
109 107 }
110 108
111 109 unsigned int rmapplugin::Read(unsigned int *Value, unsigned int count, unsigned int address)
112 110 {
113 111 unsigned int result;
114 112 switch(currentBridge)
115 113 {
116 114 case selectedBridgeIsGRESB :
117 115 result = ReadGRESB(Value, count, address);
118 116 break;
119 117 case selectedBridgeIsStarDundee :
120 result = this->ReadStarDundee(Value, count, address);
118 result = UI->starDundee->Read(Value, count, address);
121 119 break;
122 120 default:
123 121 result = 1;
124 122 break;
125 123 }
126 124 return result;
127 125 }
128 126
129 127 unsigned int rmapplugin::WriteGRESB(unsigned int *Value, unsigned int count, unsigned int address)
130 128 {
131 129 unsigned int remainingCount = count;
132 130 unsigned int iOffset = 0;
133 131 QString console_message;
134 132 char* data;
135 133
136 134 if(spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->available()!=0)
137 135 {
138 136 APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** RMAP request already running, WRITE access stopped");
139 137 return 1;
140 138 }
141 139
142 140 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: unavailable");
143 141
144 142 data = (char*) malloc(READ_WRITE_MAX_COUNTS*4);
145 143
146 144 APPENDTOLOG(QString("*** START *** WRITE ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16));
147 145
148 146 while (remainingCount > READ_WRITE_MAX_COUNTS)
149 147 {
150 148 for (int i = 0; i<READ_WRITE_MAX_COUNTS; i++)
151 149 {
152 150 data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]);
153 151 data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8);
154 152 data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16);
155 153 data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24);
156 154 }
157 155
158 156 console_message.sprintf("remainingCount: %d => ", remainingCount);
159 157 APPENDTOLOG(console_message + QString("Write ")+ QString::number(READ_WRITE_MAX_COUNTS*4) + QString(" byte(s) @0x")+ QString::number(address,16));
160 158
161 159 if(WriteBLOCK(data, READ_WRITE_MAX_COUNTS*4, address)==0)
162 160 {
163 161 APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** RMAP write command failed");
164 162 return 1;
165 163 }
166 164
167 165 remainingCount = remainingCount - READ_WRITE_MAX_COUNTS;
168 166 address = address + READ_WRITE_MAX_COUNTS * 4;
169 167 iOffset = iOffset + READ_WRITE_MAX_COUNTS;
170 168 }
171 169
172 170 if (remainingCount > 0)
173 171 {
174 172 for (unsigned int i = 0; i<remainingCount; i++)
175 173 {
176 174 data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]);
177 175 data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8);
178 176 data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16);
179 177 data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24);
180 178 }
181 179
182 180 console_message.sprintf("remainingCount: %d => ", remainingCount);
183 181 APPENDTOLOG(console_message + QString("Write ")+ QString::number(remainingCount*4) + QString(" byte(s) @0x")+ QString::number(address,16));
184 182
185 183 if (WriteBLOCK(data, remainingCount*4, address)==0)
186 184 {
187 185 APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** RMAP write command failed");
188 186 return 1;
189 187 }
190 188 }
191 189
192 190 APPENDTOLOG(QString("*** STOP *** WRITE"));
193 191 free(data);
194 192 return count;
195 193 }
196 194
197 195 unsigned int rmapplugin::ReadGRESB(unsigned int *Value, unsigned int count, unsigned int address)
198 196 {
199 197 unsigned int remainingCount = count;
200 198 unsigned int iOffset = 0;
201 199 QString console_message;
202 200
203 201 if(spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->available()!=0)
204 202 {
205 203 APPENDTOLOG("WARNING === in function READ of rmapplugin *** RMAP request already running, READ access stopped");
206 204 return 1;
207 205 }
208 206 APPENDTOLOG(QString("*** START *** READ ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16));
209 207
210 208 while (remainingCount > READ_WRITE_MAX_COUNTS)
211 209 {
212 210 console_message.sprintf("remainingCount: %d => ", remainingCount);
213 211 APPENDTOLOG(console_message + QString("Read ")+ QString::number(4*READ_WRITE_MAX_COUNTS) + QString(" byte(s) @0x")+ QString::number(address,16));
214 212
215 213 if (ReadBLOCK(READ_WRITE_MAX_COUNTS*4, address)==0)
216 214 {
217 215 APPENDTOLOG("WARNING === in function READ of rmapplugin *** RMAP packet not received");
218 216 return 1;
219 217 }
220 218
221 219 for(int i=0;i<READ_WRITE_MAX_COUNTS;i++)
222 220 {
223 221 Value[i+iOffset] = (unsigned char) spwPacketReceiverOBJECT->rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH];
224 222 for(int j=1;j<4;j++)
225 223 {
226 224 Value[i+iOffset]= ((unsigned char)(spwPacketReceiverOBJECT->rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) + Value[i+iOffset]*256;
227 225 }
228 226 }
229 227
230 228 remainingCount = remainingCount - READ_WRITE_MAX_COUNTS;
231 229 address = address + READ_WRITE_MAX_COUNTS * 4;
232 230 iOffset = iOffset + READ_WRITE_MAX_COUNTS;
233 231 spwPacketReceiverOBJECT->acquireRMAPSemaphore();
234 232 }
235 233
236 234 if (remainingCount > 0)
237 235 {
238 236 console_message.sprintf("remainingCount: %d => ", remainingCount);
239 237 APPENDTOLOG(console_message + QString("Read ")+ QString::number(4*remainingCount) + QString(" byte(s) @0x")+ QString::number(address,16));
240 238
241 239 if (ReadBLOCK(4*remainingCount, address)==0)
242 240 {
243 241 APPENDTOLOG("WARNING === in function READ of rmapplugin *** RMAP packet not received");
244 242 return 1;
245 243 }
246 244
247 245 for(unsigned int i=0;i<remainingCount;i++)
248 246 {
249 247 Value[i+iOffset] = (unsigned char) spwPacketReceiverOBJECT->rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH];
250 248 for(int j=1;j<4;j++)
251 249 {
252 250 Value[i+iOffset]= ((unsigned char)(spwPacketReceiverOBJECT->rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) + Value[i+iOffset]*256;
253 251 }
254 252 }
255 253 spwPacketReceiverOBJECT->acquireRMAPSemaphore();
256 254 }
257 255
258 256 APPENDTOLOG(QString("*** STOP *** READ "));
259 257 return count;
260 258 }
261 259
262 260 unsigned int rmapplugin::WriteBLOCK(char *data, unsigned int nbBytes, unsigned int address)
263 261 {
264 262 QTime RMAPTimeout;
265 263 RMAP *RMAPCommand;
266 264 int errorCode;
267 265 QString console_message;
268 266
269 267 if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 1)
270 268 {
271 269 RMAP_DISCONNECT();
272 270 return 1;
273 271 }
274 272
275 273 RMAPCommand = new RMAP(UI->getCommandCode(),
276 274 UI->rmapTargetLogicalAddressSpinBox->value(),
277 275 UI->rmapSourceLogicalAddressSpinBox->value(),
278 276 address,
279 277 nbBytes,
280 278 data);
281 279
282 280 // SEND GRESB HEADER
283 281 RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->GRESBHeader), 4);
284 282 // SEND SPACEWIRE PACKET HEADER
285 283 RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->RMAPHeader), sizeof(RMAPCommand->RMAPHeader));
286 284 // SEND DATA
287 285 RMAPSend_SOCKET->write( data, nbBytes);
288 286 // SEND DATA CRC
289 287 RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->dataCRC), 1);
290 288 RMAPTimeout.start();
291 289 while(RMAPSend_SOCKET->bytesToWrite() > 0)
292 290 {
293 291 RMAPSend_SOCKET->waitForBytesWritten(100);
294 292 if(RMAPTimeout.elapsed()>1000)
295 293 {
296 294 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** sending Write RMAP Command timeout");
297 295 return 0;
298 296 }
299 297 }
300 298
301 299 if (UI->RMAP_write_reply->isChecked())
302 300 {
303 301 // WAIT FOR THE RMAP REPLY PACKET
304 302 errorCode = spwPacketReceiverOBJECT->receiveSPWPacket(1);
305 303 if (errorCode<=0)
306 304 {
307 305 APPENDTOLOG("WARNING === in function WriteBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode));
308 306 return 0;
309 307 }
310 308 if(spwPacketReceiverOBJECT->rmapPacketSize != 8)
311 309 {
312 310 console_message.sprintf("WARNING === in function WRITE (with reply) of rmapplugin *** write reply format not compliant\n");
313 311 APPENDTOLOG(console_message);
314 312 return 0;
315 313 }
316 314 switch (spwPacketReceiverOBJECT->rmapPacket[3]) // byte 4 is the status byte in the reply
317 315 {
318 316 case 0:
319 317 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 0 Successfull");
320 318 break;
321 319 case 1:
322 320 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** General error code");
323 321 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 1 General error code");
324 322 break;
325 323 case 2:
326 324 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Unused RMAP packet type or command code");
327 325 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 2 Unused RMAP packet type or command code");
328 326 break;
329 327 case 3:
330 328 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid key");
331 329 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 3 Invalid key");
332 330 break;
333 331 case 4:
334 332 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid data CRC");
335 333 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 4 Invalid data CRC");
336 334 break;
337 335 case 5:
338 336 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Early EOP");
339 337 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 5 Early EOP");
340 338 break;
341 339 case 6:
342 340 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Too much data");
343 341 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 6 Too much data");
344 342 break;
345 343 case 7:
346 344 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** EEP");
347 345 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 7 EEP");
348 346 break;
349 347 case 8:
350 348 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Reserved");
351 349 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 8 Reserved");
352 350 break;
353 351 case 9:
354 352 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Verify buffer overrun");
355 353 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 9 Verify buffer overrun");
356 354 break;
357 355 case 10:
358 356 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** RMAP command not implemented or not authorised");
359 357 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 10 RMAP command not implemented or not authorised");
360 358 break;
361 359 case 11:
362 360 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** RMW data length error");
363 361 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 11 RMAP RMW data length error");
364 362 break;
365 363 case 12:
366 364 APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid target logical address");
367 365 UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 12 Invalid target logical address");
368 366 break;
369 367 }
370 368 spwPacketReceiverOBJECT->acquireRMAPSemaphore();
371 369 }
372 370 return nbBytes;
373 371 }
374 372
375 373 unsigned int rmapplugin::ReadBLOCK(unsigned int nbBytes, unsigned int address)
376 374 {
377 375 int errorCode;
378 376 RMAP *RMAPCommand;
379 377 QTime RMAPTimeout;
380 378 unsigned int dataLength;
381 379 if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 1)
382 380 {
383 381 RMAP_DISCONNECT();
384 382 return 1;
385 383 }
386 384
387 385 if (nbBytes > 4)
388 386 {
389 387 RMAPCommand = new RMAP(read_Inc,
390 388 UI->rmapTargetLogicalAddressSpinBox->value(),
391 389 UI->rmapSourceLogicalAddressSpinBox->value(),
392 390 address,
393 391 nbBytes,
394 392 NULL);
395 393 }
396 394 else
397 395 {
398 396 RMAPCommand = new RMAP(read_Single,
399 397 UI->rmapTargetLogicalAddressSpinBox->value(),
400 398 UI->rmapSourceLogicalAddressSpinBox->value(),
401 399 address,
402 400 nbBytes,
403 401 NULL);
404 402 }
405 403
406 404 // SEND THE GRESB HEADER FOR THE RMAP READ COMMAND
407 405 RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->GRESBHeader), 4);
408 406 // SEND THE SPACEWIRE PACKET FOR THE RMAP READ COMMAND
409 407 RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->RMAPHeader), sizeof(RMAPCommand->RMAPHeader));
410 408 RMAPSend_SOCKET->waitForBytesWritten(100);
411 409 RMAPTimeout.start();
412 410 // write timeout
413 411 while(RMAPSend_SOCKET->bytesToWrite() > 0)
414 412 {
415 413 RMAPSend_SOCKET->waitForBytesWritten(100);
416 414 if(RMAPTimeout.elapsed()>1000)
417 415 {
418 416 APPENDTOLOG("WARNING === in function READ of rmapplugin *** sending Read RMAP Command timeout\n");
419 417 return 0;
420 418 }
421 419 }
422 420
423 421 // RECEIVE THE INCOMING RMAP PACKET
424 422 errorCode = spwPacketReceiverOBJECT->receiveSPWPacket(1); // request ID 1 is for RMAP packet
425 423 if (errorCode<=0)
426 424 {
427 425 APPENDTOLOG("WARNING === in function ReadBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode));
428 426 return 0;
429 427 }
430 428 dataLength = spwPacketReceiverOBJECT->rmapPacketSize - RMAP_READ_REPLY_HEADER_LENGTH - RMAP_DATA_CRC_LENGTH;
431 429 if(dataLength != nbBytes)
432 430 {
433 431 APPENDTOLOG("WARNING === in function READ of rmapplugin *** number of data received ("
434 432 +QString::number(dataLength)
435 433 +") not equal to number of data requested ("
436 434 +QString::number(READ_WRITE_MAX_COUNTS*4)
437 435 +")");
438 436 return 0;
439 437 }
440 438 return dataLength;
441 439 }
442 440
443 unsigned int rmapplugin::WriteStarDundee(unsigned int *Value, unsigned int count, unsigned int address)
444 {
445 unsigned int result;
446 result = UI->starDundee->WriteStarDundee(Value, count, address);
447 return result;
448 }
449
450 unsigned int rmapplugin::ReadStarDundee(unsigned int *Value, unsigned int count, unsigned int address)
451 {
452 unsigned int result;
453 result = UI->starDundee->ReadStarDundee(Value, count, address);
454 return result;
455 }
456
457 441 ////////
458 442 // SLOTS
459 443
460 444 unsigned int rmapplugin::WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) // SLOT
461 445 {
446 unsigned int result;
447 switch(currentBridge)
448 {
449 case selectedBridgeIsGRESB :
450 result = WriteSPWGRESB(Value, count, targetLogicalAddress, userApplication);
451 break;
452 case selectedBridgeIsStarDundee :
453 result = UI->starDundee->WriteSPW(Value, count, targetLogicalAddress, userApplication);
454 break;
455 default:
456 result = 1;
457 break;
458 }
459 return result;
460 }
461
462 unsigned int rmapplugin::WriteSPWGRESB(char *Value, unsigned int count, char targetLogicalAddress, char userApplication)
463 {
462 464 char protocoleIdentifier = 0x02;
463 465 char reserved = 0x00;
464 466 char gresbProtocole = 0x00;
465 467 unsigned char size[3];
466 468 unsigned int spwPacketSize = count + 4;
467 469 QTime SPWTimeout;
468 470
469 471 if (count>248)
470 472 {
471 473 APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** CCSDS packet size > 248 bytes\n");
472 474 return 1;
473 475 }
474 476
475 477 APPENDTOLOG(QString("*** START *** Send CCSDS packet of ")+ QString::number(count) + QString(" byte(s)"));
476 478
477 479 if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 1)
478 480 {
479 481 RMAP_DISCONNECT();
480 482 APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** SPW link not running\n");
481 483 return 1;
482 484 }
483 485
484 486 // SEND GRESB HEADER
485 487 size[0] = (unsigned char) ((unsigned int) spwPacketSize>>16);
486 488 size[1] = (unsigned char) ((unsigned int) spwPacketSize>>8);
487 489 size[2] = (unsigned char) ((unsigned int) spwPacketSize);
488 490 RMAPSend_SOCKET->write(&gresbProtocole, 1);
489 491 RMAPSend_SOCKET->write((char*) size, 3);
490 492 // SEND SPW HEADER
491 493 RMAPSend_SOCKET->write(&targetLogicalAddress, 1);
492 494 RMAPSend_SOCKET->write(&protocoleIdentifier, 1);
493 495 RMAPSend_SOCKET->write(&reserved, 1);
494 496 RMAPSend_SOCKET->write(&userApplication, 1);
495 497 // SEND CCSDS PACKET
496 498 RMAPSend_SOCKET->write(Value, count);
497 499 SPWTimeout.start();
498 500 while(RMAPSend_SOCKET->bytesToWrite() > 0)
499 501 {
500 502 RMAPSend_SOCKET->waitForBytesWritten(100);
501 503 if(SPWTimeout.elapsed()>1000)
502 504 {
503 505 APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** sending CCSDS packet timeout\n");
504 506 return 1;
505 507 }
506 508 }
507 509
508 510 APPENDTOLOG(QString("*** CCSDS packet sent"));
509 511
510 512 return count;
511 513 }
512 514
513 515 void rmapplugin::sendCCSDS() // SLOT
514 516 {
515 517 unsigned int nbBYTES_application_data = 8;
516 518 unsigned int count;
517 519 char *tab;
518 520 unsigned char packetErrorControl1 = 0xaa;
519 521 unsigned char packetErrorControl0 = 0xbb;
520 522
521 523 ccsds_command = new ccsds(1, 0, 0, nbBYTES_application_data+12, 0, 0, 0, 0, 0); // +12 => packet header 6 bytes + data field header 4 bytes + packet error control 2 bytes
522 524 /* unsigned char data_field_header,
523 525 unsigned char processID,
524 526 unsigned int sequence_count,
525 527 unsigned int packet_length,
526 528 unsigned char acceptance,
527 529 unsigned int completion,
528 530 unsigned char service_type,
529 531 unsigned char service_subtype,
530 532 unsigned char sourceID*/
531 533
532 534 count = nbBYTES_application_data+12; // 12 is the size in bytes of the header
533 535 tab = (char*) malloc(count);
534 536 tab[0] = ccsds_command->ccsds_header->packetId1;
535 537 tab[1] = ccsds_command->ccsds_header->packetId0;
536 538 tab[2] = ccsds_command->ccsds_header->packetSequenceControl1;
537 539 tab[3] = ccsds_command->ccsds_header->packetSequenceControl0;
538 540 tab[4] = ccsds_command->ccsds_header->packetLength1;
539 541 tab[5] = ccsds_command->ccsds_header->packetLength0;
540 542 tab[6] = ccsds_command->ccsds_header->dataFieldHeader3;
541 543 tab[7] = ccsds_command->ccsds_header->dataFieldHeader2;
542 544 tab[8] = ccsds_command->ccsds_header->dataFieldHeader1;
543 545 tab[9] = ccsds_command->ccsds_header->dataFieldHeader0;
544 546 tab[10]=0x00;
545 547 tab[11]=0x00;
546 548 tab[12]=0x00;
547 549 tab[13]=0x00;
548 550 tab[14]=0x00;
549 551 tab[15]=0x00;
550 552 tab[nbBYTES_application_data+10] = packetErrorControl1;
551 553 tab[nbBYTES_application_data+11] = packetErrorControl0;
552 554
553 555 WriteSPW(tab, count, UI->CCSDSTargetLogicalAddressSpinBox->value(), 0x00);
554 556
555 557 free(tab);
556 558 }
557 559
558 560 void rmapplugin::send_TC_LFR_UPDATE_TIME()
559 561 {
560 562 unsigned int nbBYTES_application_data = 6; // Time at CUC format is on 48 bits / 6 bytes
561 563 unsigned int count;
562 564 char *tab;
563 565 unsigned char packetErrorControl1 = 0xaa;
564 566 unsigned char packetErrorControl0 = 0xbb;
565 567
566 568 ccsds_command = new ccsds(1, 11, 0, nbBYTES_application_data, 1, 1, 9, 129, 0);
567 569 /* unsigned char data_field_header,
568 570 unsigned char processID,
569 571 unsigned int sequence_count,
570 572 unsigned int packet_length,
571 573 unsigned char acceptance,
572 574 unsigned int completion,
573 575 unsigned char service_type,
574 576 unsigned char service_subtype,
575 577 unsigned char sourceID*/
576 578
577 579 count = nbBYTES_application_data+12; // +12 => packet header 6 bytes + data field header 4 bytes + packet error control 2 bytes
578 580 tab = (char*) malloc(count);
579 581 tab[0] = ccsds_command->ccsds_header->packetId1;
580 582 tab[1] = ccsds_command->ccsds_header->packetId0;
581 583 tab[2] = ccsds_command->ccsds_header->packetSequenceControl1;
582 584 tab[3] = ccsds_command->ccsds_header->packetSequenceControl0;
583 585 tab[4] = ccsds_command->ccsds_header->packetLength1;
584 586 tab[5] = ccsds_command->ccsds_header->packetLength0;
585 587 tab[6] = ccsds_command->ccsds_header->dataFieldHeader3;
586 588 tab[7] = ccsds_command->ccsds_header->dataFieldHeader2;
587 589 tab[8] = ccsds_command->ccsds_header->dataFieldHeader1;
588 590 tab[9] = ccsds_command->ccsds_header->dataFieldHeader0;
589 591 tab[10] = (unsigned char) (time_COARSE>>24);
590 592 tab[11] = (unsigned char) (time_COARSE>>18);
591 593 tab[12] = (unsigned char) (time_COARSE>>8);
592 594 tab[13] = (unsigned char) (time_COARSE);
593 595 tab[14] = (unsigned char) (time_FINE>>8);
594 596 tab[15] = (unsigned char) (time_FINE);
595 597 tab[nbBYTES_application_data+10] = packetErrorControl1;
596 598 tab[nbBYTES_application_data+11] = packetErrorControl0;
597 599
598 600 WriteSPW(tab, count, UI->CCSDSTargetLogicalAddressSpinBox->value(), 0x00);
599 601
600 602 time_COARSE = time_COARSE+1;
601 603
602 604 free(tab);
603 605 }
604 606
605 607 void rmapplugin::reset_TC_LFR_UPDATE_TIME()
606 608 {
607 609 time_COARSE = 0;
608 610 time_FINE = 0;
609 611 }
610 612
611 613 void rmapplugin::openBridge()
612 614 {
613 615 switch(currentBridge)
614 616 {
615 617 case selectedBridgeIsGRESB :
616 618 RMAP_CONNECT();
617 619 break;
618 620 case selectedBridgeIsStarDundee :
619 this->UI->starDundee->OpenStarDundee();
621 this->UI->starDundee->Open();
620 622 break;
621 623 default:
622 624 break;
623 625 }
624 626 }
625 627
626 628 void rmapplugin::closeBridge()
627 629 {
628 630 switch(currentBridge)
629 631 {
630 632 case selectedBridgeIsGRESB :
631 633 RMAP_DISCONNECT();
632 634 break;
633 635 case selectedBridgeIsStarDundee :
634 this->UI->starDundee->CloseStarDundee();
636 this->UI->starDundee->Close();
635 637 break;
636 638 default:
637 639 break;
638 640 }
639 641 }
640 642
641 643 void rmapplugin::RMAP_CONNECT() // SLOT
642 644 {
643 645 bool spwRunning = true;
644 646 RMAPSend_SOCKET->connectToHost( QHostAddress(UI->gresbBridgeIPDialogBox->getGRESBIP()),
645 647 3000 + UI->gresbVirtualLinkSpinBox->value()*2,
646 648 QIODevice::WriteOnly);
647 649 RMAPReceive_SOCKET->connectToHost( QHostAddress(UI->gresbBridgeIPDialogBox->getGRESBIP()),
648 650 3000 + UI->gresbVirtualLinkSpinBox->value()*2+1,
649 651 QIODevice::ReadOnly);
650 652 GRESBStatusQuery_SOCKET->connectToHost( QHostAddress(UI->gresbBridgeIPDialogBox->getGRESBIP()),
651 653 3010,
652 654 QIODevice::ReadWrite);
653 655 GRESBStatusQuery_SOCKET->waitForConnected(10000);
654 656 RMAPReceive_SOCKET->readAll(); // read all remaining data from the reception socket
655 657 // initialize SPW packet semaphores
656 658 while (spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->available()!=0) spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->acquire();
657 659 while (spwPacketReceiverOBJECT->ccsdsPacketSEMAPHORE->available()!=0) spwPacketReceiverOBJECT->ccsdsPacketSEMAPHORE->acquire();
658 660 if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) != 0)
659 661 {
660 662 spwRunning = UI->gresbStatusQueryDialog->exec();
661 663 }
662 664 if (spwRunning == false) RMAP_DISCONNECT();
663 665 else
664 666 {
665 667 APPENDTOLOG(QString("SpaceWire running on virtual link ")+ QString::number(UI->spwLinkSpinBox->value()));
666 668 emit this->activateSig(true);
667 669 emit gresbIsOpen(true);
668 670 }
669 671 }
670 672
671 673 void rmapplugin::RMAP_DISCONNECT() // SLOT
672 674 {
673 675 RMAPSend_SOCKET->disconnectFromHost();
674 676 RMAPReceive_SOCKET->disconnectFromHost();
675 677 GRESBStatusQuery_SOCKET->disconnectFromHost();
676 678 emit this->activateSig(false);
677 679 emit gresbIsOpen(false);
678 680 }
679 681
680 682 void rmapplugin::RMAPSendConnectionState(QAbstractSocket::SocketState socketState) // SLOT
681 683 {
682 684 UI->rmapSendStateLabel->setText("");
683 685 QString socketMessage = "RMAP Send Socket State: ";
684 686 switch(socketState)
685 687 {
686 688 case QAbstractSocket::UnconnectedState :
687 689 socketMessage.append("0 => Unconnected");
688 690 UI->rmapOpenCommunicationButton->setEnabled(true);
689 691 UI->rmapCloseCommunicationButton->setEnabled(false);
690 692 emit this->activateSig(false);
691 693 break;
692 694 case 1:
693 695 socketMessage.append("1 => HostLookup");
694 696 break;
695 697 case 2:
696 698 socketMessage.append("2 => Connecting");
697 699 break;
698 700 case 3:
699 701 socketMessage.append("3 => Connected");
700 702 UI->rmapOpenCommunicationButton->setEnabled(false);
701 703 UI->rmapCloseCommunicationButton->setEnabled(true);
702 704 break;
703 705 case 4:
704 706 socketMessage.append("4 => Bound");
705 707 break;
706 708 case 5:
707 709 socketMessage.append("5 => Closing");
708 710 break;
709 711 case 6:
710 712 socketMessage.append("6 => Listening");
711 713 break;
712 714 }
713 715 UI->rmapSendStateLabel->setText(socketMessage);
714 716 APPENDTOLOG(socketMessage);
715 717 }
716 718
717 719 void rmapplugin::RMAPReceiveConnectionState(QAbstractSocket::SocketState socketState) // SLOT
718 720 {
719 721 UI->rmapReceiveStateLabel->setText("");
720 722 QString socketMessage = "RMAP Receive Socket State: ";
721 723 switch(socketState)
722 724 {
723 725 case QAbstractSocket::UnconnectedState :
724 726 socketMessage.append("0 => Unconnected");
725 727 break;
726 728 case 1:
727 729 socketMessage.append("1 => HostLookup");
728 730 break;
729 731 case 2:
730 732 socketMessage.append("2 => Connecting");
731 733 break;
732 734 case 3:
733 735 socketMessage.append("3 => Connected");
734 736 break;
735 737 case 4:
736 738 socketMessage.append("4 => Bound");
737 739 break;
738 740 case 5:
739 741 socketMessage.append("5 => Closing");
740 742 break;
741 743 case 6:
742 744 socketMessage.append("6 => Listening");
743 745 break;
744 746 }
745 747 UI->rmapReceiveStateLabel->setText(socketMessage);
746 748 APPENDTOLOG(socketMessage);
747 749 }
748 750
749 751 void rmapplugin::GRESBConnectionState(QAbstractSocket::SocketState socketState) // SLOT
750 752 {
751 753 UI->gresbStatusQueryLabel->setText("");
752 754 QString socketMessage = "GRESB status query socket (port 3010): ";
753 755 switch(socketState)
754 756 {
755 757 case QAbstractSocket::UnconnectedState :
756 758 socketMessage.append("0 => Unconnected");
757 759 break;
758 760 case 1:
759 761 socketMessage.append("1 => HostLookup");
760 762 break;
761 763 case 2:
762 764 socketMessage.append("2 => Connecting");
763 765 break;
764 766 case 3:
765 767 socketMessage.append("3 => Connected");
766 768 break;
767 769 case 4:
768 770 socketMessage.append("4 => Bound");
769 771 break;
770 772 case 5:
771 773 socketMessage.append("5 => Closing");
772 774 break;
773 775 case 6:
774 776 socketMessage.append("6 => Listening");
775 777 break;
776 778 }
777 779 UI->gresbStatusQueryLabel->setText(socketMessage);
778 780 }
779 781
780 782 void rmapplugin::reTestSPWLink() // SLOT
781 783 {
782 784 if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 0)
783 785 {
784 786 UI->gresbStatusQueryDialog->accept();
785 787 }
786 788 }
787 789
788 790 int rmapplugin::GRESBStatusQuery() // SLOT
789 791 {
790 792 GRESBStatusQueryRequest(LinkStatus, 0);
791 793 GRESBStatusQueryRequest(LinkStatus, 1);
792 794 GRESBStatusQueryRequest(LinkStatus, 2);
793 795 GRESBStatusQueryRequest(LinkStatistics, 0);
794 796 GRESBStatusQueryRequest(LinkStatistics, 1);
795 797 GRESBStatusQueryRequest(LinkStatistics, 2);
796 798 return 0;
797 799 }
798 800
799 void rmapplugin::displayOnConsole(QString message)
800 {
801 this->UI->console->append(message);
802 }
803
804 void rmapplugin::activatePluginViaStarDundee(bool flag)
805 {
806 emit activateSig(flag);
807 }
808
809 801 void rmapplugin::RMAP_write_reply_setText(QString text)
810 802 {
811 803 this->UI->RMAP_write_reply->setText(text);
812 804 }
813 805
814 806 void rmapplugin::appendToLog(QString text)
815 807 {
816 808 APPENDTOLOG(text);
817 809 }
818 810
819 811 /////////////////////
820 812 // INTERNAL FUNCTIONS
821 813
822 814 int rmapplugin::GRESBStatusQueryRequest(GresbStatusQueryOption option, char link)
823 815 {
824 816 gresb_status_query_t statusQueryCommand;
825 817 gresb_link_status_reply_t linkStatusReply;
826 818 gresb_link_statistics_reply_t linkStatisticsReply;
827 819 QTime statusQueryTimeout;
828 820 QString console_message;
829 821
830 822 statusQueryCommand.protocolIdentifier = (char) 0x02;
831 823 statusQueryCommand.reserved1 = (char) 0x00;
832 824 statusQueryCommand.reserved0 = (char) 0x00;
833 825 statusQueryCommand.option = (char) option;
834 826 statusQueryCommand.value3 = (char) 0x00;
835 827 statusQueryCommand.value2 = (char) 0x00;
836 828 statusQueryCommand.value1 = (char) 0x00;
837 829 statusQueryCommand.value0 = (char) link;
838 830
839 831 GRESBStatusQuery_SOCKET->write((char*) ((void*) &statusQueryCommand), sizeof(statusQueryCommand));
840 832 GRESBStatusQuery_SOCKET->flush();
841 833 GRESBStatusQuery_SOCKET->waitForBytesWritten(1000);
842 834
843 835 statusQueryTimeout.start();
844 836 while(GRESBStatusQuery_SOCKET->bytesToWrite() > 0)
845 837 {
846 838 GRESBStatusQuery_SOCKET->waitForBytesWritten(100);
847 839 if(statusQueryTimeout.elapsed()>1000)
848 840 {
849 841 APPENDTOLOG("WARNING === in function GRESBStatusQueryRequest of rmapplugin *** sending StatusQueryCommand timeout");
850 842 return 1;
851 843 }
852 844 }
853 845
854 846 switch (option)
855 847 {
856 848 case LinkStatus:
857 849 {
858 850 statusQueryTimeout.start();
859 851 while(GRESBStatusQuery_SOCKET->bytesAvailable() < (int) sizeof(linkStatusReply))
860 852 {
861 853 GRESBStatusQuery_SOCKET->waitForReadyRead(100);
862 854 if(statusQueryTimeout.elapsed()>1000)
863 855 {
864 856 console_message.sprintf("GRESBStatusQueryRequest / LinkStatus => error timeout bytesAvailable()\n");
865 857 APPENDTOLOG(console_message);
866 858 return 1;
867 859 }
868 860 }
869 861 GRESBStatusQuery_SOCKET->read((char*) ((void*) &linkStatusReply), (int) sizeof(linkStatusReply));
870 862 console_message.sprintf("%x", linkStatusReply.byte0);
871 863 UI->spwLinkStatusEnquiry->statusQueryTable->item(0, link)->setText(console_message);
872 864 console_message.sprintf("%d", linkStatusReply.byte1);
873 865 UI->spwLinkStatusEnquiry->statusQueryTable->item(1, link)->setText(console_message);
874 866 if (linkStatusReply.byte0 == 0) return 1;
875 867 break;
876 868 }
877 869 case LinkStatistics:
878 870 {
879 871 statusQueryTimeout.start();
880 872 while(GRESBStatusQuery_SOCKET->bytesAvailable() < (int) sizeof(linkStatisticsReply))
881 873 {
882 874 GRESBStatusQuery_SOCKET->waitForReadyRead(100);
883 875 if(statusQueryTimeout.elapsed()>1000)
884 876 {
885 877 console_message.sprintf("GRESBStatusQueryRequest / LinkStatistics => error timeout bytesAvailable()\n");
886 878 APPENDTOLOG(console_message);
887 879 return 1;
888 880 }
889 881 }
890 882 GRESBStatusQuery_SOCKET->read((char*) ((void*) &linkStatisticsReply), sizeof(linkStatisticsReply));
891 883 console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.sizeOfDataTransmitted));
892 884 UI->spwLinkStatusEnquiry->statusQueryTable->item(9, link)->setText(console_message);
893 885 console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.numberOfPacketsTransmitted));
894 886 UI->spwLinkStatusEnquiry->statusQueryTable->item(8, link)->setText(console_message);
895 887 console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.numberOfTruncatedPacketsReceived));
896 888 UI->spwLinkStatusEnquiry->statusQueryTable->item(6, link)->setText(console_message);
897 889 console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.numberOfPacketsWithEEPReceived));
898 890 UI->spwLinkStatusEnquiry->statusQueryTable->item(5, link)->setText(console_message);
899 891 console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.sizeOfDataReceived));
900 892 UI->spwLinkStatusEnquiry->statusQueryTable->item(4, link)->setText(console_message);
901 893 console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.numberOfPacketsReceived));
902 894 UI->spwLinkStatusEnquiry->statusQueryTable->item(3, link)->setText(console_message);
903 895 break;
904 896 }
905 897 case NodeAddressStatistics:
906 898 {
907 899 break;
908 900 }
909 901 case GetRoute:
910 902 {
911 903 break;
912 904 }
913 905 }
914 906 return 0;
915 907 }
916 908
917 909 int rmapplugin::charTab_TO_int(char *charTab)
918 910 {
919 911 int result = 0;
920 912 result = (charTab[0]<<24) +(charTab[1]<<16) +(charTab[2]<<8) + charTab[3];
921 913 return result;
922 914 }
923 915
924 916 void rmapplugin::gresbSelection(bool flag)
925 917 {
926 918 if (flag == true) UI->selection_GROUPBOX->setEnabled(false);
927 919 if (flag == false) UI->selection_GROUPBOX->setEnabled(true);
928 920 }
929 921
930 // SLOTS
931 void rmapplugin::bridgeHasChanged(selectedBridge bridge)
932 {
933 currentBridge = bridge;
934 }
935 922
936 923
@@ -1,109 +1,108
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the LPPMON Software
3 3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef DRIVER1_H
23 23 #define DRIVER1_H
24 24 #include <rmappluginui.h>
25 25 #include <rmapoperations.h>
26 26 #include <QMenuBar>
27 27 #include <QMenu>
28 28 #include <QAction>
29 29 #include <QMainWindow>
30 30 #include <QTcpSocket>
31 31 #include <QTime>
32 32 #include <ccsds.h>
33 33 #include <QSemaphore>
34 34 #include <spwpacketreceiver.h>
35 35
36 36 #include <lppmonplugin.h>
37 37
38 38 #define APPENDTOLOG(message) this->UI->appendToLogFile(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": " + message)
39 39
40 40 #define READ_WRITE_MAX_COUNTS 4096 // in words
41 41 #define RMAP_MAX_DATA_LENGTH 4*READ_WRITE_MAX_COUNTS // in bytes, shall be lower than the limit size of SPW packet of the GRESB bridge
42 42 #define RMAP_READ_REPLY_HEADER_LENGTH 12 // in bytes => ECSS
43 43 #define RMAP_READ_COMMAND_HEADER_LENGTH 16 // in bytes => ECSS
44 44 #define RMAP_DATA_CRC_LENGTH 1 // in bytes => ECSS
45 45 #define CCSDS_MAX_PACKET_LENGTH 4412 // in bytes, specified in the LFR Software Requirements Specification
46 46
47 47 class rmapplugin : public lppmonplugin
48 48 {
49 49 Q_OBJECT
50 50 public:
51 51 explicit rmapplugin(QWidget *parent = 0);
52 52 ~rmapplugin();
53 53 int GRESBStatusQueryRequest(GresbStatusQueryOption option, char link);
54 54 int charTab_TO_int(char *charTab);
55 55 unsigned int ReadGRESB(unsigned int *Value,unsigned int count,unsigned int address=0);
56 56 unsigned int WriteGRESB(unsigned int *Value,unsigned int count,unsigned int address=0);
57 unsigned int ReadStarDundee(unsigned int *Value, unsigned int count, unsigned int address=0);
58 unsigned int WriteStarDundee(unsigned int *Value, unsigned int count, unsigned int address=0);
57 unsigned int WriteSPWGRESB(char *Value, unsigned int count, char targetLogicalAddress, char userApplication);
59 58
60 59 public slots:
61 60 unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0);
62 61 unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0);
63 62 //
64 63 unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication);
65 64 void sendCCSDS();
66 65 void send_TC_LFR_UPDATE_TIME();
67 66 void reset_TC_LFR_UPDATE_TIME();
68 67 int GRESBStatusQuery();
69 void displayOnConsole(QString message);
68 void displayOnConsole(QString message) {this->UI->console->append(message);}
70 69 //
71 70 void RMAP_CONNECT();
72 71 void RMAP_DISCONNECT();
73 72 void openBridge();
74 73 void closeBridge();
75 74 int RMAPSendReadCommand();
76 75 int RMAPSendWriteCommand();
77 76 void reTestSPWLink();
78 77 //
79 78 void RMAPSendConnectionState(QAbstractSocket::SocketState socketState);
80 79 void RMAPReceiveConnectionState(QAbstractSocket::SocketState socketState);
81 80 void GRESBConnectionState(QAbstractSocket::SocketState socketState);
82 81 //
83 82 void gresbSelection(bool flag);
84 void activatePluginViaStarDundee(bool flag);
83 void activatePluginViaStarDundee(bool flag) {emit activateSig(flag);}
85 84 void RMAP_write_reply_setText(QString text);
86 85 void appendToLog(QString text);
87 void bridgeHasChanged(selectedBridge bridge);
86 void bridgeHasChanged(selectedBridge bridge) {currentBridge = bridge;}
88 87
89 88 signals:
90 89 void ccsdsPacketReadyRead(char *ccsdsPacket, unsigned int size);
91 90 void gresbIsOpen(bool);
92 91
93 92 private:
94 93 selectedBridge currentBridge;
95 94 rmapPluginUI* UI;
96 95 QTcpSocket* GRESBStatusQuery_SOCKET;
97 96 QTcpSocket* RMAPSend_SOCKET;
98 97 QTcpSocket* RMAPReceive_SOCKET;
99 98 ccsds* ccsds_command;
100 99 unsigned int rmapPacketSize;
101 100 unsigned int time_COARSE;
102 101 unsigned int time_FINE;
103 102 spwpacketreceiver* spwPacketReceiverOBJECT;
104 103 unsigned int WriteBLOCK(char *data,unsigned int nbBytes,unsigned int address=0);
105 104 unsigned int ReadBLOCK(unsigned int nbBytes,unsigned int address=0);
106 105 char timeCode;
107 106 };
108 107
109 108 #endif // DRIVER1_H
@@ -1,73 +1,75
1 1 #
2 2 # Project created by QtCreator 2011-09-20T08:15:30
3 3 #
4 4 #-------------------------------------------------
5 5
6 6 #include(/etc/lppmon/lppmonplugin.prf)
7 7 CONFIG += lppmonplugin
8 8 TARGET = rmapplugin
9 9
10 10 DEFINES += PLUGIN=rmapplugin
11 11 DEFINES += PLUGINHEADER="\"\\\"rmapplugin.h"\\\"\"
12 12 DEFINES += driver_Name="\"\\\"RMAPPlugin"\\\"\"
13 13 DEFINES += driver_Author="\"\\\"Paul Leroy paul.leroy@lpp.polytechnique.fr"\\\"\"
14 14 DEFINES += driver_Version="\"\\\"1.1.2"\\\"\"
15 15 DEFINES += driver_Description="\"\\\"AHB bus controler, works with Gaisler's AHB plugn' play bus."\\\"\"
16 16 DEFINES += driver_can_be_root=1
17 17 DEFINES += driver_can_be_child=0
18 18 DEFINES += driver_VID=0
19 19 DEFINES += driver_PID=0
20 20
21 21
22 22 QT += network
23 23
24 24
25 25 LIBS += ../spw_usb_driver_v2.61/lib/x86_64/libSpaceWireUSBAPI.so \
26 26 ../spw_usb_driver_v2.61/lib/x86_64/libConfigLibraryUSB.so
27 27
28 28
29 29 INCLUDEPATH += \
30 30 $${PWD} \
31 31 ../common_PLE \
32 32 ../spw_usb_driver_v2.61/inc
33 33
34 34
35 35 HEADERS += \
36 36 rmappluginui.h \
37 37 rmapplugin.h \
38 38 rmapoperations.h \
39 39 ccsds.h \
40 40 spwpacketreceiver.h \
41 41 ../common_PLE/qipdialogbox.h \
42 42 ../common_PLE/gresbstatusenquiry.h \
43 43 spectralmatricesdmasimulator.h \
44 44 rmappluginpythonwrapper.h \
45 45 stardundee.h \
46 46 ../spw_usb_driver_v2.61/inc/spw_usb_api.h \
47 47 ../spw_usb_driver_v2.61/inc/spw_config_library.h \
48 gresb.h
48 gresb.h \
49 bridge.h
49 50
50 51
51 52 SOURCES += \
52 53 rmapplugin.cpp \
53 54 rmappluginui.cpp \
54 55 rmapoperations.cpp \
55 56 ccsds.cpp \
56 57 spwpacketreceiver.cpp \
57 58 ../common_PLE/qipdialogbox.cpp \
58 59 ../common_PLE/gresbstatusenquiry.cpp \
59 60 spectralmatricesdmasimulator.cpp \
60 61 rmappluginpythonwrapper.cpp \
61 62 stardundee.cpp \
62 gresb.cpp
63 gresb.cpp \
64 bridge.cpp
63 65
64 66
65 67
66 68
67 69
68 70
69 71
70 72
71 73
72 74
73 75
@@ -1,323 +1,324
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the LPPMON Software
3 3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "rmapplugin.h"
23 23
24 24 rmapPluginUI::rmapPluginUI(QWidget *parent) :
25 25 QWidget(parent)
26 26 {
27 27 spectralMatricesDMASimulator = new SpectralMatricesDMASimulator;
28 28 spwTabWidget = new QTabWidget;
29 29 QWidget* spwTabWidgetPage0 = new QWidget;
30 30 QWidget* spwTabWidgetPage1 = new QWidget;
31 31 QWidget* spwTabWidgetPage2 = new QWidget;
32 32 QWidget* spwTabWidgetPage3 = new QWidget;
33 33 QWidget* spwTabWidgetPage4 = new QWidget;
34 34 QWidget* spwTabWidgetPage5 = new QWidget;
35 35 bridgeWidget = new QWidget;
36 36 mainLayout = new QVBoxLayout;
37 37 connectionLayout = new QGridLayout;
38 38 ccsdsLayout = new QVBoxLayout;
39 39 consoleLayout = new QVBoxLayout;
40 40 selectionLayout = new QVBoxLayout;
41 41 bridgeSelection_LAYOUT = new QGridLayout;
42 42 generalParameters_LAYOUT = new QGridLayout;
43 43
44 44 gresb_GROUPBOX = new QGroupBox(tr("GRESB bridge parameters"));
45 45 stardundee_GROUPBOX = new QGroupBox(tr("Star Dundee brick parameters"));
46 46 selection_GROUPBOX = new QGroupBox(tr("Bridge selection"));
47 47 generalParameters_GROUPBOX = new QGroupBox(tr("General parameters"));
48 48
49 49 //*** QLABEL ***//
50 gresbBridgeIPLabel = new QLabel(tr("GRESB Bridge IP: "));
51 gresbVirtualLinkLabel = new QLabel(tr("GRESB Virtual Link: "));
52 spwLinkLabel = new QLabel(tr("GRESB SPW Link: "));
50 gresbBridgeIPLabel = new QLabel(tr("Bridge IP: "));
51 gresbVirtualLinkLabel = new QLabel(tr("Virtual Link: "));
52 spwLinkLabel = new QLabel(tr("SPW Link: "));
53 53 rmapSourceLogicalAddressLabel = new QLabel(tr("RMAP Source Logical Address: "));
54 54 rmapTargetLogicalAddressLabel = new QLabel(tr("RMAP Target Logical Address: "));
55 55 rmapSendStateLabel = new QLabel(tr("RMAP Send Socket State: waiting for connection"));
56 56 rmapReceiveStateLabel = new QLabel(tr("RMAP Receive Socket State: waiting for connection"));
57 57 logFileName = new QLabel;
58 gresbStatusQueryLabel = new QLabel(tr("GRESB status query socket (port 3010): waiting for connection"));
58 gresbStatusQueryLabel = new QLabel(tr("Status query socket (port 3010): waiting for connection"));
59 59 gresbStatusQueryDialogLabel = new QLabel(tr("sockets opened but SpaceWire link not running"));
60 60 sendCCSDSCommandLabel = new QLabel(tr("Address of the target"));
61 61
62 62 //*** QPUSHBUTTON ***//
63 rmapOpenCommunicationButton = new QPushButton(tr("Open RMAP Communication"));
64 rmapCloseCommunicationButton = new QPushButton(tr("Close RMAP Communication"));
63 rmapOpenCommunicationButton = new QPushButton(tr("Open selected bridge"));
64 rmapCloseCommunicationButton = new QPushButton(tr("Close selected bridge"));
65 65 rmapOpenCommunicationButton->setEnabled(false);
66 66 rmapCloseCommunicationButton->setEnabled(false);
67 67 logFileChooseButton = new QPushButton(tr("Choose file"));
68 68 gresbStatusQueryRetryButton = new QPushButton(tr("Retry"));
69 69 gresbStatusQueryAbortButton = new QPushButton(tr("Abort"));
70 70 sendCCSDSCommandButton = new QPushButton(tr("Send CCSDS Command"));
71 71 send_TC_LFR_UPDATE_TIME_Button = new QPushButton(tr("Send TC_LFR_UPDATE_TIME Packet"));
72 72 reset_TC_LFR_UPDATE_TIME_Button = new QPushButton(tr("reset the TC_LFR_UPDATE_TIME Packet coarse and fine times"));
73 73 clearConsoleButton = new QPushButton(tr("Clear"));
74 74
75 75 selectGRESB_BUTTON = new QRadioButton(tr("GRESB"));
76 76 selectStarDundee_BUTTON = new QRadioButton(tr("Star Dundee"));
77 77
78 78 //*** SPINBOX ***//
79 79 gresbVirtualLinkSpinBox = new QSpinBox;
80 80 rmapSourceLogicalAddressSpinBox = new QSpinBox;
81 81 rmapTargetLogicalAddressSpinBox = new QSpinBox;
82 82 spwLinkSpinBox = new QSpinBox;;
83 83 CCSDSTargetLogicalAddressSpinBox = new QSpinBox;
84 84 gresbVirtualLinkSpinBox->setRange(0, 4);
85 85 gresbVirtualLinkSpinBox->setValue(1);
86 86 rmapSourceLogicalAddressSpinBox->setRange(0, 255);
87 87 rmapSourceLogicalAddressSpinBox->setValue(33);
88 88 rmapTargetLogicalAddressSpinBox->setRange(0, 255);
89 rmapTargetLogicalAddressSpinBox->setValue(254);
90 89 spwLinkSpinBox->setRange(0, 2);
91 90 spwLinkSpinBox->setValue(0);
92 91 CCSDSTargetLogicalAddressSpinBox->setRange(0,255);
93 92 CCSDSTargetLogicalAddressSpinBox->setValue(254);
94 93
95 94 //*** MISC **//
96 95 starDundee = new StarDundee;
97 96 gresbBridge = new gresb;
98 97 console = new QTextEdit;
99 98 gresbBridgeIPDialogBox = new QIPDialogBox;
100 99 gresbStatusQueryDialog = new QDialog;
101 100 logEnableCheckBox = new QCheckBox(tr("Enable Logs"));
102 101 RMAP_write_verify = new QCheckBox(tr("data checked before write\nlimited to 4 bytes\nNOT IMPLEMENTED"));
103 102 RMAP_write_reply = new QCheckBox(tr("reply to the write command required\nlast reply status: unavailable"));
104 103 spwLinkStatusEnquiry = new gresbStatusEnquiry;
105 104 logFile = new QFile();
106 105
107 106 logFileEn = false;
108 107
109 108 connectionLayout->addWidget(gresbBridgeIPLabel, 0, 0, 0);
110 109 connectionLayout->addWidget(gresbBridgeIPDialogBox, 0, 1, 0);
111 110 connectionLayout->addWidget(gresbVirtualLinkLabel, 1, 0, 0);
112 111 connectionLayout->addWidget(gresbVirtualLinkSpinBox, 1, 1, 0);
113 112 connectionLayout->addWidget(spwLinkLabel, 2, 0, 0);
114 113 connectionLayout->addWidget(spwLinkSpinBox, 2, 1, 0);
115 114 connectionLayout->addWidget(rmapSourceLogicalAddressLabel, 3, 0, 0);
116 115 connectionLayout->addWidget(rmapSourceLogicalAddressSpinBox, 3, 1, 0);
117 116 connectionLayout->addWidget(rmapSendStateLabel, 4, 0, 1, 2);
118 117 connectionLayout->addWidget(rmapReceiveStateLabel, 5, 0, 1, 2);
119 118 connectionLayout->addWidget(gresbStatusQueryLabel, 6, 0, 1, 2);
120 119
121 120 connectionLayout->setRowStretch(7, 1);
122 121 connectionLayout->setColumnStretch(2, 1);
123 122
124 123 bridgeSelection_LAYOUT->addWidget(selectGRESB_BUTTON, 0, 0, 1, 1);
125 124 bridgeSelection_LAYOUT->addWidget(selectStarDundee_BUTTON, 0, 1, 1, 1);
126 125 bridgeSelection_LAYOUT->setRowStretch(1, 1);
127 126 bridgeSelection_LAYOUT->setColumnStretch(2, 1);
128 127
129 128 generalParameters_LAYOUT->addWidget(logEnableCheckBox, 0, 0, 1, 1);
130 129 generalParameters_LAYOUT->addWidget(logFileChooseButton, 0, 1, 1, 1);
131 130 generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressLabel, 1, 0, 0);
132 131 generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressSpinBox, 1, 1, 0);
133 generalParameters_LAYOUT->addWidget(rmapOpenCommunicationButton, 2, 0, 1, 2);
134 generalParameters_LAYOUT->addWidget(rmapCloseCommunicationButton, 3, 0, 1, 2);
135 generalParameters_LAYOUT->addWidget(RMAP_write_verify, 4, 0, 1, 2);
136 generalParameters_LAYOUT->addWidget(RMAP_write_reply, 5, 0, 1, 2);
137 generalParameters_LAYOUT->setRowStretch(6, 1);
132 generalParameters_LAYOUT->addWidget(rmapOpenCommunicationButton, 2, 0, 1, 1);
133 generalParameters_LAYOUT->addWidget(rmapCloseCommunicationButton, 2, 1, 1, 1);
134 generalParameters_LAYOUT->addWidget(RMAP_write_verify, 3, 0, 1, 2);
135 generalParameters_LAYOUT->addWidget(RMAP_write_reply, 4, 0, 1, 2);
136 generalParameters_LAYOUT->setRowStretch(5, 1);
138 137 generalParameters_LAYOUT->setColumnStretch(2, 1);
139 138
140 139 gresb_GROUPBOX->setLayout(connectionLayout);
141 140 gresb_GROUPBOX->setVisible(false);
142 141 stardundee_GROUPBOX->setLayout(starDundee->layout());
143 142 stardundee_GROUPBOX->setVisible(false);
144 143 selection_GROUPBOX->setLayout(bridgeSelection_LAYOUT);
145 144 generalParameters_GROUPBOX->setLayout(generalParameters_LAYOUT);
146 145 selectionLayout->addWidget(selection_GROUPBOX);
147 146 selectionLayout->addWidget(generalParameters_GROUPBOX);
148 147 selectionLayout->addWidget(gresb_GROUPBOX);
149 148 selectionLayout->addWidget(stardundee_GROUPBOX);
150 149
151 150 ccsdsLayout->addWidget(sendCCSDSCommandButton);
152 151 ccsdsLayout->addWidget(send_TC_LFR_UPDATE_TIME_Button);
153 152 ccsdsLayout->addWidget(reset_TC_LFR_UPDATE_TIME_Button);
154 153 ccsdsLayout->addWidget(sendCCSDSCommandLabel);
155 154 ccsdsLayout->addWidget(CCSDSTargetLogicalAddressSpinBox);
156 155
157 156 consoleLayout->addWidget(console);
158 157 consoleLayout->addWidget(clearConsoleButton);
159 158
160 159 connect(this->logFileChooseButton, SIGNAL(clicked()), this, SLOT(chooseLogFile()));
161 160 connect(this, SIGNAL(setLogFileName(QString)), this->logFileName, SLOT(setText(QString)));
162 161 connect(this->logEnableCheckBox, SIGNAL(stateChanged(int)), this, SLOT(logFileEnDisable(int)));
163 162
164 163 spwTabWidget->addTab(spwTabWidgetPage0, tr("connection"));
165 164 spwTabWidget->addTab(spwTabWidgetPage1, tr("ccsds"));
166 165 spwTabWidget->addTab(spwTabWidgetPage2, tr("status"));
167 166 spwTabWidget->addTab(spwTabWidgetPage3, tr("console"));
168 167 spwTabWidget->addTab(spwTabWidgetPage4, tr("DMA"));
169 168 spwTabWidget->addTab(spwTabWidgetPage5, tr("gresb"));
170 169
171 170 spwTabWidgetPage0->setLayout(selectionLayout);
172 171 spwTabWidgetPage1->setLayout(ccsdsLayout);
173 172 spwTabWidgetPage2->setLayout(this->spwLinkStatusEnquiry->mainLayout);
174 173 spwTabWidgetPage3->setLayout(consoleLayout);
175 174 spwTabWidgetPage4->setLayout(spectralMatricesDMASimulator->mainLayout);
176 175 spwTabWidgetPage5->setLayout(gresbBridge->layout());
177 176 mainLayout->addWidget(spwTabWidget);
178 177 setLayout(mainLayout);
179 178
180 179 // GRESB STATUS QUERY DIALOG
181 180 gresbStatusQueryDialogLayout = new QGridLayout;
182 181 gresbStatusQueryDialogLayout->addWidget(gresbStatusQueryDialogLabel, 0, 0, 1, 2);
183 182 gresbStatusQueryDialogLayout->addWidget(gresbStatusQueryRetryButton, 1, 0, 0);
184 183 gresbStatusQueryDialogLayout->addWidget(gresbStatusQueryAbortButton, 1, 1, 0);
185 184 gresbStatusQueryDialog->setLayout(gresbStatusQueryDialogLayout);
186 185
187 186 connect(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject()));
188 187 connect(this->clearConsoleButton, SIGNAL(clicked()), this->console, SLOT(clear()));
189 188 connect(this->selectGRESB_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee()));
190 189 connect(this->selectStarDundee_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee()));
191 connect(this->starDundee, SIGNAL(starDundeeIsOpen(bool)), this, SLOT(starDundeeIsOpen(bool)));
190 connect(this->starDundee, SIGNAL(isOpen(bool)), this, SLOT(isOpen(bool)));
191 connect(this->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->starDundee, SLOT(targetHasChanged(int)));
192 192
193 193 // command code
194 194 connect(this->RMAP_write_reply, SIGNAL(clicked()), this, SLOT(getCommandCode()));
195 195 connect(this->RMAP_write_verify, SIGNAL(clicked()), this, SLOT(getCommandCode()));
196 connect(this, SIGNAL(commandCodeHasChanged(RMAP_command_codes)), this->starDundee, SLOT(updateCommandCode(RMAP_command_codes)));
196 connect(this, SIGNAL(commandCodeHasChanged(RMAP_command_codes)), this->starDundee, SLOT(commandCodeHasChanged(RMAP_command_codes)));
197 197
198 198 getCommandCode(); // init the command code value
199 rmapTargetLogicalAddressSpinBox->setValue(254);
199 200 }
200 201
201 202 void rmapPluginUI::connectPort()
202 203 {
203 204 //emit this->connectPortsig(ui->PortName->text(),ui->PortspeedSlider->value());
204 205 }
205 206
206 207 void rmapPluginUI::setConnected(bool connected)
207 208 {
208 209 /*if(connected == true)
209 210 {
210 211 ui->OpenPort->setText(tr("Close port"));
211 212 }
212 213 else
213 214 ui->OpenPort->setText(tr("Open port"));*/
214 215 }
215 216
216 217 rmapPluginUI::~rmapPluginUI()
217 218 {
218 219 //delete ui;
219 220 }
220 221
221 222 void rmapPluginUI::chooseLogFile()
222 223 {
223 224 if(this->logFile->isOpen())
224 225 this->logFile->close();
225 226 this->logFile->setFileName(QFileDialog::getSaveFileName(this,tr("Open Log file"),
226 227 QDir::homePath()
227 228 + "/"
228 229 + QDate::currentDate().toString()
229 230 + "_"
230 231 + QTime::currentTime().toString()
231 232 + "_rmapPluginUI.log",
232 233 tr("Log Files (*.txt *.log)")));
233 234 if(this->logFile->open(QIODevice::WriteOnly))
234 235 {
235 236 this->logFileStrm = new QTextStream(this->logFile);
236 237 emit this->setLogFileName(this->logFile->fileName());
237 238 }
238 239 }
239 240
240 241 void rmapPluginUI::logFileEnDisable(int state)
241 242 {
242 243 if(state==Qt::Checked)
243 244 {
244 245 this->logFileEn = true;
245 246 }
246 247 else if(state==Qt::Unchecked)
247 248 {
248 249 this->logFileEn = false;
249 250 }
250 251 }
251 252
252 253 bool rmapPluginUI::islogfileenable()
253 254 {
254 255 return this->logFileEn;
255 256 }
256 257
257 258 void rmapPluginUI::appendToLogFile(const QString & text)
258 259 {
259 260 if(this->logFileEn && this->logFile->isOpen())
260 261 {
261 262 *(this->logFileStrm) << text << endl;
262 263 }
263 264 }
264 265
265 266 void rmapPluginUI::closeEvent(QCloseEvent *event)
266 267 {
267 268 if(this->logFile->isOpen())
268 269 {
269 270 this->logFileStrm->flush();
270 271 this->logFile->waitForBytesWritten(3000);
271 272 this->logFile->close();
272 273 }
273 274 event->accept();
274 275 }
275 276
276 277 RMAP_command_codes rmapPluginUI::getCommandCode()
277 278 {
278 279 RMAP_command_codes commandCode = invalid0;
279 280 if (RMAP_write_verify->isChecked() and RMAP_write_reply->isChecked()) commandCode = writeSingle_ver_rep;
280 281 if (RMAP_write_verify->isChecked() and !RMAP_write_reply->isChecked()) commandCode = writeSingle_ver_noRep;
281 282 if (!RMAP_write_verify->isChecked() and RMAP_write_reply->isChecked()) commandCode = writeSingle_noVer_Rep;
282 283 if (!RMAP_write_verify->isChecked() and !RMAP_write_reply->isChecked()) commandCode = writeSingle_noVer_noRep;
283 284 emit commandCodeHasChanged(commandCode);
284 285 return commandCode;
285 286 }
286 287
287 288 // SLOT
288 289
289 290 void rmapPluginUI::selectionBetweenGresbAndStarDundee() //SLOT
290 291 {
291 292 if (selectGRESB_BUTTON->isChecked())
292 293 {
293 294 gresb_GROUPBOX->setVisible(true);
294 295 stardundee_GROUPBOX->setVisible(false);
295 296 rmapOpenCommunicationButton->setEnabled(true);
296 297 emit bridgeHasChanged(selectedBridgeIsGRESB);
297 298 }
298 299 if (selectStarDundee_BUTTON->isChecked())
299 300 {
300 301 stardundee_GROUPBOX->setVisible(true);
301 302 gresb_GROUPBOX->setVisible(false);
302 303 rmapOpenCommunicationButton->setEnabled(true);
303 304 emit bridgeHasChanged(selectedBridgeIsStarDundee);
304 305 }
305 306 }
306 307
307 void rmapPluginUI::starDundeeIsOpen(bool flag)
308 void rmapPluginUI::isOpen(bool flag)
308 309 {
309 310 if (flag == true)
310 311 {
311 312 selection_GROUPBOX->setEnabled(false);
312 313 this->rmapOpenCommunicationButton->setEnabled(false);
313 314 this->rmapCloseCommunicationButton->setEnabled(true);
314 315 }
315 316 if (flag == false)
316 317 {
317 318 selection_GROUPBOX->setEnabled(true);
318 319 this->rmapOpenCommunicationButton->setEnabled(true);
319 320 this->rmapCloseCommunicationButton->setEnabled(false);
320 321 }
321 322 }
322 323
323 324
@@ -1,160 +1,161
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the LPPMON Software
3 3 -- Copyright (C) 20011, Laboratory of Plasma Physics - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Paul Leroy
20 20 -- Mail : paul.leroy@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef RMAPPLUGINUI_H
23 23 #define RMAPPLUGINUI_H
24 24
25 25 #include <QWidget>
26 26 #include <QPushButton>
27 27 #include <QLabel>
28 28 #include <QSlider>
29 29 #include <QSpinBox>
30 30 #include <QGridLayout>
31 31 #include <QCheckBox>
32 32 #include <QFile>
33 33 #include <QTextStream>
34 34 #include <QFileDialog>
35 35 #include <QDir>
36 36 #include <QDialog>
37 37 #include <QCloseEvent>
38 38 #include <QTabWidget>
39 39 #include "qipdialogbox.h"
40 40 #include <rmapoperations.h>
41 41 #include <gresbstatusenquiry.h>
42 42 #include <QTextEdit>
43 43 #include "spectralmatricesdmasimulator.h"
44 44 #include <stardundee.h>
45 45 #include <gresb.h>
46 46 #include <QRadioButton>
47 47 #include <QGroupBox>
48 48
49 49 enum selectedBridge{
50 50 selectedBridgeIsUnknown,
51 51 selectedBridgeIsGRESB,
52 52 selectedBridgeIsStarDundee
53 53 };
54 54
55 55 class rmapPluginUI : public QWidget
56 56 {
57 57 Q_OBJECT
58 58
59 59 public:
60 60 explicit rmapPluginUI(QWidget *parent = 0);
61 61 ~rmapPluginUI();
62 62
63 63 QPushButton* rmapOpenCommunicationButton;
64 64 QPushButton* rmapCloseCommunicationButton;
65 65 QPushButton* logFileChooseButton;
66 66 QPushButton* gresbStatusQueryRetryButton;
67 67 QPushButton* gresbStatusQueryAbortButton;
68 68 QPushButton* sendCCSDSCommandButton;
69 69 QPushButton* send_TC_LFR_UPDATE_TIME_Button;
70 70 QPushButton* reset_TC_LFR_UPDATE_TIME_Button;
71 71 QPushButton* clearConsoleButton;
72 72
73 73 QRadioButton* selectGRESB_BUTTON;
74 74 QRadioButton* selectStarDundee_BUTTON;
75 75
76 76 QGroupBox *selection_GROUPBOX;
77 77
78 78 QSpinBox* gresbVirtualLinkSpinBox;
79 79 QSpinBox* spwLinkSpinBox;
80 80 QSpinBox* rmapSourceLogicalAddressSpinBox;
81 81 QSpinBox* rmapTargetLogicalAddressSpinBox;
82 82 QSpinBox* CCSDSTargetLogicalAddressSpinBox;
83 83
84 84 QIPDialogBox* gresbBridgeIPDialogBox;
85 85
86 86 QCheckBox *logEnableCheckBox;
87 87 QCheckBox *RMAP_write_verify;
88 88 QCheckBox *RMAP_write_reply;
89 89
90 90 QLabel* rmapSendStateLabel;
91 91 QLabel* rmapReceiveStateLabel;
92 92 QLabel* gresbStatusQueryLabel;
93 93 QLabel* gresbStatusQueryDialogLabel;
94 94 QLabel* sendCCSDSCommandLabel;
95 95
96 96 QDialog* gresbStatusQueryDialog;
97 97
98 98 gresbStatusEnquiry* spwLinkStatusEnquiry;
99 99
100 100 SpectralMatricesDMASimulator *spectralMatricesDMASimulator;
101 101
102 102 QTextEdit* console;
103 103
104 104 StarDundee *starDundee;
105 105
106 106 gresb *gresbBridge;
107 107
108 108 bool islogfileenable();
109 109 void appendToLogFile(const QString & text);
110 110 void closeEvent(QCloseEvent *event);
111 111
112 112 public slots:
113 113 void setConnected(bool connected);
114 114 void connectPort();
115 115 void chooseLogFile();
116 116 void logFileEnDisable(int state);
117 117 RMAP_command_codes getCommandCode();
118 118
119 119 private slots:
120 120 void selectionBetweenGresbAndStarDundee();
121 void starDundeeIsOpen(bool flag);
121 void isOpen(bool flag);
122 122
123 123 signals:
124 124 void connectPortsig(QString PortName,int baudrate);
125 125 void setLogFileName(QString FileName);
126 126 void commandCodeHasChanged(RMAP_command_codes commandCode);
127 127 void bridgeHasChanged(selectedBridge bridge);
128 void targetHasChanged(unsigned char target);
128 129
129 130 private:
130 131 QLabel *gresbBridgeIPLabel;
131 132 QLabel *gresbVirtualLinkLabel;
132 133 QLabel *spwLinkLabel;
133 134 QLabel *rmapSourceLogicalAddressLabel;
134 135 QLabel *rmapTargetLogicalAddressLabel;
135 136 QLabel *logFileName;
136 137
137 138 QGridLayout *bridgeSelection_LAYOUT;
138 139 QVBoxLayout *selectionLayout;
139 140 QVBoxLayout *mainLayout;
140 141 QGridLayout *connectionLayout;
141 142 QVBoxLayout *ccsdsLayout;
142 143 QVBoxLayout *consoleLayout;
143 144 QGridLayout *gresbStatusQueryDialogLayout;
144 145 QGridLayout *generalParameters_LAYOUT;
145 146
146 147 QTabWidget *spwTabWidget;
147 148
148 149 QWidget* bridgeWidget;
149 150
150 151 QGroupBox *gresb_GROUPBOX;
151 152 QGroupBox *stardundee_GROUPBOX;
152 153 QGroupBox *generalParameters_GROUPBOX;
153 154
154 155 QFile *logFile;
155 156 QTextStream *logFileStrm;
156 157 bool logFileEn;
157 158
158 159 };
159 160
160 161 #endif // RMAPPLUGINUI_H
This diff has been collapsed as it changes many lines, (628 lines changed) Show them Hide them
@@ -1,529 +1,713
1 1 #include "stardundee.h"
2 2 #include <QTime>
3 3 #include <math.h>
4 4
5 5 StarDundee::StarDundee(QWidget *parent) :
6 6 QWidget(parent)
7 7 {
8 // Packet receiver
9 rmapPacketSEMAPHORE = new QSemaphore;
10 ccsdsPacketSEMAPHORE = new QSemaphore;
11 rmapPacket = (char*) malloc(RMAP_MAX_PACKET_LENGTH);
12 ccsdsPacket = (unsigned char*) malloc(CCSDS_MAX_PACKET_LENGTH);
13 spwPacket = (char*) malloc( qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH) );
14
8 15 commandCode = invalid0; // initialization of the cmmand code for the RMAP transfers
9 rmapPacket = (unsigned char*) malloc(RMAP_MAX_PACKET_LENGTH);
10 16
11 rmapTargetLogicalAddress = 0xfe;
12 17 rmapSourceLogicalAddress = 0x20;
13 18 connection_LAYOUT = new QGridLayout;
14 19
15 sendPacket_BUTTON = new QPushButton(tr("Send a packet"));
16 sendRMAPPacket_BUTTON = new QPushButton(tr("Write RMAP packet to the specified target"));
17 readRMAPPacket_BUTTON = new QPushButton(tr("Read RMAP packet from the specified target"));
18 getRoutingTableEntry_BUTTON = new QPushButton(tr("Get routing table entry (target logical address)"));
19
20 20 usbDeviceNumber_LABEL = new QLabel(tr("USB device number: "));
21 21 linkNumber_LABEL = new QLabel(tr("SpaceWire link number: "));
22 routingTableEntry_LABEL = new QLabel(tr("Target logical address: "));
23 22 sourceLogicalAddress_LABEL = new QLabel(tr("Source logical address: "));
24 23
25 24 usbDeviceNumber_SPINBOX = new QSpinBox;
26 25 usbDeviceNumber_SPINBOX->setRange(0,32);
27 26 usbDeviceNumber_SPINBOX->setValue(0);
28 27 linkNumber_SPINBOX = new QSpinBox;
29 28 linkNumber_SPINBOX->setRange(1,2);
30 29 linkNumber_SPINBOX->setValue(1);
31 routingTableEntry_SPINBOX = new QSpinBox;
32 routingTableEntry_SPINBOX->setRange(0, 254);
33 routingTableEntry_SPINBOX->setValue(254);
34 30 sourceLogicalAddress_SPINBOX = new QSpinBox;
35 31 sourceLogicalAddress_SPINBOX->setRange(0,254);
36 32 sourceLogicalAddress_SPINBOX->setValue(32);
37 33
38 sendPacket_BUTTON->setEnabled(false);
39 sendRMAPPacket_BUTTON->setEnabled(false);
40 readRMAPPacket_BUTTON->setEnabled(false);
41 getRoutingTableEntry_BUTTON->setEnabled(false);
42
43 34 connection_LAYOUT->addWidget(usbDeviceNumber_LABEL, 0, 0, 1, 1);
44 35 connection_LAYOUT->addWidget(usbDeviceNumber_SPINBOX, 0, 1, 1, 1);
45 connection_LAYOUT->addWidget(sendPacket_BUTTON, 1, 0, 1, 2);
46 connection_LAYOUT->addWidget(linkNumber_LABEL, 2, 0, 1, 1);
47 connection_LAYOUT->addWidget(linkNumber_SPINBOX, 2, 1, 1, 1);
48 connection_LAYOUT->addWidget(sourceLogicalAddress_LABEL, 3, 0, 1, 1);
49 connection_LAYOUT->addWidget(sourceLogicalAddress_SPINBOX, 3, 1, 1, 1);
50 connection_LAYOUT->addWidget(routingTableEntry_LABEL, 4, 0, 1, 1);
51 connection_LAYOUT->addWidget(routingTableEntry_SPINBOX, 4, 1, 1, 1);
52 connection_LAYOUT->addWidget(sendRMAPPacket_BUTTON, 5, 0, 1, 2);
53 connection_LAYOUT->addWidget(readRMAPPacket_BUTTON, 6, 0, 1, 2);
54 connection_LAYOUT->addWidget(getRoutingTableEntry_BUTTON, 7, 0, 1, 2);
36 connection_LAYOUT->addWidget(linkNumber_LABEL, 1, 0, 1, 1);
37 connection_LAYOUT->addWidget(linkNumber_SPINBOX, 1, 1, 1, 1);
38 connection_LAYOUT->addWidget(sourceLogicalAddress_LABEL, 2, 0, 1, 1);
39 connection_LAYOUT->addWidget(sourceLogicalAddress_SPINBOX, 2, 1, 1, 1);
55 40
56 connection_LAYOUT->setRowStretch(8, 1);
41 connection_LAYOUT->setRowStretch(3, 1);
57 42 connection_LAYOUT->setColumnStretch(2, 1);
58 43
59 44 this->setLayout(connection_LAYOUT);
60 45
61 connect(this->sendPacket_BUTTON, SIGNAL(clicked()), this, SLOT(SendPacket()));
62 connect(this->readRMAPPacket_BUTTON, SIGNAL(clicked()),this, SLOT(ReadRMAP()));
63 connect(this->sendRMAPPacket_BUTTON, SIGNAL(clicked()), this, SLOT(SendRMAP()));
64 connect(this->getRoutingTableEntry_BUTTON, SIGNAL(clicked()), this, SLOT(GetRoutingTableEntry()));
46 connect(this->sourceLogicalAddress_SPINBOX, SIGNAL(valueChanged(int)), this, SLOT(sourceHasChanged(int)));
65 47 }
66 48
67 49 StarDundee::~StarDundee()
68 50 {
51 free(rmapPacket);
52 free(ccsdsPacket);
53 free(spwPacket);
69 54 USBSpaceWire_Close(hDevice); // Close the device
70 55 }
71 56
72 unsigned int StarDundee::OpenStarDundee()
57 unsigned int StarDundee::Open()
73 58 {
74 59 int status;
75 60 U32 statusControl;
76 61 U32 routingTableEntry;
77 62 int tableEntry;
78 63
79 64 if (!USBSpaceWire_Open(&hDevice, usbDeviceNumber_SPINBOX->value())) // Open the USB device
80 65 {
81 66 emit sendMessage("stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))");
82 67 return -1;
83 68 }
84 69 emit sendMessage("stardundee *** Open *** USBSpaceWire_Open successful, device number: "
85 70 + QString::number(usbDeviceNumber_SPINBOX->value()));
86 71
87 72 USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode
88 73 CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP
89 74 CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices
90 75
91 76 // Set the path and return path to the device
92 77 CFGSpaceWire_StackClear();
93 78 CFGSpaceWire_AddrStackPush(0);
94 79 CFGSpaceWire_AddrStackPush(254);
95 80 CFGSpaceWire_RetAddrStackPush(254);
96 81
97 82 // set the base transmit rate to 100 MHz
98 83 status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff);
99 84 if (status != CFG_TRANSFER_SUCCESS)
100 85 {
101 86 emit sendMessage("ERROR CFGSpaceWire_SetBrickBaseTransmitRate");
102 87 }
103 88 else emit sendMessage("OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz");
104 89 // read the link status
105 90 if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber_SPINBOX->value(), &statusControl) != CFG_TRANSFER_SUCCESS)
106 91 {
107 92 emit sendMessage("Could not read link status control for link " + QString::number(linkNumber_SPINBOX->value()));
108 93 }
109 94 else
110 95 {
111 96 emit sendMessage("OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber_SPINBOX->value()));
112 97
113 98 // Set the link status control register properties
114 99 CFGSpaceWire_LSEnableAutoStart(&statusControl, 1);
115 100 CFGSpaceWire_LSEnableStart(&statusControl, 1);
116 101 CFGSpaceWire_LSEnableDisabled(&statusControl, 0);
117 102 CFGSpaceWire_LSEnableTristate(&statusControl, 0);
118 103 CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz
119 104
120 105 // Set the link status control register
121 106 if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber_SPINBOX->value(), statusControl) != CFG_TRANSFER_SUCCESS)
122 107 {
123 108 emit sendMessage("Could not set the link status control for link " + QString::number(linkNumber_SPINBOX->value()));
124 109 }
125 110 else emit sendMessage("Set the link status control for link " + QString::number(linkNumber_SPINBOX->value()));
126 111 }
127 112
128 113 // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET 254 <=> 0xfe
129 tableEntry = routingTableEntry_SPINBOX->value();
114 tableEntry = rmapTargetLogicalAddress;
130 115 if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS)
131 116 {
132 117 emit sendMessage("Could not clear routing table entry " + QString::number(tableEntry));
133 118 }
134 119 else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] cleared");
135 120 // Build the routing table entry to route out of port 1 with header deletion disabled and priority normal
136 121 CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry,
137 122 (1<<linkNumber_SPINBOX->value()), // 0x02 = 0000 0010
138 123 0,
139 124 0);
140 125 // Set the routing table entry for logical address tableEntry
141 126 if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS)
142 127 {
143 128 emit sendMessage("Could not set routing table entry [" + QString::number(tableEntry) + "]");
144 129 }
145 130 else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] set" );
146 131
147 132 // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET 32 <=> 0x20
148 133 tableEntry = sourceLogicalAddress_SPINBOX->value();
149 134 if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS)
150 135 {
151 136 emit sendMessage("Could not clear routing table entry " + QString::number(tableEntry));
152 137 }
153 138 else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] cleared");
154 139
155 140 // Build the routing table entry to route out of port 3 with header deletion disabled and priority normal
156 141 CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry,
157 142 (1<<3), // 0x02 = 0000 0010
158 143 0,
159 144 0);
160 145 // Set the routing table entry for logical address tableEntry
161 146 if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS)
162 147 {
163 148 emit sendMessage("Could not set routing table entry [" + QString::number(tableEntry) + "]");
164 149 }
165 150 else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] set" );
166 151
167 152 emit sendMessage("The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes");
168 153
169 sendPacket_BUTTON->setEnabled(true);
170 sendRMAPPacket_BUTTON->setEnabled(true);
171 readRMAPPacket_BUTTON->setEnabled(true);
172 getRoutingTableEntry_BUTTON->setEnabled(true);
154 USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports
155 USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints
173 156
174 USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports
157 // initialize SPW packet semaphores
158 while (rmapPacketSEMAPHORE->available()!=0) rmapPacketSEMAPHORE->acquire();
159 while (ccsdsPacketSEMAPHORE->available()!=0) ccsdsPacketSEMAPHORE->acquire();
175 160
176 emit starDundeeIsOpen(true);
177
178 emit sendMessage("command code: " + QString::number(commandCode,16) );
161 emit isOpen(true);
179 162
180 163 return 1;
181 164 }
182 165
183 unsigned int StarDundee::CloseStarDundee()
166 unsigned int StarDundee::Close()
184 167 {
185 168 USBSpaceWire_Close(hDevice); // Close the device
186 169 emit sendMessage("stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(usbDeviceNumber_SPINBOX->value()));
187 sendPacket_BUTTON->setEnabled(false);
188 sendRMAPPacket_BUTTON->setEnabled(false);
189 readRMAPPacket_BUTTON->setEnabled(false);
190 getRoutingTableEntry_BUTTON->setEnabled(false);
191 170
192 171 USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports
193 172
194 emit starDundeeIsOpen(false);
173 emit isOpen(false);
195 174
196 175 return 1;
197 176 }
198 177
199 178 unsigned int StarDundee::GetRoutingTableEntry()
200 179 {
201 180 U32 routingTableEntry, outputPorts;
202 181 char enabled, delHead, priority;
203 182 int portNum;
204 183 int tableEntry;
205 184
206 tableEntry = routingTableEntry_SPINBOX->value();
185 tableEntry = rmapTargetLogicalAddress;
207 186
208 187 // Set the path and return path to the device
209 188 CFGSpaceWire_StackClear();
210 189 CFGSpaceWire_AddrStackPush(0);
211 190 CFGSpaceWire_AddrStackPush(254);
212 191 CFGSpaceWire_RetAddrStackPush(254);
213 192
214 193 // Read the routing table entry
215 194 if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS)
216 195 {
217 196 emit sendMessage("Could not read routing table entry [" + QString::number(tableEntry) + "]");
218 197 }
219 198 else
220 199 {
221 200 // Display the routing table entry properties
222 201 CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled);
223 202 CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead);
224 203 CFGSpaceWire_RTIsPriority(routingTableEntry, &priority);
225 204 CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts);
226 205 emit sendMessage("CFGSpaceWire_RTIsEnabled : " + QString::number(enabled));
227 206 emit sendMessage("CFGSpaceWire_RTIsDelHead : " + QString::number(delHead));
228 207 emit sendMessage("CFGSpaceWire_RTIsPriority : " + QString::number(priority));
229 208 emit sendMessage("CFGSpaceWire_RTGetOutputPorts : ");
230 209 for (portNum = 0; portNum < 32; portNum++)
231 210 {
232 211 if (outputPorts & (1 << portNum))
233 212 {
234 213 emit sendMessage(QString::number(portNum));
235 214 }
236 215 }
237 216 }
238 217
239 218 return 1;
240 219 }
241 220
242 unsigned int StarDundee::SendPacket()
221 unsigned int StarDundee::Write(unsigned int *Value, unsigned int count, unsigned int address)
243 222 {
244 U32 nBufferSize; // The amount of data, in bytes, to be transmitted.
245 char bWait; // If bWait is 0 then the transfer is started and the function returns immediately.
246 // If bWait is not 0 then the function will return only when the transfer is completed or an error is detected.
223 unsigned int remainingCount = count;
224 unsigned int iOffset = 0;
225 QString console_message;
226 char* data;
227
228 if(rmapPacketSEMAPHORE->available()!=0)
229 {
230 emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP request already running, WRITE access stopped");
231 return 1;
232 }
233
234 emit this->RMAP_write_reply_setText("reply to the write command required\nlast reply status: unavailable");
235
236 data = (char*) malloc(READ_WRITE_MAX_COUNTS*4);
237
238 emit appendToLog(QString("*** START *** WRITE ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16));
239
240 while (remainingCount > READ_WRITE_MAX_COUNTS)
241 {
242 for (int i = 0; i<READ_WRITE_MAX_COUNTS; i++)
243 {
244 data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]);
245 data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8);
246 data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16);
247 data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24);
248 }
249
250 console_message.sprintf("remainingCount: %d => ", remainingCount);
251 emit appendToLog(console_message + QString("Write ")+ QString::number(READ_WRITE_MAX_COUNTS*4) + QString(" byte(s) @0x")+ QString::number(address,16));
247 252
248 nBufferSize = 10;
249 bWait = 1;
250 // Send the packet and wait on it completing
251 result = USBSpaceWire_SendPacket(hDevice, pBuffer, nBufferSize, bWait, &pIdentifier);
252 if (result != TRANSFER_SUCCESS)
253 if(WriteBLOCK(data, READ_WRITE_MAX_COUNTS*4, address)==0)
254 {
255 emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed");
256 return 1;
257 }
258
259 remainingCount = remainingCount - READ_WRITE_MAX_COUNTS;
260 address = address + READ_WRITE_MAX_COUNTS * 4;
261 iOffset = iOffset + READ_WRITE_MAX_COUNTS;
262 }
263
264 if (remainingCount > 0)
253 265 {
254 emit sendMessage("Error: Could not send the packet");
255 }
256 else emit sendMessage("The packet has been successfully sent");
266 for (unsigned int i = 0; i<remainingCount; i++)
267 {
268 data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]);
269 data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8);
270 data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16);
271 data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24);
272 }
273
274 console_message.sprintf("remainingCount: %d => ", remainingCount);
275 emit appendToLog(console_message + QString("Write ")+ QString::number(remainingCount*4) + QString(" byte(s) @0x")+ QString::number(address,16));
257 276
258 // Free the send
259 USBSpaceWire_FreeSend(hDevice, pIdentifier);
277 if (WriteBLOCK(data, remainingCount*4, address)==0)
278 {
279 emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed");
280 return 1;
281 }
282 }
260 283
261 return 1;
284 emit appendToLog(QString("*** STOP *** WRITE"));
285 free(data);
286 return count;
262 287 }
263 288
264 unsigned int StarDundee::SendRMAP()
289 unsigned int StarDundee::Read(unsigned int *Value, unsigned int count, unsigned int address)
265 290 {
266 unsigned int Value[4];
267 unsigned int count = 4;
268 unsigned int address = 0x40000000;
269 Value[0] = 0xabcd1234;
270 Value[1] = 0xbb;
271 Value[2] = 0xab;
272 Value[3] = 0xcd;
273 WriteStarDundee(Value, count, address);
274 return 1;
291 unsigned int remainingCount = count;
292 unsigned int iOffset = 0;
293 QString console_message;
294
295 if(rmapPacketSEMAPHORE->available()!=0)
296 {
297 emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP request already running, READ access stopped");
298 return 1;
299 }
300 emit appendToLog(QString("*** START *** READ ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16));
301
302 while (remainingCount > READ_WRITE_MAX_COUNTS)
303 {
304 console_message.sprintf("remainingCount: %d => ", remainingCount);
305 emit appendToLog(console_message + QString("Read ")+ QString::number(4*READ_WRITE_MAX_COUNTS) + QString(" byte(s) @0x")+ QString::number(address,16));
306
307 if (this->ReadBLOCK(READ_WRITE_MAX_COUNTS*4, address)==0)
308 {
309 emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received");
310 return 1;
311 }
312
313 for(int i=0;i<READ_WRITE_MAX_COUNTS;i++)
314 {
315 Value[i+iOffset] = (unsigned char) rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH];
316 for(int j=1;j<4;j++)
317 {
318 Value[i+iOffset]= ((unsigned char) (rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH]))
319 + Value[i+iOffset]*256;
320 }
321 }
322
323 remainingCount = remainingCount - READ_WRITE_MAX_COUNTS;
324 address = address + READ_WRITE_MAX_COUNTS * 4;
325 iOffset = iOffset + READ_WRITE_MAX_COUNTS;
326 this->acquireRMAPSemaphore();
327 }
328
329 if (remainingCount > 0)
330 {
331 console_message.sprintf("remainingCount: %d => ", remainingCount);
332 emit appendToLog(console_message + QString("Read ")+ QString::number(4*remainingCount) + QString(" byte(s) @0x")+ QString::number(address,16));
333
334 if (this->ReadBLOCK(4*remainingCount, address)==0)
335 {
336 emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received");
337 return 1;
338 }
339
340 for(unsigned int i=0;i<remainingCount;i++)
341 {
342 Value[i+iOffset] = (unsigned char) rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH];
343 for(int j=1;j<4;j++)
344 {
345 Value[i+iOffset]= ((unsigned char)(rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) + Value[i+iOffset]*256;
346 }
347 }
348 this->acquireRMAPSemaphore();
349 }
350
351 emit appendToLog(QString("*** STOP *** READ "));
352 return count;
275 353 }
276 354
277 unsigned int StarDundee::ReadRMAP()
278 {
279 unsigned int Value[100000];
280 unsigned int count = 100000;
281 unsigned int address = 0x40000000;
282 unsigned int result;
283 result = ReadStarDundee(Value, count, address);
284 emit sendMessage("ReadRMAP, nbBytes: " + QString::number(result));
285 emit sendMessage("Value[0]: " + QString::number(Value[0], 16));
286 emit sendMessage("Value[1]: " + QString::number(Value[1], 16));
287 emit sendMessage("Value[2]: " + QString::number(Value[2], 16));
288 emit sendMessage("Value[3]: " + QString::number(Value[3], 16));
289 return 1;
290 }
291
292 unsigned int StarDundee::ReadStarDundee(unsigned int *Value, unsigned int count, unsigned int address)
355 unsigned int StarDundee::WriteBLOCK(char *data, unsigned int nbBytes, unsigned int address)
293 356 {
294 357 RMAP *RMAPCommand;
295 rmap_read_reply_PcktHdr_t rmapReplyHeader;
296 USB_SPACEWIRE_STATUS result; // The result of the receive operation
297 USB_SPACEWIRE_PACKET_PROPERTIES properties; // The properties of the read
298 unsigned int nbBytes;
299 unsigned char* packet;
300 U32 nPacketNum;
301 unsigned int offset;
302 unsigned int i;
358 char * packet;
359 unsigned char offset, headerSize, CRCSize;
360 char* aux;
361 unsigned int totalSize;
362 int errorCode;
363 QString console_message;
303 364
304 //**********************
305 // SEND THE READ COMMAND
306 nbBytes = 4 * count;
307 if (nbBytes > 4)
365 if (getLinkStatus(this->linkNumber_SPINBOX->value()) == 0)
308 366 {
309 RMAPCommand = new RMAP(read_Inc, // build the command
310 rmapTargetLogicalAddress,
311 rmapSourceLogicalAddress,
312 address,
313 nbBytes,
314 NULL);
315 }
316 else
317 {
318 RMAPCommand = new RMAP(read_Single, // build the command
319 rmapTargetLogicalAddress,
320 rmapSourceLogicalAddress,
321 address,
322 nbBytes,
323 NULL);
367 this->Close();
368 return 1;
324 369 }
325 370
326 result = USBSpaceWire_SendPacket(hDevice,
327 (unsigned char*) ((void*) &RMAPCommand->RMAPHeader),
328 sizeof(RMAPCommand->RMAPHeader),
329 BWAIT_1, &pIdentifier);
330 if (result != TRANSFER_SUCCESS) emit sendMessage("ERROR *** ReadStarDundee when sending the READ command ");
331 else emit sendMessage("OK *** ReadStarDundee when sending the READ command");
332
333 //*****************
334 // RECEIVE THE DATA
335 nbBytes = sizeof(rmapReplyHeader) + 4 * count + 1; // 1 is for the data CRC
336 packet = (unsigned char *) malloc(nbBytes);
337 nPacketNum = 1;
338 result = USBSpaceWire_ReadPackets(hDevice, packet, nbBytes, nPacketNum, BWAIT_1, &properties, &pIdentifier);
339 if (result != TRANSFER_SUCCESS) emit sendMessage("Error: Could not receive the packet");
340 else
341 {
342 emit sendMessage("A packet of length " + QString::number(properties.len) + " has been successfully received");
343 offset = sizeof(rmapReplyHeader);
344 for(i=0; i<count; i++)
345 {
346 Value[i] = packet[offset+3];
347 Value[i] = Value[i] + packet[offset+2] * pow(2, 8);
348 Value[i] = Value[i] + packet[offset+1] * pow(2, 16);
349 Value[i] = Value[i] + packet[offset+0] * pow(2, 24);
350 offset = offset + 4;
351 }
352 free(packet);
353 USBSpaceWire_FreeRead(hDevice, pIdentifier); // Free the receive
354 return count;
355 }
356
357 return 1;
358 }
359
360 unsigned int StarDundee::WriteStarDundee(unsigned int *Value, unsigned int count, unsigned int address)
361 {
362 RMAP *RMAPCommand;
363 unsigned char *data;
364 char *dataCHAR;
365 unsigned char *aux;
366 unsigned int offset;
367 U32 dataSize, headerSize, CRCSize, totalSize; // sizes in bytes
368 U32 nPacketNum;
369 USB_SPACEWIRE_PACKET_PROPERTIES properties; // The properties of the read
370 rmap_write_reply_t rmapReplyHeader;
371
372 dataSize = count * 4;
373 dataCHAR = (char *) malloc(dataSize);
374 for (unsigned int i = 0; i<count; i++)
375 {
376 dataCHAR[i*4+3] = (char) ((unsigned int) Value[i]);
377 dataCHAR[i*4+2] = (char) ((unsigned int) Value[i]>>8);
378 dataCHAR[i*4+1] = (char) ((unsigned int) Value[i]>>16);
379 dataCHAR[i*4+0] = (char) ((unsigned int) Value[i]>>24);
380 }
381
382 RMAPCommand = new RMAP(commandCode,
371 RMAPCommand = new RMAP(this->commandCode,
383 372 rmapTargetLogicalAddress,
384 373 rmapSourceLogicalAddress,
385 374 address,
386 dataSize,
387 dataCHAR);
388 free(dataCHAR);
375 nbBytes,
376 data);
389 377 headerSize = sizeof(RMAPCommand->RMAPHeader);
390 378 CRCSize = 1;
391 379
392 380 //*************************
393 381 // BUILD THE PACKET TO SEND
394 totalSize = headerSize + dataSize + CRCSize;
395 data = (unsigned char*) malloc( totalSize );
396 aux = (unsigned char*) ((void*) &RMAPCommand->RMAPHeader);
397 for(unsigned int i = 0; i<headerSize; i++) data[i] = aux[i];
382 totalSize = headerSize + nbBytes + CRCSize;
383 packet = (char*) malloc( totalSize );
384 aux = (char*) ((void*) &RMAPCommand->RMAPHeader);
385 for(unsigned int i = 0; i<headerSize; i++) packet[i] = aux[i];
398 386 offset = headerSize;
399 for(unsigned int i = 0; i<count; i++)
387 for(unsigned int i = 0; i<nbBytes; i++)
400 388 {
401 data[offset+3] = (unsigned char) (Value[i]);
402 data[offset+2] = (unsigned char) (Value[i]>>8);
403 data[offset+1] = (unsigned char) (Value[i]>>16);
404 data[offset] = (unsigned char) (Value[i]>>24);
405 offset = offset + 4;
389 packet[i+offset] = data[i];
406 390 }
407 data[offset] = RMAPCommand->dataCRC;
391 packet[nbBytes+offset] = RMAPCommand->dataCRC;
408 392
409 //************
393 //****************
410 394 // SEND THE PACKET
411 395 result = USBSpaceWire_SendPacket(hDevice,
412 data,
396 packet,
413 397 totalSize,
414 398 BWAIT_1, &pIdentifier);
415 399 if (result != TRANSFER_SUCCESS)
416 400 {
417 401 emit sendMessage("ERROR *** WriteStarDundee when sending packet of size "
418 402 + QString::number(totalSize) +", with code: " + QString::number(result));
419 403 USBSpaceWire_FreeSend(hDevice, pIdentifier);
420 404 free(data);
421 405 return 1;
422 406 }
423 407 else emit sendMessage("OK *** WriteStarDundee when sending packet of size " + QString::number(totalSize));
424 408
425 409 //**************
426 410 // Free the send
427 411 USBSpaceWire_FreeSend(hDevice, pIdentifier);
428 free(data);
412 free(packet);
429 413
430 414 if ( (commandCode == writeSingle_noVer_Rep) | (commandCode == writeInc_noVer_Rep) |
431 415 (commandCode == writeSingle_ver_rep) | (commandCode == writeInc_ver_rep) )
432 416 {
433 //***********************
434 // RECEIVE THE RMAP REPLY
435 totalSize = sizeof(rmapReplyHeader);
436 nPacketNum = 1;
437 result = USBSpaceWire_ReadPackets(hDevice, (char *) &rmapReplyHeader, totalSize, nPacketNum, BWAIT_1, &properties, &pIdentifier);
438 if (result != TRANSFER_SUCCESS)
417 // WAIT FOR THE RMAP REPLY PACKET
418 errorCode = this->receiveSPWPacket(1);
419 if (errorCode<=0)
439 420 {
440 emit sendMessage("Error: Could not receive the RMAP reply");
441 USBSpaceWire_FreeRead(hDevice, pIdentifier); // Free the receive
442 return 1;
443 }
444 else
445 {
446 emit sendMessage("An RMAP reply of length " + QString::number(properties.len) + " has been successfully received");
447 USBSpaceWire_FreeRead(hDevice, pIdentifier); // Free the receive
421 emit appendToLog("WARNING === in function WriteBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode));
422 return 0;
448 423 }
449 if(properties.len != 8)
424 if(rmapPacketSize != 8)
450 425 {
451 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** write reply format not compliant\n");
452 return 1;
426 console_message.sprintf("WARNING === in function WRITE (with reply) of rmapplugin *** write reply format not compliant\n");
427 emit appendToLog(console_message);
428 return 0;
453 429 }
454 emit sendMessage("data CRC " + QString::number(RMAPCommand->dataCRC, 16) );
455 emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.initiatorLogicalAddress, 16) );
456 emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.protocolIdentifier, 16) );
457 emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.instruction, 16) );
458 emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.status, 16) );
459 emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.targetLogicalAddress, 16) );
460 emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.transactionIdentifier1, 16) );
461 emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.transactionIdentifier2, 16) );
462 emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.headerCRC, 16) );
463 switch (rmapReplyHeader.status) // byte 4 is the status byte in the reply
430 switch (this->rmapPacket[3]) // byte 4 is the status byte in the reply
464 431 {
465 432 case 0:
466 433 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 0 Successfull");
467 434 break;
468 435 case 1:
469 436 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** General error code");
470 437 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 1 General error code");
471 438 break;
472 439 case 2:
473 440 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Unused RMAP packet type or command code");
474 441 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 2 Unused RMAP packet type or command code");
475 442 break;
476 443 case 3:
477 444 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid key");
478 445 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 3 Invalid key");
479 446 break;
480 447 case 4:
481 448 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid data CRC");
482 449 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 4 Invalid data CRC");
483 450 break;
484 451 case 5:
485 452 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Early EOP");
486 453 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 5 Early EOP");
487 454 break;
488 455 case 6:
489 456 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Too much data");
490 457 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 6 Too much data");
491 458 break;
492 459 case 7:
493 460 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** EEP");
494 461 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 7 EEP");
495 462 break;
496 463 case 8:
497 464 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Reserved");
498 465 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 8 Reserved");
499 466 break;
500 467 case 9:
501 468 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Verify buffer overrun");
502 469 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 9 Verify buffer overrun");
503 470 break;
504 471 case 10:
505 472 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** RMAP command not implemented or not authorised");
506 473 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 10 RMAP command not implemented or not authorised");
507 474 break;
508 475 case 11:
509 476 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** RMW data length error");
510 477 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 11 RMAP RMW data length error");
511 478 break;
512 479 case 12:
513 480 emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid target logical address");
514 481 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 12 Invalid target logical address");
515 482 break;
516 483 }
484 this->acquireRMAPSemaphore();
517 485 }
518 486 else
519 487 emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: unavailable");
520 return count;
488
489 return nbBytes;
490 }
491
492 unsigned int StarDundee::ReadBLOCK(unsigned int nbBytes, unsigned int address)
493 {
494 int errorCode;
495 RMAP *RMAPCommand;
496 unsigned int dataLength;
497
498 //**********************
499 // Check the link status
500 if ( getLinkStatus( this->linkNumber_SPINBOX->value() ) == 0 )
501 {
502 this->Close();
503 emit appendToLog("WARNING === in function WriteSPW of StarDundee *** SPW link not running\n");
504 return 0;
505 }
506
507 //**********************
508 // SEND THE READ COMMAND
509 if (nbBytes > 4)
510 {
511 RMAPCommand = new RMAP(read_Inc,
512 rmapTargetLogicalAddress,
513 rmapSourceLogicalAddress,
514 address,
515 nbBytes,
516 NULL);
517 }
518 else
519 {
520 RMAPCommand = new RMAP(read_Single,
521 rmapTargetLogicalAddress,
522 rmapSourceLogicalAddress,
523 address,
524 nbBytes,
525 NULL);
526 }
527 result = USBSpaceWire_SendPacket(hDevice,
528 (unsigned char*) ((void*) &RMAPCommand->RMAPHeader),
529 sizeof(RMAPCommand->RMAPHeader),
530 BWAIT_1, &pIdentifier);
531 if (result != TRANSFER_SUCCESS) emit sendMessage("ERR *** ReadStarDundee *** ReadBLOCK *** sending the READ command ");
532 else emit sendMessage("OK *** ReadStarDundee *** ReadBLOCK *** sending the READ command");
533
534 //*********************************
535 // RECEIVE THE INCOMING RMAP PACKET
536 errorCode = this->receiveSPWPacket(1); // request ID 1 is for RMAP packet
537 if (errorCode<=0)
538 {
539 emit appendToLog("WARNING === in function ReadBLOCK of StarDundee *** RMAP packet reception failed with code " + QString::number(errorCode));
540 return 0;
541 }
542 dataLength = rmapPacketSize - RMAP_READ_REPLY_HEADER_LENGTH - RMAP_DATA_CRC_LENGTH;
543 if(dataLength != nbBytes)
544 {
545 emit appendToLog("WARNING === in function READ of StarDundee *** number of data received ("
546 +QString::number(dataLength)
547 +") not equal to number of data requested ("
548 +QString::number(nbBytes)
549 +")");
550 return 0;
551 }
552 return dataLength;
521 553 }
522 554
523 //******
524 // SLOTS
555 unsigned int StarDundee::WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication)
556 {
557 char protocoleIdentifier = 0x02;
558 char reserved = 0x00;
559 char *SPWData;
560 unsigned int totalSize;
561
562 if (count>248)
563 {
564 emit appendToLog("WARNING === in function WRITE of rmapplugin *** CCSDS packet size > 248 bytes\n");
565 return 1;
566 }
567
568 emit appendToLog("*** START *** Send CCSDS packet of "+ QString::number(count) + " byte(s)");
569
570 if ( getLinkStatus( this->linkNumber_SPINBOX->value() ) == 0 )
571 {
572 this->Close();
573 emit appendToLog("WARNING === in function WriteSPW of StarDundee *** SPW link not running\n");
574 return 1;
575 }
576
577 totalSize = count + 4;
578 SPWData = (char*) malloc(totalSize);
579 // SPW HEADER
580 SPWData[0] = targetLogicalAddress;
581 SPWData[1] = protocoleIdentifier;
582 SPWData[2] = reserved;
583 SPWData[3] = userApplication;
584 // CCSDS PACKET
585 for (unsigned int i = 0; i<count; i++)
586 {
587 SPWData[i+4] = Value[i];
588 }
589
590 //************
591 // SEND THE PACKET
592 result = USBSpaceWire_SendPacket(hDevice,
593 SPWData,
594 totalSize,
595 BWAIT_1, &pIdentifier);
596 if (result != TRANSFER_SUCCESS)
597 {
598 emit sendMessage("ERROR *** WriteSPW when sending packet of size "
599 + QString::number(totalSize) +", with code: " + QString::number(result));
600 USBSpaceWire_FreeSend(hDevice, pIdentifier);
601 free(SPWData);
602 return 0;
603 }
604 else emit sendMessage("OK *** WriteSPW when sending packet of size " + QString::number(totalSize));
605
606 //**************
607 // Free the send
608 USBSpaceWire_FreeSend(hDevice, pIdentifier);
609 free(SPWData);
610
611 emit appendToLog(QString("*** CCSDS packet sent"));
612
613 return 1;
614 }
615
616 unsigned int StarDundee::getLinkStatus(unsigned char link)
617 {
618 U32 statusControl, errorStatus, portType;
619 U32 linkStatus, operatingSpeed, outputPortConnection;
620 char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate;
525 621
526 void StarDundee::updateCommandCode(RMAP_command_codes code)
622 // Read the link status control register
623 if (CFGSpaceWire_GetLinkStatusControl(hDevice, 1, &statusControl) != CFG_TRANSFER_SUCCESS)
624 {
625 emit appendToLog("Could not read link status control for link" + QString::number(link));
626 }
627 else
628 {
629 // Display the link status control register properties
630 CFGSpaceWire_LSPortType(statusControl, &portType);
631 if (portType == CFG_CONFIGURATION_PORT)
632 {
633 CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus);
634 //emit appendToLog("Configuration port error status = " + QString::number(errorStatus));
635 }
636 else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT)
637 {
638 CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus);
639 //emit appendToLog("External port error status = " + QString::number(errorStatus));
640 }
641 else
642 {
643 CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus);
644 //emit appendToLog("SpaceWire link error status = " + QString::number(errorStatus));
645 }
646 CFGSpaceWire_LSLinkState(statusControl, &linkStatus);
647 CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning);
648 CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart);
649 CFGSpaceWire_LSIsStart(statusControl, &isStart);
650 CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled);
651 CFGSpaceWire_LSIsTristate(statusControl, &isTristate);
652 CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed);
653 CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection);
654 //emit appendToLog("The link state is = " + QString::number(linkStatus));
655 //emit appendToLog("The link is running = " + QString::number(isLinkRunning));
656 //emit appendToLog("The autostart bit is enabled = " + QString::number(isAutoStart));
657 //emit appendToLog("The start bit is enabled = " + QString::number(isStart));
658 //emit appendToLog("The link is disabled = " + QString::number(isDisabled));
659 //emit appendToLog("The tri-state bit is enabled = " + QString::number(isAutoStart));
660 //emit appendToLog("The operating speed is = " + QString::number(operatingSpeed));
661 //emit appendToLog("This port is currently connected to output port = " + QString::number(outputPortConnection));
662 }
663 if (linkStatus == 5) return 1;
664 else return 0;
665 }
666
667 int StarDundee::receiveSPWPacket(unsigned char requestID) // SLOT
527 668 {
528 this->commandCode = code;
669 unsigned int packetLength;
670 unsigned int nbBytes;
671 unsigned nPacketNum;
672 USB_SPACEWIRE_PACKET_PROPERTIES properties; // The properties of the read
673
674 if (requestID==1)
675 {
676 if (rmapPacketSEMAPHORE->available()) return rmapPacketSize;
677 }
678
679 //********************
680 // TRY TO RECEIVE DATA
681 nbBytes = qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH); // maximum size of the packet to receive
682 nPacketNum = 1;
683 result = USBSpaceWire_ReadPackets(hDevice, spwPacket, nbBytes, nPacketNum, BWAIT_1, &properties, &pIdentifier);
684 if (result != TRANSFER_SUCCESS) emit sendMessage("Error: Could not receive the packet");
685 else
686 {
687 emit sendMessage("A packet of length " + QString::number(properties.len) + " has been successfully received");
688 USBSpaceWire_FreeRead(hDevice, pIdentifier); // Free the receive
689 }
690 packetLength = properties.len;
691
692 switch(spwPacket[1]) // byte 1 is the protocole identifier in the SPW packet
693 {
694 case 1: // 0x01 is the protocole identifier for RMAP packets
695 if (rmapPacketSEMAPHORE->available()!=0) return -3; // ERROR === previous RMAP packet not processed yet
696 for(unsigned int i=0; i<packetLength; i++) rmapPacket[i] = spwPacket[i];
697 rmapPacketSize = packetLength;
698 rmapPacketSEMAPHORE->release();
699 emit sendMessage("RMAP packet of size " + QString::number(packetLength) + " received");
700 return packetLength;
701
702 case 2: // 0x02 is the protocole identifier for CCSDS packets
703 if (ccsdsPacketSEMAPHORE->available()!=0) return -4; // ERROR === previous CCSDS packet not processed yet
704 for(unsigned int i=0; i<packetLength; i++) ccsdsPacket[i] = spwPacket[i];
705 ccsdsPacketSize = packetLength;
706 ccsdsPacketSEMAPHORE->release();
707 emit(ccsdsPacketAvailable(ccsdsPacket, packetLength));
708 return packetLength;
709 }
710 return 0;
529 711 }
712
713
@@ -1,72 +1,82
1 1 #ifndef STARDUNDEE_H
2 2 #define STARDUNDEE_H
3 3
4 4 #include <QWidget>
5 5 #include "spw_usb_api.h"
6 6 #include "spw_config_library.h"
7 7 #include <QPushButton>
8 8 #include <QGridLayout>
9 9 #include <QSpinBox>
10 10 #include <QLabel>
11 #include <QSemaphore>
11 12 #include "rmapoperations.h"
12 13
13 14 #define BWAIT_0 0
14 15 #define BWAIT_1 1
15 16
16 17 class StarDundee : public QWidget
17 18 {
18 19 Q_OBJECT
19 20 public:
20 21 explicit StarDundee(QWidget *parent = 0);
21 22 ~StarDundee();
22 unsigned int WriteStarDundee(unsigned int *Value,unsigned int count,unsigned int address=0);
23 unsigned int ReadStarDundee(unsigned int *Value,unsigned int count,unsigned int address=0);
23 unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0);
24 unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0);
25 unsigned int WriteStarDundee(unsigned int *Value, unsigned int count, unsigned int address);
26 unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication);
27 unsigned int getLinkStatus(unsigned char link);
24 28
25 29 signals:
26 30 void sendMessage(QString message);
27 void starDundeeIsOpen(bool);
31 void isOpen(bool);
28 32 void RMAP_write_reply_setText(QString);
29 33 void appendToLog(QString);
34 void ccsdsPacketAvailable(unsigned char*, unsigned int);
30 35
31 36 public slots:
32 unsigned int OpenStarDundee();
33 unsigned int CloseStarDundee();
34 unsigned int SendPacket();
35 unsigned int SendRMAP();
36 unsigned int ReadRMAP();
37 unsigned int GetRoutingTableEntry();
38 void updateCommandCode(RMAP_command_codes code);
37 unsigned int Open();
38 unsigned int Close();
39 int receiveSPWPacket(unsigned char requestID);
40 void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;}
41 void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;}
42 void sourceHasChanged(int target) {rmapSourceLogicalAddress = (unsigned char) target;}
39 43
40 44 private:
41 char rmapTargetLogicalAddress ;
42 char rmapSourceLogicalAddress ;
45 unsigned int GetRoutingTableEntry();
46 unsigned int WriteBLOCK(char *data,unsigned int nbBytes,unsigned int address=0);
47 unsigned int ReadBLOCK(unsigned int nbBytes,unsigned int address=0);
48 void acquireRMAPSemaphore() {rmapPacketSEMAPHORE->acquire();}
49 void acquireCCSDSSemaphore() {ccsdsPacketSEMAPHORE->acquire();}
43 50
44 QPushButton *sendPacket_BUTTON;
45 QPushButton *sendRMAPPacket_BUTTON;
46 QPushButton *readRMAPPacket_BUTTON;
47 QPushButton *getRoutingTableEntry_BUTTON;
51 unsigned char rmapTargetLogicalAddress ;
52 unsigned char rmapSourceLogicalAddress ;
53
54 RMAP_command_codes commandCode;
48 55
49 56 QLabel *usbDeviceNumber_LABEL;
50 57 QLabel *linkNumber_LABEL;
51 QLabel *routingTableEntry_LABEL;
52 58 QLabel *sourceLogicalAddress_LABEL;
53 59
54 60 QSpinBox *usbDeviceNumber_SPINBOX;
55 61 QSpinBox *linkNumber_SPINBOX;
56 QSpinBox *routingTableEntry_SPINBOX;
57 62 QSpinBox *sourceLogicalAddress_SPINBOX;
58 63
59 64 QGridLayout *connection_LAYOUT;
60 65
61 66 unsigned char pBuffer[10]; // Pointer to the start of the user buffer from which to transmit data
62 unsigned char* rmapPacket; // The buffer to receive RMAP READ packets
63 67 USB_SPACEWIRE_ID pIdentifier; // A pointer to a variable which will be set to contain a unique identifier for the send
64 68
65 RMAP_command_codes commandCode;
66
67 69 star_device_handle hDevice; // Handle to the SpaceWire device
68 70 USB_SPACEWIRE_STATUS result; // The result of the send operation
69 71
72 // Packet receiver
73 QSemaphore *rmapPacketSEMAPHORE;
74 QSemaphore *ccsdsPacketSEMAPHORE;
75 char* rmapPacket; // The buffer to receive RMAP READ packets
76 unsigned char *ccsdsPacket;
77 char *spwPacket;
78 unsigned int rmapPacketSize;
79 unsigned int ccsdsPacketSize;
70 80 };
71 81
72 82 #endif // STARDUNDEE_H
General Comments 0
You need to be logged in to leave comments. Login now