diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index f062638cd..32a5241e0 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -1492,6 +1492,8 @@ enum timingMode getTiming() { /* configure mac */ +int getNumberofUDPInterfaces() { return 1; } + void calcChecksum(udp_header *udp) { int count = IP_HEADER_SIZE; long int sum = 0; diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 5eacd9b6d..4cb71c59b 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -1500,6 +1500,7 @@ enum timingMode getTiming() { } /* configure mac */ +int getNumberofUDPInterfaces() { return 2; } int getNumberofDestinations(int *retval) { #ifdef VIRTUAL diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index 1fd57beb4..362bf2079 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -1299,6 +1299,8 @@ int getExtSignal(int signalIndex) { /* configure mac */ +int getNumberofUDPInterfaces() { return 1; } + void calcChecksum(mac_conf *mac, int sourceip, int destip) { mac->ip.ip_ver = 0x4; mac->ip.ip_ihl = 0x5; diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 77482af77..c3e9e56b3 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -1157,6 +1157,8 @@ enum timingMode getTiming() { /* configure mac */ +int getNumberofUDPInterfaces() { return 1; } + void calcChecksum(udp_header *udp) { int count = IP_HEADER_SIZE; long int sum = 0; diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index bd4528832..eb5b2ad89 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -1719,6 +1719,8 @@ int getExtSignal(int signalIndex) { } } +int getNumberofUDPInterfaces() { return 1; } + int configureMAC() { uint32_t srcip = udpDetails[0].srcip; diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 0506650f6..a868f46a4 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -387,8 +387,8 @@ void calcChecksum(mac_conf *mac, int sourceip, int destip); #endif #if defined(JUNGFRAUD) || defined(GOTTHARD2D) void setNumberofUDPInterfaces(int val); -int getNumberofUDPInterfaces(); #endif +int getNumberofUDPInterfaces(); #if defined(JUNGFRAUD) || defined(EIGERD) int getNumberofDestinations(int *retval); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 5c9be68f0..8328e2a18 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -4725,19 +4725,23 @@ void calculate_and_set_position() { LOG(logERROR, (mess)); return; } - int maxy = maxydet; - // position does not change for gotthard2 (2 interfaces) -#ifdef JUNGFRAUD - maxy *= getNumberofUDPInterfaces(); + + // calculating new position + int numInterfaces = getNumberofUDPInterfaces(); + int modulePorts[2] = {1, 1}; + // position does change for eiger and jungfrau (2 interfaces) +#if defined(EIGERD) + modulePorts[1] = numInterfaces; // horz +#elif defined(JUNGFRAUD) + modulePorts[0] = numInterfaces; // vert #endif + int maxy = maxydet * modulePorts[0]; int pos[2] = {0, 0}; // row pos[0] = (detectorId % maxy); // col for horiz. udp ports - pos[1] = (detectorId / maxy); -#ifdef EIGERD - pos[1] *= 2; -#endif + pos[1] = (detectorId / maxy) * modulePorts[1]; + LOG(logDEBUG, ("Setting Positions (%d,%d)\n", pos[0], pos[1])); if (setDetectorPosition(pos) == FAIL) { ret = FAIL; @@ -4854,7 +4858,6 @@ int is_udp_configured() { LOG(logWARNING, ("%s", configureMessage)); return FAIL; } -#if defined(JUNGFRAUD) || defined(GOTTHARD2D) if (getNumberofUDPInterfaces() == 2) { if (udpDetails[i].srcip2 == 0) { sprintf(configureMessage, @@ -4881,7 +4884,6 @@ int is_udp_configured() { return FAIL; } } -#endif } return OK; } @@ -5320,7 +5322,16 @@ int set_num_interfaces(int file_des) { LOG(logINFO, ("Setting number of interfaces: %d\n", arg)); #if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) - functionNotImplemented(); + // fixed number of udp interfaces + int num_interfaces = getNumberofUDPInterfaces(); + if (arg != num_interfaces) { + ret = FAIL; + sprintf(mess, + "Could not set number of interfaces. Invalid value: %d. Must " + "be %d\n", + arg, num_interfaces); + LOG(logERROR, (mess)); + } #else // only set if (Server_VerifyLock() == OK) { @@ -5380,12 +5391,9 @@ int get_num_interfaces(int file_des) { int retval = -1; LOG(logDEBUG1, ("Getting number of udp interfaces\n")); -#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) - retval = 1; -#else // get only retval = getNumberofUDPInterfaces(); -#endif + LOG(logDEBUG1, ("Number of udp interfaces retval: %u\n", retval)); return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -6883,11 +6891,7 @@ int get_receiver_parameters(int file_des) { // sending real detector parameters // udp interfaces -#if defined(JUNGFRAUD) || defined(GOTTHARD2D) i32 = getNumberofUDPInterfaces(); -#else - i32 = 1; -#endif n += sendData(file_des, &i32, sizeof(i32), INT32); if (n < 0) return printSocketReadError(); @@ -9025,10 +9029,7 @@ int set_dest_udp_list(int file_des) { } // if still 0, set defaults - int twoInterfaces = 0; -#if defined(JUNGFRAUD) || defined(GOTTHARD2D) - twoInterfaces = getNumberofUDPInterfaces() == 2 ? 1 : 0; -#endif + int twoInterfaces = getNumberofUDPInterfaces() == 2 ? 1 : 0; udpDetails[entry].srcport = DEFAULT_UDP_SRC_PORTNO; if (udpDetails[entry].dstport == 0) { udpDetails[entry].dstport =