Merge pull request #423 from slsdetectorgroup/rmoldserver

copy detector server: rm old server
This commit is contained in:
Dhanya Thattil 2022-04-08 14:56:50 +02:00 committed by GitHub
commit 27c7fd9a97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 130 additions and 251 deletions

View File

@ -59,6 +59,8 @@ This document describes the differences between v7.0.0 and v6.x.x
- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels) - gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels)
- master binary file in json format now - master binary file in json format now
- fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile - fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile
- updatedetectorserver - removes old server current binary pointing to for blackfin
- removing copydetectorserver using tftp
- registerCallBackRawDataReady and registerCallBackRawDataModifyReady now gives a sls_receiver_header* instead of a char*, and uint32_t to size_t - registerCallBackRawDataReady and registerCallBackRawDataModifyReady now gives a sls_receiver_header* instead of a char*, and uint32_t to size_t
- registerCallBackStartAcquisition gave incorrect imagesize (+120 bytes). corrected. - registerCallBackStartAcquisition gave incorrect imagesize (+120 bytes). corrected.
- registerCallBackStartAcquisition parameter is a const string reference - registerCallBackStartAcquisition parameter is a const string reference

View File

@ -136,7 +136,7 @@ can use dir()
'__str__', '__subclasshook__', '_adc_register', '_frozen', '__str__', '__subclasshook__', '_adc_register', '_frozen',
'_register', 'acquire', 'adcclk', 'adcphase', 'adcpipeline', '_register', 'acquire', 'adcclk', 'adcphase', 'adcpipeline',
'adcreg', 'asamples', 'auto_comp_disable', 'clearAcquiringFlag', 'adcreg', 'asamples', 'auto_comp_disable', 'clearAcquiringFlag',
'clearBit', 'clearROI', 'client_version', 'config', 'copyDetectorServer', 'clearBit', 'clearROI', 'client_version', 'config',
'counters', 'daclist', 'dacvalues', 'dbitclk', 'dbitphase' ... 'counters', 'daclist', 'dacvalues', 'dbitclk', 'dbitphase' ...
Since the list for Detector is rather long it's an good idea to filter it. Since the list for Detector is rather long it's an good idea to filter it.

View File

@ -5,17 +5,42 @@ Detector Server Upgrade
**Location:** slsDetectorPackage/serverBin/ folder for every release. **Location:** slsDetectorPackage/serverBin/ folder for every release.
.. note ::
For Mythen3, Gotthard2 and Eiger, you need to add scripts to automatically start detector server upon power on. See :ref:`Automatic start<Automatic start servers>` for more details.
.. note ::
Eiger requires a manual reboot. Or killall the servers and restart the new linked one. If you are in the process of updating firmware, then don't reboot yet.
From 6.1.1 and above (no tftp required)
---------------------------------------
#. Program from console
.. code-block:: bash
# the following command copies new server, creates a soft link to xxxDetectorServerxxx
# [Jungfrau][CTB][Moench] also deletes the old server binary and edits initttab to respawn server on reboot
# Then, the detector controller will reboot (except Eiger)
sls_detector_put updatedetectorserver /complete-path-to-binary/xxxDetectorServerxxx
#. Copy the detector server specific config files or any others required to the detector:
.. code-block:: bash
sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
5.0.0 - 6.1.1
--------------
#. Install tftp and copy detector server binary to tftp folder #. Install tftp and copy detector server binary to tftp folder
#. Program from console #. Program from console
.. note ::
These instructions are for upgrades from v5.0.0. For earlier versions, contact us.
.. code-block:: bash .. code-block:: bash
# copies new server from pc tftp folder, creates a soft link to xxxDetectorServerxxx # the following command copies new server from pc tftp folder, creates a soft link to xxxDetectorServerxxx
# [Jungfrau][CTB][Moench] also edits initttab to respawn server on reboot # [Jungfrau][CTB][Moench] also edits initttab to respawn server on reboot
# Then, the detector controller will reboot (except Eiger) # Then, the detector controller will reboot (except Eiger)
sls_detector_put copydetectorserver xxxDetectorServerxxx pcxxx sls_detector_put copydetectorserver xxxDetectorServerxxx pcxxx
@ -27,18 +52,15 @@ Detector Server Upgrade
sls_detector_put execcommand "tftp pcxxx -r configxxx -g" sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
.. note :: Troubleshooting with tftp
^^^^^^^^^^^^^^^^^^^^^^^^^
For Mythen3, Gotthard2 and Eiger, you need to add scripts to automatically start detector server upon power on. See :ref:`Automatic start<Automatic start servers>` for more details.
.. note ::
Eiger requires a manual reboot. Or killall the servers and restart the new linked one. If you are in the process of updating firmware, then don't reboot yet.
Errors
------
#. tftp write error: There is no space left. Please delete some old binaries and try again. #. tftp write error: There is no space left. Please delete some old binaries and try again.
#. text file busy: You are trying to copy the same server. #. text file busy: You are trying to copy the same server.
Older than 5.0.0
-----------------
Please contact us.

View File

@ -1551,11 +1551,6 @@ void init_det(py::module &m) {
.def("resetFPGA", .def("resetFPGA",
(void (Detector::*)(sls::Positions)) & Detector::resetFPGA, (void (Detector::*)(sls::Positions)) & Detector::resetFPGA,
py::arg() = Positions{}) py::arg() = Positions{})
.def("copyDetectorServer",
(void (Detector::*)(const std::string &, const std::string &,
sls::Positions)) &
Detector::copyDetectorServer,
py::arg(), py::arg(), py::arg() = Positions{})
.def("updateDetectorServer", .def("updateDetectorServer",
(void (Detector::*)(const std::string &, sls::Positions)) & (void (Detector::*)(const std::string &, sls::Positions)) &
Detector::updateDetectorServer, Detector::updateDetectorServer,

View File

@ -66,3 +66,5 @@ int moveBinaryFile(char *mess, char *dest, char *src, char *errorPrefix);
int createEmptyFile(char *mess, char *fname, char *errorPrefix); int createEmptyFile(char *mess, char *fname, char *errorPrefix);
int deleteFile(char *mess, char *fname, char *errorPrefix); int deleteFile(char *mess, char *fname, char *errorPrefix);
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix);

View File

@ -132,7 +132,6 @@ int check_version(int);
int software_trigger(int); int software_trigger(int);
int led(int); int led(int);
int digital_io_delay(int); int digital_io_delay(int);
int copy_detector_server(int);
int reboot_controller(int); int reboot_controller(int);
int set_adc_enable_mask(int); int set_adc_enable_mask(int);
int get_adc_enable_mask(int); int get_adc_enable_mask(int);

View File

@ -50,6 +50,10 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
} }
int getAbsPath(char *buf, size_t bufSize, char *fname) { int getAbsPath(char *buf, size_t bufSize, char *fname) {
if (fname[0] == '/') {
strcpy(buf, fname);
return OK;
}
// get path of current binary // get path of current binary
char path[bufSize]; char path[bufSize];
memset(path, 0, bufSize); memset(path, 0, bufSize);
@ -60,10 +64,14 @@ int getAbsPath(char *buf, size_t bufSize, char *fname) {
} }
path[len] = '\0'; path[len] = '\0';
// get dir path and attach config file name // get dir path and attach file name
char *dir = dirname(path); char *dir = dirname(path);
memset(buf, 0, bufSize); memset(buf, 0, bufSize);
if (!strcmp(dir, "/")) {
sprintf(buf, "/%s", fname);
} else {
sprintf(buf, "%s/%s", dir, fname); sprintf(buf, "%s/%s", dir, fname);
}
LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf)); LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf));
return OK; return OK;
} }
@ -466,7 +474,7 @@ int setupDetectorServer(char *mess, char *sname) {
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return FAIL; return FAIL;
} }
LOG(logINFO, ("\tSymbolic link created\n")); LOG(logINFO, ("\tSymbolic link created %s -> %s\n", linkname, sname));
// blackfin boards (respawn) (only kept for backwards compatibility) // blackfin boards (respawn) (only kept for backwards compatibility)
#ifndef VIRTUAL #ifndef VIRTUAL
@ -485,7 +493,7 @@ int setupDetectorServer(char *mess, char *sname) {
// add new link name to /etc/inittab // add new link name to /etc/inittab
if (snprintf(cmd, MAX_STR_LENGTH, if (snprintf(cmd, MAX_STR_LENGTH,
"echo 'ttyS0::respawn:/./%s' >> /etc/inittab", "echo 'ttyS0::respawn:%s' >> /etc/inittab",
linkname) >= MAX_STR_LENGTH) { linkname) >= MAX_STR_LENGTH) {
strcpy(mess, "Could not copy detector server. Command " strcpy(mess, "Could not copy detector server. Command "
"to add new server for spawning is too long\n"); "to add new server for spawning is too long\n");
@ -670,3 +678,26 @@ int deleteFile(char *mess, char *fname, char *errorPrefix) {
} }
return OK; return OK;
} }
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix) {
LOG(logINFO, ("\tChecking if current binary is to be deleted ...\n"))
// get path of current binary (get file name if link)
char currentBinary[MAX_STR_LENGTH];
memset(currentBinary, 0, MAX_STR_LENGTH);
ssize_t len = readlink("/proc/self/exe", currentBinary, MAX_STR_LENGTH - 1);
if (len < 0) {
LOG(logWARNING, ("(%s): Could not delete old servers. Could not "
"readlink current binary\n",
errorPrefix));
return FAIL;
}
currentBinary[len] = '\0';
LOG(logDEBUG1, ("Current binary:%s\n", currentBinary));
// delete file
if (deleteFile(mess, currentBinary, errorPrefix) == FAIL) {
LOG(logWARNING, ("(%s). Could not delete old servers\n", errorPrefix));
return FAIL;
}
return OK;
}

View File

@ -93,7 +93,6 @@ int updateModeAllowedFunction(int file_des) {
F_PROGRAM_FPGA, F_PROGRAM_FPGA,
F_RESET_FPGA, F_RESET_FPGA,
F_CHECK_VERSION, F_CHECK_VERSION,
F_COPY_DET_SERVER,
F_REBOOT_CONTROLLER, F_REBOOT_CONTROLLER,
F_GET_KERNEL_VERSION, F_GET_KERNEL_VERSION,
F_UPDATE_KERNEL, F_UPDATE_KERNEL,
@ -322,7 +321,6 @@ void function_table() {
flist[F_SOFTWARE_TRIGGER] = &software_trigger; flist[F_SOFTWARE_TRIGGER] = &software_trigger;
flist[F_LED] = &led; flist[F_LED] = &led;
flist[F_DIGITAL_IO_DELAY] = &digital_io_delay; flist[F_DIGITAL_IO_DELAY] = &digital_io_delay;
flist[F_COPY_DET_SERVER] = &copy_detector_server;
flist[F_REBOOT_CONTROLLER] = &reboot_controller; flist[F_REBOOT_CONTROLLER] = &reboot_controller;
flist[F_SET_ADC_ENABLE_MASK] = &set_adc_enable_mask; flist[F_SET_ADC_ENABLE_MASK] = &set_adc_enable_mask;
flist[F_GET_ADC_ENABLE_MASK] = &get_adc_enable_mask; flist[F_GET_ADC_ENABLE_MASK] = &get_adc_enable_mask;
@ -4143,65 +4141,15 @@ int digital_io_delay(int file_des) {
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, NULL, 0);
} }
int copy_detector_server(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
char args[2][MAX_STR_LENGTH];
char retvals[MAX_STR_LENGTH] = {0};
memset(args, 0, sizeof(args));
memset(retvals, 0, sizeof(retvals));
if (receiveData(file_des, args, sizeof(args), OTHER) < 0)
return printSocketReadError();
#ifdef VIRTUAL
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
char *sname = args[0];
char *hostname = args[1];
LOG(logINFOBLUE, ("Copying server %s from host %s\n", sname, hostname));
char cmd[MAX_STR_LENGTH] = {0};
#ifdef BLACKFIN_DEFINED
// check update is allowed (Non Amd OR AMD + current kernel)
ret = allowUpdate(mess, "copy detector server");
#endif
// tftp server
if (ret == OK) {
if (snprintf(cmd, MAX_STR_LENGTH, "tftp %s -r %s -g", hostname,
sname) >= MAX_STR_LENGTH) {
ret = FAIL;
strcpy(mess, "Could not copy detector server. Command to copy "
"server too long\n");
LOG(logERROR, (mess));
} else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
ret = FAIL;
snprintf(mess, MAX_STR_LENGTH,
"Could not copy detector server (tftp). %s\n",
retvals);
// LOG(logERROR, (mess)); already printed in executecommand
} else {
LOG(logINFO, ("\tServer copied\n"));
}
}
if (ret == OK) {
ret = setupDetectorServer(mess, sname);
}
}
#endif
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
}
int reboot_controller(int file_des) { int reboot_controller(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
#ifdef EIGERD
functionNotImplemented();
#elif VIRTUAL
ret = GOODBYE;
#elif defined(MYTHEN3D) || defined(GOTTHARD2D)
if (getHardwareVersionNumber() == 0) { if (getHardwareVersionNumber() == 0) {
ret = FAIL; ret = FAIL;
strcpy(mess, "Old board version, reboot by yourself please!\n"); strcpy(mess, "Old board version, reboot by yourself please!\n");
@ -4209,20 +4157,11 @@ int reboot_controller(int file_des) {
Server_SendResult(file_des, INT32, NULL, 0); Server_SendResult(file_des, INT32, NULL, 0);
return GOODBYE; return GOODBYE;
} }
#ifdef VIRTUAL ret = REBOOT;
ret = GOODBYE;
#else #else
ret = REBOOT; ret = REBOOT;
#endif #endif
#elif EIGERD
functionNotImplemented();
#else
#ifdef VIRTUAL
ret = GOODBYE;
#else
ret = REBOOT;
#endif
#endif
Server_SendResult(file_des, INT32, NULL, 0); Server_SendResult(file_des, INT32, NULL, 0);
return ret; return ret;
} }
@ -9449,10 +9388,18 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
if (receiveData(file_des, &forceDeleteNormalFile, if (receiveData(file_des, &forceDeleteNormalFile,
sizeof(forceDeleteNormalFile), INT32) < 0) sizeof(forceDeleteNormalFile), INT32) < 0)
return printSocketReadError(); return printSocketReadError();
LOG(logINFO, LOG(logINFO, ("\tForce Delete Normal File flag? %s\n",
("\tForce Delete Normal File flag? %s\n", (forceDeleteNormalFile ? "Y" : "N"))); (forceDeleteNormalFile ? "Y" : "N")));
#endif #endif
// ensure the name is not the same as the linked name
if (!strcmp(serverName, LINKED_SERVER_NAME)) {
ret = FAIL;
strcpy(mess, "Server name is the same as the symbolic link. Please "
"use a different server name\n");
LOG(logERROR, (mess));
}
// in same folder as current process (will also work for virtual then // in same folder as current process (will also work for virtual then
// with write permissions) // with write permissions)
{ {
@ -9477,7 +9424,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
checksum, serverName); checksum, serverName);
#else #else
receive_program_via_blackfin(file_des, index, functionType, receive_program_via_blackfin(file_des, index, functionType,
filesize, checksum, serverName, forceDeleteNormalFile); filesize, checksum, serverName,
forceDeleteNormalFile);
#endif #endif
} }
@ -9493,7 +9441,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index, void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
char *functionType, uint64_t filesize, char *functionType, uint64_t filesize,
char *checksum, char *serverName, int forceDeleteNormalFile) { char *checksum, char *serverName,
int forceDeleteNormalFile) {
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \ #if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
!defined(GOTTHARDD) !defined(GOTTHARDD)
@ -9595,6 +9544,8 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
totalsize, forceDeleteNormalFile); totalsize, forceDeleteNormalFile);
break; break;
case PROGRAM_SERVER: case PROGRAM_SERVER:
// a fail here is not a show stopper (just for memory)
deleteOldServers(mess, serverName, "update detector server");
ret = moveBinaryFile(mess, serverName, TEMP_PROG_FILE_NAME, ret = moveBinaryFile(mess, serverName, TEMP_PROG_FILE_NAME,
"update detector server"); "update detector server");
if (ret == OK) { if (ret == OK) {

View File

@ -1766,23 +1766,11 @@ class Detector {
/** [Jungfrau][CTB][Moench] Advanced user Function! */ /** [Jungfrau][CTB][Moench] Advanced user Function! */
void resetFPGA(Positions pos = {}); void resetFPGA(Positions pos = {});
/** [[deprecated ("Replaced by updateDetectorServer, which does not require
* tftp")]] [Jungfrau][Eiger][Gotthard][CTB][Moench][Mythen3][Gotthard2]
* Advanced user Function! \n
* Copy detector server fname from tftp folder of hostname to detector. Also
* creates a symbolic link to a shorter name (without vx.x.x). Then the
* detector controller reboots (except eiger) \n
* [Jungfrau][Gotthard][CTB][Moench] Also changes respawn server (to the
* link), which is effective after a reboot.
*/
void copyDetectorServer(const std::string &fname,
const std::string &hostname, Positions pos = {});
/** [Jungfrau][Eiger][Ctb][Moench][Mythen3][Gotthard2] Copies detector /** [Jungfrau][Eiger][Ctb][Moench][Mythen3][Gotthard2] Copies detector
* server via TCP (without tftp).\nMakes a symbolic link with a shorter * server via TCP (without tftp).\nMakes a symbolic link with a shorter
* name (without vx.x.x).\nThen, detector controller reboots (except * name (without vx.x.x).\nThen, detector controller reboots (except
* Eiger).\n[Jungfrau][Ctb][Moench]Also changes respawn server to the * Eiger).\n[Jungfrau][Ctb][Moench] Also deletes old server binary and
* link, which is effective after a reboot. * changes respawn server to the link, which is effective after a reboot.
*/ */
void updateDetectorServer(const std::string &fname, Positions pos = {}); void updateDetectorServer(const std::string &fname, Positions pos = {});
@ -1797,19 +1785,6 @@ class Detector {
* Function! */ * Function! */
void rebootController(Positions pos = {}); void rebootController(Positions pos = {});
/** [[deprecated ("Replaced by overloaded updateDetectorServer, which does
* not require tftp and has one less argument")]] Advanced user Function!\n
* [Jungfrau][Gotthard][CTB][Moench] Updates the firmware, detector server,
* make a soft link and then reboots detector controller. \n
* [Mythen3][Gotthard2] Will require a script to start up the shorter named
* server link at start up \n sname is name of detector server binary found
* on tftp folder of host pc \n hostname is name of pc to tftp from \n fname
* is programming file name with full path to it
*/
void updateFirmwareAndServer(const std::string &sname,
const std::string &hostname,
const std::string &fname, Positions pos = {});
/** /**
* Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the * Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the
* firmware, detector server, make a soft link and then reboots detector * firmware, detector server, make a soft link and then reboots detector

View File

@ -2916,35 +2916,6 @@ std::string CmdProxy::ProgramFpga(int action) {
return os.str(); return os.str();
} }
std::string CmdProxy::CopyDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
LOG(logWARNING) << "Deprecated! Replaced by updatedetectorserver that "
"requires no tftp.\n";
os << "[server_name (in tftp folder)] "
"[pc_host_name]\n\t[Jungfrau][Eiger][Ctb][Moench][Mythen3]["
"Gotthard2] Copies detector server via TFTP from pc. Ensure that "
"server is in the pc's tftp folder. Makes a symbolic link with a "
"shorter name (without vx.x.x). Then, detector controller "
"reboots (except "
"Eiger).\n\t[Jungfrau][Ctb][Moench]Also changes respawn server "
"to the link, which is effective after a reboot."
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
det->copyDetectorServer(args[0], args[1], std::vector<int>{det_id});
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::UpdateDetectorServer(int action) { std::string CmdProxy::UpdateDetectorServer(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
@ -3001,23 +2972,21 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "\n\tUsing tftp: Deprecated!! [server_name" os << "\n\tWithout tftp: [server_name (incl fullpath)] "
" (in tftp folder)] [pc_host_name] [fname.pof (incl full path)]"
"\n\tWithout tftp: Recommended [server_name (incl fullpath)] "
"[fname.pof (incl full path)] " "[fname.pof (incl full path)] "
"This does not use tftp." "This does not use tftp."
"\n\t\t[Jungfrau][Gotthard][CTB][Moench] Updates the " "\n\t\t[Jungfrau][Gotthard][CTB][Moench] Updates the "
"firmware, detector server, creates the symbolic link and then " "firmware, detector server, deletes old server, creates the symbolic link and then "
"reboots detector controller. \n\t\t[Mythen3][Gotthard2] will " "reboots detector controller. \n\t\t[Mythen3][Gotthard2] will "
"require a script to start up the shorter named server link at " "require a script to start up the shorter named server link at "
"start up. \n\t\tsname is full path name of detector server " "start up. \n\t\tserver_name is full path name of detector server "
"binary" "binary"
"\n\t\tfname is full path of programming file" "\n\t\tfname is full path of programming file"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get"); throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (args.size() != 3 && args.size() != 2) { if (args.size() != 2) {
WrongNumberOfParameters(2); WrongNumberOfParameters(2);
} }
@ -3026,17 +2995,8 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
args[fpos].find(".rbf") == std::string::npos) { args[fpos].find(".rbf") == std::string::npos) {
throw sls::RuntimeError("Programming file must be a pof/rbf file."); throw sls::RuntimeError("Programming file must be a pof/rbf file.");
} }
if (args.size() == 3) {
LOG(logWARNING)
<< "Deprecated! Recommend to use same command without tftp (no "
"pc name) and using full path to the server binary";
det->updateFirmwareAndServer(args[0], args[1], args[2],
std::vector<int>{det_id});
} else {
det->updateFirmwareAndServer(args[0], args[1], det->updateFirmwareAndServer(args[0], args[1],
std::vector<int>{det_id}); std::vector<int>{det_id});
}
os << "successful\n"; os << "successful\n";
} else { } else {
throw sls::RuntimeError("Unknown action"); throw sls::RuntimeError("Unknown action");

View File

@ -743,7 +743,11 @@ class CmdProxy {
/* Pattern */ /* Pattern */
/* Moench */ /* Moench */
/* Advanced */ /* Advanced */
{"copydetectorserver", "updatedetectorserver"},
/* Insignificant */ /* Insignificant */
{"nframes", "framecounter"}, {"nframes", "framecounter"},
{"now", "runtime"}, {"now", "runtime"},
@ -1062,7 +1066,6 @@ class CmdProxy {
/* Advanced */ /* Advanced */
{"programfpga", &CmdProxy::ProgramFpga}, {"programfpga", &CmdProxy::ProgramFpga},
{"resetfpga", &CmdProxy::resetfpga}, {"resetfpga", &CmdProxy::resetfpga},
{"copydetectorserver", &CmdProxy::CopyDetectorServer},
{"updatedetectorserver", &CmdProxy::UpdateDetectorServer}, {"updatedetectorserver", &CmdProxy::UpdateDetectorServer},
{"updatekernel", &CmdProxy::UpdateKernel}, {"updatekernel", &CmdProxy::UpdateKernel},
{"rebootcontroller", &CmdProxy::rebootcontroller}, {"rebootcontroller", &CmdProxy::rebootcontroller},
@ -1189,7 +1192,6 @@ class CmdProxy {
std::string JsonParameter(int action); std::string JsonParameter(int action);
/* Advanced */ /* Advanced */
std::string ProgramFpga(int action); std::string ProgramFpga(int action);
std::string CopyDetectorServer(int action);
std::string UpdateDetectorServer(int action); std::string UpdateDetectorServer(int action);
std::string UpdateKernel(int action); std::string UpdateKernel(int action);
std::string UpdateFirmwareAndDetectorServer(int action); std::string UpdateFirmwareAndDetectorServer(int action);

View File

@ -2242,15 +2242,6 @@ void Detector::resetFPGA(Positions pos) {
pimpl->Parallel(&Module::resetFPGA, pos); pimpl->Parallel(&Module::resetFPGA, pos);
} }
void Detector::copyDetectorServer(const std::string &fname,
const std::string &hostname, Positions pos) {
LOG(logINFO) << "Updating Detector Server (via tftp)...";
pimpl->Parallel(&Module::copyDetectorServer, pos, fname, hostname);
if (getDetectorType().squash() != defs::EIGER) {
rebootController(pos);
}
}
void Detector::updateDetectorServer(const std::string &fname, Positions pos) { void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
LOG(logINFO) << "Updating Detector Server (no tftp)..."; LOG(logINFO) << "Updating Detector Server (no tftp)...";
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server"); std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
@ -2272,16 +2263,6 @@ void Detector::rebootController(Positions pos) {
pimpl->Parallel(&Module::rebootController, pos); pimpl->Parallel(&Module::rebootController, pos);
} }
void Detector::updateFirmwareAndServer(const std::string &sname,
const std::string &hostname,
const std::string &fname,
Positions pos) {
LOG(logINFO) << "Updating Firmware and Detector Server (with tftp)...";
LOG(logINFO) << "Updating Detector Server (via tftp)...";
pimpl->Parallel(&Module::copyDetectorServer, pos, sname, hostname);
programFPGA(fname, false, pos);
}
void Detector::updateFirmwareAndServer(const std::string &sname, void Detector::updateFirmwareAndServer(const std::string &sname,
const std::string &fname, const std::string &fname,
Positions pos) { Positions pos) {

View File

@ -1288,8 +1288,13 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
throw RuntimeError("Programming file must be an rbf file."); throw RuntimeError("Programming file must be an rbf file.");
} }
break; break;
default: case EIGER:
case GOTTHARD:
throw RuntimeError("programfpga not implemented for this detector"); throw RuntimeError("programfpga not implemented for this detector");
default:
throw RuntimeError(
"Unknown detector type. Did the 'hostname' command execute "
"successfully? Or use update mode in the detector server side.");
} }
LOG(logINFO) << "This can take awhile. Please be patient."; LOG(logINFO) << "This can take awhile. Please be patient.";

View File

@ -2611,28 +2611,6 @@ void Module::programFPGA(std::vector<char> buffer,
void Module::resetFPGA() { sendToDetector(F_RESET_FPGA); } void Module::resetFPGA() { sendToDetector(F_RESET_FPGA); }
void Module::copyDetectorServer(const std::string &fname,
const std::string &hostname) {
char args[2][MAX_STR_LENGTH]{};
sls::strcpy_safe(args[0], fname.c_str());
sls::strcpy_safe(args[1], hostname.c_str());
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Sending detector server " << args[0] << " from host "
<< args[1];
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_COPY_DET_SERVER);
client.Send(args);
if (client.Receive<int>() == FAIL) {
std::cout << '\n';
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw DetectorError(os.str());
}
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Detector server copied";
}
void Module::updateDetectorServer(std::vector<char> buffer, void Module::updateDetectorServer(std::vector<char> buffer,
const std::string &serverName) { const std::string &serverName) {
switch (shm()->detType) { switch (shm()->detType) {

View File

@ -548,8 +548,6 @@ class Module : public virtual slsDetectorDefs {
void programFPGA(std::vector<char> buffer, void programFPGA(std::vector<char> buffer,
const bool forceDeleteNormalFile); const bool forceDeleteNormalFile);
void resetFPGA(); void resetFPGA();
void copyDetectorServer(const std::string &fname,
const std::string &hostname);
void updateDetectorServer(std::vector<char> buffer, void updateDetectorServer(std::vector<char> buffer,
const std::string &serverName); const std::string &serverName);
void updateKernel(std::vector<char> buffer); void updateKernel(std::vector<char> buffer);

View File

@ -2787,25 +2787,6 @@ TEST_CASE("resetfpga", "[.cmd]") {
} }
} }
TEST_CASE("copydetectorserver", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
det_type == defs::MOENCH || det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD2) {
// TODO: send real server?
// std::ostringstream oss;
// proxy.Call("copydetectorserver",{"jungfrauDetectorServerv4.0.1.0",
// "pc13784"}, -1, PUT, oss);
// REQUIRE(oss.str() == "copydetectorserver successful\n");
REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, PUT));
}
}
TEST_CASE("updatekernel", "[.cmd]") { TEST_CASE("updatekernel", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);

View File

@ -111,7 +111,6 @@ enum detFuncs {
F_SOFTWARE_TRIGGER, F_SOFTWARE_TRIGGER,
F_LED, F_LED,
F_DIGITAL_IO_DELAY, F_DIGITAL_IO_DELAY,
F_COPY_DET_SERVER,
F_REBOOT_CONTROLLER, F_REBOOT_CONTROLLER,
F_SET_ADC_ENABLE_MASK, F_SET_ADC_ENABLE_MASK,
F_GET_ADC_ENABLE_MASK, F_GET_ADC_ENABLE_MASK,
@ -477,7 +476,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER"; case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
case F_LED: return "F_LED"; case F_LED: return "F_LED";
case F_DIGITAL_IO_DELAY: return "F_DIGITAL_IO_DELAY"; case F_DIGITAL_IO_DELAY: return "F_DIGITAL_IO_DELAY";
case F_COPY_DET_SERVER: return "F_COPY_DET_SERVER";
case F_REBOOT_CONTROLLER: return "F_REBOOT_CONTROLLER"; case F_REBOOT_CONTROLLER: return "F_REBOOT_CONTROLLER";
case F_SET_ADC_ENABLE_MASK: return "F_SET_ADC_ENABLE_MASK"; case F_SET_ADC_ENABLE_MASK: return "F_SET_ADC_ENABLE_MASK";
case F_GET_ADC_ENABLE_MASK: return "F_GET_ADC_ENABLE_MASK"; case F_GET_ADC_ENABLE_MASK: return "F_GET_ADC_ENABLE_MASK";

View File

@ -2,14 +2,13 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */ /** API versions */
#define GITBRANCH "developer" #define GITBRANCH "developer"
#define APILIB 0x211125 #define APILIB 0x220405
#define APIRECEIVER 0x211124 #define APIRECEIVER 0x220405
#define APIGUI 0x211124 #define APIGUI 0x220328
#define APICTB 0x220405
#define APIEIGER 0x220324 #define APIGOTTHARD 0x220405
#define APICTB 0x220328 #define APIGOTTHARD2 0x220405
#define APIGOTTHARD 0x220328 #define APIJUNGFRAU 0x220405
#define APIGOTTHARD2 0x220328 #define APIMYTHEN3 0x220405
#define APIJUNGFRAU 0x220328 #define APIMOENCH 0x220405
#define APIMOENCH 0x220328 #define APIEIGER 0x220405
#define APIMYTHEN3 0x220404