mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
all servers except eiger: easier to update firmware and software using update or copydetectorserver, rebootcontroller, and programfpga
This commit is contained in:
@ -1419,7 +1419,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
int setStoragecellStart(int pos = -1, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Programs FPGA with pof file (Jungfrau)
|
||||
* Programs FPGA with pof file (Not Eiger)
|
||||
* @param fname file name
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns OK or FAIL
|
||||
@ -1427,12 +1427,38 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
int programFPGA(const std::string &fname, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Resets FPGA (Jungfrau)
|
||||
* Resets FPGA (Not Eiger)
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int resetFPGA(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Copies detector server from tftp and changes respawn server (Not Eiger)
|
||||
* @param fname name of detector server binary
|
||||
* @param hostname name of pc to tftp from
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int copyDetectorServer(const std::string &fname, const std::string &hostname, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Reboot detector controller (Not Eiger)
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int rebootController(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Updates the firmware, detector server and then reboots detector controller blackfin. (Not Eiger)
|
||||
* @param sname name of detector server binary
|
||||
* @param hostname name of pc to tftp from
|
||||
* @param fname programming file name
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int update(const std::string &sname, const std::string &hostname, const std::string &fname, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Power on/off Chip (Jungfrau)
|
||||
* @param ival on is 1, off is 0, -1 to get
|
||||
|
@ -1291,6 +1291,20 @@ class slsDetector : public virtual slsDetectorDefs{
|
||||
int resetFPGA();
|
||||
|
||||
/**
|
||||
* Copies detector server from tftp and changes respawn server (Not Eiger)
|
||||
* @param fname name of detector server binary
|
||||
* @param hostname name of pc to tftp from
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int copyDetectorServer(const std::string &fname, const std::string &hostname);
|
||||
|
||||
/**
|
||||
* Reboot detector controller (blackfin/ powerpc)
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int rebootController();
|
||||
|
||||
/**
|
||||
* Power on/off Chip (Jungfrau)
|
||||
* @param ival on is 1, off is 0, -1 to get
|
||||
* @returns OK or FAIL
|
||||
|
@ -2597,12 +2597,13 @@ int multiSlsDetector::setStoragecellStart(int pos, int detPos) {
|
||||
}
|
||||
|
||||
int multiSlsDetector::programFPGA(const std::string &fname, int detPos) {
|
||||
FILE_LOG(logINFO) << "This can take awhile. Please be patient...";
|
||||
// read pof file
|
||||
std::vector<char> buffer = readPofFile(fname);
|
||||
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->programFPGA(buffer);
|
||||
return detectors[detPos]->programFPGA(buffer);
|
||||
}
|
||||
|
||||
// multi
|
||||
@ -2621,6 +2622,47 @@ int multiSlsDetector::resetFPGA(int detPos) {
|
||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||
}
|
||||
|
||||
int multiSlsDetector::copyDetectorServer(const std::string &fname, const std::string &hostname, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->copyDetectorServer(fname, hostname);
|
||||
return detectors[detPos]->rebootController(); // reboot and copy should be independant for update command
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::copyDetectorServer,fname, hostname);
|
||||
auto r = parallelCall(&slsDetector::rebootController);
|
||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||
}
|
||||
|
||||
int multiSlsDetector::rebootController(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->rebootController();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::rebootController);
|
||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||
}
|
||||
|
||||
int multiSlsDetector::update(const std::string &sname, const std::string &hostname, const std::string &fname, int detPos) {
|
||||
FILE_LOG(logINFO) << "This can take awhile. Please be patient...";
|
||||
// read pof file
|
||||
std::vector<char> buffer = readPofFile(fname);
|
||||
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->copyDetectorServer(sname, hostname);
|
||||
return detectors[detPos]->programFPGA(buffer);
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::copyDetectorServer,sname, hostname);
|
||||
auto r = parallelCall(&slsDetector::programFPGA, buffer);
|
||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||
}
|
||||
|
||||
int multiSlsDetector::powerChip(int ival, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
|
@ -848,7 +848,9 @@ int slsDetector::execCommand(const std::string &cmd) {
|
||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, arg, sizeof(arg), retval, sizeof(retval));
|
||||
FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval;
|
||||
if (strlen(retval)) {
|
||||
FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -3410,7 +3412,7 @@ int slsDetector::programFPGA(std::vector<char> buffer) {
|
||||
client.sendData(&fnum, sizeof(fnum));
|
||||
client.sendData(&filesize, sizeof(filesize));
|
||||
client.receiveData(&ret, sizeof(ret));
|
||||
// opening error
|
||||
// error in detector at opening file pointer to flash
|
||||
if (ret == FAIL) {
|
||||
client.receiveData(mess, sizeof(mess));
|
||||
std::ostringstream os;
|
||||
@ -3421,12 +3423,10 @@ int slsDetector::programFPGA(std::vector<char> buffer) {
|
||||
|
||||
// erasing flash
|
||||
if (ret != FAIL) {
|
||||
FILE_LOG(logINFO) << "This can take awhile. Please be patient...";
|
||||
FILE_LOG(logINFO) << "Erasing Flash for detector " << detId << " (" << detector_shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// erasing takes 65 seconds, printing here (otherwise need threads
|
||||
// in server-unnecessary)
|
||||
// erasing takes 65 seconds, printing here (otherwise need threads in server-unnecessary)
|
||||
const int ERASE_TIME = 65;
|
||||
int count = ERASE_TIME + 1;
|
||||
while (count > 0) {
|
||||
@ -3473,43 +3473,10 @@ int slsDetector::programFPGA(std::vector<char> buffer) {
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// check ending error
|
||||
if ((ret == FAIL) && (strstr(mess, "not implemented") == nullptr) &&
|
||||
(strstr(mess, "locked") == nullptr) && (strstr(mess, "-update") == nullptr)) {
|
||||
client.receiveData(&ret, sizeof(ret));
|
||||
if (ret == FAIL) {
|
||||
client.receiveData(mess, sizeof(mess));
|
||||
std::ostringstream os;
|
||||
os << "Detector " << detId << " (" << detector_shm()->hostname << ")" <<
|
||||
" returned error: " << mess;
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateDetector();
|
||||
}
|
||||
|
||||
// remapping stop server
|
||||
if ((ret == FAIL) && (strstr(mess, "not implemented") == nullptr) &&
|
||||
(strstr(mess, "locked") == nullptr) && (strstr(mess, "-update") == nullptr)) {
|
||||
fnum = F_RESET_FPGA;
|
||||
int stopret = FAIL;
|
||||
auto stop = DetectorSocket(detector_shm()->hostname, detector_shm()->stopPort);
|
||||
stop.sendData(&fnum, sizeof(fnum));
|
||||
stop.receiveData(&stopret, sizeof(stopret));
|
||||
if (stopret == FAIL) {
|
||||
client.receiveData(mess, sizeof(mess));
|
||||
std::ostringstream os;
|
||||
os << "Detector " << detId << " (" << detector_shm()->hostname << ")" <<
|
||||
" returned error: " << mess;
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "You can now restart the detector " + std::to_string(detId) +
|
||||
" in normal mode.";
|
||||
if (ret != FAIL) {
|
||||
ret = rebootController();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3528,6 +3495,37 @@ int slsDetector::resetFPGA() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int slsDetector::copyDetectorServer(const std::string &fname, const std::string &hostname) {
|
||||
int fnum = F_COPY_DET_SERVER;
|
||||
int ret = FAIL;
|
||||
char args[2][MAX_STR_LENGTH] = {};
|
||||
sls::strcpy_safe(args[0], fname.c_str());
|
||||
sls::strcpy_safe(args[1], hostname.c_str());
|
||||
FILE_LOG(logINFO) << "Sending detector server " << args[0] << " from host " << args[1];
|
||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int slsDetector::rebootController() {
|
||||
if (detector_shm()->myDetectorType == EIGER) {
|
||||
throw RuntimeError("Reboot controller not implemented for this detector");
|
||||
}
|
||||
|
||||
int fnum = F_REBOOT_CONTROLLER;
|
||||
int ret = FAIL;
|
||||
FILE_LOG(logINFO) << "Sending reboot controller to detector " << detId << " (" << detector_shm()->hostname << ")";
|
||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort);
|
||||
client.sendData(&fnum, sizeof(fnum));
|
||||
ret = OK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::powerChip(int ival) {
|
||||
int fnum = F_POWER_CHIP;
|
||||
int ret = FAIL;
|
||||
|
@ -405,6 +405,27 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
|
||||
++i;
|
||||
|
||||
/*! \page config
|
||||
- <b>copydetectorserver [sname] [phost]</b> copies the detector server sname via tftp from pc with hostname phost and changes respawn server for all detector. Not for Eiger. Only put! \c Returns \c ("successful", "failed")
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "copydetectorserver";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
|
||||
++i;
|
||||
|
||||
/*! \page config
|
||||
- <b>rebootdetpc </b> reboot detector controller blackfin. Only put! Not for Eiger. \c Returns \c ("successful", "failed")
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "rebootcontroller";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
|
||||
++i;
|
||||
|
||||
/*! \page config
|
||||
- <b>update [sname] [phost] [file] </b> updates the firmware to file and detector server to sname from phost via tftp and then reboots controller (blackfin). Only put! Not for Eiger. \c Returns \c ("successful", "failed")
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "update";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
|
||||
++i;
|
||||
|
||||
/* chip */
|
||||
/*! \page config
|
||||
\section configchip Chip
|
||||
@ -4753,9 +4774,6 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
|
||||
if (strstr(args[1], ".pof") == nullptr)
|
||||
return std::string("wrong usage: programming file should have .pof extension");
|
||||
std::string sval = std::string(args[1]);
|
||||
#ifdef VERBOSE
|
||||
std::cout << " programming file " << sval << std::endl;
|
||||
#endif
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
if (myDet->programFPGA(sval, detPos) == OK)
|
||||
return std::string("successful");
|
||||
@ -4765,15 +4783,51 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
|
||||
else if (cmd == "resetfpga") {
|
||||
if (action == GET_ACTION)
|
||||
return std::string("cannot get");
|
||||
#ifdef VERBOSE
|
||||
std::cout << " resetting fpga " << std::endl;
|
||||
#endif
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
if (myDet->resetFPGA(detPos) == OK)
|
||||
return std::string("successful");
|
||||
return std::string("failed");
|
||||
}
|
||||
|
||||
else if (cmd == "copydetectorserver") {
|
||||
if (action == GET_ACTION)
|
||||
return std::string("cannot get");
|
||||
if (narg < 3)
|
||||
return ("wrong usage." + helpAdvanced(PUT_ACTION));
|
||||
std::string sval = std::string(args[1]);
|
||||
std::string pval = std::string(args[2]);
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
if (myDet->copyDetectorServer(sval, pval, detPos) == OK)
|
||||
return std::string("successful");
|
||||
return std::string("failed");
|
||||
}
|
||||
|
||||
else if (cmd == "rebootcontroller") {
|
||||
if (action == GET_ACTION)
|
||||
return std::string("cannot get");
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
if (myDet->rebootController(detPos) == OK)
|
||||
return std::string("successful");
|
||||
return std::string("failed");
|
||||
}
|
||||
|
||||
else if (cmd == "update") {
|
||||
if (action == GET_ACTION)
|
||||
return std::string("cannot get");
|
||||
if (narg < 4)
|
||||
return ("wrong usage." + helpAdvanced(PUT_ACTION));
|
||||
// pof
|
||||
if (strstr(args[3], ".pof") == nullptr)
|
||||
return std::string("wrong usage: programming file should have .pof extension");
|
||||
std::string sval = std::string(args[1]);
|
||||
std::string pval = std::string(args[2]);
|
||||
std::string fval = std::string(args[3]);
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
if (myDet->update(sval, pval, fval, detPos) == OK)
|
||||
return std::string("successful");
|
||||
return std::string("failed");
|
||||
}
|
||||
|
||||
else if (cmd == "powerchip") {
|
||||
char ans[100];
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
@ -4842,7 +4896,9 @@ std::string slsDetectorCommand::helpAdvanced(int action) {
|
||||
|
||||
os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl;
|
||||
os << "resetfpga f \t resets fpga, f can be any value" << std::endl;
|
||||
|
||||
os << "copydetectorserver s p \t copies the detector server s via tftp from pc with hostname p and changes respawn server. Not for Eiger. " << std::endl;
|
||||
os << "rebootcontroller \t reboot controler blackfin of the detector. Not for Eiger." << std::endl;
|
||||
os << "update s p f \t updates the firmware to f and detector server to f from host p via tftp and then reboots controller (blackfin). Not for Eiger. " << std::endl;
|
||||
os << "led s \t sets led status (0 off, 1 on)" << std::endl;
|
||||
os << "diodelay m v \tsets the delay for the digital IO pins selected by mask m and delay set by v. mask is upto 64 bits in hex, delay max is 775ps, and set in steps of 25 ps. Used for MOENCH/CTB only." << std::endl;
|
||||
os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl;
|
||||
|
Reference in New Issue
Block a user