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