##// END OF EJS Templates
A lot of cleaning,...
paul -
r50:9c702d65566a default
parent child
Show More
@@ -65,10 +65,10 ahbdeviceInfo* ahbPluginUi::extractInfos
65 65
66 66 void ahbPluginUi::scanAHB()
67 67 {
68 unsigned int size = AHB_PLUGNPLAY_SLAVE_STOP- AHB_PLUGNPLAY_MASTER_START;
68 unsigned int size = (AHB_PLUGNPLAY_SLAVE_STOP - AHB_PLUGNPLAY_MASTER_START)/4;
69 69 int j=0;
70 70 unsigned long long i = AHB_PLUGNPLAY_MASTER_START;
71 int pnpregs[AHB_PLUGNPLAY_SLAVE_STOP- AHB_PLUGNPLAY_MASTER_START];
71 int pnpregs[size];
72 72 emit this->clearAHBdevicesList();
73 73 if( this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)AHB_PLUGNPLAY_MASTER_START)==size)
74 74 {
@@ -30,7 +30,6
30 30 #define AHB_PLUGNPLAY_MASTER_START ((unsigned int)(0xFFFFF000))
31 31 #define AHB_PLUGNPLAY_MASTER_STOP ((unsigned int)(0xFFFFF800))
32 32 #define AHB_PLUGNPLAY_SLAVE_START ((unsigned int)(0xFFFFF800))
33
34 33 #define AHB_PLUGNPLAY_SLAVE_STOP ((unsigned int)(0xFFFFFFFC))
35 34
36 35
@@ -74,12 +74,12 apbdeviceInfo* apbPluginUi::extractInfos
74 74 void apbPluginUi::scanAPB()
75 75 {
76 76 this->lockScanBp();
77 unsigned int size = APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START;
77 unsigned int size = (APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START)/4;
78 78 int j=0;
79 79 unsigned long long i = APB_PLUGNPLAY_START;
80 int pnpregs[APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START];
80 int pnpregs[size];
81 81 emit this->clearAPBdevicesList();
82 if(this->_plugin->Read((unsigned int*)pnpregs,size/4,(unsigned int)APB_PLUGNPLAY_START)==(size/4))
82 if(this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)APB_PLUGNPLAY_START)==size)
83 83 {
84 84 while(i<APB_PLUGNPLAY_STOP)
85 85 {
@@ -30,8 +30,7
30 30
31 31 #define APB_BUS_START ((unsigned int)(0x80000000))
32 32 #define APB_PLUGNPLAY_START ((unsigned int)(0x800FF000))
33
34 #define APB_PLUGNPLAY_STOP ((unsigned int)(0x800FF000+(512*8)))
33 #define APB_PLUGNPLAY_STOP ((unsigned int)(0x800FFFFF))
35 34
36 35
37 36 class apbPluginUi : public QWidget
@@ -105,12 +105,20 void GR_ESB_bridge::setVirtualLink(qint3
105 105
106 106 unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address)
107 107 {
108
108 // TODO write ME!
109 Q_UNUSED(count)
110 Q_UNUSED(Value)
111 Q_UNUSED(address)
112 return 0;
109 113 }
110 114
111 115 unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address)
112 116 {
113
117 // TODO write ME!
118 Q_UNUSED(Value)
119 Q_UNUSED(count)
120 Q_UNUSED(address)
121 return 0;
114 122 }
115 123
116 124 int GR_ESB_bridge::pushRMAPPacket(char *packet, int size)
@@ -206,20 +214,29 bool GR_ESB_Manager::disconnectBridge()
206 214
207 215 int GR_ESB_Manager::getRMAPtransactionID()
208 216 {
209
217 // TODO write ME!
218 return -1;
210 219 }
211 220
212 221 int GR_ESB_Manager::getRMAPanswer(int transactionID, char **buffer)
213 222 {
214
223 // TODO write ME!
224 Q_UNUSED(transactionID)
225 Q_UNUSED(buffer)
226 return -1;
215 227 }
216 228
217 229 bool GR_ESB_Manager::sendPacket(char *packet, int size)
218 230 {
219
231 // TODO write ME!
232 Q_UNUSED(packet)
233 Q_UNUSED(size)
234 return false;
220 235 }
221 236
222 237 void GR_ESB_Manager::pushRmapPacket(char *packet, int len)
223 238 {
224
239 // TODO write ME!
240 Q_UNUSED(packet)
241 Q_UNUSED(len)
225 242 }
@@ -155,7 +155,7 void SpwTcpPacketServer::parseIncomingTC
155 155 void SpwTcpPacketServer::sendTCUsingSpaceWire(QByteArray data)
156 156 {
157 157 onePacketReceived();
158 if(data[0]==0) // Protocole = 0 => Host to SpaceWire packet transmission
158 if(data[0]==(char)0) // Protocole = 0 => Host to SpaceWire packet transmission
159 159 {
160 160 int size = (data[1]*256*256) + (data[2]*256) + data[3];
161 161 char* SPWpacket = (char*)malloc(size);
@@ -182,7 +182,7 void SpwTcpPacketServer::readReady()
182 182 {
183 183 QByteArray data = soc->readAll();
184 184 onePacketReceived();
185 if(data[0]==0) // Protocole = 0 => Host to SpaceWire packet transmission
185 if(data[0]==(char)0) // Protocole = 0 => Host to SpaceWire packet transmission
186 186 {
187 187 int size = (data[1]*256*256) + (data[2]*256) + data[3];
188 188 char* SPWpacket = (char*)malloc(size);
@@ -326,6 +326,7 void stardundeeSPW_USB::rmapTimeoutChang
326 326
327 327 void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent)
328 328 {
329 Q_UNUSED(parent)
329 330 this->p_GUI = new StarDundeeGUI();
330 331 // this->mainLayout = new QGridLayout(this->p_GUI);
331 332 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection()));
@@ -402,12 +403,15 stardundeeSPW_USB_Manager::stardundeeSPW
402 403 {
403 404 this->RMAPtimeout = 2000;
404 405 this->handleMutex = new QMutex(QMutex::NonRecursive);
406 // this->handleMutex = new QMutex(QMutex::Recursive);
405 407 this->RMAP_AnswersSem = new QSemaphore(0);
406 408 this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
407 409 this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
408 410 this->plugin = plugin;
409 411 connected = false;
410 this->moveToThread(this);
412 // TODO remove this crap!
413 this->initDialog();
414 // this->moveToThread(this);
411 415 }
412 416
413 417 stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager()
@@ -429,7 +433,7 void stardundeeSPW_USB_Manager::run()
429 433 {
430 434 if(this->connected)
431 435 {
432 handleMutex->lock();
436 this->handleMutex->lock();
433 437 SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4);
434 438 if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01))
435 439 {
@@ -453,7 +457,7 void stardundeeSPW_USB_Manager::run()
453 457 memcpy(packetbuffer,buffer,properties.len);
454 458 USBSpaceWire_FreeRead(hDevice, pIdentifier);
455 459 pIdentifier = NULL;
456 handleMutex->unlock();
460 this->handleMutex->unlock();
457 461 if(properties.len==8)
458 462 {
459 463 packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len);
@@ -473,13 +477,14 void stardundeeSPW_USB_Manager::run()
473 477 memcpy(packetbuffer,buffer,properties.len);
474 478 emit emitPacket(packetbuffer,properties.len);
475 479 USBSpaceWire_FreeRead(hDevice, pIdentifier);
476 handleMutex->unlock();
480 this->handleMutex->unlock();
477 481 SocExplorerEngine::message(this->plugin,"Got SPW packet",2);
478 482 }
479 483 }
480 484 else
481 485 {
482 486 SocExplorerEngine::message(this->plugin,"No EOP received",2);
487 this->handleMutex->unlock();
483 488 }
484 489 }
485 490
@@ -487,13 +492,13 void stardundeeSPW_USB_Manager::run()
487 492 else
488 493 {
489 494 USBSpaceWire_FreeRead(hDevice, pIdentifier);
490 handleMutex->unlock();
495 this->handleMutex->unlock();
491 496 }
492 497 }
493 498 else
494 499 {
495 500 USBSpaceWire_FreeRead(hDevice, pIdentifier);
496 handleMutex->unlock();
501 this->handleMutex->unlock();
497 502 }
498 503 }
499 504 else
@@ -534,13 +539,15 bool stardundeeSPW_USB_Manager::connectB
534 539
535 540 bool stardundeeSPW_USB_Manager::connectBridgeAsInterface()
536 541 {
537 QMutexLocker mlock(this->handleMutex);
542 // QMutexLocker mlock(&this->handleMutex);
543 this->handleMutex->lock();
538 544 int status;
539 545 U32 statusControl;
540 546 this->connected = false;
541 547 if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device
542 548 {
543 549 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0);
550 this->handleMutex->unlock();
544 551 return false;
545 552 }
546 553 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0);
@@ -559,6 +566,7 bool stardundeeSPW_USB_Manager::connectB
559 566 if (status != CFG_TRANSFER_SUCCESS)
560 567 {
561 568 SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1);
569 this->handleMutex->unlock();
562 570 return false;
563 571 }
564 572 else
@@ -570,6 +578,7 bool stardundeeSPW_USB_Manager::connectB
570 578 if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
571 579 {
572 580 SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1);
581 this->handleMutex->unlock();
573 582 return false;
574 583 }
575 584 else
@@ -587,6 +596,7 bool stardundeeSPW_USB_Manager::connectB
587 596 if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
588 597 {
589 598 SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1);
599 this->handleMutex->unlock();
590 600 return false;
591 601 }
592 602 else
@@ -598,6 +608,7 bool stardundeeSPW_USB_Manager::connectB
598 608 if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS)
599 609 {
600 610 SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1);
611 this->handleMutex->unlock();
601 612 return false;
602 613 }
603 614 else
@@ -608,6 +619,7 bool stardundeeSPW_USB_Manager::connectB
608 619 USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports
609 620 USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints
610 621 USBSpaceWire_SetTimeout(hDevice,1.0);
622 this->handleMutex->unlock();
611 623 SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1);
612 624 SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1);
613 625 SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1);
@@ -617,7 +629,8 bool stardundeeSPW_USB_Manager::connectB
617 629
618 630 bool stardundeeSPW_USB_Manager::connectBridgeAsRouter()
619 631 {
620 QMutexLocker mlock(this->handleMutex);
632 // QMutexLocker mlock(&this->handleMutex);
633 this->handleMutex->lock();
621 634 int status;
622 635 U32 statusControl;
623 636 unsigned int linkStatus1;
@@ -628,6 +641,7 bool stardundeeSPW_USB_Manager::connectB
628 641 if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device
629 642 {
630 643 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))");
644 this->handleMutex->unlock();
631 645 return false;
632 646 }
633 647 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: "
@@ -721,6 +735,7 bool stardundeeSPW_USB_Manager::connectB
721 735 // test Link 1 and Link 2
722 736 linkStatus1 = getLinkStatus(0x01);
723 737 linkStatus2 = getLinkStatus(0x02);
738 this->handleMutex->unlock();
724 739
725 740 if ((linkStatus1==1) || (linkStatus2==1))
726 741 {
@@ -992,30 +1007,29 int stardundeeSPW_USB_Manager::getRMAPan
992 1007 bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size)
993 1008 {
994 1009 char protocoleIdentifier;
995 USB_SPACEWIRE_STATUS result;
1010 USB_SPACEWIRE_STATUS result=TRANSFER_ERROR_NOT_FOUND;
996 1011 USB_SPACEWIRE_ID pIdentifier;
997 1012 SocExplorerEngine::message(this->plugin,"Sending SPW packet",2);
998 1013 this->handleMutex->lock();
999 1014 result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier);
1015 USBSpaceWire_FreeSend(hDevice, pIdentifier);
1016 this->handleMutex->unlock();
1000 1017 if (result != TRANSFER_SUCCESS)
1001 1018 {
1002 1019 SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2);
1003 this->handleMutex->unlock();
1004 1020 return false;
1005 1021 }
1006 1022 else
1007 1023 {
1008 1024 emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link
1009
1010 1025 // read the protocole identifier
1011 1026 protocoleIdentifier = packet[2];
1012 1027 if (protocoleIdentifier == SPW_PROTO_ID_CCSDS)
1013 1028 emit ccsdsPacketTransmittedToSpw();
1014 1029
1015 1030 SocExplorerEngine::message(this->plugin,"Packet sent",2);
1016 USBSpaceWire_FreeSend(hDevice, pIdentifier);
1017 1031 }
1018 this->handleMutex->unlock();
1032 // this->handleMutex->unlock();
1019 1033 return true;
1020 1034 }
1021 1035
@@ -1050,10 +1064,10 int stardundeeSPW_USB_Manager::getLinkNu
1050 1064
1051 1065 void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency)
1052 1066 {
1053 U32 rtr_clk_freq;
1054 U32 freqCount;
1055 double freqCountInDouble;
1056 double currentFrequency;
1067 U32 rtr_clk_freq=0;
1068 U32 freqCount=0;
1069 double freqCountInDouble=0.0;
1070 double currentFrequency=0.0;
1057 1071
1058 1072 rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice);
1059 1073 freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency;
@@ -73,7 +73,7 public slots:
73 73 int getLinkNumber( void );
74 74
75 75 private:
76 QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
76 QMutex *handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
77 77 QSemaphore* RMAP_AnswersSem;
78 78 void pushRmapPacket(char* packet,int len);
79 79 star_device_handle hDevice;
@@ -30,7 +30,7 abstractSpwBridge::abstractSpwBridge(soc
30 30
31 31 abstractSpwBridge::~abstractSpwBridge()
32 32 {
33 delete this->p_GUI;
33 // delete this->p_GUI;
34 34 }
35 35
36 36 QWidget *abstractSpwBridge::getGUI()
@@ -9,12 +9,7 greaterThan(QT_MAJOR_VERSION, 4): QT +=
9 9
10 10 win32:CONFIG += dll
11 11 win32:CONFIG -= static
12 CONFIG(debug, debug|release) {
13 DEBUG_EXT = _d
14 } else {
15 DEBUG_EXT =
16 }
17 TARGET = spwplugin$${DEBUG_EXT}
12 TARGET = spwplugin
18 13 DEFINES += PLUGIN=spwplugin
19 14 DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\"
20 15 DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\"
General Comments 0
You need to be logged in to leave comments. Login now