diff --git a/slsReceiverSoftware/include/circularFifo.h b/slsReceiverSoftware/include/circularFifo.h index 6f779aafc..1ba584cc4 100644 --- a/slsReceiverSoftware/include/circularFifo.h +++ b/slsReceiverSoftware/include/circularFifo.h @@ -79,7 +79,7 @@ template bool CircularFifo::push(Element*& item_) { - int nextTail = increment(tail); + unsigned int nextTail = increment(tail); if(nextTail != head) { array[tail] = item_; diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index 20326bafd..682c52980 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -1399,12 +1399,6 @@ int UDPBaseImplementation::startListening(){ FILE_LOG(logDEBUG) << __AT__ << " s int UDPBaseImplementation::startWriting(){ FILE_LOG(logDEBUG) << __AT__ << " starting"; - int ithread = currentWriterThreadIndex; -#ifdef VERYVERBOSE - cout << ithread << "In startWriting()" < 0){ - - //for progress and packet loss calculation(new files) - if(myDetectorType == EIGER); - else if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) - tempframenum = (((((uint32_t)(*((uint32_t*)(buf + HEADER_SIZE_NUM_TOT_PACKETS))))+1)& (frameIndexMask)) >> frameIndexOffset); - else - tempframenum = ((((uint32_t)(*((uint32_t*)(buf + HEADER_SIZE_NUM_TOT_PACKETS))))& (frameIndexMask)) >> frameIndexOffset); - - if(numWriterThreads == 1) - currframenum = tempframenum; - else{ - if(tempframenum > currframenum) - currframenum = tempframenum; - } -#ifdef VERYDEBUG - cout << "tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl; -#endif - - //lock - if(numWriterThreads > 1) - pthread_mutex_lock(&write_mutex); - - - //to create new file when max reached - packetsToSave = maxPacketsPerFile - packetsInFile; - if(packetsToSave > numpackets) - packetsToSave = numpackets; -/**next time offset is still plus header length*/ - fwrite(buf+offset, 1, packetsToSave * onePacketSize, sfilefd); - packetsInFile += packetsToSave; - packetsCaught += packetsToSave; - totalPacketsCaught += packetsToSave; - - - //new file - if(packetsInFile >= maxPacketsPerFile){ - //for packet loss - lastpacket = (((packetsToSave - 1) * onePacketSize) + offset); - if(myDetectorType == EIGER); - else if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) - tempframenum = (((((uint32_t)(*((uint32_t*)(buf + lastpacket))))+1)& (frameIndexMask)) >> frameIndexOffset); - else - tempframenum = ((((uint32_t)(*((uint32_t*)(buf + lastpacket))))& (frameIndexMask)) >> frameIndexOffset); - - if(numWriterThreads == 1) - currframenum = tempframenum; - else{ - if(tempframenum > currframenum) - currframenum = tempframenum; - } -#ifdef VERYDEBUG - cout << "tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl; -#endif - //create - createNewFile(); - } - - //unlock - if(numWriterThreads > 1) - pthread_mutex_unlock(&write_mutex); - - - offset += (packetsToSave * onePacketSize); - numpackets -= packetsToSave; - } - - } - else{ - if(numWriterThreads > 1) - pthread_mutex_lock(&write_mutex); - packetsInFile += numpackets; - packetsCaught += numpackets; - totalPacketsCaught += numpackets; - if(numWriterThreads > 1) - pthread_mutex_unlock(&write_mutex); - } } @@ -1675,97 +1581,6 @@ void UDPBaseImplementation::handleDataCompression(int ithread, char* wbuffer[], FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " starting"; -#if defined(MYROOT1) && defined(ALLFILE_DEBUG) - writeToFile_withoutCompression(wbuf[0], numpackets,currframenum); -#endif - - eventType thisEvent = PEDESTAL; - int ndata; - char* buff = 0; - int npackets = (uint16_t)(*((uint16_t*)wbuffer[0])); - data = wbuffer[0]+ HEADER_SIZE_NUM_TOT_PACKETS; - int remainingsize = npackets * onePacketSize; - int np; - int once = 0; - double tot, tl, tr, bl, br; - int xmin = 1, ymin = 1, ix, iy; - - - while(buff = receiverdata[ithread]->findNextFrame(data,ndata,remainingsize)){ - np = ndata/onePacketSize; - - //cout<<"buff framnum:"<> frameIndexOffset)<newFrame(); - - //only for moench - if(commonModeSubtractionEnable){ - for(ix = xmin - 1; ix < xmax+1; ix++){ - for(iy = ymin - 1; iy < ymax+1; iy++){ - thisEvent = singlePhotonDet[ithread]->getEventType(buff, ix, iy, 0); - } - } - } - - - for(ix = xmin - 1; ix < xmax+1; ix++) - for(iy = ymin - 1; iy < ymax+1; iy++){ - thisEvent=singlePhotonDet[ithread]->getEventType(buff, ix, iy, commonModeSubtractionEnable); - if (nf>1000) { - tot=0; - tl=0; - tr=0; - bl=0; - br=0; - if (thisEvent==PHOTON_MAX) { - receiverdata[ithread]->getFrameNumber(buff); - //iFrame=receiverdata[ithread]->getFrameNumber(buff); -#ifdef MYROOT1 - myTree[ithread]->Fill(); - //cout << "Fill in event: frmNr: " << iFrame << " ix " << ix << " iy " << iy << " type " << thisEvent << endl; -#else - pthread_mutex_lock(&write_mutex); - if((enableFileWrite) && (sfilefd)) - singlePhotonDet[ithread]->writeCluster(sfilefd); - pthread_mutex_unlock(&write_mutex); -#endif - } - } - } - - nf++; -#ifndef ALLFILE - pthread_mutex_lock(&progress_mutex); - packetsInFile += packetsPerFrame; - packetsCaught += packetsPerFrame; - totalPacketsCaught += packetsPerFrame; - if(packetsInFile >= maxPacketsPerFile) - createNewFile(); - pthread_mutex_unlock(&progress_mutex); - -#endif - if(!once){ - copyFrameToGui(NULL,buff); - once = 1; - } - } - - remainingsize -= ((buff + ndata) - data); - data = buff + ndata; - if(data > (wbuffer[0] + HEADER_SIZE_NUM_TOT_PACKETS + npackets * onePacketSize) ) - cout <<" **************ERROR SHOULD NOT COME HERE, Error 142536!"<push(wbuffer[0])); -#ifdef VERYVERBOSE - cout<<"buf freed:"<<(void*)wbuffer[0]<missingpacket)!= missingPacketValue){ cprintf(BG_RED, "wrong blank mismatch num4 earlier2! " - "i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x add:0x%x\n", + "i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x add:0x%p\n", i,tempoffset[i],tempframenum[i], *( (uint16_t*) tempframe_header->missingpacket), *( (uint16_t*) blankframe_header->missingpacket), @@ -2303,7 +2297,7 @@ int UDPStandardImplementation::startWriting(){ blankframe_header = (eiger_packet_header_t*) blankframe[blankoffset]; if (*( (uint16_t*) tempframe_header->missingpacket)!= missingPacketValue){ cprintf(BG_RED, "correct blank mismatch num4 earlier2! " - "i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x add:0x%x\n", + "i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x add:0x%p\n", i,tempoffset[i],tempframenum[i], *( (uint16_t*) tempframe_header->missingpacket), *( (uint16_t*) blankframe_header->missingpacket), @@ -2320,7 +2314,7 @@ int UDPStandardImplementation::startWriting(){ blankoffset ++; } //add current packet - if(currentpacketheader[i] != (tempoffset[i]-(i*packetsPerFrame/numListeningThreads))+1){ + if(currentpacketheader[i] != (uint32_t)(tempoffset[i]-(i*packetsPerFrame/numListeningThreads))+1){ cprintf(BG_RED, "correct pnum mismatch earlier! tempoffset[%d]:%d pnum:%d fnum:%d rfnum:%d\n", i,tempoffset[i],currentpacketheader[i], tempframenum[i],(uint32_t)(*( (uint64_t*) wbuf_footer))); @@ -2335,7 +2329,7 @@ int UDPStandardImplementation::startWriting(){ i,*( (uint16_t*) tempframe_footer->packetnum),tempoffset[i]); #endif if(*( (uint16_t*) tempframe_footer->packetnum)!= (tempoffset[i]-(i*packetsPerFrame/numListeningThreads))+1){ - cprintf(BG_RED, "pnum mismatch num4 earlier! i:%d pnum:%d pnum orig:%d fnum:%d add:0x%x\n", + cprintf(BG_RED, "pnum mismatch num4 earlier! i:%d pnum:%d pnum orig:%d fnum:%d add:0x%p\n", i,*( (uint16_t*) tempframe_footer->packetnum),*( (uint16_t*) wbuf_footer->packetnum), tempframenum[i],(void*)(tempbuffer[tempoffset[i]])); exit(-1); @@ -2815,7 +2809,7 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf[],int n cprintf(GREEN,"totalPacketsCaught:%d\n", totalPacketsCaught); #endif //new file - if(packetsInFile >= maxPacketsPerFile){ + if(packetsInFile >= (uint32_t)maxPacketsPerFile){ //for packet loss, because currframenum is the latest one for eiger if(myDetectorType != EIGER){ @@ -2870,7 +2864,7 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf[],int n void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* wbuffer[],int npackets){ - int i,j, missingpacket,port = 0, pnuminc; + int i, missingpacket,port = 0; if (cbAction < DO_EVERYTHING){ @@ -3069,7 +3063,7 @@ void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer packetsInFile += packetsPerFrame; packetsCaught += packetsPerFrame; totalPacketsCaught += packetsPerFrame; - if(packetsInFile >= maxPacketsPerFile) + if(packetsInFile >= (uint32_t)maxPacketsPerFile) createNewFile(); pthread_mutex_unlock(&progress_mutex); diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index ffa3f5d8c..24e475c50 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -39,10 +39,11 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* shortFrame(-1), packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME), dynamicrange(16), - socket(NULL), killTCPServerThread(0), - tenGigaEnable(0), portNumber(DEFAULT_PORTNO+2), - bottom(bot){ + tenGigaEnable(0), + portNumber(DEFAULT_PORTNO+2), + bottom(bot), + socket(NULL){ int port_no=portNumber; if(receiverBase == NULL) receiverBase = 0;