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