diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 97eca3195..70a1f134e 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 6fdf65f13..49daf9313 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index fb33ceb3c..38678d1e8 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index ad450f1b7..aef4450aa 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 3a5765d5e..2123fd90d 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index e2e5f6918..a5efb58eb 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index ecf80e34f..da0b64bef 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 15b0fe1a0..54f0919b2 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -151,7 +151,7 @@ int get_read_n_lines(int); void calculate_and_set_position(); int set_detector_position(int); int check_detector_idle(); -int is_configurable(); +int is_udp_configured(); void configure_mac(); int set_source_udp_ip(int); int get_source_udp_ip(int); @@ -236,4 +236,6 @@ int set_filter(int); int get_adc_config(int); int set_adc_config(int); int get_bad_channels(int); -int set_bad_channels(int); \ No newline at end of file +int set_bad_channels(int); +int reconfigure_udp(int); +int validate_udp_configuration(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 2b5d2c1f4..8a1323660 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -354,6 +354,8 @@ void function_table() { flist[F_SET_ADC_CONFIGURATION] = &set_adc_config; flist[F_GET_BAD_CHANNELS] = &get_bad_channels; flist[F_SET_BAD_CHANNELS] = &set_bad_channels; + flist[F_RECONFIGURE_UDP] = &reconfigure_udp; + flist[F_VALIDATE_UDP_CONFIG] = &validate_udp_configuration; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -4864,14 +4866,14 @@ int check_detector_idle() { return ret; } -int is_configurable() { - if (udpDetails.srcip == 0) { - strcpy(configureMessage, "udp source ip not configured\n"); +int is_udp_configured() { + if (udpDetails.dstip == 0) { + strcpy(configureMessage, "udp destination ip not configured\n"); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } - if (udpDetails.dstip == 0) { - strcpy(configureMessage, "udp destination ip not configured\n"); + if (udpDetails.srcip == 0) { + strcpy(configureMessage, "udp source ip not configured\n"); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } @@ -4913,7 +4915,7 @@ int is_configurable() { } void configure_mac() { - if (is_configurable() == OK) { + if (is_udp_configured() == OK) { ret = configureMAC(); if (ret != OK) { #if defined(CHIPTESTBOARDD) || defined(MOENCHD) @@ -7391,7 +7393,7 @@ int set_veto(int file_des) { setVeto(arg); // if numinterfaces is 2 and veto is 1 now, then configuremac if (arg > 0 && getNumberofUDPInterfaces() == 2 && - is_configurable() == OK) { + is_udp_configured() == OK) { ret = configureMAC(); if (ret != OK) { sprintf(mess, "Configure Mac failed after enabling veto\n"); @@ -7976,3 +7978,37 @@ int set_bad_channels(int file_des) { #endif return Server_SendResult(file_des, INT32, NULL, 0); } + +int reconfigure_udp(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + + if (Server_VerifyLock() == OK) { + LOG(logINFO, ("Reconfiguring UDP\n")); + if (check_detector_idle() == OK) { + configure_mac(); + if (configured == FAIL) { + ret = FAIL; + strcpy(mess, "Invalid UDP Configuration because "); + strcat(mess, configureMessage); + LOG(logERROR, (mess)); + } + } + } + return Server_SendResult(file_des, INT32, NULL, 0); +} + +int validate_udp_configuration(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + + LOG(logINFO, ("Validating UDP Configuration\n")); + if (configured == FAIL) { + ret = FAIL; + strcpy(mess, "Invalid UDP Configuration because "); + strcat(mess, configureMessage); + LOG(logERROR, (mess)); + } + + return Server_SendResult(file_des, INT32, NULL, 0); +} \ No newline at end of file diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 2152a0135..989900c01 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -509,6 +509,10 @@ class Detector { */ void setDestinationUDPPort2(int port, int module_id = -1); + void reconfigureUDPDestination(Positions pos = {}); + + void validateUDPConfiguration(Positions pos = {}); + Result printRxConfiguration(Positions pos = {}) const; /** [Eiger][CTB][Moench][Mythen3] */ diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 28c7cbe58..6a325c7eb 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -776,6 +776,8 @@ class CmdProxy { {"udp_dstmac2", &CmdProxy::udp_dstmac2}, {"udp_dstport", &CmdProxy::udp_dstport}, {"udp_dstport2", &CmdProxy::udp_dstport2}, + {"udp_reconfigure", &CmdProxy::udp_reconfigure}, + {"udp_validate", &CmdProxy::udp_validate}, {"rx_printconfig", &CmdProxy::rx_printconfig}, {"tengiga", &CmdProxy::tengiga}, {"flowcontrol10g", &CmdProxy::flowcontrol10g}, @@ -1645,6 +1647,18 @@ class CmdProxy { "sent to. \n[Eiger] Port number of the reciever (desintation) udp " "interface where the right half of the detector data is sent to."); + EXECUTE_SET_COMMAND( + udp_reconfigure, reconfigureUDPDestination, + "\n\tReconfigures Detector with UDP destination. More for debugging as " + "the configuration is done automatically when the detector has " + "sufficient UDP details."); + + EXECUTE_SET_COMMAND( + udp_validate, validateUDPConfiguration, + "\n\tValidates that UDP configuration in the detector is " + "valid. If not configured, it will throw with error message " + "requesting missing udp information."); + GET_COMMAND(rx_printconfig, printRxConfiguration, "\n\tPrints the receiver configuration."); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 5819ce8d8..de1b90f9b 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -716,6 +716,14 @@ void Detector::setDestinationUDPPort2(int port, int module_id) { } } +void Detector::reconfigureUDPDestination(Positions pos) { + pimpl->Parallel(&Module::reconfigureUDPDestination, pos); +} + +void Detector::validateUDPConfiguration(Positions pos) { + pimpl->Parallel(&Module::validateUDPConfiguration, pos); +} + Result Detector::printRxConfiguration(Positions pos) const { return pimpl->Parallel(&Module::printReceiverConfiguration, pos); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index f61cfd143..5a86a925c 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -638,6 +638,12 @@ void Module::setDestinationUDPPort2(const int port) { } } +void Module::reconfigureUDPDestination() { sendToDetector(F_RECONFIGURE_UDP); } + +void Module::validateUDPConfiguration() { + sendToDetector(F_VALIDATE_UDP_CONFIG); +} + std::string Module::printReceiverConfiguration() { std::ostringstream os; os << "\n\nDetector " << moduleId << "\nReceiver Hostname:\t" diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index d1c9cc93a..79e1b4936 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -202,6 +202,8 @@ class Module : public virtual slsDetectorDefs { void setDestinationUDPPort(int udpport); int getDestinationUDPPort2() const; void setDestinationUDPPort2(int udpport); + void reconfigureUDPDestination(); + void validateUDPConfiguration(); std::string printReceiverConfiguration(); bool getTenGiga() const; void setTenGiga(bool value); diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 401d266e7..c75a36746 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -1268,28 +1268,28 @@ TEST_CASE("scan", "[.cmd][.new]") { proxy.Call("scan", {sls::ToString(ind), "500", "1500", "500"}, -1, PUT, oss); CHECK(oss.str() == - "scan [" + sls::ToString(ind) + ", 500, 1500, 500]\n"); + "scan [" + sls::ToString(ind) + ", 500, 1500, 500]\n"); } { std::ostringstream oss; proxy.Call("scan", {}, -1, GET, oss); CHECK(oss.str() == "scan [enabled\ndac " + sls::ToString(ind) + - "\nstart 500\nstop 1500\nstep " - "500\nsettleTime 1ms\n]\n"); + "\nstart 500\nstop 1500\nstep " + "500\nsettleTime 1ms\n]\n"); } { std::ostringstream oss; proxy.Call("scan", {sls::ToString(ind), "500", "1500", "500", "2s"}, -1, PUT, oss); CHECK(oss.str() == - "scan [" + sls::ToString(ind) + ", 500, 1500, 500, 2s]\n"); + "scan [" + sls::ToString(ind) + ", 500, 1500, 500, 2s]\n"); } { std::ostringstream oss; proxy.Call("scan", {}, -1, GET, oss); CHECK(oss.str() == "scan [enabled\ndac " + sls::ToString(ind) + - "\nstart 500\nstop 1500\nstep " - "500\nsettleTime 2s\n]\n"); + "\nstart 500\nstop 1500\nstep " + "500\nsettleTime 2s\n]\n"); } { std::ostringstream oss; @@ -1306,15 +1306,15 @@ TEST_CASE("scan", "[.cmd][.new]") { proxy.Call("scan", {sls::ToString(ind), "1500", "500", "-500"}, -1, PUT, oss); CHECK(oss.str() == - "scan [" + sls::ToString(ind) + ", 1500, 500, -500]\n"); + "scan [" + sls::ToString(ind) + ", 1500, 500, -500]\n"); } CHECK_THROWS(proxy.Call( "scan", {sls::ToString(notImplementedInd), "500", "1500", "500"}, -1, PUT)); - CHECK_THROWS(proxy.Call( - "scan", {sls::ToString(ind), "500", "1500", "-500"}, -1, PUT)); - CHECK_THROWS(proxy.Call( - "scan", {sls::ToString(ind), "1500", "500", "500"}, -1, PUT)); + CHECK_THROWS(proxy.Call("scan", {sls::ToString(ind), "500", "1500", "-500"}, + -1, PUT)); + CHECK_THROWS(proxy.Call("scan", {sls::ToString(ind), "1500", "500", "500"}, + -1, PUT)); if (det_type == defs::MYTHEN3 || defs::EIGER) { { @@ -1327,12 +1327,12 @@ TEST_CASE("scan", "[.cmd][.new]") { std::ostringstream oss; proxy.Call("scan", {}, -1, GET, oss); CHECK(oss.str() == - "scan [enabled\ndac trimbit_scan\nstart 0\nstop 48\nstep " - "16\nsettleTime 2s\n]\n"); + "scan [enabled\ndac trimbit_scan\nstart 0\nstop 48\nstep " + "16\nsettleTime 2s\n]\n"); } } - //Switch off scan for future tests + // Switch off scan for future tests det.setScan(defs::scanParameters()); // acquire for each? @@ -1562,6 +1562,20 @@ TEST_CASE("udp_dstport2", "[.cmd][.new]") { } } +TEST_CASE("udp_reconfigure", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_THROWS(proxy.Call("udp_reconfigure", {}, -1, GET)); + REQUIRE_NOTHROW(proxy.Call("udp_reconfigure", {}, -1, PUT)); +} + +TEST_CASE("udp_validate", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_THROWS(proxy.Call("udp_validate", {}, -1, GET)); + REQUIRE_NOTHROW(proxy.Call("udp_validate", {}, -1, PUT)); +} + TEST_CASE("tengiga", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index 9692d2dc5..fc78512f3 100755 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -211,6 +211,8 @@ enum detFuncs { F_SET_ADC_CONFIGURATION, F_GET_BAD_CHANNELS, F_SET_BAD_CHANNELS, + F_RECONFIGURE_UDP, + F_VALIDATE_UDP_CONFIG, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -523,6 +525,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_GET_ADC_CONFIGURATION: return "F_GET_ADC_CONFIGURATION"; case F_GET_BAD_CHANNELS: return "F_GET_BAD_CHANNELS"; case F_SET_BAD_CHANNELS: return "F_SET_BAD_CHANNELS"; + case F_RECONFIGURE_UDP: return "F_RECONFIGURE_UDP"; + case F_VALIDATE_UDP_CONFIG: return "F_VALIDATE_UDP_CONFIG"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index c08c6ca18..257ab9a05 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -3,10 +3,10 @@ #define APILIB 0x200409 #define APIRECEIVER 0x200409 #define APIGUI 0x200409 -#define APIEIGER 0x200729 -#define APICTB 0x200729 -#define APIGOTTHARD 0x200729 -#define APIJUNGFRAU 0x200729 -#define APIMOENCH 0x200729 -#define APIGOTTHARD2 0x200730 -#define APIMYTHEN3 0x200804 +#define APICTB 0x200805 +#define APIGOTTHARD 0x200805 +#define APIGOTTHARD2 0x200805 +#define APIJUNGFRAU 0x200805 +#define APIMYTHEN3 0x200805 +#define APIMOENCH 0x200804 +#define APIEIGER 0x200805