diff --git a/python/slsdet/utils.py b/python/slsdet/utils.py index ae7de4815..f7d4fbd9d 100755 --- a/python/slsdet/utils.py +++ b/python/slsdet/utils.py @@ -41,7 +41,7 @@ def list_to_bitmask(values): return mask def make_bitmask(args): - if isinstance(args, list): + if isinstance(args, (list,tuple)): return list_to_bitmask(args) elif isinstance(args, dict): return {key: list_to_bitmask(value) for key, value in args.items()} diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 7279a1c88..1c5e94dd2 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index 7c65c6bf0..e7f57a896 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -392,7 +392,7 @@ uint32_t getDetectorIP() { #ifdef VIRTUAL return 0; #endif - char temp[50] = ""; + char temp[INET_ADDRSTRLEN] = ""; uint32_t res = 0; // execute and get address char output[255]; @@ -1525,10 +1525,10 @@ int configureMAC() { int dstport = udpDetails[0].dstport; LOG(logINFOBLUE, ("Configuring MAC\n")); - char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], - dst_ip[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac, 50, srcmac); - getMacAddressinString(dst_mac, 50, dstmac); + char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN], + dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac); + getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac); getIpAddressinString(src_ip, srcip); getIpAddressinString(dst_ip, dstip); diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 6fa9f695b..1f1aa45ae 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 0bfdcfb31..6bce9df6b 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -263,7 +263,7 @@ u_int64_t getDetectorMAC() { } u_int32_t getDetectorIP() { - char temp[50] = ""; + char temp[INET_ADDRSTRLEN] = ""; u_int32_t res = 0; // execute and get address char output[255]; @@ -1531,10 +1531,10 @@ int configureMAC() { int dstport = udpDetails[iRxEntry].dstport; int dstport2 = udpDetails[iRxEntry].dstport2; - char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], - dst_ip[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac, 50, srcmac); - getMacAddressinString(dst_mac, 50, dstmac); + char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN], + dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac); + getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac); getIpAddressinString(src_ip, srcip); getIpAddressinString(dst_ip, dstip); diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index a3db0dbc8..f4189359f 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 084a50951..708f0bd12 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -326,7 +326,7 @@ u_int32_t getDetectorIP() { #ifdef VIRTUAL return 0; #endif - char temp[50] = ""; + char temp[INET_ADDRSTRLEN] = ""; u_int32_t res = 0; // execute and get address char output[255]; @@ -1749,16 +1749,16 @@ int configureMAC() { int dstport2 = udpDetails[0].dstport2; LOG(logINFOBLUE, ("Configuring MAC\n")); - char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], - dst_ip[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac, 50, srcmac); - getMacAddressinString(dst_mac, 50, dstmac); + char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN], + dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac); + getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac); getIpAddressinString(src_ip, srcip); getIpAddressinString(dst_ip, dstip); - char src_mac2[50], src_ip2[INET_ADDRSTRLEN], dst_mac2[50], - dst_ip2[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac2, 50, srcmac2); - getMacAddressinString(dst_mac2, 50, dstmac2); + char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN], + dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2); + getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2); getIpAddressinString(src_ip2, srcip2); getIpAddressinString(dst_ip2, dstip2); diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index 0bbddd66d..86541ecdc 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index 453493943..895042dd6 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -315,7 +315,7 @@ u_int32_t getDetectorIP() { #ifdef VIRTUAL return 0; #endif - char temp[50] = ""; + char temp[INET_ADDRSTRLEN] = ""; u_int32_t res = 0; // execute and get address char output[255]; @@ -1340,10 +1340,10 @@ int configureMAC() { int dstport = udpDetails[0].dstport; LOG(logINFOBLUE, ("Configuring MAC\n")); - char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], - dst_ip[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac, 50, srcmac); - getMacAddressinString(dst_mac, 50, dstmac); + char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN], + dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac); + getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac); getIpAddressinString(src_ip, srcip); getIpAddressinString(dst_ip, dstip); diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 6b15477eb..578c6815d 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index efeb45544..a63984352 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -52,9 +52,6 @@ int detPos[4] = {}; int chipVersion = 10; // (1.0) int chipConfigured = 0; -// until firmware is done -int temp_readNRows = 512; - int isInitCheckDone() { return initCheckDone; } int getInitResult(char **mess) { @@ -337,7 +334,7 @@ u_int32_t getDetectorIP() { #ifdef VIRTUAL return 0; #endif - char temp[50] = ""; + char temp[INET_ADDRSTRLEN] = ""; u_int32_t res = 0; // execute and get address char output[255]; @@ -1480,16 +1477,16 @@ int configureMAC() { int dstport = udpDetails[iRxEntry].dstport; int dstport2 = udpDetails[iRxEntry].dstport2; - char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], - dst_ip[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac, 50, srcmac); - getMacAddressinString(dst_mac, 50, dstmac); + char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN], + dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac); + getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac); getIpAddressinString(src_ip, srcip); getIpAddressinString(dst_ip, dstip); - char src_mac2[50], src_ip2[INET_ADDRSTRLEN], dst_mac2[50], - dst_ip2[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac2, 50, srcmac2); - getMacAddressinString(dst_mac2, 50, dstmac2); + char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN], + dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2); + getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2); getIpAddressinString(src_ip2, srcip2); getIpAddressinString(dst_ip2, dstip2); @@ -1642,11 +1639,6 @@ int setReadNRows(int value) { return FAIL; } - // will be replaced when firmware is fixed - LOG(logWARNING, ("Setting number of rows: %d (Not implemented in firmware yet)\n", value)); - temp_readNRows = value; - return OK; - // regval is numpackets - 1 int regval = (value / READ_N_ROWS_MULTIPLE) - 1; uint32_t addr = READ_N_ROWS_REG; @@ -1665,10 +1657,6 @@ int setReadNRows(int value) { } int getReadNRows() { - - // will be replaced when firmware is fixed - return temp_readNRows; - int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK); int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >> READ_N_ROWS_NUM_ROWS_OFST); diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index bdf7dc747..cae2ffd5b 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 45bda6da6..bdda08571 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -389,7 +389,7 @@ uint32_t getDetectorIP() { #ifdef VIRTUAL return 0; #endif - char temp[50] = ""; + char temp[INET_ADDRSTRLEN] = ""; uint32_t res = 0; // execute and get address char output[255]; @@ -1190,10 +1190,10 @@ int configureMAC() { int dstport = udpDetails[0].dstport; LOG(logINFOBLUE, ("Configuring MAC\n")); - char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], - dst_ip[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac, 50, srcmac); - getMacAddressinString(dst_mac, 50, dstmac); + char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN], + dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac); + getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac); getIpAddressinString(src_ip, srcip); getIpAddressinString(dst_ip, dstip); diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index f729bdf4f..40fa76d69 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 6d3a22451..2adda51b8 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -312,7 +312,7 @@ u_int32_t getDetectorIP() { #ifdef VIRTUAL return 0; #endif - char temp[50] = ""; + char temp[INET_ADDRSTRLEN] = ""; u_int32_t res = 0; // execute and get address char output[255]; @@ -1720,10 +1720,10 @@ int configureMAC() { int dstport = udpDetails[0].dstport; LOG(logINFOBLUE, ("Configuring MAC\n")); - char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], - dst_ip[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac, 50, srcmac); - getMacAddressinString(dst_mac, 50, dstmac); + char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN], + dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac); + getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac); getIpAddressinString(src_ip, srcip); getIpAddressinString(dst_ip, dstip); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 447d94ca5..4fc6468d0 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -52,6 +52,7 @@ typedef struct udpStruct_s { uint32_t dstip; uint32_t dstip2; } udpStruct; +#define MAC_ADDRESS_SIZE 18 // basic tests int isInitCheckDone(); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index fdaab4dfb..85ddc30b4 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -1757,8 +1757,8 @@ int acquire(int blocking, int file_des) { if (udpDetails[0].srcmac != getDetectorMAC()) { ret = FAIL; uint64_t sourcemac = getDetectorMAC(); - char src_mac[50]; - getMacAddressinString(src_mac, 50, sourcemac); + char src_mac[MAC_ADDRESS_SIZE]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac); sprintf(mess, "Invalid udp source mac address for this detector. Must be " "same as hardware detector mac address %s\n", @@ -4870,8 +4870,8 @@ void calculate_and_set_position() { else { // create detector mac from x and y if (udpDetails[0].srcmac == 0) { - char dmac[50]; - memset(dmac, 0, 50); + char dmac[MAC_ADDRESS_SIZE]; + memset(dmac, 0, MAC_ADDRESS_SIZE); sprintf(dmac, "aa:bb:cc:dd:%02x:%02x", pos[0] & 0xFF, pos[1] & 0xFF); LOG(logINFO, ("Udp source mac address created: %s\n", dmac)); @@ -4890,8 +4890,8 @@ void calculate_and_set_position() { #if defined(JUNGFRAUD) || defined(GOTTHARD2D) if (getNumberofUDPInterfaces() > 1) { if (udpDetails[0].srcmac2 == 0) { - char dmac2[50]; - memset(dmac2, 0, 50); + char dmac2[MAC_ADDRESS_SIZE]; + memset(dmac2, 0, MAC_ADDRESS_SIZE); sprintf(dmac2, "aa:bb:cc:dd:%02x:%02x", (pos[0] + 1) & 0xFF, pos[1] & 0xFF); LOG(logINFO, ("Udp source mac address2 created: %s\n", dmac2)); @@ -9095,9 +9095,9 @@ int get_dest_udp_list(int file_des) { char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN]; getIpAddressinString(ip, retvals[3]); getIpAddressinString(ip2, retvals[4]); - char mac[50], mac2[50]; - getMacAddressinString(mac, 50, retvals64[0]); - getMacAddressinString(mac2, 50, retvals64[1]); + char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE]; + getMacAddressinString(mac, MAC_ADDRESS_SIZE, retvals64[0]); + getMacAddressinString(mac2, MAC_ADDRESS_SIZE, retvals64[1]); LOG(logDEBUG1, ("Udp Dest. retval [%d]: [port %d, port2 %d, ip %s, ip2 %s, " "mac %s, mac2 %s]\n", @@ -9131,9 +9131,9 @@ int set_dest_udp_list(int file_des) { char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN]; getIpAddressinString(ip, args[3]); getIpAddressinString(ip2, args[4]); - char mac[50], mac2[50]; - getMacAddressinString(mac, 50, args64[0]); - getMacAddressinString(mac2, 50, args64[1]); + char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE]; + getMacAddressinString(mac, MAC_ADDRESS_SIZE, args64[0]); + getMacAddressinString(mac2, MAC_ADDRESS_SIZE, args64[1]); #if !defined(EIGERD) && !defined(JUNGFRAUD) functionNotImplemented(); diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 960c0545d..e0c3e8993 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -667,10 +667,10 @@ class Detector { /** [Jungfrau] bottom half [Gotthard2] veto debugging */ void setSourceUDPMAC2(const MacAddr mac, Positions pos = {}); - Result - getDestinationUDPList(const uint32_t entry, Positions pos = {}) const; + Result getDestinationUDPList(const uint32_t entry, + Positions pos = {}) const; - void setDestinationUDPList(const defs::udpDestination, const int module_id); + void setDestinationUDPList(const UdpDestination, const int module_id); /** [Jungfrau][Eiger] */ Result getNumberofUDPDestinations(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index ee5c5edda..2f66ad821 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1379,15 +1379,8 @@ IpAddr CmdProxy::getIpFromAuto() { return val; } -defs::udpDestination CmdProxy::getUdpList() { - uint32_t entry{}; - uint32_t port{}; - uint32_t port2{}; - uint32_t ip{}; - uint32_t ip2{}; - uint64_t mac{}; - uint64_t mac2{}; - +UdpDestination CmdProxy::getUdpEntry() { + UdpDestination udpDestination{}; bool hasEntry = false; for (auto it : args) { @@ -1395,40 +1388,40 @@ defs::udpDestination CmdProxy::getUdpList() { std::string key = it.substr(0, pos); std::string value = it.substr(pos + 1); if (key == "entry") { - entry = StringTo(value); + udpDestination.entry = StringTo(value); hasEntry = true; } else if (key == "ip") { if (value == "auto") { auto val = getIpFromAuto(); LOG(logINFO) << "Setting udp_dstip of detector " << det_id << " to " << val; - ip = val.uint32(); + udpDestination.ip = val; } else { - ip = IpAddr(value).uint32(); + udpDestination.ip = IpAddr(value); } } else if (key == "ip2") { if (value == "auto") { auto val = getIpFromAuto(); LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id << " to " << val; - ip2 = val.uint32(); + udpDestination.ip2 = val; } else { - ip2 = IpAddr(value).uint32(); + udpDestination.ip2 = IpAddr(value); } } else if (key == "mac") { - mac = MacAddr(value).uint64(); + udpDestination.mac = MacAddr(value); } else if (key == "mac2") { - mac2 = MacAddr(value).uint64(); + udpDestination.mac2 = MacAddr(value); } else if (key == "port") { - port = StringTo(value); + udpDestination.port = StringTo(value); } else if (key == "port2") { - port2 = StringTo(value); + udpDestination.port2 = StringTo(value); } } if (!hasEntry) { throw sls::RuntimeError("Found no entry argument."); } - return defs::udpDestination(entry, port, ip, mac, port2, ip2, mac2); + return udpDestination; } std::string CmdProxy::UDPDestinationList(int action) { @@ -1454,7 +1447,7 @@ std::string CmdProxy::UDPDestinationList(int action) { if (args.empty()) { WrongNumberOfParameters(1); } - auto t = getUdpList(); + auto t = getUdpEntry(); det->setDestinationUDPList(t, det_id); os << ToString(args) << std::endl; } else { diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index d1e536f37..eb7d74c11 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1117,7 +1117,7 @@ class CmdProxy { std::string Trigger(int action); /* Network Configuration (Detector<->Receiver) */ IpAddr getIpFromAuto(); - slsDetectorDefs::udpDestination getUdpList(); + UdpDestination getUdpEntry(); std::string UDPDestinationList(int action); std::string UDPDestinationIP(int action); std::string UDPDestinationIP2(int action); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 3e316e984..eb752baa4 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -908,12 +908,12 @@ void Detector::setSourceUDPMAC2(const MacAddr mac, Positions pos) { pimpl->Parallel(&Module::setSourceUDPMAC2, pos, mac); } -Result -Detector::getDestinationUDPList(const uint32_t entry, Positions pos) const { +Result Detector::getDestinationUDPList(const uint32_t entry, + Positions pos) const { return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry); } -void Detector::setDestinationUDPList(const defs::udpDestination dest, +void Detector::setDestinationUDPList(const UdpDestination dest, const int module_id) { if (module_id == -1 && size() > 1) { throw sls::RuntimeError("Cannot set this parameter at detector level."); diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index dc3769cae..f62339b07 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -939,31 +939,30 @@ void Module::setSourceUDPMAC2(const sls::MacAddr mac) { sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr); } -slsDetectorDefs::udpDestination -Module::getDestinationUDPList(const uint32_t entry) const { - return sendToDetector(F_GET_DEST_UDP_LIST, entry); +sls::UdpDestination Module::getDestinationUDPList(const uint32_t entry) const { + return sendToDetector(F_GET_DEST_UDP_LIST, entry); } -void Module::setDestinationUDPList(const slsDetectorDefs::udpDestination dest) { +void Module::setDestinationUDPList(const sls::UdpDestination dest) { // set them in the default way so the receivers are also set up - if (dest.entry_ == 0) { - if (dest.port_ != 0) { - setDestinationUDPPort(dest.port_); + if (dest.entry == 0) { + if (dest.port != 0) { + setDestinationUDPPort(dest.port); } - if (dest.ip_ != 0) { - setDestinationUDPIP(IpAddr(dest.ip_)); + if (dest.ip != 0) { + setDestinationUDPIP(dest.ip); } - if (dest.mac_ != 0) { - setDestinationUDPMAC(MacAddr(dest.mac_)); + if (dest.mac != 0) { + setDestinationUDPMAC(dest.mac); } - if (dest.port2_ != 0) { - setDestinationUDPPort2(dest.port2_); + if (dest.port2 != 0) { + setDestinationUDPPort2(dest.port2); } - if (dest.ip2_ != 0) { - setDestinationUDPIP2(IpAddr(dest.ip2_)); + if (dest.ip2 != 0) { + setDestinationUDPIP2(dest.ip2); } - if (dest.mac2_ != 0) { - setDestinationUDPMAC2(MacAddr(dest.mac2_)); + if (dest.mac2 != 0) { + setDestinationUDPMAC2(dest.mac2); } } else { sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr); diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 715f9b533..e8912feb3 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -222,8 +222,8 @@ class Module : public virtual slsDetectorDefs { void setSourceUDPMAC(const sls::MacAddr mac); sls::MacAddr getSourceUDPMAC2() const; void setSourceUDPMAC2(const sls::MacAddr mac); - udpDestination getDestinationUDPList(const uint32_t entry) const; - void setDestinationUDPList(const defs::udpDestination dest); + sls::UdpDestination getDestinationUDPList(const uint32_t entry) const; + void setDestinationUDPList(const sls::UdpDestination dest); int getNumberofUDPDestinations() const; void setNumberofUDPDestinations(const int value); int getFirstUDPDestination() const; diff --git a/slsSupportLib/include/sls/ToString.h b/slsSupportLib/include/sls/ToString.h index bd102e2b2..bbcd4a6c9 100644 --- a/slsSupportLib/include/sls/ToString.h +++ b/slsSupportLib/include/sls/ToString.h @@ -55,9 +55,6 @@ std::ostream &operator<<(std::ostream &os, std::string ToString(const slsDetectorDefs::currentSrcParameters &r); std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::currentSrcParameters &r); -std::string ToString(const slsDetectorDefs::udpDestination &r); -std::ostream &operator<<(std::ostream &os, - const slsDetectorDefs::udpDestination &r); const std::string &ToString(const std::string &s); /** Convert std::chrono::duration with specified output unit */ diff --git a/slsSupportLib/include/sls/network_utils.h b/slsSupportLib/include/sls/network_utils.h index b741b6e5e..68b090651 100644 --- a/slsSupportLib/include/sls/network_utils.h +++ b/slsSupportLib/include/sls/network_utils.h @@ -30,7 +30,7 @@ class IpAddr { return addr_ != other; } constexpr uint32_t uint32() const noexcept { return addr_; } -}; +} __attribute__((packed)); class MacAddr { private: @@ -57,13 +57,33 @@ class MacAddr { return addr_ != other; } constexpr uint64_t uint64() const noexcept { return addr_; } -}; +} __attribute__((packed)); + +struct UdpDestination { + uint32_t entry{}; + uint32_t port{}; + uint32_t port2{}; + IpAddr ip; + IpAddr ip2; + MacAddr mac; + MacAddr mac2; + std::string str() const; + + constexpr bool operator==(const UdpDestination &other) const { + return ((entry == other.entry) && (port == other.port) && + (port2 == other.port2) && (ip== other.ip) && + (ip2 == other.ip2) && (mac == other.mac) && + (mac2 == other.mac2)); + } +} __attribute__((packed)); + +std::ostream &operator<<(std::ostream &out, const IpAddr &addr); +std::ostream &operator<<(std::ostream &out, const MacAddr &addr); +std::ostream &operator<<(std::ostream &out, const UdpDestination &dest); IpAddr HostnameToIp(const char *hostname); std::string IpToInterfaceName(const std::string &ip); MacAddr InterfaceNameToMac(const std::string &inf); IpAddr InterfaceNameToIp(const std::string &ifn); -std::ostream &operator<<(std::ostream &out, const IpAddr &addr); -std::ostream &operator<<(std::ostream &out, const MacAddr &addr); } // namespace sls diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 0311ee816..c4b24677a 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -494,28 +494,6 @@ typedef struct { } } __attribute__((packed)); - struct udpDestination { - uint32_t entry_{}; - uint32_t port_{}; - uint32_t port2_{}; - uint32_t ip_{}; - uint32_t ip2_{}; - uint64_t mac_{}; - uint64_t mac2_{}; - udpDestination() {} - udpDestination(uint32_t entry, uint32_t port = 0, uint32_t ip = 0, uint64_t mac = 0, - uint32_t port2 = 0, uint32_t ip2 = 0, uint64_t mac2 = 0) - : entry_(entry), port_(port), port2_(port2), ip_(ip), ip2_(ip2), - mac_(mac), mac2_(mac2) {} - - bool operator==(const udpDestination &other) const { - return ((entry_ == other.entry_) && (port_ == other.port_) && - (port2_ == other.port2_) && (ip_ == other.ip_) && - (ip2_ == other.ip2_) && (mac_ == other.mac_) && - (mac2_ == other.mac2_)); - } - } __attribute__((packed)); - /** * structure to udpate receiver */ diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 01cfbf825..556c634f8 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -1,15 +1,14 @@ /** API versions */ #define GITBRANCH "roundrobin" - - - #define APILIB 0x210831 #define APIRECEIVER 0x210831 #define APIGUI 0x210819 -#define APICTB 0x210901 -#define APIGOTTHARD 0x210901 -#define APIGOTTHARD2 0x210901 -#define APIJUNGFRAU 0x210901 -#define APIMYTHEN3 0x210901 -#define APIMOENCH 0x210901 -#define APIEIGER 0x210901 + + +#define APICTB 0x210909 +#define APIGOTTHARD 0x210909 +#define APIGOTTHARD2 0x210909 +#define APIJUNGFRAU 0x210909 +#define APIMYTHEN3 0x210909 +#define APIMOENCH 0x210909 +#define APIEIGER 0x210909 diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index e37ef0d73..25bd91e35 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -148,31 +148,6 @@ std::ostream &operator<<(std::ostream &os, return os << ToString(r); } -std::string ToString(const slsDetectorDefs::udpDestination &r) { - std::ostringstream oss; - oss << '[' << std::endl - << "entry " << r.entry_ << std::endl - << "ip " << IpAddr(r.ip_) << std::endl - << "mac " << MacAddr(r.mac_) << std::endl - << "port " << r.port_ << std::endl; - if (r.port2_ != 0) { - oss << "port2 " << r.port2_ << std::endl; - } - if (r.ip2_ != 0) { - oss << "ip2 " << IpAddr(r.ip2_) << std::endl; - } - if (r.mac2_ != 0) { - oss << "mac2 " << MacAddr(r.mac2_) << std::endl; - } - oss << ']'; - return oss.str(); -} - -std::ostream &operator<<(std::ostream &os, - const slsDetectorDefs::udpDestination &r) { - return os << ToString(r); -} - std::string ToString(const defs::runStatus s) { switch (s) { case defs::ERROR: diff --git a/slsSupportLib/src/network_utils.cpp b/slsSupportLib/src/network_utils.cpp index 2f05e948c..56507e8f1 100644 --- a/slsSupportLib/src/network_utils.cpp +++ b/slsSupportLib/src/network_utils.cpp @@ -69,6 +69,26 @@ std::string MacAddr::str() const { return to_hex(':'); } std::string MacAddr::hex() const { return to_hex(); } +std::string UdpDestination::str() const { + std::ostringstream oss; + oss << '[' << std::endl + << "entry " << entry << std::endl + << "ip " << ip << std::endl + << "mac " << mac << std::endl + << "port " << port << std::endl; + if (port2 != 0) { + oss << "port2 " << port2 << std::endl; + } + if (ip2 != 0) { + oss << "ip2 " << ip2 << std::endl; + } + if (mac2 != 0) { + oss << "mac2 " << mac2 << std::endl; + } + oss << ']'; + return oss.str(); +} + std::ostream &operator<<(std::ostream &out, const IpAddr &addr) { return out << addr.str(); } @@ -77,6 +97,10 @@ std::ostream &operator<<(std::ostream &out, const MacAddr &addr) { return out << addr.str(); } +std::ostream &operator<<(std::ostream &out, const UdpDestination &dest) { + return out << dest.str(); +} + IpAddr HostnameToIp(const char *hostname) { addrinfo hints; addrinfo *result = nullptr; diff --git a/slsSupportLib/tests/test-file_utils.cpp b/slsSupportLib/tests/test-file_utils.cpp index 254c52055..b4f71cfb9 100644 --- a/slsSupportLib/tests/test-file_utils.cpp +++ b/slsSupportLib/tests/test-file_utils.cpp @@ -9,7 +9,7 @@ TEST_CASE("Get size of empty file") { char fname[] = "temfile_XXXXXX"; std::ifstream ifs(fname); auto size = sls::getFileSize(ifs); - REQUIRE(size == 0); + REQUIRE(size <= 0); // -1 or zero } TEST_CASE("Get size of file with data") { diff --git a/slsSupportLib/tests/test-network_utils.cpp b/slsSupportLib/tests/test-network_utils.cpp index 295da4c10..a6464d2b4 100644 --- a/slsSupportLib/tests/test-network_utils.cpp +++ b/slsSupportLib/tests/test-network_utils.cpp @@ -112,4 +112,19 @@ TEST_CASE("Copy construct a MacAddr") { CHECK(addr == addr2); } + +TEST_CASE("udp dst struct basic properties"){ + static_assert(sizeof(UdpDestination) == 36); + UdpDestination dst{}; + REQUIRE(dst.entry == 0); + REQUIRE(dst.port == 0); + REQUIRE(dst.port2 == 0); + REQUIRE(dst.ip == 0); + REQUIRE(dst.ip2 == 0); + REQUIRE(dst.mac == 0); + REQUIRE(dst.mac2 == 0); + +} + + // TODO!(Erik) Look up a real hostname and verify the IP