# HG changeset patch # User Jeandet Alexis # Date 2016-12-13 17:34:58 # Node ID c91564a4cc42816b97e1feba3c78486f4b997542 # Parent fed6ea04d37608f0697b4997e2228dc51dd7681f SpwPlugin: checks now if conected before disconnect. Disconnects before connect if alredy connected. Memchecker: Uses SocExplorerEngine implementation of memory size measurement. diff --git a/memcheckplugin/memchecker.cpp b/memcheckplugin/memchecker.cpp --- a/memcheckplugin/memchecker.cpp +++ b/memcheckplugin/memchecker.cpp @@ -20,6 +20,7 @@ -- Mail : alexis.jeandet@lpp.polytechnique.fr ----------------------------------------------------------------------------*/ #include "memchecker.h" +#include memchecker::memchecker(socexplorerplugin* plugin) { @@ -83,30 +84,7 @@ unsigned int p_pow2(unsigned int v) unsigned int memchecker::measureMemSize(unsigned int address, unsigned int maxSize) { - unsigned int curVal=1,testAddress=address; - unsigned int size=0; - this->plugin->Write(&curVal,1,testAddress); - this->plugin->Read(&curVal,1,testAddress); - if(curVal!=1) - return size; - unsigned int max= p_pow2((0xFFFFFFFFFFFFFFFF - address))+1; - register unsigned int maxSizeLg=p_pow2(maxSize)-1; - if(max>maxSizeLg) - max=maxSizeLg; - if(max>32)max=32; - for(size=2;sizeplugin->Write(&curVal,1,testAddress); - this->plugin->Read(&curVal,1,testAddress); - if((unsigned int)curVal!=(unsigned int)(1<plugin->Read(&curVal,1,address); - if((curVal==(unsigned int)(1<plugin,address,maxSize); } 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 @@ -406,7 +406,7 @@ stardundeeSPW_USB_Manager::stardundeeSPW { // TODO remove this crap! this->initDialog(); -// this->moveToThread(this); + // this->moveToThread(this); } stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() @@ -533,6 +533,8 @@ bool stardundeeSPW_USB_Manager::connectB bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() { + if(this->connected) + this->disconnectBridge(); this->handleMutex->lock(); int status; U32 statusControl; @@ -622,7 +624,8 @@ bool stardundeeSPW_USB_Manager::connectB bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() { -// QMutexLocker mlock(&this->handleMutex); + if(this->connected) + this->disconnectBridge(); this->handleMutex->lock(); int status; U32 statusControl; @@ -638,7 +641,7 @@ bool stardundeeSPW_USB_Manager::connectB return false; } SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " - + QString::number(this->selectedBrick)); + + QString::number(this->selectedBrick)); USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration @@ -904,19 +907,22 @@ unsigned int stardundeeSPW_USB_Manager:: bool stardundeeSPW_USB_Manager::disconnectBridge() { - this->handleMutex->lock(); - USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports - USBSpaceWire_Close(hDevice); // Close the device - SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); - this->handleMutex->unlock(); - this->RMAP_pending_transaction_IDsMtx->lock(); - this->RMAP_pending_transaction_IDs.clear(); - this->RMAP_pending_transaction_IDsMtx->unlock(); - this->RMAP_AnswersMtx->lock(); - this->RMAP_Answers.clear(); - this->RMAP_AnswersMtx->unlock(); - this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); - this->connected=false; + if (this->connected==true) + { + this->handleMutex->lock(); + USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports + USBSpaceWire_Close(hDevice); // Close the device + SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); + this->handleMutex->unlock(); + this->RMAP_pending_transaction_IDsMtx->lock(); + this->RMAP_pending_transaction_IDs.clear(); + this->RMAP_pending_transaction_IDsMtx->unlock(); + this->RMAP_AnswersMtx->lock(); + this->RMAP_Answers.clear(); + this->RMAP_AnswersMtx->unlock(); + this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); + this->connected=false; + } return true; } @@ -941,7 +947,7 @@ bool stardundeeSPW_USB_Manager::sendPack // read the protocole identifier protocoleIdentifier = packet[2]; if (protocoleIdentifier == SPW_PROTO_ID_CCSDS) - emit ccsdsPacketTransmittedToSpw(); + emit ccsdsPacketTransmittedToSpw(); SocExplorerEngine::message(this->plugin,"Packet sent",2); }