mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 01:50:40 +02:00
nios temp (#557)
* fixed temp read nios * divide for eiger and dont print
This commit is contained in:
parent
4a7cd051c1
commit
46bb9bc2d7
@ -100,6 +100,7 @@ This document describes the differences between v7.0.0 and v6.x.x
|
||||
- jungfrau reset core and usleep removed (fix for 6.1.1 is now fixed in firmware)
|
||||
- g2 change clkdivs 2 3 4 to defaults for burst and cw mode.
|
||||
- ctb and moench: allowing 1g non blocking acquire to send data
|
||||
- m3 and g2 temp
|
||||
- gain plot zooming fixed (disabled, acc. to main plot)
|
||||
- ctb, moench, jungfrau (pll reset at start fixed, before no defines)
|
||||
|
||||
|
Binary file not shown.
@ -395,35 +395,11 @@ int Feb_Control_ReceiveHighVoltage(unsigned int *value) {
|
||||
|
||||
// normal
|
||||
if (Feb_Control_normal) {
|
||||
// open file
|
||||
FILE *fd = fopen(NORMAL_HIGHVOLTAGE_INPUTPORT, "r");
|
||||
if (fd == NULL) {
|
||||
LOG(logERROR,
|
||||
("Could not open file for writing to get high voltage\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read, assigning line to null and readbytes to 0 then getline
|
||||
// allocates initial buffer
|
||||
size_t readbytes = 0;
|
||||
char *line = NULL;
|
||||
if (getline(&line, &readbytes, fd) == -1) {
|
||||
LOG(logERROR, ("could not read file to get high voltage\n"));
|
||||
if (readADCFromFile(NORMAL_HIGHVOLTAGE_INPUTPORT, value) == FAIL) {
|
||||
LOG(logERROR, ("Could not get high voltage\n"));
|
||||
return 0;
|
||||
}
|
||||
// read again to read the updated value
|
||||
rewind(fd);
|
||||
free(line);
|
||||
readbytes = 0;
|
||||
readbytes = getline(&line, &readbytes, fd);
|
||||
if (readbytes == -1) {
|
||||
LOG(logERROR, ("could not read file to get high voltage\n"));
|
||||
return 0;
|
||||
}
|
||||
// Remove the trailing 0
|
||||
*value = atoi(line) / 10;
|
||||
free(line);
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
// 9m
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1506,6 +1506,15 @@ int getDAC(enum DACINDEX ind, int mV) {
|
||||
|
||||
int getMaxDacSteps() { return LTC2620_D_GetMaxNumSteps(); }
|
||||
|
||||
int getADC(enum ADCINDEX ind, int *value) {
|
||||
LOG(logDEBUG1, ("Reading FPGA temperature...\n"));
|
||||
if (readADCFromFile(TEMPERATURE_FILE_NAME, value) == FAIL) {
|
||||
LOG(logERROR, ("Could not get temperature\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setHighVoltage(int val) {
|
||||
if (val > HV_SOFT_MAX_VOLTAGE) {
|
||||
val = HV_SOFT_MAX_VOLTAGE;
|
||||
|
@ -12,18 +12,23 @@
|
||||
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
||||
|
||||
/* Hardware Definitions */
|
||||
#define NCHAN (128)
|
||||
#define NCHIP (10)
|
||||
#define NDAC (16)
|
||||
#define NADC (32)
|
||||
#define ONCHIP_NDAC (7)
|
||||
#define DYNAMIC_RANGE (16)
|
||||
#define HV_SOFT_MAX_VOLTAGE (500)
|
||||
#define HV_HARD_MAX_VOLTAGE (530)
|
||||
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
|
||||
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
|
||||
#define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac")
|
||||
#define TYPE_FILE_NAME ("/etc/devlinks/type")
|
||||
#define NCHAN (128)
|
||||
#define NCHIP (10)
|
||||
#define NDAC (16)
|
||||
#define NADC (32)
|
||||
#define ONCHIP_NDAC (7)
|
||||
#define DYNAMIC_RANGE (16)
|
||||
#define HV_SOFT_MAX_VOLTAGE (500)
|
||||
#define HV_HARD_MAX_VOLTAGE (530)
|
||||
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
|
||||
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
|
||||
#define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac")
|
||||
#define TYPE_FILE_NAME ("/etc/devlinks/type")
|
||||
#ifdef VIRTUAL
|
||||
#define TEMPERATURE_FILE_NAME ("/tmp/temp.txt")
|
||||
#else
|
||||
#define TEMPERATURE_FILE_NAME ("/sys/class/hwmon/hwmon0/temp1_input")
|
||||
#endif
|
||||
#define CONFIG_FILE ("config_gotthard2.txt")
|
||||
#define DAC_MAX_MV (2048)
|
||||
#define ONCHIP_DAC_MAX_VAL (0x3FF)
|
||||
@ -157,6 +162,8 @@ enum CLKINDEX {
|
||||
"READOUT_C0", "READOUT_C1", "SYSTEM_C0", "SYSTEM_C1", "SYSTEM_C2", \
|
||||
"SYSTEM_C3"
|
||||
|
||||
enum ADCINDEX { TEMP_FPGA };
|
||||
|
||||
enum PLLINDEX { READOUT_PLL, SYSTEM_PLL };
|
||||
|
||||
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1647,6 +1647,15 @@ int getDAC(enum DACINDEX ind, int mV) {
|
||||
|
||||
int getMaxDacSteps() { return LTC2620_D_GetMaxNumSteps(); }
|
||||
|
||||
int getADC(enum ADCINDEX ind, int *value) {
|
||||
LOG(logDEBUG1, ("Reading FPGA temperature...\n"));
|
||||
if (readADCFromFile(TEMPERATURE_FILE_NAME, value) == FAIL) {
|
||||
LOG(logERROR, ("Could not get temperature\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setHighVoltage(int val) {
|
||||
// limit values
|
||||
if (val > HV_SOFT_MAX_VOLTAGE) {
|
||||
|
@ -12,18 +12,23 @@
|
||||
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
||||
|
||||
/* Hardware Definitions */
|
||||
#define NCOUNTERS (3)
|
||||
#define MAX_COUNTER_MSK (0x7)
|
||||
#define NCHAN_1_COUNTER (128)
|
||||
#define NCHAN (128 * NCOUNTERS)
|
||||
#define NCHIP (10)
|
||||
#define NCHAN_PER_MODULE (NCHAN * NCHIP)
|
||||
#define NDAC (16)
|
||||
#define HV_SOFT_MAX_VOLTAGE (500)
|
||||
#define HV_HARD_MAX_VOLTAGE (530)
|
||||
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
|
||||
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
|
||||
#define TYPE_FILE_NAME ("/etc/devlinks/type")
|
||||
#define NCOUNTERS (3)
|
||||
#define MAX_COUNTER_MSK (0x7)
|
||||
#define NCHAN_1_COUNTER (128)
|
||||
#define NCHAN (128 * NCOUNTERS)
|
||||
#define NCHIP (10)
|
||||
#define NCHAN_PER_MODULE (NCHAN * NCHIP)
|
||||
#define NDAC (16)
|
||||
#define HV_SOFT_MAX_VOLTAGE (500)
|
||||
#define HV_HARD_MAX_VOLTAGE (530)
|
||||
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
|
||||
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
|
||||
#define TYPE_FILE_NAME ("/etc/devlinks/type")
|
||||
#ifdef VIRTUAL
|
||||
#define TEMPERATURE_FILE_NAME ("/tmp/temp.txt")
|
||||
#else
|
||||
#define TEMPERATURE_FILE_NAME ("/sys/class/hwmon/hwmon0/temp1_input")
|
||||
#endif
|
||||
#define DAC_MAX_MV (2048)
|
||||
#define TYPE_MYTHEN3_MODULE_VAL (93)
|
||||
#define TYPE_TOLERANCE (5)
|
||||
@ -117,6 +122,8 @@ enum DACINDEX {
|
||||
800 /* VdcSh */ \
|
||||
};
|
||||
|
||||
enum ADCINDEX { TEMP_FPGA };
|
||||
|
||||
#define NUMSETTINGS (3)
|
||||
#define NSPECIALDACS (2)
|
||||
#define SPECIALDACINDEX {M_VRPREAMP, M_VRSHAPER};
|
||||
|
@ -68,3 +68,5 @@ int createEmptyFile(char *mess, char *fname, char *errorPrefix);
|
||||
int deleteFile(char *mess, char *fname, char *errorPrefix);
|
||||
|
||||
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix);
|
||||
|
||||
int readADCFromFile(char *fname, int *value);
|
@ -378,7 +378,9 @@ void setPower(enum DACINDEX ind, int val);
|
||||
void powerOff();
|
||||
#endif
|
||||
|
||||
#if !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
int getADC(enum ADCINDEX ind, int *value);
|
||||
#elif !defined(MOENCHD)
|
||||
int getADC(enum ADCINDEX ind);
|
||||
#endif
|
||||
|
||||
|
@ -701,3 +701,38 @@ int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix) {
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int readADCFromFile(char *fname, int *value) {
|
||||
LOG(logDEBUG1, ("fname:%s\n", fname));
|
||||
// open file
|
||||
FILE *fd = fopen(fname, "r");
|
||||
if (fd == NULL) {
|
||||
LOG(logERROR, ("Could not open file for reading [%s]\n", fname));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
const size_t LZ = 256;
|
||||
char line[LZ];
|
||||
memset(line, 0, LZ);
|
||||
|
||||
if (NULL == fgets(line, LZ, fd)) {
|
||||
LOG(logERROR, ("Could not read from file %s\n", fname));
|
||||
*value = -1;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
*value = -1;
|
||||
if (sscanf(line, "%d", value) != 1) {
|
||||
LOG(logERROR, ("Could not scan temperature from %s\n", line));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
#ifdef EIGERD
|
||||
*value /= 10;
|
||||
#else
|
||||
LOG(logINFO, ("Temperature: %.2f °C\n", (double)(*value) / 1000.00));
|
||||
#endif
|
||||
|
||||
fclose(fd);
|
||||
return OK;
|
||||
}
|
@ -1375,13 +1375,18 @@ int get_adc(int file_des) {
|
||||
if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
#if defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
#if defined(MOENCHD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
enum ADCINDEX serverAdcIndex = 0;
|
||||
|
||||
// get
|
||||
switch (ind) {
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
case TEMPERATURE_FPGA:
|
||||
serverAdcIndex = TEMP_FPGA;
|
||||
break;
|
||||
#endif
|
||||
#if defined(GOTTHARDD) || defined(JUNGFRAUD)
|
||||
case TEMPERATURE_FPGA:
|
||||
serverAdcIndex = TEMP_FPGA;
|
||||
@ -1481,8 +1486,18 @@ int get_adc(int file_des) {
|
||||
// valid index
|
||||
if (ret == OK) {
|
||||
LOG(logDEBUG1, ("Getting ADC %d\n", serverAdcIndex));
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
ret = getADC(serverAdcIndex, &retval);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not get temperature\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval));
|
||||
}
|
||||
#else
|
||||
retval = getADC(serverAdcIndex);
|
||||
LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1882,55 +1897,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,
|
||||
"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)) {
|
||||
LOG(logERROR, (mess));
|
||||
} else if (!enableTenGigabitEthernet(GET_FLAG) &&
|
||||
(udpDetails[0].srcip != getDetectorIP())) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not start acquisition thread!\n");
|
||||
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 {
|
||||
// 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);
|
||||
}
|
||||
@ -2011,7 +2028,6 @@ void *start_state_machine(void *arg) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
readFrames(&ret, mess);
|
||||
if (ret == FAIL && scan) {
|
||||
@ -2019,7 +2035,7 @@ void *start_state_machine(void *arg) {
|
||||
strcat(scanErrMessage, mess);
|
||||
sharedMemory_setScanStatus(ERROR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// blocking or scan
|
||||
if (*blocking || times > 1) {
|
||||
|
@ -453,6 +453,7 @@ class Detector {
|
||||
|
||||
/**
|
||||
* (Degrees)
|
||||
* [Mythen3][Gotthard2] Options: TEMPERATURE_FPGA
|
||||
* [Gotthard] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA \n
|
||||
* [Jungfrau] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA \n
|
||||
* [Eiger] Options: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE,
|
||||
|
@ -1450,9 +1450,10 @@ class CmdProxy {
|
||||
GET_IND_COMMAND(temp_adc, getTemperature, slsDetectorDefs::TEMPERATURE_ADC,
|
||||
" °C", "[n_value]\n\t[Jungfrau][Gotthard] ADC Temperature");
|
||||
|
||||
GET_IND_COMMAND(
|
||||
temp_fpga, getTemperature, slsDetectorDefs::TEMPERATURE_FPGA, " °C",
|
||||
"[n_value]\n\t[Eiger][Jungfrau][Gotthard] FPGA Temperature");
|
||||
GET_IND_COMMAND(temp_fpga, getTemperature,
|
||||
slsDetectorDefs::TEMPERATURE_FPGA, " °C",
|
||||
"[n_value]\n\t[Eiger][Jungfrau][Gotthard][Mythen3]["
|
||||
"Gotthard2] FPGA Temperature");
|
||||
|
||||
GET_IND_COMMAND(temp_fpgaext, getTemperature,
|
||||
slsDetectorDefs::TEMPERATURE_FPGAEXT, " °C",
|
||||
|
@ -605,6 +605,9 @@ std::vector<defs::dacIndex> Detector::getTemperatureList() const {
|
||||
defs::TEMPERATURE_10GE, defs::TEMPERATURE_DCDC,
|
||||
defs::TEMPERATURE_SODL, defs::TEMPERATURE_SODR,
|
||||
defs::TEMPERATURE_FPGA2, defs::TEMPERATURE_FPGA3};
|
||||
case defs::MYTHEN3:
|
||||
case defs::GOTTHARD2:
|
||||
return std::vector<defs::dacIndex>{defs::TEMPERATURE_FPGA};
|
||||
default:
|
||||
return std::vector<defs::dacIndex>{};
|
||||
}
|
||||
@ -631,6 +634,8 @@ Result<int> Detector::getTemperature(defs::dacIndex index,
|
||||
switch (getDetectorType().squash()) {
|
||||
case defs::EIGER:
|
||||
case defs::JUNGFRAU:
|
||||
case defs::MYTHEN3:
|
||||
case defs::GOTTHARD2:
|
||||
for (auto &it : res) {
|
||||
it /= 1000;
|
||||
}
|
||||
|
@ -1853,8 +1853,7 @@ TEST_CASE("temp_fpga", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD ||
|
||||
det_type == defs::EIGER) {
|
||||
if (det_type != defs::MOENCH) {
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_fpga", {}, -1, GET));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_fpga", {}, 0, GET, oss));
|
||||
|
@ -12,3 +12,4 @@
|
||||
#define APIMYTHEN3 0x221004
|
||||
#define APIMOENCH 0x221004
|
||||
#define APIEIGER 0x221004
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user