diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index b3e42951c..3801c90ce 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -5942,12 +5942,16 @@ void multiSlsDetector::readFrameFromReceiver(){ //all done if(!numRunning){ + // let main thread know that all dummy packets have been received (also from external process), + // main thread can now proceed to measurement finished call back + sem_post(&sem_endRTAcquisition); + // wait for next scan/measurement, else join thread sem_wait(&sem_newRTAcquisition); //done with complete acquisition if(checkJoinThread()) break; else{ - //starting a new scan/measurement + //starting a new scan/measurement (got dummy data) for(int i = 0; i < numSockets; ++i) runningList[i] = true; numRunning = numSockets; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index 406268656..2771c78a7 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -58,6 +58,8 @@ int slsDetectorUtils::acquire(int delflag){ //not in the loop for real time acqusition yet, //in the real time acquisition loop, processing thread will wait for a post each time sem_init(&sem_newRTAcquisition,1,0); + //in the real time acquistion loop, main thread will wait for processing thread to be done each time (which in turn waits for receiver/ext process) + sem_init(&sem_endRTAcquisition,1,0); bool receiver = (setReceiverOnline()==ONLINE_FLAG); @@ -351,6 +353,11 @@ int slsDetectorUtils::acquire(int delflag){ else{ if (stopReceiver() == FAIL) *stoppedFlag = 1; + else { + if (*threadedProcessing && dataReady) // threaded processing + sem_wait(&sem_endRTAcquisition); // waits for receiver's external process to be done sending data to gui + } + // cout<<"***********receiver stopped"<