diff --git a/ambaplugin/AHB/ahbpluginui.cpp b/ambaplugin/AHB/ahbpluginui.cpp --- a/ambaplugin/AHB/ahbpluginui.cpp +++ b/ambaplugin/AHB/ahbpluginui.cpp @@ -65,10 +65,10 @@ ahbdeviceInfo* ahbPluginUi::extractInfos void ahbPluginUi::scanAHB() { - unsigned int size = AHB_PLUGNPLAY_SLAVE_STOP- AHB_PLUGNPLAY_MASTER_START; + unsigned int size = (AHB_PLUGNPLAY_SLAVE_STOP - AHB_PLUGNPLAY_MASTER_START)/4; int j=0; unsigned long long i = AHB_PLUGNPLAY_MASTER_START; - int pnpregs[AHB_PLUGNPLAY_SLAVE_STOP- AHB_PLUGNPLAY_MASTER_START]; + int pnpregs[size]; emit this->clearAHBdevicesList(); if( this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)AHB_PLUGNPLAY_MASTER_START)==size) { diff --git a/ambaplugin/AHB/ahbpluginui.h b/ambaplugin/AHB/ahbpluginui.h --- a/ambaplugin/AHB/ahbpluginui.h +++ b/ambaplugin/AHB/ahbpluginui.h @@ -30,7 +30,6 @@ #define AHB_PLUGNPLAY_MASTER_START ((unsigned int)(0xFFFFF000)) #define AHB_PLUGNPLAY_MASTER_STOP ((unsigned int)(0xFFFFF800)) #define AHB_PLUGNPLAY_SLAVE_START ((unsigned int)(0xFFFFF800)) - #define AHB_PLUGNPLAY_SLAVE_STOP ((unsigned int)(0xFFFFFFFC)) diff --git a/ambaplugin/APB/apbpluginui.cpp b/ambaplugin/APB/apbpluginui.cpp --- a/ambaplugin/APB/apbpluginui.cpp +++ b/ambaplugin/APB/apbpluginui.cpp @@ -74,12 +74,12 @@ apbdeviceInfo* apbPluginUi::extractInfos void apbPluginUi::scanAPB() { this->lockScanBp(); - unsigned int size = APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START; + unsigned int size = (APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START)/4; int j=0; unsigned long long i = APB_PLUGNPLAY_START; - int pnpregs[APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START]; + int pnpregs[size]; emit this->clearAPBdevicesList(); - if(this->_plugin->Read((unsigned int*)pnpregs,size/4,(unsigned int)APB_PLUGNPLAY_START)==(size/4)) + if(this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)APB_PLUGNPLAY_START)==size) { while(i Host to SpaceWire packet transmission + if(data[0]==(char)0) // Protocole = 0 => Host to SpaceWire packet transmission { int size = (data[1]*256*256) + (data[2]*256) + data[3]; char* SPWpacket = (char*)malloc(size); @@ -182,7 +182,7 @@ void SpwTcpPacketServer::readReady() { QByteArray data = soc->readAll(); onePacketReceived(); - if(data[0]==0) // Protocole = 0 => Host to SpaceWire packet transmission + if(data[0]==(char)0) // Protocole = 0 => Host to SpaceWire packet transmission { int size = (data[1]*256*256) + (data[2]*256) + data[3]; char* SPWpacket = (char*)malloc(size); diff --git a/spwplugin/StarDundee/stardundeespw_usb.cpp b/spwplugin/StarDundee/stardundeespw_usb.cpp --- a/spwplugin/StarDundee/stardundeespw_usb.cpp +++ b/spwplugin/StarDundee/stardundeespw_usb.cpp @@ -326,6 +326,7 @@ void stardundeeSPW_USB::rmapTimeoutChang void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) { + Q_UNUSED(parent) this->p_GUI = new StarDundeeGUI(); // this->mainLayout = new QGridLayout(this->p_GUI); connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); @@ -402,12 +403,15 @@ stardundeeSPW_USB_Manager::stardundeeSPW { this->RMAPtimeout = 2000; this->handleMutex = new QMutex(QMutex::NonRecursive); +// this->handleMutex = new QMutex(QMutex::Recursive); this->RMAP_AnswersSem = new QSemaphore(0); this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); this->plugin = plugin; connected = false; - this->moveToThread(this); + // TODO remove this crap! + this->initDialog(); +// this->moveToThread(this); } stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() @@ -429,7 +433,7 @@ void stardundeeSPW_USB_Manager::run() { if(this->connected) { - handleMutex->lock(); + this->handleMutex->lock(); SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) { @@ -453,7 +457,7 @@ void stardundeeSPW_USB_Manager::run() memcpy(packetbuffer,buffer,properties.len); USBSpaceWire_FreeRead(hDevice, pIdentifier); pIdentifier = NULL; - handleMutex->unlock(); + this->handleMutex->unlock(); if(properties.len==8) { packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); @@ -473,13 +477,14 @@ void stardundeeSPW_USB_Manager::run() memcpy(packetbuffer,buffer,properties.len); emit emitPacket(packetbuffer,properties.len); USBSpaceWire_FreeRead(hDevice, pIdentifier); - handleMutex->unlock(); + this->handleMutex->unlock(); SocExplorerEngine::message(this->plugin,"Got SPW packet",2); } } else { SocExplorerEngine::message(this->plugin,"No EOP received",2); + this->handleMutex->unlock(); } } @@ -487,13 +492,13 @@ void stardundeeSPW_USB_Manager::run() else { USBSpaceWire_FreeRead(hDevice, pIdentifier); - handleMutex->unlock(); + this->handleMutex->unlock(); } } else { USBSpaceWire_FreeRead(hDevice, pIdentifier); - handleMutex->unlock(); + this->handleMutex->unlock(); } } else @@ -534,13 +539,15 @@ bool stardundeeSPW_USB_Manager::connectB bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() { - QMutexLocker mlock(this->handleMutex); +// QMutexLocker mlock(&this->handleMutex); + this->handleMutex->lock(); int status; U32 statusControl; this->connected = false; if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device { SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); + this->handleMutex->unlock(); return false; } SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); @@ -559,6 +566,7 @@ bool stardundeeSPW_USB_Manager::connectB if (status != CFG_TRANSFER_SUCCESS) { SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); + this->handleMutex->unlock(); return false; } else @@ -570,6 +578,7 @@ bool stardundeeSPW_USB_Manager::connectB if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) { SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); + this->handleMutex->unlock(); return false; } else @@ -587,6 +596,7 @@ bool stardundeeSPW_USB_Manager::connectB if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) { SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); + this->handleMutex->unlock(); return false; } else @@ -598,6 +608,7 @@ bool stardundeeSPW_USB_Manager::connectB if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) { SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); + this->handleMutex->unlock(); return false; } else @@ -608,6 +619,7 @@ bool stardundeeSPW_USB_Manager::connectB USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints USBSpaceWire_SetTimeout(hDevice,1.0); + this->handleMutex->unlock(); SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); @@ -617,7 +629,8 @@ bool stardundeeSPW_USB_Manager::connectB bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() { - QMutexLocker mlock(this->handleMutex); +// QMutexLocker mlock(&this->handleMutex); + this->handleMutex->lock(); int status; U32 statusControl; unsigned int linkStatus1; @@ -628,6 +641,7 @@ bool stardundeeSPW_USB_Manager::connectB if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device { SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); + this->handleMutex->unlock(); return false; } SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " @@ -721,6 +735,7 @@ bool stardundeeSPW_USB_Manager::connectB // test Link 1 and Link 2 linkStatus1 = getLinkStatus(0x01); linkStatus2 = getLinkStatus(0x02); + this->handleMutex->unlock(); if ((linkStatus1==1) || (linkStatus2==1)) { @@ -992,30 +1007,29 @@ int stardundeeSPW_USB_Manager::getRMAPan bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) { char protocoleIdentifier; - USB_SPACEWIRE_STATUS result; + USB_SPACEWIRE_STATUS result=TRANSFER_ERROR_NOT_FOUND; USB_SPACEWIRE_ID pIdentifier; SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); this->handleMutex->lock(); result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); + USBSpaceWire_FreeSend(hDevice, pIdentifier); + this->handleMutex->unlock(); if (result != TRANSFER_SUCCESS) { SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); - this->handleMutex->unlock(); return false; } else { emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link - // read the protocole identifier protocoleIdentifier = packet[2]; if (protocoleIdentifier == SPW_PROTO_ID_CCSDS) emit ccsdsPacketTransmittedToSpw(); SocExplorerEngine::message(this->plugin,"Packet sent",2); - USBSpaceWire_FreeSend(hDevice, pIdentifier); } - this->handleMutex->unlock(); +// this->handleMutex->unlock(); return true; } @@ -1050,10 +1064,10 @@ int stardundeeSPW_USB_Manager::getLinkNu void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency) { - U32 rtr_clk_freq; - U32 freqCount; - double freqCountInDouble; - double currentFrequency; + U32 rtr_clk_freq=0; + U32 freqCount=0; + double freqCountInDouble=0.0; + double currentFrequency=0.0; rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency; diff --git a/spwplugin/StarDundee/stardundeespw_usb.h b/spwplugin/StarDundee/stardundeespw_usb.h --- a/spwplugin/StarDundee/stardundeespw_usb.h +++ b/spwplugin/StarDundee/stardundeespw_usb.h @@ -73,7 +73,7 @@ public slots: int getLinkNumber( void ); private: - QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; + QMutex *handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; QSemaphore* RMAP_AnswersSem; void pushRmapPacket(char* packet,int len); star_device_handle hDevice; diff --git a/spwplugin/abstractspwbridge.cpp b/spwplugin/abstractspwbridge.cpp --- a/spwplugin/abstractspwbridge.cpp +++ b/spwplugin/abstractspwbridge.cpp @@ -30,7 +30,7 @@ abstractSpwBridge::abstractSpwBridge(soc abstractSpwBridge::~abstractSpwBridge() { - delete this->p_GUI; +// delete this->p_GUI; } QWidget *abstractSpwBridge::getGUI() diff --git a/spwplugin/spwplugin.pro b/spwplugin/spwplugin.pro --- a/spwplugin/spwplugin.pro +++ b/spwplugin/spwplugin.pro @@ -9,12 +9,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += win32:CONFIG += dll win32:CONFIG -= static -CONFIG(debug, debug|release) { - DEBUG_EXT = _d -} else { - DEBUG_EXT = -} -TARGET = spwplugin$${DEBUG_EXT} +TARGET = spwplugin DEFINES += PLUGIN=spwplugin DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\"