diff --git a/slsDetectorSoftware/include/CmdProxy.h b/slsDetectorSoftware/include/CmdProxy.h index ade8ab196..69d19e6de 100644 --- a/slsDetectorSoftware/include/CmdProxy.h +++ b/slsDetectorSoftware/include/CmdProxy.h @@ -510,6 +510,7 @@ class CmdProxy { /* Pattern */ /* Moench */ /* Advanced */ + /* Insignificant */ @@ -744,6 +745,21 @@ class CmdProxy { /* Advanced */ {"programfpga", &CmdProxy::ProgramFpga}, {"resetfpga", &CmdProxy::resetfpga}, + {"copydetectorserver", &CmdProxy::CopyDetectorServer}, + {"rebootcontroller", &CmdProxy::rebootcontroller}, + {"update", &CmdProxy::UpdateFirmwareAndDetectorServer}, + {"reg", &CmdProxy::Register}, + {"adcreg", &CmdProxy::AdcRegister}, + {"setbit", &CmdProxy::BitOperations}, + {"clearbit", &CmdProxy::BitOperations}, + {"getbit", &CmdProxy::BitOperations}, + {"firmwaretest", &CmdProxy::firmwaretest}, + {"bustest", &CmdProxy::bustest}, + + /* Insignificant */ + + + @@ -814,6 +830,13 @@ class CmdProxy { std::string MinMaxEnergyThreshold(int action); /* Advanced */ std::string ProgramFpga(int action); + std::string CopyDetectorServer(int action); + std::string UpdateFirmwareAndDetectorServer(int action); + std::string Register(int action); + std::string AdcRegister(int action); + std::string BitOperations(int action); + /* Insignificant */ + @@ -1298,6 +1321,20 @@ class CmdProxy { EXECUTE_SET_COMMAND(resetfpga, resetFPGA, "\n\t[Jungfrau][Ctb] Reset FPGA."); + EXECUTE_SET_COMMAND(rebootcontroller, rebootController, + "\n\t[Jungfrau][Ctb] Reboot controler (blackfin) of detector."); + + EXECUTE_SET_COMMAND(firmwaretest, executeFirmwareTest, + "\n\t[Jungfrau][Ctb][Gotthard] Firmware test, ie. reads a read fixed pattern from a register."); + + EXECUTE_SET_COMMAND(bustest, executeBusTest, + "\n\t[Jungfrau][Ctb][Gotthard] Bus test, ie. keeps writing and reading back different values in R/W register."); + + + /* Insignificant */ + + + DAC_COMMAND(adcvpp, getDAC, setDAC, defs::ADC_VPP, "[dac or mv value][(optional unit) mv] \n\t[Ctb] Vpp of ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V."); diff --git a/slsDetectorSoftware/include/slsDetectorCommand.h b/slsDetectorSoftware/include/slsDetectorCommand.h index 982339968..911808f41 100755 --- a/slsDetectorSoftware/include/slsDetectorCommand.h +++ b/slsDetectorSoftware/include/slsDetectorCommand.h @@ -51,10 +51,8 @@ class slsDetectorCommand : public virtual slsDetectorDefs { static std::string helpSettings(int action); static std::string helpSN(int action); static std::string helpDigiTest(int action); - static std::string helpRegister(int action); static std::string helpDAC(int action); static std::string helpTimeLeft(int action); - static std::string helpAdvanced(int action); static std::string helpConfiguration(int action); static std::string helpReceiver(int action); @@ -74,10 +72,8 @@ class slsDetectorCommand : public virtual slsDetectorDefs { std::string cmdSettings(int narg, const char * const args[], int action, int detPos = -1); std::string cmdSN(int narg, const char * const args[], int action, int detPos = -1); std::string cmdDigiTest(int narg, const char * const args[], int action, int detPos = -1); - std::string cmdRegister(int narg, const char * const args[], int action, int detPos = -1); std::string cmdDAC(int narg, const char * const args[], int action, int detPos = -1); std::string cmdTimeLeft(int narg, const char * const args[], int action, int detPos = -1); - std::string cmdAdvanced(int narg, const char * const args[], int action, int detPos = -1); std::string cmdConfiguration(int narg, const char * const args[], int action, int detPos = -1); std::string cmdReceiver(int narg, const char * const args[], int action, int detPos = -1); diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 6de00dbec..18349a78c 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -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 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 \ No newline at end of file diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 91e1db2fc..5a6c1e3a9 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -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); } diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index e3095fff1..b2f7cba19 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -124,54 +124,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { /* digital test and debugging */ - /*! \page test - - bustest 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 - - firmwaretest performs the firmware test. Cannot set! Jungfrau only. Only get! - */ - descrToFuncMap[i].m_pFuncName = "firmwaretest"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDigiTest; - ++i; - - /*! \page test - - reg [addr] [val] ??? 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 - - adcreg [addr] [val] ??? 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 - - setbit ??? Only put! - */ - descrToFuncMap[i].m_pFuncName = "setbit"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdRegister; - ++i; - - /*! \page test - - clearbit ??? Only put! - */ - descrToFuncMap[i].m_pFuncName = "clearbit"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdRegister; - ++i; - - /*! \page test - - getbit ??? 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 - - copydetectorserver [sname] [phost] 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 - - rebootdetpc 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 - - update [sname] [phost] [file] 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) diff --git a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp index ad39a75c9..38d6b6628 100644 --- a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp +++ b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp @@ -9,7 +9,178 @@ auto GET = slsDetectorDefs::GET_ACTION; auto PUT = slsDetectorDefs::PUT_ACTION; -TEST_CASE("resetfpga", "[.cmd][.ctb][.jungfrau") { +TEST_CASE("adcreg", "[.cmd]") { + if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD || test::type == slsDetectorDefs::GOTTHARD) { + REQUIRE_THROWS(multiSlsDetectorClient("adcreg 0x34", PUT)); + REQUIRE_THROWS(multiSlsDetectorClient("adcreg", GET)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("adcreg 0x45 0x3", PUT)); + } +} + +TEST_CASE("bustest", "[.cmd]") { + if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD || test::type == slsDetectorDefs::GOTTHARD) { + REQUIRE_NOTHROW(multiSlsDetectorClient("bustest", PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("bustest", PUT)); + } +} + +TEST_CASE("firmwaretest", "[.cmd]") { + if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD || test::type == slsDetectorDefs::GOTTHARD) { + REQUIRE_NOTHROW(multiSlsDetectorClient("firmwaretest", PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("firmwaretest", PUT)); + } +} + +TEST_CASE("reg", "[.cmd]") { + if (test::type == slsDetectorDefs::JUNGFRAU) { + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x01", GET, nullptr, oss)); + REQUIRE(oss.str() == "reg 0xacdc2014\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x64 5", PUT, nullptr, oss)); + REQUIRE(oss.str() == "reg [0x64, 5]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, oss)); + REQUIRE(oss.str() == "frames 5\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("getbit 0x64 0", GET, nullptr, oss)); + REQUIRE(oss.str() == "getbit 1\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("setbit 0x64 1", PUT, nullptr, oss)); + REQUIRE(oss.str() == "setbit [0x64, 1]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("clearbit 0x64 0", PUT, nullptr, oss)); + REQUIRE(oss.str() == "clearbit [0x64, 0]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, oss)); + REQUIRE(oss.str() == "frames 6\n"); + } + REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); + } else if (test::type == slsDetectorDefs::GOTTHARD) { + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x023", GET, nullptr, oss)); + REQUIRE(oss.str() == "reg 0xacdc1980\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x70 5", PUT, nullptr, oss)); + REQUIRE(oss.str() == "reg [0x70, 5]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, oss)); + REQUIRE(oss.str() == "frames 5\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("getbit 0x70 0", GET, nullptr, oss)); + REQUIRE(oss.str() == "getbit 1\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("setbit 0x70 1", PUT, nullptr, oss)); + REQUIRE(oss.str() == "setbit [0x70, 1]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("clearbit 0x70 0", PUT, nullptr, oss)); + REQUIRE(oss.str() == "clearbit [0x70, 0]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, oss)); + REQUIRE(oss.str() == "frames 6\n"); + } + REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); + } else if (test::type == slsDetectorDefs::CHIPTESTBOARD) { + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x01", GET, nullptr, oss)); + REQUIRE(oss.str() == "reg 0xacdc2016\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x64 5", PUT, nullptr, oss)); + REQUIRE(oss.str() == "reg [0x64, 5]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, oss)); + REQUIRE(oss.str() == "frames 5\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("getbit 0x64 0", GET, nullptr, oss)); + REQUIRE(oss.str() == "getbit 1\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("setbit 0x64 1", PUT, nullptr, oss)); + REQUIRE(oss.str() == "setbit [0x64, 1]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("clearbit 0x64 0", PUT, nullptr, oss)); + REQUIRE(oss.str() == "clearbit [0x64, 0]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, oss)); + REQUIRE(oss.str() == "frames 6\n"); + } + REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); + } +} + +TEST_CASE("update", "[.cmd][.ctb][.jungfrau]") { + if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD) { + REQUIRE_THROWS(multiSlsDetectorClient("update", PUT)); + REQUIRE_THROWS(multiSlsDetectorClient("update jungfrauDetectorServer_developer", PUT)); + REQUIRE_THROWS(multiSlsDetectorClient("update jungfrauDetectorServer_developer pc13784", PUT)); + REQUIRE_THROWS(multiSlsDetectorClient("update jungfrauDetectorServer_developer pc13784 dfd.pff", PUT)); + REQUIRE_NOTHROW(multiSlsDetectorClient("update jungfrauDetectorServer_developer pc13784 /afs/psi.ch/project/sls_det_firmware/jungfrau_firmware/cyclone_V/v0_8/Jungfrau_MCB.pof", PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("update", GET)); + } +} + +TEST_CASE("copydetectorserver", "[.cmd][.ctb][.jungfrau]") { + if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD) { + REQUIRE_THROWS(multiSlsDetectorClient("copydetectorserver", PUT)); + REQUIRE_THROWS(multiSlsDetectorClient("copydetectorserver jungfrauDetectorServer_developer", PUT)); + REQUIRE_NOTHROW(multiSlsDetectorClient("copydetectorserver jungfrauDetectorServer_developer pc13784", PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("copydetectorserver", GET)); + } +} + +TEST_CASE("rebootcontroller", "[.cmd][.ctb][.jungfrau]") { + if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(multiSlsDetectorClient("rebootcontroller", PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("rebootcontroller", GET)); + } +} + + +TEST_CASE("resetfpga", "[.cmd][.ctb][.jungfrau]") { if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD) { REQUIRE_NOTHROW(multiSlsDetectorClient("resetfpga", PUT)); } else { @@ -17,7 +188,7 @@ TEST_CASE("resetfpga", "[.cmd][.ctb][.jungfrau") { } } -TEST_CASE("programfpga", "[.cmd][.ctb][.jungfrau") { +TEST_CASE("programfpga", "[.cmd][.ctb][.jungfrau]") { if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD) { REQUIRE_THROWS(multiSlsDetectorClient("programfpga fdgd.oki", PUT)); } else {