diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c index 348e62158..97884a9db 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c @@ -1813,35 +1813,114 @@ int allocateRAM() { } int prepareADC(){ - printf("Preparing ADC\n"); - u_int32_t valw,codata,csmask; - int i,cdx,ddx; - cdx=0; ddx=1; - csmask=0x7c; // 1111100 - - codata=0; - codata=(0x14<<8)+(0x0); //command and value; - valw=0xff; bus_w(ADC_WRITE_REG,(valw)); // start point - valw=((0xffffffff&(~csmask)));bus_w(ADC_WRITE_REG,valw); //chip sel bar down - for (i=0;i<24;i++) { - valw=valw&(~(0x1<>(23-i))&0x1)<>(23-i))&0x1)<>(23-i))&0x1)<>(23-i))&0x1)<>(23-i))&0x1)<setExposureTime(t); + return myDetector->setExposureTime((int64_t)t); else return ((1E-9) * (double)myDetector->setExposureTime(tms)); } double slsDetectorUsers::setExposurePeriod(double t, bool inseconds){ - int64_t tms = t * (1E+9); + int64_t tms = (int64_t)(t * (1E+9)); if (t < 0) tms = -1; if(!inseconds) - return myDetector->setExposurePeriod(t); + return myDetector->setExposurePeriod((int64_t)t); else return ((1E-9) * (double)myDetector->setExposurePeriod(tms)); } double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds){ - int64_t tms = t * (1E+9); + int64_t tms = (int64_t)(t * (1E+9)); if (t < 0) tms = -1; if(!inseconds) - return myDetector->setDelayAfterTrigger(t); + return myDetector->setDelayAfterTrigger((int64_t)t); else return ((1E-9) * (double)myDetector->setDelayAfterTrigger(tms)); } diff --git a/slsDetectorSoftware/slsReceiver/Makefile b/slsDetectorSoftware/slsReceiver/Makefile index 31680bb33..ac372b7b2 100644 --- a/slsDetectorSoftware/slsReceiver/Makefile +++ b/slsDetectorSoftware/slsReceiver/Makefile @@ -7,7 +7,7 @@ LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ LIBS?= -L$(LIBDIR) -lSlsDetector INCLUDES ?= -I ../MySocketTCP -I ../commonFiles -I -I ../slsDetectorAnalysis -I . -SRC_CLNT = slsReceiver.cpp +SRC_CLNT = slsReceiver.cpp #../MySocketTCP/MySocketTCP.cpp slsReceiver_funcs.cpp UHRIXCallback.cpp slsReceiverFunctionList.cpp slsReceiverUsers.cpp DESTDIR ?= bin diff --git a/slsDetectorSoftware/slsReceiver/receiver_defs.h b/slsDetectorSoftware/slsReceiver/receiver_defs.h index add44149e..8d57bd636 100755 --- a/slsDetectorSoftware/slsReceiver/receiver_defs.h +++ b/slsDetectorSoftware/slsReceiver/receiver_defs.h @@ -15,18 +15,24 @@ //all max frames defined in sls_detector_defs.h. 20000 gotthard, 100000 for short gotthard, 1000 for moench + #define GOTTHARD_FIFO_SIZE 25000 #define GOTTHARD_ALIGNED_FRAME_SIZE 4096 #define GOTTHARD_PACKETS_PER_FRAME 2 -#define GOTTHARD_BUFFER_SIZE (1286*GOTTHARD_PACKETS_PER_FRAME) -#define GOTTHARD_DATA_BYTES (1280*GOTTHARD_PACKETS_PER_FRAME) +#define GOTTHARD_ONE_PACKET_SIZE 1286 +#define GOTTHARD_BUFFER_SIZE (GOTTHARD_ONE_PACKET_SIZE*GOTTHARD_PACKETS_PER_FRAME) //1286*2 +#define GOTTHARD_DATA_BYTES (1280*GOTTHARD_PACKETS_PER_FRAME) //1280*2 #define GOTTHARD_SHORT_PACKETS_PER_FRAME 1 #define GOTTHARD_SHORT_BUFFER_SIZE 518 #define GOTTHARD_SHORT_DATABYTES 512 +#define GOTTHARD_SHORT_FRAME_INDEX_MASK 0xFFFFFFFF +#define GOTTHARD_SHORT_FRAME_INDEX_OFFSET 0 +#define GOTTHARD_SHORT_PACKET_INDEX_MASK 0 -#define GOTTHARD_FRAME_INDEX_MASK 0xFFFFFFFF -#define GOTTHARD_FRAME_INDEX_OFFSET 0 +#define GOTTHARD_FRAME_INDEX_MASK 0xFFFFFFFE +#define GOTTHARD_FRAME_INDEX_OFFSET 1 +#define GOTTHARD_PACKET_INDEX_MASK 0x1 @@ -34,8 +40,9 @@ #define MOENCH_FIFO_SIZE 2500 #define MOENCH_ALIGNED_FRAME_SIZE 65536 #define MOENCH_PACKETS_PER_FRAME 40 -#define MOENCH_BUFFER_SIZE (1286*MOENCH_PACKETS_PER_FRAME) -#define MOENCH_DATA_BYTES (1280*MOENCH_PACKETS_PER_FRAME) +#define MOENCH_ONE_PACKET_SIZE 1286 +#define MOENCH_BUFFER_SIZE (MOENCH_ONE_PACKET_SIZE*MOENCH_PACKETS_PER_FRAME) //1286*40 +#define MOENCH_DATA_BYTES (1280*MOENCH_PACKETS_PER_FRAME) //1280*40 #define MOENCH_BYTES_PER_ADC (40*2) #define MOENCH_PIXELS_IN_ONE_ROW 160 diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp index 6c19db0f9..3cb27f3f5 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp @@ -23,48 +23,49 @@ using namespace std; FILE* slsReceiverFunctionList::sfilefd(NULL); int slsReceiverFunctionList::receiver_threads_running(0); -slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwithGotthardTest): - myDetectorType(det), - maxFramesPerFile(MAX_FRAMES_PER_FILE), - enableFileWrite(1), - fileIndex(0), - frameIndexNeeded(0), - framesCaught(0), - acqStarted(false), - measurementStarted(false), - startFrameIndex(0), - frameIndex(0), - totalFramesCaught(0), - startAcquisitionIndex(0), - acquisitionIndex(0), - framesInFile(0), - prevframenum(0), - listening_thread_running(0), - writing_thread_running(0), - status(IDLE), - latestData(NULL), - udpSocket(NULL), - server_port(DEFAULT_UDP_PORTNO), - fifo(NULL), - fifofree(NULL), - fifosize(GOTTHARD_FIFO_SIZE), - shortFrame(-1), - bufferSize(GOTTHARD_BUFFER_SIZE), - packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME), - guiDataReady(0), - guiData(NULL), - guiFileName(NULL), - currframenum(0), - nFrameToGui(0), - startAcquisitionCallBack(NULL), - pStartAcquisition(NULL), - acquisitionFinishedCallBack(NULL), - pAcquisitionFinished(NULL), - rawDataReadyCallBack(NULL), - pRawDataReady(NULL), - withGotthard(moenchwithGotthardTest), - frameIndexMask(GOTTHARD_FRAME_INDEX_MASK), - frameIndexOffset(GOTTHARD_FRAME_INDEX_OFFSET) +slsReceiverFunctionList::slsReceiverFunctionList(detectorType det): + myDetectorType(det), + maxFramesPerFile(MAX_FRAMES_PER_FILE), + enableFileWrite(1), + fileIndex(0), + frameIndexNeeded(0), + framesCaught(0), + acqStarted(false), + measurementStarted(false), + startFrameIndex(0), + frameIndex(0), + totalFramesCaught(0), + startAcquisitionIndex(0), + acquisitionIndex(0), + packetsInFile(0), + prevframenum(0), + listening_thread_running(0), + writing_thread_running(0), + status(IDLE), + latestData(NULL), + udpSocket(NULL), + server_port(DEFAULT_UDP_PORTNO), + fifo(NULL), + fifofree(NULL), + fifosize(GOTTHARD_FIFO_SIZE), + shortFrame(-1), + bufferSize(GOTTHARD_BUFFER_SIZE), + packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME), + guiDataReady(0), + guiData(NULL), + guiFileName(NULL), + currframenum(0), + nFrameToGui(0), + frameIndexMask(GOTTHARD_FRAME_INDEX_MASK), + frameIndexOffset(GOTTHARD_FRAME_INDEX_OFFSET), + dataCompression(false), + startAcquisitionCallBack(NULL), + pStartAcquisition(NULL), + acquisitionFinishedCallBack(NULL), + pAcquisitionFinished(NULL), + rawDataReadyCallBack(NULL), + pRawDataReady(NULL) + { @@ -76,11 +77,8 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwit maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE; bufferSize = MOENCH_BUFFER_SIZE; packetsPerFrame = MOENCH_PACKETS_PER_FRAME; - if(!withGotthard){ - frameIndexMask = MOENCH_FRAME_INDEX_MASK; - frameIndexOffset = MOENCH_FRAME_INDEX_OFFSET; - } } + oneBufferSize = bufferSize/packetsPerFrame; strcpy(savefilename,""); strcpy(filePath,""); @@ -106,12 +104,105 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwit buffer+=aligned_frame_size; } - if(withGotthard) - cout << "Testing MOENCH Receiver with GOTTHARD Detector" << endl; + vector > map; + vector > mask; + int initial_offset = 4; + int later_offset = 2; + + int mask_y_offset = 120; + int mask_adc = 0x7fff; + int num_packets_in_col = 4; + int num_packets_in_row = 10; + int num_pixels_per_packet_in_row = 40; + int num_pixels_per_packet_in_col = 16; + int offset,ipacket; + + + int x; + int y; + int i, j; + + /** not for roi */ + //filter + switch(myDetectorType){ + case MOENCH: + x = MOENCH_PIXELS_IN_ONE_ROW; + y = MOENCH_PIXELS_IN_ONE_ROW; + mask.resize(x); + for(i=0;igetErrorStatus()){ #ifdef VERBOSE @@ -420,30 +514,43 @@ int slsReceiverFunctionList::startListening(){ break; } - + filter->setupAcquisitionParameters(); while (receiver_threads_running) { - pthread_mutex_lock(&status_mutex); - listening_thread_running = 1; - pthread_mutex_unlock(&(status_mutex)); + if(!listening_thread_running){ + pthread_mutex_lock(&status_mutex); + listening_thread_running = 1; + pthread_mutex_unlock(&(status_mutex)); + } if (!fifofree->isEmpty()) { - fifofree->pop(buffer); + if (ret!=0) + fifofree->pop(buffer); + if(ret == -2){ + memcpy(buffer,tempchar,oneBufferSize); + offset = oneBufferSize; + } //receiver 2 half frames / 1 short frame / 40 moench frames - rc = udpSocket->ReceiveDataOnly(buffer,bufferSize); - if( rc < 0) + rc = udpSocket->ReceiveDataOnly(buffer+offset,oneBufferSize); + if( rc <= 0){ +#ifdef VERYVERBOSE cerr << "recvfrom() failed" << endl; +#endif + continue; + } + if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) + (*((uint32_t*)(buffer+offset)))++; + + + ret = filter->verifyFrame(buffer+offset); + //start for each scan if(!measurementStarted){ - if(!frameIndexOffset) - startFrameIndex = ((uint32_t)(*((uint32_t*)buffer))); - else - startFrameIndex = ((((uint32_t)(*((uint32_t*)buffer))) & (frameIndexMask)) >> frameIndexOffset); - - cout<<"startFrameIndex:"<> frameIndexOffset); + cout<<"startFrameIndex:"<isFull()) - ;//cout<<"**********************FIFO FULLLLLLLL************************"<> frameIndexOffset; - fifo->push(buffer); - } - - - + if((receiver_threads_running) && (!fifo->isFull())){ + fifo->push(buffer); } + } } } while (receiver_threads_running); @@ -482,6 +612,7 @@ int slsReceiverFunctionList::startListening(){ //Close down any open socket descriptors udpSocket->Disconnect(); + delete tempchar; #ifdef VERBOSE cout << "receiver_threads_running:" << receiver_threads_running << endl; @@ -512,9 +643,10 @@ int slsReceiverFunctionList::startWriting(){ char *wbuf; int sleepnumber=0; int frameFactor=0; - int packetloss=0; + int i; +/*int i1,i2;*/ - framesInFile=0; + packetsInFile=0; framesCaught=0; frameIndex=0; if(sfilefd) sfilefd=NULL; @@ -546,11 +678,16 @@ int slsReceiverFunctionList::startWriting(){ cout << "Ready!" << endl; + + + if (dataCompression) + filter->enableFilter(true); + //will always run till acquisition over and then runs till fifo is empty while(receiver_threads_running || (!fifo->isEmpty())){ //start a new file - if ((framesInFile == maxFramesPerFile) || (strlen(savefilename) == 0)){ + if (((int)(packetsInFile/packetsPerFrame) >= maxFramesPerFile) || (strlen(savefilename) == 0)){ //create file name if(frameIndexNeeded==-1) sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex); @@ -558,6 +695,14 @@ int slsReceiverFunctionList::startWriting(){ if(enableFileWrite && cbAction > DO_NOTHING){ + //create tree and file + if(dataCompression){ + if(enableFileWrite){ + filter->writeToFile(); + filter->initTree(savefilename); + } + } + /*else{*///the standard way if(sfilefd){ fclose(sfilefd); sfilefd = NULL; @@ -570,24 +715,22 @@ int slsReceiverFunctionList::startWriting(){ pthread_mutex_unlock(&(status_mutex)); break; } - //setting buffer setvbuf(sfilefd,NULL,_IOFBF,BUF_SIZE); + /*}*/ //printing packet losses and file names //if(prevframenum != 0) if(!framesCaught) cout << savefilename << endl; else{ - if(!frameIndexOffset) - packetloss = (int)(((currframenum-prevframenum-(packetsPerFrame*framesInFile))/(double)(packetsPerFrame*framesInFile))*100.000); - else - packetloss = (int)(((currframenum-prevframenum-(framesInFile))/(double)(framesInFile))*100.000); cout << savefilename - << "\tpacket loss " << setw(4)<isEmpty()){ if(fifo->pop(wbuf)){ - framesCaught++; - totalFramesCaught++; - if(!frameIndexOffset) - currframenum = (uint32_t)(*((uint32_t*)wbuf)); - else - currframenum = (((uint32_t)(*((uint32_t*)wbuf))) & (frameIndexMask)) >> frameIndexOffset; - //cout<<"currframenum:"<>frameIndexOffset; + //cout<<"currframenum: "<> frameIndexOffset)<> frameIndexOffset)<> frameIndexOffset); + i2 = ((((uint32_t)(*((uint32_t*)(latestData+oneBufferSize)))) & (frameIndexMask)) >> frameIndexOffset); + if ( i1 == (i2+1)) + cout<<"222WEIRDDD:"<push(wbuf); + fifofree->push(wbuf); } } else{//cout<<"************************fifo empty**********************************"<> frameIndexOffset); + i2 = ((((uint32_t)(*((uint32_t*)(guiData+oneBufferSize)))) & (frameIndexMask)) >> frameIndexOffset); + if ( i1 == (i2+1)) + cout<<"WEIRDDD:"<getPacketsPerFrame() != packetsPerFrame){ + + vector > map; + vector > mask; + int initial_offset = 4; + int later_offset = 2; + int x,y,i,j,offset = 0; + + switch(packetsPerFrame){ + case GOTTHARD_SHORT_PACKETS_PER_FRAME://roi readout for gotthard + x = 1; + y = (GOTTHARD_DATA_BYTES/GOTTHARD_PACKETS_PER_FRAME)/2; + offset = initial_offset; + + mask.resize(x); + for(int i=0;i @@ -30,7 +31,7 @@ public: /** * Constructor */ - slsReceiverFunctionList(detectorType det, bool moenchwithGotthardTest); + slsReceiverFunctionList(detectorType det); /** * Destructor @@ -207,6 +208,12 @@ public: * when fifo is empty later, sets status to run_finished */ void startReadout(); + /** enabl data compression, by saving only hits */ + void enableDataCompression(bool enable){dataCompression = enable;}; + + /** get data compression, by saving only hits */ + bool getDataCompression(){ return dataCompression;}; + private: /** detector type */ @@ -257,8 +264,8 @@ private: /** Actual current frame index of an entire acquisition (including all scans) */ uint32_t acquisitionIndex; - /** Frames currently in current file, starts new file when it reaches max */ - uint32_t framesInFile; + /** Packets currently in current file, starts new file when it reaches max */ + uint32_t packetsInFile; /** Previous Frame number from buffer */ uint32_t prevframenum; @@ -338,6 +345,26 @@ private: /** send every nth frame to gui or only upon gui request*/ int nFrameToGui; + /** frame index mask */ + int frameIndexMask; + + /** frame index offset */ + int frameIndexOffset; + + /** datacompression - save only hits */ + bool dataCompression; + + /** single photon filter */ + singlePhotonFilter *filter; + + /** oen buffer size */ + int oneBufferSize; + + /** semaphore to synchronize writer and guireader threads */ + sem_t smp; + + /** guiDataReady mutex */ + pthread_mutex_t dataReadyMutex; /** callback arguments are @@ -381,21 +408,6 @@ private: * 2 we open, close, write file, callback does not do anything */ int cbAction; - /**temporary variable to test moench with gotthard module*/ - bool withGotthard; - - /** frame index mask */ - int frameIndexMask; - - /** frame index offset */ - int frameIndexOffset; - - /** semaphore to synchronize writer and guireader threads */ - sem_t smp; - - /** guiDataReady mutex */ - pthread_mutex_t dataReadyMutex; - public: /** File Descriptor */ diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp index c0d4410cf..dda104fe0 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp @@ -34,7 +34,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success): lockStatus(0), shortFrame(-1), packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME), - withGotthard(0), socket(NULL){ int port_no = DEFAULT_PORTNO+2; @@ -147,20 +146,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success): } } } - //test with gotthard module - else if(!strcasecmp(argv[iarg],"-test")){ - if(iarg+1==argc){ - cout << "no test condition given after -test in command line. Exiting." << endl; - success=FAIL; - }else{ - if(!strcasecmp(argv[iarg+1],"with_gotthard")) - withGotthard = 1; - else{ - cout << "could not decode test condition in command line. \nOptions are:\nwith_gotthard.\n\nExiting." << endl; - success=FAIL; - } - } - } //tcp port else if(!strcasecmp(argv[iarg],"-rx_tcpport")){ if(iarg+1==argc){ @@ -184,18 +169,10 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success): //display detector message switch(myDetectorType){ case GOTTHARD: - if(withGotthard){ - cout << "Option -test with_gotthard exists only for MOENCH detectors. Exiting" << endl; - exit(-1); - }else - cout << "This is a GOTTHARD Receiver" << endl; + cout << "This is a GOTTHARD Receiver" << endl; break; case MOENCH: - if(withGotthard) - cout << "This is a MOENCH Receiver using a GOTTHARD Detector." - "\nNote:Packet numbers are not matched for its corresponding frames." << endl; - else - cout << "This is a MOENCH Receiver" << endl; + cout << "This is a MOENCH Receiver" << endl; break; default: cout << "Unknown Receiver" << endl; @@ -218,7 +195,7 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success): strcpy(mess,"dummy message"); function_table(); - slsReceiverList = new slsReceiverFunctionList(myDetectorType,withGotthard); + slsReceiverList = new slsReceiverFunctionList(myDetectorType); #ifdef VERBOSE cout << "Function table assigned." << endl; @@ -933,7 +910,7 @@ int slsReceiverFuncs::read_frame(){ int slsReceiverFuncs::moench_read_frame(){ ret=OK; char fName[MAX_STR_LENGTH]=""; - int arg = -1,i,j,x,y; + int arg = -1,i; int bufferSize = MOENCH_BUFFER_SIZE; @@ -948,7 +925,6 @@ int slsReceiverFuncs::moench_read_frame(){ uint32_t startIndex=0; int index = 0; - int count=0; int offset=0; @@ -982,108 +958,63 @@ int slsReceiverFuncs::moench_read_frame(){ memcpy(origVal,raw,bufferSize); raw=NULL; - - //************** default order***************************** - if(withGotthard){ - count = 0; - offset = 4; - j=0; - for(x=0;x<(MOENCH_BYTES_IN_ONE_ROW/MOENCH_BYTES_PER_ADC);x++){ - for(y=0;y> MOENCH_FRAME_INDEX_OFFSET); - //cout<<"this frame number:"<> MOENCH_FRAME_INDEX_OFFSET); - uint32_t numPackets = MOENCH_PACKETS_PER_FRAME; //40 - uint32_t onePacketSize = MOENCH_DATA_BYTES / MOENCH_PACKETS_PER_FRAME; //1280*40 / 40 = 1280 - uint32_t packetDatabytes_row = onePacketSize * (MOENCH_BYTES_IN_ONE_ROW / MOENCH_BYTES_PER_ADC); //1280 * 4 = 5120 - uint32_t partsPerFrame = onePacketSize / MOENCH_BYTES_PER_ADC; // 1280 / 80 = 16 - uint32_t packetOffset = 0; - int packetIndex,x,y; - int iPacket = 0; - offset = 4; + uint32_t numPackets = MOENCH_PACKETS_PER_FRAME; //40 + uint32_t onePacketSize = MOENCH_DATA_BYTES / MOENCH_PACKETS_PER_FRAME; //1280*40 / 40 = 1280 + uint32_t packetDatabytes_row = onePacketSize * (MOENCH_BYTES_IN_ONE_ROW / MOENCH_BYTES_PER_ADC); //1280 * 4 = 5120 + uint32_t partsPerFrame = onePacketSize / MOENCH_BYTES_PER_ADC; // 1280 / 80 = 16 + uint32_t packetOffset = 0; + int packetIndex,x,y; + int iPacket = 0; + offset = 4; - while (iPacket < numPackets){ + while (iPacket < (int)numPackets){ #ifdef VERBOSE - printf("iPacket:%d\n",iPacket);cout << endl; + printf("iPacket:%d\n",iPacket);cout << endl; #endif - packetIndex = (*((uint32_t*)(((char*)origVal)+packetOffset))) & MOENCH_PACKET_INDEX_MASK; - //the first packet is placed in the end - packetIndex--; - if(packetIndex ==-1) - packetIndex = 39; + packetIndex = (*((uint32_t*)(((char*)origVal)+packetOffset))) & MOENCH_PACKET_INDEX_MASK; + //the first packet is placed in the end + packetIndex--; + if(packetIndex ==-1) + packetIndex = 39; - //check validity - if ((packetIndex >= 40) && (packetIndex < 0)) - cout << "cannot decode packet index:" << packetIndex << endl; - else{ + //check validity + if ((packetIndex >= 40) && (packetIndex < 0)) + cout << "cannot decode packet index:" << packetIndex << endl; + else{ - x = packetIndex / 10; - y = packetIndex % 10; + x = packetIndex / 10; + y = packetIndex % 10; #ifdef VERBOSE - cout<<"x:"<> MOENCH_FRAME_INDEX_OFFSET)<> MOENCH_FRAME_INDEX_OFFSET) != index){cout<<"did not match"<= numPackets) - break; - //increment - offset+=6; - iPacket++; - packetOffset = packetOffset + offset + onePacketSize; - }*/ } + + //increment + offset=6; + iPacket++; + packetOffset = packetOffset + offset + onePacketSize; + + //check if same frame number } + arg = index - startIndex; - if(withGotthard) - arg = arg/MOENCH_PACKETS_PER_FRAME; } - //******************************************************** } @@ -1152,8 +1083,9 @@ int slsReceiverFuncs::gotthard_read_frame(){ uint32_t index=0,index2=0; + uint32_t pindex=0,pindex2=0; + uint32_t bindex=0,bindex2=0; uint32_t startIndex=0; - int count=0; strcpy(mess,"Could not read frame\n"); @@ -1179,40 +1111,63 @@ int slsReceiverFuncs::gotthard_read_frame(){ cout<<"data not ready for gui yet"<> GOTTHARD_SHORT_FRAME_INDEX_OFFSET); #ifdef VERBOSE - cout<<"index:"<> GOTTHARD_FRAME_INDEX_OFFSET); + bindex2 = (uint32_t)(*((uint32_t*)((char*)(raw+onebuffersize)))); + pindex2 =(bindex2 & GOTTHARD_PACKET_INDEX_MASK); + index2 =((bindex2 & GOTTHARD_FRAME_INDEX_MASK) >> GOTTHARD_FRAME_INDEX_OFFSET); +#ifdef VERBOSE + cout<<"index1:"<