diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 3cd559b52..9f365d4b0 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -1922,43 +1922,34 @@ int UDPStandardImplementation::startWriting(){ thread_started = 1; - int numpackets[numListeningThreads], nf; - bool startdatapacket[numListeningThreads],fullframe[numListeningThreads],popready[numListeningThreads]; - uint32_t tempframenum[numListeningThreads]; - - int lastpacketheader[numListeningThreads], currentpacketheader[numListeningThreads]; - int numberofmissingpackets[numListeningThreads]; - int LAST_PACKET_VALUE; - - - char* wbuf[numListeningThreads];//interleaved char *d=new char[bufferSize*numListeningThreads]; int xmax=0,ymax=0; int ret,i,j; + int numpackets[numListeningThreads], nf; + bool startdatapacket[numListeningThreads],fullframe[numListeningThreads],popready[numListeningThreads]; + uint32_t tempframenum[numListeningThreads]; + int lastpacketheader[numListeningThreads], currentpacketheader[numListeningThreads]; + int numberofmissingpackets[numListeningThreads]; - char* tofree[packetsPerFrame] ; - int tofreeoffset[packetsPerFrame]; - char* tempbuffer[packetsPerFrame]; - char* blankframe[packetsPerFrame]; - int blankoffset; + int MAX_VALUE = 1024; + char* tofree[MAX_VALUE]; + char* tempbuffer[MAX_VALUE]; + char* blankframe[MAX_VALUE]; + int tofreeoffset[numListeningThreads]; int tempoffset[numListeningThreads]; + int blankoffset; + for(i=0;inum3)) != 0xFF) - cprintf(RED,"blank frame header is not FF\n"); - - cprintf(GREEN,"packet %d blank frame 0x%x\n",i,(void*)(blankframe[i])); - } - - //last packet numbers for different dynamic ranges switch(dynamicRange){ case 4: LAST_PACKET_VALUE = 0x40; break; case 8: LAST_PACKET_VALUE = 0x80; break; @@ -1966,9 +1957,10 @@ int UDPStandardImplementation::startWriting(){ case 32: LAST_PACKET_VALUE = 0xff; break; default: break; } - } + + while(1){ @@ -1989,6 +1981,20 @@ int UDPStandardImplementation::startWriting(){ //so that the first frame is always copied guiData = latestData; + //blank frame + if(myDetectorType == EIGER){ + for(i=0;ipush((wbuf[i]))); -//#ifdef FIFO_DEBUG - cprintf(GREEN,"%d writer freed unknown length pushed into fifofree %x for listener %d\n",ithread, (void*)(wbuf[i]),i); -//#endif - } continue; } //not dummy buffer and not after getting a full frame if(numpackets[i] && (!fullframe[i])){ - //header packet + //IMAGE HEADER PACKET if( 0x01 == (*(uint8_t*)(((eiger_image_header *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->header_confirm))){ //new frame (no datapacket received yet), update frame num and corrected for fnum reset for scans @@ -2114,12 +2115,37 @@ int UDPStandardImplementation::startWriting(){ if(!tempframenum[i]) cprintf(RED,"**VERY WEIRD frame numbers for fifo %d: %d\n",i,tempframenum[i]); tempframenum[i] += (startFrameIndex-1); - //#ifdef VERYVERBOSE - cprintf(GREEN,"**tempfraemnum of %d: %d\n",i,tempframenum[i]); - //#endif - }//next frame, leave + + //normal frame packet (also exception of tempnum 0 and currfnum 0) + if((tempframenum[i] == (currframenum+1))||(!tempframenum[i] && !currframenum)){ +#ifdef EIGER_DEBUG3 + cprintf(GREEN,"**tempfraemnum of %d: %d\n",i,tempframenum[i]); +#endif + } + //frame too far ahead + else{ +#ifdef EIGER_DEBUG3 + cprintf(RED,"frame number too far ahead, missing packets\n"); +#endif + tempframenum[i] = currframenum + 1; + //add missing packets + numberofmissingpackets[i] = (LAST_PACKET_VALUE); + //to decrement from packetsInFile to calculate packet loss + for(j=0;jpush(wbuffer[i])); -//#ifdef FIFO_DEBUG +#ifdef FIFO_DEBUG cprintf(GREEN,"%d writer free dummy pushed into fifofree %x for listener %d\n", ithread,(void*)(wbuffer[i]),i); -//#endif +#endif } @@ -2584,7 +2610,7 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf[],int numpackets, uint32_t framenum){ FILE_LOG(logDEBUG) << __AT__ << " called"; -cout<<"in write to file numpackets:"<= maxPacketsPerFile){ @@ -2814,28 +2842,10 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* cprintf(GREEN,"gonna copy frame\n"); #endif copyFrameToGui(wbuffer,currframenum); - //#ifdef VERYDEBUG +#ifdef VERYDEBUG cprintf(GREEN,"copied frame\n"); - //#endif - -/* - for(j=0;jnum3)) != 0xFF){ - - while(!fifoFree[(j/(packetsPerFrame/2))]->push(&(wbuffer[j] - HEADER_SIZE_NUM_TOT_PACKETS))); - - //#ifdef FIFO_DEBUG - cprintf(GREEN,"%d writer freed pushed into fifofree %x for listener %d\n",ithread, (void*)(wbuffer[j]- HEADER_SIZE_NUM_TOT_PACKETS),(j/(packetsPerFrame/2))); - //#endif - }else cprintf(GREEN,"blank frame 0x%x\n",(void*)(wbuffer[j])); - } - - //#ifdef VERYDEBUG - cprintf(GREEN,"finished freeing\n"); - //#endif - */ - } - else{ +#endif + }else{ //copy to gui if(npackets >= packetsPerFrame){//min 1 frame, but neednt be //if(npackets == packetsPerFrame * numJobsPerThread){ //only full frames @@ -2843,11 +2853,14 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* #ifdef VERYVERBOSE cout << ithread << " finished copying" << endl; #endif - }//else cout << "unfinished buffersize" << endl; + } + /* freeing now done at function call + //else cout << "unfinished buffersize" << endl; while(!fifoFree[0]->push(wbuffer[0])); #ifdef FIFO_DEBUG cprintf(GREEN,"%d writer freed pushed into fifofree %x for listener 0\n",ithread, (void*)(wbuffer[0])); #endif + */ } }