mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 11:20:04 +02:00
g2 and m3: kernel checks only when its too old
This commit is contained in:
parent
cb23e827bf
commit
d931416def
@ -1,3 +1,4 @@
|
|||||||
|
#define _GNU_SOURCE // needed for strptime to be at the top
|
||||||
#include "slsDetectorFunctionList.h"
|
#include "slsDetectorFunctionList.h"
|
||||||
#include "ALTERA_PLL_CYCLONE10.h"
|
#include "ALTERA_PLL_CYCLONE10.h"
|
||||||
#include "ASIC_Driver.h"
|
#include "ASIC_Driver.h"
|
||||||
@ -14,10 +15,10 @@
|
|||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
#include <unistd.h> // usleep
|
#include <unistd.h> // usleep
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <time.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
@ -181,18 +182,44 @@ int checkKernelVersion() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// extract kernel date string
|
||||||
char output[256];
|
char output[256];
|
||||||
memset(output, 0, 256);
|
memset(output, 0, 256);
|
||||||
FILE *sysFile = popen("uname -a | cut -d ' ' -f5-10", "r");
|
FILE *sysFile = popen("uname -a | cut -d ' ' -f5-10", "r");
|
||||||
fgets(output, sizeof(output), sysFile);
|
fgets(output, sizeof(output), sysFile);
|
||||||
pclose(sysFile);
|
pclose(sysFile);
|
||||||
|
// remove end line
|
||||||
|
output[strlen(output) - 1] = '\0';
|
||||||
|
|
||||||
if (strstr(output, KERNEL_DATE_VRSN) == NULL) {
|
// convert kernel date string into time
|
||||||
LOG(logERROR, ("Kernel Version Incompatible! Expected: %s, Got: %s\n",
|
struct tm kernelDate;
|
||||||
|
if (NULL == strptime(output, "%a %b %d %H:%M:%S %Z %Y", &kernelDate)) {
|
||||||
|
LOG(logERROR, ("Could not parse retrieved kernel date, %s\n", output));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
time_t t_kernelDate = mktime(&kernelDate);
|
||||||
|
|
||||||
|
// convert expected date into time
|
||||||
|
struct tm expDate;
|
||||||
|
if (NULL ==
|
||||||
|
strptime(KERNEL_DATE_VRSN, "%a %b %d %H:%M:%S %Z %Y", &expDate)) {
|
||||||
|
LOG(logERROR,
|
||||||
|
("Could not parse expected kernel date, %s\n", KERNEL_DATE_VRSN));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
time_t t_expDate = mktime(&expDate);
|
||||||
|
|
||||||
|
// compare if kernel time is older than expected time
|
||||||
|
if (t_kernelDate < t_expDate) {
|
||||||
|
LOG(logERROR,
|
||||||
|
("Kernel Version Incompatible (too old)! Expected: %s, Got %s\n",
|
||||||
KERNEL_DATE_VRSN, output));
|
KERNEL_DATE_VRSN, output));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("Kernel Version Compatible: %s\n", output));
|
|
||||||
|
LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n", output,
|
||||||
|
KERNEL_DATE_VRSN));
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#define _GNU_SOURCE // needed for strptime to be at the top
|
||||||
#include "slsDetectorFunctionList.h"
|
#include "slsDetectorFunctionList.h"
|
||||||
#include "ALTERA_PLL_CYCLONE10.h"
|
#include "ALTERA_PLL_CYCLONE10.h"
|
||||||
#include "DAC6571.h"
|
#include "DAC6571.h"
|
||||||
@ -13,10 +14,10 @@
|
|||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
#include <unistd.h> // usleep
|
#include <unistd.h> // usleep
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <time.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
@ -167,18 +168,44 @@ int checkKernelVersion() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// extract kernel date string
|
||||||
char output[256];
|
char output[256];
|
||||||
memset(output, 0, 256);
|
memset(output, 0, 256);
|
||||||
FILE *sysFile = popen("uname -a | cut -d ' ' -f5-10", "r");
|
FILE *sysFile = popen("uname -a | cut -d ' ' -f5-10", "r");
|
||||||
fgets(output, sizeof(output), sysFile);
|
fgets(output, sizeof(output), sysFile);
|
||||||
pclose(sysFile);
|
pclose(sysFile);
|
||||||
|
// remove end line
|
||||||
|
output[strlen(output) - 1] = '\0';
|
||||||
|
|
||||||
if (strstr(output, KERNEL_DATE_VRSN) == NULL) {
|
// convert kernel date string into time
|
||||||
LOG(logERROR, ("Kernel Version Incompatible! Expected: %s, Got: %s\n",
|
struct tm kernelDate;
|
||||||
|
if (NULL == strptime(output, "%a %b %d %H:%M:%S %Z %Y", &kernelDate)) {
|
||||||
|
LOG(logERROR, ("Could not parse retrieved kernel date, %s\n", output));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
time_t t_kernelDate = mktime(&kernelDate);
|
||||||
|
|
||||||
|
// convert expected date into time
|
||||||
|
struct tm expDate;
|
||||||
|
if (NULL ==
|
||||||
|
strptime(KERNEL_DATE_VRSN, "%a %b %d %H:%M:%S %Z %Y", &expDate)) {
|
||||||
|
LOG(logERROR,
|
||||||
|
("Could not parse expected kernel date, %s\n", KERNEL_DATE_VRSN));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
time_t t_expDate = mktime(&expDate);
|
||||||
|
|
||||||
|
// compare if kernel time is older than expected time
|
||||||
|
if (t_kernelDate < t_expDate) {
|
||||||
|
LOG(logERROR,
|
||||||
|
("Kernel Version Incompatible (too old)! Expected: %s, Got %s\n",
|
||||||
KERNEL_DATE_VRSN, output));
|
KERNEL_DATE_VRSN, output));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("Kernel Version Compatible: %s\n", output));
|
|
||||||
|
LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n", output,
|
||||||
|
KERNEL_DATE_VRSN));
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user