##// END OF EJS Templates
Backported SPW work from GRESB branch.
Alexis Jeandet -
r78:61fd409c32ee default
parent child
Show More
@@ -10,6 +10,7 SUBDIRS = \
10 10 genericrwplugin \
11 11 memctrlrplugin \
12 12 memcheckplugin
13
13 14 unix:SUBDIRS += spwplugin
14 15
15 16 OTHER_FILES += SocExplorer-plugins.spec
@@ -85,7 +85,8 void GR_ESB_bridge::setIP(QString ip)
85 85
86 86 void GR_ESB_bridge::setVirtualLink(QString vlink)
87 87 {
88 vlink = vlink.section("Virtual link",0,0);
88 //vlink = vlink.section(,0,0);
89 vlink.remove("Virtual link");
89 90 bool success;
90 91 int vlinkTmp = vlink.toInt(&success);
91 92 if(success)
@@ -105,20 +106,169 void GR_ESB_bridge::setVirtualLink(qint3
105 106
106 107 unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address)
107 108 {
108 // TODO write ME!
109 Q_UNUSED(count)
110 Q_UNUSED(Value)
111 Q_UNUSED(address)
112 return 0;
109 char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))];
110 char *RMAPAckBuff;
111 int transactionID = 0;
112 int written=0;
113 SocExplorerEngine::message(this->plugin,"Enter Write function",2);
114 QProgressBar* progress=NULL;
115 SocExplorerAutoProgressBar autopb;
116 if(count>RMAP_MAX_XFER_SIZE)
117 {
118 progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
119 autopb.setProgressBar(progress);
120 }
121 //Quite stupide loop, I guess that I always get the number of byte I asked for!
122 while(count>=RMAP_MAX_XFER_SIZE)
123 {
124 for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++)
125 {
126 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+0] = (char)(((unsigned int)Value[i+written]>>24)&0xFF);
127 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>16)&0xFF);
128 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
129 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written])&0xFF);
130 }
131 transactionID=manager->getRMAPtransactionID();
132 SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2);
133 RMAP_build_tx_request_header(
134 this->manager->destinationLogicalAddress,
135 this->manager->destinationKey,
136 this->manager->sourceLogicalAddress,
137 transactionID,
138 address+(written*4),
139 RMAP_MAX_XFER_SIZE*4,
140 writeBuffer);
141 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4));
142 manager->getRMAPanswer(transactionID,&RMAPAckBuff);
143 free(RMAPAckBuff);
144 written+=RMAP_MAX_XFER_SIZE;
145 count-=RMAP_MAX_XFER_SIZE;
146 progress->setValue(written);
147 qApp->processEvents();
148 }
149 if(count>0)
150 {
151 for(int i=0;i<((int)count);i++)
152 {
153 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+0] = (char)(((unsigned int)Value[i+written]>>24)&0xFF);
154 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>16)&0xFF);
155 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
156 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written])&0xFF);
157 }
158 transactionID=manager->getRMAPtransactionID();
159 SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2);
160 RMAP_build_tx_request_header(
161 this->manager->destinationLogicalAddress,
162 this->manager->destinationKey,
163 this->manager->sourceLogicalAddress,
164 transactionID,
165 address+(written*4),
166 count*4,
167 writeBuffer);
168 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4));
169 manager->getRMAPanswer(transactionID,&RMAPAckBuff);
170 free(RMAPAckBuff);
171 written+=count;
172 if(progress!=NULL)
173 {
174 progress->setValue(written);
175 qApp->processEvents();
176 }
177 }
178 return written;
113 179 }
114 180
115 181 unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address)
116 182 {
117 // TODO write ME!
118 Q_UNUSED(Value)
119 Q_UNUSED(count)
120 Q_UNUSED(address)
121 return 0;
183 char requestBuffer[RMAP_READ_HEADER_MIN_SZ];
184 char* RMAP_AnswerBuffer;
185 requestBuffer[0]=this->manager->linkNumber;//Link number
186 int transactionID = 0;
187 int read=0;
188 QProgressBar* progress=NULL;
189 SocExplorerAutoProgressBar autopb;
190 if(count>RMAP_MAX_XFER_SIZE)
191 {
192 progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
193 autopb.setProgressBar(progress);
194 }
195 SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2);
196
197 //Quite stupide loop, I guess that I always get the number of byte I asked for!
198 while((int)count>=(int)RMAP_MAX_XFER_SIZE)
199 {
200 transactionID = manager->getRMAPtransactionID();
201 SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2);
202 RMAP_build_rx_request_header(
203 this->manager->destinationLogicalAddress,
204 this->manager->destinationKey,
205 this->manager->sourceLogicalAddress,
206 transactionID,
207 address+(read*4),
208 RMAP_MAX_XFER_SIZE*4,
209 requestBuffer);
210 manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ);
211 int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
212 if(len==-1)
213 {
214 this->toggleBridgeConnection();
215 return 0;
216 }
217 for(int i=0;i<((len-13)/4);i++)
218 {
219 Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
220 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13]));
221 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14]));
222 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15]));
223 }
224 free(RMAP_AnswerBuffer);
225 read+=RMAP_MAX_XFER_SIZE;
226 count-=RMAP_MAX_XFER_SIZE;
227 if(progress!=NULL)
228 {
229 progress->setValue(read);
230 qApp->processEvents();
231 }
232 }
233 if((int)count>0)
234 {
235 transactionID = manager->getRMAPtransactionID();
236 SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2);
237 SocExplorerEngine::message(this->plugin,QString("Building request with:"),2);
238 SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2);
239 SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2);
240 SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2);
241 RMAP_build_rx_request_header(
242 this->manager->destinationLogicalAddress,
243 this->manager->destinationKey,
244 this->manager->sourceLogicalAddress,
245 transactionID,
246 address+(read*4),
247 count*4,
248 requestBuffer);
249 manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ);
250 int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
251 if(len==-1)
252 {
253 this->toggleBridgeConnection();
254 return 0;
255 }
256 for(int i=0;i<((len-13)/4);i++)
257 {
258 Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
259 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13]));
260 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14]));
261 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15]));
262 }
263 free(RMAP_AnswerBuffer);
264 read+=count;
265 if(progress!=NULL)
266 {
267 progress->setValue(read);
268 qApp->processEvents();
269 }
270 }
271 return read;
122 272 }
123 273
124 274 int GR_ESB_bridge::pushRMAPPacket(char *packet, int size)
@@ -128,40 +278,139 int GR_ESB_bridge::pushRMAPPacket(char *
128 278
129 279
130 280 GR_ESB_Manager::GR_ESB_Manager(socexplorerplugin *plugin, QObject *parent)
131 :QThread((QObject*)parent)
281 :abstractSpwManager(plugin, parent)
132 282 {
133 this->Read_soc = new QTcpSocket(this);
134 this->Write_soc = new QTcpSocket(this);
135 this->RMAPtimeout = 2000;
136 this->handleMutex = new QMutex(QMutex::NonRecursive);
137 this->RMAP_AnswersSem = new QSemaphore(0);
138 this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
139 this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
140 this->plugin = plugin;
141 connected = false;
142 this->moveToThread(this);
283 this->sourceLogicalAddress=32;
284 this->destinationLogicalAddress=254;
285 this->destinationKey=2;
286 connect(&(this->Read_soc),SIGNAL(readyRead()),this,SLOT(readyRead()));
143 287 }
144 288
145 289 GR_ESB_Manager::~GR_ESB_Manager()
146 290 {
291 }
147 292
293 void GR_ESB_Manager::__processPacket(packetBuffer_t *packet)
294 {
295 if(packet->complete)
296 {
297 if(packet->buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet
298 {
299 RMAP_Answer* RMapPacket;
300 SocExplorerEngine::message(this->plugin,"Got RMAP packet",2);
301 SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(packet->PacketLen),2);
302 char* packetbuffer = (char*)malloc(packet->PacketLen);
303 if(packetbuffer)
304 {
305 memcpy(packetbuffer,packet->buffer,packet->PacketLen);
306 this->handleMutex->unlock();
307 if(packet->PacketLen==8)
308 {
309 RMapPacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer),packetbuffer,packet->PacketLen);
310 }
311 else
312 {
313 RMapPacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer),packetbuffer,packet->PacketLen);
314 }
315 RMAP_AnswersMtx->lock();
316 RMAP_Answers.append(RMapPacket);
317 RMAP_AnswersMtx->unlock();
318 RMAP_AnswersSem->release();
319 }
320 }
321 else //any non-rmap packet will be pushed to the network
322 {
323 char* packetbuffer = (char*)malloc(packet->PacketLen);
324 if(packetbuffer)
325 {
326 memcpy(packetbuffer,packet->buffer,packet->PacketLen);
327 emit emitPacket(packetbuffer,packet->PacketLen);
328 SocExplorerEngine::message(this->plugin,"Got SPW packet",2);
329 }
330 }
331 }
332
333 }
334
335 QByteArray GR_ESB_Manager::__processData(const QByteArray &data, packetBuffer_t *buffer)
336 {
337 if(buffer->complete)
338 {
339 if(Q_UNLIKELY(data.size()<=4))
340 return data;
341 buffer->PacketLen= ((int)data.at(3)& 0x0FF) + (((int)data.at(2)& 0x0FF)<<8) + (((int)data.at(1)& 0x0FF)<<16);
342 if(buffer->PacketLen>(data.size()-4))
343 {
344 memcpy(buffer->buffer,data.data()+4,data.size()-4);
345 buffer->complete=false;
346 buffer->index=data.size()-4;
347 }
348 else
349 {
350 memcpy(buffer->buffer,data.data()+4,data.size()-4);
351 buffer->PacketLen = data.size()-4;
352 buffer->index=data.size()-4;
353 buffer->complete=true;
354 __processPacket(buffer);
355 int len = buffer->PacketLen;
356 buffer->PacketLen = 0;
357 buffer->index=0;
358 if((data.size()-4-len))
359 {
360 return __processData(data.right((data.size()-4-len)),buffer);
361 }
362 }
363
364 }
365 else
366 {
367 if(buffer->PacketLen>(data.size()+buffer->index))
368 {
369 memcpy(buffer->buffer+buffer->index,data.data(),data.size());
370 buffer->complete=false;
371 buffer->index+=data.size();
372 }
373 else
374 {
375 memcpy(buffer->buffer+buffer->index,data.data(),buffer->PacketLen-buffer->index);
376 buffer->complete=true;
377 buffer->index+=data.size();
378 __processPacket(buffer);
379 int len = buffer->PacketLen;
380 buffer->PacketLen = 0;
381 buffer->index=0;
382 if((data.size()-len))
383 {
384 return __processData(data.right((data.size()-len)),buffer);
385 }
386 }
387 }
388 return QByteArray();
148 389 }
149 390
150 391 void GR_ESB_Manager::run()
151 392 {
393 char bufferData[(RMAP_MAX_XFER_SIZE*4)+50];
394 packetBuffer_t buffer={bufferData,0,0,true};
152 395 SocExplorerEngine::message(this->plugin,"Starting GRESB pooling thread",1);
396 QByteArray data;
153 397 while (!this->isInterruptionRequested())
154 398 {
155 399 if(this->connected)
156 400 {
157 handleMutex->lock();
158 SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4);
401 SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",8);
402 if(!incomingPackets.isEmpty())
403 {
404 incomingPacketsMutex.lock();
405 data.append(incomingPackets.dequeue());
406 this->incomingPacketsMutex.unlock();
407 data = __processData(data,&buffer);
408 }
159 409
160 410 }
161 411 else
162 412 {
163 413 //do some sanity checks!
164
165 414 usleep(RMAPtimeout/2);
166 415 }
167 416 usleep(1000);
@@ -172,21 +421,23 void GR_ESB_Manager::run()
172 421 bool GR_ESB_Manager::connectBridge()
173 422 {
174 423 int timeout=60;
175 if(this->Read_soc->state()==QTcpSocket::UnconnectedState)
424 this->connected = false;
425 if(this->Read_soc.state()==QTcpSocket::UnconnectedState)
176 426 {
177 this->Read_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Read_port);
178 this->Read_soc->waitForConnected(30000);
427 this->Read_soc.connectToHost(IP,gresb_Conf[virtualLinkIndex].Receive_port);
428 this->Read_soc.waitForConnected(30000);
179 429 }
180 if(this->Write_soc->state()==QTcpSocket::UnconnectedState)
430 if(this->Write_soc.state()==QTcpSocket::UnconnectedState)
181 431 {
182 this->Write_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Write_port);
183 this->Write_soc->waitForConnected(30000);
432 this->Write_soc.connectToHost(IP,gresb_Conf[virtualLinkIndex].Transmit_port);
433 this->Write_soc.waitForConnected(30000);
184 434 }
185 while((this->Read_soc->state()!=QTcpSocket::ConnectedState) && (this->Write_soc->state()!=QTcpSocket::ConnectedState))
435 while((this->Read_soc.state()!=QTcpSocket::ConnectedState) && (this->Write_soc.state()!=QTcpSocket::ConnectedState))
186 436 {
187 437 usleep(100000);
188 438 if(timeout--==0)return false;
189 439 }
440 this->connected = true;
190 441 return true;
191 442
192 443 }
@@ -194,17 +445,17 bool GR_ESB_Manager::connectBridge()
194 445 bool GR_ESB_Manager::disconnectBridge()
195 446 {
196 447 int timeout=60;
197 if(this->Read_soc->state()!=QTcpSocket::UnconnectedState)
448 if(this->Read_soc.state()!=QTcpSocket::UnconnectedState)
198 449 {
199 this->Read_soc->disconnectFromHost();
200 this->Read_soc->waitForDisconnected(30000);
450 this->Read_soc.disconnectFromHost();
451 this->Read_soc.waitForDisconnected(30000);
201 452 }
202 if(this->Write_soc->state()!=QTcpSocket::UnconnectedState)
453 if(this->Write_soc.state()!=QTcpSocket::UnconnectedState)
203 454 {
204 this->Write_soc->disconnectFromHost();
205 this->Write_soc->waitForDisconnected(30000);
455 this->Write_soc.disconnectFromHost();
456 this->Write_soc.waitForDisconnected(30000);
206 457 }
207 while((this->Read_soc->state()!=QTcpSocket::UnconnectedState) && (this->Write_soc->state()!=QTcpSocket::UnconnectedState))
458 while((this->Read_soc.state()!=QTcpSocket::UnconnectedState) && (this->Write_soc.state()!=QTcpSocket::UnconnectedState))
208 459 {
209 460 usleep(100000);
210 461 if(timeout--==0)return false;
@@ -212,31 +463,52 bool GR_ESB_Manager::disconnectBridge()
212 463 return true;
213 464 }
214 465
215 int GR_ESB_Manager::getRMAPtransactionID()
216 {
217 // TODO write ME!
218 return -1;
219 }
220
221 int GR_ESB_Manager::getRMAPanswer(int transactionID, char **buffer)
222 {
223 // TODO write ME!
224 Q_UNUSED(transactionID)
225 Q_UNUSED(buffer)
226 return -1;
227 }
228 466
229 467 bool GR_ESB_Manager::sendPacket(char *packet, int size)
230 468 {
231 // TODO write ME!
232 Q_UNUSED(packet)
233 Q_UNUSED(size)
234 return false;
469 bool result = false;
470 char protocoleIdentifier;
471 SocExplorerEngine::message(this->plugin,"Sending SPW packet",2);
472 if(Q_UNLIKELY(this->Write_soc.state()!=QAbstractSocket::ConnectedState))
473 {
474 SocExplorerEngine::message(this->plugin,"Socket closed",2);
475 //TODO handle disconnection
476 }
477 char* SPWpacket = (char*)malloc(size+4);
478 if(SPWpacket!=NULL)
479 {
480 SPWpacket[0]=0; //Protocol = spw
481 memcpy(SPWpacket+4,packet,size);
482 SPWpacket[1]=(size>>16) & 0x0FF;
483 SPWpacket[2]=(size>>8) & 0x0FF;
484 SPWpacket[3]=size & 0x0FF;
485 this->handleMutex->lock();
486 result = ((size+4) == this->Write_soc.write(SPWpacket,size+4));
487 this->Write_soc.flush();
488 this->handleMutex->unlock();
489 free(SPWpacket);
490 }
491 if (Q_UNLIKELY(!result))
492 {
493 SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2);
494 return false;
495 }
496 else
497 {
498 emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link
499 // read the protocole identifier
500 protocoleIdentifier = packet[2];
501 if (protocoleIdentifier == SPW_PROTO_ID_CCSDS)
502 emit ccsdsPacketTransmittedToSpw();
503 SocExplorerEngine::message(this->plugin,"Packet sent",2);
504 }
505 return true;
235 506 }
236 507
237 void GR_ESB_Manager::pushRmapPacket(char *packet, int len)
508 void GR_ESB_Manager::readyRead()
238 509 {
239 // TODO write ME!
240 Q_UNUSED(packet)
241 Q_UNUSED(len)
510 incomingPacketsMutex.lock();
511 incomingPackets.append(Read_soc.readAll());
512 incomingPacketsMutex.unlock();
242 513 }
514
@@ -5,56 +5,64
5 5 #include <QThread>
6 6 #include <QMutex>
7 7 #include <QSemaphore>
8 #include <QQueue>
8 9
9 10 struct gresb_Conf_str
10 11 {
11 qint32 Read_port;
12 qint32 Write_port;
12 qint32 Transmit_port;
13 qint32 Receive_port;
13 14 };
14 15
15 16
16 17 const struct gresb_Conf_str gresb_Conf[]=
17 18 {
18 {3000,3001}, //Virtual link 0
19 {3002,3003}, //Virtual link 1
20 {3004,3005}, //Virtual link 2
21 {3006,3007}, //Virtual link 3
22 {3008,3009}, //Virtual link 4
23 {3010,3011} //Virtual link 5
19 {3000,3001}, //Virtual link 0
20 {3002,3003}, //Virtual link 1
21 {3004,3005}, //Virtual link 2
22 {3006,3007}, //Virtual link 3
23 {3008,3009}, //Virtual link 4
24 {3010,3011} //Virtual link 5
24 25 };
25 26
26 27
27 class GR_ESB_Manager: public QThread
28 class GR_ESB_Manager: public abstractSpwManager
28 29 {
29 30 Q_OBJECT
31
32 typedef struct packetBuffer_t
33 {
34 char* buffer;
35 int PacketLen;
36 int index;
37 bool complete;
38 }packetBuffer_t;
39
30 40 public:
31 41 explicit GR_ESB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0);
32 42 ~GR_ESB_Manager();
33 43 void run();
34 44 bool connectBridge();
35 45 bool disconnectBridge();
36 int getRMAPtransactionID();
37 int getRMAPanswer(int transactionID,char** buffer);
38 46 bool sendPacket(char* packet,int size);
39 47
40 48 signals:
41 49 void emitPacket(char* packet,int size);
42 50 private:
43 QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
44 QSemaphore* RMAP_AnswersSem;
45 51 void pushRmapPacket(char* packet,int len);
46 socexplorerplugin* plugin;
47 bool connected;
48 52 char* SPWPacketBuff;
49 QList<RMAP_Answer*> RMAP_Answers;
50 QList<int> RMAP_pending_transaction_IDs;
53
54 void __processPacket(packetBuffer_t *packet);
55 QByteArray __processData(const QByteArray &data, packetBuffer_t* buffer);
56 private slots:
57 void readyRead();
51 58
52 59 public:
53 QTcpSocket* Read_soc;
54 QTcpSocket* Write_soc;
60 QTcpSocket Read_soc;
61 QTcpSocket Write_soc;
62 QMutex incomingPacketsMutex;
63 QQueue<QByteArray> incomingPackets;
55 64 QString IP;
56 65 int virtualLinkIndex;
57 int RMAPtimeout;
58 66 };
59 67
60 68
@@ -6,8 +6,8
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 <width>968</width>
10 <height>392</height>
9 <width>978</width>
10 <height>518</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
@@ -30,7 +30,188
30 30 <string>Config</string>
31 31 </attribute>
32 32 <layout class="QGridLayout" name="gridLayout_2">
33 <item row="1" column="1">
33 <item row="4" column="2">
34 <widget class="QLineEdit" name="destinationAddressLineEdit">
35 <property name="toolTip">
36 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the RMAP target address, this address will be used as destination address for all the RMAP transfers.&lt;/p&gt;&lt;p&gt;This is you SOC spw address.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
37 </property>
38 <property name="inputMask">
39 <string comment="ddD"/>
40 </property>
41 <property name="text">
42 <string>254</string>
43 </property>
44 <property name="maxLength">
45 <number>3</number>
46 </property>
47 </widget>
48 </item>
49 <item row="11" column="0" colspan="3">
50 <widget class="QWidget" name="widget" native="true">
51 <layout class="QGridLayout" name="gridLayout">
52 <item row="0" column="2">
53 <widget class="QLabel" name="label_7">
54 <property name="font">
55 <font>
56 <weight>75</weight>
57 <bold>true</bold>
58 </font>
59 </property>
60 <property name="text">
61 <string>Transmitted</string>
62 </property>
63 </widget>
64 </item>
65 <item row="1" column="1">
66 <widget class="QLabel" name="ReceivedPackets">
67 <property name="text">
68 <string>-</string>
69 </property>
70 </widget>
71 </item>
72 <item row="2" column="2">
73 <widget class="QLabel" name="TransmittedBytes">
74 <property name="text">
75 <string>-</string>
76 </property>
77 </widget>
78 </item>
79 <item row="2" column="0">
80 <widget class="QLabel" name="label_5">
81 <property name="text">
82 <string>Bytes</string>
83 </property>
84 </widget>
85 </item>
86 <item row="2" column="1">
87 <widget class="QLabel" name="ReceivedBytes">
88 <property name="text">
89 <string>-</string>
90 </property>
91 </widget>
92 </item>
93 <item row="1" column="2">
94 <widget class="QLabel" name="TransmittedPackets">
95 <property name="text">
96 <string>-</string>
97 </property>
98 </widget>
99 </item>
100 <item row="0" column="1">
101 <widget class="QLabel" name="label_3">
102 <property name="font">
103 <font>
104 <weight>75</weight>
105 <bold>true</bold>
106 </font>
107 </property>
108 <property name="text">
109 <string>Received</string>
110 </property>
111 </widget>
112 </item>
113 <item row="1" column="0">
114 <widget class="QLabel" name="label_4">
115 <property name="text">
116 <string>Packets</string>
117 </property>
118 </widget>
119 </item>
120 <item row="0" column="0">
121 <widget class="QPushButton" name="resetStatsQpb">
122 <property name="text">
123 <string>Reset stats</string>
124 </property>
125 </widget>
126 </item>
127 </layout>
128 </widget>
129 </item>
130 <item row="3" column="2">
131 <widget class="QLineEdit" name="sourceAddressLineEdit">
132 <property name="toolTip">
133 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the Space Wire Brick destination Key, the default value is 32 (0x20).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
134 </property>
135 <property name="inputMask">
136 <string comment="ddD"/>
137 </property>
138 <property name="text">
139 <string>32</string>
140 </property>
141 <property name="maxLength">
142 <number>3</number>
143 </property>
144 </widget>
145 </item>
146 <item row="8" column="2">
147 <widget class="QLineEdit" name="RMAPTimeoutLineEdit">
148 <property name="toolTip">
149 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the RMAP timeout, when waiting for a RMAP answer the driver will give up after this time if it doesn't get any answer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
150 </property>
151 <property name="inputMethodHints">
152 <set>Qt::ImhDigitsOnly</set>
153 </property>
154 <property name="inputMask">
155 <string comment="DDdd;"/>
156 </property>
157 <property name="text">
158 <string>500</string>
159 </property>
160 <property name="maxLength">
161 <number>5</number>
162 </property>
163 </widget>
164 </item>
165 <item row="2" column="2">
166 <widget class="QComboBox" name="GRESB_LinkNum_CmBx">
167 <item>
168 <property name="text">
169 <string>SPW0</string>
170 </property>
171 </item>
172 <item>
173 <property name="text">
174 <string>SPW1</string>
175 </property>
176 </item>
177 <item>
178 <property name="text">
179 <string>SPW2</string>
180 </property>
181 </item>
182 </widget>
183 </item>
184 <item row="4" column="0">
185 <widget class="QLabel" name="RMAPaddressLbl">
186 <property name="text">
187 <string>Destination address</string>
188 </property>
189 </widget>
190 </item>
191 <item row="6" column="2">
192 <widget class="QLineEdit" name="destinationKeyLineEdit">
193 <property name="toolTip">
194 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the RMAP target key, this key will be used for all the RMAP transfers.&lt;/p&gt;&lt;p&gt;This is you SOC spw key.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
195 </property>
196 <property name="inputMask">
197 <string comment="ddD"/>
198 </property>
199 <property name="text">
200 <string comment="ddD">2</string>
201 </property>
202 <property name="maxLength">
203 <number>3</number>
204 </property>
205 </widget>
206 </item>
207 <item row="1" column="0">
208 <widget class="QLabel" name="GRESB_Vlink_Lbl">
209 <property name="text">
210 <string>GR-ESB Virtual link</string>
211 </property>
212 </widget>
213 </item>
214 <item row="1" column="2">
34 215 <widget class="QComboBox" name="GRESB_Vlink_CmBx">
35 216 <item>
36 217 <property name="text">
@@ -64,33 +245,21
64 245 </item>
65 246 </widget>
66 247 </item>
67 <item row="1" column="0">
68 <widget class="QLabel" name="GRESB_Vlink_Lbl">
248 <item row="3" column="0">
249 <widget class="QLabel" name="setDestKeyLbl">
69 250 <property name="text">
70 <string>GR-ESB Virtual link</string>
251 <string>Source address</string>
71 252 </property>
72 253 </widget>
73 254 </item>
74 <item row="2" column="1">
75 <widget class="QComboBox" name="GRESB_LinkNum_CmBx">
76 <item>
77 <property name="text">
78 <string>SPW0</string>
79 </property>
80 </item>
81 <item>
82 <property name="text">
83 <string>SPW1</string>
84 </property>
85 </item>
86 <item>
87 <property name="text">
88 <string>SPW2</string>
89 </property>
90 </item>
255 <item row="8" column="0">
256 <widget class="QLabel" name="RMAPTimeoutLbl">
257 <property name="text">
258 <string>RMAP timeout(ms)</string>
259 </property>
91 260 </widget>
92 261 </item>
93 <item row="0" column="1">
262 <item row="0" column="2">
94 263 <widget class="QLineEdit" name="GRESB_IP_lineEdit"/>
95 264 </item>
96 265 <item row="2" column="0">
@@ -100,6 +269,13
100 269 </property>
101 270 </widget>
102 271 </item>
272 <item row="6" column="0">
273 <widget class="QLabel" name="RMAPKeyLbl">
274 <property name="text">
275 <string>Destination key</string>
276 </property>
277 </widget>
278 </item>
103 279 <item row="0" column="0">
104 280 <widget class="QLabel" name="GRESB_IP_Lbl">
105 281 <property name="text">
@@ -107,7 +283,7
107 283 </property>
108 284 </widget>
109 285 </item>
110 <item row="3" column="0" colspan="2">
286 <item row="10" column="0" colspan="3">
111 287 <widget class="QPushButton" name="connectQpb">
112 288 <property name="text">
113 289 <string>Connect</string>
@@ -125,7 +301,7
125 301 </attribute>
126 302 <layout class="QHBoxLayout" name="horizontalLayout">
127 303 <item>
128 <widget class="QWebView" name="WebView" native="true"/>
304 <widget class="QWebView" name="WebView"/>
129 305 </item>
130 306 </layout>
131 307 </widget>
@@ -137,7 +313,7
137 313 <customwidget>
138 314 <class>QWebView</class>
139 315 <extends>QWidget</extends>
140 <header location="global">QWebView</header>
316 <header>QtWebKitWidgets/QWebView</header>
141 317 <container>1</container>
142 318 </customwidget>
143 319 </customwidgets>
@@ -40,11 +40,11 stardundeeSPW_USB::stardundeeSPW_USB(soc
40 40 Q_UNUSED(parent)
41 41 this->manager = new stardundeeSPW_USB_Manager(parent,this);
42 42 makeGUI(parent);
43 this->manager->start();
44 43 connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int)));
45 44 connect(this->manager, SIGNAL(bytesReceivedFromSpw(uint)), this, SIGNAL(BytesReceivedFromSpw(uint)));
46 45 connect(this->manager, SIGNAL(bytesTransmittedToSpw(uint)), this, SIGNAL(BytesTransmittedToSpw(uint)));
47 46 connect(this->manager, SIGNAL(ccsdsPacketTransmittedToSpw()), this, SIGNAL(CCSDSPacketTransmittedToSpw()));
47 this->manager->start();
48 48 }
49 49
50 50 stardundeeSPW_USB::~stardundeeSPW_USB()
@@ -215,8 +215,11 unsigned int stardundeeSPW_USB::Read(uns
215 215 free(RMAP_AnswerBuffer);
216 216 read+=RMAP_MAX_XFER_SIZE;
217 217 count-=RMAP_MAX_XFER_SIZE;
218 progress->setValue(read);
219 qApp->processEvents();
218 if(progress!=NULL)
219 {
220 progress->setValue(read);
221 qApp->processEvents();
222 }
220 223 }
221 224 if((int)count>0)
222 225 {
@@ -329,7 +332,6 void stardundeeSPW_USB::makeGUI(socexplo
329 332 {
330 333 Q_UNUSED(parent)
331 334 this->p_GUI = new StarDundeeGUI();
332 // this->mainLayout = new QGridLayout(this->p_GUI);
333 335 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection()));
334 336 connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int)));
335 337 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int)));
@@ -400,16 +402,8 void stardundeeSPW_USB::sendPacketComing
400 402 }
401 403
402 404 stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent)
403 :QThread((QObject*)parent)
405 :abstractSpwManager(plugin, parent)
404 406 {
405 this->RMAPtimeout = 2000;
406 this->handleMutex = new QMutex(QMutex::NonRecursive);
407 // this->handleMutex = new QMutex(QMutex::Recursive);
408 this->RMAP_AnswersSem = new QSemaphore(0);
409 this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
410 this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
411 this->plugin = plugin;
412 connected = false;
413 407 // TODO remove this crap!
414 408 this->initDialog();
415 409 // this->moveToThread(this);
@@ -417,10 +411,6 stardundeeSPW_USB_Manager::stardundeeSPW
417 411
418 412 stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager()
419 413 {
420 this->terminate();
421 while (!this->isFinished()) {
422 this->usleep(1000);
423 }
424 414 }
425 415
426 416 void stardundeeSPW_USB_Manager::run()
@@ -867,7 +857,7 void stardundeeSPW_USB_Manager::initiali
867 857 unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link)
868 858 {
869 859 U32 statusControl, errorStatus, portType;
870 U32 linkStatus, operatingSpeed, outputPortConnection;
860 U32 linkStatus=0, operatingSpeed, outputPortConnection;
871 861 char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate;
872 862
873 863 // Read the link status control register
@@ -912,9 +902,9 unsigned int stardundeeSPW_USB_Manager::
912 902 bool stardundeeSPW_USB_Manager::disconnectBridge()
913 903 {
914 904 this->handleMutex->lock();
905 USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports
915 906 USBSpaceWire_Close(hDevice); // Close the device
916 907 SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0);
917 USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports
918 908 this->handleMutex->unlock();
919 909 this->RMAP_pending_transaction_IDsMtx->lock();
920 910 this->RMAP_pending_transaction_IDs.clear();
@@ -926,84 +916,6 bool stardundeeSPW_USB_Manager::disconne
926 916 return true;
927 917 }
928 918
929 int stardundeeSPW_USB_Manager::getRMAPtransactionID()
930 {
931 this->RMAP_pending_transaction_IDsMtx->lock();
932 int ID=0;
933 bool found=true;
934 while(ID<511)
935 {
936 for(int i=0;i<RMAP_pending_transaction_IDs.count();i++)
937 {
938 if(RMAP_pending_transaction_IDs[i]==ID)found=false;
939 }
940 if(found==true)break;
941 ID++;
942 found = true;
943 }
944 if(found)
945 {
946 RMAP_pending_transaction_IDs.append(ID);
947 }
948 this->RMAP_pending_transaction_IDsMtx->unlock();
949 return ID;
950 }
951
952 int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer)
953 {
954 QTime timeout;
955 *buffer=NULL;
956 int count=0;
957 SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2);
958 timeout.start();
959 while (*buffer==NULL)
960 {
961 this->RMAP_AnswersMtx->lock();
962 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2);
963 SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2);
964 for(int i=0;i<RMAP_Answers.count();i++)
965 {
966 SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2);
967 if(RMAP_Answers[i]->transactionID==transactionID)
968 {
969 this->RMAP_pending_transaction_IDsMtx->lock();
970 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2);
971 for(int j=0;j<RMAP_pending_transaction_IDs.count();j++)
972 {
973 if(RMAP_pending_transaction_IDs[j]==transactionID)
974 {
975 RMAP_pending_transaction_IDs.removeAt(j);
976 }
977 }
978 this->RMAP_pending_transaction_IDsMtx->unlock();
979 *buffer = RMAP_Answers[i]->data;
980 count = RMAP_Answers[i]->len;
981 RMAP_Answer* tmp=RMAP_Answers[i];
982 RMAP_Answers.removeAt(i);
983 delete tmp;
984 }
985 }
986 this->RMAP_AnswersMtx->unlock();
987 //if no answer found in the stack wait until a new packet is pushed
988 SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2);
989 if(*buffer==NULL)
990 {
991 while (0==this->RMAP_AnswersSem->available())
992 {
993 SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2);
994 if(timeout.elapsed()>=RMAPtimeout)
995 {
996 SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2);
997 return -1;
998 }
999 usleep(1000);
1000 }
1001 this->RMAP_AnswersSem->acquire();
1002 }
1003 }
1004 return count;
1005 }
1006
1007 919 bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size)
1008 920 {
1009 921 char protocoleIdentifier;
@@ -1032,15 +944,6 bool stardundeeSPW_USB_Manager::sendPack
1032 944 return true;
1033 945 }
1034 946
1035 void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len)
1036 {
1037 char* packetbuffer = (char*)malloc(len);
1038 memcpy(packetbuffer,packet,len);
1039 RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len);
1040 RMAP_AnswersMtx->lock();
1041 RMAP_Answers.append(RMPAPpacket);
1042 RMAP_AnswersMtx->unlock();
1043 }
1044 947
1045 948 void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff )
1046 949 {
@@ -41,7 +41,7
41 41 #define BRICK_IS_SET_AS_AN_INTERFACE true
42 42 #define BRICK_IS_SET_AS_A_ROUTER false
43 43
44 class stardundeeSPW_USB_Manager: public QThread
44 class stardundeeSPW_USB_Manager: public abstractSpwManager
45 45 {
46 46 Q_OBJECT
47 47 public:
@@ -58,8 +58,6 public:
58 58 void setTimecodeFrequency(double requestedFrequency);
59 59 unsigned int getLinkStatus(unsigned char link);
60 60 bool disconnectBridge();
61 int getRMAPtransactionID();
62 int getRMAPanswer(int transactionID,char** buffer);
63 61 bool sendPacket(char* packet,int size);
64 62
65 63 signals:
@@ -75,15 +73,8 public slots:
75 73 int getLinkNumber( void );
76 74
77 75 private:
78 QMutex *handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
79 QSemaphore* RMAP_AnswersSem;
80 void pushRmapPacket(char* packet,int len);
76 //QSemaphore* RMAP_AnswersSem;
81 77 star_device_handle hDevice;
82 socexplorerplugin* plugin;
83 bool connected;
84 char* SPWPacketBuff;
85 QList<RMAP_Answer*> RMAP_Answers;
86 QList<int> RMAP_pending_transaction_IDs;
87 78
88 79 QLabel *starDundeeStatusQueryDialogLabel;
89 80 QPushButton *starDundeeStatusQueryRetryButton;
@@ -96,13 +87,8 private:
96 87
97 88 public:
98 89 int selectedBrick;
99 int linkNumber;
100 90 int brickList;
101 91 int linkSpeed;
102 int sourceLogicalAddress;
103 int destinationLogicalAddress;
104 int destinationKey;
105 int RMAPtimeout;
106 92 double timecodeFrequency;
107 93 bool interfaceMode; // 1 => interface mode, 0 => router mode
108 94 };
@@ -20,6 +20,8
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "abstractspwbridge.h"
23 #include <QTime>
24 #include <socexplorerengine.h>
23 25
24 26 abstractSpwBridge::abstractSpwBridge(socexplorerplugin *parent)
25 27 :QObject((QObject*)parent)
@@ -54,3 +56,124 bool abstractSpwBridge::disconnectBridge
54 56
55 57
56 58
59
60
61
62 abstractSpwManager::abstractSpwManager(socexplorerplugin *plugin, QObject *parent)
63 :QThread((QObject*)parent)
64 {
65 this->RMAPtimeout = 2000;
66 this->handleMutex = new QMutex(QMutex::NonRecursive);
67 this->RMAP_AnswersSem = new QSemaphore(0);
68 this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
69 this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
70 this->plugin = plugin;
71 connected = false;
72 }
73
74 abstractSpwManager::~abstractSpwManager()
75 {
76 this->terminate();
77 while (!this->isFinished())
78 {
79 this->usleep(1000);
80 }
81 }
82
83 int abstractSpwManager::getRMAPtransactionID()
84 {
85 this->RMAP_pending_transaction_IDsMtx->lock();
86 int ID=0;
87 bool found=true;
88 while(ID<511)
89 {
90 for(int i=0;i<RMAP_pending_transaction_IDs.count();i++)
91 {
92 if(RMAP_pending_transaction_IDs[i]==ID)found=false;
93 }
94 if(found==true)break;
95 ID++;
96 found = true;
97 }
98 if(found)
99 {
100 RMAP_pending_transaction_IDs.append(ID);
101 }
102 this->RMAP_pending_transaction_IDsMtx->unlock();
103 return ID;
104 }
105
106 int abstractSpwManager::getRMAPanswer(int transactionID, char **buffer)
107 {
108
109 QTime timeout;
110 *buffer=NULL;
111 int count=0;
112 SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2);
113 qApp->processEvents();
114 timeout.start();
115 while (*buffer==NULL)
116 {
117 this->RMAP_AnswersMtx->lock();
118 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2);
119 SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2);
120 for(int i=0;i<RMAP_Answers.count();i++)
121 {
122 SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2);
123 if(RMAP_Answers[i]->transactionID==transactionID)
124 {
125 this->RMAP_pending_transaction_IDsMtx->lock();
126 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2);
127 for(int j=0;j<RMAP_pending_transaction_IDs.count();j++)
128 {
129 if(RMAP_pending_transaction_IDs[j]==transactionID)
130 {
131 RMAP_pending_transaction_IDs.removeAt(j);
132 }
133 }
134 this->RMAP_pending_transaction_IDsMtx->unlock();
135 *buffer = RMAP_Answers[i]->data;
136 count = RMAP_Answers[i]->len;
137 RMAP_Answer* tmp=RMAP_Answers[i];
138 RMAP_Answers.removeAt(i);
139 delete tmp;
140 }
141 }
142 this->RMAP_AnswersMtx->unlock();
143 //if no answer found in the stack wait until a new packet is pushed
144 SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2);
145 if(*buffer==NULL)
146 {
147 while (0==this->RMAP_AnswersSem->available())
148 {
149 SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2);
150 if(timeout.elapsed()>=RMAPtimeout)
151 {
152 SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2);
153 return -1;
154 }
155 usleep(1000);
156 qApp->processEvents();
157 }
158 this->RMAP_AnswersSem->acquire();
159 }
160 }
161 return count;
162 }
163
164 int abstractSpwManager::getLinkNumber()
165 {
166 return this->linkNumber;
167 }
168
169 void abstractSpwManager::pushRmapPacket(char *packet, int len)
170 {
171 char* packetbuffer = (char*)malloc(len);
172 memcpy(packetbuffer,packet,len);
173 RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len);
174 RMAP_AnswersMtx->lock();
175 RMAP_Answers.append(RMPAPpacket);
176 RMAP_AnswersMtx->unlock();
177 }
178
179
@@ -23,6 +23,9
23 23 #define ABSTRACTSPWBRIDGE_H
24 24
25 25 #include <QObject>
26 #include <QThread>
27 #include <QMutex>
28 #include <QSemaphore>
26 29 #include <socexplorerplugin.h>
27 30 #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes
28 31 #include <spw.h>
@@ -65,4 +68,43 private:
65 68
66 69 };
67 70
71 class abstractSpwManager: public QThread
72 {
73 Q_OBJECT
74 public:
75 explicit abstractSpwManager(socexplorerplugin *plugin = 0,QObject* parent=0);
76 ~abstractSpwManager();
77 virtual void run(){}
78 virtual bool connectBridge()=0;
79 virtual bool disconnectBridge()=0;
80 int getRMAPtransactionID();
81 int getRMAPanswer(int transactionID,char** buffer);
82 virtual bool sendPacket(char* packet,int size)=0;
83 int RMAPtimeout;
84 int linkNumber;
85 int sourceLogicalAddress;
86 int destinationLogicalAddress;
87 int destinationKey;
88 signals:
89 void emitPacket(char* packet,int size);
90 void bytesReceivedFromSpw( unsigned int );
91 void bytesTransmittedToSpw( unsigned int);
92 void ccsdsPacketTransmittedToSpw( void );
93
94 public slots:
95 int getLinkNumber();
96
97 protected:
98 QList<RMAP_Answer*> RMAP_Answers;
99 QList<int> RMAP_pending_transaction_IDs;
100 QMutex *handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
101 QSemaphore* RMAP_AnswersSem;
102 socexplorerplugin* plugin;
103 bool connected;
104 void pushRmapPacket(char* packet,int len);
105
106 };
107
108
109
68 110 #endif // ABSTRACTSPWBRIDGE_H
@@ -12,7 +12,7 QMAKE_CFLAGS += -std=c++11
12 12
13 13 win32:CONFIG += dll
14 14 win32:CONFIG -= static
15 VERSION=0.6.1
15 VERSION=0.6.2
16 16 TARGET = spwplugin
17 17 DEFINES += PLUGIN=spwplugin
18 18 DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\"
@@ -24,10 +24,6 DEFINES += driver_can_be_child=0
24 24 DEFINES += driver_VID=0
25 25 DEFINES += driver_PID=0
26 26
27 #STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/
28
29 #LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \
30 # $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so
31 27
32 28 INCLUDEPATH += \
33 29 $${PWD} \
General Comments 0
You need to be logged in to leave comments. Login now