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