diff --git a/RELEASE.txt b/RELEASE.txt index b8cb9459b..e0f1d3af7 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -19,7 +19,7 @@ This document describes the differences between vx.x.x and v6.0.0. 1. New or Changed Features ========================== - +- kernelversion diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 5fbc7f8dd..4406f53b1 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -224,6 +224,19 @@ class Detector(CppDetectorApi): """ return ut.lhex(self.getDetectorServerVersion()) + @property + @element + def kernelversion(self): + """ + Kernel version on the detector including time and date + + Example + ------- + >>> d.kernelversion + '#37 PREEMPT Thu Oct 13 14:51:04 CEST 2016' + """ + return self.getKernelVersion() + @property def clientversion(self): """Client software version in format [YYMMDD] @@ -1656,6 +1669,7 @@ class Detector(CppDetectorApi): 'client': self.clientversion, 'firmware': self.firmwareversion, 'detectorserver': self.detectorserverversion, + 'kernel': self.kernelversion, 'receiver': self.rx_version} @property diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 22fc4795e..c25c807de 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -67,6 +67,10 @@ void init_det(py::module &m) { (Result(Detector::*)(sls::Positions) const) & Detector::getDetectorServerVersion, py::arg() = Positions{}) + .def("getKernelVersion", + (Result(Detector::*)(sls::Positions) const) & + Detector::getKernelVersion, + py::arg() = Positions{}) .def("getSerialNumber", (Result(Detector::*)(sls::Positions) const) & Detector::getSerialNumber, diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 5650deb8a..ff837951b 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index 1289163e5..81ba10521 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 7d8bdb5ba..b28dac471 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -101,7 +101,7 @@ void basictests() { } // does check only if flag is 0 (by default), set by command line if ((!debugflag) && (!updateFlag) && - ((checkKernelVersion() == FAIL) || (checkType() == FAIL) || + ((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || (checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { sprintf(initErrorMessage, "Could not pass basic tests of FPGA and bus. Dangerous to " @@ -184,15 +184,6 @@ void basictests() { #endif } -int checkKernelVersion() { -#ifdef VIRTUAL - return OK; -#endif - char buf[255] = {0}; - strcpy(buf, KERNEL_DATE_VRSN); - return validateKernelVersion(buf); -} - int checkType() { #ifdef VIRTUAL return OK; diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index e7b3ee9e5..01bb4a918 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 2b0824c45..e2cf6aab3 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index 34e4abcec..ef970aebf 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index a219abecd..56fe9bd17 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 516d8ddc6..e536e4b58 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -96,7 +96,7 @@ void basictests() { } // does check only if flag is 0 (by default), set by command line if ((!debugflag) && (!updateFlag) && - ((checkKernelVersion() == FAIL) || (checkType() == FAIL) || + ((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || (checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. " "Dangerous to continue.\n"); @@ -177,15 +177,6 @@ void basictests() { #endif } -int checkKernelVersion() { -#ifdef VIRTUAL - return OK; -#endif - char buf[255] = {0}; - strcpy(buf, KERNEL_DATE_VRSN); - return validateKernelVersion(buf); -} - int checkType() { #ifdef VIRTUAL return OK; diff --git a/slsDetectorServers/slsDetectorServer/include/common.h b/slsDetectorServers/slsDetectorServer/include/common.h index 0435c7df2..7cfbf007a 100644 --- a/slsDetectorServers/slsDetectorServer/include/common.h +++ b/slsDetectorServers/slsDetectorServer/include/common.h @@ -28,6 +28,8 @@ int getAbsPath(char *buf, size_t bufSize, char *fname); int getTimeFromString(char *buf, time_t *result); +int getKernelVersion(char* retvals); + int validateKernelVersion(char *expectedVersion); void validate(int *ret, char *mess, int arg, int retval, char *modename, diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index c17522c9c..a8854e8ca 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -60,9 +60,7 @@ typedef struct udpStruct_s { int isInitCheckDone(); int getInitResult(char **mess); void basictests(); -#if defined(MYTHEN3D) || defined(GOTTHARD2D) -int checkKernelVersion(); -#endif +int getKernelVersion(char* retvals); #if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \ defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D) int checkType(); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 06c0431a3..a6026dd72 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -276,4 +276,5 @@ int clear_all_udp_dst(int); int get_udp_first_dest(int); int set_udp_first_dest(int); int get_readout_speed(int); -int set_readout_speed(int); \ No newline at end of file +int set_readout_speed(int); +int get_kernel_version(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/common.c b/slsDetectorServers/slsDetectorServer/src/common.c index b00dcb330..89bfa0814 100644 --- a/slsDetectorServers/slsDetectorServer/src/common.c +++ b/slsDetectorServers/slsDetectorServer/src/common.c @@ -96,28 +96,44 @@ int getTimeFromString(char *buf, time_t *result) { return OK; } -int validateKernelVersion(char *expectedVersion) { - // extract kernel date string +int getKernelVersion(char* retvals) { struct utsname buf = {0}; if (uname(&buf) == -1) { - LOG(logERROR, ("Could not get kernel version\n")); + strcpy(retvals, "Failed to get utsname structure from uname\n"); + LOG(logERROR, (retvals)); + return FAIL; + } + strcpy(retvals, buf.version); + LOG(logINFOBLUE, ("Kernel Version: %s\n", retvals)); + return OK; +} + +int validateKernelVersion(char *expectedVersion) { + // extract kernel date string + char version[255] = {0}; + if (getKernelVersion(version) == FAIL) { + LOG(logERROR, ("Could not validate kernel version\n")); return FAIL; } + LOG(logDEBUG, ("utsname.version:%s\n", version)); + char currentVersion[255] = {0}; +#ifdef VIRTUAL + strcpy(currentVersion, expectedVersion); +#else // remove first word (#version number) - const char *ptr = strchr(buf.version, ' '); + const char *ptr = strchr(version, ' '); if (ptr == NULL) { LOG(logERROR, ("Could not parse kernel version\n")); return FAIL; } - char output[255]; - memset(output, 0, sizeof(output)); - strcpy(output, buf.version + (ptr - buf.version + 1)); + strcpy(currentVersion, version + (ptr - version + 1)); +#endif // convert kernel date string into time time_t kernelDate; - if (getTimeFromString(output, &kernelDate) == FAIL) { - LOG(logERROR, ("Could not parse retrieved kernel date, %s\n", output)); + if (getTimeFromString(currentVersion, &kernelDate) == FAIL) { + LOG(logERROR, ("Could not parse retrieved kernel date, %s\n", currentVersion)); return FAIL; } @@ -133,11 +149,11 @@ int validateKernelVersion(char *expectedVersion) { if (kernelDate < expDate) { LOG(logERROR, ("Kernel Version Incompatible (too old)! Expected: [%s], " "Got [%s]\n", - expectedVersion, output)); + expectedVersion, currentVersion)); return FAIL; } - LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n", output, + LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n", currentVersion, expectedVersion)); return OK; } diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c index 7b633e4d1..0b8ada232 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c @@ -193,7 +193,7 @@ int main(int argc, char *argv[]) { memset(portCmd, 0, 256); sprintf(portCmd, "-p%d", portno); for (int i = 0; i < argc; ++i) { - LOG(logINFOBLUE, ("i:%d argv[i]:%s\n", i, argv[i])); + LOG(logDEBUG, ("i:%d argv[i]:%s\n", i, argv[i])); // remove port argument (--port) and [value] if (!strcasecmp(argv[i], "--port")) { ++i; diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 2d2ea2831..086e6380e 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -414,6 +414,8 @@ void function_table() { flist[F_SET_UDP_FIRST_DEST] = &set_udp_first_dest; flist[F_GET_READOUT_SPEED] = &get_readout_speed; flist[F_SET_READOUT_SPEED] = &set_readout_speed; + flist[F_GET_KERNEL_VERSION] = &get_kernel_version; + // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { LOG(logERROR, ("The last detector function enum has reached its " @@ -9411,4 +9413,24 @@ int set_readout_speed(int file_des) { } #endif return Server_SendResult(file_des, INT32, NULL, 0); -} \ No newline at end of file +} + +int get_kernel_version(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + char retvals[MAX_STR_LENGTH]; + memset(retvals, 0, MAX_STR_LENGTH); + + LOG(logDEBUG1, ("Getting kernel version\n")); + + // get only + ret = getKernelVersion(retvals); + if (ret == FAIL) { + snprintf(mess, MAX_STR_LENGTH, + "Could not get kernel version. %s\n", retvals); + LOG(logERROR, (mess)); + } else { + LOG(logDEBUG1, ("kernel version: [%s]\n", retvals)); + } + return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals)); +} diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index d07c41b24..451038412 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -81,6 +81,8 @@ class Detector { Result getDetectorServerVersion(Positions pos = {}) const; + Result getKernelVersion(Positions pos = {}) const; + /* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */ Result getSerialNumber(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index c19eb3913..5ecf8f281 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -275,7 +275,7 @@ std::string CmdProxy::Versions(int action) { if (!args.empty()) { WrongNumberOfParameters(0); } - auto t = det->getFirmwareVersion(); + auto t = det->getFirmwareVersion(std::vector{det_id}); os << "\nDetector Type: " << OutString(det->getDetectorType()) << "\nPackage Version: " << det->getPackageVersion() << std::hex << "\nClient Version: 0x" << det->getClientVersion(); @@ -285,10 +285,12 @@ std::string CmdProxy::Versions(int action) { os << "\nFirmware Version: " << OutStringHex(t); } os << "\nDetector Server Version: " - << OutStringHex(det->getDetectorServerVersion()); + << OutStringHex(det->getDetectorServerVersion(std::vector{det_id})); + os << "\nDetector Server Version: " + << OutString(det->getKernelVersion({std::vector{det_id}})); if (det->getUseReceiverFlag().squash(true)) { os << "\nReceiver Version: " - << OutStringHex(det->getReceiverVersion()); + << OutStringHex(det->getReceiverVersion(std::vector{det_id})); } os << std::dec << '\n'; } else if (action == defs::PUT_ACTION) { diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index fe2712aa8..0e9fdfa5d 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -767,6 +767,7 @@ class CmdProxy { {"clientversion", &CmdProxy::ClientVersion}, {"firmwareversion", &CmdProxy::FirmwareVersion}, {"detectorserverversion", &CmdProxy::detectorserverversion}, + {"kernelversion", &CmdProxy::kernelversion}, {"rx_version", &CmdProxy::rx_version}, {"serialnumber", &CmdProxy::serialnumber}, {"moduleid", &CmdProxy::moduleid}, @@ -1206,6 +1207,10 @@ class CmdProxy { detectorserverversion, getDetectorServerVersion, "\n\tOn-board detector server software version in format [0xYYMMDD]."); + GET_COMMAND( + kernelversion, getKernelVersion, + "\n\tGet kernel version on the detector including time and date."); + GET_COMMAND_HEX(rx_version, getReceiverVersion, "\n\tReceiver version in format [0xYYMMDD]."); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 43f2642b9..bfa62f1f6 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -117,6 +117,10 @@ Result Detector::getDetectorServerVersion(Positions pos) const { return pimpl->Parallel(&Module::getDetectorServerVersion, pos); } +Result Detector::getKernelVersion(Positions pos) const { + return pimpl->Parallel(&Module::getKernelVersion, pos); +} + Result Detector::getSerialNumber(Positions pos) const { return pimpl->Parallel(&Module::getSerialNumber, pos); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index e8a957b88..dfbc4e001 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -94,6 +94,12 @@ int64_t Module::getDetectorServerVersion() const { return sendToDetector(F_GET_SERVER_VERSION); } +std::string Module::getKernelVersion() const { + char retval[MAX_STR_LENGTH]{}; + sendToDetector(F_GET_KERNEL_VERSION, nullptr, retval); + return retval; +} + int64_t Module::getSerialNumber() const { return sendToDetector(F_GET_SERIAL_NUMBER); } diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index ef2ef187d..6bb10a9d3 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -91,6 +91,7 @@ class Module : public virtual slsDetectorDefs { int64_t getFirmwareVersion() const; int64_t getDetectorServerVersion() const; + std::string getKernelVersion() const; int64_t getSerialNumber() const; int getModuleId() const; int64_t getReceiverSoftwareVersion() const; diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 2278c096f..e6e3851fe 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -103,6 +103,13 @@ TEST_CASE("detectorserverversion", "[.cmd]") { REQUIRE_THROWS(proxy.Call("detectorserverversion", {"0"}, -1, PUT)); } +TEST_CASE("kernelversion", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_NOTHROW(proxy.Call("kernelversion", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("kernelversion", {"0"}, -1, PUT)); +} + TEST_CASE("serialnumber", "[.cmd]") { Detector det; CmdProxy proxy(&det); diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 21dd84db6..62b232513 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -253,6 +253,7 @@ enum detFuncs { F_SET_UDP_FIRST_DEST, F_GET_READOUT_SPEED, F_SET_READOUT_SPEED, + F_GET_KERNEL_VERSION, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -608,9 +609,12 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_UDP_FIRST_DEST: return "F_SET_UDP_FIRST_DEST"; case F_GET_READOUT_SPEED: return "F_GET_READOUT_SPEED"; case F_SET_READOUT_SPEED: return "F_SET_READOUT_SPEED"; + case F_GET_KERNEL_VERSION: return "F_GET_KERNEL_VERSION"; + case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; + case F_EXEC_RECEIVER_COMMAND: return "F_EXEC_RECEIVER_COMMAND"; case F_LOCK_RECEIVER: return "F_LOCK_RECEIVER"; case F_GET_LAST_RECEIVER_CLIENT_IP: return "F_GET_LAST_RECEIVER_CLIENT_IP";