diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index aa8c12d55..a2fcf0200 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -4573,7 +4573,7 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){ int n,complete=OK; int i,k,offsetX, offsetY, maxX, maxY; double dr; int* retval=new int[nel]; - int *retdet, *p=retval; + int *retdet = NULL, *p=retval; string fullFName=""; string ext=""; @@ -4585,22 +4585,21 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){ for (int id=0; idnumberOfDetectors; id++) { if (detectors[id]) { + n=detectors[id]->getDataBytes(); retdet=detectors[id]->readFrameFromReceiver(fName,fIndex); if(detectors[id]->getErrorMask()) setErrorMask(getErrorMask()|(1<getDataBytes(); if(getDetectorsType() == EIGER){ - //cout << "fname:"<getMaxNumberOfChannels()<<" n:"<getMaxNumberOfChannels()<<" n:"<getMaxNumberOfChannels(); - //cout << "dr:"<getMaxNumberOfChannels(X)*dr);//bit mode - //cout << "k:"<offsetY[id] + detectors[id]->getMaxNumberOfChannels(Y))) * maxX)*dr);//bit mode offsetX = (int)(thisMultiDetector->offsetX[id]*dr); //cout << "offsetY"< using namespace std; +int dummyCallback(detectorData* d, int p,void*) { +cout << "got data " << p << endl; +} class multiSlsDetectorClient { @@ -21,6 +24,7 @@ class multiSlsDetectorClient { if (argc==0 && action==slsDetectorDefs::READOUT_ACTION) { \ if (myDetector==NULL) { \ myDetector=new multiSlsDetector(); \ + //myDetector->registerDataCallback(&dummyCallback, NULL); del=1; \ }; myCmd=new multiSlsDetectorCommand(myDetector); \ diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 8c861e61c..1d466c765 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -6461,34 +6461,31 @@ int* slsDetector::readFrameFromReceiver(char* fName, int &fIndex){ std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes << " " <stoppedFlag){ - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - n= dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned: " << mess << " " << n << std::endl; + if (ret==FAIL) { + n= dataSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned: " << mess << " " << n << std::endl; + delete [] retval; + dataSocket->Disconnect(); + return NULL; + } else { + n=dataSocket->ReceiveDataOnly(fName,MAX_STR_LENGTH); + n=dataSocket->ReceiveDataOnly(&fIndex,sizeof(fIndex)); + n=dataSocket->ReceiveDataOnly(retval,thisDetector->dataBytes); + +#ifdef VERBOSE + std::cout<< "Received "<< n << " data bytes" << std::endl; +#endif + if (n!=thisDetector->dataBytes) { + std::cout<dataBytes << std::endl; + ret=FAIL; delete [] retval; dataSocket->Disconnect(); return NULL; - } else { - n=dataSocket->ReceiveDataOnly(fName,MAX_STR_LENGTH); - n=dataSocket->ReceiveDataOnly(&fIndex,sizeof(fIndex)); - n=dataSocket->ReceiveDataOnly(retval,thisDetector->dataBytes); - -#ifdef VERBOSE - std::cout<< "Received "<< n << " data bytes" << std::endl; -#endif - if (n!=thisDetector->dataBytes) { - std::cout<dataBytes << std::endl; - ret=FAIL; - delete [] retval; - dataSocket->Disconnect(); - return NULL; - } } - //} - + } dataSocket->Disconnect(); } } diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp index 1ca44fb1e..b2854f4bd 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -475,10 +475,10 @@ void* postProcessing::processData(int delflag) { } if (fdata) { - cout << "delete fdata "<< endl; + //cout << "delete fdata "<< endl; delete [] fdata; - - cout << "delete done "<< endl; + fdata = NULL; + //cout << "delete done "<< endl; } } //receiver @@ -535,6 +535,8 @@ void* postProcessing::processData(int delflag) { #ifdef VERY_VERY_DEBUG cout << "currentfIndex:" << currentfIndex << endl; #endif + + /** IF detector acquisition is done, let the acquire() thread know to finish up and force join thread */ if(acquiringDone > 0){ #ifdef VERY_VERY_DEBUG @@ -579,6 +581,7 @@ void* postProcessing::processData(int delflag) { //get data strcpy(currentfName,""); pthread_mutex_lock(&mg); + //int* receiverData = new int [getTotalNumberOfChannels()]; int* receiverData = readFrameFromReceiver(currentfName,currentfIndex); pthread_mutex_unlock(&mg); @@ -599,7 +602,13 @@ void* postProcessing::processData(int delflag) { }*/ //not garbage frame - if (currentfIndex >= 0) { + if(currentfIndex < 0){ +#ifdef VERY_VERY_DEBUG + cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<