##// END OF EJS Templates
Now RMAP write uses Transaction ID and waits for ack.
Jeandet Alexis -
r16:66782ba1cf13 default
parent child
Show More
@@ -32,7 +32,7 spwplugin::spwplugin(QWidget *parent):so
32 this->pyObject = new spwPyWrapper(this);
32 this->pyObject = new spwPyWrapper(this);
33 this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this);
33 this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this);
34 this->bridgeSelector = new QComboBox(this);
34 this->bridgeSelector = new QComboBox(this);
35 this->mainLayout = new QGridLayout(this);
35 this->mainLayout = new QGridLayout(this->mainGroupBox);
36 this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter);
36 this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter);
37 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
37 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
38 this->mainGroupBox->setLayout(this->mainLayout);
38 this->mainGroupBox->setLayout(this->mainLayout);
@@ -82,6 +82,7 int stardundeeSPW_USB::pushRMAPPacket(ch
82 unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address)
82 unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address)
83 {
83 {
84 char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1];
84 char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1];
85 char *RMAPAckBuff;
85 writeBuffer[0]=this->manager->linkNumber;//Link number
86 writeBuffer[0]=this->manager->linkNumber;//Link number
86 int transactionID = 0;
87 int transactionID = 0;
87 int written=0;
88 int written=0;
@@ -103,8 +104,12 unsigned int stardundeeSPW_USB::Write(un
103 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
104 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
104 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
105 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
105 }
106 }
107 transactionID=manager->getRMAPtransactionID();
108 SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2);
106 RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1);
109 RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1);
107 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1);
110 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1);
111 manager->getRMAPanswer(transactionID,&RMAPAckBuff);
112 free(RMAPAckBuff);
108 written+=RMAP_MAX_XFER_SIZE;
113 written+=RMAP_MAX_XFER_SIZE;
109 count-=RMAP_MAX_XFER_SIZE;
114 count-=RMAP_MAX_XFER_SIZE;
110 progress->setValue(written);
115 progress->setValue(written);
@@ -119,8 +124,12 unsigned int stardundeeSPW_USB::Write(un
119 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
124 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
120 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
125 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
121 }
126 }
127 transactionID=manager->getRMAPtransactionID();
128 SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2);
122 RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1);
129 RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1);
123 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1);
130 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1);
131 manager->getRMAPanswer(transactionID,&RMAPAckBuff);
132 free(RMAPAckBuff);
124 written+=count;
133 written+=count;
125 if(progress!=NULL)
134 if(progress!=NULL)
126 {
135 {
@@ -338,29 +347,26 void stardundeeSPW_USB_Manager::run()
338 SocExplorerEngine::message(this->plugin,"Got end of packet",2);
347 SocExplorerEngine::message(this->plugin,"Got end of packet",2);
339 if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet
348 if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet
340 {
349 {
350 RMAP_Answer* packet;
341 SocExplorerEngine::message(this->plugin,"Got RMAP packet",2);
351 SocExplorerEngine::message(this->plugin,"Got RMAP packet",2);
342 SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2);
352 SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2);
343 if(properties.len>8)
344 {
345 char* packetbuffer = (char*)malloc(properties.len);
353 char* packetbuffer = (char*)malloc(properties.len);
346 memcpy(packetbuffer,buffer,properties.len);
354 memcpy(packetbuffer,buffer,properties.len);
347 USBSpaceWire_FreeRead(hDevice, pIdentifier);
355 USBSpaceWire_FreeRead(hDevice, pIdentifier);
348 pIdentifier = NULL;
356 pIdentifier = NULL;
349 handleMutex->unlock();
357 handleMutex->unlock();
350 RMAP_Answer* packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len);
358 if(properties.len==8)
359 {
360 packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len);
361 }
362 else
363 {
364 packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len);
365 }
351 RMAP_AnswersMtx->lock();
366 RMAP_AnswersMtx->lock();
352 RMAP_Answers.append(packet);
367 RMAP_Answers.append(packet);
353 RMAP_AnswersMtx->unlock();
368 RMAP_AnswersMtx->unlock();
354 RMAP_AnswersSem->release();
369 RMAP_AnswersSem->release();
355
356 }
357 else //it's a RMAP write response
358 {
359 USBSpaceWire_FreeRead(hDevice, pIdentifier);
360 pIdentifier = NULL;
361 handleMutex->unlock();
362 }
363
364 }
370 }
365 else //any non-rmap packet will be pushed to the network
371 else //any non-rmap packet will be pushed to the network
366 {
372 {
@@ -538,9 +544,10 int stardundeeSPW_USB_Manager::getRMAPan
538 {
544 {
539 this->RMAP_AnswersMtx->lock();
545 this->RMAP_AnswersMtx->lock();
540 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2);
546 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2);
541 SocExplorerEngine::message(this->plugin,QString("%2 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2);
547 SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2);
542 for(int i=0;i<RMAP_Answers.count();i++)
548 for(int i=0;i<RMAP_Answers.count();i++)
543 {
549 {
550 SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2);
544 if(RMAP_Answers[i]->transactionID==transactionID)
551 if(RMAP_Answers[i]->transactionID==transactionID)
545 {
552 {
546 this->RMAP_pending_transaction_IDsMtx->lock();
553 this->RMAP_pending_transaction_IDsMtx->lock();
General Comments 0
You need to be logged in to leave comments. Login now