mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
adding the check for copydetector server and updatemode (also for any kind of updatedetectorserver, programfpga and updatekernel)
This commit is contained in:
parent
ed2e6e4e28
commit
f39f93b2c8
@ -14,7 +14,7 @@ int FPGATouchFlash(char *mess);
|
|||||||
int resetFPGA(char *mess);
|
int resetFPGA(char *mess);
|
||||||
|
|
||||||
int emptyTempFolder(char *mess);
|
int emptyTempFolder(char *mess);
|
||||||
int allowKernelUpdate(char *mess, char *functionType);
|
int allowUpdate(char *mess, char *functionType);
|
||||||
/**
|
/**
|
||||||
* deletes old file
|
* deletes old file
|
||||||
* verify memory available to copy
|
* verify memory available to copy
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
#include <unistd.h> // usleep
|
#include <unistd.h> // usleep
|
||||||
|
|
||||||
|
#define BLACKFIN_DEFINED
|
||||||
/* global variables */
|
/* global variables */
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define MAX_TIME_FPGA_TOUCH_FLASH_US (10 * 1000 * 1000) // 10s
|
#define MAX_TIME_FPGA_TOUCH_FLASH_US (10 * 1000 * 1000) // 10s
|
||||||
@ -248,8 +249,8 @@ int emptyTempFolder(char *mess) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int allowKernelUpdate(char *mess, char *functionType) {
|
int allowUpdate(char *mess, char *functionType) {
|
||||||
LOG(logINFO, ("\tVerifying kernel update allowed...\n"));
|
LOG(logINFO, ("\tVerifying %s allowed...\n", functionType));
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return OK;
|
return OK;
|
||||||
|
@ -4143,20 +4143,28 @@ int copy_detector_server(int file_des) {
|
|||||||
LOG(logINFOBLUE, ("Copying server %s from host %s\n", sname, hostname));
|
LOG(logINFOBLUE, ("Copying server %s from host %s\n", sname, hostname));
|
||||||
char cmd[MAX_STR_LENGTH] = {0};
|
char cmd[MAX_STR_LENGTH] = {0};
|
||||||
|
|
||||||
|
#if BLACKFIN_DEFINED
|
||||||
|
// check update is allowed (Non Amd OR AMD + current kernel)
|
||||||
|
ret = allowUpdate(mess, "copy detector server");
|
||||||
|
#endif
|
||||||
|
|
||||||
// tftp server
|
// tftp server
|
||||||
if (snprintf(cmd, MAX_STR_LENGTH, "tftp %s -r %s -g", hostname,
|
if (ret == OK) {
|
||||||
sname) >= MAX_STR_LENGTH) {
|
if (snprintf(cmd, MAX_STR_LENGTH, "tftp %s -r %s -g", hostname,
|
||||||
ret = FAIL;
|
sname) >= MAX_STR_LENGTH) {
|
||||||
strcpy(mess, "Could not copy detector server. Command to copy "
|
ret = FAIL;
|
||||||
"server too long\n");
|
strcpy(mess, "Could not copy detector server. Command to copy "
|
||||||
LOG(logERROR, (mess));
|
"server too long\n");
|
||||||
} else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
LOG(logERROR, (mess));
|
||||||
ret = FAIL;
|
} else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
ret = FAIL;
|
||||||
"Could not copy detector server (tftp). %s\n", retvals);
|
snprintf(mess, MAX_STR_LENGTH,
|
||||||
// LOG(logERROR, (mess)); already printed in executecommand
|
"Could not copy detector server (tftp). %s\n",
|
||||||
} else {
|
retvals);
|
||||||
LOG(logINFO, ("\tServer copied\n"));
|
// LOG(logERROR, (mess)); already printed in executecommand
|
||||||
|
} else {
|
||||||
|
LOG(logINFO, ("\tServer copied\n"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
@ -9373,8 +9381,8 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
|||||||
functionType);
|
functionType);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
#else
|
#else
|
||||||
// check kernel update is allowed (Non Amd OR AMD + current kernel)
|
// check update is allowed (Non Amd OR AMD + current kernel)
|
||||||
ret = allowKernelUpdate(mess, functionType);
|
ret = allowUpdate(mess, functionType);
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
Server_SendResult(file_des, INT32, NULL, 0);
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
return;
|
return;
|
||||||
@ -9599,18 +9607,25 @@ int set_update_mode(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logDEBUG1, ("Setting update mode to \n", arg));
|
LOG(logDEBUG1, ("Setting update mode to \n", arg));
|
||||||
|
|
||||||
switch (arg) {
|
#if BLACKFIN_DEFINED
|
||||||
case 0:
|
// check update is allowed (Non Amd OR AMD + current kernel)
|
||||||
ret = deleteFile(mess, UPDATE_FILE, "unset update mode");
|
ret = allowUpdate(mess, "copy detector server");
|
||||||
break;
|
#endif
|
||||||
case 1:
|
|
||||||
ret = createEmptyFile(mess, UPDATE_FILE, "set update mode");
|
if (ret == OK) {
|
||||||
break;
|
switch (arg) {
|
||||||
default:
|
case 0:
|
||||||
ret = FAIL;
|
ret = deleteFile(mess, UPDATE_FILE, "unset update mode");
|
||||||
sprintf(mess, "Could not set updatemode. Options: 0 or 1\n");
|
break;
|
||||||
LOG(logERROR, (mess));
|
case 1:
|
||||||
break;
|
ret = createEmptyFile(mess, UPDATE_FILE, "set update mode");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Could not set updatemode. Options: 0 or 1\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user