|
@@
-1,1074
+1,1088
|
|
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
|
connect(this->manager, SIGNAL(ccsdsPacketTransmittedToSpw()), this, SIGNAL(CCSDSPacketTransmittedToSpw()));
|
|
47
|
}
|
|
47
|
}
|
|
48
|
|
|
48
|
|
|
49
|
stardundeeSPW_USB::~stardundeeSPW_USB()
|
|
49
|
stardundeeSPW_USB::~stardundeeSPW_USB()
|
|
50
|
{
|
|
50
|
{
|
|
51
|
this->manager->requestInterruption();
|
|
51
|
this->manager->requestInterruption();
|
|
52
|
while(this->manager->isRunning());
|
|
52
|
while(this->manager->isRunning());
|
|
53
|
}
|
|
53
|
}
|
|
54
|
|
|
54
|
|
|
55
|
void stardundeeSPW_USB::toggleBridgeConnection()
|
|
55
|
void stardundeeSPW_USB::toggleBridgeConnection()
|
|
56
|
{
|
|
56
|
{
|
|
57
|
if(this->plugin->isConnected())
|
|
57
|
if(this->plugin->isConnected())
|
|
58
|
{
|
|
58
|
{
|
|
59
|
this->disconnectBridge();
|
|
59
|
this->disconnectBridge();
|
|
60
|
}
|
|
60
|
}
|
|
61
|
else
|
|
61
|
else
|
|
62
|
{
|
|
62
|
{
|
|
63
|
this->connectBridge();
|
|
63
|
this->connectBridge();
|
|
64
|
}
|
|
64
|
}
|
|
65
|
}
|
|
65
|
}
|
|
66
|
|
|
66
|
|
|
67
|
bool stardundeeSPW_USB::connectBridge()
|
|
67
|
bool stardundeeSPW_USB::connectBridge()
|
|
68
|
{
|
|
68
|
{
|
|
69
|
if(this->manager->connectBridge())
|
|
69
|
if(this->manager->connectBridge())
|
|
70
|
{
|
|
70
|
{
|
|
71
|
this->timecodeFrequencyChanged( ((StarDundeeGUI*)this->p_GUI)->getTimecodeFrequency());
|
|
71
|
this->timecodeFrequencyChanged( ((StarDundeeGUI*)this->p_GUI)->getTimecodeFrequency());
|
|
72
|
this->startSendingTimecodes( ((StarDundeeGUI*)this->p_GUI)->getStartSendingTimecodes());
|
|
72
|
this->startSendingTimecodes( ((StarDundeeGUI*)this->p_GUI)->getStartSendingTimecodes());
|
|
73
|
((StarDundeeGUI*)this->p_GUI)->lock(true);
|
|
73
|
((StarDundeeGUI*)this->p_GUI)->lock(true);
|
|
74
|
emit setConnected(true);
|
|
74
|
emit setConnected(true);
|
|
75
|
return true;
|
|
75
|
return true;
|
|
76
|
}
|
|
76
|
}
|
|
77
|
return false;
|
|
77
|
return false;
|
|
78
|
}
|
|
78
|
}
|
|
79
|
|
|
79
|
|
|
80
|
bool stardundeeSPW_USB::disconnectBridge()
|
|
80
|
bool stardundeeSPW_USB::disconnectBridge()
|
|
81
|
{
|
|
81
|
{
|
|
82
|
if(this->manager->disconnectBridge())
|
|
82
|
if(this->manager->disconnectBridge())
|
|
83
|
{
|
|
83
|
{
|
|
84
|
((StarDundeeGUI*)this->p_GUI)->lock(false);
|
|
84
|
((StarDundeeGUI*)this->p_GUI)->lock(false);
|
|
85
|
emit setConnected(false);
|
|
85
|
emit setConnected(false);
|
|
86
|
return true;
|
|
86
|
return true;
|
|
87
|
}
|
|
87
|
}
|
|
88
|
return false;
|
|
88
|
return false;
|
|
89
|
}
|
|
89
|
}
|
|
90
|
|
|
90
|
|
|
91
|
|
|
|
|
|
92
|
int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size)
|
|
91
|
int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size)
|
|
93
|
{
|
|
92
|
{
|
|
94
|
return this->manager->sendPacket(packet,size);
|
|
93
|
return this->manager->sendPacket(packet,size);
|
|
95
|
}
|
|
94
|
}
|
|
96
|
|
|
95
|
|
|
97
|
unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address)
|
|
96
|
unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address)
|
|
98
|
{
|
|
97
|
{
|
|
99
|
char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1];
|
|
98
|
char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1];
|
|
100
|
char *RMAPAckBuff;
|
|
99
|
char *RMAPAckBuff;
|
|
101
|
writeBuffer[0]=this->manager->linkNumber;//Link number
|
|
100
|
writeBuffer[0]=this->manager->linkNumber;//Link number
|
|
102
|
int transactionID = 0;
|
|
101
|
int transactionID = 0;
|
|
103
|
int written=0;
|
|
102
|
int written=0;
|
|
104
|
SocExplorerEngine::message(this->plugin,"Enter Write function",2);
|
|
103
|
SocExplorerEngine::message(this->plugin,"Enter Write function",2);
|
|
105
|
QProgressBar* progress=NULL;
|
|
104
|
QProgressBar* progress=NULL;
|
|
106
|
SocExplorerAutoProgressBar autopb;
|
|
105
|
SocExplorerAutoProgressBar autopb;
|
|
107
|
if(count>RMAP_MAX_XFER_SIZE)
|
|
106
|
if(count>RMAP_MAX_XFER_SIZE)
|
|
108
|
{
|
|
107
|
{
|
|
109
|
progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
|
|
108
|
progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
|
|
110
|
autopb.setProgressBar(progress);
|
|
109
|
autopb.setProgressBar(progress);
|
|
111
|
}
|
|
110
|
}
|
|
112
|
//Quite stupide loop, I guess that I always get the number of byte I asked for!
|
|
111
|
//Quite stupide loop, I guess that I always get the number of byte I asked for!
|
|
113
|
while(count>=RMAP_MAX_XFER_SIZE)
|
|
112
|
while(count>=RMAP_MAX_XFER_SIZE)
|
|
114
|
{
|
|
113
|
{
|
|
115
|
for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++)
|
|
114
|
for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++)
|
|
116
|
{
|
|
115
|
{
|
|
117
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF);
|
|
116
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF);
|
|
118
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF);
|
|
117
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF);
|
|
119
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
|
|
118
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
|
|
120
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
|
|
119
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
|
|
121
|
}
|
|
120
|
}
|
|
122
|
transactionID=manager->getRMAPtransactionID();
|
|
121
|
transactionID=manager->getRMAPtransactionID();
|
|
123
|
SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2);
|
|
122
|
SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2);
|
|
124
|
RMAP_build_tx_request_header(
|
|
123
|
RMAP_build_tx_request_header(
|
|
125
|
this->manager->destinationLogicalAddress,
|
|
124
|
this->manager->destinationLogicalAddress,
|
|
126
|
this->manager->destinationKey,
|
|
125
|
this->manager->destinationKey,
|
|
127
|
this->manager->sourceLogicalAddress,
|
|
126
|
this->manager->sourceLogicalAddress,
|
|
128
|
transactionID,
|
|
127
|
transactionID,
|
|
129
|
address+(written*4),
|
|
128
|
address+(written*4),
|
|
130
|
RMAP_MAX_XFER_SIZE*4,
|
|
129
|
RMAP_MAX_XFER_SIZE*4,
|
|
131
|
writeBuffer+1);
|
|
130
|
writeBuffer+1);
|
|
132
|
manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1);
|
|
131
|
manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1);
|
|
133
|
manager->getRMAPanswer(transactionID,&RMAPAckBuff);
|
|
132
|
manager->getRMAPanswer(transactionID,&RMAPAckBuff);
|
|
134
|
free(RMAPAckBuff);
|
|
133
|
free(RMAPAckBuff);
|
|
135
|
written+=RMAP_MAX_XFER_SIZE;
|
|
134
|
written+=RMAP_MAX_XFER_SIZE;
|
|
136
|
count-=RMAP_MAX_XFER_SIZE;
|
|
135
|
count-=RMAP_MAX_XFER_SIZE;
|
|
137
|
progress->setValue(written);
|
|
136
|
progress->setValue(written);
|
|
138
|
qApp->processEvents();
|
|
137
|
qApp->processEvents();
|
|
139
|
}
|
|
138
|
}
|
|
140
|
if(count>0)
|
|
139
|
if(count>0)
|
|
141
|
{
|
|
140
|
{
|
|
142
|
for(int i=0;i<((int)count);i++)
|
|
141
|
for(int i=0;i<((int)count);i++)
|
|
143
|
{
|
|
142
|
{
|
|
144
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF);
|
|
143
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF);
|
|
145
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF);
|
|
144
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF);
|
|
146
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
|
|
145
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
|
|
147
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
|
|
146
|
writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
|
|
148
|
}
|
|
147
|
}
|
|
149
|
transactionID=manager->getRMAPtransactionID();
|
|
148
|
transactionID=manager->getRMAPtransactionID();
|
|
150
|
SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2);
|
|
149
|
SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2);
|
|
151
|
RMAP_build_tx_request_header(
|
|
150
|
RMAP_build_tx_request_header(
|
|
152
|
this->manager->destinationLogicalAddress,
|
|
151
|
this->manager->destinationLogicalAddress,
|
|
153
|
this->manager->destinationKey,
|
|
152
|
this->manager->destinationKey,
|
|
154
|
this->manager->sourceLogicalAddress,
|
|
153
|
this->manager->sourceLogicalAddress,
|
|
155
|
transactionID,
|
|
154
|
transactionID,
|
|
156
|
address+(written*4),
|
|
155
|
address+(written*4),
|
|
157
|
count*4,
|
|
156
|
count*4,
|
|
158
|
writeBuffer+1);
|
|
157
|
writeBuffer+1);
|
|
159
|
manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1);
|
|
158
|
manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1);
|
|
160
|
manager->getRMAPanswer(transactionID,&RMAPAckBuff);
|
|
159
|
manager->getRMAPanswer(transactionID,&RMAPAckBuff);
|
|
161
|
free(RMAPAckBuff);
|
|
160
|
free(RMAPAckBuff);
|
|
162
|
written+=count;
|
|
161
|
written+=count;
|
|
163
|
if(progress!=NULL)
|
|
162
|
if(progress!=NULL)
|
|
164
|
{
|
|
163
|
{
|
|
165
|
progress->setValue(written);
|
|
164
|
progress->setValue(written);
|
|
166
|
qApp->processEvents();
|
|
165
|
qApp->processEvents();
|
|
167
|
}
|
|
166
|
}
|
|
168
|
}
|
|
167
|
}
|
|
169
|
return written;
|
|
168
|
return written;
|
|
170
|
}
|
|
169
|
}
|
|
171
|
|
|
170
|
|
|
172
|
unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address)
|
|
171
|
unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address)
|
|
173
|
{
|
|
172
|
{
|
|
174
|
char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1];
|
|
173
|
char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1];
|
|
175
|
char* RMAP_AnswerBuffer;
|
|
174
|
char* RMAP_AnswerBuffer;
|
|
176
|
requestBuffer[0]=this->manager->linkNumber;//Link number
|
|
175
|
requestBuffer[0]=this->manager->linkNumber;//Link number
|
|
177
|
int transactionID = 0;
|
|
176
|
int transactionID = 0;
|
|
178
|
int read=0;
|
|
177
|
int read=0;
|
|
179
|
QProgressBar* progress=NULL;
|
|
178
|
QProgressBar* progress=NULL;
|
|
180
|
SocExplorerAutoProgressBar autopb;
|
|
179
|
SocExplorerAutoProgressBar autopb;
|
|
181
|
if(count>RMAP_MAX_XFER_SIZE)
|
|
180
|
if(count>RMAP_MAX_XFER_SIZE)
|
|
182
|
{
|
|
181
|
{
|
|
183
|
progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
|
|
182
|
progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
|
|
184
|
autopb.setProgressBar(progress);
|
|
183
|
autopb.setProgressBar(progress);
|
|
185
|
}
|
|
184
|
}
|
|
186
|
SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2);
|
|
185
|
SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2);
|
|
187
|
|
|
186
|
|
|
188
|
//Quite stupide loop, I guess that I always get the number of byte I asked for!
|
|
187
|
//Quite stupide loop, I guess that I always get the number of byte I asked for!
|
|
189
|
while((int)count>=(int)RMAP_MAX_XFER_SIZE)
|
|
188
|
while((int)count>=(int)RMAP_MAX_XFER_SIZE)
|
|
190
|
{
|
|
189
|
{
|
|
191
|
transactionID = manager->getRMAPtransactionID();
|
|
190
|
transactionID = manager->getRMAPtransactionID();
|
|
192
|
SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2);
|
|
191
|
SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2);
|
|
193
|
RMAP_build_rx_request_header(
|
|
192
|
RMAP_build_rx_request_header(
|
|
194
|
this->manager->destinationLogicalAddress,
|
|
193
|
this->manager->destinationLogicalAddress,
|
|
195
|
this->manager->destinationKey,
|
|
194
|
this->manager->destinationKey,
|
|
196
|
this->manager->sourceLogicalAddress,
|
|
195
|
this->manager->sourceLogicalAddress,
|
|
197
|
transactionID,
|
|
196
|
transactionID,
|
|
198
|
address+(read*4),
|
|
197
|
address+(read*4),
|
|
199
|
RMAP_MAX_XFER_SIZE*4,
|
|
198
|
RMAP_MAX_XFER_SIZE*4,
|
|
200
|
requestBuffer+1);
|
|
199
|
requestBuffer+1);
|
|
201
|
manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1);
|
|
200
|
manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1);
|
|
202
|
int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
|
|
201
|
int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
|
|
203
|
if(len==-1)
|
|
202
|
if(len==-1)
|
|
204
|
{
|
|
203
|
{
|
|
205
|
this->toggleBridgeConnection();
|
|
204
|
this->toggleBridgeConnection();
|
|
206
|
return 0;
|
|
205
|
return 0;
|
|
207
|
}
|
|
206
|
}
|
|
208
|
for(int i=0;i<((len-13)/4);i++)
|
|
207
|
for(int i=0;i<((len-13)/4);i++)
|
|
209
|
{
|
|
208
|
{
|
|
210
|
Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
|
|
209
|
Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
|
|
211
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13]));
|
|
210
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13]));
|
|
212
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14]));
|
|
211
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14]));
|
|
213
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15]));
|
|
212
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15]));
|
|
214
|
}
|
|
213
|
}
|
|
215
|
free(RMAP_AnswerBuffer);
|
|
214
|
free(RMAP_AnswerBuffer);
|
|
216
|
read+=RMAP_MAX_XFER_SIZE;
|
|
215
|
read+=RMAP_MAX_XFER_SIZE;
|
|
217
|
count-=RMAP_MAX_XFER_SIZE;
|
|
216
|
count-=RMAP_MAX_XFER_SIZE;
|
|
218
|
progress->setValue(read);
|
|
217
|
progress->setValue(read);
|
|
219
|
qApp->processEvents();
|
|
218
|
qApp->processEvents();
|
|
220
|
}
|
|
219
|
}
|
|
221
|
if((int)count>0)
|
|
220
|
if((int)count>0)
|
|
222
|
{
|
|
221
|
{
|
|
223
|
transactionID = manager->getRMAPtransactionID();
|
|
222
|
transactionID = manager->getRMAPtransactionID();
|
|
224
|
SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2);
|
|
223
|
SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2);
|
|
225
|
SocExplorerEngine::message(this->plugin,QString("Building request with:"),2);
|
|
224
|
SocExplorerEngine::message(this->plugin,QString("Building request with:"),2);
|
|
226
|
SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2);
|
|
225
|
SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2);
|
|
227
|
SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2);
|
|
226
|
SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2);
|
|
228
|
SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2);
|
|
227
|
SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2);
|
|
229
|
RMAP_build_rx_request_header(
|
|
228
|
RMAP_build_rx_request_header(
|
|
230
|
this->manager->destinationLogicalAddress,
|
|
229
|
this->manager->destinationLogicalAddress,
|
|
231
|
this->manager->destinationKey,
|
|
230
|
this->manager->destinationKey,
|
|
232
|
this->manager->sourceLogicalAddress,
|
|
231
|
this->manager->sourceLogicalAddress,
|
|
233
|
transactionID,
|
|
232
|
transactionID,
|
|
234
|
address+(read*4),
|
|
233
|
address+(read*4),
|
|
235
|
count*4,
|
|
234
|
count*4,
|
|
236
|
requestBuffer+1);
|
|
235
|
requestBuffer+1);
|
|
237
|
manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1);
|
|
236
|
manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1);
|
|
238
|
int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
|
|
237
|
int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
|
|
239
|
if(len==-1)
|
|
238
|
if(len==-1)
|
|
240
|
{
|
|
239
|
{
|
|
241
|
this->toggleBridgeConnection();
|
|
240
|
this->toggleBridgeConnection();
|
|
242
|
return 0;
|
|
241
|
return 0;
|
|
243
|
}
|
|
242
|
}
|
|
244
|
for(int i=0;i<((len-13)/4);i++)
|
|
243
|
for(int i=0;i<((len-13)/4);i++)
|
|
245
|
{
|
|
244
|
{
|
|
246
|
Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
|
|
245
|
Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
|
|
247
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13]));
|
|
246
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13]));
|
|
248
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14]));
|
|
247
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14]));
|
|
249
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15]));
|
|
248
|
Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15]));
|
|
250
|
}
|
|
249
|
}
|
|
251
|
free(RMAP_AnswerBuffer);
|
|
250
|
free(RMAP_AnswerBuffer);
|
|
252
|
read+=count;
|
|
251
|
read+=count;
|
|
253
|
if(progress!=NULL)
|
|
252
|
if(progress!=NULL)
|
|
254
|
{
|
|
253
|
{
|
|
255
|
progress->setValue(read);
|
|
254
|
progress->setValue(read);
|
|
256
|
qApp->processEvents();
|
|
255
|
qApp->processEvents();
|
|
257
|
}
|
|
256
|
}
|
|
258
|
}
|
|
257
|
}
|
|
259
|
return read;
|
|
258
|
return read;
|
|
260
|
}
|
|
259
|
}
|
|
261
|
|
|
260
|
|
|
262
|
void stardundeeSPW_USB::brickSelectionChanged(int brickIndex)
|
|
261
|
void stardundeeSPW_USB::brickSelectionChanged(int brickIndex)
|
|
263
|
{
|
|
262
|
{
|
|
264
|
this->manager->selectedBrick = brickIndex-1;
|
|
263
|
this->manager->selectedBrick = brickIndex-1;
|
|
265
|
SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1);
|
|
264
|
SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1);
|
|
266
|
}
|
|
265
|
}
|
|
267
|
|
|
266
|
|
|
268
|
void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex)
|
|
267
|
void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex)
|
|
269
|
{
|
|
268
|
{
|
|
270
|
this->manager->linkNumber = linkIndex + 1;
|
|
269
|
this->manager->linkNumber = linkIndex + 1;
|
|
271
|
SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1);
|
|
270
|
SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1);
|
|
272
|
}
|
|
271
|
}
|
|
273
|
|
|
272
|
|
|
274
|
void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed)
|
|
273
|
void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed)
|
|
275
|
{
|
|
274
|
{
|
|
276
|
this->manager->linkSpeed = linkSpeed.toInt();
|
|
275
|
this->manager->linkSpeed = linkSpeed.toInt();
|
|
277
|
|
|
276
|
|
|
278
|
SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1);
|
|
277
|
SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1);
|
|
279
|
}
|
|
278
|
}
|
|
280
|
|
|
279
|
|
|
281
|
void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress)
|
|
280
|
void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress)
|
|
282
|
{
|
|
281
|
{
|
|
283
|
this->manager->sourceLogicalAddress = sourceAddress.toInt();
|
|
282
|
this->manager->sourceLogicalAddress = sourceAddress.toInt();
|
|
284
|
SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1);
|
|
283
|
SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1);
|
|
285
|
}
|
|
284
|
}
|
|
286
|
|
|
285
|
|
|
287
|
void stardundeeSPW_USB::destinationAddressChanged(const QString &rmapaddress)
|
|
286
|
void stardundeeSPW_USB::destinationAddressChanged(const QString &rmapaddress)
|
|
288
|
{
|
|
287
|
{
|
|
289
|
this->manager->destinationLogicalAddress = rmapaddress.toInt();
|
|
288
|
this->manager->destinationLogicalAddress = rmapaddress.toInt();
|
|
290
|
SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1);
|
|
289
|
SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1);
|
|
291
|
}
|
|
290
|
}
|
|
292
|
|
|
291
|
|
|
293
|
void stardundeeSPW_USB::destinationKeyChanged(const QString &key)
|
|
292
|
void stardundeeSPW_USB::destinationKeyChanged(const QString &key)
|
|
294
|
{
|
|
293
|
{
|
|
295
|
this->manager->destinationKey = key.toInt();
|
|
294
|
this->manager->destinationKey = key.toInt();
|
|
296
|
SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1);
|
|
295
|
SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1);
|
|
297
|
}
|
|
296
|
}
|
|
298
|
|
|
297
|
|
|
299
|
void stardundeeSPW_USB::brickModeChanged( bool interfaceMode )
|
|
298
|
void stardundeeSPW_USB::brickModeChanged( bool interfaceMode )
|
|
300
|
{
|
|
299
|
{
|
|
301
|
this->manager->interfaceMode = interfaceMode;
|
|
300
|
this->manager->interfaceMode = interfaceMode;
|
|
302
|
}
|
|
301
|
}
|
|
303
|
|
|
302
|
|
|
304
|
void stardundeeSPW_USB::timecodeFrequencyChanged(const QString &frequency)
|
|
303
|
void stardundeeSPW_USB::timecodeFrequencyChanged(const QString &frequency)
|
|
305
|
{
|
|
304
|
{
|
|
306
|
this->manager->timecodeFrequency = frequency.toDouble();
|
|
305
|
this->manager->timecodeFrequency = frequency.toDouble();
|
|
307
|
this->manager->setTimecodeFrequency( this->manager->timecodeFrequency);
|
|
306
|
this->manager->setTimecodeFrequency( this->manager->timecodeFrequency);
|
|
308
|
SocExplorerEngine::message(plugin,QString("Changing timecode frequency: %1").arg(manager->timecodeFrequency),1);
|
|
307
|
SocExplorerEngine::message(plugin,QString("Changing timecode frequency: %1").arg(manager->timecodeFrequency),1);
|
|
309
|
}
|
|
308
|
}
|
|
310
|
|
|
309
|
|
|
311
|
void stardundeeSPW_USB::startSendingTimecodes(bool onOff )
|
|
310
|
void stardundeeSPW_USB::startSendingTimecodes(bool onOff )
|
|
312
|
{
|
|
311
|
{
|
|
313
|
this->manager->sendTimecodePeriodically( onOff );
|
|
312
|
this->manager->sendTimecodePeriodically( onOff );
|
|
314
|
}
|
|
313
|
}
|
|
315
|
|
|
314
|
|
|
316
|
void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout)
|
|
315
|
void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout)
|
|
317
|
{
|
|
316
|
{
|
|
318
|
int tim=timeout.toInt();
|
|
317
|
int tim=timeout.toInt();
|
|
319
|
if(tim<50)
|
|
318
|
if(tim<50)
|
|
320
|
{
|
|
319
|
{
|
|
321
|
tim = 50;
|
|
320
|
tim = 50;
|
|
322
|
((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim));
|
|
321
|
((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim));
|
|
323
|
}
|
|
322
|
}
|
|
324
|
this->manager->RMAPtimeout = tim;
|
|
323
|
this->manager->RMAPtimeout = tim;
|
|
325
|
SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1);
|
|
324
|
SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1);
|
|
326
|
}
|
|
325
|
}
|
|
327
|
|
|
326
|
|
|
328
|
void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent)
|
|
327
|
void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent)
|
|
329
|
{
|
|
328
|
{
|
|
330
|
this->p_GUI = new StarDundeeGUI();
|
|
329
|
this->p_GUI = new StarDundeeGUI();
|
|
331
|
// this->mainLayout = new QGridLayout(this->p_GUI);
|
|
330
|
// this->mainLayout = new QGridLayout(this->p_GUI);
|
|
332
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection()));
|
|
331
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection()));
|
|
333
|
connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int)));
|
|
332
|
connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int)));
|
|
334
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int)));
|
|
333
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int)));
|
|
335
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int)));
|
|
334
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int)));
|
|
336
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString)));
|
|
335
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString)));
|
|
337
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString)));
|
|
336
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString)));
|
|
338
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(destinationAddressChanged(QString)));
|
|
337
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(destinationAddressChanged(QString)));
|
|
339
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString)));
|
|
338
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString)));
|
|
340
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString)));
|
|
339
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString)));
|
|
341
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool)));
|
|
340
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool)));
|
|
342
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(timecodeFrequencyChange(QString)), this, SLOT(timecodeFrequencyChanged(QString)));
|
|
341
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(timecodeFrequencyChange(QString)), this, SLOT(timecodeFrequencyChanged(QString)));
|
|
343
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(startSendingTimecode(bool)), this, SLOT(startSendingTimecodes(bool)));
|
|
342
|
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(startSendingTimecode(bool)), this, SLOT(startSendingTimecodes(bool)));
|
|
344
|
|
|
343
|
|
|
345
|
this->brickSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getBrickSelection());
|
|
344
|
this->brickSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getBrickSelection());
|
|
346
|
this->linkNumberSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection());
|
|
345
|
this->linkNumberSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection());
|
|
347
|
this->linkSpeedSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection());
|
|
346
|
this->linkSpeedSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection());
|
|
348
|
this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getSourceAddress());
|
|
347
|
this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getSourceAddress());
|
|
349
|
this->destinationAddressChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationAddress());
|
|
348
|
this->destinationAddressChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationAddress());
|
|
350
|
this->destinationKeyChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationKey());
|
|
349
|
this->destinationKeyChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationKey());
|
|
351
|
this->rmapTimeoutChanged( ((StarDundeeGUI*)this->p_GUI)->getRmapTimeout());
|
|
350
|
this->rmapTimeoutChanged( ((StarDundeeGUI*)this->p_GUI)->getRmapTimeout());
|
|
352
|
this->brickModeChanged( ((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface());
|
|
351
|
this->brickModeChanged( ((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface());
|
|
353
|
|
|
352
|
|
|
354
|
connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int)));
|
|
353
|
connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int)));
|
|
355
|
connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int)));
|
|
354
|
connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int)));
|
|
356
|
connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int)));
|
|
355
|
connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int)));
|
|
357
|
connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString)));
|
|
356
|
connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString)));
|
|
358
|
connect(this,SIGNAL(SetDestinationAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationAddress(QString)));
|
|
357
|
connect(this,SIGNAL(SetDestinationAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationAddress(QString)));
|
|
359
|
connect(this,SIGNAL(SetSourceAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setSourceAddress(QString)));
|
|
358
|
connect(this,SIGNAL(SetSourceAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setSourceAddress(QString)));
|
|
360
|
connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString)));
|
|
359
|
connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString)));
|
|
361
|
connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount()));
|
|
360
|
connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount()));
|
|
362
|
connect(this,SIGNAL(GetNbPacketsTransmittedToSpw()),((StarDundeeGUI*)this->p_GUI),SLOT(getNbPacketsTransmittedToSpw()));
|
|
361
|
connect(this,SIGNAL(GetNbPacketsTransmittedToSpw()),((StarDundeeGUI*)this->p_GUI),SLOT(getNbPacketsTransmittedToSpw()));
|
|
363
|
connect(this,SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()),
|
|
362
|
connect(this,SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()),
|
|
364
|
((StarDundeeGUI*)this->p_GUI),SLOT(getNbCCSDSPacketsTransmittedToSpw()));
|
|
363
|
((StarDundeeGUI*)this->p_GUI),SLOT(getNbCCSDSPacketsTransmittedToSpw()));
|
|
365
|
connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool)));
|
|
364
|
connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool)));
|
|
366
|
connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool)));
|
|
365
|
connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool)));
|
|
367
|
connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint)));
|
|
366
|
connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint)));
|
|
368
|
connect(this,SIGNAL(BytesTransmittedToSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint)));
|
|
367
|
connect(this,SIGNAL(BytesTransmittedToSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint)));
|
|
369
|
connect(this, SIGNAL(CCSDSPacketTransmittedToSpw()),((StarDundeeGUI*)this->p_GUI),SLOT(updateCCSDSPacketTransmittedToSpw()));
|
|
368
|
connect(this,SIGNAL(CCSDSPacketTransmittedToSpw()), ((StarDundeeGUI*)this->p_GUI),SLOT(updateCCSDSPacketTransmittedToSpw()));
|
|
370
|
connect(this,SIGNAL(SetTimecodeFrequency(double)), ((StarDundeeGUI*)this->p_GUI),SLOT(setTimecodeFrequency(QString)));
|
|
369
|
connect(this,SIGNAL(SetTimecodeFrequency(double)), ((StarDundeeGUI*)this->p_GUI),SLOT(setTimecodeFrequency(QString)));
|
|
371
|
connect(this,SIGNAL(StartSendingTimecodes(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setStartSendingTimecodes(bool)));
|
|
370
|
connect(this,SIGNAL(StartSendingTimecodes(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setStartSendingTimecodes(bool)));
|
|
372
|
|
|
371
|
|
|
373
|
connect(this,SIGNAL(GetLinkNumber()), this->manager, SLOT(getLinkNumber()));
|
|
372
|
connect(this,SIGNAL(SendOneTimecode(unsigned char)),this->manager, SLOT(sendOneTimecode(unsigned char)));
|
|
|
|
|
373
|
connect(this,SIGNAL(GetLinkNumber()), this->manager, SLOT(getLinkNumber()));
|
|
374
|
}
|
|
374
|
}
|
|
375
|
|
|
375
|
|
|
376
|
void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size)
|
|
376
|
void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size)
|
|
377
|
{
|
|
377
|
{
|
|
378
|
char* data;
|
|
378
|
char* data;
|
|
379
|
int i;
|
|
379
|
int i;
|
|
380
|
|
|
380
|
|
|
381
|
data = (char *) malloc( size + 5 );
|
|
381
|
data = (char *) malloc( size + 5 );
|
|
382
|
|
|
382
|
|
|
383
|
data[0] = this->manager->linkNumber;
|
|
383
|
data[0] = this->manager->linkNumber;
|
|
384
|
data[1] = this->manager->destinationLogicalAddress; // target logical address
|
|
384
|
data[1] = this->manager->destinationLogicalAddress; // target logical address
|
|
385
|
data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier
|
|
385
|
data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier
|
|
386
|
data[3] = 0x00; // reserved
|
|
386
|
data[3] = 0x00; // reserved
|
|
387
|
data[4] = 0x00; // user application
|
|
387
|
data[4] = 0x00; // user application
|
|
388
|
|
|
388
|
|
|
389
|
for ( i=0; i<size; i++ )
|
|
389
|
for ( i=0; i<size; i++ )
|
|
390
|
{
|
|
390
|
{
|
|
391
|
data[i+5] = packet[i];
|
|
391
|
data[i+5] = packet[i];
|
|
392
|
}
|
|
392
|
}
|
|
393
|
|
|
393
|
|
|
394
|
this->manager->sendPacket( data, size + 5);
|
|
394
|
this->manager->sendPacket( data, size + 5);
|
|
395
|
|
|
395
|
|
|
396
|
free(data);
|
|
396
|
free(data);
|
|
397
|
free(packet);
|
|
397
|
free(packet);
|
|
398
|
}
|
|
398
|
}
|
|
399
|
|
|
399
|
|
|
400
|
stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent)
|
|
400
|
stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent)
|
|
401
|
:QThread((QObject*)parent)
|
|
401
|
:QThread((QObject*)parent)
|
|
402
|
{
|
|
402
|
{
|
|
403
|
this->RMAPtimeout = 2000;
|
|
403
|
this->RMAPtimeout = 2000;
|
|
404
|
this->handleMutex = new QMutex(QMutex::NonRecursive);
|
|
404
|
this->handleMutex = new QMutex(QMutex::NonRecursive);
|
|
405
|
this->RMAP_AnswersSem = new QSemaphore(0);
|
|
405
|
this->RMAP_AnswersSem = new QSemaphore(0);
|
|
406
|
this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
|
|
406
|
this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
|
|
407
|
this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
|
|
407
|
this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
|
|
408
|
this->plugin = plugin;
|
|
408
|
this->plugin = plugin;
|
|
409
|
connected = false;
|
|
409
|
connected = false;
|
|
410
|
this->moveToThread(this);
|
|
410
|
this->moveToThread(this);
|
|
411
|
}
|
|
411
|
}
|
|
412
|
|
|
412
|
|
|
413
|
stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager()
|
|
413
|
stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager()
|
|
414
|
{
|
|
414
|
{
|
|
415
|
this->terminate();
|
|
415
|
this->terminate();
|
|
416
|
while (!this->isFinished()) {
|
|
416
|
while (!this->isFinished()) {
|
|
417
|
this->usleep(1000);
|
|
417
|
this->usleep(1000);
|
|
418
|
}
|
|
418
|
}
|
|
419
|
}
|
|
419
|
}
|
|
420
|
|
|
420
|
|
|
421
|
void stardundeeSPW_USB_Manager::run()
|
|
421
|
void stardundeeSPW_USB_Manager::run()
|
|
422
|
{
|
|
422
|
{
|
|
423
|
USB_SPACEWIRE_PACKET_PROPERTIES properties;
|
|
423
|
USB_SPACEWIRE_PACKET_PROPERTIES properties;
|
|
424
|
USB_SPACEWIRE_ID pIdentifier=NULL;
|
|
424
|
USB_SPACEWIRE_ID pIdentifier=NULL;
|
|
425
|
USB_SPACEWIRE_STATUS stat;
|
|
425
|
USB_SPACEWIRE_STATUS stat;
|
|
426
|
SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1);
|
|
426
|
SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1);
|
|
427
|
char buffer[(RMAP_MAX_XFER_SIZE*4)+50];
|
|
427
|
char buffer[(RMAP_MAX_XFER_SIZE*4)+50];
|
|
428
|
while (!this->isInterruptionRequested())
|
|
428
|
while (!this->isInterruptionRequested())
|
|
429
|
{
|
|
429
|
{
|
|
430
|
if(this->connected)
|
|
430
|
if(this->connected)
|
|
431
|
{
|
|
431
|
{
|
|
432
|
handleMutex->lock();
|
|
432
|
handleMutex->lock();
|
|
433
|
SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4);
|
|
433
|
SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4);
|
|
434
|
if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01))
|
|
434
|
if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01))
|
|
435
|
{
|
|
435
|
{
|
|
436
|
SocExplorerEngine::message(this->plugin,"Got packet",2);
|
|
436
|
SocExplorerEngine::message(this->plugin,"Got packet",2);
|
|
437
|
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);
|
|
438
|
if (stat == TRANSFER_SUCCESS)
|
|
438
|
if (stat == TRANSFER_SUCCESS)
|
|
439
|
{
|
|
439
|
{
|
|
440
|
if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET)
|
|
440
|
if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET)
|
|
441
|
{
|
|
441
|
{
|
|
442
|
SocExplorerEngine::message(this->plugin,"It's a SPW packet",2);
|
|
442
|
SocExplorerEngine::message(this->plugin,"It's a SPW packet",2);
|
|
443
|
if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP)
|
|
443
|
if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP)
|
|
444
|
{
|
|
444
|
{
|
|
445
|
SocExplorerEngine::message(this->plugin,"Got end of packet",2);
|
|
445
|
SocExplorerEngine::message(this->plugin,"Got end of packet",2);
|
|
446
|
emit bytesReceivedFromSpw( properties.len );
|
|
446
|
emit bytesReceivedFromSpw( properties.len );
|
|
447
|
if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet
|
|
447
|
if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet
|
|
448
|
{
|
|
448
|
{
|
|
449
|
RMAP_Answer* packet;
|
|
449
|
RMAP_Answer* packet;
|
|
450
|
SocExplorerEngine::message(this->plugin,"Got RMAP packet",2);
|
|
450
|
SocExplorerEngine::message(this->plugin,"Got RMAP packet",2);
|
|
451
|
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);
|
|
452
|
char* packetbuffer = (char*)malloc(properties.len);
|
|
452
|
char* packetbuffer = (char*)malloc(properties.len);
|
|
453
|
memcpy(packetbuffer,buffer,properties.len);
|
|
453
|
memcpy(packetbuffer,buffer,properties.len);
|
|
454
|
USBSpaceWire_FreeRead(hDevice, pIdentifier);
|
|
454
|
USBSpaceWire_FreeRead(hDevice, pIdentifier);
|
|
455
|
pIdentifier = NULL;
|
|
455
|
pIdentifier = NULL;
|
|
456
|
handleMutex->unlock();
|
|
456
|
handleMutex->unlock();
|
|
457
|
if(properties.len==8)
|
|
457
|
if(properties.len==8)
|
|
458
|
{
|
|
458
|
{
|
|
459
|
packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len);
|
|
459
|
packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len);
|
|
460
|
}
|
|
460
|
}
|
|
461
|
else
|
|
461
|
else
|
|
462
|
{
|
|
462
|
{
|
|
463
|
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);
|
|
464
|
}
|
|
464
|
}
|
|
465
|
RMAP_AnswersMtx->lock();
|
|
465
|
RMAP_AnswersMtx->lock();
|
|
466
|
RMAP_Answers.append(packet);
|
|
466
|
RMAP_Answers.append(packet);
|
|
467
|
RMAP_AnswersMtx->unlock();
|
|
467
|
RMAP_AnswersMtx->unlock();
|
|
468
|
RMAP_AnswersSem->release();
|
|
468
|
RMAP_AnswersSem->release();
|
|
469
|
}
|
|
469
|
}
|
|
470
|
else //any non-rmap packet will be pushed to the network
|
|
470
|
else //any non-rmap packet will be pushed to the network
|
|
471
|
{
|
|
471
|
{
|
|
472
|
char* packetbuffer = (char*)malloc(properties.len);
|
|
472
|
char* packetbuffer = (char*)malloc(properties.len);
|
|
473
|
memcpy(packetbuffer,buffer,properties.len);
|
|
473
|
memcpy(packetbuffer,buffer,properties.len);
|
|
474
|
emit emitPacket(packetbuffer,properties.len);
|
|
474
|
emit emitPacket(packetbuffer,properties.len);
|
|
475
|
USBSpaceWire_FreeRead(hDevice, pIdentifier);
|
|
475
|
USBSpaceWire_FreeRead(hDevice, pIdentifier);
|
|
476
|
handleMutex->unlock();
|
|
476
|
handleMutex->unlock();
|
|
477
|
SocExplorerEngine::message(this->plugin,"Got SPW packet",2);
|
|
477
|
SocExplorerEngine::message(this->plugin,"Got SPW packet",2);
|
|
478
|
}
|
|
478
|
}
|
|
479
|
}
|
|
479
|
}
|
|
480
|
else
|
|
480
|
else
|
|
481
|
{
|
|
481
|
{
|
|
482
|
SocExplorerEngine::message(this->plugin,"No EOP received",2);
|
|
482
|
SocExplorerEngine::message(this->plugin,"No EOP received",2);
|
|
483
|
}
|
|
483
|
}
|
|
484
|
}
|
|
484
|
}
|
|
485
|
|
|
485
|
|
|
486
|
}
|
|
486
|
}
|
|
487
|
else
|
|
487
|
else
|
|
488
|
{
|
|
488
|
{
|
|
489
|
USBSpaceWire_FreeRead(hDevice, pIdentifier);
|
|
489
|
USBSpaceWire_FreeRead(hDevice, pIdentifier);
|
|
490
|
handleMutex->unlock();
|
|
490
|
handleMutex->unlock();
|
|
491
|
}
|
|
491
|
}
|
|
492
|
}
|
|
492
|
}
|
|
493
|
else
|
|
493
|
else
|
|
494
|
{
|
|
494
|
{
|
|
495
|
USBSpaceWire_FreeRead(hDevice, pIdentifier);
|
|
495
|
USBSpaceWire_FreeRead(hDevice, pIdentifier);
|
|
496
|
handleMutex->unlock();
|
|
496
|
handleMutex->unlock();
|
|
497
|
}
|
|
497
|
}
|
|
498
|
}
|
|
498
|
}
|
|
499
|
else
|
|
499
|
else
|
|
500
|
{
|
|
500
|
{
|
|
501
|
//do some sanity checks!
|
|
501
|
//do some sanity checks!
|
|
502
|
int list = USBSpaceWire_ListDevices();
|
|
502
|
int list = USBSpaceWire_ListDevices();
|
|
503
|
if(this->brickList!=list)
|
|
503
|
if(this->brickList!=list)
|
|
504
|
{
|
|
504
|
{
|
|
505
|
this->brickList = list;
|
|
505
|
this->brickList = list;
|
|
506
|
emit updateAvailableBrickCount(this->brickList);
|
|
506
|
emit updateAvailableBrickCount(this->brickList);
|
|
507
|
}
|
|
507
|
}
|
|
508
|
usleep(RMAPtimeout/2);
|
|
508
|
usleep(RMAPtimeout/2);
|
|
509
|
}
|
|
509
|
}
|
|
510
|
usleep(1000);
|
|
510
|
usleep(1000);
|
|
511
|
}
|
|
511
|
}
|
|
512
|
SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1);
|
|
512
|
SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1);
|
|
513
|
}
|
|
513
|
}
|
|
514
|
|
|
514
|
|
|
515
|
bool stardundeeSPW_USB_Manager::connectBridge()
|
|
515
|
bool stardundeeSPW_USB_Manager::connectBridge()
|
|
516
|
{
|
|
516
|
{
|
|
517
|
bool ret;
|
|
517
|
bool ret;
|
|
518
|
|
|
518
|
|
|
519
|
if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE)
|
|
519
|
if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE)
|
|
520
|
{
|
|
520
|
{
|
|
521
|
ret = connectBridgeAsInterface();
|
|
521
|
ret = connectBridgeAsInterface();
|
|
522
|
}
|
|
522
|
}
|
|
523
|
else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER)
|
|
523
|
else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER)
|
|
524
|
{
|
|
524
|
{
|
|
525
|
ret = connectBridgeAsRouter();
|
|
525
|
ret = connectBridgeAsRouter();
|
|
526
|
}
|
|
526
|
}
|
|
527
|
else
|
|
527
|
else
|
|
528
|
{
|
|
528
|
{
|
|
529
|
ret = false;
|
|
529
|
ret = false;
|
|
530
|
}
|
|
530
|
}
|
|
531
|
|
|
531
|
|
|
532
|
return ret;
|
|
532
|
return ret;
|
|
533
|
}
|
|
533
|
}
|
|
534
|
|
|
534
|
|
|
535
|
bool stardundeeSPW_USB_Manager::connectBridgeAsInterface()
|
|
535
|
bool stardundeeSPW_USB_Manager::connectBridgeAsInterface()
|
|
536
|
{
|
|
536
|
{
|
|
537
|
QMutexLocker mlock(this->handleMutex);
|
|
537
|
QMutexLocker mlock(this->handleMutex);
|
|
538
|
int status;
|
|
538
|
int status;
|
|
539
|
U32 statusControl;
|
|
539
|
U32 statusControl;
|
|
540
|
this->connected = false;
|
|
540
|
this->connected = false;
|
|
541
|
if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device
|
|
541
|
if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device
|
|
542
|
{
|
|
542
|
{
|
|
543
|
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);
|
|
544
|
return false;
|
|
544
|
return false;
|
|
545
|
}
|
|
545
|
}
|
|
546
|
SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0);
|
|
546
|
SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0);
|
|
547
|
|
|
547
|
|
|
548
|
USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode
|
|
548
|
USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode
|
|
549
|
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
|
|
550
|
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
|
|
551
|
|
|
551
|
|
|
552
|
// Set the path and return path to the device
|
|
552
|
// Set the path and return path to the device
|
|
553
|
CFGSpaceWire_StackClear();
|
|
553
|
CFGSpaceWire_StackClear();
|
|
554
|
CFGSpaceWire_AddrStackPush(0);
|
|
554
|
CFGSpaceWire_AddrStackPush(0);
|
|
555
|
CFGSpaceWire_AddrStackPush(254);
|
|
555
|
CFGSpaceWire_AddrStackPush(254);
|
|
556
|
CFGSpaceWire_RetAddrStackPush(254);
|
|
556
|
CFGSpaceWire_RetAddrStackPush(254);
|
|
557
|
// set the base transmit rate to 100 MHz
|
|
557
|
// set the base transmit rate to 100 MHz
|
|
558
|
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);
|
|
559
|
if (status != CFG_TRANSFER_SUCCESS)
|
|
559
|
if (status != CFG_TRANSFER_SUCCESS)
|
|
560
|
{
|
|
560
|
{
|
|
561
|
SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1);
|
|
561
|
SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1);
|
|
562
|
return false;
|
|
562
|
return false;
|
|
563
|
}
|
|
563
|
}
|
|
564
|
else
|
|
564
|
else
|
|
565
|
{
|
|
565
|
{
|
|
566
|
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);
|
|
567
|
}
|
|
567
|
}
|
|
568
|
|
|
568
|
|
|
569
|
// read the link status
|
|
569
|
// read the link status
|
|
570
|
if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
|
|
570
|
if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
|
|
571
|
{
|
|
571
|
{
|
|
572
|
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);
|
|
573
|
return false;
|
|
573
|
return false;
|
|
574
|
}
|
|
574
|
}
|
|
575
|
else
|
|
575
|
else
|
|
576
|
{
|
|
576
|
{
|
|
577
|
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);
|
|
578
|
|
|
578
|
|
|
579
|
// Set the link status control register properties
|
|
579
|
// Set the link status control register properties
|
|
580
|
CFGSpaceWire_LSEnableAutoStart(&statusControl, 1);
|
|
580
|
CFGSpaceWire_LSEnableAutoStart(&statusControl, 1);
|
|
581
|
CFGSpaceWire_LSEnableStart(&statusControl, 1);
|
|
581
|
CFGSpaceWire_LSEnableStart(&statusControl, 1);
|
|
582
|
CFGSpaceWire_LSEnableDisabled(&statusControl, 0);
|
|
582
|
CFGSpaceWire_LSEnableDisabled(&statusControl, 0);
|
|
583
|
CFGSpaceWire_LSEnableTristate(&statusControl, 0);
|
|
583
|
CFGSpaceWire_LSEnableTristate(&statusControl, 0);
|
|
584
|
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
|
|
585
|
|
|
585
|
|
|
586
|
// Set the link status control register
|
|
586
|
// Set the link status control register
|
|
587
|
if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
|
|
587
|
if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
|
|
588
|
{
|
|
588
|
{
|
|
589
|
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);
|
|
590
|
return false;
|
|
590
|
return false;
|
|
591
|
}
|
|
591
|
}
|
|
592
|
else
|
|
592
|
else
|
|
593
|
{
|
|
593
|
{
|
|
594
|
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);
|
|
595
|
}
|
|
595
|
}
|
|
596
|
}
|
|
596
|
}
|
|
597
|
|
|
597
|
|
|
598
|
if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS)
|
|
598
|
if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS)
|
|
599
|
{
|
|
599
|
{
|
|
600
|
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);
|
|
601
|
return false;
|
|
601
|
return false;
|
|
602
|
}
|
|
602
|
}
|
|
603
|
else
|
|
603
|
else
|
|
604
|
{
|
|
604
|
{
|
|
605
|
SocExplorerEngine::message(this->plugin,"Device set to be an interface",1);
|
|
605
|
SocExplorerEngine::message(this->plugin,"Device set to be an interface",1);
|
|
606
|
}
|
|
606
|
}
|
|
607
|
|
|
607
|
|
|
608
|
USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports
|
|
608
|
USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports
|
|
609
|
USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints
|
|
609
|
USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints
|
|
610
|
USBSpaceWire_SetTimeout(hDevice,1.0);
|
|
610
|
USBSpaceWire_SetTimeout(hDevice,1.0);
|
|
611
|
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);
|
|
612
|
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);
|
|
613
|
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);
|
|
614
|
this->connected = true;
|
|
614
|
this->connected = true;
|
|
615
|
return true;
|
|
615
|
return true;
|
|
616
|
}
|
|
616
|
}
|
|
617
|
|
|
617
|
|
|
618
|
bool stardundeeSPW_USB_Manager::connectBridgeAsRouter()
|
|
618
|
bool stardundeeSPW_USB_Manager::connectBridgeAsRouter()
|
|
619
|
{
|
|
619
|
{
|
|
620
|
QMutexLocker mlock(this->handleMutex);
|
|
620
|
QMutexLocker mlock(this->handleMutex);
|
|
621
|
int status;
|
|
621
|
int status;
|
|
622
|
U32 statusControl;
|
|
622
|
U32 statusControl;
|
|
623
|
unsigned int linkStatus1;
|
|
623
|
unsigned int linkStatus1;
|
|
624
|
unsigned int linkStatus2;
|
|
624
|
unsigned int linkStatus2;
|
|
625
|
unsigned char linkNumber;
|
|
625
|
unsigned char linkNumber;
|
|
626
|
unsigned char deviceIsAnInterface;
|
|
626
|
unsigned char deviceIsAnInterface;
|
|
627
|
|
|
627
|
|
|
628
|
if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device
|
|
628
|
if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device
|
|
629
|
{
|
|
629
|
{
|
|
630
|
SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))");
|
|
630
|
SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))");
|
|
631
|
return false;
|
|
631
|
return false;
|
|
632
|
}
|
|
632
|
}
|
|
633
|
SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: "
|
|
633
|
SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: "
|
|
634
|
+ QString::number(this->selectedBrick));
|
|
634
|
+ QString::number(this->selectedBrick));
|
|
635
|
|
|
635
|
|
|
636
|
USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode
|
|
636
|
USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode
|
|
637
|
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
|
|
638
|
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
|
|
639
|
|
|
639
|
|
|
640
|
// Set the path and return path to the device
|
|
640
|
// Set the path and return path to the device
|
|
641
|
// 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
|
|
642
|
// sent and received using the driver API.
|
|
642
|
// sent and received using the driver API.
|
|
643
|
CFGSpaceWire_StackClear();
|
|
643
|
CFGSpaceWire_StackClear();
|
|
644
|
CFGSpaceWire_AddrStackPush(0);
|
|
644
|
CFGSpaceWire_AddrStackPush(0);
|
|
645
|
CFGSpaceWire_AddrStackPush(254);
|
|
645
|
CFGSpaceWire_AddrStackPush(254);
|
|
646
|
CFGSpaceWire_RetAddrStackPush(254);
|
|
646
|
CFGSpaceWire_RetAddrStackPush(254);
|
|
647
|
|
|
647
|
|
|
648
|
// set the base transmit rate to 100 MHz
|
|
648
|
// set the base transmit rate to 100 MHz
|
|
649
|
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);
|
|
650
|
if (status != CFG_TRANSFER_SUCCESS)
|
|
650
|
if (status != CFG_TRANSFER_SUCCESS)
|
|
651
|
{
|
|
651
|
{
|
|
652
|
SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate");
|
|
652
|
SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate");
|
|
653
|
}
|
|
653
|
}
|
|
654
|
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");
|
|
655
|
|
|
655
|
|
|
656
|
//*********************
|
|
656
|
//*********************
|
|
657
|
// LINK 1 CONFIGURATION
|
|
657
|
// LINK 1 CONFIGURATION
|
|
658
|
linkNumber = 1;
|
|
658
|
linkNumber = 1;
|
|
659
|
if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
|
|
659
|
if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
|
|
660
|
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));
|
|
661
|
else
|
|
661
|
else
|
|
662
|
{
|
|
662
|
{
|
|
663
|
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));
|
|
664
|
|
|
664
|
|
|
665
|
// Set the link status control register properties
|
|
665
|
// Set the link status control register properties
|
|
666
|
CFGSpaceWire_LSEnableAutoStart(&statusControl, 1);
|
|
666
|
CFGSpaceWire_LSEnableAutoStart(&statusControl, 1);
|
|
667
|
CFGSpaceWire_LSEnableStart(&statusControl, 1);
|
|
667
|
CFGSpaceWire_LSEnableStart(&statusControl, 1);
|
|
668
|
CFGSpaceWire_LSEnableDisabled(&statusControl, 0);
|
|
668
|
CFGSpaceWire_LSEnableDisabled(&statusControl, 0);
|
|
669
|
CFGSpaceWire_LSEnableTristate(&statusControl, 0);
|
|
669
|
CFGSpaceWire_LSEnableTristate(&statusControl, 0);
|
|
670
|
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
|
|
671
|
|
|
671
|
|
|
672
|
// Set the link status control register
|
|
672
|
// Set the link status control register
|
|
673
|
if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
|
|
673
|
if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
|
|
674
|
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));
|
|
675
|
else
|
|
675
|
else
|
|
676
|
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");
|
|
677
|
}
|
|
677
|
}
|
|
678
|
|
|
678
|
|
|
679
|
//*********************
|
|
679
|
//*********************
|
|
680
|
// LINK 2 CONFIGURATION
|
|
680
|
// LINK 2 CONFIGURATION
|
|
681
|
linkNumber = 2;
|
|
681
|
linkNumber = 2;
|
|
682
|
if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
|
|
682
|
if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
|
|
683
|
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));
|
|
684
|
else
|
|
684
|
else
|
|
685
|
{
|
|
685
|
{
|
|
686
|
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));
|
|
687
|
|
|
687
|
|
|
688
|
// Set the link status control register properties
|
|
688
|
// Set the link status control register properties
|
|
689
|
CFGSpaceWire_LSEnableAutoStart(&statusControl, 1);
|
|
689
|
CFGSpaceWire_LSEnableAutoStart(&statusControl, 1);
|
|
690
|
CFGSpaceWire_LSEnableStart(&statusControl, 1);
|
|
690
|
CFGSpaceWire_LSEnableStart(&statusControl, 1);
|
|
691
|
CFGSpaceWire_LSEnableDisabled(&statusControl, 0);
|
|
691
|
CFGSpaceWire_LSEnableDisabled(&statusControl, 0);
|
|
692
|
CFGSpaceWire_LSEnableTristate(&statusControl, 0);
|
|
692
|
CFGSpaceWire_LSEnableTristate(&statusControl, 0);
|
|
693
|
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
|
|
694
|
|
|
694
|
|
|
695
|
// Set the link status control register
|
|
695
|
// Set the link status control register
|
|
696
|
if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
|
|
696
|
if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
|
|
697
|
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));
|
|
698
|
else
|
|
698
|
else
|
|
699
|
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");
|
|
700
|
}
|
|
700
|
}
|
|
701
|
|
|
701
|
|
|
702
|
//***************************
|
|
702
|
//***************************
|
|
703
|
// SET THE DEVICE AS A ROUTER
|
|
703
|
// SET THE DEVICE AS A ROUTER
|
|
704
|
deviceIsAnInterface = 0; // 0 = router, 1 = interface
|
|
704
|
deviceIsAnInterface = 0; // 0 = router, 1 = interface
|
|
705
|
if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS)
|
|
705
|
if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS)
|
|
706
|
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");
|
|
707
|
else
|
|
707
|
else
|
|
708
|
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)");
|
|
709
|
|
|
709
|
|
|
710
|
setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1
|
|
710
|
setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1
|
|
711
|
setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3
|
|
711
|
setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3
|
|
712
|
|
|
712
|
|
|
713
|
USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only
|
|
713
|
USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only
|
|
714
|
USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints
|
|
714
|
USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints
|
|
715
|
|
|
715
|
|
|
716
|
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");
|
|
717
|
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");
|
|
718
|
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)));
|
|
719
|
|
|
719
|
|
|
720
|
//************
|
|
720
|
//************
|
|
721
|
// test Link 1 and Link 2
|
|
721
|
// test Link 1 and Link 2
|
|
722
|
linkStatus1 = getLinkStatus(0x01);
|
|
722
|
linkStatus1 = getLinkStatus(0x01);
|
|
723
|
linkStatus2 = getLinkStatus(0x02);
|
|
723
|
linkStatus2 = getLinkStatus(0x02);
|
|
724
|
|
|
724
|
|
|
725
|
if ((linkStatus1==1) || (linkStatus2==1))
|
|
725
|
if ((linkStatus1==1) || (linkStatus2==1))
|
|
726
|
{
|
|
726
|
{
|
|
727
|
initializeTimecodeGeneration();
|
|
727
|
initializeTimecodeGeneration();
|
|
728
|
this->connected=true;
|
|
728
|
this->connected=true;
|
|
729
|
return true;
|
|
729
|
return true;
|
|
730
|
}
|
|
730
|
}
|
|
731
|
else
|
|
731
|
else
|
|
732
|
{
|
|
732
|
{
|
|
733
|
statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1));
|
|
733
|
statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1));
|
|
734
|
statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2));
|
|
734
|
statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2));
|
|
735
|
starDundeeStatusQueryDialog->exec();
|
|
735
|
starDundeeStatusQueryDialog->exec();
|
|
736
|
this->connected = false;
|
|
736
|
this->connected = false;
|
|
737
|
return false;
|
|
737
|
return false;
|
|
738
|
}
|
|
738
|
}
|
|
739
|
}
|
|
739
|
}
|
|
740
|
|
|
740
|
|
|
741
|
void stardundeeSPW_USB_Manager::initDialog( void )
|
|
741
|
void stardundeeSPW_USB_Manager::initDialog( void )
|
|
742
|
{
|
|
742
|
{
|
|
743
|
// STAR DUNDEE STATUS QUERY DIALOG
|
|
743
|
// STAR DUNDEE STATUS QUERY DIALOG
|
|
744
|
starDundeeStatusQueryDialog = new QDialog;
|
|
744
|
starDundeeStatusQueryDialog = new QDialog;
|
|
745
|
starDundeeStatusQueryDialogLayout = new QGridLayout;
|
|
745
|
starDundeeStatusQueryDialogLayout = new QGridLayout;
|
|
746
|
starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state"));
|
|
746
|
starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state"));
|
|
747
|
starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue"));
|
|
747
|
starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue"));
|
|
748
|
starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry"));
|
|
748
|
starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry"));
|
|
749
|
starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort"));
|
|
749
|
starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort"));
|
|
750
|
statusLink1 = new QLabel(tr("Link 1 status code: -"));
|
|
750
|
statusLink1 = new QLabel(tr("Link 1 status code: -"));
|
|
751
|
statusLink2 = new QLabel(tr("Link 2 status code: -"));
|
|
751
|
statusLink2 = new QLabel(tr("Link 2 status code: -"));
|
|
752
|
|
|
752
|
|
|
753
|
starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2);
|
|
753
|
starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2);
|
|
754
|
starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0);
|
|
754
|
starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0);
|
|
755
|
starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0);
|
|
755
|
starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0);
|
|
756
|
starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0);
|
|
756
|
starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0);
|
|
757
|
starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0);
|
|
757
|
starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0);
|
|
758
|
starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0);
|
|
758
|
starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0);
|
|
759
|
starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout);
|
|
759
|
starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout);
|
|
760
|
}
|
|
760
|
}
|
|
761
|
|
|
761
|
|
|
762
|
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)
|
|
763
|
{
|
|
763
|
{
|
|
764
|
U32 routingTableEntry;
|
|
764
|
U32 routingTableEntry;
|
|
765
|
// SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber
|
|
765
|
// SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber
|
|
766
|
if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS)
|
|
766
|
if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS)
|
|
767
|
{
|
|
767
|
{
|
|
768
|
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));
|
|
769
|
}
|
|
769
|
}
|
|
770
|
// Build the routing table entry
|
|
770
|
// Build the routing table entry
|
|
771
|
CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry,
|
|
771
|
CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry,
|
|
772
|
dwOutputPorts, // route out of port dwOutputPorts
|
|
772
|
dwOutputPorts, // route out of port dwOutputPorts
|
|
773
|
bDelHead, // header deletion is enabled [1] or disabled [0]
|
|
773
|
bDelHead, // header deletion is enabled [1] or disabled [0]
|
|
774
|
0); // priority normal
|
|
774
|
0); // priority normal
|
|
775
|
// Set the routing table entry for logical address tableEntry
|
|
775
|
// Set the routing table entry for logical address tableEntry
|
|
776
|
if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS)
|
|
776
|
if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS)
|
|
777
|
{
|
|
777
|
{
|
|
778
|
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) + "]");
|
|
779
|
}
|
|
779
|
}
|
|
780
|
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" );
|
|
781
|
return 1;
|
|
781
|
return 1;
|
|
782
|
}
|
|
782
|
}
|
|
783
|
|
|
783
|
|
|
784
|
unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry)
|
|
784
|
unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry)
|
|
785
|
{
|
|
785
|
{
|
|
786
|
U32 routingTableEntry, outputPorts;
|
|
786
|
U32 routingTableEntry, outputPorts;
|
|
787
|
char enabled, delHead, priority;
|
|
787
|
char enabled, delHead, priority;
|
|
788
|
int portNum;
|
|
788
|
int portNum;
|
|
789
|
|
|
789
|
|
|
790
|
SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]");
|
|
790
|
SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]");
|
|
791
|
// Read the routing table entry
|
|
791
|
// Read the routing table entry
|
|
792
|
if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS)
|
|
792
|
if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS)
|
|
793
|
{
|
|
793
|
{
|
|
794
|
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) + "]");
|
|
795
|
}
|
|
795
|
}
|
|
796
|
else
|
|
796
|
else
|
|
797
|
{
|
|
797
|
{
|
|
798
|
// Display the routing table entry properties
|
|
798
|
// Display the routing table entry properties
|
|
799
|
CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled);
|
|
799
|
CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled);
|
|
800
|
CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead);
|
|
800
|
CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead);
|
|
801
|
CFGSpaceWire_RTIsPriority(routingTableEntry, &priority);
|
|
801
|
CFGSpaceWire_RTIsPriority(routingTableEntry, &priority);
|
|
802
|
CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts);
|
|
802
|
CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts);
|
|
803
|
SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled));
|
|
803
|
SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled));
|
|
804
|
SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead));
|
|
804
|
SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead));
|
|
805
|
SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority));
|
|
805
|
SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority));
|
|
806
|
SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : ");
|
|
806
|
SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : ");
|
|
807
|
for (portNum = 0; portNum < 32; portNum++)
|
|
807
|
for (portNum = 0; portNum < 32; portNum++)
|
|
808
|
{
|
|
808
|
{
|
|
809
|
if (outputPorts & (1 << portNum))
|
|
809
|
if (outputPorts & (1 << portNum))
|
|
810
|
{
|
|
810
|
{
|
|
811
|
SocExplorerEngine::message(this->plugin,QString::number(portNum));
|
|
811
|
SocExplorerEngine::message(this->plugin,QString::number(portNum));
|
|
812
|
}
|
|
812
|
}
|
|
813
|
}
|
|
813
|
}
|
|
814
|
}
|
|
814
|
}
|
|
815
|
|
|
815
|
|
|
816
|
return 1;
|
|
816
|
return 1;
|
|
817
|
}
|
|
817
|
}
|
|
818
|
|
|
818
|
|
|
819
|
void stardundeeSPW_USB_Manager::initializeTimecodeGeneration()
|
|
819
|
void stardundeeSPW_USB_Manager::initializeTimecodeGeneration()
|
|
820
|
{
|
|
820
|
{
|
|
821
|
U32 dwTickEnableStatus;
|
|
821
|
U32 dwTickEnableStatus;
|
|
822
|
U32 rtr_clk_freq;
|
|
822
|
U32 rtr_clk_freq;
|
|
823
|
|
|
823
|
|
|
824
|
// (1) RESET
|
|
824
|
// (1) RESET
|
|
825
|
if (!USBSpaceWire_TC_Reset(hDevice))
|
|
825
|
if (!USBSpaceWire_TC_Reset(hDevice))
|
|
826
|
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");
|
|
827
|
|
|
827
|
|
|
828
|
// (2) Clear the tick enable register
|
|
828
|
// (2) Clear the tick enable register
|
|
829
|
if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS)
|
|
829
|
if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS)
|
|
830
|
SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register");
|
|
830
|
SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register");
|
|
831
|
else
|
|
831
|
else
|
|
832
|
SocExplorerEngine::message(this->plugin,"Cleared the tick enable register");
|
|
832
|
SocExplorerEngine::message(this->plugin,"Cleared the tick enable register");
|
|
833
|
|
|
833
|
|
|
834
|
// (3) get the tick status
|
|
834
|
// (3) get the tick status
|
|
835
|
CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus);
|
|
835
|
CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus);
|
|
836
|
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));
|
|
837
|
|
|
837
|
|
|
838
|
// (4) enable external timecode selection
|
|
838
|
// (4) enable external timecode selection
|
|
839
|
if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0))
|
|
839
|
if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0))
|
|
840
|
SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection");
|
|
840
|
SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection");
|
|
841
|
|
|
841
|
|
|
842
|
rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice);
|
|
842
|
rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice);
|
|
843
|
|
|
843
|
|
|
844
|
SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) );
|
|
844
|
SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) );
|
|
845
|
|
|
845
|
|
|
846
|
//**************************************************
|
|
846
|
//**************************************************
|
|
847
|
// auto _ tick _ freq = rtr _ clk _ freq / freqCount
|
|
847
|
// auto _ tick _ freq = rtr _ clk _ freq / freqCount
|
|
848
|
if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) )
|
|
848
|
if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) )
|
|
849
|
SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency");
|
|
849
|
SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency");
|
|
850
|
}
|
|
850
|
}
|
|
851
|
|
|
851
|
|
|
852
|
unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link)
|
|
852
|
unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link)
|
|
853
|
{
|
|
853
|
{
|
|
854
|
U32 statusControl, errorStatus, portType;
|
|
854
|
U32 statusControl, errorStatus, portType;
|
|
855
|
U32 linkStatus, operatingSpeed, outputPortConnection;
|
|
855
|
U32 linkStatus, operatingSpeed, outputPortConnection;
|
|
856
|
char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate;
|
|
856
|
char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate;
|
|
857
|
|
|
857
|
|
|
858
|
// Read the link status control register
|
|
858
|
// Read the link status control register
|
|
859
|
if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS)
|
|
859
|
if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS)
|
|
860
|
{
|
|
860
|
{
|
|
861
|
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));
|
|
862
|
}
|
|
862
|
}
|
|
863
|
else
|
|
863
|
else
|
|
864
|
{
|
|
864
|
{
|
|
865
|
// Display the link status control register properties
|
|
865
|
// Display the link status control register properties
|
|
866
|
CFGSpaceWire_LSPortType(statusControl, &portType);
|
|
866
|
CFGSpaceWire_LSPortType(statusControl, &portType);
|
|
867
|
if (portType == CFG_CONFIGURATION_PORT)
|
|
867
|
if (portType == CFG_CONFIGURATION_PORT)
|
|
868
|
{
|
|
868
|
{
|
|
869
|
CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus);
|
|
869
|
CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus);
|
|
870
|
}
|
|
870
|
}
|
|
871
|
else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT)
|
|
871
|
else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT)
|
|
872
|
{
|
|
872
|
{
|
|
873
|
CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus);
|
|
873
|
CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus);
|
|
874
|
}
|
|
874
|
}
|
|
875
|
else
|
|
875
|
else
|
|
876
|
{
|
|
876
|
{
|
|
877
|
CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus);
|
|
877
|
CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus);
|
|
878
|
}
|
|
878
|
}
|
|
879
|
CFGSpaceWire_LSLinkState(statusControl, &linkStatus);
|
|
879
|
CFGSpaceWire_LSLinkState(statusControl, &linkStatus);
|
|
880
|
CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning);
|
|
880
|
CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning);
|
|
881
|
CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart);
|
|
881
|
CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart);
|
|
882
|
CFGSpaceWire_LSIsStart(statusControl, &isStart);
|
|
882
|
CFGSpaceWire_LSIsStart(statusControl, &isStart);
|
|
883
|
CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled);
|
|
883
|
CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled);
|
|
884
|
CFGSpaceWire_LSIsTristate(statusControl, &isTristate);
|
|
884
|
CFGSpaceWire_LSIsTristate(statusControl, &isTristate);
|
|
885
|
CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed);
|
|
885
|
CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed);
|
|
886
|
CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection);
|
|
886
|
CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection);
|
|
887
|
}
|
|
887
|
}
|
|
888
|
SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link)
|
|
888
|
SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link)
|
|
889
|
+" is " + dwLinkStatusQString[linkStatus]);
|
|
889
|
+" is " + dwLinkStatusQString[linkStatus]);
|
|
890
|
if (linkStatus == 5)
|
|
890
|
if (linkStatus == 5)
|
|
891
|
{
|
|
891
|
{
|
|
892
|
return 1;
|
|
892
|
return 1;
|
|
893
|
}
|
|
893
|
}
|
|
894
|
else return 0;
|
|
894
|
else return 0;
|
|
895
|
}
|
|
895
|
}
|
|
896
|
|
|
896
|
|
|
897
|
bool stardundeeSPW_USB_Manager::disconnectBridge()
|
|
897
|
bool stardundeeSPW_USB_Manager::disconnectBridge()
|
|
898
|
{
|
|
898
|
{
|
|
899
|
this->handleMutex->lock();
|
|
899
|
this->handleMutex->lock();
|
|
900
|
USBSpaceWire_Close(hDevice); // Close the device
|
|
900
|
USBSpaceWire_Close(hDevice); // Close the device
|
|
901
|
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);
|
|
902
|
USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports
|
|
902
|
USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports
|
|
903
|
this->handleMutex->unlock();
|
|
903
|
this->handleMutex->unlock();
|
|
904
|
this->RMAP_pending_transaction_IDsMtx->lock();
|
|
904
|
this->RMAP_pending_transaction_IDsMtx->lock();
|
|
905
|
this->RMAP_pending_transaction_IDs.clear();
|
|
905
|
this->RMAP_pending_transaction_IDs.clear();
|
|
906
|
this->RMAP_pending_transaction_IDsMtx->unlock();
|
|
906
|
this->RMAP_pending_transaction_IDsMtx->unlock();
|
|
907
|
this->RMAP_AnswersMtx->lock();
|
|
907
|
this->RMAP_AnswersMtx->lock();
|
|
908
|
this->RMAP_Answers.clear();
|
|
908
|
this->RMAP_Answers.clear();
|
|
909
|
this->RMAP_AnswersMtx->unlock();
|
|
909
|
this->RMAP_AnswersMtx->unlock();
|
|
910
|
this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available());
|
|
910
|
this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available());
|
|
911
|
return true;
|
|
911
|
return true;
|
|
912
|
}
|
|
912
|
}
|
|
913
|
|
|
913
|
|
|
914
|
int stardundeeSPW_USB_Manager::getRMAPtransactionID()
|
|
914
|
int stardundeeSPW_USB_Manager::getRMAPtransactionID()
|
|
915
|
{
|
|
915
|
{
|
|
916
|
this->RMAP_pending_transaction_IDsMtx->lock();
|
|
916
|
this->RMAP_pending_transaction_IDsMtx->lock();
|
|
917
|
int ID=0;
|
|
917
|
int ID=0;
|
|
918
|
bool found=true;
|
|
918
|
bool found=true;
|
|
919
|
while(ID<511)
|
|
919
|
while(ID<511)
|
|
920
|
{
|
|
920
|
{
|
|
921
|
for(int i=0;i<RMAP_pending_transaction_IDs.count();i++)
|
|
921
|
for(int i=0;i<RMAP_pending_transaction_IDs.count();i++)
|
|
922
|
{
|
|
922
|
{
|
|
923
|
if(RMAP_pending_transaction_IDs[i]==ID)found=false;
|
|
923
|
if(RMAP_pending_transaction_IDs[i]==ID)found=false;
|
|
924
|
}
|
|
924
|
}
|
|
925
|
if(found==true)break;
|
|
925
|
if(found==true)break;
|
|
926
|
ID++;
|
|
926
|
ID++;
|
|
927
|
found = true;
|
|
927
|
found = true;
|
|
928
|
}
|
|
928
|
}
|
|
929
|
if(found)
|
|
929
|
if(found)
|
|
930
|
{
|
|
930
|
{
|
|
931
|
RMAP_pending_transaction_IDs.append(ID);
|
|
931
|
RMAP_pending_transaction_IDs.append(ID);
|
|
932
|
}
|
|
932
|
}
|
|
933
|
this->RMAP_pending_transaction_IDsMtx->unlock();
|
|
933
|
this->RMAP_pending_transaction_IDsMtx->unlock();
|
|
934
|
return ID;
|
|
934
|
return ID;
|
|
935
|
}
|
|
935
|
}
|
|
936
|
|
|
936
|
|
|
937
|
int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer)
|
|
937
|
int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer)
|
|
938
|
{
|
|
938
|
{
|
|
939
|
QTime timeout;
|
|
939
|
QTime timeout;
|
|
940
|
*buffer=NULL;
|
|
940
|
*buffer=NULL;
|
|
941
|
int count=0;
|
|
941
|
int count=0;
|
|
942
|
SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2);
|
|
942
|
SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2);
|
|
943
|
timeout.start();
|
|
943
|
timeout.start();
|
|
944
|
while (*buffer==NULL)
|
|
944
|
while (*buffer==NULL)
|
|
945
|
{
|
|
945
|
{
|
|
946
|
this->RMAP_AnswersMtx->lock();
|
|
946
|
this->RMAP_AnswersMtx->lock();
|
|
947
|
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);
|
|
948
|
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);
|
|
949
|
for(int i=0;i<RMAP_Answers.count();i++)
|
|
949
|
for(int i=0;i<RMAP_Answers.count();i++)
|
|
950
|
{
|
|
950
|
{
|
|
951
|
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);
|
|
952
|
if(RMAP_Answers[i]->transactionID==transactionID)
|
|
952
|
if(RMAP_Answers[i]->transactionID==transactionID)
|
|
953
|
{
|
|
953
|
{
|
|
954
|
this->RMAP_pending_transaction_IDsMtx->lock();
|
|
954
|
this->RMAP_pending_transaction_IDsMtx->lock();
|
|
955
|
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);
|
|
956
|
for(int j=0;j<RMAP_pending_transaction_IDs.count();j++)
|
|
956
|
for(int j=0;j<RMAP_pending_transaction_IDs.count();j++)
|
|
957
|
{
|
|
957
|
{
|
|
958
|
if(RMAP_pending_transaction_IDs[j]==transactionID)
|
|
958
|
if(RMAP_pending_transaction_IDs[j]==transactionID)
|
|
959
|
{
|
|
959
|
{
|
|
960
|
RMAP_pending_transaction_IDs.removeAt(j);
|
|
960
|
RMAP_pending_transaction_IDs.removeAt(j);
|
|
961
|
}
|
|
961
|
}
|
|
962
|
}
|
|
962
|
}
|
|
963
|
this->RMAP_pending_transaction_IDsMtx->unlock();
|
|
963
|
this->RMAP_pending_transaction_IDsMtx->unlock();
|
|
964
|
*buffer = RMAP_Answers[i]->data;
|
|
964
|
*buffer = RMAP_Answers[i]->data;
|
|
965
|
count = RMAP_Answers[i]->len;
|
|
965
|
count = RMAP_Answers[i]->len;
|
|
966
|
RMAP_Answer* tmp=RMAP_Answers[i];
|
|
966
|
RMAP_Answer* tmp=RMAP_Answers[i];
|
|
967
|
RMAP_Answers.removeAt(i);
|
|
967
|
RMAP_Answers.removeAt(i);
|
|
968
|
delete tmp;
|
|
968
|
delete tmp;
|
|
969
|
}
|
|
969
|
}
|
|
970
|
}
|
|
970
|
}
|
|
971
|
this->RMAP_AnswersMtx->unlock();
|
|
971
|
this->RMAP_AnswersMtx->unlock();
|
|
972
|
//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
|
|
973
|
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);
|
|
974
|
if(*buffer==NULL)
|
|
974
|
if(*buffer==NULL)
|
|
975
|
{
|
|
975
|
{
|
|
976
|
while (0==this->RMAP_AnswersSem->available())
|
|
976
|
while (0==this->RMAP_AnswersSem->available())
|
|
977
|
{
|
|
977
|
{
|
|
978
|
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);
|
|
979
|
if(timeout.elapsed()>=RMAPtimeout)
|
|
979
|
if(timeout.elapsed()>=RMAPtimeout)
|
|
980
|
{
|
|
980
|
{
|
|
981
|
SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2);
|
|
981
|
SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2);
|
|
982
|
return -1;
|
|
982
|
return -1;
|
|
983
|
}
|
|
983
|
}
|
|
984
|
usleep(1000);
|
|
984
|
usleep(1000);
|
|
985
|
}
|
|
985
|
}
|
|
986
|
this->RMAP_AnswersSem->acquire();
|
|
986
|
this->RMAP_AnswersSem->acquire();
|
|
987
|
}
|
|
987
|
}
|
|
988
|
}
|
|
988
|
}
|
|
989
|
return count;
|
|
989
|
return count;
|
|
990
|
}
|
|
990
|
}
|
|
991
|
|
|
991
|
|
|
992
|
bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size)
|
|
992
|
bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size)
|
|
993
|
{
|
|
993
|
{
|
|
994
|
char protocoleIdentifier;
|
|
994
|
char protocoleIdentifier;
|
|
995
|
USB_SPACEWIRE_STATUS result;
|
|
995
|
USB_SPACEWIRE_STATUS result;
|
|
996
|
USB_SPACEWIRE_ID pIdentifier;
|
|
996
|
USB_SPACEWIRE_ID pIdentifier;
|
|
997
|
SocExplorerEngine::message(this->plugin,"Sending SPW packet",2);
|
|
997
|
SocExplorerEngine::message(this->plugin,"Sending SPW packet",2);
|
|
998
|
this->handleMutex->lock();
|
|
998
|
this->handleMutex->lock();
|
|
999
|
result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier);
|
|
999
|
result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier);
|
|
1000
|
if (result != TRANSFER_SUCCESS)
|
|
1000
|
if (result != TRANSFER_SUCCESS)
|
|
1001
|
{
|
|
1001
|
{
|
|
1002
|
SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2);
|
|
1002
|
SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2);
|
|
1003
|
this->handleMutex->unlock();
|
|
1003
|
this->handleMutex->unlock();
|
|
1004
|
return false;
|
|
1004
|
return false;
|
|
1005
|
}
|
|
1005
|
}
|
|
1006
|
else
|
|
1006
|
else
|
|
1007
|
{
|
|
1007
|
{
|
|
1008
|
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
|
|
|
1009
|
|
|
1010
|
// read the protocole identifier
|
|
1010
|
// read the protocole identifier
|
|
1011
|
protocoleIdentifier = packet[2];
|
|
1011
|
protocoleIdentifier = packet[2];
|
|
1012
|
if (protocoleIdentifier == SPW_PROTO_ID_CCSDS)
|
|
1012
|
if (protocoleIdentifier == SPW_PROTO_ID_CCSDS)
|
|
1013
|
emit ccsdsPacketTransmittedToSpw();
|
|
1013
|
emit ccsdsPacketTransmittedToSpw();
|
|
1014
|
|
|
1014
|
|
|
1015
|
SocExplorerEngine::message(this->plugin,"Packet sent",2);
|
|
1015
|
SocExplorerEngine::message(this->plugin,"Packet sent",2);
|
|
1016
|
USBSpaceWire_FreeSend(hDevice, pIdentifier);
|
|
1016
|
USBSpaceWire_FreeSend(hDevice, pIdentifier);
|
|
1017
|
}
|
|
1017
|
}
|
|
1018
|
this->handleMutex->unlock();
|
|
1018
|
this->handleMutex->unlock();
|
|
1019
|
return true;
|
|
1019
|
return true;
|
|
1020
|
}
|
|
1020
|
}
|
|
1021
|
|
|
1021
|
|
|
1022
|
void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len)
|
|
1022
|
void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len)
|
|
1023
|
{
|
|
1023
|
{
|
|
1024
|
char* packetbuffer = (char*)malloc(len);
|
|
1024
|
char* packetbuffer = (char*)malloc(len);
|
|
1025
|
memcpy(packetbuffer,packet,len);
|
|
1025
|
memcpy(packetbuffer,packet,len);
|
|
1026
|
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);
|
|
1027
|
RMAP_AnswersMtx->lock();
|
|
1027
|
RMAP_AnswersMtx->lock();
|
|
1028
|
RMAP_Answers.append(RMPAPpacket);
|
|
1028
|
RMAP_Answers.append(RMPAPpacket);
|
|
1029
|
RMAP_AnswersMtx->unlock();
|
|
1029
|
RMAP_AnswersMtx->unlock();
|
|
1030
|
}
|
|
1030
|
}
|
|
1031
|
|
|
1031
|
|
|
1032
|
void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff )
|
|
1032
|
void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff )
|
|
1033
|
{
|
|
1033
|
{
|
|
1034
|
if (onOff == true)
|
|
1034
|
if (onOff == true)
|
|
1035
|
{
|
|
1035
|
{
|
|
1036
|
if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1))
|
|
1036
|
if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1))
|
|
1037
|
SocExplorerEngine::message(this->plugin,"Could not enable auto tick-in");
|
|
1037
|
SocExplorerEngine::message(this->plugin,"Could not enable auto tick-in");
|
|
1038
|
}
|
|
1038
|
}
|
|
1039
|
else
|
|
1039
|
else
|
|
1040
|
{
|
|
1040
|
{
|
|
1041
|
if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0))
|
|
1041
|
if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0))
|
|
1042
|
SocExplorerEngine::message(this->plugin,"Could not disable auto tick-in");
|
|
1042
|
SocExplorerEngine::message(this->plugin,"Could not disable auto tick-in");
|
|
1043
|
}
|
|
1043
|
}
|
|
1044
|
}
|
|
1044
|
}
|
|
1045
|
|
|
1045
|
|
|
1046
|
int stardundeeSPW_USB_Manager::getLinkNumber( void )
|
|
1046
|
int stardundeeSPW_USB_Manager::getLinkNumber( void )
|
|
1047
|
{
|
|
1047
|
{
|
|
1048
|
return this->linkNumber;
|
|
1048
|
return this->linkNumber;
|
|
1049
|
}
|
|
1049
|
}
|
|
1050
|
|
|
1050
|
|
|
1051
|
void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency)
|
|
1051
|
void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency)
|
|
1052
|
{
|
|
1052
|
{
|
|
1053
|
U32 rtr_clk_freq;
|
|
1053
|
U32 rtr_clk_freq;
|
|
1054
|
U32 freqCount;
|
|
1054
|
U32 freqCount;
|
|
1055
|
double freqCountInDouble;
|
|
1055
|
double freqCountInDouble;
|
|
1056
|
double currentFrequency;
|
|
1056
|
double currentFrequency;
|
|
1057
|
|
|
1057
|
|
|
1058
|
rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice);
|
|
1058
|
rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice);
|
|
1059
|
freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency;
|
|
1059
|
freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency;
|
|
1060
|
freqCount = (unsigned int) freqCountInDouble;
|
|
1060
|
freqCount = (unsigned int) freqCountInDouble;
|
|
1061
|
|
|
1061
|
|
|
1062
|
currentFrequency = ((double) rtr_clk_freq) / ((double) freqCount);
|
|
1062
|
currentFrequency = ((double) rtr_clk_freq) / ((double) freqCount);
|
|
1063
|
|
|
1063
|
|
|
1064
|
//**************************************************
|
|
1064
|
//**************************************************
|
|
1065
|
// auto _ tick _ freq = rtr _ clk _ freq / freqCount
|
|
1065
|
// auto _ tick _ freq = rtr _ clk _ freq / freqCount
|
|
1066
|
if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, freqCount) )
|
|
1066
|
if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, freqCount) )
|
|
1067
|
SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency");
|
|
1067
|
SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency");
|
|
1068
|
else
|
|
1068
|
else
|
|
1069
|
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");
|
|
1070
|
}
|
|
1070
|
}
|
|
1071
|
|
|
1071
|
|
|
|
|
|
1072
|
void stardundeeSPW_USB_Manager::sendOneTimecode( unsigned char nTimein )
|
|
|
|
|
1073
|
{
|
|
|
|
|
1074
|
// enable external timecode selection
|
|
|
|
|
1075
|
if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,1))
|
|
|
|
|
1076
|
SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** enable external timecode selection");
|
|
|
|
|
1077
|
|
|
|
|
|
1078
|
if (!USBSpaceWire_TC_PerformTickIn( hDevice, nTimein) )
|
|
|
|
|
1079
|
SocExplorerEngine::message( this->plugin,"sendOneTimecode *** ERR *** Could not send the requested timecode: " + QString::number(nTimein) );
|
|
|
|
|
1080
|
else
|
|
|
|
|
1081
|
SocExplorerEngine::message( this->plugin,"sendOneTimecode *** OK *** timecode sent " + QString::number(nTimein) );
|
|
|
|
|
1082
|
|
|
|
|
|
1083
|
// disable external timecode selection
|
|
|
|
|
1084
|
if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0))
|
|
|
|
|
1085
|
SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** disable external timecode selection");
|
|
|
|
|
1086
|
}
|
|
1072
|
|
|
1087
|
|
|
1073
|
|
|
1088
|
|
|
1074
|
|
|
|
|