mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
seems to run fine, only 16gb checked for fimware v 10 and software version v1.10.2
This commit is contained in:
parent
572b6fe29f
commit
fe76ce9650
@ -505,6 +505,9 @@ protected:
|
|||||||
/** max number of writer threads */
|
/** max number of writer threads */
|
||||||
const static int MAX_NUM_WRITER_THREADS = 15;
|
const static int MAX_NUM_WRITER_THREADS = 15;
|
||||||
|
|
||||||
|
/** missing packet identifier value */
|
||||||
|
const static uint16_t missingPacketValue = 0xFFFF;
|
||||||
|
|
||||||
/** detector type */
|
/** detector type */
|
||||||
detectorType myDetectorType;
|
detectorType myDetectorType;
|
||||||
|
|
||||||
@ -712,6 +715,9 @@ protected:
|
|||||||
/** 10Gbe enable*/
|
/** 10Gbe enable*/
|
||||||
int tengigaEnable;
|
int tengigaEnable;
|
||||||
|
|
||||||
|
/** footer offset is different for 1g and 10g*/
|
||||||
|
int footer_offset;
|
||||||
|
|
||||||
// TODO: not properly sure where to put these...
|
// TODO: not properly sure where to put these...
|
||||||
/** structure of an eiger image header*/
|
/** structure of an eiger image header*/
|
||||||
|
|
||||||
|
@ -118,10 +118,11 @@
|
|||||||
#define EIGER_ONE_GIGA_ONE_DATA_SIZE 1024
|
#define EIGER_ONE_GIGA_ONE_DATA_SIZE 1024
|
||||||
#define EIGER_TEN_GIGA_ONE_PACKET_SIZE 4112
|
#define EIGER_TEN_GIGA_ONE_PACKET_SIZE 4112
|
||||||
#define EIGER_TEN_GIGA_ONE_DATA_SIZE 4096
|
#define EIGER_TEN_GIGA_ONE_DATA_SIZE 4096
|
||||||
|
#define EIGER_PACKET_HEADER_SIZE 8
|
||||||
//#define EIGER_BUFFER_SIZE_CONSTANT (EIGER_ONE_PACKET_SIZE*EIGER_PACKETS_PER_FRAME_COSTANT)//1040*16*2//*bit mode
|
//#define EIGER_BUFFER_SIZE_CONSTANT (EIGER_ONE_PACKET_SIZE*EIGER_PACKETS_PER_FRAME_COSTANT)//1040*16*2//*bit mode
|
||||||
//#define EIGER_DATA_BYTES_CONSTANT (EIGER_ONE_DATA_SIZE*EIGER_PACKETS_PER_FRAME_COSTANT) //1024*16*2//*bit mode
|
//#define EIGER_DATA_BYTES_CONSTANT (EIGER_ONE_DATA_SIZE*EIGER_PACKETS_PER_FRAME_COSTANT) //1024*16*2//*bit mode
|
||||||
|
|
||||||
#define EIGER_FRAME_INDEX_MASK 0xFFFF
|
#define EIGER_FRAME_INDEX_MASK 0xFFFFFFFF //32 bit for now
|
||||||
#define EIGER_FRAME_INDEX_OFFSET 0
|
#define EIGER_FRAME_INDEX_OFFSET 0
|
||||||
#define EIGER_PACKET_INDEX_MASK 0x0
|
#define EIGER_PACKET_INDEX_MASK 0x0
|
||||||
|
|
||||||
|
@ -558,83 +558,6 @@ void UDPBaseImplementation::setupFilter(){ FILE_LOG(logDEBUG) << __AT__ << " sta
|
|||||||
//LEO: it is not clear to me..
|
//LEO: it is not clear to me..
|
||||||
void UDPBaseImplementation::setupFifoStructure(){ FILE_LOG(logDEBUG) << __AT__ << " starting";
|
void UDPBaseImplementation::setupFifoStructure(){ FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||||
|
|
||||||
int64_t i;
|
|
||||||
int oldn = numJobsPerThread;
|
|
||||||
|
|
||||||
//if every nth frame mode
|
|
||||||
if(nFrameToGui)
|
|
||||||
numJobsPerThread = nFrameToGui;
|
|
||||||
|
|
||||||
//random nth frame mode
|
|
||||||
else{
|
|
||||||
if(!acquisitionPeriod)
|
|
||||||
i = SAMPLE_TIME_IN_NS;
|
|
||||||
else
|
|
||||||
i = SAMPLE_TIME_IN_NS/acquisitionPeriod;
|
|
||||||
if (i > MAX_JOBS_PER_THREAD)
|
|
||||||
numJobsPerThread = MAX_JOBS_PER_THREAD;
|
|
||||||
else if (i < 1)
|
|
||||||
numJobsPerThread = 1;
|
|
||||||
else
|
|
||||||
numJobsPerThread = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if same, return
|
|
||||||
if(oldn == numJobsPerThread)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(myDetectorType == EIGER)
|
|
||||||
numJobsPerThread = 1;
|
|
||||||
|
|
||||||
//otherwise memory too much if numjobsperthread is at max = 1000
|
|
||||||
fifosize = GOTTHARD_FIFO_SIZE;
|
|
||||||
if(myDetectorType == MOENCH)
|
|
||||||
fifosize = MOENCH_FIFO_SIZE;
|
|
||||||
else if(myDetectorType == EIGER)
|
|
||||||
fifosize = EIGER_FIFO_SIZE;
|
|
||||||
|
|
||||||
if(fifosize % numJobsPerThread)
|
|
||||||
fifosize = (fifosize/numJobsPerThread)+1;
|
|
||||||
else
|
|
||||||
fifosize = fifosize/numJobsPerThread;
|
|
||||||
|
|
||||||
|
|
||||||
cout << "Number of Frames per buffer:" << numJobsPerThread << endl;
|
|
||||||
cout << "Fifo Size:" << fifosize << endl;
|
|
||||||
|
|
||||||
/*
|
|
||||||
//for testing
|
|
||||||
numJobsPerThread = 3; fifosize = 11;
|
|
||||||
*/
|
|
||||||
|
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
|
||||||
//deleting old structure and creating fifo structure
|
|
||||||
if(fifoFree[i]){
|
|
||||||
while(!fifoFree[i]->isEmpty())
|
|
||||||
fifoFree[i]->pop(buffer[i]);
|
|
||||||
delete fifoFree[i];
|
|
||||||
}
|
|
||||||
if(fifo[i]) delete fifo[i];
|
|
||||||
if(mem0[i]) free(mem0[i]);
|
|
||||||
fifoFree[i] = new CircularFifo<char>(fifosize);
|
|
||||||
fifo[i] = new CircularFifo<char>(fifosize);
|
|
||||||
|
|
||||||
|
|
||||||
//allocate memory
|
|
||||||
mem0[i]=(char*)malloc((bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS)*fifosize);
|
|
||||||
/** shud let the client know about this */
|
|
||||||
if (mem0[i]==NULL){
|
|
||||||
cprintf(BG_RED,"++++++++++++++++++++++ COULD NOT ALLOCATE MEMORY FOR LISTENING !!!!!!!+++++++++++++++++++++\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
buffer[i]=mem0[i];
|
|
||||||
//push the addresses into freed fifoFree and writingFifoFree
|
|
||||||
while (buffer[i]<(mem0[i]+(bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS)*(fifosize-1))) {
|
|
||||||
fifoFree[i]->push(buffer[i]);
|
|
||||||
buffer[i]+=(bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cout << "Fifo structure(s) reconstructed" << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1529,93 +1452,6 @@ int UDPBaseImplementation::startWriting(){ FILE_LOG(logDEBUG) << __AT__ << " sta
|
|||||||
cout << ithread << "In startWriting()" <<endl;
|
cout << ithread << "In startWriting()" <<endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
thread_started = 1;
|
|
||||||
|
|
||||||
int numpackets, nf;
|
|
||||||
uint32_t tempframenum;
|
|
||||||
char* wbuf[numListeningThreads];//interleaved
|
|
||||||
char *d=new char[bufferSize*numListeningThreads];
|
|
||||||
int xmax=0,ymax=0;
|
|
||||||
int ret,i;
|
|
||||||
int packetsPerThread = packetsPerFrame/numListeningThreads;
|
|
||||||
|
|
||||||
while(1){
|
|
||||||
|
|
||||||
|
|
||||||
nf = 0;
|
|
||||||
packetsPerThread = packetsPerFrame/numListeningThreads;
|
|
||||||
if(myDetectorType == MOENCH){
|
|
||||||
xmax = MOENCH_PIXELS_IN_ONE_ROW-1;
|
|
||||||
ymax = MOENCH_PIXELS_IN_ONE_ROW-1;
|
|
||||||
}else{
|
|
||||||
if(shortFrame == -1){
|
|
||||||
xmax = GOTTHARD_PIXELS_IN_ROW-1;
|
|
||||||
ymax = GOTTHARD_PIXELS_IN_COL-1;
|
|
||||||
}else{
|
|
||||||
xmax = GOTTHARD_SHORT_PIXELS_IN_ROW-1;
|
|
||||||
ymax = GOTTHARD_SHORT_PIXELS_IN_COL-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while((1<<ithread)&writerthreads_mask){
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
cout << ithread << " gonna wait for 1st sem" << endl;
|
|
||||||
#endif
|
|
||||||
//wait
|
|
||||||
sem_wait(&writersmp[ithread]);
|
|
||||||
if(killAllWritingThreads){
|
|
||||||
cout << ithread << " good bye writing thread" << endl;
|
|
||||||
closeFile(ithread);
|
|
||||||
pthread_exit(NULL);
|
|
||||||
}
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
cout << ithread << " got 1st post" << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
if((1<<ithread)&createfile_mask){
|
|
||||||
if(dataCompression){
|
|
||||||
#ifdef MYROOT1
|
|
||||||
pthread_mutex_lock(&write_mutex);
|
|
||||||
ret = createCompressionFile(ithread,0);
|
|
||||||
pthread_mutex_unlock(&write_mutex);
|
|
||||||
if(ret == FAIL)
|
|
||||||
ret_createfile = FAIL;
|
|
||||||
#endif
|
|
||||||
}else{
|
|
||||||
ret = createNewFile();
|
|
||||||
if(ret == FAIL)
|
|
||||||
ret_createfile = FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//let tcp know
|
|
||||||
pthread_mutex_lock(&status_mutex);
|
|
||||||
createfile_mask^=(1<<ithread);
|
|
||||||
pthread_mutex_unlock(&status_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
cout << ithread << " gonna wait for 2nd sem" << endl;
|
|
||||||
#endif
|
|
||||||
//wait
|
|
||||||
sem_wait(&writersmp[ithread]);
|
|
||||||
if(killAllWritingThreads){
|
|
||||||
cout << ithread << " Goodbye thread" << endl;
|
|
||||||
closeFile(ithread);
|
|
||||||
pthread_exit(NULL);
|
|
||||||
}
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
cout << ithread << " got 2nd post" << endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@ -1626,34 +1462,8 @@ int UDPBaseImplementation::startWriting(){ FILE_LOG(logDEBUG) << __AT__ << " sta
|
|||||||
|
|
||||||
void UDPBaseImplementation::startFrameIndices(int ithread){ FILE_LOG(logDEBUG) << __AT__ << " starting";
|
void UDPBaseImplementation::startFrameIndices(int ithread){ FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||||
|
|
||||||
if (myDetectorType == EIGER)
|
|
||||||
//add currframenum later in this method for scans
|
|
||||||
startFrameIndex = htonl(*(unsigned int*)((eiger_image_header *)((char*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum);
|
|
||||||
//gotthard has +1 for frame number and not a short frame
|
|
||||||
else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
|
|
||||||
startFrameIndex = (((((uint32_t)(*((uint32_t*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS))))+1)
|
|
||||||
& (frameIndexMask)) >> frameIndexOffset);
|
|
||||||
else
|
|
||||||
startFrameIndex = ((((uint32_t)(*((uint32_t*)(buffer[ithread]+HEADER_SIZE_NUM_TOT_PACKETS))))
|
|
||||||
& (frameIndexMask)) >> frameIndexOffset);
|
|
||||||
|
|
||||||
|
|
||||||
//start of acquisition
|
|
||||||
if(!acqStarted){
|
|
||||||
startAcquisitionIndex=startFrameIndex;
|
|
||||||
currframenum = startAcquisitionIndex;
|
|
||||||
acqStarted = true;
|
|
||||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex<<endl;
|
|
||||||
}
|
|
||||||
//for scans, cuz currfraenum resets
|
|
||||||
else if (myDetectorType == EIGER)
|
|
||||||
startFrameIndex += currframenum;
|
|
||||||
|
|
||||||
|
|
||||||
cout << "startFrameIndex:" << startFrameIndex<<endl;
|
|
||||||
prevframenum=startFrameIndex;
|
|
||||||
measurementStarted = true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ UDPStandardImplementation::UDPStandardImplementation()
|
|||||||
guiFileName = NULL;
|
guiFileName = NULL;
|
||||||
guiFrameNumber = NULL;
|
guiFrameNumber = NULL;
|
||||||
tengigaEnable = 0;
|
tengigaEnable = 0;
|
||||||
|
footer_offset = 0;
|
||||||
for(int i=0;i<MAX_NUM_LISTENING_THREADS;i++){
|
for(int i=0;i<MAX_NUM_LISTENING_THREADS;i++){
|
||||||
udpSocket[i] = NULL;
|
udpSocket[i] = NULL;
|
||||||
server_port[i] = DEFAULT_UDP_PORTNO+i;
|
server_port[i] = DEFAULT_UDP_PORTNO+i;
|
||||||
@ -159,6 +160,7 @@ void UDPStandardImplementation::initializeMembers(){
|
|||||||
killAllWritingThreads = 0;
|
killAllWritingThreads = 0;
|
||||||
cbAction = DO_EVERYTHING;
|
cbAction = DO_EVERYTHING;
|
||||||
tengigaEnable = 0;
|
tengigaEnable = 0;
|
||||||
|
footer_offset = 0;
|
||||||
|
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
udpSocket[i] = NULL;
|
udpSocket[i] = NULL;
|
||||||
@ -332,6 +334,7 @@ int UDPStandardImplementation::setDetectorType(detectorType det){ FILE_LOG(logD
|
|||||||
frameIndexMask = EIGER_FRAME_INDEX_MASK;
|
frameIndexMask = EIGER_FRAME_INDEX_MASK;
|
||||||
frameIndexOffset = EIGER_FRAME_INDEX_OFFSET;
|
frameIndexOffset = EIGER_FRAME_INDEX_OFFSET;
|
||||||
packetIndexMask = EIGER_PACKET_INDEX_MASK;
|
packetIndexMask = EIGER_PACKET_INDEX_MASK;
|
||||||
|
footer_offset = EIGER_PACKET_HEADER_SIZE + oneDataSize;
|
||||||
|
|
||||||
pthread_mutex_lock(&status_mutex);
|
pthread_mutex_lock(&status_mutex);
|
||||||
listeningthreads_mask = 0x0;
|
listeningthreads_mask = 0x0;
|
||||||
@ -598,12 +601,14 @@ int32_t UDPStandardImplementation::setDynamicRange(int32_t dr){ FILE_LOG(logDEB
|
|||||||
if(!tengigaEnable){
|
if(!tengigaEnable){
|
||||||
packetsPerFrame = EIGER_ONE_GIGA_CONSTANT * dynamicRange * EIGER_MAX_PORTS;
|
packetsPerFrame = EIGER_ONE_GIGA_CONSTANT * dynamicRange * EIGER_MAX_PORTS;
|
||||||
onePacketSize = EIGER_ONE_GIGA_ONE_PACKET_SIZE;
|
onePacketSize = EIGER_ONE_GIGA_ONE_PACKET_SIZE;
|
||||||
|
oneDataSize = EIGER_ONE_GIGA_ONE_DATA_SIZE;
|
||||||
}else{
|
}else{
|
||||||
packetsPerFrame = EIGER_TEN_GIGA_CONSTANT * dynamicRange * EIGER_MAX_PORTS;
|
packetsPerFrame = EIGER_TEN_GIGA_CONSTANT * dynamicRange * EIGER_MAX_PORTS;
|
||||||
onePacketSize = EIGER_TEN_GIGA_ONE_PACKET_SIZE;
|
onePacketSize = EIGER_TEN_GIGA_ONE_PACKET_SIZE;
|
||||||
|
oneDataSize = EIGER_TEN_GIGA_ONE_DATA_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footer_offset = EIGER_PACKET_HEADER_SIZE + oneDataSize;
|
||||||
frameSize = onePacketSize * packetsPerFrame;
|
frameSize = onePacketSize * packetsPerFrame;
|
||||||
bufferSize = (frameSize/EIGER_MAX_PORTS) + EIGER_HEADER_LENGTH;//everything one port gets (img header plus packets)
|
bufferSize = (frameSize/EIGER_MAX_PORTS) + EIGER_HEADER_LENGTH;//everything one port gets (img header plus packets)
|
||||||
maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame;
|
maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame;
|
||||||
@ -1952,7 +1957,7 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
bool endofacquisition;
|
bool endofacquisition;
|
||||||
int numpackets[numListeningThreads], nf;
|
int numpackets[numListeningThreads], nf;
|
||||||
bool fullframe[numListeningThreads],popready[numListeningThreads];
|
bool fullframe[numListeningThreads],popready[numListeningThreads];
|
||||||
uint32_t tempframenum[numListeningThreads];
|
volatile uint32_t tempframenum[numListeningThreads];
|
||||||
uint32_t presentframenum;
|
uint32_t presentframenum;
|
||||||
uint32_t lastpacketheader[numListeningThreads], currentpacketheader[numListeningThreads];
|
uint32_t lastpacketheader[numListeningThreads], currentpacketheader[numListeningThreads];
|
||||||
int numberofmissingpackets[numListeningThreads];
|
int numberofmissingpackets[numListeningThreads];
|
||||||
@ -1972,15 +1977,27 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
|
|
||||||
|
|
||||||
int LAST_PACKET_VALUE;
|
int LAST_PACKET_VALUE;
|
||||||
|
|
||||||
|
eiger_packet_header_t* wbuf_header=0;
|
||||||
|
eiger_packet_footer_t* wbuf_footer=0;
|
||||||
|
|
||||||
|
eiger_packet_header_t* tempframe_header=0;
|
||||||
|
eiger_packet_footer_t* tempframe_footer=0;
|
||||||
|
|
||||||
|
eiger_packet_header_t* blankframe_header=0;
|
||||||
|
unsigned char* blankframe_data=0;
|
||||||
|
eiger_packet_footer_t* blankframe_footer=0;
|
||||||
|
|
||||||
//last packet numbers for different dynamic ranges
|
//last packet numbers for different dynamic ranges
|
||||||
if(myDetectorType == EIGER){
|
if(myDetectorType == EIGER){
|
||||||
switch(dynamicRange){
|
switch(dynamicRange){
|
||||||
case 4: LAST_PACKET_VALUE = 0x3f; break;
|
case 4: LAST_PACKET_VALUE = 0x40; break;
|
||||||
case 8: LAST_PACKET_VALUE = 0x7f; break;
|
case 8: LAST_PACKET_VALUE = 0x80; break;
|
||||||
case 16: LAST_PACKET_VALUE = 0xff; break;
|
case 16: LAST_PACKET_VALUE = 0x100; break;
|
||||||
case 32: LAST_PACKET_VALUE = 0xff; break;
|
case 32: LAST_PACKET_VALUE = 0x200; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2007,24 +2024,23 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
|
|
||||||
//blank frame
|
//blank frame
|
||||||
if(myDetectorType == EIGER){
|
if(myDetectorType == EIGER){
|
||||||
|
|
||||||
for(i=0;i<packetsPerFrame;++i){
|
for(i=0;i<packetsPerFrame;++i){
|
||||||
if(blankframe[i]){delete [] blankframe[i]; blankframe[i] = 0;}
|
if(blankframe[i]){delete [] blankframe[i]; blankframe[i] = 0;}
|
||||||
|
|
||||||
//blank frame for each packet
|
//blank frame for each packet
|
||||||
blankframe[i] = new char[onePacketSize];
|
blankframe[i] = new char[onePacketSize];
|
||||||
eiger_packet_header = (eiger_packet_header_t*) blankframe[i];
|
blankframe_header = (eiger_packet_header_t*) blankframe[i];
|
||||||
//set missing packet to 0xff
|
//set missing packet to 0xff
|
||||||
*( (uint16_t*) eiger_packet_header->missingpacket) = 0xFF;
|
*( (uint16_t*) blankframe_header->missingpacket) = missingPacketValue;
|
||||||
|
|
||||||
//set each value inside blank frame to 0xff
|
//set each value inside blank frame to 0xff
|
||||||
for(j=0;j<(oneDataSize);++j){
|
for(j=0;j<(oneDataSize);++j){
|
||||||
eiger_packet_data = blankframe[i] + sizeof(eiger_packet_header_t) + j;
|
blankframe_data = (unsigned char*)blankframe[i] + sizeof(eiger_packet_header_t) + j;
|
||||||
*(eiger_packet_data) = 0xFF;
|
*(blankframe_data) = 0xFF;
|
||||||
}
|
}
|
||||||
//verify
|
//verify
|
||||||
if (*( (uint16_t*) eiger_packet_header->missingpacket) != 0xFF){
|
if (*( (uint16_t*) blankframe_header->missingpacket) != missingPacketValue){
|
||||||
cprintf(RED,"blank frame not detected at %d: 0x%x\n",i,*( (uint16_t*) eiger_packet_header->missingpacket) );
|
cprintf(RED,"blank frame not detected at %d: 0x%x\n",i,*( (uint16_t*) blankframe_header->missingpacket) );
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
#ifdef FIFO_DEBUG
|
#ifdef FIFO_DEBUG
|
||||||
@ -2041,8 +2057,8 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
tempoffset[i] = (i*packetsPerFrame/numListeningThreads);
|
tempoffset[i] = (i*packetsPerFrame/numListeningThreads);
|
||||||
tofreeoffset[i] = (i*packetsPerFrame/numListeningThreads);
|
tofreeoffset[i] = (i*packetsPerFrame/numListeningThreads);
|
||||||
blankoffset = 0;
|
blankoffset = 0;
|
||||||
lastpacketheader[i] = -1;
|
lastpacketheader[i] = 0;
|
||||||
currentpacketheader[i] = -1;
|
currentpacketheader[i] = 0;
|
||||||
numberofmissingpackets[i] = 0;
|
numberofmissingpackets[i] = 0;
|
||||||
|
|
||||||
numpackets[i] = 0;
|
numpackets[i] = 0;
|
||||||
@ -2065,6 +2081,7 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
cprintf(GREEN,"%d writer poped 0x%x from fifo %d\n", ithread, (void*)(wbuf[i]), i);
|
cprintf(GREEN,"%d writer poped 0x%x from fifo %d\n", ithread, (void*)(wbuf[i]), i);
|
||||||
#endif
|
#endif
|
||||||
numpackets[i] = (uint32_t)(*((uint32_t*)wbuf[i]));
|
numpackets[i] = (uint32_t)(*((uint32_t*)wbuf[i]));
|
||||||
|
|
||||||
#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cprintf(GREEN,"%d numpackets: %d for fifo :%d\n", ithread, numpackets[i], i);
|
cprintf(GREEN,"%d numpackets: %d for fifo :%d\n", ithread, numpackets[i], i);
|
||||||
#endif
|
#endif
|
||||||
@ -2080,17 +2097,22 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
#endif
|
#endif
|
||||||
}else{
|
}else{
|
||||||
endofacquisition = false;
|
endofacquisition = false;
|
||||||
if(numpackets[i] == 1040){
|
if(numpackets[i] == 1040){;
|
||||||
cprintf(BLUE,"tempframenum[%d]:%d\n",i,((*(uint32_t*)(((eiger_packet_1g *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->framenum))));
|
#ifdef EIGER_DEBUG3
|
||||||
cprintf(BLUE,"packetnum[%d]:%d\n",i,((*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->packetnum))));
|
wbuf_footer = (eiger_packet_footer_t*)(wbuf[i] + footer_offset + HEADER_SIZE_NUM_TOT_PACKETS);
|
||||||
|
//cprintf(BLUE,"footer value:0x%x\n",i,(uint64_t)(*( (uint64_t*) wbuf_footer)));
|
||||||
|
cprintf(BLUE,"tempframenum[%d]:%d\n",i,(uint32_t)(*( (uint64_t*) wbuf_footer)));
|
||||||
|
cprintf(BLUE,"packetnum[%d]:%d\n",i,*( (uint16_t*) wbuf_footer->packetnum));
|
||||||
|
#endif
|
||||||
}else if(numpackets[i] == EIGER_HEADER_LENGTH){
|
}else if(numpackets[i] == EIGER_HEADER_LENGTH){
|
||||||
cprintf(BG_RED, "got header in writer, weirdd packetsize:%d\n",numpackets[i]);
|
cprintf(BG_RED, "got header in writer, weirdd packetsize:%d\n",numpackets[i]);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}else {
|
|
||||||
cprintf(BG_RED, "got weird in writer, weirdd packetsize:%d\n",numpackets[i]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//#ifdef EIGER_DEBUG3
|
||||||
|
else {
|
||||||
|
cprintf(BG_RED, "got weird in writer, weirdd packetsize:%d\n",numpackets[i]);
|
||||||
|
}
|
||||||
|
//#endif
|
||||||
if(myDetectorType == EIGER){
|
if(myDetectorType == EIGER){
|
||||||
tofree[tofreeoffset[i]] = wbuf[i];
|
tofree[tofreeoffset[i]] = wbuf[i];
|
||||||
tofreeoffset[i]++;
|
tofreeoffset[i]++;
|
||||||
@ -2104,9 +2126,9 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
|
|
||||||
//END OF ACQUISITION
|
//END OF ACQUISITION
|
||||||
if(endofacquisition){
|
if(endofacquisition){
|
||||||
//#ifdef VERYDEBUG
|
#ifdef EIGER_DEBUG3
|
||||||
cprintf(GREEN,"%d Both dummy frames\n", ithread);
|
cprintf(GREEN,"%d Both dummy frames\n", ithread);
|
||||||
//#endif
|
#endif
|
||||||
//remaining packets to be written
|
//remaining packets to be written
|
||||||
if((myDetectorType == EIGER) &&
|
if((myDetectorType == EIGER) &&
|
||||||
((tempoffset[0]!=0) || (tempoffset[1]!=(packetsPerFrame/numListeningThreads))));
|
((tempoffset[0]!=0) || (tempoffset[1]!=(packetsPerFrame/numListeningThreads))));
|
||||||
@ -2121,6 +2143,8 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
|
|
||||||
if(myDetectorType == EIGER){
|
if(myDetectorType == EIGER){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//NOT FULL FRAME
|
//NOT FULL FRAME
|
||||||
if(!fullframe[0] || !fullframe[1]){
|
if(!fullframe[0] || !fullframe[1]){
|
||||||
for(i=0;i<numListeningThreads;++i){
|
for(i=0;i<numListeningThreads;++i){
|
||||||
@ -2133,35 +2157,35 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
if(numpackets[i] == EIGER_HEADER_LENGTH) {cprintf(BG_RED,"weird, frame packet recieved\n"); exit(-1);}
|
if(numpackets[i] == EIGER_HEADER_LENGTH) {cprintf(BG_RED,"weird, frame packet recieved\n"); exit(-1);}
|
||||||
//dummy packet
|
//dummy packet
|
||||||
else if(!numpackets[i]){
|
else if(!numpackets[i]){
|
||||||
//#ifdef VERYDEBUG
|
#ifdef EIGER_DEBUG3
|
||||||
cprintf(RED, "Dummy packet: %d from fifo %d\n", numpackets[i],i);
|
cprintf(RED, "Dummy packet: %d from fifo %d\n", numpackets[i],i);
|
||||||
//#endif
|
#endif
|
||||||
cout<<"tempoffset["<<i<<"]:"<<tempoffset[i]<<" checking against:"<<(((i+1)*packetsPerFrame/numListeningThreads))<<endl;
|
cout<<"tempoffset["<<i<<"]:"<<tempoffset[i]<<" checking against:"<<(((i+1)*packetsPerFrame/numListeningThreads))<<endl;
|
||||||
//cannot check for full frame as it will be false if its done with all packets OR waiting for packets
|
//cannot check for full frame as it will be false if its done with all packets OR waiting for packets
|
||||||
if(tempoffset[i]!= (((i+1)*packetsPerFrame/numListeningThreads))){
|
if(tempoffset[i]!= (((i+1)*packetsPerFrame/numListeningThreads))){
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cprintf(RED, "Dummy packet: Adding missing packets\n");
|
cprintf(RED, "Dummy packet: Adding missing packets\n");
|
||||||
//#endif
|
#endif
|
||||||
//add missing packets
|
//add missing packets
|
||||||
numberofmissingpackets[i] = (LAST_PACKET_VALUE - lastpacketheader[i]);
|
numberofmissingpackets[i] = (LAST_PACKET_VALUE - lastpacketheader[i]);
|
||||||
//to decrement from packetsInFile to calculate packet loss
|
//to decrement from packetsInFile to calculate packet loss
|
||||||
for(j=0;j<numberofmissingpackets[i];++j){
|
for(j=0;j<numberofmissingpackets[i];++j){
|
||||||
tempbuffer[tempoffset[i]] = blankframe[blankoffset];
|
tempbuffer[tempoffset[i]] = blankframe[blankoffset];
|
||||||
#ifdef VERYDEBUG
|
|
||||||
if (*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket))
|
tempframe_header = (eiger_packet_header_t*) tempbuffer[tempoffset[i]];
|
||||||
cprintf(RED,"1 fifo:%d missing packet added at pnum:%d\n",i,tempoffset[i]);
|
blankframe_header = (eiger_packet_header_t*) blankframe[blankoffset];
|
||||||
else cprintf(RED, "1 fifo:%d Weird at pnum:%d\n",i,tempoffset[i]);
|
if (*( (uint16_t*) tempframe_header->missingpacket)!= missingPacketValue){
|
||||||
#endif
|
cprintf(BG_RED, "dummy blank mismatch num4 earlier2! "
|
||||||
if ((*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket))!= 0xFF){
|
"i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x\n",
|
||||||
cprintf(BG_RED, "dummy blank mismatch num4 earlier2! i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x\n",
|
|
||||||
i,tempoffset[i],tempframenum[i],
|
i,tempoffset[i],tempframenum[i],
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket)),
|
*( (uint16_t*) tempframe_header->missingpacket),
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(blankframe[blankoffset])))->missingpacket)));
|
*( (uint16_t*) blankframe_header->missingpacket));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}else
|
}else
|
||||||
//#ifdef PADDING
|
#ifdef PADDING
|
||||||
cprintf(GREEN, "blank packet i:%d pnum:%d fnum:%d missingpacket:0x%x\n",i,tempoffset[i],tempframenum[i],(*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket)));
|
cprintf(GREEN, "blank packet i:%d pnum:%d fnum:%d missingpacket:0x%x\n",i,
|
||||||
//#endif
|
tempoffset[i],tempframenum[i],*( (uint16_t*) tempframe_header->missingpacket));
|
||||||
|
#endif
|
||||||
tempoffset[i]++;
|
tempoffset[i]++;
|
||||||
blankoffset++;
|
blankoffset++;
|
||||||
}
|
}
|
||||||
@ -2184,9 +2208,12 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
|
|
||||||
//not a full frame
|
//not a full frame
|
||||||
if(!fullframe[i]){
|
if(!fullframe[i]){
|
||||||
|
wbuf_footer = (eiger_packet_footer_t*)(wbuf[i] + footer_offset + HEADER_SIZE_NUM_TOT_PACKETS);
|
||||||
|
#ifdef EIGER_DEBUG3
|
||||||
|
cprintf(GREEN,"**pnum of %d: %d\n",i,(*( (uint16_t*) wbuf_footer->packetnum)));
|
||||||
|
#endif
|
||||||
//update frame number
|
//update frame number
|
||||||
tempframenum[i] = ((*(uint32_t*)(((eiger_packet_1g *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->framenum)));
|
tempframenum[i] =(uint32_t)(*( (uint64_t*) wbuf_footer));
|
||||||
|
|
||||||
|
|
||||||
if(!tempframenum[i])
|
if(!tempframenum[i])
|
||||||
@ -2196,16 +2223,18 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
|
|
||||||
//WRONG FRAME - leave
|
//WRONG FRAME - leave
|
||||||
if(tempframenum[i] != presentframenum){
|
if(tempframenum[i] != presentframenum){
|
||||||
//#ifdef PADDING
|
#ifdef PADDING
|
||||||
cout<<"wrong packet"<<endl;
|
cout<<"wrong packet"<<endl;
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
//#ifdef EIGER_DEBUG3
|
#ifdef EIGER_DEBUG3
|
||||||
cprintf(RED,"fifo:%d packet from next frame %d, add missing packets to the right one %d\n",i,tempframenum[i],presentframenum );
|
cprintf(RED,"fifo:%d packet from next frame %d, add missing packets to the right one %d\n",
|
||||||
|
i,tempframenum[i],presentframenum );
|
||||||
cprintf(RED,"current wrong frame:%d wrong frame packet number:%d\n",
|
cprintf(RED,"current wrong frame:%d wrong frame packet number:%d\n",
|
||||||
((*(uint32_t*)(((eiger_packet_1g *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->framenum))),
|
(uint32_t)(*( (uint64_t*) wbuf_footer)),
|
||||||
((*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->packetnum))));
|
*( (uint16_t*) wbuf_footer->packetnum));
|
||||||
//#endif
|
|
||||||
|
#endif
|
||||||
tempframenum[i] = presentframenum;
|
tempframenum[i] = presentframenum;
|
||||||
//add missing packets
|
//add missing packets
|
||||||
numberofmissingpackets[i] = (LAST_PACKET_VALUE - lastpacketheader[i]);
|
numberofmissingpackets[i] = (LAST_PACKET_VALUE - lastpacketheader[i]);
|
||||||
@ -2216,26 +2245,24 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
//to decrement from packetsInFile to calculate packet loss
|
//to decrement from packetsInFile to calculate packet loss
|
||||||
for(j=0;j<numberofmissingpackets[i];++j){
|
for(j=0;j<numberofmissingpackets[i];++j){
|
||||||
tempbuffer[tempoffset[i]] = blankframe[blankoffset];
|
tempbuffer[tempoffset[i]] = blankframe[blankoffset];
|
||||||
#ifdef VERYDEBUG
|
|
||||||
if ((*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket))== 0xFF)
|
tempframe_header = (eiger_packet_header_t*) tempbuffer[tempoffset[i]];
|
||||||
cprintf(RED,"5 fifo:%d missing packet added at pnum:%d\n",i,tempoffset[i]);
|
blankframe_header = (eiger_packet_header_t*) blankframe[blankoffset];
|
||||||
else cprintf(RED, "5 fifo:%d WEird at pnum:%d\n",i,tempoffset[i]);
|
if (*( (uint16_t*) tempframe_header->missingpacket)!= missingPacketValue){
|
||||||
#endif
|
|
||||||
if ((*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket))!= 0xFF){
|
|
||||||
cprintf(BG_RED, "wrong blank mismatch num4 earlier2! "
|
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%x\n",
|
||||||
i,tempoffset[i],tempframenum[i],
|
i,tempoffset[i],tempframenum[i],
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket)),
|
*( (uint16_t*) tempframe_header->missingpacket),
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(blankframe[blankoffset])))->missingpacket)),
|
*( (uint16_t*) blankframe_header->missingpacket),
|
||||||
(void*)(tempbuffer[tempoffset[i]]));
|
(void*)(tempbuffer[tempoffset[i]]));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}else
|
}else
|
||||||
//#ifdef PADDING
|
#ifdef PADDING
|
||||||
cprintf(GREEN, "blank packet i:%d pnum:%d fnum:%d missingpacket:0x%x add:0x%x\n",
|
cprintf(GREEN, "blank packet i:%d pnum:%d fnum:%d missingpacket:0x%x add:0x%x\n",
|
||||||
i,tempoffset[i],tempframenum[i],
|
i,tempoffset[i],tempframenum[i],
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket)),
|
*( (uint16_t*) tempframe_header->missingpacket),
|
||||||
(void*)(tempbuffer[tempoffset[i]]));
|
(void*)(tempbuffer[tempoffset[i]]));
|
||||||
//#endif
|
#endif
|
||||||
tempoffset[i] ++;
|
tempoffset[i] ++;
|
||||||
blankoffset ++;
|
blankoffset ++;
|
||||||
}
|
}
|
||||||
@ -2247,73 +2274,75 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
|
|
||||||
//CORRECT FRAME - continue building frame
|
//CORRECT FRAME - continue building frame
|
||||||
else {
|
else {
|
||||||
//#ifdef PADDING
|
#ifdef PADDING
|
||||||
cout<<"correct packet"<<endl;
|
cout<<"correct packet"<<endl;
|
||||||
//#endif
|
#endif
|
||||||
//#ifdef EIGER_DEBUG3
|
#ifdef EIGER_DEBUG3
|
||||||
cprintf(GREEN,"**tempfraemnum of %d: %d\n",i,tempframenum[i]);
|
cprintf(GREEN,"**tempfraemnum of %d: %d\n",i,tempframenum[i]);
|
||||||
//#endif
|
#endif
|
||||||
//update current packet
|
//update current packet
|
||||||
currentpacketheader[i] = ((*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->packetnum)));
|
currentpacketheader[i] = *( (uint16_t*) wbuf_footer->packetnum);
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
cprintf(GREEN,"**fifo:%d currentpacketheader: %d lastpacketheader %d tempoffset:%d\n",i,currentpacketheader[i],lastpacketheader[i], tempoffset[i]);
|
cprintf(GREEN,"**fifo:%d currentpacketheader: %d lastpacketheader %d tempoffset:%d\n",
|
||||||
|
i,currentpacketheader[i],lastpacketheader[i], tempoffset[i]);
|
||||||
#endif
|
#endif
|
||||||
//add missing packets
|
//add missing packets
|
||||||
numberofmissingpackets[i] = (currentpacketheader[i] - lastpacketheader[i] -1);
|
numberofmissingpackets[i] = (currentpacketheader[i] - lastpacketheader[i] -1);
|
||||||
#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
if(numberofmissingpackets[i]>0)
|
if(numberofmissingpackets[i]>0)
|
||||||
cprintf(BG_RED,"fifo:%d missing packet from: %d now at :%d tempoffset:%d\n",i,lastpacketheader[i],currentpacketheader[i],tempoffset[i]);
|
cprintf(BG_RED,"fifo:%d missing packet from: %d now at :%d tempoffset:%d\n",
|
||||||
|
i,lastpacketheader[i],currentpacketheader[i],tempoffset[i]);
|
||||||
#endif
|
#endif
|
||||||
//to decrement from packetsInFile to calculate packet loss
|
//to decrement from packetsInFile to calculate packet loss
|
||||||
for(j=0;j<numberofmissingpackets[i];++j){
|
for(j=0;j<numberofmissingpackets[i];++j){
|
||||||
tempbuffer[tempoffset[i]] = blankframe[blankoffset];
|
tempbuffer[tempoffset[i]] = blankframe[blankoffset];
|
||||||
#ifdef VERYDEBUG
|
|
||||||
if ((*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket)) ==0xFF)
|
tempframe_header = (eiger_packet_header_t*) tempbuffer[tempoffset[i]];
|
||||||
cprintf(RED,"4 fifo:%d missing packet added at pnum:%d\n",i,tempoffset[i]);
|
blankframe_header = (eiger_packet_header_t*) blankframe[blankoffset];
|
||||||
else cprintf(RED, "4 fifo:%d WEird at pnum:%d\n",i,tempoffset[i]);
|
if (*( (uint16_t*) tempframe_header->missingpacket)!= missingPacketValue){
|
||||||
#endif
|
|
||||||
if ((*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket))!= 0xFF){
|
|
||||||
cprintf(BG_RED, "correct blank mismatch num4 earlier2! "
|
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%x\n",
|
||||||
i,tempoffset[i],tempframenum[i],
|
i,tempoffset[i],tempframenum[i],
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket)),
|
*( (uint16_t*) tempframe_header->missingpacket),
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(blankframe[blankoffset])))->missingpacket)),
|
*( (uint16_t*) blankframe_header->missingpacket),
|
||||||
(void*)(tempbuffer[tempoffset[i]]));
|
(void*)(tempbuffer[tempoffset[i]]));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}else
|
}else
|
||||||
//#ifdef PADDING
|
#ifdef PADDING
|
||||||
cprintf(GREEN, "blank packet i:%d pnum:%d fnum:%d missingpacket:0x%x add:0x%x\n",
|
cprintf(GREEN, "blank packet i:%d pnum:%d fnum:%d missingpacket:0x%x add:0x%x\n",
|
||||||
i,tempoffset[i],tempframenum[i],
|
i,tempoffset[i],tempframenum[i],
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket)),
|
*( (uint16_t*) tempframe_header->missingpacket),
|
||||||
(void*)(tempbuffer[tempoffset[i]]));
|
(void*)(tempbuffer[tempoffset[i]]));
|
||||||
//#endif
|
#endif
|
||||||
tempoffset[i] ++;
|
tempoffset[i] ++;
|
||||||
blankoffset ++;
|
blankoffset ++;
|
||||||
}
|
}
|
||||||
//add current packet
|
//add current packet
|
||||||
|
if(currentpacketheader[i] != (tempoffset[i]-(i*packetsPerFrame/numListeningThreads))+1){
|
||||||
if(currentpacketheader[i] != (tempoffset[i]-(i*packetsPerFrame/numListeningThreads))){
|
|
||||||
cprintf(BG_RED, "correct pnum mismatch earlier! tempoffset[%d]:%d pnum:%d fnum:%d rfnum:%d\n",
|
cprintf(BG_RED, "correct pnum mismatch earlier! tempoffset[%d]:%d pnum:%d fnum:%d rfnum:%d\n",
|
||||||
i,tempoffset[i],currentpacketheader[i],
|
i,tempoffset[i],currentpacketheader[i],
|
||||||
tempframenum[i],(*(uint32_t*)(((eiger_packet_1g *)((char*)(wbuf[i]+ HEADER_SIZE_NUM_TOT_PACKETS)))->framenum)));
|
tempframenum[i],(uint32_t)(*( (uint64_t*) wbuf_footer)));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
tempbuffer[tempoffset[i]] = wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS;
|
tempbuffer[tempoffset[i]] = wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS;
|
||||||
|
tempframe_footer = (eiger_packet_footer_t*) (tempbuffer[tempoffset[i]] + footer_offset);
|
||||||
#ifdef EIGER_DEBUG3
|
#ifdef EIGER_DEBUG3
|
||||||
cprintf(GREEN,"**fifo:%d currentpacketheader: %d tempoffset:%d\n",i,(*(uint16_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->packetnum)),tempoffset[i]);
|
cprintf(GREEN,"**fifo:%d currentpacketheader: %d tempoffset:%d\n",
|
||||||
|
i,*( (uint16_t*) tempframe_footer->packetnum),tempoffset[i]);
|
||||||
#endif
|
#endif
|
||||||
if((*(uint16_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->packetnum)) != (tempoffset[i]-(i*packetsPerFrame/numListeningThreads))){
|
if(*( (uint16_t*) tempframe_footer->packetnum)!= (tempoffset[i]-(i*packetsPerFrame/numListeningThreads))+1){
|
||||||
cprintf(BG_RED, "pnum mismatch num4 earlier! i:%d pnum:%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%x\n",
|
||||||
i,(*(uint16_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->packetnum)),
|
i,*( (uint16_t*) tempframe_footer->packetnum),*( (uint16_t*) wbuf_footer->packetnum),
|
||||||
tempframenum[i],(void*)(tempbuffer[tempoffset[i]]));
|
tempframenum[i],(void*)(tempbuffer[tempoffset[i]]));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
//#ifdef PADDING
|
#ifdef PADDING
|
||||||
cprintf(GREEN, "normal packet i:%d pnum:%d fnum:%d missingpacket:0x%x add:0x%x\n",
|
cprintf(GREEN, "normal packet i:%d pnum:%d fnum:%d missingpacket:0x%x add:0x%x\n",
|
||||||
i,tempoffset[i],tempframenum[i],
|
i,tempoffset[i],tempframenum[i],
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[tempoffset[i]])))->missingpacket)),
|
*( (uint16_t*) tempframe_footer->packetnum),
|
||||||
(void*)(tempbuffer[tempoffset[i]]));
|
(void*)(tempbuffer[tempoffset[i]]));
|
||||||
//#endif
|
#endif
|
||||||
tempoffset[i] ++;
|
tempoffset[i] ++;
|
||||||
//update last packet
|
//update last packet
|
||||||
lastpacketheader[i] = currentpacketheader[i];
|
lastpacketheader[i] = currentpacketheader[i];
|
||||||
@ -2343,10 +2372,10 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
numMissingPackets += (numberofmissingpackets[0]+numberofmissingpackets[1]);
|
numMissingPackets += (numberofmissingpackets[0]+numberofmissingpackets[1]);
|
||||||
numTotMissingPacketsInFile += numMissingPackets;
|
numTotMissingPacketsInFile += numMissingPackets;
|
||||||
numTotMissingPackets += numMissingPackets;
|
numTotMissingPackets += numMissingPackets;
|
||||||
//#ifdef EIGER_DEBUG2
|
#ifdef EIGER_DEBUG2
|
||||||
cprintf(GREEN,"**fnum:%d**\n",currframenum);
|
cprintf(GREEN,"**fnum:%d**\n",currframenum);
|
||||||
//#endif
|
#endif
|
||||||
//#ifdef EIGER_DEBUG3
|
#ifdef EIGER_DEBUG3
|
||||||
if(numberofmissingpackets[0])
|
if(numberofmissingpackets[0])
|
||||||
cprintf(RED, "fifo 0 missing packets:%d fnum:%d\n",numberofmissingpackets[0],currframenum);
|
cprintf(RED, "fifo 0 missing packets:%d fnum:%d\n",numberofmissingpackets[0],currframenum);
|
||||||
if(numberofmissingpackets[1])
|
if(numberofmissingpackets[1])
|
||||||
@ -2354,11 +2383,13 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
if(numMissingPackets){
|
if(numMissingPackets){
|
||||||
cprintf(RED, "numMissingPackets:%d fnum:%d\n",numMissingPackets,currframenum);
|
cprintf(RED, "numMissingPackets:%d fnum:%d\n",numMissingPackets,currframenum);
|
||||||
|
|
||||||
for (j=0;j<packetsPerFrame;++j)
|
for (j=0;j<packetsPerFrame;++j){
|
||||||
if ((*(uint8_t*)(((eiger_packet_1g *)((char*)(tempbuffer[j])))->missingpacket))==0xFF)
|
tempframe_header = (eiger_packet_header_t*) tempbuffer[j];
|
||||||
|
if (*( (uint16_t*) tempframe_header->missingpacket)==missingPacketValue)
|
||||||
cprintf(RED,"found the missing packet at pnum:%d\n",j);
|
cprintf(RED,"found the missing packet at pnum:%d\n",j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//write and copy to gui
|
//write and copy to gui
|
||||||
@ -2378,9 +2409,9 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
cprintf(GREEN,"%d writer freed pushed into fifofree %x for listener %d\n",ithread, (void*)(tofree[j]),1);
|
cprintf(GREEN,"%d writer freed pushed into fifofree %x for listener %d\n",ithread, (void*)(tofree[j]),1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cprintf(GREEN,"finished freeing\n");
|
cprintf(GREEN,"finished freeing\n");
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//reset a few stuff
|
//reset a few stuff
|
||||||
@ -2394,19 +2425,20 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
tempoffset[i] = (i*packetsPerFrame/numListeningThreads);
|
tempoffset[i] = (i*packetsPerFrame/numListeningThreads);
|
||||||
tofreeoffset[i] = (i*packetsPerFrame/numListeningThreads);
|
tofreeoffset[i] = (i*packetsPerFrame/numListeningThreads);
|
||||||
blankoffset = 0;
|
blankoffset = 0;
|
||||||
lastpacketheader[i] = -1;
|
lastpacketheader[i] = 0;
|
||||||
currentpacketheader[i] = -1;
|
currentpacketheader[i] = 0;
|
||||||
numberofmissingpackets[i] = 0;
|
numberofmissingpackets[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
|
wbuf_footer = (eiger_packet_footer_t*)(wbuf[i] + footer_offset + HEADER_SIZE_NUM_TOT_PACKETS);
|
||||||
cprintf(GREEN," end of loop popready[%d]:%d add:0x%x\n",i,popready[i],(void*)(wbuf[i]));
|
cprintf(GREEN," end of loop popready[%d]:%d add:0x%x\n",i,popready[i],(void*)(wbuf[i]));
|
||||||
cprintf(GREEN,"tempframenum[%d]:%d\n",i,((*(uint32_t*)(((eiger_packet_1g *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->framenum))));
|
cprintf(GREEN,"tempframenum[%d]:%d\n",i,(uint32_t)(*( (uint64_t*) wbuf_footer)));
|
||||||
cprintf(GREEN,"packetnum[%d]:%d\n",i,((*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->packetnum))));
|
cprintf(GREEN,"packetnum[%d]:%d\n",i,*( (uint16_t*) wbuf_footer->packetnum));
|
||||||
}
|
}
|
||||||
//#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2838,8 +2870,6 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char*
|
|||||||
int i,j, missingpacket,port = 0, pnuminc;
|
int i,j, missingpacket,port = 0, pnuminc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cbAction < DO_EVERYTHING){
|
if (cbAction < DO_EVERYTHING){
|
||||||
if (myDetectorType == EIGER){
|
if (myDetectorType == EIGER){
|
||||||
for(i=0;i<npackets;++i)
|
for(i=0;i<npackets;++i)
|
||||||
@ -2854,8 +2884,17 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char*
|
|||||||
#ifdef WRITE_HEADERS
|
#ifdef WRITE_HEADERS
|
||||||
if (myDetectorType == EIGER){
|
if (myDetectorType == EIGER){
|
||||||
|
|
||||||
|
eiger_packet_header_t* wbuf_header=0;
|
||||||
|
eiger_packet_footer_t* wbuf_footer=0;
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < packetsPerFrame; i++){
|
for (i = 0; i < packetsPerFrame; i++){
|
||||||
|
|
||||||
|
wbuf_header = (eiger_packet_header_t*) wbuffer[i];
|
||||||
|
wbuf_footer = (eiger_packet_footer_t*)(wbuffer[i] + footer_offset);
|
||||||
|
#ifdef EIGER_DEBUG3
|
||||||
|
cprintf(GREEN, "i:%d pnum:%d \n",i,*( (uint16_t*) wbuf_footer->packetnum));
|
||||||
|
#endif
|
||||||
//which port
|
//which port
|
||||||
if (i ==(packetsPerFrame/2))
|
if (i ==(packetsPerFrame/2))
|
||||||
port = 1;
|
port = 1;
|
||||||
@ -2863,77 +2902,51 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char*
|
|||||||
|
|
||||||
|
|
||||||
//missing packet
|
//missing packet
|
||||||
if ((*(uint8_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->missingpacket))==0xFF){
|
if (*( (uint16_t*) wbuf_header->missingpacket)== missingPacketValue){
|
||||||
|
#ifdef VERY_VERBOSE
|
||||||
|
cprintf(GREEN,"missing packet at %d\n", i+1);
|
||||||
|
#endif
|
||||||
missingpacket = 1;
|
missingpacket = 1;
|
||||||
//add packet numbers
|
//add frame and packet numbers
|
||||||
(*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum)) = (i+1);
|
*( (uint64_t*) wbuf_footer) = (uint64_t)((currframenum+1));
|
||||||
(*(uint32_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->framenum)) = currframenum+1;
|
*( (uint16_t*) wbuf_footer->packetnum) = (i+1);
|
||||||
}else{
|
}else{
|
||||||
missingpacket = 0;
|
missingpacket = 0;
|
||||||
|
|
||||||
if((*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum)) != (i-(port*packetsPerFrame/numListeningThreads))){
|
if(*( (uint16_t*) wbuf_footer->packetnum)!= (i-(port*packetsPerFrame/numListeningThreads))+1){
|
||||||
cprintf(BG_RED, "pnum mismatch num4! i:%d pnum:%d fnum:%d\n",i,(*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum)),currframenum);
|
cprintf(BG_RED, "pnum mismatch num4! i:%d pnum:%d fnum:%d\n",
|
||||||
|
i,*( (uint16_t*) wbuf_footer->packetnum),currframenum);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* if(dynamicRange != 32){*/
|
|
||||||
//move packet numbers to num2, and compensate for port1 starting pnum from 0
|
//move packet numbers to num2, and compensate for port1 starting pnum from 0
|
||||||
if(!port)
|
if(port)
|
||||||
(*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum)) =
|
*( (uint16_t*) wbuf_footer->packetnum) = (*( (uint16_t*) wbuf_footer->packetnum))+(packetsPerFrame/2);
|
||||||
((*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum))+1);
|
|
||||||
else
|
|
||||||
(*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum)) =
|
|
||||||
((*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum))+(packetsPerFrame/2) +1);
|
|
||||||
/*}
|
|
||||||
//dr == 32
|
|
||||||
else{
|
|
||||||
if(i == 0)
|
|
||||||
pnuminc = 0;
|
|
||||||
else if(i == (packetsPerFrame/4))
|
|
||||||
pnuminc = (packetsPerFrame/4);
|
|
||||||
else if(i == (packetsPerFrame/2))
|
|
||||||
pnuminc = (packetsPerFrame/2);
|
|
||||||
else if(i == (3*packetsPerFrame/4))
|
|
||||||
pnuminc = (3*packetsPerFrame/4);
|
|
||||||
(*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum))
|
|
||||||
= ((*(uint8_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum,))+pnuminc+1);
|
|
||||||
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(*( (uint16_t*) wbuf_footer->packetnum) != (i+1)){
|
||||||
if((*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum)) != (i+1)){
|
cprintf(BG_RED, "pnum mismatch! i:%d pnum:%d fnum:%d\n",
|
||||||
cprintf(BG_RED, "pnum mismatch! i:%d pnum:%d fnum:%d\n",i,(*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum)),currframenum);
|
i,*( (uint16_t*) wbuf_footer->packetnum),currframenum);
|
||||||
if ((*(uint8_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->missingpacket))==0xFF)
|
if (*( (uint16_t*) wbuf_header->missingpacket) == missingPacketValue)
|
||||||
cprintf(BG_RED,"missing packet though\n");
|
cprintf(BG_RED,"missing packet though\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//overwriting port number and dynamic range
|
//overwriting port number and dynamic range
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->missingpacket)) =
|
*( (uint8_t*) wbuf_header->portnum) = port;
|
||||||
((dynamicRange<<2)|(missingpacket<<1)|(port));
|
*( (uint8_t*) wbuf_header->dynamicrange) = dynamicRange;
|
||||||
|
|
||||||
|
|
||||||
//frame number
|
|
||||||
//(*(uint32_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->framenum)) = currframenum;
|
|
||||||
|
|
||||||
#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
if((i==0)||(i==1)){
|
if((i==0)||(i==1)){
|
||||||
cprintf(GREEN, "%d packet header:0x%016llx missingpacket:0x%x\n",i,
|
cprintf(GREEN, "%d packet header:0x%016llx missingpacket:0x%x\n",i,
|
||||||
((uint64_t)(*((uint64_t*)(wbuffer[i])))),
|
(uint64_t)()*( (uint64_t*) wbuf_header)), *( (uint16_t*) wbuf_header->missingpacket));
|
||||||
(uint8_t)(*(uint8_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->missingpacket)));
|
|
||||||
|
|
||||||
cprintf(GREEN, "%d - 0x%x - %d\n", i,
|
cprintf(GREEN, "%d - 0x%x - %d\n", i,
|
||||||
(*(uint8_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->missingpacket)),
|
*( (uint16_t*) wbuf_header->missingpacket), *( (uint16_t*) wbuf_footer->packetnum));
|
||||||
(*(uint16_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->packetnum)));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/*
|
|
||||||
cprintf(GREEN,"at writing, fnum:%d, pnum:%d,missingpacket:0x%x add:0x%x\n",
|
|
||||||
currframenum, i, (*(uint8_t*)(((eiger_packet_1g *)((char*)(wbuffer[i])))->missingpacket)),
|
|
||||||
(void*)(wbuffer[i]));
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user