diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h index 3ece433dd..9daf2ab79 100644 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ b/slsReceiverSoftware/include/UDPBaseImplementation.h @@ -659,6 +659,9 @@ protected: /** Receiver buffer */ char *buffer[MAX_NUM_LISTENING_THREADS]; + /** Missing Packet */ + char *missingPacket; + /** number of writer threads */ int numListeningThreads; diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 5b6ca4bdf..004ba1fb1 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -54,6 +54,7 @@ UDPStandardImplementation::UDPStandardImplementation() udpSocket[i] = NULL; server_port[i] = DEFAULT_UDP_PORTNO+i; mem0[i] = NULL; + missingPacket[i] = NULL; fifo[i] = NULL; fifoFree[i] = NULL; } @@ -163,6 +164,7 @@ void UDPStandardImplementation::initializeMembers(){ for(int i=0;inum4))); + numberofmissingpackets = 0; - //push missing packet if any by looking at last packetheader values - - - //packetnumber is smaller = different frame - if(lastpacketheader >= ((*(uint8_t*)(((eiger_packet_header *)((char*)(buffer[ithread])))->num4)))) + //update tempframenumber if header packet missed out, ie. if packetnumber is smaller = different frame + if(lastpacketheader >= currentpacketheader){ tempframenum++; + //add missing packets for previous frame + numberofmissingpackets += (LAST_PACKET_VALUE - lastpacketheader); + //add for missing frames + numberofmissingpackets += ((tempframenum-lastframeheader -1) * (packetsPerFrame/numListeningThreads)); + //add missing packets for current frame + numberofmissingpackets += (currentpacketheader); + } - //tag framenumber to the packet - (*(uint32_t*)(((eiger_packet_header *)((char*)(buffer[ithread])))->num1)) = tempframenum; //remember last packet value lastpacketheader = ((*(uint8_t*)(((eiger_packet_header *)((char*)(buffer[ithread])))->num4))); + lastframeheader = tempframenum; + + //temporarily store current buffer if there are missing packets + if(numberofmissingpackets) + tempchar = buffer[ithread]; + + for(i=0;inum1)) = tempframenum; +#ifdef VERYDEBUG + cprintf(BLUE,"%d listener going to push fifo: 0x%x\n", ithread,(void*)(buffer[ithread])); +#endif + while(!fifo[ithread]->push(buffer[ithread])); +#ifdef FIFO_DEBUG + //if(!ithread) + cprintf(BLUE, "%d listener pushed into fifo %x\n",ithread, (void*)(buffer[ithread])); +#endif +#ifdef VERYDEBUG + cprintf(BLUE, "%d waiting to pop out of listeningfifo\n",ithread); +#endif + //pop + fifoFree[ithread]->pop(buffer[ithread]); +#ifdef FIFO_DEBUG + cprintf(BLUE,"%d listener popped from fifofree %x\n", ithread, (void*)(buffer[ithread])); +#endif + } + + buffer[ithread] = tempchar; + //tag framenumber to the packet + (*(uint32_t*)(((eiger_packet_header *)((char*)(buffer[ithread])))->num1)) = tempframenum; + packetcount = 1; - - - - +/* //literally end of buffer lastpacketoffset = rc + HEADER_SIZE_NUM_TOT_PACKETS; @@ -1997,6 +2068,8 @@ int UDPStandardImplementation::startListening(){ //when we lose frame header packet lastframeheader = htonl(*(unsigned int*)((eiger_image_header *)((char*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum); cprintf(RED,"%d lastframeheader : %d\n", ithread, lastframeheader); + + */ break; @@ -2007,11 +2080,14 @@ int UDPStandardImplementation::startListening(){ + + //#ifdef VERYDEBUG cprintf(BLUE, "%d packetcount:%d carryonbuffer:%d\n", ithread, packetcount, carryonBufferSize); //#endif //write packet count and push - (*((uint16_t*)(buffer[ithread]))) = packetcount; + if(myDetectorType != EIGER) + (*((uint16_t*)(buffer[ithread]))) = packetcount; totalListeningFrameCount[ithread] += packetcount; #ifdef VERYDEBUG cprintf(BLUE,"%d listener going to push fifo: 0x%x\n", ithread,(void*)(buffer[ithread])); @@ -2067,8 +2143,7 @@ int UDPStandardImplementation::startWriting(){ int xmax=0,ymax=0; int ret,i; int packetsPerThread = packetsPerFrame/numListeningThreads; - int allDummyFramesPopped; - int smaller, onlyoneport=0; + while(1){ @@ -2099,16 +2174,10 @@ int UDPStandardImplementation::startWriting(){ while((1<push(wbuf[i])); -#ifdef FIFO_DEBUG - cprintf(GREEN,"%d writer free dummy pushed into fifofree %x for listener %d\n", ithread,(void*)(wbuf[i]),i); -#endif - - }else allDummyFramesPopped = 0; - } } - //if all last dummy frames popped - if(allDummyFramesPopped){ + if(numpackets[i] == 0xFFFF){ #ifdef VERYDEBUG cprintf(GREEN,"%d all dummy frames popped\n", ithread); #endif