diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index ba7c2ab64..8d4e58395 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -4681,8 +4681,7 @@ int slsDetector::configureMAC(int adc){ char arg[5][50]; char cword[50]="", *pcword; string sword; - int shortframe=1; - int retval=-100; + int retval=-1; if(((adc>=-1)&&(adc<=4))||(adc==-100)); else{ @@ -4811,11 +4810,10 @@ int slsDetector::configureMAC(int adc){ //connect to receiver if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ - if(retval==-1) shortframe=0; #ifdef VERBOSE - std::cout << "Sending shortframe to receiver " << shortframe << std::endl; + std::cout << "Sending adc val to receiver " << retval << std::endl; #endif - ret=thisReceiver->sendInt(fnum,retval,shortframe); + ret=thisReceiver->sendInt(fnum,retval,retval); if(ret==FAIL) setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); } diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp index 86a365075..dbd527a6c 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -393,11 +393,13 @@ void* postProcessing::processData(int delflag) { } //receiver else{ + /* while(1){ if (checkJoinThread()) break; usleep(200000); } - /* + */ + pthread_mutex_lock(&mg); int prevCaught=getReceiverCurrentFrameIndex(); pthread_mutex_unlock(&mg); @@ -446,7 +448,7 @@ void* postProcessing::processData(int delflag) { cout<<"****Detector returned mismatched indeices***"<isFull()) ;//cout<<"**********************FIFO FULLLLLLLL************************"<buffer=buffer; dataReadFrame->rc=rc; @@ -404,7 +406,7 @@ int slsReceiverFunctionList::startWriting(){ framesCaught++; totalFramesCaught++; memcpy(latestData,dataWriteFrame->buffer,bufferSize); - //cout<<"list write \t index:"<<(int)(*(int*)latestData)<buffer, 1, dataWriteFrame->rc, sfilefd); framesInFile++; @@ -444,7 +446,7 @@ char* slsReceiverFunctionList::readFrame(char* c){ int slsReceiverFunctionList::setShortFrame(int i){ shortFrame=i; - if(shortFrame){ + if(shortFrame!=-1){ bufferSize = SHORT_BUFFER_SIZE; maxFramesPerFile = SHORT_MAX_FRAMES; packetsPerFrame = 1; diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h index ecdbd7ff8..ffd561582 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h @@ -283,10 +283,6 @@ public: /** if the listening thread is running*/ static int listening_thread_running; }; -/* -//int setUDPPortNumber(int p=-1); //sets/gets port number to listen to for data from the detector -//int setTCPPortNumber(int p=-1); //sets/get port number for communication to client -*/ #endif diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp index f94b1ba71..456f06d35 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp @@ -23,7 +23,8 @@ slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int socket(mySocket), ret(OK), lockStatus(0), - shortFrame(0){ + shortFrame(-1), + packetsPerFrame(2){ int port_no = DEFAULT_PORTNO+2; ifstream infile; @@ -171,7 +172,7 @@ int slsReceiverFuncs::decode_function(){ #endif #ifdef VERBOSE - cout << "calling function fnum = "<< fnum << hex << flist[fnum] << endl; + cout << "calling function fnum = "<< fnum << hex << ":"<< flist[fnum] << endl; #endif if (fnum<0 || fnum>numberOfFunctions-1) @@ -649,26 +650,28 @@ int slsReceiverFuncs::reset_frames_caught(){ int slsReceiverFuncs::read_frame(){ ret=OK; char fName[MAX_STR_LENGTH]; - int arg = -1; + int arg = -1,i; + //retval is a full frame + int rnel = BUFFER_SIZE/(sizeof(int)); + int* retval = new int[rnel]; + //all initialized to 0 + for(i=0;ireadFrame(fName); index=(int)(*(int*)raw); - index2= (int)(*((int*)((char*)(raw+onebuffersize)))); memcpy(origVal,raw,bufferSize); raw=NULL; - //cout<<"funcs\tindex:"<readFrame(fName); + index=(int)(*(int*)raw); + index2= (int)(*((int*)((char*)(raw+onebuffersize)))); + memcpy(origVal,raw,bufferSize); + raw=NULL; + //cout<<"funcs\tindex:"<setShortFrame(index); shortFrame = retval; + if(shortFrame==-1) + packetsPerFrame=PACKETS_PER_FRAME; + else + packetsPerFrame=SHORT_PACKETS_PER_FRAME; } } #endif diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h index 37d3ebadf..5f02b1b6e 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h @@ -136,6 +136,9 @@ private: /** Short frame */ int shortFrame; + /** Packets per frame */ + int packetsPerFrame; + static int file_des; static int socketDescriptor;