@@ -0,0 +1,14 | |||||
|
1 | #include "spwtcppacketserver.h" | |||
|
2 | #include "ui_spwtcppacketserver.h" | |||
|
3 | ||||
|
4 | SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) : | |||
|
5 | QWidget(parent), | |||
|
6 | ui(new Ui::SpwTcpPacketServer) | |||
|
7 | { | |||
|
8 | ui->setupUi(this); | |||
|
9 | } | |||
|
10 | ||||
|
11 | SpwTcpPacketServer::~SpwTcpPacketServer() | |||
|
12 | { | |||
|
13 | delete ui; | |||
|
14 | } |
@@ -0,0 +1,22 | |||||
|
1 | #ifndef SPWTCPPACKETSERVER_H | |||
|
2 | #define SPWTCPPACKETSERVER_H | |||
|
3 | ||||
|
4 | #include <QWidget> | |||
|
5 | ||||
|
6 | namespace Ui { | |||
|
7 | class SpwTcpPacketServer; | |||
|
8 | } | |||
|
9 | ||||
|
10 | class SpwTcpPacketServer : public QWidget | |||
|
11 | { | |||
|
12 | Q_OBJECT | |||
|
13 | ||||
|
14 | public: | |||
|
15 | explicit SpwTcpPacketServer(QWidget *parent = 0); | |||
|
16 | ~SpwTcpPacketServer(); | |||
|
17 | ||||
|
18 | private: | |||
|
19 | Ui::SpwTcpPacketServer *ui; | |||
|
20 | }; | |||
|
21 | ||||
|
22 | #endif // SPWTCPPACKETSERVER_H |
@@ -0,0 +1,55 | |||||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |||
|
2 | <ui version="4.0"> | |||
|
3 | <class>SpwTcpPacketServer</class> | |||
|
4 | <widget class="QWidget" name="SpwTcpPacketServer"> | |||
|
5 | <property name="geometry"> | |||
|
6 | <rect> | |||
|
7 | <x>0</x> | |||
|
8 | <y>0</y> | |||
|
9 | <width>541</width> | |||
|
10 | <height>127</height> | |||
|
11 | </rect> | |||
|
12 | </property> | |||
|
13 | <property name="windowTitle"> | |||
|
14 | <string>Form</string> | |||
|
15 | </property> | |||
|
16 | <layout class="QFormLayout" name="formLayout"> | |||
|
17 | <item row="0" column="1"> | |||
|
18 | <widget class="QLineEdit" name="IPLineEdit"> | |||
|
19 | <property name="maxLength"> | |||
|
20 | <number>15</number> | |||
|
21 | </property> | |||
|
22 | <property name="readOnly"> | |||
|
23 | <bool>true</bool> | |||
|
24 | </property> | |||
|
25 | </widget> | |||
|
26 | </item> | |||
|
27 | <item row="0" column="0"> | |||
|
28 | <widget class="QLabel" name="IPLbl"> | |||
|
29 | <property name="text"> | |||
|
30 | <string>Server IP</string> | |||
|
31 | </property> | |||
|
32 | </widget> | |||
|
33 | </item> | |||
|
34 | <item row="1" column="0"> | |||
|
35 | <widget class="QLabel" name="PortLbl"> | |||
|
36 | <property name="text"> | |||
|
37 | <string>Server Port</string> | |||
|
38 | </property> | |||
|
39 | </widget> | |||
|
40 | </item> | |||
|
41 | <item row="1" column="1"> | |||
|
42 | <widget class="QLineEdit" name="PortLineEdit"/> | |||
|
43 | </item> | |||
|
44 | <item row="2" column="1"> | |||
|
45 | <widget class="QPushButton" name="startServeQpb"> | |||
|
46 | <property name="text"> | |||
|
47 | <string>Start Server</string> | |||
|
48 | </property> | |||
|
49 | </widget> | |||
|
50 | </item> | |||
|
51 | </layout> | |||
|
52 | </widget> | |||
|
53 | <resources/> | |||
|
54 | <connections/> | |||
|
55 | </ui> |
@@ -0,0 +1,5 | |||||
|
1 | <RCC> | |||
|
2 | <qresource prefix="/imgs"> | |||
|
3 | <file>stardundee.tif</file> | |||
|
4 | </qresource> | |||
|
5 | </RCC> |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -1,112 +1,113 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 |
|
22 | |||
23 | #include "spwplugin.h" |
|
23 | #include "spwplugin.h" | |
24 | #include "stardundeespw_usb.h" |
|
24 | #include "stardundeespw_usb.h" | |
25 | #include <socexplorerproxy.h> |
|
25 | #include <socexplorerproxy.h> | |
26 |
|
26 | |||
27 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,true) |
|
27 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,true) | |
28 | { |
|
28 | { | |
29 | Q_UNUSED(parent) |
|
29 | Q_UNUSED(parent) | |
30 | this->bridge = NULL; |
|
30 | this->bridge = NULL; | |
31 | this->scanDone = false; |
|
31 | this->scanDone = false; | |
32 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); |
|
32 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); | |
33 | this->bridgeSelector = new QComboBox(this); |
|
33 | this->bridgeSelector = new QComboBox(this); | |
34 | this->mainLayout = new QGridLayout(this); |
|
34 | this->mainLayout = new QGridLayout(this); | |
35 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); |
|
35 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); | |
36 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); |
|
36 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); | |
37 | this->mainGroupBox->setLayout(this->mainLayout); |
|
37 | this->mainGroupBox->setLayout(this->mainLayout); | |
38 | this->setWidget(this->mainGroupBox); |
|
38 | this->setWidget(this->mainGroupBox); | |
39 | this->bridgeSelector->addItem("none"); |
|
39 | this->bridgeSelector->addItem("none"); | |
40 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); |
|
40 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); | |
41 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); |
|
41 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 |
|
44 | |||
45 | spwplugin::~spwplugin() |
|
45 | spwplugin::~spwplugin() | |
46 | { |
|
46 | { | |
47 |
|
47 | |||
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 |
|
50 | |||
51 |
|
51 | |||
52 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
52 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
53 | { |
|
53 | { | |
54 | if(Connected) |
|
54 | if(Connected) | |
55 | { |
|
55 | { | |
56 | return bridge->Read(Value,count,address); |
|
56 | return bridge->Read(Value,count,address); | |
57 | } |
|
57 | } | |
58 | return 0; |
|
58 | return 0; | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | void spwplugin::bridgeSelectionChanged(const QString &text) |
|
61 | void spwplugin::bridgeSelectionChanged(const QString &text) | |
62 | { |
|
62 | { | |
63 | printf("test"); |
|
63 | printf("test"); | |
64 | if(text=="none") |
|
64 | if(text=="none") | |
65 | { |
|
65 | { | |
66 | if(this->bridge!=NULL) |
|
66 | if(this->bridge!=NULL) | |
67 | { |
|
67 | { | |
68 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
68 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
69 | this->disconnect(this,SLOT(setConnected(bool))); |
|
69 | this->disconnect(this,SLOT(setConnected(bool))); | |
70 | delete this->bridge; |
|
70 | delete this->bridge; | |
71 | this->bridge= NULL; |
|
71 | this->bridge= NULL; | |
72 | } |
|
72 | } | |
73 | } |
|
73 | } | |
74 | if(text=="STAR-Dundee Spw USB Brick") |
|
74 | if(text=="STAR-Dundee Spw USB Brick") | |
75 | { |
|
75 | { | |
76 | if(this->bridge!=NULL) |
|
76 | if(this->bridge!=NULL) | |
77 | { |
|
77 | { | |
78 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
78 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
79 | this->disconnect(this,SLOT(setConnected(bool))); |
|
79 | this->disconnect(this,SLOT(setConnected(bool))); | |
80 | delete this->bridge; |
|
80 | delete this->bridge; | |
81 | } |
|
81 | } | |
82 | this->bridge = new stardundeeSPW_USB(this); |
|
82 | this->bridge = new stardundeeSPW_USB(this); | |
83 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
83 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); | |
84 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
84 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | void spwplugin::setConnected(bool connected) |
|
89 | void spwplugin::setConnected(bool connected) | |
90 | { |
|
90 | { | |
|
91 | this->bridgeSelector->setDisabled(connected); | |||
91 | this->Connected = connected; |
|
92 | this->Connected = connected; | |
92 | emit activateSig(connected); |
|
93 | emit activateSig(connected); | |
93 | } |
|
94 | } | |
94 |
|
95 | |||
95 |
|
96 | |||
96 |
|
97 | |||
97 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
98 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
98 | { |
|
99 | { | |
99 | if(Connected) |
|
100 | if(Connected) | |
100 | { |
|
101 | { | |
101 | return bridge->Write(Value,count,address); |
|
102 | return bridge->Write(Value,count,address); | |
102 | } |
|
103 | } | |
103 | return 0; |
|
104 | return 0; | |
104 | } |
|
105 | } | |
105 |
|
106 | |||
106 |
|
107 | |||
107 |
|
108 | |||
108 |
|
109 | |||
109 |
|
110 | |||
110 |
|
111 | |||
111 |
|
112 | |||
112 |
|
113 |
@@ -1,74 +1,80 | |||||
1 | # |
|
1 | # | |
2 | # Project created by QtCreator 2011-09-20T08:15:30 |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
3 | # |
|
3 | # | |
4 | #------------------------------------------------- |
|
4 | #------------------------------------------------- | |
5 |
|
5 | |||
6 | CONFIG += socexplorerplugin |
|
6 | CONFIG += socexplorerplugin | |
7 | win32:CONFIG += dll |
|
7 | win32:CONFIG += dll | |
8 | win32:CONFIG -= static |
|
8 | win32:CONFIG -= static | |
9 | CONFIG(debug, debug|release) { |
|
9 | CONFIG(debug, debug|release) { | |
10 | DEBUG_EXT = _d |
|
10 | DEBUG_EXT = _d | |
11 | } else { |
|
11 | } else { | |
12 | DEBUG_EXT = |
|
12 | DEBUG_EXT = | |
13 | } |
|
13 | } | |
14 | TARGET = spwplugin$${DEBUG_EXT} |
|
14 | TARGET = spwplugin$${DEBUG_EXT} | |
15 | DEFINES += PLUGIN=spwplugin |
|
15 | DEFINES += PLUGIN=spwplugin | |
16 | DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" |
|
16 | DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" | |
17 | DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" |
|
17 | DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" | |
18 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" |
|
18 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" | |
19 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" |
|
19 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" | |
20 | DEFINES += driver_Description="\"\\\"Driver description"\\\"\" |
|
20 | DEFINES += driver_Description="\"\\\"Driver description"\\\"\" | |
21 | DEFINES += driver_can_be_root=1 |
|
21 | DEFINES += driver_can_be_root=1 | |
22 | DEFINES += driver_can_be_child=0 |
|
22 | DEFINES += driver_can_be_child=0 | |
23 | DEFINES += driver_VID=0 |
|
23 | DEFINES += driver_VID=0 | |
24 | DEFINES += driver_PID=0 |
|
24 | DEFINES += driver_PID=0 | |
25 |
|
25 | |||
26 | STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/ |
|
26 | STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/ | |
27 |
|
27 | |||
28 | LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \ |
|
28 | LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \ | |
29 | $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so |
|
29 | $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so | |
30 |
|
30 | |||
31 | INCLUDEPATH += \ |
|
31 | INCLUDEPATH += \ | |
32 | $${PWD} \ |
|
32 | $${PWD} \ | |
33 | $$STARTDUNDEEPATH/inc \ |
|
33 | $$STARTDUNDEEPATH/inc \ | |
34 |
|
34 | |||
35 | HEADERS += \ |
|
35 | HEADERS += \ | |
36 | spwplugin.h \ |
|
36 | spwplugin.h \ | |
37 | stardundeespw_usb.h \ |
|
37 | stardundeespw_usb.h \ | |
38 | abstractspwbridge.h \ |
|
38 | abstractspwbridge.h \ | |
39 | spw.h \ |
|
39 | spw.h \ | |
40 | stardundeegui.h |
|
40 | stardundeegui.h \ | |
|
41 | SpwTcpPacketServer/spwtcppacketserver.h | |||
41 |
|
42 | |||
42 |
|
43 | |||
43 | SOURCES += \ |
|
44 | SOURCES += \ | |
44 | spwplugin.cpp \ |
|
45 | spwplugin.cpp \ | |
45 | stardundeespw_usb.cpp \ |
|
46 | stardundeespw_usb.cpp \ | |
46 | abstractspwbridge.cpp \ |
|
47 | abstractspwbridge.cpp \ | |
47 | stardundeegui.cpp |
|
48 | stardundeegui.cpp \ | |
|
49 | SpwTcpPacketServer/spwtcppacketserver.cpp | |||
48 |
|
50 | |||
49 | FORMS += \ |
|
51 | FORMS += \ | |
50 | stardundeeGUI.ui |
|
52 | stardundeeGUI.ui \ | |
|
53 | SpwTcpPacketServer/spwtcppacketserver.ui | |||
|
54 | ||||
|
55 | RESOURCES += \ | |||
|
56 | spwRessources.qrc | |||
51 |
|
57 | |||
52 |
|
58 | |||
53 |
|
59 | |||
54 |
|
60 | |||
55 |
|
61 | |||
56 |
|
62 | |||
57 |
|
63 | |||
58 |
|
64 | |||
59 |
|
65 | |||
60 |
|
66 | |||
61 |
|
67 | |||
62 |
|
68 | |||
63 |
|
69 | |||
64 |
|
70 | |||
65 |
|
71 | |||
66 |
|
72 | |||
67 |
|
73 | |||
68 |
|
74 | |||
69 |
|
75 | |||
70 |
|
76 | |||
71 |
|
77 | |||
72 |
|
78 | |||
73 |
|
79 | |||
74 |
|
80 |
@@ -1,144 +1,162 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>StarDundeeUI</class> |
|
3 | <class>StarDundeeUI</class> | |
4 | <widget class="QWidget" name="StarDundeeUI"> |
|
4 | <widget class="QWidget" name="StarDundeeUI"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 |
<width> |
|
9 | <width>778</width> | |
10 |
<height>2 |
|
10 | <height>271</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Form</string> |
|
14 | <string>Form</string> | |
15 | </property> |
|
15 | </property> | |
16 | <layout class="QFormLayout" name="formLayout"> |
|
16 | <layout class="QFormLayout" name="formLayout"> | |
17 | <property name="fieldGrowthPolicy"> |
|
|||
18 | <enum>QFormLayout::AllNonFixedFieldsGrow</enum> |
|
|||
19 | </property> |
|
|||
20 | <item row="0" column="0"> |
|
17 | <item row="0" column="0"> | |
21 | <widget class="QLabel" name="selectBrickLbl"> |
|
18 | <widget class="QLabel" name="selectBrickLbl"> | |
22 | <property name="text"> |
|
19 | <property name="text"> | |
23 | <string>Select Brick</string> |
|
20 | <string>Select Brick</string> | |
24 | </property> |
|
21 | </property> | |
25 | </widget> |
|
22 | </widget> | |
26 | </item> |
|
23 | </item> | |
27 | <item row="0" column="1"> |
|
24 | <item row="0" column="1"> | |
28 | <widget class="QComboBox" name="selectBrickCmbx"> |
|
25 | <widget class="QComboBox" name="selectBrickCmbx"> | |
|
26 | <property name="toolTip"> | |||
|
27 | <string><html><head/><body><p>Select the brick you want to use.</p></body></html></string> | |||
|
28 | </property> | |||
|
29 | <property name="whatsThis"> | |||
|
30 | <string/> | |||
|
31 | </property> | |||
29 | <item> |
|
32 | <item> | |
30 | <property name="text"> |
|
33 | <property name="text"> | |
31 | <string>None</string> |
|
34 | <string>None</string> | |
32 | </property> |
|
35 | </property> | |
33 | </item> |
|
36 | </item> | |
34 | </widget> |
|
37 | </widget> | |
35 | </item> |
|
38 | </item> | |
36 | <item row="1" column="0"> |
|
39 | <item row="1" column="0"> | |
37 | <widget class="QLabel" name="selectLinkLbl"> |
|
40 | <widget class="QLabel" name="selectLinkLbl"> | |
38 | <property name="text"> |
|
41 | <property name="text"> | |
39 | <string>Select link number</string> |
|
42 | <string>Select link number</string> | |
40 | </property> |
|
43 | </property> | |
41 | </widget> |
|
44 | </widget> | |
42 | </item> |
|
45 | </item> | |
43 | <item row="1" column="1"> |
|
46 | <item row="1" column="1"> | |
44 | <widget class="QComboBox" name="selectLinkCmbx"> |
|
47 | <widget class="QComboBox" name="selectLinkCmbx"> | |
|
48 | <property name="toolTip"> | |||
|
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 | </property> | |||
45 | <item> |
|
51 | <item> | |
46 | <property name="text"> |
|
52 | <property name="text"> | |
47 | <string>1</string> |
|
53 | <string>1</string> | |
48 | </property> |
|
54 | </property> | |
49 | </item> |
|
55 | </item> | |
50 | <item> |
|
56 | <item> | |
51 | <property name="text"> |
|
57 | <property name="text"> | |
52 | <string>2</string> |
|
58 | <string>2</string> | |
53 | </property> |
|
59 | </property> | |
54 | </item> |
|
60 | </item> | |
55 | </widget> |
|
61 | </widget> | |
56 | </item> |
|
62 | </item> | |
57 | <item row="2" column="0"> |
|
63 | <item row="2" column="0"> | |
58 | <widget class="QLabel" name="selectLinkSpeedLbl"> |
|
64 | <widget class="QLabel" name="selectLinkSpeedLbl"> | |
59 | <property name="text"> |
|
65 | <property name="text"> | |
60 | <string>Link Speed</string> |
|
66 | <string>Link Speed</string> | |
61 | </property> |
|
67 | </property> | |
62 | </widget> |
|
68 | </widget> | |
63 | </item> |
|
69 | </item> | |
64 | <item row="2" column="1"> |
|
70 | <item row="2" column="1"> | |
65 | <widget class="QComboBox" name="setLinkSpeedCmbx"> |
|
71 | <widget class="QComboBox" name="setLinkSpeedCmbx"> | |
|
72 | <property name="toolTip"> | |||
|
73 | <string><html><head/><body><p>Select the Space Wire link speed you want to use.</p></body></html></string> | |||
|
74 | </property> | |||
66 | <item> |
|
75 | <item> | |
67 | <property name="text"> |
|
76 | <property name="text"> | |
68 | <string>10MHz</string> |
|
77 | <string>10MHz</string> | |
69 | </property> |
|
78 | </property> | |
70 | </item> |
|
79 | </item> | |
71 | </widget> |
|
80 | </widget> | |
72 | </item> |
|
81 | </item> | |
73 | <item row="3" column="0"> |
|
82 | <item row="3" column="0"> | |
74 | <widget class="QLabel" name="setDestKeyLbl"> |
|
83 | <widget class="QLabel" name="setDestKeyLbl"> | |
75 | <property name="text"> |
|
84 | <property name="text"> | |
76 | <string>Destination key</string> |
|
85 | <string>Destination key</string> | |
77 | </property> |
|
86 | </property> | |
78 | </widget> |
|
87 | </widget> | |
79 | </item> |
|
88 | </item> | |
80 | <item row="3" column="1"> |
|
89 | <item row="3" column="1"> | |
81 | <widget class="QLineEdit" name="destKeyLineEdit"> |
|
90 | <widget class="QLineEdit" name="destKeyLineEdit"> | |
|
91 | <property name="toolTip"> | |||
|
92 | <string><html><head/><body><p>Set the Space Wire Brick destination Key, the default value is 32 (0x20).</p></body></html></string> | |||
|
93 | </property> | |||
82 | <property name="inputMask"> |
|
94 | <property name="inputMask"> | |
83 | <string comment="ddD"/> |
|
95 | <string comment="ddD"/> | |
84 | </property> |
|
96 | </property> | |
85 | <property name="text"> |
|
97 | <property name="text"> | |
86 | <string>32</string> |
|
98 | <string>32</string> | |
87 | </property> |
|
99 | </property> | |
88 | <property name="maxLength"> |
|
100 | <property name="maxLength"> | |
89 | <number>3</number> |
|
101 | <number>3</number> | |
90 | </property> |
|
102 | </property> | |
91 | </widget> |
|
103 | </widget> | |
92 | </item> |
|
104 | </item> | |
93 | <item row="4" column="0"> |
|
105 | <item row="4" column="0"> | |
94 | <widget class="QLabel" name="RMAPaddressLbl"> |
|
106 | <widget class="QLabel" name="RMAPaddressLbl"> | |
95 | <property name="text"> |
|
107 | <property name="text"> | |
96 | <string>RMAP Target address</string> |
|
108 | <string>RMAP Target address</string> | |
97 | </property> |
|
109 | </property> | |
98 | </widget> |
|
110 | </widget> | |
99 | </item> |
|
111 | </item> | |
100 | <item row="4" column="1"> |
|
112 | <item row="4" column="1"> | |
101 | <widget class="QLineEdit" name="RMAPAddresslineEdit"> |
|
113 | <widget class="QLineEdit" name="RMAPAddresslineEdit"> | |
|
114 | <property name="toolTip"> | |||
|
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 | </property> | |||
102 | <property name="inputMask"> |
|
117 | <property name="inputMask"> | |
103 | <string comment="ddD"/> |
|
118 | <string comment="ddD"/> | |
104 | </property> |
|
119 | </property> | |
105 | <property name="text"> |
|
120 | <property name="text"> | |
106 | <string>254</string> |
|
121 | <string>254</string> | |
107 | </property> |
|
122 | </property> | |
108 | <property name="maxLength"> |
|
123 | <property name="maxLength"> | |
109 | <number>3</number> |
|
124 | <number>3</number> | |
110 | </property> |
|
125 | </property> | |
111 | </widget> |
|
126 | </widget> | |
112 | </item> |
|
127 | </item> | |
113 | <item row="5" column="0"> |
|
128 | <item row="5" column="0"> | |
114 | <widget class="QLabel" name="RMAPKeyLbl"> |
|
129 | <widget class="QLabel" name="RMAPKeyLbl"> | |
115 | <property name="text"> |
|
130 | <property name="text"> | |
116 | <string>RMAP Target key</string> |
|
131 | <string>RMAP Target key</string> | |
117 | </property> |
|
132 | </property> | |
118 | </widget> |
|
133 | </widget> | |
119 | </item> |
|
134 | </item> | |
120 | <item row="5" column="1"> |
|
135 | <item row="5" column="1"> | |
121 | <widget class="QLineEdit" name="RMAPKeylineEdit"> |
|
136 | <widget class="QLineEdit" name="RMAPKeylineEdit"> | |
|
137 | <property name="toolTip"> | |||
|
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 | </property> | |||
122 | <property name="inputMask"> |
|
140 | <property name="inputMask"> | |
123 | <string comment="ddD"/> |
|
141 | <string comment="ddD"/> | |
124 | </property> |
|
142 | </property> | |
125 | <property name="text"> |
|
143 | <property name="text"> | |
126 | <string comment="ddD">2</string> |
|
144 | <string comment="ddD">2</string> | |
127 | </property> |
|
145 | </property> | |
128 | <property name="maxLength"> |
|
146 | <property name="maxLength"> | |
129 | <number>3</number> |
|
147 | <number>3</number> | |
130 | </property> |
|
148 | </property> | |
131 | </widget> |
|
149 | </widget> | |
132 | </item> |
|
150 | </item> | |
133 | <item row="6" column="1"> |
|
151 | <item row="6" column="1"> | |
134 | <widget class="QPushButton" name="connectQpb"> |
|
152 | <widget class="QPushButton" name="connectQpb"> | |
135 | <property name="text"> |
|
153 | <property name="text"> | |
136 | <string>Connect</string> |
|
154 | <string>Connect</string> | |
137 | </property> |
|
155 | </property> | |
138 | </widget> |
|
156 | </widget> | |
139 | </item> |
|
157 | </item> | |
140 | </layout> |
|
158 | </layout> | |
141 | </widget> |
|
159 | </widget> | |
142 | <resources/> |
|
160 | <resources/> | |
143 | <connections/> |
|
161 | <connections/> | |
144 | </ui> |
|
162 | </ui> |
@@ -1,98 +1,107 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "stardundeegui.h" |
|
22 | #include "stardundeegui.h" | |
23 |
|
23 | |||
24 | #include "ui_stardundeeGUI.h" |
|
24 | #include "ui_stardundeeGUI.h" | |
|
25 | #include <spw_usb_api.h> | |||
|
26 | #include <spw_config_library.h> | |||
25 |
|
27 | |||
26 | StarDundeeGUI::StarDundeeGUI(QWidget *parent) : |
|
28 | StarDundeeGUI::StarDundeeGUI(QWidget *parent) : | |
27 | QWidget(parent),ui(new Ui::StarDundeeUI) |
|
29 | QWidget(parent),ui(new Ui::StarDundeeUI) | |
28 | { |
|
30 | { | |
29 | this->ui->setupUi(this); |
|
31 | this->ui->setupUi(this); | |
30 | connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int))); |
|
32 | connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int))); | |
31 | connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int))); |
|
33 | connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int))); | |
32 | connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString))); |
|
34 | connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString))); | |
33 | connect(this->ui->destKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString))); |
|
35 | connect(this->ui->destKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString))); | |
34 | connect(this->ui->RMAPAddresslineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString))); |
|
36 | connect(this->ui->RMAPAddresslineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString))); | |
35 | connect(this->ui->RMAPKeylineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString))); |
|
37 | connect(this->ui->RMAPKeylineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString))); | |
36 | connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked())); |
|
38 | connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked())); | |
37 |
|
39 | |||
38 | } |
|
40 | } | |
39 |
|
41 | |||
40 | int StarDundeeGUI::getBrickSelection() |
|
42 | int StarDundeeGUI::getBrickSelection() | |
41 | { |
|
43 | { | |
42 | return ui->selectBrickCmbx->currentIndex(); |
|
44 | return ui->selectBrickCmbx->currentIndex(); | |
43 | } |
|
45 | } | |
44 |
|
46 | |||
45 | int StarDundeeGUI::getLinkNumberSelection() |
|
47 | int StarDundeeGUI::getLinkNumberSelection() | |
46 | { |
|
48 | { | |
47 | return ui->selectLinkCmbx->currentIndex(); |
|
49 | return ui->selectLinkCmbx->currentIndex(); | |
48 | } |
|
50 | } | |
49 |
|
51 | |||
50 | QString StarDundeeGUI::getLinkSpeedSelection() |
|
52 | QString StarDundeeGUI::getLinkSpeedSelection() | |
51 | { |
|
53 | { | |
52 | return ui->setLinkSpeedCmbx->currentText(); |
|
54 | return ui->setLinkSpeedCmbx->currentText(); | |
53 | } |
|
55 | } | |
54 |
|
56 | |||
55 | QString StarDundeeGUI::getDestinationKey() |
|
57 | QString StarDundeeGUI::getDestinationKey() | |
56 | { |
|
58 | { | |
57 | return ui->destKeyLineEdit->text(); |
|
59 | return ui->destKeyLineEdit->text(); | |
58 | } |
|
60 | } | |
59 |
|
61 | |||
60 | QString StarDundeeGUI::getRmapAddress() |
|
62 | QString StarDundeeGUI::getRmapAddress() | |
61 | { |
|
63 | { | |
62 | return ui->RMAPAddresslineEdit->text(); |
|
64 | return ui->RMAPAddresslineEdit->text(); | |
63 | } |
|
65 | } | |
64 |
|
66 | |||
65 | QString StarDundeeGUI::getRmapKey() |
|
67 | QString StarDundeeGUI::getRmapKey() | |
66 | { |
|
68 | { | |
67 | return ui->RMAPKeylineEdit->text(); |
|
69 | return ui->RMAPKeylineEdit->text(); | |
68 | } |
|
70 | } | |
69 |
|
71 | |||
70 |
|
72 | |||
71 |
|
73 | |||
72 | void StarDundeeGUI::lock(bool lock) |
|
74 | void StarDundeeGUI::lock(bool lock) | |
73 | { |
|
75 | { | |
74 | this->ui->selectBrickCmbx->setDisabled(lock); |
|
76 | this->ui->selectBrickCmbx->setDisabled(lock); | |
75 | this->ui->selectLinkCmbx->setDisabled(lock); |
|
77 | this->ui->selectLinkCmbx->setDisabled(lock); | |
76 | this->ui->setLinkSpeedCmbx->setDisabled(lock); |
|
78 | this->ui->setLinkSpeedCmbx->setDisabled(lock); | |
77 | this->ui->destKeyLineEdit->setDisabled(lock); |
|
79 | this->ui->destKeyLineEdit->setDisabled(lock); | |
78 | this->ui->RMAPAddresslineEdit->setDisabled(lock); |
|
80 | this->ui->RMAPAddresslineEdit->setDisabled(lock); | |
79 | this->ui->RMAPKeylineEdit->setDisabled(lock); |
|
81 | this->ui->RMAPKeylineEdit->setDisabled(lock); | |
80 | if(lock) |
|
82 | if(lock) | |
81 | this->ui->connectQpb->setText("Disconnect"); |
|
83 | this->ui->connectQpb->setText("Disconnect"); | |
82 | else |
|
84 | else | |
83 | this->ui->connectQpb->setText("Connect"); |
|
85 | this->ui->connectQpb->setText("Connect"); | |
84 | } |
|
86 | } | |
85 |
|
87 | |||
86 | void StarDundeeGUI::updateAvailableBrickCount(int count) |
|
88 | void StarDundeeGUI::updateAvailableBrickCount(int count) | |
87 | { |
|
89 | { | |
88 | this->ui->selectBrickCmbx->clear(); |
|
90 | this->ui->selectBrickCmbx->clear(); | |
89 | this->ui->selectBrickCmbx->addItem("none"); |
|
91 | this->ui->selectBrickCmbx->addItem("none"); | |
90 | for(int i =0;i<32;i++) |
|
92 | for(int i =0;i<32;i++) | |
91 | { |
|
93 | { | |
92 | if((count&1)==1) |
|
94 | if((count&1)==1) | |
93 | { |
|
95 | { | |
94 | this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i)); |
|
96 | star_device_handle hDevice; | |
|
97 | char serial[11]=""; | |||
|
98 | if (USBSpaceWire_Open(&hDevice, 0)) | |||
|
99 | { | |||
|
100 | USBSpaceWire_GetSerialNumber(hDevice,(U8*) serial); | |||
|
101 | USBSpaceWire_Close(hDevice); | |||
|
102 | } | |||
|
103 | this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i)+" sn:" + serial); | |||
95 | } |
|
104 | } | |
96 | count>>=1; |
|
105 | count>>=1; | |
97 | } |
|
106 | } | |
98 | } |
|
107 | } |
@@ -1,605 +1,607 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 |
|
22 | |||
23 | #include "stardundeespw_usb.h" |
|
23 | #include "stardundeespw_usb.h" | |
24 | #include <socexplorerengine.h> |
|
24 | #include <socexplorerengine.h> | |
25 | #include <qhexedit.h> |
|
25 | #include <qhexedit.h> | |
26 |
|
26 | |||
27 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : |
|
27 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : | |
28 | abstractSpwBridge(parent) |
|
28 | abstractSpwBridge(parent) | |
29 | { |
|
29 | { | |
30 | Q_UNUSED(parent) |
|
30 | Q_UNUSED(parent) | |
31 | this->manager = new stardundeeSPW_USB_Manager(parent,this); |
|
31 | this->manager = new stardundeeSPW_USB_Manager(parent,this); | |
32 | makeGUI(parent); |
|
32 | makeGUI(parent); | |
33 | this->manager->start(); |
|
33 | this->manager->start(); | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | stardundeeSPW_USB::~stardundeeSPW_USB() |
|
36 | stardundeeSPW_USB::~stardundeeSPW_USB() | |
37 | { |
|
37 | { | |
38 | this->manager->requestInterruption(); |
|
38 | this->manager->requestInterruption(); | |
39 | delete this->p_GUI; |
|
39 | delete this->p_GUI; | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void stardundeeSPW_USB::toggleBridgeConnection() |
|
42 | void stardundeeSPW_USB::toggleBridgeConnection() | |
43 | { |
|
43 | { | |
44 | if(this->plugin->isConnected()) |
|
44 | if(this->plugin->isConnected()) | |
45 | { |
|
45 | { | |
46 | if(this->disconnectBridge()) |
|
46 | if(this->disconnectBridge()) | |
47 | { |
|
47 | { | |
48 | ((StarDundeeGUI*)this->p_GUI)->lock(false); |
|
48 | ((StarDundeeGUI*)this->p_GUI)->lock(false); | |
49 | emit setConnected(false); |
|
49 | emit setConnected(false); | |
50 | } |
|
50 | } | |
51 | } |
|
51 | } | |
52 | else |
|
52 | else | |
53 | { |
|
53 | { | |
54 | if(this->connectBridge()) |
|
54 | if(this->connectBridge()) | |
55 | { |
|
55 | { | |
56 | ((StarDundeeGUI*)this->p_GUI)->lock(true); |
|
56 | ((StarDundeeGUI*)this->p_GUI)->lock(true); | |
57 | emit setConnected(true); |
|
57 | emit setConnected(true); | |
58 | } |
|
58 | } | |
59 | } |
|
59 | } | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | bool stardundeeSPW_USB::connectBridge() |
|
62 | bool stardundeeSPW_USB::connectBridge() | |
63 | { |
|
63 | { | |
64 | return this->manager->connectBridge(); |
|
64 | return this->manager->connectBridge(); | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | bool stardundeeSPW_USB::disconnectBridge() |
|
67 | bool stardundeeSPW_USB::disconnectBridge() | |
68 | { |
|
68 | { | |
69 | return this->manager->disconnectBridge(); |
|
69 | return this->manager->disconnectBridge(); | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) |
|
72 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) | |
73 | { |
|
73 | { | |
74 | return this->manager->sendPacket(packet,size); |
|
74 | return this->manager->sendPacket(packet,size); | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
77 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
78 | { |
|
78 | { | |
79 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; |
|
79 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; | |
80 | writeBuffer[0]=this->manager->linkNumber;//Link number |
|
80 | writeBuffer[0]=this->manager->linkNumber;//Link number | |
81 | int transactionID = 0; |
|
81 | int transactionID = 0; | |
82 | int written=0; |
|
82 | int written=0; | |
83 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); |
|
83 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); | |
84 | QProgressBar* progress=NULL; |
|
84 | QProgressBar* progress=NULL; | |
85 | if(count>RMAP_MAX_XFER_SIZE) |
|
85 | if(count>RMAP_MAX_XFER_SIZE) | |
86 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
86 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
87 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
87 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
88 | while(count>=RMAP_MAX_XFER_SIZE) |
|
88 | while(count>=RMAP_MAX_XFER_SIZE) | |
89 | { |
|
89 | { | |
90 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) |
|
90 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) | |
91 | { |
|
91 | { | |
92 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
92 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
93 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
93 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
94 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
94 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
95 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
95 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
96 | } |
|
96 | } | |
97 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1); |
|
97 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1); | |
98 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); |
|
98 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); | |
99 | written+=RMAP_MAX_XFER_SIZE; |
|
99 | written+=RMAP_MAX_XFER_SIZE; | |
100 | count-=RMAP_MAX_XFER_SIZE; |
|
100 | count-=RMAP_MAX_XFER_SIZE; | |
101 | progress->setValue(written); |
|
101 | progress->setValue(written); | |
102 | qApp->processEvents(); |
|
102 | qApp->processEvents(); | |
103 | } |
|
103 | } | |
104 | if(count>0) |
|
104 | if(count>0) | |
105 | { |
|
105 | { | |
106 | for(int i=0;i<((int)count);i++) |
|
106 | for(int i=0;i<((int)count);i++) | |
107 | { |
|
107 | { | |
108 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
108 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
109 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
109 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
110 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
110 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
111 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
111 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
112 | } |
|
112 | } | |
113 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1); |
|
113 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1); | |
114 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); |
|
114 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); | |
115 | written+=count; |
|
115 | written+=count; | |
116 | if(progress!=NULL) |
|
116 | if(progress!=NULL) | |
117 | { |
|
117 | { | |
118 | progress->setValue(written); |
|
118 | progress->setValue(written); | |
119 | qApp->processEvents(); |
|
119 | qApp->processEvents(); | |
120 | } |
|
120 | } | |
121 | } |
|
121 | } | |
122 | if(progress!=NULL) |
|
122 | if(progress!=NULL) | |
123 | { |
|
123 | { | |
124 | SocExplorerEngine::deleteProgressBar(progress); |
|
124 | SocExplorerEngine::deleteProgressBar(progress); | |
125 | } |
|
125 | } | |
126 | return written; |
|
126 | return written; | |
127 | } |
|
127 | } | |
128 |
|
128 | |||
129 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
129 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
130 | { |
|
130 | { | |
131 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; |
|
131 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; | |
132 | char* RMAP_AnswerBuffer; |
|
132 | char* RMAP_AnswerBuffer; | |
133 | requestBuffer[0]=this->manager->linkNumber;//Link number |
|
133 | requestBuffer[0]=this->manager->linkNumber;//Link number | |
134 | int transactionID = 0; |
|
134 | int transactionID = 0; | |
135 | int read=0; |
|
135 | int read=0; | |
136 | QProgressBar* progress=NULL; |
|
136 | QProgressBar* progress=NULL; | |
137 | if(count>RMAP_MAX_XFER_SIZE) |
|
137 | if(count>RMAP_MAX_XFER_SIZE) | |
138 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
138 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
139 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); |
|
139 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); | |
140 |
|
140 | |||
141 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
141 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
142 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) |
|
142 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) | |
143 | { |
|
143 | { | |
144 | transactionID = manager->getRMAPtransactionID(); |
|
144 | transactionID = manager->getRMAPtransactionID(); | |
145 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); |
|
145 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); | |
146 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1); |
|
146 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1); | |
147 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
147 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
148 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
148 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
149 | if(len==-1) |
|
149 | if(len==-1) | |
150 | { |
|
150 | { | |
151 | this->toggleBridgeConnection(); |
|
151 | this->toggleBridgeConnection(); | |
152 | return 0; |
|
152 | return 0; | |
153 | } |
|
153 | } | |
154 | for(int i=0;i<((len-13)/4);i++) |
|
154 | for(int i=0;i<((len-13)/4);i++) | |
155 | { |
|
155 | { | |
156 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
156 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
157 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
157 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
158 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
158 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
159 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
159 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
160 | } |
|
160 | } | |
161 | free(RMAP_AnswerBuffer); |
|
161 | free(RMAP_AnswerBuffer); | |
162 | read+=RMAP_MAX_XFER_SIZE; |
|
162 | read+=RMAP_MAX_XFER_SIZE; | |
163 | count-=RMAP_MAX_XFER_SIZE; |
|
163 | count-=RMAP_MAX_XFER_SIZE; | |
164 | progress->setValue(read); |
|
164 | progress->setValue(read); | |
165 | qApp->processEvents(); |
|
165 | qApp->processEvents(); | |
166 | } |
|
166 | } | |
167 | if((int)count>0) |
|
167 | if((int)count>0) | |
168 | { |
|
168 | { | |
169 | transactionID = manager->getRMAPtransactionID(); |
|
169 | transactionID = manager->getRMAPtransactionID(); | |
170 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); |
|
170 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); | |
171 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); |
|
171 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); | |
172 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); |
|
172 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); | |
173 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); |
|
173 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); | |
174 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); |
|
174 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); | |
175 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),count*4,requestBuffer+1); |
|
175 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),count*4,requestBuffer+1); | |
176 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
176 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
177 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
177 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
178 | if(len==-1) |
|
178 | if(len==-1) | |
179 | { |
|
179 | { | |
180 | this->toggleBridgeConnection(); |
|
180 | this->toggleBridgeConnection(); | |
181 | return 0; |
|
181 | return 0; | |
182 | } |
|
182 | } | |
183 | for(int i=0;i<((len-13)/4);i++) |
|
183 | for(int i=0;i<((len-13)/4);i++) | |
184 | { |
|
184 | { | |
185 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
185 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
186 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
186 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
187 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
187 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
188 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
188 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
189 | } |
|
189 | } | |
190 | free(RMAP_AnswerBuffer); |
|
190 | free(RMAP_AnswerBuffer); | |
191 | read+=count; |
|
191 | read+=count; | |
192 | if(progress!=NULL) |
|
192 | if(progress!=NULL) | |
193 | { |
|
193 | { | |
194 | progress->setValue(read); |
|
194 | progress->setValue(read); | |
195 | qApp->processEvents(); |
|
195 | qApp->processEvents(); | |
196 | } |
|
196 | } | |
197 | } |
|
197 | } | |
198 | if(progress!=NULL) |
|
198 | if(progress!=NULL) | |
199 | { |
|
199 | { | |
200 | SocExplorerEngine::deleteProgressBar(progress); |
|
200 | SocExplorerEngine::deleteProgressBar(progress); | |
201 | } |
|
201 | } | |
202 | return read; |
|
202 | return read; | |
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) |
|
205 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) | |
206 | { |
|
206 | { | |
207 | this->manager->selectedBrick = brickIndex-1; |
|
207 | this->manager->selectedBrick = brickIndex-1; | |
208 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick)); |
|
208 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick)); | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) |
|
211 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) | |
212 | { |
|
212 | { | |
213 | this->manager->linkNumber = linkIndex + 1; |
|
213 | this->manager->linkNumber = linkIndex + 1; | |
214 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber)); |
|
214 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber)); | |
215 | } |
|
215 | } | |
216 |
|
216 | |||
217 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) |
|
217 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) | |
218 | { |
|
218 | { | |
219 | this->manager->linkSpeed = linkSpeed.toInt(); |
|
219 | this->manager->linkSpeed = linkSpeed.toInt(); | |
220 |
|
220 | |||
221 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed)); |
|
221 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed)); | |
222 | } |
|
222 | } | |
223 |
|
223 | |||
224 | void stardundeeSPW_USB::destinationKeyChanged(const QString &destKey) |
|
224 | void stardundeeSPW_USB::destinationKeyChanged(const QString &destKey) | |
225 | { |
|
225 | { | |
226 | this->manager->destinationKey = destKey.toInt(); |
|
226 | this->manager->destinationKey = destKey.toInt(); | |
227 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->destinationKey)); |
|
227 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->destinationKey)); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | void stardundeeSPW_USB::rmapAddressChanged(const QString &rmapaddress) |
|
230 | void stardundeeSPW_USB::rmapAddressChanged(const QString &rmapaddress) | |
231 | { |
|
231 | { | |
232 | this->manager->rmapAddress = rmapaddress.toInt(); |
|
232 | this->manager->rmapAddress = rmapaddress.toInt(); | |
233 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->rmapAddress)); |
|
233 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->rmapAddress)); | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | void stardundeeSPW_USB::rmapKeyChanged(const QString &key) |
|
236 | void stardundeeSPW_USB::rmapKeyChanged(const QString &key) | |
237 | { |
|
237 | { | |
238 | this->manager->rmapKey = key.toInt(); |
|
238 | this->manager->rmapKey = key.toInt(); | |
239 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->rmapKey)); |
|
239 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->rmapKey)); | |
240 | } |
|
240 | } | |
241 |
|
241 | |||
242 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) |
|
242 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) | |
243 | { |
|
243 | { | |
244 | this->p_GUI = new StarDundeeGUI(); |
|
244 | this->p_GUI = new StarDundeeGUI(); | |
245 | // this->mainLayout = new QGridLayout(this->p_GUI); |
|
245 | // this->mainLayout = new QGridLayout(this->p_GUI); | |
246 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); |
|
246 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); | |
247 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); |
|
247 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); | |
248 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); |
|
248 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); | |
249 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); |
|
249 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); | |
250 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); |
|
250 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); | |
251 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); |
|
251 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); | |
252 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(rmapAddressChanged(QString))); |
|
252 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(rmapAddressChanged(QString))); | |
253 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapKeyChanged(QString)),this,SLOT(rmapKeyChanged(QString))); |
|
253 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapKeyChanged(QString)),this,SLOT(rmapKeyChanged(QString))); | |
254 | this->brickSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); |
|
254 | this->brickSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); | |
255 | this->linkNumberSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); |
|
255 | this->linkNumberSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); | |
256 | this->linkSpeedSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); |
|
256 | this->linkSpeedSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); | |
257 | this->destinationKeyChanged(((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); |
|
257 | this->destinationKeyChanged(((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); | |
258 | this->rmapAddressChanged(((StarDundeeGUI*)this->p_GUI)->getRmapAddress()); |
|
258 | this->rmapAddressChanged(((StarDundeeGUI*)this->p_GUI)->getRmapAddress()); | |
259 | this->rmapKeyChanged(((StarDundeeGUI*)this->p_GUI)->getRmapKey()); |
|
259 | this->rmapKeyChanged(((StarDundeeGUI*)this->p_GUI)->getRmapKey()); | |
260 |
|
260 | |||
261 | } |
|
261 | } | |
262 |
|
262 | |||
263 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) |
|
263 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) | |
264 | :QThread((QObject*)parent) |
|
264 | :QThread((QObject*)parent) | |
265 | { |
|
265 | { | |
266 | this->RMAPtimeout = 2000; |
|
266 | this->RMAPtimeout = 2000; | |
267 | this->handleMutex = new QMutex(QMutex::NonRecursive); |
|
267 | this->handleMutex = new QMutex(QMutex::NonRecursive); | |
268 | this->RMAP_AnswersSem = new QSemaphore(0); |
|
268 | this->RMAP_AnswersSem = new QSemaphore(0); | |
269 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); |
|
269 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); | |
270 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); |
|
270 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); | |
271 | this->plugin = plugin; |
|
271 | this->plugin = plugin; | |
272 | connected = false; |
|
272 | connected = false; | |
|
273 | this->moveToThread(this); | |||
273 | } |
|
274 | } | |
274 |
|
275 | |||
275 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() |
|
276 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() | |
276 | { |
|
277 | { | |
277 | this->terminate(); |
|
278 | this->terminate(); | |
278 | while (!this->isFinished()) { |
|
279 | while (!this->isFinished()) { | |
279 | this->usleep(1000); |
|
280 | this->usleep(1000); | |
280 | } |
|
281 | } | |
281 | } |
|
282 | } | |
282 |
|
283 | |||
283 |
|
284 | |||
284 | void stardundeeSPW_USB_Manager::run() |
|
285 | void stardundeeSPW_USB_Manager::run() | |
285 | { |
|
286 | { | |
286 | USB_SPACEWIRE_PACKET_PROPERTIES properties; |
|
287 | USB_SPACEWIRE_PACKET_PROPERTIES properties; | |
287 | USB_SPACEWIRE_ID pIdentifier=NULL; |
|
288 | USB_SPACEWIRE_ID pIdentifier=NULL; | |
288 | USB_SPACEWIRE_STATUS stat; |
|
289 | USB_SPACEWIRE_STATUS stat; | |
289 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); |
|
290 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); | |
290 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; |
|
291 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; | |
291 | while (!this->isInterruptionRequested()) |
|
292 | while (!this->isInterruptionRequested()) | |
292 | { |
|
293 | { | |
293 | if(this->connected) |
|
294 | if(this->connected) | |
294 | { |
|
295 | { | |
295 | handleMutex->lock(); |
|
296 | handleMutex->lock(); | |
296 |
|
|
297 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); | |
297 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) |
|
298 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) | |
298 | { |
|
299 | { | |
299 | SocExplorerEngine::message(this->plugin,"Got packet",2); |
|
300 | SocExplorerEngine::message(this->plugin,"Got packet",2); | |
300 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); |
|
301 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); | |
301 | if (stat == TRANSFER_SUCCESS) |
|
302 | if (stat == TRANSFER_SUCCESS) | |
302 | { |
|
303 | { | |
303 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) |
|
304 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) | |
304 | { |
|
305 | { | |
305 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); |
|
306 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); | |
306 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) |
|
307 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) | |
307 | { |
|
308 | { | |
308 | SocExplorerEngine::message(this->plugin,"Got end of packet"); |
|
309 | SocExplorerEngine::message(this->plugin,"Got end of packet"); | |
309 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet |
|
310 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet | |
310 | { |
|
311 | { | |
311 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); |
|
312 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); | |
312 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); |
|
313 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); | |
313 | if(properties.len>8) |
|
314 | if(properties.len>8) | |
314 | { |
|
315 | { | |
315 | char* packetbuffer = (char*)malloc(properties.len); |
|
316 | char* packetbuffer = (char*)malloc(properties.len); | |
316 | memcpy(packetbuffer,buffer,properties.len); |
|
317 | memcpy(packetbuffer,buffer,properties.len); | |
317 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
318 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
318 | pIdentifier = NULL; |
|
319 | pIdentifier = NULL; | |
319 | handleMutex->unlock(); |
|
320 | handleMutex->unlock(); | |
320 | RMAP_Answer* packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); |
|
321 | RMAP_Answer* packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); | |
321 | RMAP_AnswersMtx->lock(); |
|
322 | RMAP_AnswersMtx->lock(); | |
322 | RMAP_Answers.append(packet); |
|
323 | RMAP_Answers.append(packet); | |
323 | RMAP_AnswersMtx->unlock(); |
|
324 | RMAP_AnswersMtx->unlock(); | |
324 | RMAP_AnswersSem->release(); |
|
325 | RMAP_AnswersSem->release(); | |
325 |
|
326 | |||
326 | } |
|
327 | } | |
327 | else //it's a RMAP write response |
|
328 | else //it's a RMAP write response | |
328 | { |
|
329 | { | |
329 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
330 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
330 | pIdentifier = NULL; |
|
331 | pIdentifier = NULL; | |
331 | handleMutex->unlock(); |
|
332 | handleMutex->unlock(); | |
332 | } |
|
333 | } | |
333 |
|
334 | |||
334 | } |
|
335 | } | |
335 | else //any non-rmap packet will be pushed to the network |
|
336 | else //any non-rmap packet will be pushed to the network | |
336 | { |
|
337 | { | |
337 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
338 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
338 | handleMutex->unlock(); |
|
339 | handleMutex->unlock(); | |
339 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); |
|
340 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); | |
340 | } |
|
341 | } | |
341 | } |
|
342 | } | |
342 | else |
|
343 | else | |
343 | { |
|
344 | { | |
344 | SocExplorerEngine::message(this->plugin,"No EOP received",2); |
|
345 | SocExplorerEngine::message(this->plugin,"No EOP received",2); | |
345 | } |
|
346 | } | |
346 | } |
|
347 | } | |
347 |
|
348 | |||
348 | } |
|
349 | } | |
349 | else |
|
350 | else | |
350 | { |
|
351 | { | |
351 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
352 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
352 | handleMutex->unlock(); |
|
353 | handleMutex->unlock(); | |
353 | } |
|
354 | } | |
354 | } |
|
355 | } | |
355 | else |
|
356 | else | |
356 | { |
|
357 | { | |
357 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
358 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
358 | handleMutex->unlock(); |
|
359 | handleMutex->unlock(); | |
359 | } |
|
360 | } | |
360 | } |
|
361 | } | |
361 | else |
|
362 | else | |
362 | { |
|
363 | { | |
363 | sleep(1); |
|
364 | //do some sanity checks! | |
364 | int list = USBSpaceWire_ListDevices(); |
|
365 | int list = USBSpaceWire_ListDevices(); | |
365 | if(this->brickList!=list) |
|
366 | if(this->brickList!=list) | |
366 | { |
|
367 | { | |
367 | this->brickList = list; |
|
368 | this->brickList = list; | |
368 | emit updateAvailableBrickCount(this->brickList); |
|
369 | emit updateAvailableBrickCount(this->brickList); | |
369 | } |
|
370 | } | |
|
371 | sleep(1); | |||
370 | } |
|
372 | } | |
371 | usleep(1000); |
|
373 | usleep(1000); | |
372 | } |
|
374 | } | |
373 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); |
|
375 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); | |
374 | } |
|
376 | } | |
375 |
|
377 | |||
376 | bool stardundeeSPW_USB_Manager::connectBridge() |
|
378 | bool stardundeeSPW_USB_Manager::connectBridge() | |
377 | { |
|
379 | { | |
378 | QMutexLocker mlock(this->handleMutex); |
|
380 | QMutexLocker mlock(this->handleMutex); | |
379 | int status; |
|
381 | int status; | |
380 | U32 statusControl; |
|
382 | U32 statusControl; | |
381 | this->connected = false; |
|
383 | this->connected = false; | |
382 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
384 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |
383 | { |
|
385 | { | |
384 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); |
|
386 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); | |
385 | return false; |
|
387 | return false; | |
386 | } |
|
388 | } | |
387 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); |
|
389 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); | |
388 |
|
390 | |||
389 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
391 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
390 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
392 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
391 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
393 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
392 |
|
394 | |||
393 | // Set the path and return path to the device |
|
395 | // Set the path and return path to the device | |
394 | CFGSpaceWire_StackClear(); |
|
396 | CFGSpaceWire_StackClear(); | |
395 | CFGSpaceWire_AddrStackPush(0); |
|
397 | CFGSpaceWire_AddrStackPush(0); | |
396 | CFGSpaceWire_AddrStackPush(254); |
|
398 | CFGSpaceWire_AddrStackPush(254); | |
397 | CFGSpaceWire_RetAddrStackPush(254); |
|
399 | CFGSpaceWire_RetAddrStackPush(254); | |
398 | // set the base transmit rate to 100 MHz |
|
400 | // set the base transmit rate to 100 MHz | |
399 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
401 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
400 | if (status != CFG_TRANSFER_SUCCESS) |
|
402 | if (status != CFG_TRANSFER_SUCCESS) | |
401 | { |
|
403 | { | |
402 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); |
|
404 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); | |
403 | return false; |
|
405 | return false; | |
404 | } |
|
406 | } | |
405 | else |
|
407 | else | |
406 | { |
|
408 | { | |
407 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); |
|
409 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); | |
408 | } |
|
410 | } | |
409 |
|
411 | |||
410 | // read the link status |
|
412 | // read the link status | |
411 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
413 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
412 | { |
|
414 | { | |
413 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); |
|
415 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); | |
414 | return false; |
|
416 | return false; | |
415 | } |
|
417 | } | |
416 | else |
|
418 | else | |
417 | { |
|
419 | { | |
418 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); |
|
420 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); | |
419 |
|
421 | |||
420 | // Set the link status control register properties |
|
422 | // Set the link status control register properties | |
421 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
423 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
422 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
424 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
423 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
425 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
424 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
426 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
425 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
427 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
426 |
|
428 | |||
427 | // Set the link status control register |
|
429 | // Set the link status control register | |
428 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
430 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
429 | { |
|
431 | { | |
430 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); |
|
432 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); | |
431 | return false; |
|
433 | return false; | |
432 | } |
|
434 | } | |
433 | else |
|
435 | else | |
434 | { |
|
436 | { | |
435 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); |
|
437 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); | |
436 | } |
|
438 | } | |
437 | } |
|
439 | } | |
438 |
|
440 | |||
439 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) |
|
441 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) | |
440 | { |
|
442 | { | |
441 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); |
|
443 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); | |
442 | return false; |
|
444 | return false; | |
443 | } |
|
445 | } | |
444 | else |
|
446 | else | |
445 | { |
|
447 | { | |
446 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); |
|
448 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); | |
447 | } |
|
449 | } | |
448 |
|
450 | |||
449 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports |
|
451 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports | |
450 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
452 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
451 | USBSpaceWire_SetTimeout(hDevice,1.0); |
|
453 | USBSpaceWire_SetTimeout(hDevice,1.0); | |
452 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); |
|
454 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); | |
453 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); |
|
455 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); | |
454 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); |
|
456 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); | |
455 | this->connected = true; |
|
457 | this->connected = true; | |
456 | return true; |
|
458 | return true; | |
457 | } |
|
459 | } | |
458 |
|
460 | |||
459 | bool stardundeeSPW_USB_Manager::disconnectBridge() |
|
461 | bool stardundeeSPW_USB_Manager::disconnectBridge() | |
460 | { |
|
462 | { | |
461 | this->handleMutex->lock(); |
|
463 | this->handleMutex->lock(); | |
462 | USBSpaceWire_Close(hDevice); // Close the device |
|
464 | USBSpaceWire_Close(hDevice); // Close the device | |
463 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); |
|
465 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); | |
464 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports |
|
466 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports | |
465 | this->handleMutex->unlock(); |
|
467 | this->handleMutex->unlock(); | |
466 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
468 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
467 | this->RMAP_pending_transaction_IDs.clear(); |
|
469 | this->RMAP_pending_transaction_IDs.clear(); | |
468 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
470 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
469 | this->RMAP_AnswersMtx->lock(); |
|
471 | this->RMAP_AnswersMtx->lock(); | |
470 | this->RMAP_Answers.clear(); |
|
472 | this->RMAP_Answers.clear(); | |
471 | this->RMAP_AnswersMtx->unlock(); |
|
473 | this->RMAP_AnswersMtx->unlock(); | |
472 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); |
|
474 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); | |
473 | return true; |
|
475 | return true; | |
474 | } |
|
476 | } | |
475 |
|
477 | |||
476 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() |
|
478 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() | |
477 | { |
|
479 | { | |
478 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
480 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
479 | int ID=0; |
|
481 | int ID=0; | |
480 | bool found=true; |
|
482 | bool found=true; | |
481 | while(ID<511) |
|
483 | while(ID<511) | |
482 | { |
|
484 | { | |
483 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) |
|
485 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) | |
484 | { |
|
486 | { | |
485 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; |
|
487 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; | |
486 | } |
|
488 | } | |
487 | if(found==true)break; |
|
489 | if(found==true)break; | |
488 | ID++; |
|
490 | ID++; | |
489 | found = true; |
|
491 | found = true; | |
490 | } |
|
492 | } | |
491 | if(found) |
|
493 | if(found) | |
492 | { |
|
494 | { | |
493 | RMAP_pending_transaction_IDs.append(ID); |
|
495 | RMAP_pending_transaction_IDs.append(ID); | |
494 | } |
|
496 | } | |
495 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
497 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
496 | return ID; |
|
498 | return ID; | |
497 | } |
|
499 | } | |
498 |
|
500 | |||
499 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) |
|
501 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) | |
500 | { |
|
502 | { | |
501 | QTime timeout; |
|
503 | QTime timeout; | |
502 | *buffer=NULL; |
|
504 | *buffer=NULL; | |
503 | int count=0; |
|
505 | int count=0; | |
504 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); |
|
506 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); | |
505 | timeout.start(); |
|
507 | timeout.start(); | |
506 | while (*buffer==NULL) |
|
508 | while (*buffer==NULL) | |
507 | { |
|
509 | { | |
508 | this->RMAP_AnswersMtx->lock(); |
|
510 | this->RMAP_AnswersMtx->lock(); | |
509 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); |
|
511 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); | |
510 | SocExplorerEngine::message(this->plugin,QString("%2 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); |
|
512 | SocExplorerEngine::message(this->plugin,QString("%2 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); | |
511 | for(int i=0;i<RMAP_Answers.count();i++) |
|
513 | for(int i=0;i<RMAP_Answers.count();i++) | |
512 | { |
|
514 | { | |
513 | if(RMAP_Answers[i]->transactionID==transactionID) |
|
515 | if(RMAP_Answers[i]->transactionID==transactionID) | |
514 | { |
|
516 | { | |
515 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
517 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
516 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); |
|
518 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); | |
517 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) |
|
519 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) | |
518 | { |
|
520 | { | |
519 | if(RMAP_pending_transaction_IDs[j]==transactionID) |
|
521 | if(RMAP_pending_transaction_IDs[j]==transactionID) | |
520 | { |
|
522 | { | |
521 | RMAP_pending_transaction_IDs.removeAt(j); |
|
523 | RMAP_pending_transaction_IDs.removeAt(j); | |
522 | } |
|
524 | } | |
523 | } |
|
525 | } | |
524 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
526 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
525 | *buffer = RMAP_Answers[i]->data; |
|
527 | *buffer = RMAP_Answers[i]->data; | |
526 | count = RMAP_Answers[i]->len; |
|
528 | count = RMAP_Answers[i]->len; | |
527 | RMAP_Answer* tmp=RMAP_Answers[i]; |
|
529 | RMAP_Answer* tmp=RMAP_Answers[i]; | |
528 | RMAP_Answers.removeAt(i); |
|
530 | RMAP_Answers.removeAt(i); | |
529 | delete tmp; |
|
531 | delete tmp; | |
530 | } |
|
532 | } | |
531 | } |
|
533 | } | |
532 | this->RMAP_AnswersMtx->unlock(); |
|
534 | this->RMAP_AnswersMtx->unlock(); | |
533 | //if no answer found in the stack wait until a new packet is pushed |
|
535 | //if no answer found in the stack wait until a new packet is pushed | |
534 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); |
|
536 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); | |
535 | if(*buffer==NULL) |
|
537 | if(*buffer==NULL) | |
536 | { |
|
538 | { | |
537 | while (0==this->RMAP_AnswersSem->available()) |
|
539 | while (0==this->RMAP_AnswersSem->available()) | |
538 | { |
|
540 | { | |
539 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); |
|
541 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); | |
540 | if(timeout.elapsed()>=RMAPtimeout) |
|
542 | if(timeout.elapsed()>=RMAPtimeout) | |
541 | { |
|
543 | { | |
542 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); |
|
544 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); | |
543 | return -1; |
|
545 | return -1; | |
544 | } |
|
546 | } | |
545 | usleep(1000); |
|
547 | usleep(1000); | |
546 | } |
|
548 | } | |
547 | this->RMAP_AnswersSem->acquire(); |
|
549 | this->RMAP_AnswersSem->acquire(); | |
548 | } |
|
550 | } | |
549 | } |
|
551 | } | |
550 | return count; |
|
552 | return count; | |
551 | } |
|
553 | } | |
552 |
|
554 | |||
553 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) |
|
555 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) | |
554 | { |
|
556 | { | |
555 | USB_SPACEWIRE_STATUS result; |
|
557 | USB_SPACEWIRE_STATUS result; | |
556 | USB_SPACEWIRE_ID pIdentifier; |
|
558 | USB_SPACEWIRE_ID pIdentifier; | |
557 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); |
|
559 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); | |
558 | this->handleMutex->lock(); |
|
560 | this->handleMutex->lock(); | |
559 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); |
|
561 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); | |
560 | if (result != TRANSFER_SUCCESS) |
|
562 | if (result != TRANSFER_SUCCESS) | |
561 | { |
|
563 | { | |
562 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); |
|
564 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); | |
563 | this->handleMutex->unlock(); |
|
565 | this->handleMutex->unlock(); | |
564 | return false; |
|
566 | return false; | |
565 | } |
|
567 | } | |
566 | else |
|
568 | else | |
567 | { |
|
569 | { | |
568 | SocExplorerEngine::message(this->plugin,"Packet sent",2); |
|
570 | SocExplorerEngine::message(this->plugin,"Packet sent",2); | |
569 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
571 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
570 | } |
|
572 | } | |
571 | this->handleMutex->unlock(); |
|
573 | this->handleMutex->unlock(); | |
572 | return true; |
|
574 | return true; | |
573 | } |
|
575 | } | |
574 |
|
576 | |||
575 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) |
|
577 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) | |
576 | { |
|
578 | { | |
577 | char* packetbuffer = (char*)malloc(len); |
|
579 | char* packetbuffer = (char*)malloc(len); | |
578 | memcpy(packetbuffer,packet,len); |
|
580 | memcpy(packetbuffer,packet,len); | |
579 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); |
|
581 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); | |
580 | RMAP_AnswersMtx->lock(); |
|
582 | RMAP_AnswersMtx->lock(); | |
581 | RMAP_Answers.append(RMPAPpacket); |
|
583 | RMAP_Answers.append(RMPAPpacket); | |
582 | RMAP_AnswersMtx->unlock(); |
|
584 | RMAP_AnswersMtx->unlock(); | |
583 | } |
|
585 | } | |
584 |
|
586 | |||
585 |
|
587 | |||
586 |
|
588 | |||
587 |
|
589 | |||
588 |
|
590 | |||
589 |
|
591 | |||
590 |
|
592 | |||
591 |
|
593 | |||
592 |
|
594 | |||
593 |
|
595 | |||
594 |
|
596 | |||
595 |
|
597 | |||
596 |
|
598 | |||
597 |
|
599 | |||
598 |
|
600 | |||
599 |
|
601 | |||
600 |
|
602 | |||
601 |
|
603 | |||
602 |
|
604 | |||
603 |
|
605 | |||
604 |
|
606 | |||
605 |
|
607 |
General Comments 0
You need to be logged in to leave comments.
Login now