mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
WIP
This commit is contained in:
@ -1329,5 +1329,144 @@ std::string CmdProxy::ProgramFpga(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::CopyDetectorServer(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[server_name] [pc_host_name]\n\t[Jungfrau][Ctb] Copies detector server via tftp from pc and changes respawn server name in /etc/inittab of detector." << '\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], {det_id});
|
||||
os << "successful\n";
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[server_name] [pc_host_name] [fname.pof]\n\t[Jungfrau][Ctb] Updates detector server via tftp from pc, updates firmware to pof file and then reboots controller (blackfin)." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 3) {
|
||||
WrongNumberOfParameters(3);
|
||||
}
|
||||
if (args[2].find(".pof") == std::string::npos) {
|
||||
throw sls::RuntimeError("Programming file must be a pof file.");
|
||||
}
|
||||
det->updateFirmwareAndServer(args[0], args[1], args[2], {det_id});
|
||||
os << "successful\n";
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::Register(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[address] [32 bit value]\n\tReads/writes to a 32 bit register in hex.\n\t[Eiger] +0x100 for only left, +0x200 for only right" << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->readRegister(stoiHex(args[0]), {det_id});
|
||||
os << OutStringHex(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->writeRegister(stoiHex(args[0]), stoiHex(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::AdcRegister(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[address] [value]\n\t[Jungfrau][Ctb][Gotthard] Writes to an adc register in hex." << '\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->writeAdcRegister(stoiHex(args[0]), stoiHex(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::BitOperations(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
if (cmd == "setbit") {
|
||||
os << "[address] [value\n\t[Moench] Minimum energy threshold (soft setting) for processor." << '\n';
|
||||
} else if (cmd == "clearbit") {
|
||||
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft setting) for processor." << '\n';
|
||||
} else if (cmd == "getbit") {
|
||||
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft setting) for processor." << '\n';
|
||||
}else {
|
||||
throw sls::RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
} else {
|
||||
if (cmd != "setbit" && cmd != "clearbit" && cmd != "getbit") {
|
||||
throw sls::RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
uint32_t addr = stoiHex(args[0]);
|
||||
int bitnr = std::stoi(args[1]);
|
||||
if (bitnr < 0 || bitnr > 31) {
|
||||
return std::string("Bit number out of range") + std::to_string(bitnr);
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
if (cmd == "setbit" || cmd == "clearbit") {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
}
|
||||
auto t = det->readRegister(addr, {det_id});
|
||||
Result<int> result(t.size());
|
||||
for (unsigned int i = 0; i < t.size(); ++i) {
|
||||
result[i] = ((t[i] >> bitnr) & 0x1);
|
||||
}
|
||||
os << OutString(result) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (cmd == "getbit") {
|
||||
throw sls::RuntimeError("Cannot put");
|
||||
}
|
||||
if (cmd == "setbit") {
|
||||
det->setBit(addr, bitnr, {det_id});
|
||||
} else if (cmd == "clearbit") {
|
||||
det->clearBit(addr, bitnr, {det_id});
|
||||
}
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
/* Insignificant */
|
||||
|
||||
|
||||
|
||||
} // namespace sls
|
@ -1487,7 +1487,7 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
|
||||
const std::string &hostname,
|
||||
const std::string &fname,
|
||||
Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::copyDetectorServer, pos, fname, hostname);
|
||||
pimpl->Parallel(&slsDetector::copyDetectorServer, pos, sname, hostname);
|
||||
programFPGA(fname, pos);
|
||||
rebootController(pos);
|
||||
}
|
||||
|
@ -124,54 +124,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
|
||||
/* digital test and debugging */
|
||||
|
||||
/*! \page test
|
||||
- <b>bustest</b> performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes. Cannot set! Jungfrau only. Only get!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "bustest";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDigiTest;
|
||||
++i;
|
||||
|
||||
/*! \page test
|
||||
- <b>firmwaretest</b> performs the firmware test. Cannot set! Jungfrau only. Only get!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "firmwaretest";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDigiTest;
|
||||
++i;
|
||||
|
||||
/*! \page test
|
||||
- <b>reg [addr] [val]</b> ??? writes to an register \c addr with \c value in hexadecimal format.
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "reg";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdRegister;
|
||||
++i;
|
||||
|
||||
/*! \page test
|
||||
- <b>adcreg [addr] [val]</b> ??? writes to an adc register \c addr with \c value in hexadecimal format. Only put!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "adcreg";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdRegister;
|
||||
++i;
|
||||
|
||||
/*! \page test
|
||||
- <b>setbit</b> ??? Only put!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "setbit";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdRegister;
|
||||
++i;
|
||||
|
||||
/*! \page test
|
||||
- <b>clearbit </b> ??? Only put!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "clearbit";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdRegister;
|
||||
++i;
|
||||
|
||||
/*! \page test
|
||||
- <b>getbit </b> ??? Only get!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "getbit";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdRegister;
|
||||
++i;
|
||||
|
||||
/* Acquisition and status commands */
|
||||
/*! \page acquisition Acquition commands
|
||||
@ -253,28 +206,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
commands to configure detector flags
|
||||
*/
|
||||
|
||||
/* fpga */
|
||||
|
||||
/*! \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
|
||||
@ -1384,123 +1315,6 @@ std::string slsDetectorCommand::helpDigiTest(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdRegister(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpRegister(action);
|
||||
|
||||
int addr, val, n;
|
||||
char answer[1000];
|
||||
|
||||
|
||||
// "reg" //
|
||||
|
||||
// "setbit" //
|
||||
|
||||
// "clearbit" //
|
||||
|
||||
// "getbit" //
|
||||
|
||||
if (action == PUT_ACTION) {
|
||||
if (cmd == "getbit")
|
||||
return std::string("Cannot put");
|
||||
|
||||
if (narg < 3) {
|
||||
if (cmd == "reg")
|
||||
return std::string("wrong usage: should specify both address and value (hexadecimal fomat) ");
|
||||
else
|
||||
return std::string("wrong usage: should specify both address (hexadecimal fomat) and bit number");
|
||||
}
|
||||
|
||||
if (sscanf(args[1], "%x", &addr))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan address (hexadecimal fomat) ") + std::string(args[1]);
|
||||
|
||||
if (cmd == "reg") {
|
||||
if (sscanf(args[2], "%x", &val))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan value (hexadecimal fomat) ") + std::string(args[2]);
|
||||
sprintf(answer, "0x%x", myDet->writeRegister(addr, val, detPos));
|
||||
} else if (cmd == "adcreg") {
|
||||
if (sscanf(args[2], "%x", &val))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan value (hexadecimal fomat) ") + std::string(args[2]);
|
||||
myDet->writeAdcRegister(addr, val, detPos);
|
||||
sprintf(answer, "%s","successful");
|
||||
} else {
|
||||
|
||||
if (sscanf(args[2], "%d", &n))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan bit number ") + std::string(args[2]);
|
||||
|
||||
if (n < 0 || n > 31)
|
||||
return std::string("Bit number out of range") + std::string(args[2]);
|
||||
|
||||
if (cmd == "setbit")
|
||||
sprintf(answer, "0x%x", myDet->setBit(addr, n, detPos));
|
||||
if (cmd == "clearbit")
|
||||
sprintf(answer, "0x%x", myDet->clearBit(addr, n, detPos));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (cmd == "setbit")
|
||||
return std::string("Cannot get");
|
||||
if (cmd == "clearbit")
|
||||
return std::string("Cannot get");
|
||||
if (cmd == "adcreg")
|
||||
return std::string("Cannot get");
|
||||
|
||||
if (cmd == "reg") {
|
||||
if (narg < 2)
|
||||
return std::string("wrong usage: should specify address (hexadecimal fomat) ");
|
||||
if (sscanf(args[1], "%x", &addr))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan address (hexadecimal fomat) ") + std::string(args[1]);
|
||||
|
||||
sprintf(answer, "0x%x", myDet->readRegister(addr, detPos));
|
||||
}
|
||||
|
||||
if (cmd == "getbit") {
|
||||
|
||||
if (narg < 3)
|
||||
return std::string("wrong usage: should specify both address (hexadecimal fomat) and bit number");
|
||||
|
||||
if (sscanf(args[1], "%x", &addr))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan address (hexadecimal fomat) ") + std::string(args[1]);
|
||||
|
||||
if (sscanf(args[2], "%d", &n))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan bit number ") + std::string(args[2]);
|
||||
|
||||
if (n < 0 || n > 31)
|
||||
return std::string("Bit number out of range") + std::string(args[2]);
|
||||
|
||||
sprintf(answer, "%d", (myDet->readRegister(addr, detPos) >> n) & 1);
|
||||
}
|
||||
}
|
||||
|
||||
return std::string(answer);
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::helpRegister(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
if (action == PUT_ACTION || action == HELP_ACTION) {
|
||||
os << "reg addr val \n writes the register addr with the value val (hexadecimal format)" << std::endl;
|
||||
}
|
||||
if (action == GET_ACTION || action == HELP_ACTION) {
|
||||
os << "reg addr \n reads the register addr" << std::endl;
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdDAC(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
@ -1896,61 +1710,6 @@ std::string slsDetectorCommand::helpTimeLeft(int action) {
|
||||
}
|
||||
|
||||
|
||||
std::string slsDetectorCommand::cmdAdvanced(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpAdvanced(action);
|
||||
|
||||
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->copyDetectorServer(sval, pval, detPos);
|
||||
return std::string("successful");
|
||||
}
|
||||
|
||||
else if (cmd == "rebootcontroller") {
|
||||
if (action == GET_ACTION)
|
||||
return std::string("cannot get");
|
||||
myDet->rebootController(detPos);
|
||||
return std::string("successful");
|
||||
}
|
||||
|
||||
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->update(sval, pval, fval, detPos);
|
||||
return std::string("successful");
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
return std::string("unknown command ") + cmd;
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::helpAdvanced(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
if (action == PUT_ACTION || action == HELP_ACTION) {
|
||||
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;
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdConfiguration(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
|
Reference in New Issue
Block a user