From 40d0430f2e1b19cb0808211b9c3ca1d57d6d2aef Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 31 Jul 2020 12:02:12 +0200 Subject: [PATCH] get type from detector --- slsDetectorSoftware/src/Module.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index b002c4693..3b8e3e085 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -106,14 +106,11 @@ int64_t Module::getReceiverSoftwareVersion() const { // static function slsDetectorDefs::detectorType Module::getTypeFromDetector(const std::string &hostname, int cport) { - int fnum = F_GET_DETECTOR_TYPE; - int ret = FAIL; - detectorType retval = GENERIC; LOG(logDEBUG1) << "Getting detector type "; - sls::ClientSocket cs("Detector", hostname, cport); - cs.Send(reinterpret_cast(&fnum), sizeof(fnum)); - cs.Receive(reinterpret_cast(&ret), sizeof(ret)); - cs.Receive(reinterpret_cast(&retval), sizeof(retval)); + sls::ClientSocket socket("Detector", hostname, cport); + socket.Send(F_GET_DETECTOR_TYPE); + socket.Receive(); // TODO! Should we look at this OK/FAIL? + auto retval = socket.Receive(); LOG(logDEBUG1) << "Detector type is " << retval; return retval; } @@ -447,22 +444,17 @@ std::vector Module::getNumMissingPackets() const { // TODO!(Erik) Refactor LOG(logDEBUG1) << "Getting num missing packets"; if (shm()->useReceiverFlag) { - int fnum = F_GET_NUM_MISSING_PACKETS; - int ret = FAIL; auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort); - client.Send(&fnum, sizeof(fnum)); - client.Receive(&ret, sizeof(ret)); - if (ret == FAIL) { + client.Send(F_GET_NUM_MISSING_PACKETS); + if (client.Receive() == FAIL) { char mess[MAX_STR_LENGTH]{}; client.Receive(mess, MAX_STR_LENGTH); throw RuntimeError("Receiver " + std::to_string(moduleId) + " returned error: " + std::string(mess)); } else { - int nports = 0; - client.Receive(&nports, sizeof(nports)); + auto nports = client.Receive(); std::vector retval(nports); - client.Receive(retval.data(), - sizeof(retval[0]) * retval.size()); + client.Receive(retval); LOG(logDEBUG1) << "Missing packets of Receiver" << moduleId << ": " << sls::ToString(retval); return retval;