##// END OF EJS Templates
SpwPlugin:...
Jeandet Alexis -
r97:c91564a4cc42 default draft
parent child
Show More
@@ -20,6 +20,7
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "memchecker.h"
23 #include <socexplorerengine.h>
23 24
24 25 memchecker::memchecker(socexplorerplugin* plugin)
25 26 {
@@ -83,30 +84,7 unsigned int p_pow2(unsigned int v)
83 84
84 85 unsigned int memchecker::measureMemSize(unsigned int address, unsigned int maxSize)
85 86 {
86 unsigned int curVal=1,testAddress=address;
87 unsigned int size=0;
88 this->plugin->Write(&curVal,1,testAddress);
89 this->plugin->Read(&curVal,1,testAddress);
90 if(curVal!=1)
91 return size;
92 unsigned int max= p_pow2((0xFFFFFFFFFFFFFFFF - address))+1;
93 register unsigned int maxSizeLg=p_pow2(maxSize)-1;
94 if(max>maxSizeLg)
95 max=maxSizeLg;
96 if(max>32)max=32;
97 for(size=2;size<max;size++) //check each address bit
98 {
99 testAddress = (unsigned int)(address+(1<<size));
100 curVal = (unsigned int)(1<<size);
101 this->plugin->Write(&curVal,1,testAddress);
102 this->plugin->Read(&curVal,1,testAddress);
103 if((unsigned int)curVal!=(unsigned int)(1<<size))
104 return (1<<(size));
105 this->plugin->Read(&curVal,1,address);
106 if((curVal==(unsigned int)(1<<size)) && (size!=0))
107 return (1<<(size));
108 }
109 return (1<<(size+1));
87 return SocExplorerEngine::memMeasureSize(this->plugin,address,maxSize);
110 88 }
111 89
112 90
@@ -406,7 +406,7 stardundeeSPW_USB_Manager::stardundeeSPW
406 406 {
407 407 // TODO remove this crap!
408 408 this->initDialog();
409 // this->moveToThread(this);
409 // this->moveToThread(this);
410 410 }
411 411
412 412 stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager()
@@ -533,6 +533,8 bool stardundeeSPW_USB_Manager::connectB
533 533
534 534 bool stardundeeSPW_USB_Manager::connectBridgeAsInterface()
535 535 {
536 if(this->connected)
537 this->disconnectBridge();
536 538 this->handleMutex->lock();
537 539 int status;
538 540 U32 statusControl;
@@ -622,7 +624,8 bool stardundeeSPW_USB_Manager::connectB
622 624
623 625 bool stardundeeSPW_USB_Manager::connectBridgeAsRouter()
624 626 {
625 // QMutexLocker mlock(&this->handleMutex);
627 if(this->connected)
628 this->disconnectBridge();
626 629 this->handleMutex->lock();
627 630 int status;
628 631 U32 statusControl;
@@ -638,7 +641,7 bool stardundeeSPW_USB_Manager::connectB
638 641 return false;
639 642 }
640 643 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: "
641 + QString::number(this->selectedBrick));
644 + QString::number(this->selectedBrick));
642 645
643 646 USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode
644 647 CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration
@@ -904,19 +907,22 unsigned int stardundeeSPW_USB_Manager::
904 907
905 908 bool stardundeeSPW_USB_Manager::disconnectBridge()
906 909 {
907 this->handleMutex->lock();
908 USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports
909 USBSpaceWire_Close(hDevice); // Close the device
910 SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0);
911 this->handleMutex->unlock();
912 this->RMAP_pending_transaction_IDsMtx->lock();
913 this->RMAP_pending_transaction_IDs.clear();
914 this->RMAP_pending_transaction_IDsMtx->unlock();
915 this->RMAP_AnswersMtx->lock();
916 this->RMAP_Answers.clear();
917 this->RMAP_AnswersMtx->unlock();
918 this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available());
919 this->connected=false;
910 if (this->connected==true)
911 {
912 this->handleMutex->lock();
913 USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports
914 USBSpaceWire_Close(hDevice); // Close the device
915 SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0);
916 this->handleMutex->unlock();
917 this->RMAP_pending_transaction_IDsMtx->lock();
918 this->RMAP_pending_transaction_IDs.clear();
919 this->RMAP_pending_transaction_IDsMtx->unlock();
920 this->RMAP_AnswersMtx->lock();
921 this->RMAP_Answers.clear();
922 this->RMAP_AnswersMtx->unlock();
923 this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available());
924 this->connected=false;
925 }
920 926 return true;
921 927 }
922 928
@@ -941,7 +947,7 bool stardundeeSPW_USB_Manager::sendPack
941 947 // read the protocole identifier
942 948 protocoleIdentifier = packet[2];
943 949 if (protocoleIdentifier == SPW_PROTO_ID_CCSDS)
944 emit ccsdsPacketTransmittedToSpw();
950 emit ccsdsPacketTransmittedToSpw();
945 951
946 952 SocExplorerEngine::message(this->plugin,"Packet sent",2);
947 953 }
General Comments 0
You need to be logged in to leave comments. Login now