From 64d489f1e6f79d947c8e6df08409fecfccb5b0f7 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 7 Feb 2024 13:25:11 +0100 Subject: [PATCH] formatting --- .../src/slsDetectorServer_funcs.c | 173 +++++++++--------- .../slsDetectorFunctionList.c | 3 +- slsSupportLib/include/sls/versionAPI.h | 12 +- 3 files changed, 98 insertions(+), 90 deletions(-) diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 7cc3d922a..811d113f3 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -1991,98 +1991,105 @@ int acquire(int blocking, int file_des) { #if defined(JUNGFRAUD) // chipv1.1 has to be configured before acquisition if (getChipVersion() == 11 && !isChipConfigured()) { - ret = FAIL; - strcpy(mess, "Could not start acquisition. Chip is not configured. " - "Power it on to configure it.\n"); - LOG(logERROR, (mess)); - } else + ret = FAIL; + strcpy(mess, + "Could not start acquisition. Chip is not configured. " + "Power it on to configure it.\n"); + LOG(logERROR, (mess)); + } else #endif #if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) - if ((getReadoutMode() == ANALOG_AND_DIGITAL || - getReadoutMode() == ANALOG_ONLY) && - (getNumAnalogSamples() <= 0)) { - ret = FAIL; - sprintf(mess, - "Could not start acquisition. Invalid number of analog " - "samples: %d.\n", - getNumAnalogSamples()); - LOG(logERROR, (mess)); - } else if ((getReadoutMode() == ANALOG_AND_DIGITAL || - getReadoutMode() == DIGITAL_ONLY || - getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && - (getNumDigitalSamples() <= 0)) { - ret = FAIL; - sprintf(mess, + if ((getReadoutMode() == ANALOG_AND_DIGITAL || + getReadoutMode() == ANALOG_ONLY) && + (getNumAnalogSamples() <= 0)) { + ret = FAIL; + sprintf(mess, + "Could not start acquisition. Invalid number of analog " + "samples: %d.\n", + getNumAnalogSamples()); + LOG(logERROR, (mess)); + } else if ((getReadoutMode() == ANALOG_AND_DIGITAL || + getReadoutMode() == DIGITAL_ONLY || + getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && + (getNumDigitalSamples() <= 0)) { + ret = FAIL; + sprintf( + mess, "Could not start acquisition. Invalid number of digital " "samples: %d.\n", getNumDigitalSamples()); - LOG(logERROR, (mess)); - } else if ((getReadoutMode() == TRANSCEIVER_ONLY || - getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && - (getNumTransceiverSamples() <= 0)) { - ret = FAIL; - sprintf( - mess, - "Could not start acquisition. Invalid number of transceiver " - "samples: %d.\n", - getNumTransceiverSamples()); - LOG(logERROR, (mess)); - } else + LOG(logERROR, (mess)); + } else if ((getReadoutMode() == TRANSCEIVER_ONLY || + getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && + (getNumTransceiverSamples() <= 0)) { + ret = FAIL; + sprintf(mess, + "Could not start acquisition. Invalid number of " + "transceiver " + "samples: %d.\n", + getNumTransceiverSamples()); + LOG(logERROR, (mess)); + } else #endif #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, - "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, - "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 + // 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, + "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, + "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 #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)) { - ret = FAIL; - strcpy(mess, "Could not start acquisition thread!\n"); - LOG(logERROR, (mess)); - } else { - // wait for blocking always (scan or not) - // non blocking-no scan also wait (for error message) - // non blcoking-scan dont wait (there is scanErrorMessage) - if (blocking || !scan) { - pthread_join(pthread_tid, NULL); + 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)) { + ret = FAIL; + strcpy(mess, "Could not start acquisition thread!\n"); + LOG(logERROR, (mess)); + } else { + // wait for blocking always (scan or not) + // non blocking-no scan also wait (for error message) + // non blcoking-scan dont wait (there is + // scanErrorMessage) + if (blocking || !scan) { + pthread_join(pthread_tid, NULL); + } + } } - } - } } return Server_SendResult(file_des, INT32, NULL, 0); } diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index 94cc5fa50..caa446311 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -511,7 +511,8 @@ int waitTransceiverAligned(char *mess) { // no module: transceiver will never get aligned if (!checkModuleFlag) { - LOG(logWARNING, ("No module: Transceiver will never get aligned. Ignoring alignment check.\n")); + LOG(logWARNING, ("No module: Transceiver will never get aligned. " + "Ignoring alignment check.\n")); return OK; } diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index dabf9ce57..745078acb 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -4,11 +4,11 @@ #define RELEASE "developer" #define APILIB "developer 0x230224" #define APIRECEIVER "developer 0x230224" -#define APICTB "developer 0x240207" -#define APIGOTTHARD "developer 0x240207" +#define APICTB "developer 0x240207" +#define APIGOTTHARD "developer 0x240207" #define APIGOTTHARD2 "developer 0x240207" -#define APIJUNGFRAU "developer 0x240207" -#define APIMYTHEN3 "developer 0x240207" -#define APIMOENCH "developer 0x240207" +#define APIJUNGFRAU "developer 0x240207" +#define APIMYTHEN3 "developer 0x240207" +#define APIMOENCH "developer 0x240207" #define APIXILINXCTB "developer 0x240207" -#define APIEIGER "developer 0x240207" +#define APIEIGER "developer 0x240207"