From afabc9a5030731aeea54667dd7e174e63e512911 Mon Sep 17 00:00:00 2001 From: Anna Bergamaschi Date: Tue, 18 Aug 2020 10:56:21 +0200 Subject: [PATCH] Fixed file cluster closing and cprintf warning in moenchZmqProcess --- .../moenchExecutables/moenchZmqProcess.cpp | 7 ++++--- slsDetectorCalibration/singlePhotonDetector.h | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp index 45d5ed86f..12e92586f 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp @@ -241,7 +241,7 @@ int main(int argc, char *argv[]) { #endif if (zmqsocket->Connect()) { cprintf(RED, "Error: Could not connect to socket %s\n", - zmqsocket->GetZmqServerAddress()); + (zmqsocket->GetZmqServerAddress()).c_str()); delete zmqsocket; return EXIT_FAILURE; } else @@ -281,12 +281,12 @@ int main(int argc, char *argv[]) { #endif if (zmqsocket2->Connect()) { cprintf(RED, "BBB Error: Could not connect to socket %s\n", - zmqsocket2->GetZmqServerAddress()); + zmqsocket2->GetZmqServerAddress().c_str()); // delete zmqsocket2; send = false; // return EXIT_FAILURE; } else - printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress()); + printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress().c_str()); } @@ -388,6 +388,7 @@ int main(int argc, char *argv[]) { while (mt->isBusy()) {;}//wait until all data are processed from the queues if (of) { + mt->setFilePointer(NULL); fclose(of); of=NULL; } diff --git a/slsDetectorCalibration/singlePhotonDetector.h b/slsDetectorCalibration/singlePhotonDetector.h index 5a30341f4..09c2333db 100644 --- a/slsDetectorCalibration/singlePhotonDetector.h +++ b/slsDetectorCalibration/singlePhotonDetector.h @@ -602,12 +602,14 @@ int *getClusters(char *data, int *ph=NULL) { */ static void writeClusters(FILE *f, single_photon_hit *cl, int nph, int fn=0){ - if (nph>0) { + if (f) { + if (nph>0) { #ifndef OLDFORMAT - if (fwrite((void*)&fn, 1, sizeof(int), f)) - if (fwrite((void*)&nph, 1, sizeof(int), f)) + if (fwrite((void*)&fn, 1, sizeof(int), f)) + if (fwrite((void*)&nph, 1, sizeof(int), f)) #endif - for (int i=0; iwrite(f); + for (int i=0; iwrite(f); + } } };