mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
addd kernel version
This commit is contained in:
parent
1da2761654
commit
eff64f99f2
@ -19,7 +19,7 @@ This document describes the differences between vx.x.x and v6.0.0.
|
||||
|
||||
1. New or Changed Features
|
||||
==========================
|
||||
|
||||
- kernelversion
|
||||
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -67,6 +67,10 @@ void init_det(py::module &m) {
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getDetectorServerVersion,
|
||||
py::arg() = Positions{})
|
||||
.def("getKernelVersion",
|
||||
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getKernelVersion,
|
||||
py::arg() = Positions{})
|
||||
.def("getSerialNumber",
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getSerialNumber,
|
||||
|
Binary file not shown.
Binary file not shown.
@ -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;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
int set_readout_speed(int);
|
||||
int get_kernel_version(int);
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ class Detector {
|
||||
|
||||
Result<int64_t> getDetectorServerVersion(Positions pos = {}) const;
|
||||
|
||||
Result<std::string> getKernelVersion(Positions pos = {}) const;
|
||||
|
||||
/* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */
|
||||
Result<int64_t> getSerialNumber(Positions pos = {}) const;
|
||||
|
||||
|
@ -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<int>{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<int>{det_id}));
|
||||
os << "\nDetector Server Version: "
|
||||
<< OutString(det->getKernelVersion({std::vector<int>{det_id}}));
|
||||
if (det->getUseReceiverFlag().squash(true)) {
|
||||
os << "\nReceiver Version: "
|
||||
<< OutStringHex(det->getReceiverVersion());
|
||||
<< OutStringHex(det->getReceiverVersion(std::vector<int>{det_id}));
|
||||
}
|
||||
os << std::dec << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
|
@ -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].");
|
||||
|
||||
|
@ -117,6 +117,10 @@ Result<int64_t> Detector::getDetectorServerVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDetectorServerVersion, pos);
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getKernelVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getKernelVersion, pos);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getSerialNumber(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getSerialNumber, pos);
|
||||
}
|
||||
|
@ -94,6 +94,12 @@ int64_t Module::getDetectorServerVersion() const {
|
||||
return sendToDetector<int64_t>(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<int64_t>(F_GET_SERIAL_NUMBER);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user