From 3ee146a2cacd92ec9a41627fc9c0a6aba7dd87bd Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 24 Feb 2015 16:19:33 +0100 Subject: [PATCH] moved start of frame to after stoplistening, for eiger to ignore incomplete frames --- .../src/UDPBaseImplementation.cpp | 1 + .../src/UDPStandardImplementation.cpp | 61 ++++++++++++------- .../src/slsReceiverTCPIPInterface.cpp | 12 ++-- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index 7641a5a1e..9c6c26460 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -171,6 +171,7 @@ uint32_t UDPBaseImplementation::getAcquisitionIndex(){ FILE_LOG(logDEBUG) << __A acquisitionIndex=-1; else acquisitionIndex = currframenum - startAcquisitionIndex; + //cout<<"acquisitionIndex:"< 0) && (!ithread)) startFrameIndices(ithread); - +*/ //problem in receiving or end of acquisition if((rc < expected)||(rc <= 0)){ @@ -1703,11 +1703,11 @@ int UDPStandardImplementation::startListening(){ continue; } -/* - //start indices for each start of scan/acquisition - eiger does it before +///* + //start indices for each start of scan/acquisition - this should be done after to ignore first incomplete frames if((!measurementStarted) && (rc > 0) && (!ithread)) startFrameIndices(ithread); -*/ +//*/ //reset packetcount = (packetsPerFrame/numListeningThreads) * numJobsPerThread; @@ -1884,17 +1884,16 @@ int UDPStandardImplementation::startWriting(){ cout << ithread << " *** writer popped from fifo " << (void*) wbuf[1]<< endl; #endif - //last dummy packet if(numpackets == 0xFFFF){ #ifdef VERYDEBUG - cout << "LAST dummy packet" << endl; + cout << "**LAST dummy packet" << endl; #endif stopWriting(ithread,wbuf); continue; } #ifdef VERYDEBUG - else cout <<"NOT a dummy packet"<push(buffer[ithread]); exit(-1); } + //push the last buffer into fifo - if((myDetectorType == EIGER) && (rc < 266240) )//for eiger throw away incomplete frames - fifoFree[ithread]->push(buffer[ithread]); - else if(rc > 0){ - pc = (rc/onePacketSize); + if(rc > 0){ + //eiger (incomplete frames) - throw away + if((myDetectorType == EIGER) && (rc < (bufferSize * numJobsPerThread)) ){ + if(rc == 266240) + cout << ithread << " Start of detector: Received test frame of 266240 bytes." << endl; + cout << ithread << "Discarding incomplete frame" << endl; + fifoFree[ithread]->push(buffer[ithread]); + } + //eiger (complete frames) + other detectors + else{ + pc = (rc/onePacketSize); #ifdef VERYDEBUG - cout << ithread << " last rc:"<push(buffer[ithread])); + (*((uint16_t*)(buffer[ithread]))) = pc; + totalListeningFrameCount[ithread] += pc; + while(!fifo[ithread]->push(buffer[ithread])); #ifdef VERYDEBUG - cout << ithread << " *** last lbuf1:" << (void*)buffer[ithread] << endl; + cout << ithread << " *** last lbuf1:" << (void*)buffer[ithread] << endl; #endif + } } + //free buffer + else{ + cout << ithread << "Discarding empty frame" << endl; + fifoFree[ithread]->push(buffer[ithread]); + } + //push dummy buffer to all writer threads @@ -2279,8 +2293,9 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf,int num packetsInFile += packetsToSave; packetsCaught += packetsToSave; totalPacketsCaught += packetsToSave; - - +#ifdef VERYDEBUG + cout << "/totalPacketsCaught:" << dec << totalPacketsCaught <= maxPacketsPerFile){ //for packet loss diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index d98a7ddd7..8b0d52195 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -1336,9 +1336,9 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){ /**send garbage with -1 index to try again*/ if (raw == NULL){ arg = -1; -//#ifdef VERBOSE +#ifdef VERBOSE cout<<"data not ready for gui yet"<