@@ -1,284 +1,305 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <ui version="4.0"> |
|
3 | 3 | <class>StarDundeeUI</class> |
|
4 | 4 | <widget class="QWidget" name="StarDundeeUI"> |
|
5 | 5 | <property name="geometry"> |
|
6 | 6 | <rect> |
|
7 | 7 | <x>0</x> |
|
8 | 8 | <y>0</y> |
|
9 | 9 | <width>397</width> |
|
10 |
<height> |
|
|
10 | <height>506</height> | |
|
11 | 11 | </rect> |
|
12 | 12 | </property> |
|
13 | 13 | <property name="windowTitle"> |
|
14 | 14 | <string>Form</string> |
|
15 | 15 | </property> |
|
16 | 16 | <layout class="QFormLayout" name="formLayout"> |
|
17 | 17 | <item row="0" column="0"> |
|
18 | 18 | <widget class="QLabel" name="selectBrickLbl"> |
|
19 | 19 | <property name="text"> |
|
20 | 20 | <string>Select Brick</string> |
|
21 | 21 | </property> |
|
22 | 22 | </widget> |
|
23 | 23 | </item> |
|
24 | 24 | <item row="0" column="1"> |
|
25 | 25 | <widget class="QComboBox" name="selectBrickCmbx"> |
|
26 | 26 | <property name="toolTip"> |
|
27 | 27 | <string><html><head/><body><p>Select the brick you want to use.</p></body></html></string> |
|
28 | 28 | </property> |
|
29 | 29 | <property name="whatsThis"> |
|
30 | 30 | <string/> |
|
31 | 31 | </property> |
|
32 | 32 | <item> |
|
33 | 33 | <property name="text"> |
|
34 | 34 | <string>None</string> |
|
35 | 35 | </property> |
|
36 | 36 | </item> |
|
37 | 37 | </widget> |
|
38 | 38 | </item> |
|
39 | 39 | <item row="1" column="0"> |
|
40 | 40 | <widget class="QLabel" name="selectLinkLbl"> |
|
41 | 41 | <property name="text"> |
|
42 | 42 | <string>Select link number</string> |
|
43 | 43 | </property> |
|
44 | 44 | </widget> |
|
45 | 45 | </item> |
|
46 | 46 | <item row="1" column="1"> |
|
47 | 47 | <widget class="QComboBox" name="selectLinkCmbx"> |
|
48 | 48 | <property name="toolTip"> |
|
49 | 49 | <string><html><head/><body><p>Select the link number you want to use.</p><p>The link number correspond to the numbers on the brick:</p><p><img src=":/imgs/stardundee.tif"/></p><p><br/></p></body></html></string> |
|
50 | 50 | </property> |
|
51 | 51 | <item> |
|
52 | 52 | <property name="text"> |
|
53 | 53 | <string>1</string> |
|
54 | 54 | </property> |
|
55 | 55 | </item> |
|
56 | 56 | <item> |
|
57 | 57 | <property name="text"> |
|
58 | 58 | <string>2</string> |
|
59 | 59 | </property> |
|
60 | 60 | </item> |
|
61 | 61 | </widget> |
|
62 | 62 | </item> |
|
63 | 63 | <item row="2" column="0"> |
|
64 | 64 | <widget class="QLabel" name="selectLinkSpeedLbl"> |
|
65 | 65 | <property name="text"> |
|
66 | 66 | <string>Link Speed</string> |
|
67 | 67 | </property> |
|
68 | 68 | </widget> |
|
69 | 69 | </item> |
|
70 | 70 | <item row="2" column="1"> |
|
71 | 71 | <widget class="QComboBox" name="setLinkSpeedCmbx"> |
|
72 | 72 | <property name="toolTip"> |
|
73 | 73 | <string><html><head/><body><p>Select the Space Wire link speed you want to use.</p></body></html></string> |
|
74 | 74 | </property> |
|
75 | 75 | <item> |
|
76 | 76 | <property name="text"> |
|
77 | 77 | <string>10MHz</string> |
|
78 | 78 | </property> |
|
79 | 79 | </item> |
|
80 | 80 | </widget> |
|
81 | 81 | </item> |
|
82 | 82 | <item row="3" column="0"> |
|
83 | 83 | <widget class="QLabel" name="setDestKeyLbl"> |
|
84 | 84 | <property name="text"> |
|
85 | 85 | <string>Source address</string> |
|
86 | 86 | </property> |
|
87 | 87 | </widget> |
|
88 | 88 | </item> |
|
89 | 89 | <item row="3" column="1"> |
|
90 |
<widget class="QLineEdit" name=" |
|
|
90 | <widget class="QLineEdit" name="sourceAddressLineEdit"> | |
|
91 | 91 | <property name="toolTip"> |
|
92 | 92 | <string><html><head/><body><p>Set the Space Wire Brick destination Key, the default value is 32 (0x20).</p></body></html></string> |
|
93 | 93 | </property> |
|
94 | 94 | <property name="inputMask"> |
|
95 | 95 | <string comment="ddD"/> |
|
96 | 96 | </property> |
|
97 | 97 | <property name="text"> |
|
98 | 98 | <string>32</string> |
|
99 | 99 | </property> |
|
100 | 100 | <property name="maxLength"> |
|
101 | 101 | <number>3</number> |
|
102 | 102 | </property> |
|
103 | 103 | </widget> |
|
104 | 104 | </item> |
|
105 | 105 | <item row="4" column="0"> |
|
106 | 106 | <widget class="QLabel" name="RMAPaddressLbl"> |
|
107 | 107 | <property name="text"> |
|
108 | 108 | <string>Destination address</string> |
|
109 | 109 | </property> |
|
110 | 110 | </widget> |
|
111 | 111 | </item> |
|
112 | 112 | <item row="4" column="1"> |
|
113 |
<widget class="QLineEdit" name=" |
|
|
113 | <widget class="QLineEdit" name="destinationAddressLineEdit"> | |
|
114 | 114 | <property name="toolTip"> |
|
115 | 115 | <string><html><head/><body><p>Set the RMAP target address, this address will be used as destination address for all the RMAP transfers.</p><p>This is you SOC spw address.</p></body></html></string> |
|
116 | 116 | </property> |
|
117 | 117 | <property name="inputMask"> |
|
118 | 118 | <string comment="ddD"/> |
|
119 | 119 | </property> |
|
120 | 120 | <property name="text"> |
|
121 | 121 | <string>254</string> |
|
122 | 122 | </property> |
|
123 | 123 | <property name="maxLength"> |
|
124 | 124 | <number>3</number> |
|
125 | 125 | </property> |
|
126 | 126 | </widget> |
|
127 | 127 | </item> |
|
128 | 128 | <item row="5" column="0"> |
|
129 | 129 | <widget class="QLabel" name="RMAPKeyLbl"> |
|
130 | 130 | <property name="text"> |
|
131 | 131 | <string>Destination key</string> |
|
132 | 132 | </property> |
|
133 | 133 | </widget> |
|
134 | 134 | </item> |
|
135 | 135 | <item row="5" column="1"> |
|
136 |
<widget class="QLineEdit" name=" |
|
|
136 | <widget class="QLineEdit" name="destinationKeyLineEdit"> | |
|
137 | 137 | <property name="toolTip"> |
|
138 | 138 | <string><html><head/><body><p>Set the RMAP target key, this key will be used for all the RMAP transfers.</p><p>This is you SOC spw key.</p></body></html></string> |
|
139 | 139 | </property> |
|
140 | 140 | <property name="inputMask"> |
|
141 | 141 | <string comment="ddD"/> |
|
142 | 142 | </property> |
|
143 | 143 | <property name="text"> |
|
144 | 144 | <string comment="ddD">2</string> |
|
145 | 145 | </property> |
|
146 | 146 | <property name="maxLength"> |
|
147 | 147 | <number>3</number> |
|
148 | 148 | </property> |
|
149 | 149 | </widget> |
|
150 | 150 | </item> |
|
151 | 151 | <item row="6" column="1"> |
|
152 | 152 | <widget class="QLineEdit" name="RMAPTimeoutLineEdit"> |
|
153 | 153 | <property name="toolTip"> |
|
154 | 154 | <string><html><head/><body><p>Set the RMAP timeout, when waiting for a RMAP answer the driver will give up after this time if it doesn't get any answer.</p></body></html></string> |
|
155 | 155 | </property> |
|
156 | 156 | <property name="inputMethodHints"> |
|
157 | 157 | <set>Qt::ImhDigitsOnly</set> |
|
158 | 158 | </property> |
|
159 | 159 | <property name="inputMask"> |
|
160 | 160 | <string comment="DDdd;"/> |
|
161 | 161 | </property> |
|
162 | 162 | <property name="text"> |
|
163 | 163 | <string>500</string> |
|
164 | 164 | </property> |
|
165 | 165 | <property name="maxLength"> |
|
166 | 166 | <number>5</number> |
|
167 | 167 | </property> |
|
168 | 168 | </widget> |
|
169 | 169 | </item> |
|
170 | 170 | <item row="6" column="0"> |
|
171 | 171 | <widget class="QLabel" name="RMAPTimeoutLbl"> |
|
172 | 172 | <property name="text"> |
|
173 | 173 | <string>RMAP timeout(ms)</string> |
|
174 | 174 | </property> |
|
175 | 175 | </widget> |
|
176 | 176 | </item> |
|
177 |
<item row=" |
|
|
177 | <item row="10" column="1"> | |
|
178 | 178 | <widget class="QPushButton" name="connectQpb"> |
|
179 | 179 | <property name="text"> |
|
180 | 180 | <string>Connect</string> |
|
181 | 181 | </property> |
|
182 | 182 | </widget> |
|
183 | 183 | </item> |
|
184 |
<item row=" |
|
|
184 | <item row="8" column="1"> | |
|
185 | 185 | <widget class="QRadioButton" name="setInterfaceModeQrb"> |
|
186 | 186 | <property name="text"> |
|
187 | 187 | <string>interface mode</string> |
|
188 | 188 | </property> |
|
189 | 189 | <property name="checked"> |
|
190 | 190 | <bool>true</bool> |
|
191 | 191 | </property> |
|
192 | 192 | </widget> |
|
193 | 193 | </item> |
|
194 |
<item row=" |
|
|
194 | <item row="9" column="1"> | |
|
195 | 195 | <widget class="QRadioButton" name="setRouterModeQrb"> |
|
196 | 196 | <property name="text"> |
|
197 | 197 | <string>router mode</string> |
|
198 | 198 | </property> |
|
199 | 199 | </widget> |
|
200 | 200 | </item> |
|
201 |
<item row="1 |
|
|
201 | <item row="11" column="0" colspan="2"> | |
|
202 | 202 | <layout class="QGridLayout" name="gridLayout"> |
|
203 | 203 | <item row="1" column="0"> |
|
204 | 204 | <widget class="QLabel" name="label_4"> |
|
205 | 205 | <property name="text"> |
|
206 | 206 | <string>Packets</string> |
|
207 | 207 | </property> |
|
208 | 208 | </widget> |
|
209 | 209 | </item> |
|
210 | 210 | <item row="1" column="1"> |
|
211 | 211 | <widget class="QLabel" name="starDundeeReceivedPackets"> |
|
212 | 212 | <property name="text"> |
|
213 | 213 | <string>-</string> |
|
214 | 214 | </property> |
|
215 | 215 | </widget> |
|
216 | 216 | </item> |
|
217 | 217 | <item row="0" column="1"> |
|
218 | 218 | <widget class="QLabel" name="label_3"> |
|
219 | 219 | <property name="font"> |
|
220 | 220 | <font> |
|
221 | 221 | <weight>75</weight> |
|
222 | 222 | <bold>true</bold> |
|
223 | 223 | </font> |
|
224 | 224 | </property> |
|
225 | 225 | <property name="text"> |
|
226 | 226 | <string>Received</string> |
|
227 | 227 | </property> |
|
228 | 228 | </widget> |
|
229 | 229 | </item> |
|
230 | 230 | <item row="2" column="1"> |
|
231 | 231 | <widget class="QLabel" name="starDundeeReceivedBytes"> |
|
232 | 232 | <property name="text"> |
|
233 | 233 | <string>-</string> |
|
234 | 234 | </property> |
|
235 | 235 | </widget> |
|
236 | 236 | </item> |
|
237 | 237 | <item row="2" column="0"> |
|
238 | 238 | <widget class="QLabel" name="label_5"> |
|
239 | 239 | <property name="text"> |
|
240 | 240 | <string>Bytes</string> |
|
241 | 241 | </property> |
|
242 | 242 | </widget> |
|
243 | 243 | </item> |
|
244 | 244 | <item row="0" column="2"> |
|
245 | 245 | <widget class="QLabel" name="label_7"> |
|
246 | 246 | <property name="font"> |
|
247 | 247 | <font> |
|
248 | 248 | <weight>75</weight> |
|
249 | 249 | <bold>true</bold> |
|
250 | 250 | </font> |
|
251 | 251 | </property> |
|
252 | 252 | <property name="text"> |
|
253 | 253 | <string>Transmitted</string> |
|
254 | 254 | </property> |
|
255 | 255 | </widget> |
|
256 | 256 | </item> |
|
257 | 257 | <item row="1" column="2"> |
|
258 | 258 | <widget class="QLabel" name="starDundeeTransmittedPackets"> |
|
259 | 259 | <property name="text"> |
|
260 | 260 | <string>-</string> |
|
261 | 261 | </property> |
|
262 | 262 | </widget> |
|
263 | 263 | </item> |
|
264 | 264 | <item row="2" column="2"> |
|
265 | 265 | <widget class="QLabel" name="starDundeeTransmittedBytes"> |
|
266 | 266 | <property name="text"> |
|
267 | 267 | <string>-</string> |
|
268 | 268 | </property> |
|
269 | 269 | </widget> |
|
270 | 270 | </item> |
|
271 | 271 | <item row="0" column="0"> |
|
272 | 272 | <widget class="QPushButton" name="resetStatsQpb"> |
|
273 | 273 | <property name="text"> |
|
274 | 274 | <string>Reset stats</string> |
|
275 | 275 | </property> |
|
276 | 276 | </widget> |
|
277 | 277 | </item> |
|
278 | 278 | </layout> |
|
279 | 279 | </item> |
|
280 | <item row="8" column="0"> | |
|
281 | <widget class="QCheckBox" name="spwTimecodes"> | |
|
282 | <property name="text"> | |
|
283 | <string>timecode</string> | |
|
284 | </property> | |
|
285 | </widget> | |
|
286 | </item> | |
|
287 | <item row="7" column="0"> | |
|
288 | <widget class="QLabel" name="label"> | |
|
289 | <property name="text"> | |
|
290 | <string>Timecode f (Hz)</string> | |
|
291 | </property> | |
|
292 | </widget> | |
|
293 | </item> | |
|
294 | <item row="7" column="1"> | |
|
295 | <widget class="QLineEdit" name="timecodeFrequencyLineEdit"> | |
|
296 | <property name="text"> | |
|
297 | <string>1</string> | |
|
298 | </property> | |
|
299 | </widget> | |
|
300 | </item> | |
|
280 | 301 | </layout> |
|
281 | 302 | </widget> |
|
282 | 303 | <resources/> |
|
283 | 304 | <connections/> |
|
284 | 305 | </ui> |
@@ -1,254 +1,288 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - 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@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #include "stardundeegui.h" |
|
23 | 23 | |
|
24 | 24 | #include "ui_stardundeeGUI.h" |
|
25 | 25 | #include <spw_usb_api.h> |
|
26 | 26 | #include <spw_config_library.h> |
|
27 | 27 | |
|
28 | 28 | StarDundeeGUI::StarDundeeGUI(QWidget *parent) : |
|
29 | 29 | QWidget(parent),ui(new Ui::StarDundeeUI) |
|
30 | 30 | { |
|
31 | 31 | resetBytesPacketsStatistics(); |
|
32 | 32 | |
|
33 | 33 | this->ui->setupUi(this); |
|
34 | 34 | connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int))); |
|
35 | 35 | connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int))); |
|
36 | 36 | connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString))); |
|
37 |
connect(this->ui-> |
|
|
38 |
connect(this->ui-> |
|
|
39 |
connect(this->ui-> |
|
|
37 | connect(this->ui->sourceAddressLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString))); | |
|
38 | connect(this->ui->destinationAddressLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString))); | |
|
39 | connect(this->ui->destinationKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString))); | |
|
40 | 40 | connect(this->ui->RMAPTimeoutLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapTimeoutChanged(QString))); |
|
41 | connect(this->ui->timecodeFrequencyLineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(timecodeFrequencyChange(QString))); | |
|
41 | 42 | connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked())); |
|
42 | 43 | connect(this->ui->setInterfaceModeQrb, SIGNAL(toggled(bool)), this, SIGNAL(brickModeChanged(bool))); |
|
43 | 44 | connect(this->ui->resetStatsQpb, SIGNAL(clicked()), this, SLOT(resetStatistics())); |
|
45 | connect(this->ui->spwTimecodes, SIGNAL(toggled(bool)), this, SIGNAL(startSendingTimecode(bool))); | |
|
44 | 46 | } |
|
45 | 47 | |
|
46 | 48 | int StarDundeeGUI::getBrickSelection() |
|
47 | 49 | { |
|
48 | 50 | return ui->selectBrickCmbx->currentIndex(); |
|
49 | 51 | } |
|
50 | 52 | |
|
51 | 53 | int StarDundeeGUI::getLinkNumberSelection() |
|
52 | 54 | { |
|
53 | 55 | return ui->selectLinkCmbx->currentIndex(); |
|
54 | 56 | } |
|
55 | 57 | |
|
56 | 58 | QString StarDundeeGUI::getLinkSpeedSelection() |
|
57 | 59 | { |
|
58 | 60 | return ui->setLinkSpeedCmbx->currentText(); |
|
59 | 61 | } |
|
60 | 62 | |
|
61 |
QString StarDundeeGUI::get |
|
|
63 | QString StarDundeeGUI::getSourceAddress() | |
|
62 | 64 | { |
|
63 |
return ui-> |
|
|
65 | return ui->sourceAddressLineEdit->text(); | |
|
64 | 66 | } |
|
65 | 67 | |
|
66 |
QString StarDundeeGUI::get |
|
|
68 | QString StarDundeeGUI::getDestinationAddress() | |
|
67 | 69 | { |
|
68 |
return ui-> |
|
|
70 | return ui->destinationAddressLineEdit->text(); | |
|
69 | 71 | } |
|
70 | 72 | |
|
71 |
QString StarDundeeGUI::get |
|
|
73 | QString StarDundeeGUI::getDestinationKey() | |
|
72 | 74 | { |
|
73 |
return ui-> |
|
|
75 | return ui->destinationKeyLineEdit->text(); | |
|
74 | 76 | } |
|
75 | 77 | |
|
76 | 78 | QString StarDundeeGUI::getRmapTimeout() |
|
77 | 79 | { |
|
78 | 80 | return ui->RMAPTimeoutLineEdit->text(); |
|
79 | 81 | } |
|
80 | 82 | |
|
83 | QString StarDundeeGUI::getTimecodeFrequency() | |
|
84 | { | |
|
85 | return ui->timecodeFrequencyLineEdit->text(); | |
|
86 | } | |
|
87 | ||
|
88 | bool StarDundeeGUI::getStartSendingTimecodes() | |
|
89 | { | |
|
90 | return ui->spwTimecodes->isChecked(); | |
|
91 | } | |
|
92 | ||
|
81 | 93 | bool StarDundeeGUI::isBrickSetAsAnInterface() |
|
82 | 94 | { |
|
83 | 95 | return ui->setInterfaceModeQrb->isChecked(); |
|
84 | 96 | } |
|
85 | 97 | |
|
86 | 98 | void StarDundeeGUI::setBrickAsAnInterface( bool interfaceMode ) |
|
87 | 99 | { |
|
88 | 100 | if (interfaceMode == true) |
|
89 | 101 | { |
|
90 | 102 | this->ui->setInterfaceModeQrb->setChecked( true ); |
|
91 | 103 | } |
|
92 | 104 | else |
|
93 | 105 | { |
|
94 | 106 | this->ui->setRouterModeQrb->setChecked( true ); |
|
95 | 107 | } |
|
96 | 108 | } |
|
97 | 109 | |
|
98 | 110 | void StarDundeeGUI::setBrickAsARouter( bool interfaceMode ) |
|
99 | 111 | { |
|
100 | 112 | if (interfaceMode==true) |
|
101 | 113 | { |
|
102 | 114 | this->ui->setRouterModeQrb->setChecked( true ); |
|
103 | 115 | } |
|
104 | 116 | else |
|
105 | 117 | { |
|
106 | 118 | this->ui->setInterfaceModeQrb->setChecked( true ); |
|
107 | 119 | } |
|
108 | 120 | |
|
109 | 121 | } |
|
110 | 122 | |
|
111 | 123 | void StarDundeeGUI::lock(bool lock) |
|
112 | 124 | { |
|
113 | 125 | this->ui->selectBrickCmbx->setDisabled(lock); |
|
114 | 126 | this->ui->selectLinkCmbx->setDisabled(lock); |
|
115 | 127 | this->ui->setLinkSpeedCmbx->setDisabled(lock); |
|
116 |
this->ui-> |
|
|
117 |
this->ui-> |
|
|
118 |
this->ui-> |
|
|
128 | this->ui->sourceAddressLineEdit->setDisabled(lock); | |
|
129 | this->ui->destinationAddressLineEdit->setDisabled(lock); | |
|
130 | this->ui->destinationKeyLineEdit->setDisabled(lock); | |
|
119 | 131 | this->ui->RMAPTimeoutLineEdit->setDisabled(lock); |
|
120 | 132 | this->ui->setInterfaceModeQrb->setDisabled(lock); |
|
121 | 133 | this->ui->setRouterModeQrb->setDisabled(lock); |
|
122 | 134 | if(lock) |
|
123 | 135 | this->ui->connectQpb->setText("Disconnect"); |
|
124 | 136 | else |
|
125 | 137 | this->ui->connectQpb->setText("Connect"); |
|
126 | 138 | } |
|
127 | 139 | |
|
128 | 140 | void StarDundeeGUI::updateAvailableBrickCount(int count) |
|
129 | 141 | { |
|
130 | 142 | this->ui->selectBrickCmbx->clear(); |
|
131 | 143 | this->ui->selectBrickCmbx->addItem("none"); |
|
132 | 144 | for(int i =0;i<32;i++) |
|
133 | 145 | { |
|
134 | 146 | if((count&1)==1) |
|
135 | 147 | { |
|
136 | 148 | star_device_handle hDevice; |
|
137 | 149 | char serial[11]=""; |
|
138 | 150 | if (USBSpaceWire_Open(&hDevice, 0)) |
|
139 | 151 | { |
|
140 | 152 | USBSpaceWire_GetSerialNumber(hDevice,(U8*) serial); |
|
141 | 153 | USBSpaceWire_Close(hDevice); |
|
142 | 154 | } |
|
143 | 155 | this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i)+" sn:" + serial); |
|
144 | 156 | } |
|
145 | 157 | count>>=1; |
|
146 | 158 | } |
|
147 | 159 | } |
|
148 | 160 | |
|
149 | 161 | void StarDundeeGUI::setRmapTimeout(const QString &timeout) |
|
150 | 162 | { |
|
151 | 163 | this->ui->RMAPTimeoutLineEdit->setText(timeout); |
|
152 | 164 | } |
|
153 | 165 | |
|
154 | 166 | void StarDundeeGUI::selectBrick(int brickIndex) |
|
155 | 167 | { |
|
156 | 168 | if(brickIndex>=0&& brickIndex<this->ui->selectBrickCmbx->count()) |
|
157 | 169 | { |
|
158 | 170 | this->ui->selectBrickCmbx->setCurrentIndex(brickIndex); |
|
159 | 171 | } |
|
160 | 172 | } |
|
161 | 173 | |
|
162 | 174 | void StarDundeeGUI::selectLinkNumber(int linkNumber) |
|
163 | 175 | { |
|
164 | 176 | if(linkNumber==1 || linkNumber==2) |
|
165 | 177 | { |
|
166 | 178 | this->ui->selectLinkCmbx->setCurrentIndex(linkNumber-1); |
|
167 | 179 | } |
|
168 | 180 | } |
|
169 | 181 | |
|
170 | 182 | void StarDundeeGUI::selectLinkSpeed(int linkSpeed) |
|
171 | 183 | { |
|
172 | 184 | #define MHz *(1000*1000) |
|
173 | 185 | if(linkSpeed==10 MHz) |
|
174 | 186 | { |
|
175 | 187 | this->ui->selectLinkCmbx->setCurrentIndex(0); |
|
176 | 188 | } |
|
177 | 189 | } |
|
178 | 190 | |
|
179 |
void StarDundeeGUI::set |
|
|
191 | void StarDundeeGUI::setSourceAddress(const QString &address) | |
|
180 | 192 | { |
|
181 | 193 | bool ok; |
|
182 |
|
|
|
194 | address.toInt(&ok,10); | |
|
183 | 195 | if(ok) |
|
184 | 196 | { |
|
185 |
this->ui-> |
|
|
197 | this->ui->sourceAddressLineEdit->setText(address); | |
|
198 | } | |
|
199 | } | |
|
200 | ||
|
201 | void StarDundeeGUI::setDestinationAddress(const QString &address) | |
|
202 | { | |
|
203 | bool ok; | |
|
204 | address.toInt(&ok,10); | |
|
205 | if(ok) | |
|
206 | { | |
|
207 | this->ui->destinationAddressLineEdit->setText(address); | |
|
186 | 208 | } |
|
187 | 209 | } |
|
188 | 210 | |
|
189 |
void StarDundeeGUI::set |
|
|
211 | void StarDundeeGUI::setDestinationKey(const QString &key) | |
|
190 | 212 | { |
|
191 | 213 | bool ok; |
|
192 |
|
|
|
214 | key.toInt(&ok,10); | |
|
193 | 215 | if(ok) |
|
194 | 216 | { |
|
195 |
this->ui-> |
|
|
217 | this->ui->destinationKeyLineEdit->setText(key); | |
|
196 | 218 | } |
|
197 | 219 | } |
|
198 | 220 | |
|
199 |
void StarDundeeGUI::set |
|
|
221 | void StarDundeeGUI::setTimecodeFrequency(const QString &frequency) | |
|
200 | 222 | { |
|
201 | 223 | bool ok; |
|
202 | int tmp=key.toInt(&ok,10); | |
|
224 | frequency.toDouble(&ok); | |
|
203 | 225 | if(ok) |
|
204 | 226 | { |
|
205 |
this->ui-> |
|
|
227 | this->ui->timecodeFrequencyLineEdit->setText(frequency); | |
|
228 | } | |
|
229 | } | |
|
230 | ||
|
231 | void StarDundeeGUI::setStartSendingTimecodes( bool onOff ) | |
|
232 | { | |
|
233 | if (this->ui->spwTimecodes->isChecked()) | |
|
234 | { | |
|
235 | if (onOff==false) this->ui->spwTimecodes->setChecked(false); | |
|
236 | } | |
|
237 | else | |
|
238 | { | |
|
239 | if (onOff==true) this->ui->spwTimecodes->setChecked(true); | |
|
206 | 240 | } |
|
207 | 241 | } |
|
208 | 242 | |
|
209 | 243 | int StarDundeeGUI::getAvailableBrickCount( void ) |
|
210 | 244 | { |
|
211 | 245 | int list = USBSpaceWire_ListDevices(); |
|
212 | 246 | emit updateAvailableBrickCount(list); |
|
213 | 247 | QCoreApplication::processEvents(); |
|
214 | 248 | return list; |
|
215 | 249 | } |
|
216 | 250 | |
|
217 | 251 | void StarDundeeGUI::resetBytesPacketsStatistics( void ) |
|
218 | 252 | { |
|
219 | 253 | nbBytesReceivedFromSpw = 0; |
|
220 | 254 | nbBytesTransmittedToSpw = 0; |
|
221 | 255 | nbPacketsReceivedFromSpw = 0; |
|
222 | 256 | nbPacketsTransmittedToSpw = 0; |
|
223 | 257 | } |
|
224 | 258 | |
|
225 | 259 | void StarDundeeGUI::resetStatistics( void ) |
|
226 | 260 | { |
|
227 | 261 | nbBytesReceivedFromSpw = 0; |
|
228 | 262 | nbBytesTransmittedToSpw = 0; |
|
229 | 263 | nbPacketsReceivedFromSpw = 0; |
|
230 | 264 | nbPacketsTransmittedToSpw = 0; |
|
231 | 265 | |
|
232 | 266 | this->ui->starDundeeReceivedBytes->setText( QString::number(nbBytesReceivedFromSpw) ); |
|
233 | 267 | this->ui->starDundeeReceivedPackets->setText( QString::number(nbPacketsReceivedFromSpw) ); |
|
234 | 268 | this->ui->starDundeeTransmittedBytes->setText( QString::number(nbBytesTransmittedToSpw) ); |
|
235 | 269 | this->ui->starDundeeTransmittedPackets->setText( QString::number(nbPacketsTransmittedToSpw) ); |
|
236 | 270 | } |
|
237 | 271 | |
|
238 | 272 | void StarDundeeGUI::updateNbReceivedBytesFromSpw( unsigned int nbBytes) |
|
239 | 273 | { |
|
240 | 274 | nbBytesReceivedFromSpw = nbBytesReceivedFromSpw + nbBytes; |
|
241 | 275 | nbPacketsReceivedFromSpw = nbPacketsReceivedFromSpw + 1; |
|
242 | 276 | |
|
243 | 277 | this->ui->starDundeeReceivedBytes->setText( QString::number(nbBytesReceivedFromSpw) ); |
|
244 | 278 | this->ui->starDundeeReceivedPackets->setText( QString::number(nbPacketsReceivedFromSpw) ); |
|
245 | 279 | } |
|
246 | 280 | |
|
247 | 281 | void StarDundeeGUI::updateNbTransmittedBytesToSpw( unsigned int nbBytes) |
|
248 | 282 | { |
|
249 | 283 | nbBytesTransmittedToSpw = nbBytesTransmittedToSpw + nbBytes; |
|
250 | 284 | nbPacketsTransmittedToSpw = nbPacketsTransmittedToSpw + 1; |
|
251 | 285 | |
|
252 | 286 | this->ui->starDundeeTransmittedBytes->setText( QString::number(nbBytesTransmittedToSpw) ); |
|
253 | 287 | this->ui->starDundeeTransmittedPackets->setText( QString::number(nbPacketsTransmittedToSpw) ); |
|
254 | 288 | } |
@@ -1,79 +1,85 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - 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@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef STARDUNDEEGUI_H |
|
23 | 23 | #define STARDUNDEEGUI_H |
|
24 | 24 | |
|
25 | 25 | #include <QWidget> |
|
26 | 26 | |
|
27 | 27 | namespace Ui { |
|
28 | 28 | class StarDundeeUI; |
|
29 | 29 | } |
|
30 | 30 | |
|
31 | 31 | class StarDundeeGUI : public QWidget |
|
32 | 32 | { |
|
33 | 33 | Q_OBJECT |
|
34 | 34 | public: |
|
35 | 35 | explicit StarDundeeGUI(QWidget *parent = 0); |
|
36 | 36 | int getBrickSelection(); |
|
37 | 37 | int getLinkNumberSelection(); |
|
38 | 38 | QString getLinkSpeedSelection(); |
|
39 | QString getSourceAddress(); | |
|
40 | QString getDestinationAddress(); | |
|
39 | 41 | QString getDestinationKey(); |
|
40 | QString getRmapAddress(); | |
|
41 | QString getRmapKey(); | |
|
42 | 42 | QString getRmapTimeout(); |
|
43 | QString getTimecodeFrequency(); | |
|
44 | bool getStartSendingTimecodes(); | |
|
43 | 45 | bool isBrickSetAsAnInterface(); |
|
44 | 46 | signals: |
|
45 | 47 | void brickSelectionChanged(int brickIndex); |
|
46 | 48 | void linkNumberSelectionChanged(int linkIndex); |
|
47 | 49 | void linkSpeedSelectionChanged(const QString & linkSpeed); |
|
48 | 50 | void destinationKeyChanged(const QString & destKey); |
|
49 | 51 | void rmapAddressChanged(const QString & address); |
|
50 | 52 | void rmapKeyChanged(const QString & key); |
|
51 | 53 | void rmapTimeoutChanged(const QString & timeout); |
|
54 | void timecodeFrequencyChange(const QString & timeout); | |
|
52 | 55 | void connectClicked(); |
|
53 | 56 | void brickModeChanged(bool); |
|
57 | void startSendingTimecode(bool); | |
|
54 | 58 | public slots: |
|
55 | 59 | void lock(bool lock); |
|
56 | 60 | void updateAvailableBrickCount(int count); |
|
57 | 61 | void selectBrick(int brickIndex); |
|
58 | 62 | void selectLinkNumber(int linkIndex); |
|
59 | 63 | void selectLinkSpeed(int linkSpeed); |
|
60 | 64 | void setDestinationKey(const QString & destKey); |
|
61 |
void set |
|
|
62 |
void set |
|
|
65 | void setSourceAddress(const QString & address); | |
|
66 | void setDestinationAddress(const QString & address); | |
|
67 | void setTimecodeFrequency(const QString &frequency); | |
|
68 | void setStartSendingTimecodes( bool onOff ); | |
|
63 | 69 | void setRmapTimeout(const QString & timeout); |
|
64 | 70 | int getAvailableBrickCount( void ); |
|
65 | 71 | void setBrickAsAnInterface(bool interfaceMode); |
|
66 | 72 | void setBrickAsARouter( bool interfaceMode ); |
|
67 | 73 | void resetBytesPacketsStatistics( void ); |
|
68 | 74 | void resetStatistics( void ); |
|
69 | 75 | void updateNbReceivedBytesFromSpw( unsigned int nbBytes); |
|
70 | 76 | void updateNbTransmittedBytesToSpw( unsigned int nbBytes); |
|
71 | 77 | private: |
|
72 | 78 | Ui::StarDundeeUI *ui; |
|
73 | 79 | unsigned int nbBytesReceivedFromSpw; |
|
74 | 80 | unsigned int nbBytesTransmittedToSpw; |
|
75 | 81 | unsigned int nbPacketsReceivedFromSpw; |
|
76 | 82 | unsigned int nbPacketsTransmittedToSpw; |
|
77 | 83 | }; |
|
78 | 84 | |
|
79 | 85 | #endif // STARDUNDEEGUI_H |
@@ -1,1020 +1,1055 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - 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@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | |
|
23 | 23 | #include "stardundeespw_usb.h" |
|
24 | 24 | #include <socexplorerengine.h> |
|
25 | 25 | #include <qhexedit.h> |
|
26 | 26 | |
|
27 | 27 | QString dwLinkStatusQString[6] = { |
|
28 | 28 | "CFG_SPACEWIRE_ERROR_RESET", |
|
29 | 29 | "CFG_SPACEWIRE_ERROR_WAIT", |
|
30 | 30 | "CFG_SPACEWIRE_READY", |
|
31 | 31 | "CFG_SPACEWIRE_STARTED", |
|
32 | 32 | "CFG_SPACEWIRE_CONNECTING", |
|
33 | 33 | "CFG_SPACEWIRE_RUN" |
|
34 | 34 | }; |
|
35 | 35 | |
|
36 | 36 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : |
|
37 | 37 | abstractSpwBridge(parent) |
|
38 | 38 | { |
|
39 | 39 | Q_UNUSED(parent) |
|
40 | 40 | this->manager = new stardundeeSPW_USB_Manager(parent,this); |
|
41 | 41 | makeGUI(parent); |
|
42 | 42 | this->manager->start(); |
|
43 | 43 | connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int))); |
|
44 | 44 | connect(this->manager, SIGNAL(bytesReceivedFromSpw(uint)), this, SIGNAL(BytesReceivedFromSpw(uint))); |
|
45 | 45 | connect(this->manager, SIGNAL(bytesTransmittedToSpw(uint)), this, SIGNAL(BytesTransmittedToSpw(uint))); |
|
46 | 46 | } |
|
47 | 47 | |
|
48 | 48 | stardundeeSPW_USB::~stardundeeSPW_USB() |
|
49 | 49 | { |
|
50 | 50 | this->manager->requestInterruption(); |
|
51 | 51 | while(this->manager->isRunning()); |
|
52 | 52 | } |
|
53 | 53 | |
|
54 | 54 | void stardundeeSPW_USB::toggleBridgeConnection() |
|
55 | 55 | { |
|
56 | 56 | if(this->plugin->isConnected()) |
|
57 | 57 | { |
|
58 | 58 | this->disconnectBridge(); |
|
59 | 59 | } |
|
60 | 60 | else |
|
61 | 61 | { |
|
62 | 62 | this->connectBridge(); |
|
63 | 63 | } |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | bool stardundeeSPW_USB::connectBridge() |
|
67 | 67 | { |
|
68 | 68 | if(this->manager->connectBridge()) |
|
69 | 69 | { |
|
70 | this->timecodeFrequencyChanged( ((StarDundeeGUI*)this->p_GUI)->getTimecodeFrequency()); | |
|
71 | this->startSendingTimecodes( ((StarDundeeGUI*)this->p_GUI)->getStartSendingTimecodes()); | |
|
70 | 72 | ((StarDundeeGUI*)this->p_GUI)->lock(true); |
|
71 | 73 | emit setConnected(true); |
|
72 | 74 | return true; |
|
73 | 75 | } |
|
74 | 76 | return false; |
|
75 | 77 | } |
|
76 | 78 | |
|
77 | 79 | bool stardundeeSPW_USB::disconnectBridge() |
|
78 | 80 | { |
|
79 | 81 | if(this->manager->disconnectBridge()) |
|
80 | 82 | { |
|
81 | 83 | ((StarDundeeGUI*)this->p_GUI)->lock(false); |
|
82 | 84 | emit setConnected(false); |
|
83 | 85 | return true; |
|
84 | 86 | } |
|
85 | 87 | return false; |
|
86 | 88 | } |
|
87 | 89 | |
|
88 | 90 | |
|
89 | 91 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) |
|
90 | 92 | { |
|
91 | 93 | return this->manager->sendPacket(packet,size); |
|
92 | 94 | } |
|
93 | 95 | |
|
94 | 96 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
95 | 97 | { |
|
96 | 98 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; |
|
97 | 99 | char *RMAPAckBuff; |
|
98 | 100 | writeBuffer[0]=this->manager->linkNumber;//Link number |
|
99 | 101 | int transactionID = 0; |
|
100 | 102 | int written=0; |
|
101 | 103 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); |
|
102 | 104 | QProgressBar* progress=NULL; |
|
103 | 105 | SocExplorerAutoProgressBar autopb; |
|
104 | 106 | if(count>RMAP_MAX_XFER_SIZE) |
|
105 | 107 | { |
|
106 | 108 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
107 | 109 | autopb.setProgressBar(progress); |
|
108 | 110 | } |
|
109 | 111 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
110 | 112 | while(count>=RMAP_MAX_XFER_SIZE) |
|
111 | 113 | { |
|
112 | 114 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) |
|
113 | 115 | { |
|
114 | 116 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
115 | 117 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
116 | 118 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
117 | 119 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
118 | 120 | } |
|
119 | 121 | transactionID=manager->getRMAPtransactionID(); |
|
120 | 122 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
121 | 123 | RMAP_build_tx_request_header( |
|
122 | 124 | this->manager->destinationLogicalAddress, |
|
123 | 125 | this->manager->destinationKey, |
|
124 | 126 | this->manager->sourceLogicalAddress, |
|
125 | 127 | transactionID, |
|
126 | 128 | address+(written*4), |
|
127 | 129 | RMAP_MAX_XFER_SIZE*4, |
|
128 | 130 | writeBuffer+1); |
|
129 | 131 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); |
|
130 | 132 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
131 | 133 | free(RMAPAckBuff); |
|
132 | 134 | written+=RMAP_MAX_XFER_SIZE; |
|
133 | 135 | count-=RMAP_MAX_XFER_SIZE; |
|
134 | 136 | progress->setValue(written); |
|
135 | 137 | qApp->processEvents(); |
|
136 | 138 | } |
|
137 | 139 | if(count>0) |
|
138 | 140 | { |
|
139 | 141 | for(int i=0;i<((int)count);i++) |
|
140 | 142 | { |
|
141 | 143 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
142 | 144 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
143 | 145 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
144 | 146 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
145 | 147 | } |
|
146 | 148 | transactionID=manager->getRMAPtransactionID(); |
|
147 | 149 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
148 | 150 | RMAP_build_tx_request_header( |
|
149 | 151 | this->manager->destinationLogicalAddress, |
|
150 | 152 | this->manager->destinationKey, |
|
151 | 153 | this->manager->sourceLogicalAddress, |
|
152 | 154 | transactionID, |
|
153 | 155 | address+(written*4), |
|
154 | 156 | count*4, |
|
155 | 157 | writeBuffer+1); |
|
156 | 158 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); |
|
157 | 159 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
158 | 160 | free(RMAPAckBuff); |
|
159 | 161 | written+=count; |
|
160 | 162 | if(progress!=NULL) |
|
161 | 163 | { |
|
162 | 164 | progress->setValue(written); |
|
163 | 165 | qApp->processEvents(); |
|
164 | 166 | } |
|
165 | 167 | } |
|
166 | 168 | return written; |
|
167 | 169 | } |
|
168 | 170 | |
|
169 | 171 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
170 | 172 | { |
|
171 | 173 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; |
|
172 | 174 | char* RMAP_AnswerBuffer; |
|
173 | 175 | requestBuffer[0]=this->manager->linkNumber;//Link number |
|
174 | 176 | int transactionID = 0; |
|
175 | 177 | int read=0; |
|
176 | 178 | QProgressBar* progress=NULL; |
|
177 | 179 | SocExplorerAutoProgressBar autopb; |
|
178 | 180 | if(count>RMAP_MAX_XFER_SIZE) |
|
179 | 181 | { |
|
180 | 182 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
181 | 183 | autopb.setProgressBar(progress); |
|
182 | 184 | } |
|
183 | 185 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); |
|
184 | 186 | |
|
185 | 187 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
186 | 188 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) |
|
187 | 189 | { |
|
188 | 190 | transactionID = manager->getRMAPtransactionID(); |
|
189 | 191 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); |
|
190 | 192 | RMAP_build_rx_request_header( |
|
191 | 193 | this->manager->destinationLogicalAddress, |
|
192 | 194 | this->manager->destinationKey, |
|
193 | 195 | this->manager->sourceLogicalAddress, |
|
194 | 196 | transactionID, |
|
195 | 197 | address+(read*4), |
|
196 | 198 | RMAP_MAX_XFER_SIZE*4, |
|
197 | 199 | requestBuffer+1); |
|
198 | 200 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
199 | 201 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
200 | 202 | if(len==-1) |
|
201 | 203 | { |
|
202 | 204 | this->toggleBridgeConnection(); |
|
203 | 205 | return 0; |
|
204 | 206 | } |
|
205 | 207 | for(int i=0;i<((len-13)/4);i++) |
|
206 | 208 | { |
|
207 | 209 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
208 | 210 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
209 | 211 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
210 | 212 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
211 | 213 | } |
|
212 | 214 | free(RMAP_AnswerBuffer); |
|
213 | 215 | read+=RMAP_MAX_XFER_SIZE; |
|
214 | 216 | count-=RMAP_MAX_XFER_SIZE; |
|
215 | 217 | progress->setValue(read); |
|
216 | 218 | qApp->processEvents(); |
|
217 | 219 | } |
|
218 | 220 | if((int)count>0) |
|
219 | 221 | { |
|
220 | 222 | transactionID = manager->getRMAPtransactionID(); |
|
221 | 223 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); |
|
222 | 224 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); |
|
223 | 225 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); |
|
224 | 226 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); |
|
225 | 227 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); |
|
226 | 228 | RMAP_build_rx_request_header( |
|
227 | 229 | this->manager->destinationLogicalAddress, |
|
228 | 230 | this->manager->destinationKey, |
|
229 | 231 | this->manager->sourceLogicalAddress, |
|
230 | 232 | transactionID, |
|
231 | 233 | address+(read*4), |
|
232 | 234 | count*4, |
|
233 | 235 | requestBuffer+1); |
|
234 | 236 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
235 | 237 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
236 | 238 | if(len==-1) |
|
237 | 239 | { |
|
238 | 240 | this->toggleBridgeConnection(); |
|
239 | 241 | return 0; |
|
240 | 242 | } |
|
241 | 243 | for(int i=0;i<((len-13)/4);i++) |
|
242 | 244 | { |
|
243 | 245 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
244 | 246 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
245 | 247 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
246 | 248 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
247 | 249 | } |
|
248 | 250 | free(RMAP_AnswerBuffer); |
|
249 | 251 | read+=count; |
|
250 | 252 | if(progress!=NULL) |
|
251 | 253 | { |
|
252 | 254 | progress->setValue(read); |
|
253 | 255 | qApp->processEvents(); |
|
254 | 256 | } |
|
255 | 257 | } |
|
256 | 258 | return read; |
|
257 | 259 | } |
|
258 | 260 | |
|
259 | 261 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) |
|
260 | 262 | { |
|
261 | 263 | this->manager->selectedBrick = brickIndex-1; |
|
262 | 264 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); |
|
263 | 265 | } |
|
264 | 266 | |
|
265 | 267 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) |
|
266 | 268 | { |
|
267 | 269 | this->manager->linkNumber = linkIndex + 1; |
|
268 | 270 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); |
|
269 | 271 | } |
|
270 | 272 | |
|
271 | 273 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) |
|
272 | 274 | { |
|
273 | 275 | this->manager->linkSpeed = linkSpeed.toInt(); |
|
274 | 276 | |
|
275 | 277 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); |
|
276 | 278 | } |
|
277 | 279 | |
|
278 | 280 | void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress) |
|
279 | 281 | { |
|
280 | 282 | this->manager->sourceLogicalAddress = sourceAddress.toInt(); |
|
281 | 283 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1); |
|
282 | 284 | } |
|
283 | 285 | |
|
284 |
void stardundeeSPW_USB:: |
|
|
286 | void stardundeeSPW_USB::destinationAddressChanged(const QString &rmapaddress) | |
|
285 | 287 | { |
|
286 | 288 | this->manager->destinationLogicalAddress = rmapaddress.toInt(); |
|
287 | 289 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1); |
|
288 | 290 | } |
|
289 | 291 | |
|
290 | 292 | void stardundeeSPW_USB::destinationKeyChanged(const QString &key) |
|
291 | 293 | { |
|
292 | 294 | this->manager->destinationKey = key.toInt(); |
|
293 | 295 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1); |
|
294 | 296 | } |
|
295 | 297 | |
|
296 | 298 | void stardundeeSPW_USB::brickModeChanged( bool interfaceMode ) |
|
297 | 299 | { |
|
298 | 300 | this->manager->interfaceMode = interfaceMode; |
|
299 | 301 | } |
|
300 | 302 | |
|
303 | void stardundeeSPW_USB::timecodeFrequencyChanged(const QString &frequency) | |
|
304 | { | |
|
305 | this->manager->timecodeFrequency = frequency.toDouble(); | |
|
306 | this->manager->setTimecodeFrequency( this->manager->timecodeFrequency); | |
|
307 | SocExplorerEngine::message(plugin,QString("Changing timecode frequency: %1").arg(manager->timecodeFrequency),1); | |
|
308 | } | |
|
309 | ||
|
310 | void stardundeeSPW_USB::startSendingTimecodes(bool onOff ) | |
|
311 | { | |
|
312 | this->manager->sendTimecodePeriodically( onOff ); | |
|
313 | } | |
|
314 | ||
|
301 | 315 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) |
|
302 | 316 | { |
|
303 | 317 | int tim=timeout.toInt(); |
|
304 | 318 | if(tim<50) |
|
305 | 319 | { |
|
306 | 320 | tim = 50; |
|
307 | 321 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); |
|
308 | 322 | } |
|
309 | 323 | this->manager->RMAPtimeout = tim; |
|
310 | 324 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); |
|
311 | 325 | } |
|
312 | 326 | |
|
313 | 327 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) |
|
314 | 328 | { |
|
315 | 329 | this->p_GUI = new StarDundeeGUI(); |
|
316 | 330 | // this->mainLayout = new QGridLayout(this->p_GUI); |
|
317 | 331 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); |
|
318 | 332 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); |
|
319 | 333 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); |
|
320 | 334 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); |
|
321 | 335 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); |
|
322 | 336 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString))); |
|
323 |
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT( |
|
|
337 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(destinationAddressChanged(QString))); | |
|
324 | 338 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); |
|
325 | 339 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); |
|
326 | 340 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool))); |
|
341 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(timecodeFrequencyChange(QString)), this, SLOT(timecodeFrequencyChanged(QString))); | |
|
342 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(startSendingTimecode(bool)), this, SLOT(startSendingTimecodes(bool))); | |
|
327 | 343 | |
|
328 | this->brickSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); | |
|
329 | this->linkNumberSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); | |
|
330 | this->linkSpeedSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); | |
|
331 |
this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->get |
|
|
332 |
this-> |
|
|
333 |
this->destinationKeyChanged(((StarDundeeGUI*)this->p_GUI)->get |
|
|
334 | this->rmapTimeoutChanged(((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); | |
|
335 | this->brickModeChanged(((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface()); | |
|
344 | this->brickSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); | |
|
345 | this->linkNumberSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); | |
|
346 | this->linkSpeedSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); | |
|
347 | this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getSourceAddress()); | |
|
348 | this->destinationAddressChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationAddress()); | |
|
349 | this->destinationKeyChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); | |
|
350 | this->rmapTimeoutChanged( ((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); | |
|
351 | this->brickModeChanged( ((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface()); | |
|
336 | 352 | |
|
337 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); | |
|
338 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); | |
|
339 | connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); | |
|
340 | connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); | |
|
341 |
connect(this,SIGNAL(Set |
|
|
342 |
connect(this,SIGNAL(Set |
|
|
343 | connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); | |
|
344 | connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount())); | |
|
345 | connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool))); | |
|
346 | connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool))); | |
|
347 | connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint))); | |
|
348 | connect(this,SIGNAL(BytesTransmittedToSpw(uint)),((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint))); | |
|
353 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); | |
|
354 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); | |
|
355 | connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); | |
|
356 | connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); | |
|
357 | connect(this,SIGNAL(SetDestinationAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationAddress(QString))); | |
|
358 | connect(this,SIGNAL(SetSourceAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setSourceAddress(QString))); | |
|
359 | connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); | |
|
360 | connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount())); | |
|
361 | connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool))); | |
|
362 | connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool))); | |
|
363 | connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint))); | |
|
364 | connect(this,SIGNAL(BytesTransmittedToSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint))); | |
|
365 | connect(this,SIGNAL(SetTimecodeFrequency(double)), ((StarDundeeGUI*)this->p_GUI),SLOT(setTimecodeFrequency(QString))); | |
|
366 | connect(this,SIGNAL(StartSendingTimecodes(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setStartSendingTimecodes(bool))); | |
|
349 | 367 | } |
|
350 | 368 | |
|
351 | 369 | void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size) |
|
352 | 370 | { |
|
353 | 371 | char* data; |
|
354 | 372 | int i; |
|
355 | 373 | |
|
356 | 374 | data = (char *) malloc( size + 5 ); |
|
357 | 375 | |
|
358 | 376 | data[0] = this->manager->linkNumber; |
|
359 | 377 | data[1] = this->manager->destinationLogicalAddress; // target logical address |
|
360 | 378 | data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier |
|
361 | 379 | data[3] = 0x00; // reserved |
|
362 | 380 | data[4] = 0x00; // user application |
|
363 | 381 | |
|
364 | 382 | for ( i=0; i<size; i++ ) |
|
365 | 383 | { |
|
366 | 384 | data[i+5] = packet[i]; |
|
367 | 385 | } |
|
368 | 386 | |
|
369 | 387 | this->manager->sendPacket( data, size + 5); |
|
370 | 388 | |
|
371 | 389 | free(data); |
|
372 | 390 | free(packet); |
|
373 | 391 | } |
|
374 | 392 | |
|
375 | 393 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) |
|
376 | 394 | :QThread((QObject*)parent) |
|
377 | 395 | { |
|
378 | 396 | this->RMAPtimeout = 2000; |
|
379 | 397 | this->handleMutex = new QMutex(QMutex::NonRecursive); |
|
380 | 398 | this->RMAP_AnswersSem = new QSemaphore(0); |
|
381 | 399 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); |
|
382 | 400 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); |
|
383 | 401 | this->plugin = plugin; |
|
384 | 402 | connected = false; |
|
385 | 403 | this->moveToThread(this); |
|
386 | 404 | } |
|
387 | 405 | |
|
388 | 406 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() |
|
389 | 407 | { |
|
390 | 408 | this->terminate(); |
|
391 | 409 | while (!this->isFinished()) { |
|
392 | 410 | this->usleep(1000); |
|
393 | 411 | } |
|
394 | 412 | } |
|
395 | 413 | |
|
396 | 414 | void stardundeeSPW_USB_Manager::run() |
|
397 | 415 | { |
|
398 | 416 | USB_SPACEWIRE_PACKET_PROPERTIES properties; |
|
399 | 417 | USB_SPACEWIRE_ID pIdentifier=NULL; |
|
400 | 418 | USB_SPACEWIRE_STATUS stat; |
|
401 | 419 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); |
|
402 | 420 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; |
|
403 | 421 | while (!this->isInterruptionRequested()) |
|
404 | 422 | { |
|
405 | 423 | if(this->connected) |
|
406 | 424 | { |
|
407 | 425 | handleMutex->lock(); |
|
408 | 426 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); |
|
409 | 427 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) |
|
410 | 428 | { |
|
411 | 429 | SocExplorerEngine::message(this->plugin,"Got packet",2); |
|
412 | 430 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); |
|
413 | 431 | if (stat == TRANSFER_SUCCESS) |
|
414 | 432 | { |
|
415 | 433 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) |
|
416 | 434 | { |
|
417 | 435 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); |
|
418 | 436 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) |
|
419 | 437 | { |
|
420 | 438 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); |
|
421 | 439 | emit bytesReceivedFromSpw( properties.len ); |
|
422 | 440 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet |
|
423 | 441 | { |
|
424 | 442 | RMAP_Answer* packet; |
|
425 | 443 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); |
|
426 | 444 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); |
|
427 | 445 | char* packetbuffer = (char*)malloc(properties.len); |
|
428 | 446 | memcpy(packetbuffer,buffer,properties.len); |
|
429 | 447 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
430 | 448 | pIdentifier = NULL; |
|
431 | 449 | handleMutex->unlock(); |
|
432 | 450 | if(properties.len==8) |
|
433 | 451 | { |
|
434 | 452 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); |
|
435 | 453 | } |
|
436 | 454 | else |
|
437 | 455 | { |
|
438 | 456 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); |
|
439 | 457 | } |
|
440 | 458 | RMAP_AnswersMtx->lock(); |
|
441 | 459 | RMAP_Answers.append(packet); |
|
442 | 460 | RMAP_AnswersMtx->unlock(); |
|
443 | 461 | RMAP_AnswersSem->release(); |
|
444 | 462 | } |
|
445 | 463 | else //any non-rmap packet will be pushed to the network |
|
446 | 464 | { |
|
447 | 465 | char* packetbuffer = (char*)malloc(properties.len); |
|
448 | 466 | memcpy(packetbuffer,buffer,properties.len); |
|
449 | 467 | emit emitPacket(packetbuffer,properties.len); |
|
450 | 468 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
451 | 469 | handleMutex->unlock(); |
|
452 | 470 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); |
|
453 | 471 | } |
|
454 | 472 | } |
|
455 | 473 | else |
|
456 | 474 | { |
|
457 | 475 | SocExplorerEngine::message(this->plugin,"No EOP received",2); |
|
458 | 476 | } |
|
459 | 477 | } |
|
460 | 478 | |
|
461 | 479 | } |
|
462 | 480 | else |
|
463 | 481 | { |
|
464 | 482 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
465 | 483 | handleMutex->unlock(); |
|
466 | 484 | } |
|
467 | 485 | } |
|
468 | 486 | else |
|
469 | 487 | { |
|
470 | 488 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
471 | 489 | handleMutex->unlock(); |
|
472 | 490 | } |
|
473 | 491 | } |
|
474 | 492 | else |
|
475 | 493 | { |
|
476 | 494 | //do some sanity checks! |
|
477 | 495 | int list = USBSpaceWire_ListDevices(); |
|
478 | 496 | if(this->brickList!=list) |
|
479 | 497 | { |
|
480 | 498 | this->brickList = list; |
|
481 | 499 | emit updateAvailableBrickCount(this->brickList); |
|
482 | 500 | } |
|
483 | 501 | usleep(RMAPtimeout/2); |
|
484 | 502 | } |
|
485 | 503 | usleep(1000); |
|
486 | 504 | } |
|
487 | 505 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); |
|
488 | 506 | } |
|
489 | 507 | |
|
490 | 508 | bool stardundeeSPW_USB_Manager::connectBridge() |
|
491 | 509 | { |
|
492 | 510 | bool ret; |
|
493 | 511 | |
|
494 | 512 | if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE) |
|
495 | 513 | { |
|
496 | 514 | ret = connectBridgeAsInterface(); |
|
497 | 515 | } |
|
498 | 516 | else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER) |
|
499 | 517 | { |
|
500 | 518 | ret = connectBridgeAsRouter(); |
|
501 | 519 | } |
|
502 | 520 | else |
|
503 | 521 | { |
|
504 | 522 | ret = false; |
|
505 | 523 | } |
|
506 | 524 | |
|
507 | 525 | return ret; |
|
508 | 526 | } |
|
509 | 527 | |
|
510 | 528 | bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() |
|
511 | 529 | { |
|
512 | 530 | QMutexLocker mlock(this->handleMutex); |
|
513 | 531 | int status; |
|
514 | 532 | U32 statusControl; |
|
515 | 533 | this->connected = false; |
|
516 | 534 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
517 | 535 | { |
|
518 | 536 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); |
|
519 | 537 | return false; |
|
520 | 538 | } |
|
521 | 539 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); |
|
522 | 540 | |
|
523 | 541 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
524 | 542 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
525 | 543 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
526 | 544 | |
|
527 | 545 | // Set the path and return path to the device |
|
528 | 546 | CFGSpaceWire_StackClear(); |
|
529 | 547 | CFGSpaceWire_AddrStackPush(0); |
|
530 | 548 | CFGSpaceWire_AddrStackPush(254); |
|
531 | 549 | CFGSpaceWire_RetAddrStackPush(254); |
|
532 | 550 | // set the base transmit rate to 100 MHz |
|
533 | 551 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
534 | 552 | if (status != CFG_TRANSFER_SUCCESS) |
|
535 | 553 | { |
|
536 | 554 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); |
|
537 | 555 | return false; |
|
538 | 556 | } |
|
539 | 557 | else |
|
540 | 558 | { |
|
541 | 559 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); |
|
542 | 560 | } |
|
543 | 561 | |
|
544 | 562 | // read the link status |
|
545 | 563 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
546 | 564 | { |
|
547 | 565 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); |
|
548 | 566 | return false; |
|
549 | 567 | } |
|
550 | 568 | else |
|
551 | 569 | { |
|
552 | 570 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); |
|
553 | 571 | |
|
554 | 572 | // Set the link status control register properties |
|
555 | 573 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
556 | 574 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
557 | 575 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
558 | 576 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
559 | 577 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
560 | 578 | |
|
561 | 579 | // Set the link status control register |
|
562 | 580 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
563 | 581 | { |
|
564 | 582 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); |
|
565 | 583 | return false; |
|
566 | 584 | } |
|
567 | 585 | else |
|
568 | 586 | { |
|
569 | 587 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); |
|
570 | 588 | } |
|
571 | 589 | } |
|
572 | 590 | |
|
573 | 591 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) |
|
574 | 592 | { |
|
575 | 593 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); |
|
576 | 594 | return false; |
|
577 | 595 | } |
|
578 | 596 | else |
|
579 | 597 | { |
|
580 | 598 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); |
|
581 | 599 | } |
|
582 | 600 | |
|
583 | 601 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports |
|
584 | 602 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
585 | 603 | USBSpaceWire_SetTimeout(hDevice,1.0); |
|
586 | 604 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); |
|
587 | 605 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); |
|
588 | 606 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); |
|
589 | 607 | this->connected = true; |
|
590 | 608 | return true; |
|
591 | 609 | } |
|
592 | 610 | |
|
593 | 611 | bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() |
|
594 | 612 | { |
|
595 | 613 | QMutexLocker mlock(this->handleMutex); |
|
596 | 614 | int status; |
|
597 | 615 | U32 statusControl; |
|
598 | 616 | unsigned int linkStatus1; |
|
599 | 617 | unsigned int linkStatus2; |
|
600 | 618 | unsigned char linkNumber; |
|
601 | 619 | unsigned char deviceIsAnInterface; |
|
602 | 620 | |
|
603 | 621 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
604 | 622 | { |
|
605 | 623 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); |
|
606 | 624 | return false; |
|
607 | 625 | } |
|
608 | 626 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " |
|
609 | 627 | + QString::number(this->selectedBrick)); |
|
610 | 628 | |
|
611 | 629 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
612 | 630 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
613 | 631 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
614 | 632 | |
|
615 | 633 | // Set the path and return path to the device |
|
616 | 634 | // This affects just the operations performed by the Configuration Library and does not affect the packets |
|
617 | 635 | // sent and received using the driver API. |
|
618 | 636 | CFGSpaceWire_StackClear(); |
|
619 | 637 | CFGSpaceWire_AddrStackPush(0); |
|
620 | 638 | CFGSpaceWire_AddrStackPush(254); |
|
621 | 639 | CFGSpaceWire_RetAddrStackPush(254); |
|
622 | 640 | |
|
623 | 641 | // set the base transmit rate to 100 MHz |
|
624 | 642 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
625 | 643 | if (status != CFG_TRANSFER_SUCCESS) |
|
626 | 644 | { |
|
627 | 645 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); |
|
628 | 646 | } |
|
629 | 647 | else SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); |
|
630 | 648 | |
|
631 | 649 | //********************* |
|
632 | 650 | // LINK 1 CONFIGURATION |
|
633 | 651 | linkNumber = 1; |
|
634 | 652 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
635 | 653 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); |
|
636 | 654 | else |
|
637 | 655 | { |
|
638 | 656 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
639 | 657 | |
|
640 | 658 | // Set the link status control register properties |
|
641 | 659 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
642 | 660 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
643 | 661 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
644 | 662 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
645 | 663 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
646 | 664 | |
|
647 | 665 | // Set the link status control register |
|
648 | 666 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
649 | 667 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); |
|
650 | 668 | else |
|
651 | 669 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(0x01) + " is set"); |
|
652 | 670 | } |
|
653 | 671 | |
|
654 | 672 | //********************* |
|
655 | 673 | // LINK 2 CONFIGURATION |
|
656 | 674 | linkNumber = 2; |
|
657 | 675 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
658 | 676 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); |
|
659 | 677 | else |
|
660 | 678 | { |
|
661 | 679 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
662 | 680 | |
|
663 | 681 | // Set the link status control register properties |
|
664 | 682 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
665 | 683 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
666 | 684 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
667 | 685 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
668 | 686 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
669 | 687 | |
|
670 | 688 | // Set the link status control register |
|
671 | 689 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
672 | 690 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); |
|
673 | 691 | else |
|
674 | 692 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(linkNumber) + " is set"); |
|
675 | 693 | } |
|
676 | 694 | |
|
677 | 695 | //*************************** |
|
678 | 696 | // SET THE DEVICE AS A ROUTER |
|
679 | 697 | deviceIsAnInterface = 0; // 0 = router, 1 = interface |
|
680 | 698 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) |
|
681 | 699 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); |
|
682 | 700 | else |
|
683 | 701 | SocExplorerEngine::message(this->plugin,"Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); |
|
684 | 702 | |
|
685 | 703 | setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1 |
|
686 | 704 | setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3 |
|
687 | 705 | |
|
688 | 706 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only |
|
689 | 707 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
690 | 708 | |
|
691 | 709 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); |
|
692 | 710 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); |
|
693 | 711 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); |
|
694 | 712 | |
|
695 | 713 | //************ |
|
696 | 714 | // test Link 1 and Link 2 |
|
697 | 715 | linkStatus1 = getLinkStatus(0x01); |
|
698 | 716 | linkStatus2 = getLinkStatus(0x02); |
|
699 | 717 | |
|
700 | 718 | if ((linkStatus1==1) || (linkStatus2==1)) |
|
701 | 719 | { |
|
702 | 720 | initializeTimecodeGeneration(); |
|
703 | 721 | this->connected=true; |
|
704 | 722 | return true; |
|
705 | 723 | } |
|
706 | 724 | else |
|
707 | 725 | { |
|
708 | 726 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); |
|
709 | 727 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); |
|
710 | 728 | starDundeeStatusQueryDialog->exec(); |
|
711 | 729 | this->connected = false; |
|
712 | 730 | return false; |
|
713 | 731 | } |
|
714 | 732 | } |
|
715 | 733 | |
|
716 | 734 | void stardundeeSPW_USB_Manager::initDialog( void ) |
|
717 | 735 | { |
|
718 | 736 | // STAR DUNDEE STATUS QUERY DIALOG |
|
719 | 737 | starDundeeStatusQueryDialog = new QDialog; |
|
720 | 738 | starDundeeStatusQueryDialogLayout = new QGridLayout; |
|
721 | 739 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); |
|
722 | 740 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); |
|
723 | 741 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); |
|
724 | 742 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); |
|
725 | 743 | statusLink1 = new QLabel(tr("Link 1 status code: -")); |
|
726 | 744 | statusLink2 = new QLabel(tr("Link 2 status code: -")); |
|
727 | 745 | |
|
728 | 746 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); |
|
729 | 747 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); |
|
730 | 748 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); |
|
731 | 749 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); |
|
732 | 750 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); |
|
733 | 751 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); |
|
734 | 752 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); |
|
735 | 753 | } |
|
736 | 754 | |
|
737 | 755 | unsigned char stardundeeSPW_USB_Manager::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead) |
|
738 | 756 | { |
|
739 | 757 | U32 routingTableEntry; |
|
740 | 758 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber |
|
741 | 759 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) |
|
742 | 760 | { |
|
743 | 761 | SocExplorerEngine::message(this->plugin,"Could not clear routing table entry " + QString::number(tableEntry)); |
|
744 | 762 | } |
|
745 | 763 | // Build the routing table entry |
|
746 | 764 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, |
|
747 | 765 | dwOutputPorts, // route out of port dwOutputPorts |
|
748 | 766 | bDelHead, // header deletion is enabled [1] or disabled [0] |
|
749 | 767 | 0); // priority normal |
|
750 | 768 | // Set the routing table entry for logical address tableEntry |
|
751 | 769 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
752 | 770 | { |
|
753 | 771 | SocExplorerEngine::message(this->plugin,"Could not set routing table entry [" + QString::number(tableEntry) + "]"); |
|
754 | 772 | } |
|
755 | 773 | else SocExplorerEngine::message(this->plugin,"Routing table entry [" + QString::number(tableEntry) + "] set" ); |
|
756 | 774 | return 1; |
|
757 | 775 | } |
|
758 | 776 | |
|
759 | 777 | unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry) |
|
760 | 778 | { |
|
761 | 779 | U32 routingTableEntry, outputPorts; |
|
762 | 780 | char enabled, delHead, priority; |
|
763 | 781 | int portNum; |
|
764 | 782 | |
|
765 | 783 | SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); |
|
766 | 784 | // Read the routing table entry |
|
767 | 785 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
768 | 786 | { |
|
769 | 787 | SocExplorerEngine::message(this->plugin,"Could not read routing table entry [" + QString::number(tableEntry) + "]"); |
|
770 | 788 | } |
|
771 | 789 | else |
|
772 | 790 | { |
|
773 | 791 | // Display the routing table entry properties |
|
774 | 792 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); |
|
775 | 793 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); |
|
776 | 794 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); |
|
777 | 795 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); |
|
778 | 796 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); |
|
779 | 797 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); |
|
780 | 798 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority)); |
|
781 | 799 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : "); |
|
782 | 800 | for (portNum = 0; portNum < 32; portNum++) |
|
783 | 801 | { |
|
784 | 802 | if (outputPorts & (1 << portNum)) |
|
785 | 803 | { |
|
786 | 804 | SocExplorerEngine::message(this->plugin,QString::number(portNum)); |
|
787 | 805 | } |
|
788 | 806 | } |
|
789 | 807 | } |
|
790 | 808 | |
|
791 | 809 | return 1; |
|
792 | 810 | } |
|
793 | 811 | |
|
794 | 812 | void stardundeeSPW_USB_Manager::initializeTimecodeGeneration() |
|
795 | 813 | { |
|
796 | 814 | U32 dwTickEnableStatus; |
|
797 | 815 | U32 rtr_clk_freq; |
|
798 | 816 | |
|
799 | 817 | // (1) RESET |
|
800 | 818 | if (!USBSpaceWire_TC_Reset(hDevice)) |
|
801 | 819 | SocExplorerEngine::message(this->plugin,"ERR *** in Open *** Could not reset timecodes\n"); |
|
802 | 820 | |
|
803 | 821 | // (2) Clear the tick enable register |
|
804 | 822 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) |
|
805 | 823 | SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register"); |
|
806 | 824 | else |
|
807 | 825 | SocExplorerEngine::message(this->plugin,"Cleared the tick enable register"); |
|
808 | 826 | |
|
809 | 827 | // (3) get the tick status |
|
810 | 828 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); |
|
811 | 829 | SocExplorerEngine::message(this->plugin,"OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); |
|
812 | 830 | |
|
813 | 831 | // (4) enable external timecode selection |
|
814 | 832 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) |
|
815 | 833 | SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection"); |
|
816 | 834 | |
|
817 | 835 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); |
|
818 | 836 | |
|
819 | 837 | SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) ); |
|
820 | 838 | |
|
821 | 839 | //************************************************** |
|
822 | 840 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount |
|
823 | 841 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) |
|
824 | 842 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); |
|
825 | 843 | } |
|
826 | 844 | |
|
827 | 845 | unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link) |
|
828 | 846 | { |
|
829 | 847 | U32 statusControl, errorStatus, portType; |
|
830 | 848 | U32 linkStatus, operatingSpeed, outputPortConnection; |
|
831 | 849 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; |
|
832 | 850 | |
|
833 | 851 | // Read the link status control register |
|
834 | 852 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
835 | 853 | { |
|
836 | 854 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link" + QString::number(link)); |
|
837 | 855 | } |
|
838 | 856 | else |
|
839 | 857 | { |
|
840 | 858 | // Display the link status control register properties |
|
841 | 859 | CFGSpaceWire_LSPortType(statusControl, &portType); |
|
842 | 860 | if (portType == CFG_CONFIGURATION_PORT) |
|
843 | 861 | { |
|
844 | 862 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); |
|
845 | 863 | } |
|
846 | 864 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) |
|
847 | 865 | { |
|
848 | 866 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); |
|
849 | 867 | } |
|
850 | 868 | else |
|
851 | 869 | { |
|
852 | 870 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); |
|
853 | 871 | } |
|
854 | 872 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); |
|
855 | 873 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); |
|
856 | 874 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); |
|
857 | 875 | CFGSpaceWire_LSIsStart(statusControl, &isStart); |
|
858 | 876 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); |
|
859 | 877 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); |
|
860 | 878 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); |
|
861 | 879 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); |
|
862 | 880 | } |
|
863 | 881 | SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link) |
|
864 | 882 | +" is " + dwLinkStatusQString[linkStatus]); |
|
865 | 883 | if (linkStatus == 5) |
|
866 | 884 | { |
|
867 | 885 | return 1; |
|
868 | 886 | } |
|
869 | 887 | else return 0; |
|
870 | 888 | } |
|
871 | 889 | |
|
872 | 890 | bool stardundeeSPW_USB_Manager::disconnectBridge() |
|
873 | 891 | { |
|
874 | 892 | this->handleMutex->lock(); |
|
875 | 893 | USBSpaceWire_Close(hDevice); // Close the device |
|
876 | 894 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); |
|
877 | 895 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports |
|
878 | 896 | this->handleMutex->unlock(); |
|
879 | 897 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
880 | 898 | this->RMAP_pending_transaction_IDs.clear(); |
|
881 | 899 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
882 | 900 | this->RMAP_AnswersMtx->lock(); |
|
883 | 901 | this->RMAP_Answers.clear(); |
|
884 | 902 | this->RMAP_AnswersMtx->unlock(); |
|
885 | 903 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); |
|
886 | 904 | return true; |
|
887 | 905 | } |
|
888 | 906 | |
|
889 | 907 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() |
|
890 | 908 | { |
|
891 | 909 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
892 | 910 | int ID=0; |
|
893 | 911 | bool found=true; |
|
894 | 912 | while(ID<511) |
|
895 | 913 | { |
|
896 | 914 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) |
|
897 | 915 | { |
|
898 | 916 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; |
|
899 | 917 | } |
|
900 | 918 | if(found==true)break; |
|
901 | 919 | ID++; |
|
902 | 920 | found = true; |
|
903 | 921 | } |
|
904 | 922 | if(found) |
|
905 | 923 | { |
|
906 | 924 | RMAP_pending_transaction_IDs.append(ID); |
|
907 | 925 | } |
|
908 | 926 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
909 | 927 | return ID; |
|
910 | 928 | } |
|
911 | 929 | |
|
912 | 930 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) |
|
913 | 931 | { |
|
914 | 932 | QTime timeout; |
|
915 | 933 | *buffer=NULL; |
|
916 | 934 | int count=0; |
|
917 | 935 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); |
|
918 | 936 | timeout.start(); |
|
919 | 937 | while (*buffer==NULL) |
|
920 | 938 | { |
|
921 | 939 | this->RMAP_AnswersMtx->lock(); |
|
922 | 940 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); |
|
923 | 941 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); |
|
924 | 942 | for(int i=0;i<RMAP_Answers.count();i++) |
|
925 | 943 | { |
|
926 | 944 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); |
|
927 | 945 | if(RMAP_Answers[i]->transactionID==transactionID) |
|
928 | 946 | { |
|
929 | 947 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
930 | 948 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); |
|
931 | 949 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) |
|
932 | 950 | { |
|
933 | 951 | if(RMAP_pending_transaction_IDs[j]==transactionID) |
|
934 | 952 | { |
|
935 | 953 | RMAP_pending_transaction_IDs.removeAt(j); |
|
936 | 954 | } |
|
937 | 955 | } |
|
938 | 956 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
939 | 957 | *buffer = RMAP_Answers[i]->data; |
|
940 | 958 | count = RMAP_Answers[i]->len; |
|
941 | 959 | RMAP_Answer* tmp=RMAP_Answers[i]; |
|
942 | 960 | RMAP_Answers.removeAt(i); |
|
943 | 961 | delete tmp; |
|
944 | 962 | } |
|
945 | 963 | } |
|
946 | 964 | this->RMAP_AnswersMtx->unlock(); |
|
947 | 965 | //if no answer found in the stack wait until a new packet is pushed |
|
948 | 966 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); |
|
949 | 967 | if(*buffer==NULL) |
|
950 | 968 | { |
|
951 | 969 | while (0==this->RMAP_AnswersSem->available()) |
|
952 | 970 | { |
|
953 | 971 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); |
|
954 | 972 | if(timeout.elapsed()>=RMAPtimeout) |
|
955 | 973 | { |
|
956 | 974 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); |
|
957 | 975 | return -1; |
|
958 | 976 | } |
|
959 | 977 | usleep(1000); |
|
960 | 978 | } |
|
961 | 979 | this->RMAP_AnswersSem->acquire(); |
|
962 | 980 | } |
|
963 | 981 | } |
|
964 | 982 | return count; |
|
965 | 983 | } |
|
966 | 984 | |
|
967 | 985 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) |
|
968 | 986 | { |
|
969 | 987 | USB_SPACEWIRE_STATUS result; |
|
970 | 988 | USB_SPACEWIRE_ID pIdentifier; |
|
971 | 989 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); |
|
972 | 990 | this->handleMutex->lock(); |
|
973 | 991 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); |
|
974 | 992 | if (result != TRANSFER_SUCCESS) |
|
975 | 993 | { |
|
976 | 994 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); |
|
977 | 995 | this->handleMutex->unlock(); |
|
978 | 996 | return false; |
|
979 | 997 | } |
|
980 | 998 | else |
|
981 | 999 | { |
|
982 | 1000 | emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link |
|
983 | 1001 | SocExplorerEngine::message(this->plugin,"Packet sent",2); |
|
984 | 1002 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
985 | 1003 | } |
|
986 | 1004 | this->handleMutex->unlock(); |
|
987 | 1005 | return true; |
|
988 | 1006 | } |
|
989 | 1007 | |
|
990 | 1008 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) |
|
991 | 1009 | { |
|
992 | 1010 | char* packetbuffer = (char*)malloc(len); |
|
993 | 1011 | memcpy(packetbuffer,packet,len); |
|
994 | 1012 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); |
|
995 | 1013 | RMAP_AnswersMtx->lock(); |
|
996 | 1014 | RMAP_Answers.append(RMPAPpacket); |
|
997 | 1015 | RMAP_AnswersMtx->unlock(); |
|
998 | 1016 | } |
|
999 | 1017 | |
|
1000 | ||
|
1001 | ||
|
1002 | ||
|
1018 | void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff ) | |
|
1019 | { | |
|
1020 | if (onOff == true) | |
|
1021 | { | |
|
1022 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) | |
|
1023 | SocExplorerEngine::message(this->plugin,"Could not enable auto tick-in"); | |
|
1024 | } | |
|
1025 | else | |
|
1026 | { | |
|
1027 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) | |
|
1028 | SocExplorerEngine::message(this->plugin,"Could not disable auto tick-in"); | |
|
1029 | } | |
|
1030 | } | |
|
1003 | 1031 | |
|
1004 | ||
|
1032 | void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency) | |
|
1033 | { | |
|
1034 | U32 rtr_clk_freq; | |
|
1035 | U32 freqCount; | |
|
1036 | double freqCountInDouble; | |
|
1037 | double currentFrequency; | |
|
1005 | 1038 | |
|
1039 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); | |
|
1040 | freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency; | |
|
1041 | freqCount = (unsigned int) freqCountInDouble; | |
|
1006 | 1042 | |
|
1043 | currentFrequency = ((double) rtr_clk_freq) / ((double) freqCount); | |
|
1044 | ||
|
1045 | //************************************************** | |
|
1046 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount | |
|
1047 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, freqCount) ) | |
|
1048 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); | |
|
1049 | else | |
|
1050 | SocExplorerEngine::message(this->plugin,"tick frequency set to " + QString::number(currentFrequency) +" Hz"); | |
|
1051 | } | |
|
1007 | 1052 | |
|
1008 | 1053 | |
|
1009 | 1054 | |
|
1010 | 1055 | |
|
1011 | ||
|
1012 | ||
|
1013 | ||
|
1014 | ||
|
1015 | ||
|
1016 | ||
|
1017 | ||
|
1018 | ||
|
1019 | ||
|
1020 |
@@ -1,144 +1,153 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - 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@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef STARDUNDEESPW_USB_H |
|
23 | 23 | #define STARDUNDEESPW_USB_H |
|
24 | 24 | |
|
25 | 25 | #include <QObject> |
|
26 | 26 | #include <spw_usb_api.h> |
|
27 | 27 | #include <spw_config_library.h> |
|
28 | 28 | #include <socexplorerplugin.h> |
|
29 | 29 | #include <abstractspwbridge.h> |
|
30 | 30 | #include <QThread> |
|
31 | 31 | #include <QMutex> |
|
32 | 32 | #include <QSemaphore> |
|
33 | 33 | #include <QGridLayout> |
|
34 | 34 | #include <QPushButton> |
|
35 | 35 | #include <QComboBox> |
|
36 | 36 | #include <QLabel> |
|
37 | 37 | #include "stardundeegui.h" |
|
38 | 38 | |
|
39 | 39 | #define BRICK_IS_SET_AS_AN_INTERFACE true |
|
40 | 40 | #define BRICK_IS_SET_AS_A_ROUTER false |
|
41 | 41 | |
|
42 | 42 | class stardundeeSPW_USB_Manager: public QThread |
|
43 | 43 | { |
|
44 | 44 | Q_OBJECT |
|
45 | 45 | public: |
|
46 | 46 | explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); |
|
47 | 47 | ~stardundeeSPW_USB_Manager(); |
|
48 | 48 | void run(); |
|
49 | 49 | bool connectBridge(); |
|
50 | 50 | bool connectBridgeAsInterface(); |
|
51 | 51 | bool connectBridgeAsRouter(); |
|
52 | 52 | void initDialog( void ); |
|
53 | 53 | unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead); |
|
54 | 54 | unsigned int getRoutingTableEntry(int tableEntry); |
|
55 | 55 | void initializeTimecodeGeneration(); |
|
56 | void setTimecodeFrequency(double requestedFrequency); | |
|
56 | 57 | unsigned int getLinkStatus(unsigned char link); |
|
57 | 58 | bool disconnectBridge(); |
|
58 | 59 | int getRMAPtransactionID(); |
|
59 | 60 | int getRMAPanswer(int transactionID,char** buffer); |
|
60 | 61 | bool sendPacket(char* packet,int size); |
|
61 | 62 | |
|
62 | 63 | signals: |
|
63 | 64 | void updateAvailableBrickCount(int count); |
|
64 | 65 | void emitPacket(char* packet,int size); |
|
65 | 66 | void bytesReceivedFromSpw( unsigned int ); |
|
66 | 67 | void bytesTransmittedToSpw( unsigned int); |
|
67 | 68 | |
|
69 | public slots: | |
|
70 | void sendTimecodePeriodically( bool onOff ); | |
|
71 | ||
|
68 | 72 | private: |
|
69 | 73 | QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; |
|
70 | 74 | QSemaphore* RMAP_AnswersSem; |
|
71 | 75 | void pushRmapPacket(char* packet,int len); |
|
72 | 76 | star_device_handle hDevice; |
|
73 | 77 | socexplorerplugin* plugin; |
|
74 | 78 | bool connected; |
|
75 | 79 | char* SPWPacketBuff; |
|
76 | 80 | QList<RMAP_Answer*> RMAP_Answers; |
|
77 | 81 | QList<int> RMAP_pending_transaction_IDs; |
|
78 | 82 | |
|
79 | 83 | QLabel *starDundeeStatusQueryDialogLabel; |
|
80 | 84 | QPushButton *starDundeeStatusQueryRetryButton; |
|
81 | 85 | QPushButton *starDundeeStatusQueryAbortButton; |
|
82 | 86 | QLabel *statusLink1; |
|
83 | 87 | QLabel *statusLink2; |
|
84 | 88 | QPushButton *starDundeeStatusQueryContinueButton; |
|
85 | 89 | QDialog *starDundeeStatusQueryDialog; |
|
86 | 90 | QGridLayout *starDundeeStatusQueryDialogLayout; |
|
87 | 91 | |
|
88 | 92 | public: |
|
89 | 93 | int selectedBrick; |
|
90 | 94 | int linkNumber; |
|
91 | 95 | int brickList; |
|
92 | 96 | int linkSpeed; |
|
93 | 97 | int sourceLogicalAddress; |
|
94 | 98 | int destinationLogicalAddress; |
|
95 | 99 | int destinationKey; |
|
96 | 100 | int RMAPtimeout; |
|
101 | double timecodeFrequency; | |
|
97 | 102 | bool interfaceMode; // 1 => interface mode, 0 => router mode |
|
98 | 103 | }; |
|
99 | 104 | |
|
100 | 105 | class stardundeeSPW_USB : public abstractSpwBridge |
|
101 | 106 | { |
|
102 | 107 | Q_OBJECT |
|
103 | 108 | public: |
|
104 | 109 | explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); |
|
105 | 110 | ~stardundeeSPW_USB(); |
|
106 | 111 | |
|
107 | 112 | signals: |
|
108 | 113 | |
|
109 | 114 | void setRmapTimeout(const QString & timeout); |
|
110 | 115 | void SelectBrick(int brickIndex); |
|
111 | 116 | void SelectLinkNumber(int linkIndex); |
|
112 | 117 | void SelectLinkSpeed(int linkSpeed); |
|
113 | 118 | void SetDestinationKey(const QString & destKey); |
|
114 |
void Set |
|
|
115 |
void Set |
|
|
119 | void SetSourceAddress(const QString & address); | |
|
120 | void SetDestinationAddress(const QString & address); | |
|
116 | 121 | void SetRmapTimeout(const QString & timeout); |
|
122 | void SetTimecodeFrequency( double ); | |
|
117 | 123 | void SetBrickAsAnInterface( bool ); |
|
118 | 124 | void SetBrickAsARouter( bool ); |
|
119 | 125 | int GetAvailableBrickCount( void ); |
|
120 | 126 | void BytesReceivedFromSpw( unsigned int ); |
|
121 | 127 | void BytesTransmittedToSpw( unsigned int ); |
|
128 | void StartSendingTimecodes( bool ); | |
|
122 | 129 | |
|
123 | 130 | public slots: |
|
124 | 131 | void toggleBridgeConnection(); |
|
125 | 132 | bool connectBridge(); |
|
126 | 133 | bool disconnectBridge(); |
|
127 | 134 | int pushRMAPPacket(char* packet,int size); |
|
128 | 135 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
129 | 136 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
130 | 137 | void brickSelectionChanged(int brickIndex); |
|
131 | 138 | void linkNumberSelectionChanged(int linkIndex); |
|
132 | 139 | void linkSpeedSelectionChanged(const QString & linkSpeed); |
|
133 | 140 | void sourceLogicalAddressChanged(const QString & destKey); |
|
134 |
void |
|
|
141 | void destinationAddressChanged(const QString & rmapaddress); | |
|
135 | 142 | void brickModeChanged( bool interfaceMode ); |
|
136 | 143 | void destinationKeyChanged(const QString & key); |
|
137 | 144 | void rmapTimeoutChanged(const QString & timeout); |
|
138 | 145 | void sendPacketComingFromTCPServer(char *packet, int size); |
|
146 | void timecodeFrequencyChanged(const QString &frequency); | |
|
147 | void startSendingTimecodes( bool onOff ); | |
|
139 | 148 | private: |
|
140 | 149 | void makeGUI(socexplorerplugin *parent); |
|
141 | 150 | stardundeeSPW_USB_Manager* manager; |
|
142 | 151 | }; |
|
143 | 152 | |
|
144 | 153 | #endif // STARDUNDEESPW_USB_H |
@@ -1,170 +1,174 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - 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@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | |
|
23 | 23 | #include "spwplugin.h" |
|
24 | 24 | #include "stardundeespw_usb.h" |
|
25 | 25 | #include "gr_esb_bridge.h" |
|
26 | 26 | #include <socexplorerproxy.h> |
|
27 | 27 | #include "spwpywrapper.h" |
|
28 | 28 | |
|
29 | 29 | |
|
30 | 30 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) |
|
31 | 31 | { |
|
32 | 32 | Q_UNUSED(parent) |
|
33 | 33 | this->bridge = NULL; |
|
34 | 34 | this->scanDone = false; |
|
35 | 35 | this->pyObject = new spwPyWrapper(this); |
|
36 | 36 | this->tcpServer = new SpwTcpPacketServer(this); |
|
37 | 37 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); |
|
38 | 38 | this->bridgeSelector = new QComboBox(this); |
|
39 | 39 | this->mainTabWidgt = new QTabWidget(this); |
|
40 | 40 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); |
|
41 | 41 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); |
|
42 | 42 | this->mainLayout = new QGridLayout(this->mainGroupBox); |
|
43 | 43 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); |
|
44 | 44 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); |
|
45 | 45 | this->setWidget(this->mainTabWidgt); |
|
46 | 46 | this->bridgeSelector->addItem("none"); |
|
47 | 47 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); |
|
48 | 48 | this->bridgeSelector->addItem("GR-ESB"); |
|
49 | 49 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); |
|
50 | 50 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); |
|
51 | 51 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); |
|
52 | 52 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); |
|
53 | 53 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32))); |
|
54 | 54 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString))); |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | |
|
58 | 58 | spwplugin::~spwplugin() |
|
59 | 59 | { |
|
60 | 60 | |
|
61 | 61 | } |
|
62 | 62 | |
|
63 | 63 | |
|
64 | 64 | |
|
65 | 65 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
66 | 66 | { |
|
67 | 67 | if(Connected) |
|
68 | 68 | { |
|
69 | 69 | return bridge->Read(Value,count,address); |
|
70 | 70 | } |
|
71 | 71 | return 0; |
|
72 | 72 | } |
|
73 | 73 | |
|
74 | 74 | void spwplugin::bridgeSelectionChanged(const QString &text) |
|
75 | 75 | { |
|
76 | 76 | printf("test"); |
|
77 | 77 | if(text=="none") |
|
78 | 78 | { |
|
79 | 79 | if(this->bridge!=NULL) |
|
80 | 80 | { |
|
81 | 81 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
82 | 82 | this->disconnect(this,SLOT(setConnected(bool))); |
|
83 | 83 | delete this->bridge; |
|
84 | 84 | this->bridge= NULL; |
|
85 | 85 | } |
|
86 | 86 | } |
|
87 | 87 | if(text=="STAR-Dundee Spw USB Brick") |
|
88 | 88 | { |
|
89 | 89 | if(this->bridge!=NULL) |
|
90 | 90 | { |
|
91 | 91 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
92 | 92 | this->disconnect(this,SLOT(setConnected(bool))); |
|
93 | 93 | delete this->bridge; |
|
94 | 94 | } |
|
95 | 95 | this->bridge = new stardundeeSPW_USB(this); |
|
96 | 96 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
97 | 97 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
98 | 98 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int))); |
|
99 | 99 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int))); |
|
100 | 100 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int))); |
|
101 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetSourceAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetSourceAddress(QString))); | |
|
102 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationAddress(QString))); | |
|
101 | 103 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString))); |
|
102 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString))); | |
|
103 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString))); | |
|
104 | 104 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString))); |
|
105 | 105 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); |
|
106 | 106 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); |
|
107 | 107 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetAvailableBrickCount()),((stardundeeSPW_USB*)bridge),SIGNAL(GetAvailableBrickCount())); |
|
108 | 108 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetBrickAsAninterface(bool)), |
|
109 | 109 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsAnInterface(bool))); |
|
110 | 110 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetBrickAsARouter(bool)), |
|
111 | 111 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsARouter(bool))); |
|
112 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeStartTimecodes(bool)), | |
|
113 | ((stardundeeSPW_USB*)bridge),SIGNAL(StartSendingTimecodes(bool))); | |
|
114 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetTimecodeFrequency(double)), | |
|
115 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetTimecodeFrequency(double))); | |
|
112 | 116 | connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int))); |
|
113 | 117 | connect(this->tcpServer, SIGNAL(sendSPWPacket(char*,int)), ((stardundeeSPW_USB*)bridge), SLOT(sendPacketComingFromTCPServer(char*,int))); |
|
114 | 118 | } |
|
115 | 119 | if(text=="GR-ESB") |
|
116 | 120 | { |
|
117 | 121 | if(this->bridge!=NULL) |
|
118 | 122 | { |
|
119 | 123 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
120 | 124 | this->disconnect(this,SLOT(setConnected(bool))); |
|
121 | 125 | delete this->bridge; |
|
122 | 126 | } |
|
123 | 127 | this->bridge = new GR_ESB_bridge(this); |
|
124 | 128 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
125 | 129 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
126 | 130 | } |
|
127 | 131 | } |
|
128 | 132 | |
|
129 | 133 | |
|
130 | 134 | void spwplugin::selectBridge(const QString &text) |
|
131 | 135 | { |
|
132 | 136 | |
|
133 | 137 | if(text=="none") |
|
134 | 138 | { |
|
135 | 139 | this->bridgeSelector->setCurrentIndex(0); |
|
136 | 140 | } |
|
137 | 141 | if(text=="STAR-Dundee Spw USB Brick") |
|
138 | 142 | { |
|
139 | 143 | this->bridgeSelector->setCurrentIndex(1); |
|
140 | 144 | } |
|
141 | 145 | } |
|
142 | 146 | |
|
143 | 147 | void spwplugin::setConnected(bool connected) |
|
144 | 148 | { |
|
145 | 149 | this->bridgeSelector->setDisabled(connected); |
|
146 | 150 | this->Connected = connected; |
|
147 | 151 | emit activateSig(connected); |
|
148 | 152 | if(!this->scanDone) |
|
149 | 153 | { |
|
150 | 154 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); |
|
151 | 155 | this->scanDone=true; |
|
152 | 156 | } |
|
153 | 157 | } |
|
154 | 158 | |
|
155 | 159 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
156 | 160 | { |
|
157 | 161 | if(Connected) |
|
158 | 162 | { |
|
159 | 163 | return bridge->Write(Value,count,address); |
|
160 | 164 | } |
|
161 | 165 | return 0; |
|
162 | 166 | } |
|
163 | 167 | |
|
164 | 168 | |
|
165 | 169 | |
|
166 | 170 | |
|
167 | 171 | |
|
168 | 172 | |
|
169 | 173 | |
|
170 | 174 |
@@ -1,33 +1,35 | |||
|
1 | 1 | #ifndef SPWPYWRAPPER_H |
|
2 | 2 | #define SPWPYWRAPPER_H |
|
3 | 3 | #include <genericPySysdriver.h> |
|
4 | 4 | |
|
5 | 5 | class spwPyWrapper : public genericPySysdriver |
|
6 | 6 | { |
|
7 | 7 | Q_OBJECT |
|
8 | 8 | public: |
|
9 | 9 | explicit spwPyWrapper(socexplorerplugin *parent = 0); |
|
10 | 10 | signals: |
|
11 | 11 | void selectBridge(const QString &bridgeName); |
|
12 | 12 | bool connectBridge(); |
|
13 | 13 | bool disconnectBridge(); |
|
14 | 14 | void StarDundeeSelectBrick(int brickIndex); |
|
15 | 15 | void StarDundeeSelectLinkNumber(int linkIndex); |
|
16 | 16 | void StarDundeeSelectLinkSpeed(int linkSpeed); |
|
17 |
void StarDundeeSet |
|
|
18 |
void StarDundeeSet |
|
|
19 |
void StarDundeeSet |
|
|
17 | void StarDundeeSetSourceAddress(const QString & destKey); | |
|
18 | void StarDundeeSetDestinationAddress(const QString & address); | |
|
19 | void StarDundeeSetDestinationKey(const QString & key); | |
|
20 | 20 | void StarDundeeSetRmapTimeout(const QString & timeout); |
|
21 | 21 | int StarDundeeGetAvailableBrickCount(); |
|
22 | 22 | void StarDundeeSetBrickAsAninterface( bool ); |
|
23 | 23 | void StarDundeeSetBrickAsARouter( bool ); |
|
24 | void StarDundeeSetTimecodeFrequency( double ); | |
|
25 | void StarDundeeStartTimecodes( bool ); | |
|
24 | 26 | |
|
25 | 27 | void TCPServerConnect(); |
|
26 | 28 | void TCPServerDisconnect(); |
|
27 | 29 | void TCPServerSetPort(qint32 port); |
|
28 | 30 | void TCPServerSetIP(QString ip); |
|
29 | 31 | public slots: |
|
30 | 32 | |
|
31 | 33 | }; |
|
32 | 34 | |
|
33 | 35 | #endif // SPWPYWRAPPER_H |
General Comments 0
You need to be logged in to leave comments.
Login now