From c9215a6d9be6f18de39e56ecd1740ef5afa3ec01 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil <33750417+thattil@users.noreply.github.com> Date: Mon, 20 Mar 2023 10:31:27 +0100 Subject: [PATCH] fix old server version in 64 bits (#697) * check server version before initial checks, catch old server version exception, get old server version as 64 bit and print it alon gwith exception --- RELEASE.txt | 1 + slsDetectorSoftware/src/Module.cpp | 27 +++++++++++++++++++++++---- slsDetectorSoftware/src/Module.h | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/RELEASE.txt b/RELEASE.txt index 191012b66..d8102209a 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -33,6 +33,7 @@ This document describes the differences between v7.x.x and v7.0.0 - eiger hardware version fx30 and fx70 (versions command) - fixed rx_arping error - fix hdf5 compilation (detspec fields) +- print server version atleast in exception msg when connecting to an older server, also able to add hostname to shm diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 9039c0608..50cd6b2bc 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -73,8 +73,8 @@ void Module::setHostname(const std::string &hostname, auto client = DetectorSocket(shm()->hostname, shm()->controlPort); client.close(); try { - initialDetectorServerChecks(); checkDetectorVersionCompatibility(); + initialDetectorServerChecks(); LOG(logINFO) << "Module Version Compatibility - Success"; } catch (const RuntimeError &e) { if (!initialChecks) { @@ -99,9 +99,28 @@ Module::getFrontEndFirmwareVersion(const fpgaPosition fpgaPosition) const { } std::string Module::getControlServerLongVersion() const { - char retval[MAX_STR_LENGTH]{}; - sendToDetector(F_GET_SERVER_VERSION, nullptr, retval); - return retval; + try { + char retval[MAX_STR_LENGTH]{}; + sendToDetector(F_GET_SERVER_VERSION, nullptr, retval); + return retval; + } + // throw with old server version (sends 8 bytes) + catch (RuntimeError &e) { + std::string emsg = std::string(e.what()); + if (emsg.find(F_GET_SERVER_VERSION) && emsg.find("8 bytes")) { + throwDeprecatedServerVersion(); + } + throw; + } +} + +void Module::throwDeprecatedServerVersion() const { + uint64_t res = sendToDetectorStop(F_GET_SERVER_VERSION); + std::cout << std::endl; + std::ostringstream os; + os << "Detector Server (Control) version (0x" << std::hex << res + << ") is incompatible with this client. Please update detector server!"; + throw RuntimeError(os.str()); } std::string Module::getStopServerLongVersion() const { diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 432a9336b..28dbc4639 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -93,6 +93,7 @@ class Module : public virtual slsDetectorDefs { int64_t getFrontEndFirmwareVersion(const fpgaPosition fpgaPosition) const; std::string getControlServerLongVersion() const; std::string getStopServerLongVersion() const; + void throwDeprecatedServerVersion() const; std::string getDetectorServerVersion() const; std::string getHardwareVersion() const; std::string getKernelVersion() const;