diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 28318ecdb..691c6e3c8 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -547,8 +547,8 @@ int M_nofunc(int file_des) { ret = FAIL; memset(mess, 0, sizeof(mess)); - sprintf(mess, "Unrecognized Function enum %d. Please do not proceed.\n", - fnum); + sprintf(mess, "%s Function enum %d. Please do not proceed.\n", + UNRECOGNIZED_FNUM_ENUM, fnum); LOG(logERROR, (mess)); return Server_SendResult(file_des, OTHER, NULL, 0); } @@ -1916,55 +1916,57 @@ int acquire(int blocking, int file_des) { #ifdef EIGERD // check for hardware mac and hardware ip if (udpDetails[0].srcmac != getDetectorMAC()) { - ret = FAIL; - uint64_t sourcemac = getDetectorMAC(); - char src_mac[MAC_ADDRESS_SIZE]; - getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac); - sprintf(mess, + ret = FAIL; + uint64_t sourcemac = getDetectorMAC(); + 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", src_mac); - LOG(logERROR, (mess)); - } else if (!enableTenGigabitEthernet(GET_FLAG) && - (udpDetails[0].srcip != getDetectorIP())) { - ret = FAIL; - uint32_t sourceip = getDetectorIP(); - char src_ip[INET_ADDRSTRLEN]; - getIpAddressinString(src_ip, sourceip); - sprintf(mess, + LOG(logERROR, (mess)); + } else if (!enableTenGigabitEthernet(GET_FLAG) && + (udpDetails[0].srcip != getDetectorIP())) { + ret = FAIL; + uint32_t sourceip = getDetectorIP(); + char src_ip[INET_ADDRSTRLEN]; + getIpAddressinString(src_ip, sourceip); + sprintf( + mess, "Invalid udp source ip address for this detector. Must be " "same as hardware detector ip address %s in 1G readout " "mode \n", src_ip); - LOG(logERROR, (mess)); - } else + LOG(logERROR, (mess)); + } else #endif - if (configured == FAIL) { - ret = FAIL; - strcpy(mess, "Could not start acquisition because "); - strcat(mess, configureMessage); - LOG(logERROR, (mess)); - } else if (sharedMemory_getScanStatus() == RUNNING) { - ret = FAIL; - strcpy(mess, "Could not start acquisition because a scan is " - "already running!\n"); - LOG(logERROR, (mess)); - } else { - memset(scanErrMessage, 0, MAX_STR_LENGTH); - sharedMemory_setScanStop(0); - sharedMemory_setScanStatus(IDLE); // if it was error - if (pthread_create(&pthread_tid, NULL, &start_state_machine, - &blocking)) { + if (configured == FAIL) { ret = FAIL; - strcpy(mess, "Could not start acquisition thread!\n"); + strcpy(mess, "Could not start acquisition because "); + strcat(mess, configureMessage); + LOG(logERROR, (mess)); + } else if (sharedMemory_getScanStatus() == RUNNING) { + ret = FAIL; + strcpy(mess, "Could not start acquisition because a scan is " + "already running!\n"); LOG(logERROR, (mess)); } else { - // only does not wait for non blocking and scan - if (blocking || !scan) { - pthread_join(pthread_tid, NULL); + memset(scanErrMessage, 0, MAX_STR_LENGTH); + sharedMemory_setScanStop(0); + sharedMemory_setScanStatus(IDLE); // if it was error + if (pthread_create(&pthread_tid, NULL, &start_state_machine, + &blocking)) { + ret = FAIL; + strcpy(mess, "Could not start acquisition thread!\n"); + LOG(logERROR, (mess)); + } else { + // only does not wait for non blocking and scan + if (blocking || !scan) { + pthread_join(pthread_tid, NULL); + } } } - } } return Server_SendResult(file_des, INT32, NULL, 0); } diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 253275dd5..457b46263 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -234,8 +234,7 @@ int ClientInterface::decodeFunction(Interface &socket) { socket.Receive(fnum); socket.setFnum(fnum); if (fnum <= NUM_DET_FUNCTIONS || fnum >= NUM_REC_FUNCTIONS) { - throw RuntimeError("Unrecognized Function enum " + - std::to_string(fnum) + "\n"); + throw RuntimeError(UNRECOGNIZED_FNUM_ENUM + std::to_string(fnum)); } else { LOG(logDEBUG1) << "calling function fnum: " << fnum << " (" << getFunctionNameFromEnum((enum detFuncs)fnum) << ")"; diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index da102064d..4f35954da 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -10,6 +10,8 @@ *@short functions indices to call on server (detector/receiver) */ +#define UNRECOGNIZED_FNUM_ENUM "Unrecognized Function enum" + enum detFuncs { F_EXEC_COMMAND = 0, F_GET_DETECTOR_TYPE, diff --git a/slsSupportLib/src/ClientSocket.cpp b/slsSupportLib/src/ClientSocket.cpp index 866314372..117e7621c 100644 --- a/slsSupportLib/src/ClientSocket.cpp +++ b/slsSupportLib/src/ClientSocket.cpp @@ -4,6 +4,7 @@ #include "sls/logger.h" #include "sls/sls_detector_defs.h" #include "sls/sls_detector_exceptions.h" +#include "sls/sls_detector_funcs.h" #include #include #include @@ -76,9 +77,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) { try { Receive(&ret, sizeof(ret)); if (ret == slsDetectorDefs::FAIL) { - char mess[MAX_STR_LENGTH]{}; - // get error message - Receive(mess, sizeof(mess)); + std::string mess = readErrorMessage(); // Do we need to know hostname here? // In that case save it??? if (socketType == "Receiver") { @@ -107,6 +106,9 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) { std::string ClientSocket::readErrorMessage() { std::string error_msg(MAX_STR_LENGTH, '\0'); Receive(&error_msg[0], error_msg.size()); + if (error_msg.find(UNRECOGNIZED_FNUM_ENUM) != std::string::npos) { + error_msg.insert(0, "Software version mismatch. "); + } return error_msg; }