From 44870480be2f33be577e623fc64fd499238bb539 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Thu, 22 Sep 2016 13:17:17 +0200 Subject: [PATCH] merging for gotthard, not done --- slsReceiverSoftware/include/receiver_defs.h | 4 ++- .../src/UDPStandardImplementation.cpp | 27 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/slsReceiverSoftware/include/receiver_defs.h b/slsReceiverSoftware/include/receiver_defs.h index 0c60b892c..d0cd07320 100755 --- a/slsReceiverSoftware/include/receiver_defs.h +++ b/slsReceiverSoftware/include/receiver_defs.h @@ -169,7 +169,9 @@ typedef struct { #define EIGER_MAX_PORTS 2 -#define EIGER_HEADER_LENGTH 48 +#define EIGER_HEADER_PACKET_LENGTH 48 + +#define EIGER_HEADER_SIZE 8 #define EIGER_FIFO_SIZE 100 /*#define EIGER_ALIGNED_FRAME_SIZE 65536*/ diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index d46ca831f..01bf81401 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -1219,7 +1219,7 @@ void UDPStandardImplementation::closeFile(int ithread){ int UDPStandardImplementation::createDataCallbackThreads(bool destroy){ FILE_LOG(logDEBUG) << __AT__ << " starting"; - + if(!destroy) cprintf(MAGENTA,"Data Callback thread created\n"); else cprintf(MAGENTA,"Data Callback thread destroyed\n"); //reset masks killAllDataCallbackThreads = false; pthread_mutex_lock(&statusMutex); @@ -1270,7 +1270,7 @@ int UDPStandardImplementation::createDataCallbackThreads(bool destroy){ int UDPStandardImplementation::createListeningThreads(bool destroy){ FILE_LOG(logDEBUG) << __AT__ << " starting"; - + if(!destroy) cprintf(BLUE,"Listening thread created\n"); else cprintf(BLUE,"Listening thread destroyed\n"); //reset masks killAllListeningThreads = false; pthread_mutex_lock(&statusMutex); @@ -1321,7 +1321,7 @@ int UDPStandardImplementation::createListeningThreads(bool destroy){ int UDPStandardImplementation::createWriterThreads(bool destroy){ FILE_LOG(logDEBUG) << __AT__ << " starting"; - + if(!destroy) cprintf(GREEN,"Writer thread created\n"); else cprintf(GREEN,"Writer thread destroyed\n"); //reset masks killAllWritingThreads = false; pthread_mutex_lock(&statusMutex); @@ -1439,7 +1439,7 @@ int UDPStandardImplementation::createUDPSockets(){ shutDownUDPSockets(); int headerpacketsize = 0; if(myDetectorType == EIGER) - headerpacketsize = EIGER_HEADER_LENGTH; + headerpacketsize = EIGER_HEADER_PACKET_LENGTH; //if no eth, listen to all if(!strlen(eth)){ @@ -1668,6 +1668,15 @@ void UDPStandardImplementation::startDataCallback(){ sprintf(hostName,"%s%d",hostName,portno); FILE_LOG(logINFO) << "Thread" << ithread << ": ZMQ Server at " << hostName; + + int headersize=0; + switch(myDetectorType){ + case EIGER: + headersize = EIGER_HEADER_SIZE; break; + + } + + /* outer loop - loops once for each acquisition */ //infinite loop, exited only to change dynamic range, 10G parameters etc (then recreated again) while(true){ @@ -1705,7 +1714,7 @@ void UDPStandardImplementation::startDataCallback(){ int frameIndex = -1; int subframeIndex = -1; #ifdef DEBUG - int oldpnum = 0; + int oldpnum = -1; #endif int datapacketscaught = 0; @@ -1797,11 +1806,11 @@ void UDPStandardImplementation::startDataCallback(){ //last packet of same frame - if(fnum == currentfnum && pnum == packetsPerFrame){ + if(fnum == currentfnum && pnum == (packetsPerFrame-1)){ #ifdef DEBUG oldpnum=0; #endif - memcpy(buffer+((pnum-1)*oneDataSize), latestData[ithread]+offset+8,oneDataSize); + memcpy(buffer+(pnum*oneDataSize), latestData[ithread]+offset+headersize,oneDataSize); offset+= onePacketSize; //send header //update frame details @@ -1861,7 +1870,7 @@ void UDPStandardImplementation::startDataCallback(){ memset(buffer,0xFF,oneframesize); } - memcpy(buffer+((pnum-1)*oneDataSize), latestData[ithread]+offset+8,oneDataSize); + memcpy(buffer+(pnum*oneDataSize), latestData[ithread]+offset+headersize,oneDataSize); offset+= onePacketSize; newFrame = true; } @@ -3030,7 +3039,7 @@ int UDPStandardImplementation::getFrameandPacketNumber(int ithread, char* wbuffe FILE_LOG(logERROR) << "Fifo "<< ithread << ": Frame Number is zero from firmware."; return FAIL; } - packetnumber = (*( (uint16_t*) footer->packetNumber)); + packetnumber = (*( (uint16_t*) footer->packetNumber))-1; e_header = (eiger_packet_header_t*) (wbuffer); subframenumber = *( (uint32_t*) e_header->subFrameNumber); #ifdef DEBUG4