# HG changeset patch # User Jeandet Alexis # Date 2014-03-06 15:45:20 # Node ID 66782ba1cf13020fa3f8d0ddd0617e805f646646 # Parent b813b27420b449706b8882b41a619b29cc57463d Now RMAP write uses Transaction ID and waits for ack. diff --git a/spwplugin/spwplugin.cpp b/spwplugin/spwplugin.cpp --- a/spwplugin/spwplugin.cpp +++ b/spwplugin/spwplugin.cpp @@ -32,7 +32,7 @@ spwplugin::spwplugin(QWidget *parent):so this->pyObject = new spwPyWrapper(this); this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); this->bridgeSelector = new QComboBox(this); - this->mainLayout = new QGridLayout(this); + this->mainLayout = new QGridLayout(this->mainGroupBox); this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); this->mainGroupBox->setLayout(this->mainLayout); diff --git a/spwplugin/stardundeespw_usb.cpp b/spwplugin/stardundeespw_usb.cpp --- a/spwplugin/stardundeespw_usb.cpp +++ b/spwplugin/stardundeespw_usb.cpp @@ -82,6 +82,7 @@ int stardundeeSPW_USB::pushRMAPPacket(ch unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) { char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; + char *RMAPAckBuff; writeBuffer[0]=this->manager->linkNumber;//Link number int transactionID = 0; int written=0; @@ -103,8 +104,12 @@ unsigned int stardundeeSPW_USB::Write(un writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); } + transactionID=manager->getRMAPtransactionID(); + SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1); manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); + manager->getRMAPanswer(transactionID,&RMAPAckBuff); + free(RMAPAckBuff); written+=RMAP_MAX_XFER_SIZE; count-=RMAP_MAX_XFER_SIZE; progress->setValue(written); @@ -119,8 +124,12 @@ unsigned int stardundeeSPW_USB::Write(un writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); } + transactionID=manager->getRMAPtransactionID(); + SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1); manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); + manager->getRMAPanswer(transactionID,&RMAPAckBuff); + free(RMAPAckBuff); written+=count; if(progress!=NULL) { @@ -260,7 +269,7 @@ void stardundeeSPW_USB::rmapTimeoutChang void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) { this->p_GUI = new StarDundeeGUI(); -// this->mainLayout = new QGridLayout(this->p_GUI); + // this->mainLayout = new QGridLayout(this->p_GUI); connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); @@ -338,29 +347,26 @@ void stardundeeSPW_USB_Manager::run() SocExplorerEngine::message(this->plugin,"Got end of packet",2); if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet { + RMAP_Answer* packet; SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); - if(properties.len>8) + char* packetbuffer = (char*)malloc(properties.len); + memcpy(packetbuffer,buffer,properties.len); + USBSpaceWire_FreeRead(hDevice, pIdentifier); + pIdentifier = NULL; + handleMutex->unlock(); + if(properties.len==8) { - char* packetbuffer = (char*)malloc(properties.len); - memcpy(packetbuffer,buffer,properties.len); - USBSpaceWire_FreeRead(hDevice, pIdentifier); - pIdentifier = NULL; - handleMutex->unlock(); - RMAP_Answer* packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); - RMAP_AnswersMtx->lock(); - RMAP_Answers.append(packet); - RMAP_AnswersMtx->unlock(); - RMAP_AnswersSem->release(); - + packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); } - else //it's a RMAP write response + else { - USBSpaceWire_FreeRead(hDevice, pIdentifier); - pIdentifier = NULL; - handleMutex->unlock(); + packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); } - + RMAP_AnswersMtx->lock(); + RMAP_Answers.append(packet); + RMAP_AnswersMtx->unlock(); + RMAP_AnswersSem->release(); } else //any non-rmap packet will be pushed to the network { @@ -538,9 +544,10 @@ int stardundeeSPW_USB_Manager::getRMAPan { this->RMAP_AnswersMtx->lock(); SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); - SocExplorerEngine::message(this->plugin,QString("%2 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); + SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); for(int i=0;iplugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); if(RMAP_Answers[i]->transactionID==transactionID) { this->RMAP_pending_transaction_IDsMtx->lock();