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