formatting

This commit is contained in:
2025-01-31 12:27:35 +01:00
parent 0e45ae189d
commit e92578f89d
13 changed files with 135 additions and 126 deletions

View File

@ -106,9 +106,9 @@
(0x0000FFFF << I2C_SDA_HOLD_COUNT_PERIOD_OFST)
/** Receive Data Fifo Level register */
//#define I2C_RX_DATA_FIFO_LVL_OFST (0)
//#define I2C_RX_DATA_FIFO_LVL_MSK (0x000000FF <<
// I2C_RX_DATA_FIFO_LVL_OFST)
// #define I2C_RX_DATA_FIFO_LVL_OFST (0)
// #define I2C_RX_DATA_FIFO_LVL_MSK (0x000000FF <<
// I2C_RX_DATA_FIFO_LVL_OFST)
// defines in the fpga
uint32_t I2C_Control_Reg = 0x0;

View File

@ -622,7 +622,7 @@ void getIpAddressinString(char *cip, uint32_t ip) {
inet_ntop(AF_INET, &ip, cip, INET_ADDRSTRLEN);
#else
sprintf(cip, "%d.%d.%d.%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff,
(ip >> 8) & 0xff, (ip)&0xff);
(ip >> 8) & 0xff, (ip) & 0xff);
#endif
}

View File

@ -2013,102 +2013,106 @@ 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
#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);
// 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
pthread_detach(pthread_tid);
}
}
#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);
} else
pthread_detach(pthread_tid);
}
}
}
return Server_SendResult(file_des, INT32, NULL, 0);
}