From f16db2e6ca6ee7e2ba448b67ab255edb7fec939e Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Wed, 2 Dec 2015 09:39:16 +0100 Subject: [PATCH 01/10] 10giga offset corrected --- slsReceiverSoftware/src/UDPStandardImplementation.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index ec0f964cb..d7e6989a3 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -568,7 +568,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){ frameSize = onePacketSize * packetsPerFrame; bufferSize = onePacketSize; maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame; - + footerOffset = EIGER_PACKET_HEADER_SIZE + oneDataSize; FILE_LOG(logDEBUG) << dec << "packetsPerFrame:" << packetsPerFrame << "\nonePacketSize:" << onePacketSize << @@ -1586,11 +1586,12 @@ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, in #ifdef MANUALDEBUG eiger_packet_header_t* header = (eiger_packet_header_t*) (buffer[ithread]+HEADER_SIZE_NUM_TOT_PACKETS); eiger_packet_footer_t* footer = (eiger_packet_footer_t*)(buffer[ithread] + footerOffset + HEADER_SIZE_NUM_TOT_PACKETS); - cprintf(GREEN,"thread:%d subframenum:%d oldpacketnum:%d new pnum:%d\n", - ithread, + cprintf(GREEN,"thread:%d footeroffset:%dsubframenum:%d oldpacketnum:%d new pnum:%d new fnum:%d\n", + ithread,footerOffset, (*( (unsigned int*) header->subFameNumber)), (*( (uint8_t*) header->dynamicRange)), - (*( (uint16_t*) footer->packetNumber))); + (*( (uint16_t*) footer->packetNumber)), + (uint32_t)(*( (uint64_t*) footer))); #endif From 18eb1274c5a7151abfa77332616b2451902776ce Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 15 Dec 2015 11:04:49 +0100 Subject: [PATCH 02/10] fixed fifodepth to return defualt size, also moved destroying and creating threads to fifostructure, had forgotten to override setnumberofframes calling fifostructure which is important for gotthard --- .../include/UDPBaseImplementation.h | 5 +- slsReceiverSoftware/include/UDPInterface.h | 3 +- .../include/UDPStandardImplementation.h | 11 ++ .../src/UDPBaseImplementation.cpp | 5 +- .../src/UDPStandardImplementation.cpp | 104 ++++++++---------- 5 files changed, 63 insertions(+), 65 deletions(-) diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h index 2c544759b..568183e42 100644 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ b/slsReceiverSoftware/include/UDPBaseImplementation.h @@ -312,10 +312,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter /** * Set Number of Frames expected by receiver from detector - * The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented) + * The data receiver status will change from running to idle when it gets this number of frames * @param i number of frames expected + * @return OK or FAIL */ - void setNumberOfFrames(const uint64_t i); + int setNumberOfFrames(const uint64_t i); /** * Set Dynamic Range or Number of Bits Per Pixel diff --git a/slsReceiverSoftware/include/UDPInterface.h b/slsReceiverSoftware/include/UDPInterface.h index b00f038cb..9ad5a7e6a 100644 --- a/slsReceiverSoftware/include/UDPInterface.h +++ b/slsReceiverSoftware/include/UDPInterface.h @@ -371,8 +371,9 @@ class UDPInterface { * Set Number of Frames expected by receiver from detector * The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented) * @param i number of frames expected + * @return OK or FAIL */ - virtual void setNumberOfFrames(const uint64_t i) = 0; + virtual int setNumberOfFrames(const uint64_t i) = 0; /** * Set Dynamic Range or Number of Bits Per Pixel diff --git a/slsReceiverSoftware/include/UDPStandardImplementation.h b/slsReceiverSoftware/include/UDPStandardImplementation.h index 7ec6672aa..9a34f25d3 100644 --- a/slsReceiverSoftware/include/UDPStandardImplementation.h +++ b/slsReceiverSoftware/include/UDPStandardImplementation.h @@ -102,6 +102,15 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase */ int setAcquisitionPeriod(const uint64_t i); + /** + * Overridden method + * Set Number of Frames expected by receiver from detector + * The data receiver status will change from running to idle when it gets this number of frames + * @param i number of frames expected + * @return OK or FAIL + */ + int setNumberOfFrames(const uint64_t i); + /** * Overridden method * Set Dynamic Range or Number of Bits Per Pixel @@ -253,6 +262,8 @@ private: /** * Set up the Fifo Structure for processing buffers * between listening and writer threads + * When the parameters ahve been determined and if fifostructure needs to be changes, + * the listerning and writing threads are also destroyed together with this * @return OK or FAIL */ int setupFifoStructure(); diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index 9a9b1723a..a76cf0e9f 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -334,11 +334,14 @@ int UDPBaseImplementation::setAcquisitionPeriod(const uint64_t i){ return OK; } -void UDPBaseImplementation::setNumberOfFrames(const uint64_t i){ +int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){ FILE_LOG(logDEBUG) << __AT__ << " starting"; numberOfFrames = i; FILE_LOG(logINFO) << "Number of Frames:" << numberOfFrames; + + //overrridden child classes might return FAIL + return OK; } int UDPBaseImplementation::setDynamicRange(const uint32_t i){ diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index d7e6989a3..36f8aa436 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -282,23 +282,11 @@ int UDPStandardImplementation::setupFifoStructure(){ // fifo depth uint32_t oldFifoSize = fifoSize; - //default - if(!fifoDepth){ - switch(myDetectorType){ - case GOTTHARD: fifoSize = GOTTHARD_FIFO_SIZE; break; - case MOENCH: fifoSize = MOENCH_FIFO_SIZE; break; - case PROPIX: fifoSize = PROPIX_FIFO_SIZE; break; - case EIGER: fifoSize = EIGER_FIFO_SIZE * packetsPerFrame; break;//listens to 1 packet at a time and size depends on packetsperframe - default: break; - } - } - //change by user - else{ - if(myDetectorType == EIGER) - fifoSize = fifoDepth * packetsPerFrame; - else fifoSize = fifoDepth; - } + if(myDetectorType == EIGER) + fifoSize = fifoDepth * packetsPerFrame;//listens to 1 packet at a time and size depends on packetsperframe + else + fifoSize = fifoDepth; //reduce fifo depth if > 1 numberofJobsPerBuffer if(fifoSize % numberofJobsPerBuffer) @@ -313,6 +301,11 @@ int UDPStandardImplementation::setupFifoStructure(){ + //delete threads + if(threadStarted){ + createListeningThreads(true); + createWriterThreads(true); + } //set up fifo structure @@ -357,6 +350,18 @@ int UDPStandardImplementation::setupFifoStructure(){ } } cout << "Fifo structure(s) reconstructed" << endl; + + //create threads + if(createListeningThreads() == FAIL){ + FILE_LOG(logERROR) << "Could not create listening thread"; + return FAIL; + } + if(createWriterThreads() == FAIL){ + FILE_LOG(logERROR) << "Could not create writer threads"; + return FAIL; + } + setThreadPriorities(); + return OK; } @@ -483,11 +488,25 @@ int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i){ FILE_LOG(logDEBUG) << __AT__ << " called"; acquisitionPeriod = i; - if(setupFifoStructure() == FAIL) - return FAIL; + if((myDetectorType == GOTTHARD) && (myDetectorType == MOENCH)) + if(setupFifoStructure() == FAIL) + return FAIL; FILE_LOG(logINFO) << "Acquisition Period: " << (double)acquisitionPeriod/(1E9) << "s"; + return OK; +} + + +int UDPStandardImplementation::setNumberOfFrames(const uint64_t i){ + FILE_LOG(logDEBUG) << __AT__ << " called"; + + numberOfFrames = i; + if((myDetectorType == GOTTHARD) && (myDetectorType == MOENCH)) + if(setupFifoStructure() == FAIL) + return FAIL; + + FILE_LOG(logINFO) << "Number of Frames:" << numberOfFrames; return OK; } @@ -511,30 +530,15 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){ //new dynamic range, then restart threads and resetup fifo structure if(oldDynamicRange != dynamicRange){ - //delete threads - if(threadStarted){ - createListeningThreads(true); - createWriterThreads(true); - } - //gui buffer if(latestData){delete[] latestData; latestData = NULL;} latestData = new char[frameSize]; //restructure fifo + numberofJobsPerBuffer = -1; if(setupFifoStructure() == FAIL) return FAIL; - //create threads - if(createListeningThreads() == FAIL){ - FILE_LOG(logERROR) << "Could not create listening thread"; - return FAIL; - } - if(createWriterThreads() == FAIL){ - FILE_LOG(logERROR) << "Could not create writer threads"; - return FAIL; - } - setThreadPriorities(); } } @@ -582,12 +586,6 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){ //new enable, then restart threads and resetup fifo structure if(oldTenGigaEnable != tengigaEnable){ - //delete threads - if(threadStarted){ - createListeningThreads(true); - createWriterThreads(true); - } - //gui buffer if(latestData){delete[] latestData; latestData = NULL;} latestData = new char[frameSize]; @@ -596,16 +594,6 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){ if(setupFifoStructure() == FAIL) return FAIL; - //create threads - if(createListeningThreads() == FAIL){ - FILE_LOG(logERROR) << "Could not create listening thread"; - return FAIL; - } - if(createWriterThreads() == FAIL){ - FILE_LOG(logERROR) << "Could not create writer threads"; - return FAIL; - } - setThreadPriorities(); } } @@ -674,6 +662,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){ packetIndexMask = GOTTHARD_PACKET_INDEX_MASK; maxPacketsPerFile = MAX_FRAMES_PER_FILE * GOTTHARD_PACKETS_PER_FRAME; fifoSize = GOTTHARD_FIFO_SIZE; + fifoDepth = GOTTHARD_FIFO_SIZE; //footerOffset = Not applicable; break; case PROPIX: @@ -687,6 +676,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){ packetIndexMask = PROPIX_PACKET_INDEX_MASK; maxPacketsPerFile = MAX_FRAMES_PER_FILE * PROPIX_PACKETS_PER_FRAME; fifoSize = PROPIX_FIFO_SIZE; + fifoDepth = PROPIX_FIFO_SIZE; //footerOffset = Not applicable; break; case MOENCH: @@ -700,6 +690,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){ packetIndexMask = MOENCH_PACKET_INDEX_MASK; maxPacketsPerFile = MOENCH_MAX_FRAMES_PER_FILE * MOENCH_PACKETS_PER_FRAME; fifoSize = MOENCH_FIFO_SIZE; + fifoDepth = MOENCH_FIFO_SIZE; //footerOffset = Not applicable; break; case EIGER: @@ -714,6 +705,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){ packetIndexMask = EIGER_PACKET_INDEX_MASK; maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame; fifoSize = EIGER_FIFO_SIZE; + fifoDepth = EIGER_FIFO_SIZE; footerOffset = EIGER_PACKET_HEADER_SIZE + oneDataSize; break; case JUNGFRAUCTB: @@ -728,6 +720,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){ packetIndexMask = JCTB_PACKET_INDEX_MASK; maxPacketsPerFile = JFCTB_MAX_FRAMES_PER_FILE * JCTB_PACKETS_PER_FRAME; fifoSize = JCTB_FIFO_SIZE; + fifoDepth = JCTB_FIFO_SIZE; //footerOffset = Not applicable; break; default: @@ -749,17 +742,6 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){ numberofJobsPerBuffer = -1; setupFifoStructure(); - //create threads - if(createListeningThreads() == FAIL){ - FILE_LOG(logERROR) << "Could not create listening thread"; - return FAIL; - } - if(createWriterThreads() == FAIL){ - FILE_LOG(logERROR) << "Could not create writer threads"; - return FAIL; - } - setThreadPriorities(); - //allocate for latest data (frame copy for gui) latestData = new char[frameSize]; From bb78d1af738dc4d9b646f3679397bbf0ed43947a Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 15 Dec 2015 11:59:17 +0100 Subject: [PATCH 03/10] solved recover from root permission error --- slsReceiverSoftware/src/UDPStandardImplementation.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 36f8aa436..39d25e1ef 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -827,7 +827,8 @@ int UDPStandardImplementation::startReceiver(char *c){ //stop udp socket shutDownUDPSockets(); sprintf(c,"Could not create file %s.",completeFileName); - FILE_LOG(logERROR) << c; + //FILE_LOG(logERROR) << c; + for(int i=0; i < numberofWriterThreads; i++) sem_post(&writerSemaphore[i]); return FAIL; } @@ -1308,8 +1309,10 @@ int UDPStandardImplementation::setupWriter(){ #endif } - FILE_LOG(logDEBUG) << "Successfully created file(s)"; - cout << "Writer Ready ..." << endl; + if(fileCreateSuccess == OK){ + FILE_LOG(logDEBUG) << "Successfully created file(s)"; + cout << "Writer Ready ..." << endl; + } return fileCreateSuccess; } From deb72feb912fcc62a49acf719e45e949e0ee499d Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 19 Jan 2016 14:39:58 +0100 Subject: [PATCH 04/10] still not resolved altho some changes --- .../src/UDPStandardImplementation.cpp | 347 ++++++++++++++---- 1 file changed, 285 insertions(+), 62 deletions(-) diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 39d25e1ef..682d82e19 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -1964,7 +1964,10 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ blankframe[i] = new char[onePacketSize]; //set missing packet to 0xff eiger_packet_header_t* blankframe_header = (eiger_packet_header_t*) blankframe[i]; + eiger_packet_footer_t* blankframe_footer = (eiger_packet_footer_t*)(blankframe[i] + footerOffset); *( (uint16_t*) blankframe_header->missingPacket) = missingPacketValue; + *( (uint16_t*) blankframe_footer->packetNumber) = i+1; + //set each value inside blank frame to 0xff for(int j=0;j<(oneDataSize);++j){ unsigned char* blankframe_data = (unsigned char*)blankframe[i] + sizeof(eiger_packet_header_t) + j; @@ -1980,11 +1983,29 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ //until mask unset (udp sockets shut down by client) while((1 << ithread) & writerThreadsMask){ + /* for(int iloop=0;ilooppacketNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber); + cprintf(MAGENTA,"Fifo %d: threadframenumber original-1:%d currentpacketnumber real:%d\n", + i,threadFrameNumber[i],currentPacketNumber[i]); } - + /* for(int iloop=0;ilooppacketNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<missingPacket)!= missingPacketValue){ eiger_packet_header_t* blankframe_header = (eiger_packet_header_t*) blankframe[blankoffset]; - cprintf(BG_RED, "Fifo %d: Missing Packet Error: Adding blank packets mismatch " + cprintf(BG_RED, "Fifo %d: Add Missing Packet Error: " "pnum_offset %d, pnum %d, fnum_thread %d, missingpacket_buffer 0x%x, missingpacket_blank 0x%x\n", i,frameBufferoffset[i],currentPacketNumber[i],threadFrameNumber[i], *( (uint16_t*) frameBuffer_header->missingPacket), *( (uint16_t*) blankframe_header->missingPacket)); exit(-1); }else{ -#ifdef DEBUG4 - cprintf(RED, "Fifo %d: Missing Packet: Adding blank packets success " - "pnum_offset %d, pnum %d, fnum_thread %d, missingpacket_buffer 0x%x\n", +//#ifdef DEBUG4 + cprintf(RED, "Fifo %d: Add Missing Packet success: " + "pnum_offset %d, pnum_got %d, fnum_thread %d, missingpacket_buffer 0x%x\n", i,frameBufferoffset[i],currentPacketNumber[i],threadFrameNumber[i], *( (uint16_t*) frameBuffer_header->missingPacket)); -#endif - frameBufferoffset[i]++; - blankoffset++; +//#endif + frameBufferoffset[i]=frameBufferoffset[i]+1; + //blankoffset++; } } + popReady[i] = false; + if((numPackets[i] == dummyPacketValue) ||(threadFrameNumber[i] != presentFrameNumber)) + fullframe[i] = true; + else + fullframe[i] = false; + if(threadFrameNumber[i] != presentFrameNumber) + threadFrameNumber[i] = presentFrameNumber; + //missed packets/future packet: do not pop over and determine fullframe-------------------- if(numberofMissingPackets[i]){ - popReady[i] = false; - if((numPackets[i] == dummyPacketValue) ||(threadFrameNumber[i] != presentFrameNumber)) - fullframe[i] = true; - else{ - fullframe[i] = false; + //popReady[i] = false; + //if((numPackets[i] == dummyPacketValue) ||(threadFrameNumber[i] != presentFrameNumber)) + // fullframe[i] = true; + //else{ + // fullframe[i] = false; //update last packet - lastPacketNumber[i] = currentPacketNumber[i] - 1; - } - if(threadFrameNumber[i] != presentFrameNumber) - threadFrameNumber[i] = presentFrameNumber; + //lastPacketNumber[i] = currentPacketNumber[i] - 1; + //} + //if(threadFrameNumber[i] != presentFrameNumber) + // threadFrameNumber[i] = presentFrameNumber; numMissingPackets += numberofMissingPackets[i]; } - //no missed packet: add current packet-------------------------------------------------------------- - else{ + /*for(int iloop=0;ilooppacketNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber),threadFrameNumber[i], *( (uint16_t*) frameBuffer_header->missingPacket)); -#endif - frameBufferoffset[i]++; +//#endif + frameBufferoffset[i]=frameBufferoffset[i]+1; //update last packet lastPacketNumber[i] = currentPacketNumber[i]; popReady[i] = true; fullframe[i] = false; if(currentPacketNumber[i] == LAST_PACKET_VALUE){ -#ifdef DEBUG4 +//#ifdef DEBUG4 cprintf(GREEN, "Fifo %d: Got last packet\n",i); -#endif +//#endif popReady[i] = false; fullframe[i] = true; } @@ -2121,15 +2243,31 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ } } + /* for(int iloop=0;ilooppacketNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<isEmpty()){ @@ -2173,24 +2345,57 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ if((numPackets[i] != dummyPacketValue) && (currentPacketNumber[i] == LAST_PACKET_VALUE)) popReady[i] = true; frameBufferoffset[i] = (i*packetsPerFrame/numberofListeningThreads); - blankoffset = 0; + //blankoffset = 0; lastPacketNumber[i] = 0; currentPacketNumber[i] = 0; numberofMissingPackets[i] = 0; } + } + /* for(int iloop=0;ilooppacketNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), (void*)(packetBuffer[i])); + i,popReady[i],(uint32_t)(*( (uint64_t*) wbuf_footer1)), + *( (uint16_t*) wbuf_footer1->packetNumber), (void*)(packetBuffer[i])); } #endif + /*for(int iloop=0;ilooppacketNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + cout<packetNumber)); } -#endif +//#endif if(myDetectorType == EIGER){ while(!fifoTempFree[i]->push(wbuffer[i])); } @@ -2548,14 +2753,21 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ int port = 0, missingPacket; + bool exitVal = 0; + cprintf(GREEN,"packetsperframe:%d\n",packetsPerFrame); for (uint32_t i = 0; i < packetsPerFrame; i++){ eiger_packet_header_t* wbuf_header = (eiger_packet_header_t*) wbuffer[i]; eiger_packet_footer_t* wbuf_footer = (eiger_packet_footer_t*)(wbuffer[i] + footerOffset); #ifdef DEBUG4 - cprintf(GREEN, "Loop index:%d Pnum:%d\n",i,*( (uint16_t*) wbuf_footer->packetNumber)); + cprintf(GREEN, "Loop index:%d Pnum:%d real fnum %d,missingPacket 0x%x\n", + i, + *( (uint16_t*) wbuf_footer->packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket) + ); cout <missingPacket)== missingPacketValue){ #ifdef DEBUG4 - cprintf(GREEN,"Missing packet at %d\n", i+1); + cprintf(RED,"-Missing packet at Loop Index %d\n", i); #endif missingPacket = 1; - //add frame and packet numbers - *( (uint64_t*) wbuf_footer) = (uint64_t)((currentFrameNumber+1)); - *( (uint16_t*) wbuf_footer->packetNumber) = (i+1); + //add frame number + *( (uint64_t*) wbuf_footer) = (currentFrameNumber+1) | (((uint64_t)(*( (uint16_t*) wbuf_footer->packetNumber)))<<0x30); + //*( (uint16_t*) wbuf_footer->packetNumber) = (i+1); +#ifdef DEBUG4 + cprintf(RED, "Missing Packet Loop index:%d fnum:%d Pnum:%d\n",i, + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_footer->packetNumber)); +#endif } //normal packet else{ @@ -2579,14 +2796,20 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ //DEBUGGING if(*( (uint16_t*) wbuf_footer->packetNumber) != (i+1)){ cprintf(BG_RED, "Writing_Thread: Packet Number Mismatch! " - "i %d, pnum %d, fnum %lld, missingPacket 0x%x\n", - i,*( (uint16_t*) wbuf_footer->packetNumber),(long long int)currentFrameNumber,*( (uint16_t*) wbuf_header->missingPacket)); - exit(-1); + "i %d, real pnum %d, real fnum %d, missingPacket 0x%x\n", + i, + *( (uint16_t*) wbuf_footer->packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + exitVal =1; } //overwriting port number and dynamic range *( (uint8_t*) wbuf_header->portIndex) = port; *( (uint8_t*) wbuf_header->dynamicRange) = dynamicRange; } + + if(exitVal){exit(-1);} + } From 39c3a712e1e1750b3e8af7535bbbaecfcd4c16d1 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Mon, 1 Feb 2016 17:57:43 +0100 Subject: [PATCH 05/10] solved a bit, but not the create fiel problem --- .../src/UDPStandardImplementation.cpp | 379 ++++++++++++------ 1 file changed, 262 insertions(+), 117 deletions(-) diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 682d82e19..b814d4c06 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -313,16 +313,20 @@ int UDPStandardImplementation::setupFifoStructure(){ //deleting if(fifoFree[i]){ - while(!fifoFree[i]->isEmpty()) + while(!fifoFree[i]->isEmpty()){ fifoFree[i]->pop(buffer[i]); + //cprintf(BLUE,"FifoFree[%d]: value:%d, pop 0x%x\n",i,fifoFree[i]->getSemValue(),(void*)(buffer[i])); + } #ifdef DEBUG5 cprintf(BLUE,"Info: %d fifostructure popped from fifofree %p\n", i, (void*)(buffer[i])); #endif delete fifoFree[i]; } if(fifo[i]){ - while(!fifo[i]->isEmpty()) + while(!fifo[i]->isEmpty()){ fifo[i]->pop(buffer[i]); + //cprintf(CYAN,"Fifo[%d]: value:%d, pop 0x%x\n",i,fifo[i]->getSemValue(),(void*)(buffer[i])); + } delete fifo[i]; } if(mem0[i]) free(mem0[i]); @@ -341,8 +345,13 @@ int UDPStandardImplementation::setupFifoStructure(){ //push free address into fifoFree buffer[i]=mem0[i]; while (buffer[i] < (mem0[i]+(bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * (fifoSize-1))) { - fifoFree[i]->push(buffer[i]); + //cprintf(BLUE,"fifofree %d: push 0x%p\n",i,(void*)buffer[i]); + /*for(int k=0;kpush(buffer[i])); + //cprintf(GREEN,"Fifofree[%d]: value:%d, push 0x%x\n",i,fifoFree[i]->getSemValue(),(void*)(buffer[i])); #ifdef DEBUG5 cprintf(BLUE,"Info: %d fifostructure free pushed into fifofree %p\n", i, (void*)(buffer[i])); #endif @@ -897,11 +906,12 @@ void UDPStandardImplementation::stopReceiver(){ int UDPStandardImplementation::shutDownUDPSockets(){ FILE_LOG(logDEBUG) << __AT__ << " called"; - FILE_LOG(logDEBUG) << "Info: Shutting down UDP Socket(s)"; + for(int i=0;iShutDownSocket(); + FILE_LOG(logINFO) << "Info: Shut down UDP Socket " << i << endl; delete udpSocket[i]; udpSocket[i] = NULL; } @@ -934,9 +944,9 @@ void UDPStandardImplementation::startReadout(){ prev = -1; //wait as long as there is change from prev totalP while(prev != totalP){ -#ifdef DEBUG5 +//#ifdef DEBUG5 cprintf(MAGENTA,"waiting for all packets totalP:%d\n",totalP); -#endif +//#endif usleep(5000);/* Need to find optimal time (exposure time and acquisition period) **/ prev = totalP; @@ -1476,6 +1486,11 @@ void UDPStandardImplementation::startListening(){ //pop from fifo fifoFree[ithread]->pop(buffer[ithread]); + +#ifdef EVERYFIFODEBUG + if(fifoFree[ithread]->getSemValue()<100) + cprintf(BLUE,"FifoFree[%d]: value:%d, pop 0x%x\n",ithread,fifoFree[ithread]->getSemValue(),(void*)(buffer[ithread])); +#endif #ifdef CFIFODEBUG if(ithread == 0) cprintf(CYAN,"Listening_Thread %d :Listener popped from fifofree %p\n", ithread, (void*)(buffer[ithread])); @@ -1492,7 +1507,6 @@ void UDPStandardImplementation::startListening(){ rc = prepareAndListenBuffer(ithread, listenSize, carryonBufferSize, tempBuffer); - //start indices for each start of scan/acquisition if((!measurementStarted) && (rc > 0)){ pthread_mutex_lock(&progressMutex); @@ -1518,6 +1532,10 @@ void UDPStandardImplementation::startListening(){ //push buffer to FIFO while(!fifo[ithread]->push(buffer[ithread])); +#ifdef EVERYFIFODEBUG + if(fifo[ithread]->getSemValue()>(fifoSize-100)) + cprintf(MAGENTA,"Fifo[%d]: value:%d, push 0x%x\n",ithread,fifo[ithread]->getSemValue(),(void*)(buffer[ithread])); +#endif #ifdef CFIFODEBUG if(ithread == 0) cprintf(CYAN,"Listening_Thread %d: Listener pushed into fifo %p\n",ithread, (void*)(buffer[ithread])); @@ -1549,6 +1567,7 @@ void UDPStandardImplementation::startListening(){ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, int cSize, char* temp){ FILE_LOG(logDEBUG) << __AT__ << " called"; + int testbit = 0; //listen to UDP packets if(cSize) @@ -1558,8 +1577,11 @@ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, in //throw away packets that is not one packet size, need to check status if socket is shut down while(status != TRANSMITTING && myDetectorType == EIGER && receivedSize != onePacketSize) { - if(receivedSize != EIGER_HEADER_LENGTH) + if(receivedSize != EIGER_HEADER_LENGTH){ cprintf(RED,"Listening_Thread %d: Listened to a weird packet size %d\n",ithread, receivedSize); + }/*else{ + testbit = 1; + }*/ #ifdef DEBUG else cprintf(BLUE,"Listening_Thread %d: Listened to a header packet\n",ithread); @@ -1567,6 +1589,11 @@ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, in receivedSize = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS); } totalListeningFrameCount[ithread] += (receivedSize/onePacketSize); + /*if(testbit == 1){ + testbit = 0; + eiger_packet_footer_t* footer = (eiger_packet_footer_t*)(buffer[ithread] + footerOffset + HEADER_SIZE_NUM_TOT_PACKETS); + cprintf(CYAN,"Listening_Thread %d: fnum:%d\n",ithread,(uint32_t)(*( (uint64_t*) footer))); + }*/ #ifdef MANUALDEBUG eiger_packet_header_t* header = (eiger_packet_header_t*) (buffer[ithread]+HEADER_SIZE_NUM_TOT_PACKETS); @@ -1631,9 +1658,9 @@ void UDPStandardImplementation::startFrameIndices(int ithread){ void UDPStandardImplementation::stopListening(int ithread, int numbytes){ FILE_LOG(logDEBUG) << __AT__ << " called"; -#ifdef DEBUG4 - cprintf(BLUE,"Listening_Thread %d: Stop Listening\nStatus: %s\n", ithread, runStatusType(status).c_str()); -#endif +//#ifdef DEBUG4 + cprintf(BG_RED,"Listening_Thread %d: Stop Listening\nStatus: %s numbytes:%d\n", ithread, runStatusType(status).c_str(),numbytes); +//#endif //less than 1 packet size (especially for eiger), ignore the buffer (so that 2 dummy buffers are not sent with pc=0) if(numbytes < onePacketSize) @@ -1644,6 +1671,10 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){ if(numbytes <= 0){ cprintf(BLUE,"Listening_Thread %d :End of Acquisition\n", ithread); while(!fifoFree[ithread]->push(buffer[ithread])); +#ifdef EVERYFIFODEBUG + if(fifoFree[ithread]->getSemValue()<100) + cprintf(GREEN,"Fifofree[%d]: value:%d, push 0x%x\n",ithread,fifoFree[ithread]->getSemValue(),(void*)(buffer[ithread])); +#endif #ifdef CFIFODEBUG if(ithread == 0) cprintf(CYAN,"Listening_Thread %d :Listener push empty buffer into fifofree %p\n", ithread, (void*)(buffer[ithread])); @@ -1657,11 +1688,15 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){ else{ (*((uint32_t*)(buffer[ithread]))) = numbytes/onePacketSize; totalListeningFrameCount[ithread] += (numbytes/onePacketSize); -#ifdef DEBUG +//#ifdef DEBUG cprintf(BLUE,"Listening_Thread %d: Last Buffer numBytes:%d\n",ithread, numbytes); cprintf(BLUE,"Listening_Thread %d: Last Buffer packet count:%d\n",ithread, numbytes/onePacketSize); -#endif +//#endif while(!fifo[ithread]->push(buffer[ithread])); +#ifdef EVERYFIFODEBUG + if(fifo[ithread]->getSemValue()>(fifoSize-100)) + cprintf(MAGENTA,"Fifo[%d]: value:%d, push 0x%x\n",ithread,fifo[ithread]->getSemValue(),(void*)(buffer[ithread])); +#endif #ifdef CFIFODEBUG if(ithread == 0) cprintf(CYAN,"Listening_Thread %d: Listener Last Buffer pushed into fifo %p\n", ithread,(void*)(buffer[ithread])); @@ -1673,6 +1708,10 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){ //push dummy-end buffer into fifo for all writer threads for(int i=0; ipop(buffer[ithread]); +#ifdef EVERYFIFODEBUG + if(fifoFree[ithread]->getSemValue()<100) + cprintf(BLUE,"FifoFree[%d]: value:%d, pop 0x%x\n",ithread,fifoFree[ithread]->getSemValue(),(void*)(buffer[ithread])); +#endif #ifdef CFIFODEBUG if(ithread == 0) cprintf(CYAN,"Listening_Thread %d: Popped Dummy from fifoFree %p\n", ithread,(void*)(buffer[ithread])); @@ -1682,6 +1721,10 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){ //creating dummy-end buffer with pc=0xFFFF (*((uint32_t*)(buffer[ithread]))) = dummyPacketValue; while(!fifo[ithread]->push(buffer[ithread])); +#ifdef EVERYFIFODEBUG + if(fifo[ithread]->getSemValue()>(fifoSize-100)) + cprintf(MAGENTA,"Fifo[%d]: value:%d, push 0x%x\n",ithread,fifo[ithread]->getSemValue(),(void*)(buffer[ithread])); +#endif #ifdef CFIFODEBUG if(ithread == 0) cprintf(CYAN,"Listening_Thread %d: Listener pushed dummy-end buffer into fifo %p\n", ithread,(void*)(buffer[ithread])); @@ -1850,6 +1893,10 @@ void UDPStandardImplementation::processWritingBuffer(int ithread){ while((1 << ithread) & writerThreadsMask){ //pop fifo[0]->pop(wbuf[0]); +#ifdef EVERYFIFODEBUG + if(fifo[0]->getSemValue()>(fifoSize-100)) + cprintf(CYAN,"Fifo[%d]: value:%d, pop 0x%x\n",0,fifo[0]->getSemValue(),(void*)(wbuf[0])); +#endif #ifdef DEBUG5 cprintf(GREEN,"Writing_Thread %d: Popped %p from FIFO %d\n", ithread, (void*)(wbuf[0]),0); #endif @@ -1952,8 +1999,13 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ //circular temp fifo between getting a whole frame and freeing them if(fifoTempFree[i]){ - while(!fifoTempFree[i]->isEmpty()) + while(!fifoTempFree[i]->isEmpty()){ fifoTempFree[i]->pop(temp); +#ifdef EVERYFIFODEBUG + if(fifoTempFree[i]->getSemValue()>((packetsPerFrame/numberofListeningThreads)-3)) + cprintf(RED,"FifoTempFree[%d]: value:%d, pop 0x%x\n",i,fifoTempFree[i]->getSemValue(),(void*)(temp)); +#endif + } delete fifoTempFree[i]; } fifoTempFree[i] = new CircularFifo(MAX_NUM_PACKETS); @@ -1983,29 +2035,34 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ //until mask unset (udp sockets shut down by client) while((1 << ithread) & writerThreadsMask){ - /* for(int iloop=0;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); + *( (uint16_t*) wbuf_header->missingPacket), + (void*)frameBuffer[iloop]); cout<packetNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); + *( (uint16_t*) wbuf_header->missingPacket), + (void*)frameBuffer[iloop]); cout<packetNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); @@ -2023,13 +2084,13 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ } for(int iloop=64;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); cout<packetNumber); - cprintf(MAGENTA,"Fifo %d: threadframenumber original-1:%d currentpacketnumber real:%d\n", +#ifdef DEBUG4 + cprintf(MAGENTA,"Fifo %d: threadframenumber original:%d currentpacketnumber real:%d\n", i,threadFrameNumber[i],currentPacketNumber[i]); +#endif } - /* for(int iloop=0;ilooppacketNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); cout<packetNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); cout<packetNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); cout<packetNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); cout<missingPacket)!= missingPacketValue){ @@ -2156,12 +2206,12 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ *( (uint16_t*) blankframe_header->missingPacket)); exit(-1); }else{ -//#ifdef DEBUG4 +#ifdef DEBUG4 cprintf(RED, "Fifo %d: Add Missing Packet success: " "pnum_offset %d, pnum_got %d, fnum_thread %d, missingpacket_buffer 0x%x\n", i,frameBufferoffset[i],currentPacketNumber[i],threadFrameNumber[i], *( (uint16_t*) frameBuffer_header->missingPacket)); -//#endif +#endif frameBufferoffset[i]=frameBufferoffset[i]+1; //blankoffset++; } @@ -2189,25 +2239,26 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ // threadFrameNumber[i] = presentFrameNumber; numMissingPackets += numberofMissingPackets[i]; } - - /*for(int iloop=0;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); cout<packetNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); cout<push(packetBuffer[i])); +#ifdef EVERYFIFODEBUG + if(fifoTempFree[i]->getSemValue()>((packetsPerFrame/numberofListeningThreads)-3)) + cprintf(YELLOW,"FifoTempfree[%d]: value:%d, push 0x%x\n",i,fifoTempFree[i]->getSemValue(),(void*)(wbuffer[i])); +#endif + + + + //cprintf(RED,"Current Packet frameBufferoffset[i]:%d\n",frameBufferoffset[i]); + frameBuffer[frameBufferoffset[i]] = (packetBuffer[i] + HEADER_SIZE_NUM_TOT_PACKETS); +#ifdef DEBUG4 eiger_packet_header_t* frameBuffer_header = (eiger_packet_header_t*) frameBuffer[frameBufferoffset[i]]; eiger_packet_footer_t* frameBuffer_footer = (eiger_packet_footer_t*) (frameBuffer[frameBufferoffset[i]] + footerOffset); cprintf(GREEN, "Fifo %d: Current Packet added success:" "pnum_offset %d, pnum %d, real pnum %d fnum_thread %d, missingpacket_buffer 0x%x\n", i,frameBufferoffset[i],currentPacketNumber[i],*( (uint16_t*) frameBuffer_footer->packetNumber),threadFrameNumber[i], *( (uint16_t*) frameBuffer_header->missingPacket)); -//#endif +#endif frameBufferoffset[i]=frameBufferoffset[i]+1; //update last packet lastPacketNumber[i] = currentPacketNumber[i]; popReady[i] = true; fullframe[i] = false; if(currentPacketNumber[i] == LAST_PACKET_VALUE){ -//#ifdef DEBUG4 +#ifdef DEBUG4 cprintf(GREEN, "Fifo %d: Got last packet\n",i); -//#endif +#endif popReady[i] = false; fullframe[i] = true; - } - } - } - } + } //end of last packet + }//end of add current packet + }//end of if(!fullframe) + }//end of for listening threads - /* for(int iloop=0;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); @@ -2253,7 +2314,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ } for(int iloop=64;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); @@ -2265,9 +2326,21 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ currentFrameNumber = presentFrameNumber; numTotMissingPacketsInFile += numMissingPackets; numTotMissingPackets += numMissingPackets; -//#ifdef FNUM_DEBUG + + + cprintf(GREEN,"**framenum:%lld\n ",(long long int)currentFrameNumber); + for(int i=0;ipacketNumber), (void*)(packetBuffer[i])); + } +#ifdef DEBUG4 + cprintf(BLUE," nummissingpackets:%d\n",numMissingPackets); +#endif +#ifdef FNUM_DEBUG cprintf(GREEN,"**fnum:%lld**\n",(long long int)currentFrameNumber); -//#endif +#endif #ifdef MISSINGP_DEBUG if(numMissingPackets){ cprintf(RED, "Total missing packets %d for fnum %d\n",numMissingPackets,currentFrameNumber); @@ -2280,7 +2353,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ #endif /* for(int iloop=0;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); @@ -2288,19 +2361,20 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ } for(int iloop=64;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); cout<packetNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); @@ -2308,7 +2382,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ } for(int iloop=64;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); @@ -2320,7 +2394,15 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ for(int i=0; iisEmpty()){ fifoTempFree[i]->pop(temp); - fifoFree[i]->push(temp); +#ifdef EVERYFIFODEBUG + if(fifoTempFree[i]->getSemValue()>((packetsPerFrame/numberofListeningThreads)-3)) + cprintf(GRAY,"FifoTempFree[%d]: value:%d, pop 0x%x\n",i,fifoTempFree[i]->getSemValue(),(void*)(temp)); +#endif + while(!fifoFree[i]->push(temp)); +#ifdef EVERYFIFODEBUG + if(fifoFree[i]->getSemValue()<100) + cprintf(GREEN,"FifoFree[%d]: value:%d, push 0x%x\n",i,fifoFree[i]->getSemValue(),(void*)(temp)); +#endif #ifdef CFIFODEBUG if(i==0) cprintf(CYAN,"Fifo %d: Writing_Thread freed: pushed into fifofree %p\n",i, (void*)(temp)); @@ -2341,8 +2423,13 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ presentFrameNumber++; for(int i=0; ipacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); @@ -2365,7 +2452,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ } for(int iloop=64;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); @@ -2382,18 +2469,20 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ #endif /*for(int iloop=0;ilooppacketNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); + *( (uint16_t*) wbuf_header->missingPacket), + (void*)frameBuffer[iloop]); cout<packetNumber), (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); + *( (uint16_t*) wbuf_header->missingPacket), + (void*)frameBuffer[iloop]); cout<isEmpty()){ - cout << ithread << ":emptied buffer in fifo" << endl; + cprintf(RED,"%d:emptied buffer in fifo\n", ithread); fifo[ithread]->pop(temp); +#ifdef EVERYFIFODEBUG + if(fifo[ithread]->getSemValue()>(fifoSize-100)) + cprintf(CYAN,"Fifo[%d]: value:%d, pop 0x%x\n",ithread,fifo[ithread]->getSemValue(),(void*)(temp)); +#endif } //create file @@ -2481,6 +2574,10 @@ bool UDPStandardImplementation::popAndCheckEndofAcquisition(int ithread, char* w //pop if ready if(ready[i]){ fifo[i]->pop(wbuffer[i]); +#ifdef EVERYFIFODEBUG + if(fifo[i]->getSemValue()>(fifoSize-100)) + cprintf(CYAN,"Fifo[%d]: value:%d, pop 0x%x\n",i,fifo[i]->getSemValue(),(void*)(wbuffer[i])); +#endif #ifdef CFIFODEBUG if(i == 0) cprintf(CYAN,"Writing_Thread %d: Popped %p from FIFO %d\n", ithread, (void*)(wbuffer[i]),i); @@ -2494,24 +2591,31 @@ bool UDPStandardImplementation::popAndCheckEndofAcquisition(int ithread, char* w //dummy-end buffer if(nP[i] == dummyPacketValue){ ready[i] = false; -#ifdef DEBUG3 +//#ifdef DEBUG3 cprintf(GREEN,"Writing_Thread %d: Dummy frame popped out of FIFO %d",ithread, i); -#endif +//#endif } //normal buffer popped out else{ endofAcquisition = false; -//#ifdef DEBUG4 +#ifdef DEBUG4 if(myDetectorType == EIGER){ eiger_packet_footer_t* wbuf_footer = (eiger_packet_footer_t*)(wbuffer[i] + footerOffset + HEADER_SIZE_NUM_TOT_PACKETS); //cprintf(BLUE,"footer value:0x%x\n",i,(uint64_t)(*( (uint64_t*) wbuf_footer))); + //if(*( (uint16_t*) wbuf_footer->packetNumber) == 1){ cprintf(BLUE,"Fnum[%d]:%d\n",i,(uint32_t)(*( (uint64_t*) wbuf_footer))); cprintf(BLUE,"Pnum[%d]:%d\n",i,*( (uint16_t*) wbuf_footer->packetNumber)); + //} } -//#endif - if(myDetectorType == EIGER){ +#endif + /*moved to current packet addition + * if(myDetectorType == EIGER){ while(!fifoTempFree[i]->push(wbuffer[i])); - } +#ifdef EVERYFIFODEBUG + if(fifoTempFree[i]->getSemValue()>((packetsPerFrame/numberofListeningThreads)-3)) + cprintf(YELLOW,"FifoTempfree[%d]: value:%d, push 0x%x\n",i,fifoTempFree[i]->getSemValue(),(void*)(wbuffer[i])); +#endif + }*/ } } //when both are not popped but curretn frame number is being processed @@ -2534,6 +2638,10 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){ //free fifo for(int i=0; ipush(wbuffer[i])); +#ifdef EVERYFIFODEBUG + if(fifoFree[i]->getSemValue()<100) + cprintf(GREEN,"FifoFree[%d]: value:%d, push 0x%x\n",i,fifoFree[i]->getSemValue(),(void*)(wbuffer[i])); +#endif #ifdef CFIFODEBUG if(i==0) cprintf(CYAN,"Writing_Thread %d: Freeing dummy-end buffer. Pushed into fifofree %p for listener %d\n", ithread,(void*)(wbuffer[i]),i); @@ -2633,16 +2741,20 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* //copy frame for gui - if(npackets >= packetsPerFrame) + /*if(npackets >= packetsPerFrame) copyFrameToGui(wbuffer); #ifdef DEBUG4 cprintf(GREEN,"Writing_Thread: Copied frame\n"); -#endif +#endif*/ //free fifo addresses (eiger frees for each packet later) if(myDetectorType != EIGER){ while(!fifoFree[0]->push(wbuffer[0])); +#ifdef EVERYFIFODEBUG + if(fifoFree[0]->getSemValue()<100) + cprintf(GREEN,"FifoFree[%d]: value:%d, push 0x%x\n",0,fifoFree[0]->getSemValue(),(void*)(wbuffer[0])); +#endif #ifdef DEBUG5 cprintf(GREEN,"Writing_Thread %d: Freed buffer, pushed into fifofree %p for listener 0\n",ithread, (void*)(wbuffer[0])); #endif @@ -2723,6 +2835,7 @@ void UDPStandardImplementation::writeFileWithoutCompression(char* wbuffer[],uint #ifdef DEBUG3 cprintf(GREEN,"Writing_Thread: Current Frame Number:%d\n",currentFrameNumber); #endif + cprintf(BG_RED,"CREATE NEW FILE %lld \n",(long long int)currentFrameNumber );exit(-1); createNewFile(); } @@ -2754,13 +2867,14 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ int port = 0, missingPacket; bool exitVal = 0; + eiger_packet_header_t* wbuf_header; + eiger_packet_footer_t* wbuf_footer; - cprintf(GREEN,"packetsperframe:%d\n",packetsPerFrame); for (uint32_t i = 0; i < packetsPerFrame; i++){ - eiger_packet_header_t* wbuf_header = (eiger_packet_header_t*) wbuffer[i]; - eiger_packet_footer_t* wbuf_footer = (eiger_packet_footer_t*)(wbuffer[i] + footerOffset); + wbuf_header = (eiger_packet_header_t*) wbuffer[i]; + wbuf_footer = (eiger_packet_footer_t*)(wbuffer[i] + footerOffset); #ifdef DEBUG4 cprintf(GREEN, "Loop index:%d Pnum:%d real fnum %d,missingPacket 0x%x\n", i, @@ -2778,8 +2892,20 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ cprintf(RED,"-Missing packet at Loop Index %d\n", i); #endif missingPacket = 1; + + //DEBUGGING + if(*( (uint16_t*) wbuf_footer->packetNumber) != (i+1)){ + cprintf(BG_RED, "Writing_Thread: Packet Number Mismatch (missing p)! " + "i %d, real pnum %d, real fnum %d, missingPacket 0x%x\n", + i, + *( (uint16_t*) wbuf_footer->packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + exitVal =1; + } + //add frame number - *( (uint64_t*) wbuf_footer) = (currentFrameNumber+1) | (((uint64_t)(*( (uint16_t*) wbuf_footer->packetNumber)))<<0x30); + /**( (uint64_t*) wbuf_footer) = (currentFrameNumber+1) | (((uint64_t)(*( (uint16_t*) wbuf_footer->packetNumber)))<<0x30);*/ //*( (uint16_t*) wbuf_footer->packetNumber) = (i+1); #ifdef DEBUG4 cprintf(RED, "Missing Packet Loop index:%d fnum:%d Pnum:%d\n",i, @@ -2790,10 +2916,25 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ //normal packet else{ missingPacket = 0; + + //DEBUGGING + if(*( (uint16_t*) wbuf_footer->packetNumber) != ( (i>((packetsPerFrame/2)-1)?(i-(packetsPerFrame/2)+1):i+1) )){ + cprintf(BG_RED, "Writing_Thread: Packet Number Mismatch! " + "i %d, real pnum %d, real fnum %d, missingPacket 0x%x\n", + i, + *( (uint16_t*) wbuf_footer->packetNumber), + (uint32_t)(*( (uint64_t*) wbuf_footer)), + *( (uint16_t*) wbuf_header->missingPacket)); + exitVal =1; + } + + /*uint16_t p = *( (uint16_t*) wbuf_footer->packetNumber); //correct the packet numbers of port2 so that port1 and 2 are not the same - if(port) *( (uint16_t*) wbuf_footer->packetNumber) = (*( (uint16_t*) wbuf_footer->packetNumber))+(packetsPerFrame/2); + if(port) *( (uint16_t*) wbuf_footer->packetNumber) = (p +(packetsPerFrame/2));*/ + } - //DEBUGGING + + /*//DEBUGGING if(*( (uint16_t*) wbuf_footer->packetNumber) != (i+1)){ cprintf(BG_RED, "Writing_Thread: Packet Number Mismatch! " "i %d, real pnum %d, real fnum %d, missingPacket 0x%x\n", @@ -2802,10 +2943,10 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); exitVal =1; - } + }*/ //overwriting port number and dynamic range - *( (uint8_t*) wbuf_header->portIndex) = port; - *( (uint8_t*) wbuf_header->dynamicRange) = dynamicRange; + /**( (uint8_t*) wbuf_header->portIndex) = (uint8_t)port; + *( (uint8_t*) wbuf_header->dynamicRange) = (uint8_t)dynamicRange;*/ } if(exitVal){exit(-1);} @@ -2997,6 +3138,10 @@ void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer while(!fifoFree[0]->push(wbuffer[0])); +#ifdef EVERYFIFODEBUG + if(fifoFree[0]->getSemValue()<100) + cprintf(GREEN,"FifoFree[%d]: value:%d, push 0x%x\n",0,fifoFree[0]->getSemValue(),(void*)(wbuffer[0])); +#endif #ifdef DEBUG5 cprintf(GREEN,"Writing_Thread %d: Compression free pushed into fifofree %p for listerner 0\n", ithread, (void*)(wbuffer[0])); #endif From 3045876a86e4deb7551f3bade9f06a89f8d9efa8 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 2 Feb 2016 17:33:57 +0100 Subject: [PATCH 06/10] solved bug problem --- .../src/UDPStandardImplementation.cpp | 295 +++--------------- 1 file changed, 49 insertions(+), 246 deletions(-) diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index b814d4c06..899e69e25 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -861,8 +861,8 @@ int UDPStandardImplementation::startReceiver(char *c){ for(int i=0;iShutDownSocket(); - FILE_LOG(logINFO) << "Info: Shut down UDP Socket " << i << endl; + FILE_LOG(logINFO) << "Shut down UDP Socket " << i; delete udpSocket[i]; udpSocket[i] = NULL; } @@ -929,7 +929,7 @@ int UDPStandardImplementation::shutDownUDPSockets(){ void UDPStandardImplementation::startReadout(){ FILE_LOG(logDEBUG) << __AT__ << " called"; - FILE_LOG(logDEBUG) << "Info: Transmitting last data"; + FILE_LOG(logDEBUG) << "Transmitting last data"; if(status == RUNNING){ @@ -944,9 +944,9 @@ void UDPStandardImplementation::startReadout(){ prev = -1; //wait as long as there is change from prev totalP while(prev != totalP){ -//#ifdef DEBUG5 +#ifdef DEBUG5 cprintf(MAGENTA,"waiting for all packets totalP:%d\n",totalP); -//#endif +#endif usleep(5000);/* Need to find optimal time (exposure time and acquisition period) **/ prev = totalP; @@ -963,7 +963,8 @@ void UDPStandardImplementation::startReadout(){ pthread_mutex_lock(&statusMutex); status = TRANSMITTING; pthread_mutex_unlock(&statusMutex); - cout << "Status: Transmitting" << endl; + + FILE_LOG(logINFO) << "Status: Transmitting"; } //shut down udp sockets and make listeners push dummy (end) packets for writers @@ -1658,9 +1659,9 @@ void UDPStandardImplementation::startFrameIndices(int ithread){ void UDPStandardImplementation::stopListening(int ithread, int numbytes){ FILE_LOG(logDEBUG) << __AT__ << " called"; -//#ifdef DEBUG4 - cprintf(BG_RED,"Listening_Thread %d: Stop Listening\nStatus: %s numbytes:%d\n", ithread, runStatusType(status).c_str(),numbytes); -//#endif +#ifdef DEBUG4 + cprintf(BLUE,"Listening_Thread %d: Stop Listening\nStatus: %s numbytes:%d\n", ithread, runStatusType(status).c_str(),numbytes); +#endif //less than 1 packet size (especially for eiger), ignore the buffer (so that 2 dummy buffers are not sent with pc=0) if(numbytes < onePacketSize) @@ -1669,7 +1670,7 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){ //free empty buffer if(numbytes <= 0){ - cprintf(BLUE,"Listening_Thread %d :End of Acquisition\n", ithread); + FILE_LOG(logINFO) << "Listening "<< ithread << ": End of Acquisition"; while(!fifoFree[ithread]->push(buffer[ithread])); #ifdef EVERYFIFODEBUG if(fifoFree[ithread]->getSemValue()<100) @@ -1688,10 +1689,10 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){ else{ (*((uint32_t*)(buffer[ithread]))) = numbytes/onePacketSize; totalListeningFrameCount[ithread] += (numbytes/onePacketSize); -//#ifdef DEBUG +#ifdef DEBUG cprintf(BLUE,"Listening_Thread %d: Last Buffer numBytes:%d\n",ithread, numbytes); cprintf(BLUE,"Listening_Thread %d: Last Buffer packet count:%d\n",ithread, numbytes/onePacketSize); -//#endif +#endif while(!fifo[ithread]->push(buffer[ithread])); #ifdef EVERYFIFODEBUG if(fifo[ithread]->getSemValue()>(fifoSize-100)) @@ -2035,27 +2036,6 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ //until mask unset (udp sockets shut down by client) while((1 << ithread) & writerThreadsMask){ - /* - for(int iloop=0;ilooppacketNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket), - (void*)frameBuffer[iloop]); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket), - (void*)frameBuffer[iloop]); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<500){ + cprintf(BG_RED,"too high frame number %lld \n",(long long int)currentFrameNumber ); + exit(-1); + } for(int i=0;ipacketNumber), (void*)(packetBuffer[i])); - } + }*/ #ifdef DEBUG4 cprintf(BLUE," nummissingpackets:%d\n",numMissingPackets); #endif @@ -2351,43 +2245,31 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ } } #endif - /* for(int iloop=0;ilooppacketNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket)); - cout<packetNumber), (void*)(packetBuffer[i])); - } -#endif - /*for(int iloop=0;ilooppacketNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket), - (void*)frameBuffer[iloop]); - cout<packetNumber), - (uint32_t)(*( (uint64_t*) wbuf_footer)), - *( (uint16_t*) wbuf_header->missingPacket), - (void*)frameBuffer[iloop]); - cout<push(wbuffer[i])); -#ifdef EVERYFIFODEBUG - if(fifoTempFree[i]->getSemValue()>((packetsPerFrame/numberofListeningThreads)-3)) - cprintf(YELLOW,"FifoTempfree[%d]: value:%d, push 0x%x\n",i,fifoTempFree[i]->getSemValue(),(void*)(wbuffer[i])); -#endif - }*/ } } //when both are not popped but curretn frame number is being processed @@ -2633,7 +2437,7 @@ bool UDPStandardImplementation::popAndCheckEndofAcquisition(int ithread, char* w void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){ FILE_LOG(logDEBUG) << __AT__ << " called"; - cprintf(GREEN,"Info: Writing_Thread %d: End of Acquisition\n",ithread); + FILE_LOG(logINFO) << "Writing "<< ithread << ": End of Acquisition"; //free fifo for(int i=0; i Date: Tue, 2 Feb 2016 18:52:24 +0100 Subject: [PATCH 07/10] all changes done --- .../src/UDPStandardImplementation.cpp | 54 ++++++------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 899e69e25..3c0252008 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -1568,7 +1568,6 @@ void UDPStandardImplementation::startListening(){ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, int cSize, char* temp){ FILE_LOG(logDEBUG) << __AT__ << " called"; - int testbit = 0; //listen to UDP packets if(cSize) @@ -1580,9 +1579,7 @@ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, in while(status != TRANSMITTING && myDetectorType == EIGER && receivedSize != onePacketSize) { if(receivedSize != EIGER_HEADER_LENGTH){ cprintf(RED,"Listening_Thread %d: Listened to a weird packet size %d\n",ithread, receivedSize); - }/*else{ - testbit = 1; - }*/ + } #ifdef DEBUG else cprintf(BLUE,"Listening_Thread %d: Listened to a header packet\n",ithread); @@ -1590,11 +1587,6 @@ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, in receivedSize = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS); } totalListeningFrameCount[ithread] += (receivedSize/onePacketSize); - /*if(testbit == 1){ - testbit = 0; - eiger_packet_footer_t* footer = (eiger_packet_footer_t*)(buffer[ithread] + footerOffset + HEADER_SIZE_NUM_TOT_PACKETS); - cprintf(CYAN,"Listening_Thread %d: fnum:%d\n",ithread,(uint32_t)(*( (uint64_t*) footer))); - }*/ #ifdef MANUALDEBUG eiger_packet_header_t* header = (eiger_packet_header_t*) (buffer[ithread]+HEADER_SIZE_NUM_TOT_PACKETS); @@ -2099,7 +2091,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ numberofMissingPackets[i] = (LAST_PACKET_VALUE - lastPacketNumber[i]); else numberofMissingPackets[i] = (currentPacketNumber[i] - lastPacketNumber[i] - 1); - + numMissingPackets += numberofMissingPackets[i]; #ifdef DEBUG4 if(numPackets[i] == dummyPacketValue) @@ -2118,7 +2110,6 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ for(int j=0;jmissingPacket)!= missingPacketValue){ @@ -2137,10 +2128,10 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ *( (uint16_t*) frameBuffer_header->missingPacket)); #endif frameBufferoffset[i]=frameBufferoffset[i]+1; - //blankoffset++; } } + //missed packets/future packet: do not pop over and determine fullframe-------------------- popReady[i] = false; if((numPackets[i] == dummyPacketValue) ||(threadFrameNumber[i] != presentFrameNumber)) fullframe[i] = true; @@ -2149,24 +2140,8 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){ if(threadFrameNumber[i] != presentFrameNumber) threadFrameNumber[i] = presentFrameNumber; - //missed packets/future packet: do not pop over and determine fullframe-------------------- - if(numberofMissingPackets[i]){ - //popReady[i] = false; - //if((numPackets[i] == dummyPacketValue) ||(threadFrameNumber[i] != presentFrameNumber)) - // fullframe[i] = true; - //else{ - // fullframe[i] = false; - //update last packet - //lastPacketNumber[i] = currentPacketNumber[i] - 1; - //} - //if(threadFrameNumber[i] != presentFrameNumber) - // threadFrameNumber[i] = presentFrameNumber; - numMissingPackets += numberofMissingPackets[i]; - } - //add current packet-------------------------------------------------------------- - if(fullframe[i] == false){ if(currentPacketNumber[i] != (uint32_t)(frameBufferoffset[i]-(i*packetsPerFrame/numberofListeningThreads))+1){ cprintf(BG_RED, "Fifo %d: Correct Packet Offset Error: " @@ -2545,11 +2520,11 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* //copy frame for gui - /*if(npackets >= packetsPerFrame) + if(npackets >= packetsPerFrame) copyFrameToGui(wbuffer); #ifdef DEBUG4 cprintf(GREEN,"Writing_Thread: Copied frame\n"); -#endif*/ +#endif //free fifo addresses (eiger frees for each packet later) @@ -2708,8 +2683,8 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ } //add frame number - /**( (uint64_t*) wbuf_footer) = (currentFrameNumber+1) | (((uint64_t)(*( (uint16_t*) wbuf_footer->packetNumber)))<<0x30);*/ - //*( (uint16_t*) wbuf_footer->packetNumber) = (i+1); + ( (uint64_t*) wbuf_footer) = (currentFrameNumber+1) | (((uint64_t)(*( (uint16_t*) wbuf_footer->packetNumber)))<<0x30); + //*( (uint16_t*) wbuf_footer->packetNumber) = (i+1); // missing frames already have the right packet number #ifdef DEBUG4 cprintf(RED, "Missing Packet Loop index:%d fnum:%d Pnum:%d\n",i, (uint32_t)(*( (uint64_t*) wbuf_footer)), @@ -2731,13 +2706,17 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ exitVal =1; } - /*uint16_t p = *( (uint16_t*) wbuf_footer->packetNumber); + uint16_t p = *( (uint16_t*) wbuf_footer->packetNumber); //correct the packet numbers of port2 so that port1 and 2 are not the same - if(port) *( (uint16_t*) wbuf_footer->packetNumber) = (p +(packetsPerFrame/2));*/ + if(port) *( (uint16_t*) wbuf_footer->packetNumber) = (p +(packetsPerFrame/2)); } - /*//DEBUGGING + //overwriting port number and dynamic range + ( (uint8_t*) wbuf_header->portIndex) = (uint8_t)port; + *( (uint8_t*) wbuf_header->dynamicRange) = (uint8_t)dynamicRange; + + //DEBUGGING if(*( (uint16_t*) wbuf_footer->packetNumber) != (i+1)){ cprintf(BG_RED, "Writing_Thread: Packet Number Mismatch! " "i %d, real pnum %d, real fnum %d, missingPacket 0x%x\n", @@ -2746,10 +2725,7 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ (uint32_t)(*( (uint64_t*) wbuf_footer)), *( (uint16_t*) wbuf_header->missingPacket)); exitVal =1; - }*/ - //overwriting port number and dynamic range - /**( (uint8_t*) wbuf_header->portIndex) = (uint8_t)port; - *( (uint8_t*) wbuf_header->dynamicRange) = (uint8_t)dynamicRange;*/ + } } if(exitVal){exit(-1);} From 72cfd7a1d747b78805d29aacb51dbccd2c4a869b Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 2 Feb 2016 18:57:20 +0100 Subject: [PATCH 08/10] all changes done with bugs solved. need to test with image reconstruction --- slsReceiverSoftware/src/UDPStandardImplementation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 3c0252008..89bff743b 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -2683,7 +2683,7 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ } //add frame number - ( (uint64_t*) wbuf_footer) = (currentFrameNumber+1) | (((uint64_t)(*( (uint16_t*) wbuf_footer->packetNumber)))<<0x30); + *( (uint64_t*) wbuf_footer) = (currentFrameNumber+1) | (((uint64_t)(*( (uint16_t*) wbuf_footer->packetNumber)))<<0x30); //*( (uint16_t*) wbuf_footer->packetNumber) = (i+1); // missing frames already have the right packet number #ifdef DEBUG4 cprintf(RED, "Missing Packet Loop index:%d fnum:%d Pnum:%d\n",i, @@ -2713,7 +2713,7 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ } //overwriting port number and dynamic range - ( (uint8_t*) wbuf_header->portIndex) = (uint8_t)port; + *( (uint8_t*) wbuf_header->portIndex) = (uint8_t)port; *( (uint8_t*) wbuf_header->dynamicRange) = (uint8_t)dynamicRange; //DEBUGGING From fed17eb8ebc54d3fe521258d2b60d9cb24934889 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Wed, 3 Feb 2016 11:26:18 +0100 Subject: [PATCH 09/10] modified color of printout --- slsReceiverSoftware/src/UDPStandardImplementation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 89bff743b..60893deea 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -1501,7 +1501,7 @@ void UDPStandardImplementation::startListening(){ //udpsocket doesnt exist if(udpSocket[ithread] == NULL){ - FILE_LOG(logERROR) << "Listening_Thread " << ithread << ": UDP Socket not created"; + FILE_LOG(logERROR) << "Listening_Thread " << ithread << ": UDP Socket not created or shut down earlier"; stopListening(ithread,0); continue; } @@ -2461,7 +2461,7 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){ //statistics FILE_LOG(logINFO) << "Status: Run Finished"; - if(numTotMissingPackets){ + if(totalPacketsCaught != (numberOfFrames*packetsPerFrame)){ cprintf(RED, "Total Missing Packets padded: %d\n",numTotMissingPackets); cprintf(RED, "Total Packets Caught: %lld\n",(long long int)totalPacketsCaught); cprintf(RED, "Total Frames Caught: %lld\n",(long long int)(totalPacketsCaught/packetsPerFrame)); From ef8fbab1f4aa08f0c069fd4390ad20ebc59f0f08 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Wed, 3 Feb 2016 11:34:47 +0100 Subject: [PATCH 10/10] 10g bug fixed in previous branch merge --- slsReceiverSoftware/src/UDPStandardImplementation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 60893deea..c5fee8065 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -955,7 +955,7 @@ void UDPStandardImplementation::startReadout(){ totalP += totalListeningFrameCount[i]; } } - }//else cprintf(MAGENTA,"***Got all packets without waiting****\n"); + }