Merge branch 'developer' into jf_h5reader

This commit is contained in:
hinger_v 2024-08-23 11:44:05 +02:00
commit 543b311c06
37 changed files with 364 additions and 315 deletions

View File

@ -22,6 +22,8 @@ Common
* Check transeiver and fibers are compatible (all MMF 850nm or all SMF 1030nm)
* Check fiber
* Check fiber polarity (if short range, unplug the link anywhere, and look at the light/dark pattern: dark has to mate with light)
* For Jungfrau, check if the blue sfp light is blinking rapidly (even when it is not sending data). If so, most likely the link is down and something is wrong with the board. If it connected to a switch, then you do not see it with the ethtool command if link is down. One option is to connect it directly to a pc to see if link is down.
* With nc, try "nc -u -p 50001 -l" in receiving pc, and from another pc try "echo hallo | nc -u 10.1.2.172 50001" to send something to the recieving pc interface to see if the link is up and see if the other nc console receives the hallo.
#. Detector is not acquiring (Not Eiger)
* Take an acquisition with many images and using the following steps instead of acquire:
@ -47,11 +49,20 @@ Common
* Ensure that the interfaces (on NIC and the switch) used in receiver pc have MTU 9000 (jumbo frames) enabled.
#. Check if 'rx_frames' counter in 'ifconfig' do not increment for interface.
#. Check if 'rx packets' counter in 'ifconfig' do not increment for interface.
* If no, check switch configuration if present. Port counters of switch can also help to identify problem.
* If yes, but receiver software does not see it:
* Check no firewall (eg. firewalld) is present or add rules
.. code-block:: bash
# Stop and disable firewall
service firewalld stop
systemctl disable firewalld
# Check status
service firewalld status
* Check that selinux is disabled ( or add rules)
#. Source UDP IP in config file (Not Eiger)

View File

@ -183,8 +183,8 @@ int main(int argc, char *argv[]) {
gainfname = args["gainfile"];
etafname = args["etafilefile"];
if (atoi(args["nuninterfaces"].c_str())>1){
cprintf(RED, "Sorry, at the moment only a single interface is supported instead of %d\n",atoi(args["nuninterfaces"].c_str()));
if (atoi(args["numinterfaces"].c_str())>1){
cprintf(RED, "Sorry, at the moment only a single interface is supported instead of %d\n",atoi(args["numinterfaces"].c_str()));
return EXIT_FAILURE;
}
@ -272,54 +272,34 @@ int main(int argc, char *argv[]) {
sls::ZmqSocket *zmqsocket = NULL;
#ifdef NEWZMQ
// receive socket
try {
#endif
zmqsocket = new sls::ZmqSocket(socketip.c_str(), portnum);
#ifdef NEWZMQ
} catch (...) {
cprintf(RED,
"Error: Could not create Zmq socket on port %d with ip %s\n",
"Error: Could not create Zmq receiving socket on port %d with ip %s\n",
portnum, socketip.c_str());
delete zmqsocket;
return EXIT_FAILURE;
}
#endif
#ifndef NEWZMQ
if (zmqsocket->IsError()) {
cprintf(RED,
"Error: Could not create Zmq socket on port %d with ip %s\n",
portnum, socketip.c_str());
delete zmqsocket;
return EXIT_FAILURE;
}
#endif
if (zmqsocket->Connect()) {
cprintf(RED, "Error: Could not connect to socket %s\n",
cprintf(RED, "Error: Could not connect to Zmq receiving socket %s\n",
(zmqsocket->GetZmqServerAddress()).c_str());
delete zmqsocket;
return EXIT_FAILURE;
} else
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress().c_str());
printf("Zmq receiving socket at %s\n", zmqsocket->GetZmqServerAddress().c_str());
// send socket
sls::ZmqSocket *zmqsocket2 = 0;
// cout << "zmq2 " << endl;
if (send) {
#ifdef NEWZMQ
// receive socket
try {
#endif
zmqsocket2 = new sls::ZmqSocket(portnum2, socketip2.c_str());
#ifdef NEWZMQ
} catch (...) {
cprintf(RED,
"Error: Could not create Zmq socket server on port %d and "
"Error: Could not create Zmq sending socket on port %d and "
"ip %s\n",
portnum2, socketip2.c_str());
// delete zmqsocket2;
@ -328,28 +308,7 @@ int main(int argc, char *argv[]) {
// return EXIT_FAILURE;
send = false;
}
#endif
#ifndef NEWZMQ
if (zmqsocket2->IsError()) {
cprintf(RED,
"AAA Error: Could not create Zmq socket server on port %d "
"and ip %s\n",
portnum2, socketip2.c_str());
// delete zmqsocket2;
// delete zmqsocket;
// return EXIT_FAILURE;
send = false;
}
#endif
if (zmqsocket2->Connect()) {
cprintf(RED, "BBB Error: Could not connect to socket %s\n",
zmqsocket2->GetZmqServerAddress().c_str());
// delete zmqsocket2;
send = false;
// return EXIT_FAILURE;
} else
printf("Zmq Client at %s\n",
printf("Zmq sending socket at %s\n",
zmqsocket2->GetZmqServerAddress().c_str());
}

View File

@ -839,8 +839,8 @@ void qTabMeasurement::UpdateProgress() {
int qTabMeasurement::VerifyOutputDirectoryError() {
try {
auto retval = det->getFilePath();
for (auto &it : retval) {
det->setFilePath(it);
for (size_t i = 0; i < retval.size(); i++) {
det->setFilePath(retval[i], {i});
}
return slsDetectorDefs::OK;
}

View File

@ -473,8 +473,8 @@ void setupDetector() {
// hv
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
// dacs
LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC, 1,
0, "");
LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC, 0,
"");
// on chip dacs
ASIC_Driver_SetDefines(ONCHIP_DAC_DRIVER_FILE_NAME);
setTimingSource(DEFAULT_TIMING_SOURCE);

View File

@ -489,6 +489,7 @@ void setupDetector() {
AD9257_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK,
ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK,
ADC_SPI_SRL_DT_OTPT_OFST);
AD9257_Set_Jungfrau_Hardware_Version_1_0(isHardwareVersion_1_0());
AD9257_Disable();
AD9257_Configure();

View File

@ -486,8 +486,8 @@ void setupDetector() {
// hv
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
// dac
LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC, 1,
0, "");
LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC, 0,
"");
resetCore();
resetPeripheral();

View File

@ -4,6 +4,10 @@
#include <inttypes.h>
#ifdef JUNGFRAUD
void AD9257_Set_Jungfrau_Hardware_Version_1_0(int val);
#endif
/**
* Set Defines
* @param reg spi register

View File

@ -5,10 +5,12 @@
#include <inttypes.h>
void LTC2620_D_SetDefines(int hardMinV, int hardMaxV, char *driverfname,
int numdacs, int numdevices, int startingDeviceIndex,
int numdacs, int numpowers,
char *powerdownDriverfname);
int LTC2620_D_GetMaxNumSteps();
int LTC2620_D_GetPowerDownValue();
int LTC2620_D_GetMinInput();
int LTC2620_D_GetMaxInput();
/**
* Convert voltage to dac units

View File

@ -5,8 +5,8 @@
#include <sys/types.h>
int resetFPGA(char *mess);
int loadDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex);
int loadDeviceTree(char *mess);
int checksBeforeCreatingDeviceTree(char *mess);
int createDeviceTree(char *mess);
int verifyDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex);
int verifyDeviceTree(char *mess);

View File

@ -184,7 +184,7 @@ uint32_t readRegister16And32(uint32_t offset);
#if defined(XILINX_CHIPTESTBOARDD)
void cleanFifos();
void resetFlow();
int waitTranseiverReset(char *mess);
int waitTransceiverReset(char *mess);
#ifdef VIRTUAL
void setTransceiverAlignment(int align);
#endif
@ -424,6 +424,8 @@ int getPower();
void setPower(enum DACINDEX ind, int val);
void powerOff();
#elif XILINX_CHIPTESTBOARDD
int isPowerValid(enum DACINDEX ind, int val);
int getPower();
void setPower(enum DACINDEX ind, int val);
#endif

View File

@ -172,6 +172,14 @@ uint32_t AD9257_DigMask = 0x0;
int AD9257_DigOffset = 0x0;
int AD9257_VrefVoltage = 0;
#ifdef JUNGFRAUD
int AD9257_is_Jungfrau_Hardware_Version_1_0 = 0;
void AD9257_Set_Jungfrau_Hardware_Version_1_0(int val) {
AD9257_is_Jungfrau_Hardware_Version_1_0 = val;
}
#endif
void AD9257_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk,
uint32_t dmsk, int dofst) {
AD9257_Reg = reg;
@ -286,8 +294,18 @@ void AD9257_Configure() {
AD9257_OUT_BINARY_OFST_VAL | AD9257_OUT_LVDS_IEEE_VAL);
// output clock phase
#ifdef JUNGFRAUD
if (AD9257_is_Jungfrau_Hardware_Version_1_0) {
LOG(logINFO, ("\tOutput clock phase: 120\n"));
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_120_VAL);
} else {
LOG(logINFO, ("\tOutput clock phase: 180\n"));
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_180_VAL);
}
#else
LOG(logINFO, ("\tOutput clock phase: 180\n"));
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_180_VAL);
#endif
// all devices on chip to receive next command
LOG(logINFO, ("\tAll devices on chip to receive next command\n"));

View File

@ -9,6 +9,7 @@
/* LTC2620 DAC DEFINES */
#define LTC2620_D_PWR_DOWN_VAL (-100)
#define LTC2620_D_MIN_DAC_VAL (0)
#define LTC2620_D_MAX_DAC_VAL (4095) // 12 bits
#define LTC2620_D_MAX_STEPS (LTC2620_D_MAX_DAC_VAL + 1)
@ -18,17 +19,15 @@ int LTC2620_D_HardMaxVoltage = 0;
char LTC2620_D_DriverFileName[MAX_STR_LENGTH];
char LTC2620_D_PowerDownDriverFileName[MAX_STR_LENGTH];
int LTC2620_D_NumDacs = 0;
int LTC2620_D_NumDevices = 0;
int LTC2620_D_NumChannelsPerDevice = 0;
int LTC2620_D_DacDriverStartingDeviceIndex = 0;
int LTC2620_D_NumDacsOnly = 0;
void LTC2620_D_SetDefines(int hardMinV, int hardMaxV, char *driverfname,
int numdacs, int numdevices, int startingDeviceIndex,
int numdacs, int numpowers,
char *powerdownDriverfname) {
LOG(logINFOBLUE,
("Configuring DACs (LTC2620) to %s\n\t (numdacs:%d, hard min:%d, hard "
"max: %dmV, idev:%d)\n",
driverfname, numdacs, hardMinV, hardMaxV, startingDeviceIndex));
"max: %dmV)\n",
driverfname, numdacs, hardMinV, hardMaxV));
LTC2620_D_HardMinVoltage = hardMinV;
LTC2620_D_HardMaxVoltage = hardMaxV;
memset(LTC2620_D_DriverFileName, 0, MAX_STR_LENGTH);
@ -36,15 +35,17 @@ void LTC2620_D_SetDefines(int hardMinV, int hardMaxV, char *driverfname,
memset(LTC2620_D_PowerDownDriverFileName, 0, MAX_STR_LENGTH);
strcpy(LTC2620_D_PowerDownDriverFileName, powerdownDriverfname);
LTC2620_D_NumDacs = numdacs;
LTC2620_D_NumDevices = numdevices;
LTC2620_D_NumChannelsPerDevice = LTC2620_D_NumDacs / LTC2620_D_NumDevices;
LTC2620_D_DacDriverStartingDeviceIndex = startingDeviceIndex;
LTC2620_D_NumDacsOnly = numdacs - numpowers;
}
int LTC2620_D_GetMaxNumSteps() { return LTC2620_D_MAX_STEPS; }
int LTC2620_D_GetPowerDownValue() { return LTC2620_D_PWR_DOWN_VAL; }
int LTC2620_D_GetMinInput() { return LTC2620_D_MIN_DAC_VAL; }
int LTC2620_D_GetMaxInput() { return LTC2620_D_MAX_DAC_VAL; }
int LTC2620_D_VoltageToDac(int voltage, int *dacval) {
return ConvertToDifferentRange(LTC2620_D_HardMinVoltage,
LTC2620_D_HardMaxVoltage, 0,
@ -94,7 +95,10 @@ int LTC2620_D_SetDACValue(int dacnum, int val, int mV, char *dacname,
int dacmV = val;
if (mV) {
ret = LTC2620_D_VoltageToDac(val, dacval);
} else if (val >= 0) {
}
// mV only for print out (dont convert to mV for power regulators)
else if (val >= 0 && dacnum < LTC2620_D_NumDacsOnly) {
// do not convert power down dac val
ret = LTC2620_D_DacToVoltage(val, &dacmV);
}
@ -109,8 +113,16 @@ int LTC2620_D_SetDACValue(int dacnum, int val, int mV, char *dacname,
// print and set
#ifdef XILINX_CHIPTESTBOARDD
if (*dacval >= 0) {
LOG(logINFO, ("Setting DAC %2d [%-6s] : %d dac (%d mV)\n", dacnum,
dacname, *dacval, dacmV));
// also print mV
if (dacnum < LTC2620_D_NumDacsOnly) {
LOG(logINFO, ("Setting DAC %2d [%-6s] : %d dac (%d mV)\n",
dacnum, dacname, *dacval, dacmV));
}
// do not print mV for power regulators
else {
LOG(logINFO, ("Setting Power DAC%2d [%-6s] : %d dac \n", dacnum,
dacname, *dacval));
}
}
#else
if ((*dacval >= 0) || (*dacval == LTC2620_D_PWR_DOWN_VAL)) {
@ -125,10 +137,7 @@ int LTC2620_D_SetDACValue(int dacnum, int val, int mV, char *dacname,
char fname[MAX_STR_LENGTH];
memset(fname, 0, MAX_STR_LENGTH);
#ifdef XILINX_CHIPTESTBOARDD
int idev = LTC2620_D_DacDriverStartingDeviceIndex +
(dacnum / LTC2620_D_NumChannelsPerDevice);
int idac = dacnum % LTC2620_D_NumChannelsPerDevice;
sprintf(fname, fnameFormat, idev, idac);
sprintf(fname, fnameFormat, dacnum);
#else
sprintf(fname, "%s%d", fnameFormat, dacnum);
#endif

View File

@ -13,9 +13,9 @@
/* global variables */
#define CSP0 (0xB0080000)
#define CSP1 (0xB0050000) // udp
#define MEM_SIZE (0x10000)
//#define MEM_SIZE_CSP0 (4096)
//#define MEM_SIZE_CSP1 (2 * 4096)
#define MEM_SIZE_CSP0 (0x10000)
#define MEM_SIZE_CSP1 (0x2000) // smaller size for udp
u_int32_t *csp0base = 0;
u_int32_t *csp1base = 0;
@ -52,6 +52,7 @@ u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
int mapCSP0(void) {
u_int32_t csps[2] = {CSP0, CSP1};
u_int32_t **cspbases[2] = {&csp0base, &csp1base};
u_int32_t memsize[2] = {MEM_SIZE_CSP0, MEM_SIZE_CSP1};
char names[2][10] = {"csp0base", "csp1base"};
for (int i = 0; i < 2; ++i) {
@ -59,10 +60,11 @@ int mapCSP0(void) {
if (*cspbases[i] == 0) {
LOG(logINFO, ("Mapping memory for %s\n", names[i]));
#ifdef VIRTUAL
*cspbases[i] = malloc(MEM_SIZE);
*cspbases[i] = malloc(memsize[i]);
if (*cspbases[i] == NULL) {
LOG(logERROR,
("Could not allocate virtual memory for %s.\n", names[i]));
("Could not allocate virtual memory of size %d for %s.\n",
memsize[i], names[i]));
return FAIL;
}
LOG(logINFO, ("memory allocated for %s\n", names[i]));
@ -75,15 +77,16 @@ int mapCSP0(void) {
LOG(logDEBUG1,
("/dev/mem opened for %s, (CSP:0x%x)\n", names[i], csps[i]));
*cspbases[i] =
(u_int32_t *)mmap(0, MEM_SIZE, PROT_READ | PROT_WRITE,
(u_int32_t *)mmap(0, memsize[i], PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, fd, csps[i]);
if (*cspbases[i] == MAP_FAILED) {
LOG(logERROR, ("Can't map memmory area for %s\n", names[i]));
return FAIL;
}
#endif
LOG(logINFO, ("%s mapped from %p to %p,(CSP:0x%x) \n", names[i],
*cspbases[i], *cspbases[i] + MEM_SIZE, csps[i]));
LOG(logINFO,
("%s mapped of size %d from %p to %p,(CSP:0x%x) \n", names[i],
memsize[i], *cspbases[i], *cspbases[i] + memsize[i], csps[i]));
// LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
} else
LOG(logINFO, ("Memory %s already mapped before\n", names[i]));

View File

@ -35,8 +35,8 @@ int resetFPGA(char *mess) {
return OK;
}
int loadDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex) {
if (verifyDeviceTree(mess, adcDeviceIndex, dacDeviceIndex) == OK)
int loadDeviceTree(char *mess) {
if (verifyDeviceTree(mess) == OK)
return OK;
if (checksBeforeCreatingDeviceTree(mess) == FAIL)
@ -45,7 +45,7 @@ int loadDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex) {
if (createDeviceTree(mess) == FAIL)
return FAIL;
if (verifyDeviceTree(mess, adcDeviceIndex, dacDeviceIndex) == FAIL) {
if (verifyDeviceTree(mess) == FAIL) {
LOG(logERROR, ("Device tree loading failed at verification\n"));
return FAIL;
}
@ -129,10 +129,8 @@ int createDeviceTree(char *mess) {
return OK;
}
int verifyDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex) {
int verifyDeviceTree(char *mess) {
LOG(logINFOBLUE, ("Verifying Device Tree...\n"));
*adcDeviceIndex = 1;
*dacDeviceIndex = 2;
#ifndef VIRTUAL
// check if iio:device0-4 exists in device tree destination
@ -170,8 +168,6 @@ int verifyDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex) {
strstr(retvals, deviceNames[hardcodedDeviceIndex + 1]) !=
NULL) {
++hardcodedDeviceIndex;
*adcDeviceIndex = 4;
*dacDeviceIndex = 1;
} else {
snprintf(
mess, MAX_STR_LENGTH,
@ -188,9 +184,6 @@ int verifyDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex) {
hardcodedDeviceIndex = 1;
}
#endif
LOG(logINFOBLUE, ("Device tree verified successfully [temp: 0, adc:%d, "
"dac:%d, %d, %d]\n",
*adcDeviceIndex, *dacDeviceIndex, *dacDeviceIndex + 1,
*dacDeviceIndex + 2));
LOG(logINFOBLUE, ("Device tree verified successfully\n"));
return OK;
}

View File

@ -1297,7 +1297,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
ind, getVLimit());
LOG(logERROR, (mess));
}
#ifdef CHIPTESTBOARDD
else if (!isPowerValid(serverDacIndex, val)) {
ret = FAIL;
sprintf(
@ -1306,10 +1306,14 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
"should be between %d and %d mV\n",
ind,
(serverDacIndex == D_PWR_IO ? VIO_MIN_MV : POWER_RGLTR_MIN),
#ifdef CHIPTESTBOARDD
(VCHIP_MAX_MV - VCHIP_POWER_INCRMNT));
#else
POWER_RGLTR_MAX);
#endif
LOG(logERROR, (mess));
}
#endif
else {
setPower(serverDacIndex, val);
}
@ -2023,8 +2027,7 @@ int acquire(int blocking, int file_des) {
// chipv1.1 has to be configured before acquisition
if (getChipVersion() == 11 && !isChipConfigured()) {
ret = FAIL;
strcpy(mess,
"Could not start acquisition. Chip is not configured. "
strcpy(mess, "Could not start acquisition. Chip is not configured. "
"Power it on to configure it.\n");
LOG(logERROR, (mess));
} else
@ -2044,8 +2047,7 @@ int acquire(int blocking, int file_des) {
getReadoutMode() == DIGITAL_AND_TRANSCEIVER) &&
(getNumDigitalSamples() <= 0)) {
ret = FAIL;
sprintf(
mess,
sprintf(mess,
"Could not start acquisition. Invalid number of digital "
"samples: %d.\n",
getNumDigitalSamples());
@ -2081,8 +2083,7 @@ int acquire(int blocking, int file_des) {
uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip);
sprintf(
mess,
sprintf(mess,
"Invalid udp source ip address for this detector. Must "
"be "
"same as hardware detector ip address %s in 1G readout "
@ -2098,8 +2099,7 @@ int acquire(int blocking, int file_des) {
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess,
"Could not start acquisition because a scan is "
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess));
} else {

View File

@ -23,6 +23,10 @@ SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(m
OBJS = $(SRCS:.c=.o)
all: clean $(PROGS)
local: CC := gcc
local: clean $(PROGS)
version: clean versioning $(PROGS)
boot: $(OBJS)

View File

@ -39,8 +39,6 @@ char initErrorMessage[MAX_STR_LENGTH];
int detPos[2] = {0, 0};
int adcDeviceIndex = 0;
int dacDeviceIndex = 0;
int chipConfigured = 0;
int analogEnable = 0;
int digitalEnable = 0;
@ -75,8 +73,7 @@ void basictests() {
return;
}
initError =
loadDeviceTree(initErrorMessage, &adcDeviceIndex, &dacDeviceIndex);
initError = loadDeviceTree(initErrorMessage);
if (initError == FAIL) {
return;
}
@ -390,19 +387,18 @@ void setupDetector() {
initializePatternWord();
#endif
// initialization only at start up (restart fpga)
initError = waitTranseiverReset(initErrorMessage);
if (initError == FAIL) {
return;
}
// power off chip
// initError = waitTransceiverReset(initErrorMessage);
// if (initError == FAIL) {
// return;
// }
// // power off chip
initError = powerChip(0, initErrorMessage);
if (initError == FAIL) {
return;
}
// if (initError == FAIL) {
// return;
// }
LTC2620_D_SetDefines(DAC_MAX_MV, DAC_MIN_MV, DAC_DRIVER_FILE_NAME, NDAC,
DAC_DRIVER_NUM_DEVICES, dacDeviceIndex,
DAC_POWERDOWN_DRIVER_FILE_NAME);
LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC,
NPWR, DAC_POWERDOWN_DRIVER_FILE_NAME);
LOG(logINFOBLUE, ("Powering down all dacs\n"));
for (int idac = 0; idac < NDAC; ++idac) {
setDAC(idac, LTC2620_D_GetPowerDownValue(), 0);
@ -458,7 +454,7 @@ void resetFlow() {
bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) & ~RST_F_MSK);
}
int waitTranseiverReset(char *mess) {
int waitTransceiverReset(char *mess) {
#ifndef VIRTUAL
int resetTransceiverDone = (bus_r(TRANSCEIVERSTATUS) & RESETRXDONE_MSK);
int times = 0;
@ -556,7 +552,7 @@ int powerChip(int on, char *mess) {
POWER_VCC_C_MSK | POWER_VCC_D_MSK;
if (on) {
LOG(logINFOBLUE, ("Powering chip: on\n"));
bus_w(addr, bus_r(addr) & ~mask);
bus_w(addr, bus_r(addr) | mask);
if (configureChip(mess) == FAIL)
return FAIL;
@ -566,7 +562,7 @@ int powerChip(int on, char *mess) {
chipConfigured = 1;
} else {
LOG(logINFOBLUE, ("Powering chip: off\n"));
bus_w(addr, bus_r(addr) | mask);
bus_w(addr, bus_r(addr) & ~mask);
chipConfigured = 0;
@ -588,7 +584,7 @@ int getPowerChip() {
uint32_t addr = CTRL_REG;
uint32_t mask = POWER_VIO_MSK | POWER_VCC_A_MSK | POWER_VCC_B_MSK |
POWER_VCC_C_MSK | POWER_VCC_D_MSK;
return (((bus_r(addr) & mask) == mask) ? 0 : 1);
return (((bus_r(addr) & mask) == mask) ? 1 : 0);
}
int configureChip(char *mess) {
@ -981,21 +977,8 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dacName, val,
(mV ? "mV" : "dac units")));
int dacval = val;
#ifdef VIRTUAL
LOG(logINFO, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dacName, val,
(mV ? "mV" : "dac units")));
if (!mV) {
dacValues[ind] = val;
}
// convert to dac units
else if (LTC2620_D_VoltageToDac(val, &dacval) == OK) {
dacValues[ind] = dacval;
}
#else
if (LTC2620_D_SetDACValue((int)ind, val, mV, dacName, &dacval) == OK)
dacValues[ind] = dacval;
#endif
}
int getDAC(enum DACINDEX ind, int mV) {
@ -1045,74 +1028,91 @@ void setVLimit(int l) {
vLimit = l;
}
int getPower(enum DACINDEX ind) {
// check power enable first
uint32_t addr = CTRL_REG;
uint32_t offset = POWER_VCC_A_OFST + (int)(D_PWR_A - ind);
if (ind == D_PWR_IO)
offset = POWER_VIO_OFST;
uint32_t mask = (1 << offset);
if ((bus_r(addr) & mask) != 0) {
LOG(logINFO, ("Power for dac %d is off\n", ind));
int isPowerValid(enum DACINDEX ind, int val) {
char *powerNames[] = {PWR_NAMES};
int pwrIndex = (int)(ind - D_PWR_D);
int min = POWER_RGLTR_MIN;
if (!strcmp(powerNames[pwrIndex], "IO")) {
min = VIO_MIN_MV;
}
// not power_rgltr_max because it is allowed only upto vchip max - 200
if (val != 0 && (val != LTC2620_D_GetPowerDownValue()) &&
(val < min || val > POWER_RGLTR_MAX)) {
LOG(logERROR,
("Invalid value of %d mV for Power V%s. Is not between %d and "
"%d mV\n",
val, powerNames[pwrIndex], min, POWER_RGLTR_MAX));
return 0;
}
return 1;
}
int getPower(enum DACINDEX ind) {
char *powerNames[] = {PWR_NAMES};
int pwrIndex = (int)(ind - D_PWR_D);
// check dac value
// not set yet
if (dacValues[ind] == -1) {
LOG(logERROR,
("Power enabled, but unknown dac value for power index %d!", ind));
("Unknown dac value for Power V%s!\n", powerNames[pwrIndex]));
return -1;
}
// dac powered off
if (dacValues[ind] == LTC2620_D_GetPowerDownValue()) {
LOG(logWARNING,
("Power %d enabled, dac value %d, voltage at minimum or 0\n", ind,
LTC2620_D_GetPowerDownValue()));
LOG(logWARNING, ("Power V%s powered down\n", powerNames[pwrIndex]));
return LTC2620_D_GetPowerDownValue();
}
// get dac in mV
// (unless its a different voltage range compared to other dacs)
return getDAC(ind, 1);
int retval = -1;
ConvertToDifferentRange(LTC2620_D_GetMaxInput(), LTC2620_D_GetMinInput(),
POWER_RGLTR_MIN, POWER_RGLTR_MAX, dacValues[ind],
&retval);
return retval;
}
void setPower(enum DACINDEX ind, int val) {
uint32_t addr = CTRL_REG;
uint32_t offset = POWER_VCC_A_OFST + (int)(D_PWR_A - ind);
if (ind == D_PWR_IO)
offset = POWER_VIO_OFST;
uint32_t mask = (1 << offset);
if (val >= 0 || val == LTC2620_D_GetPowerDownValue()) {
if (val > 0) {
LOG(logINFO, ("Setting Power to %d mV\n", val));
}
// switch off power enable
LOG(logINFO, ("\tSwitching off enable for P%d (ctrl reg)\n",
(int)(ind - D_PWR_A)));
bus_w(addr, bus_r(addr) | mask);
char *powerNames[] = {PWR_NAMES};
int pwrIndex = (int)(ind - D_PWR_D);
// power down dac
LOG(logINFO, ("\tPowering down P%d\n", (int)(ind - D_PWR_A)));
if (val == LTC2620_D_GetPowerDownValue()) {
LOG(logINFO, ("\tPowering down V%d\n", powerNames[pwrIndex]));
setDAC(ind, LTC2620_D_GetPowerDownValue(), 0);
// set dac in mV
if (val > 0) {
LOG(logINFO, ("\tSetting Power P%d (DAC %d) to %d mV\n",
(int)(ind - D_PWR_A), (int)ind, val));
setDAC(ind, val, 1);
}
// switch on power enable
if (getDAC(ind, 1) == val || val == LTC2620_D_GetPowerDownValue()) {
LOG(logINFO, ("\tSwitching on enable for P%d (ctrl reg)\n",
(int)(ind - D_PWR_A)));
bus_w(addr, bus_r(addr) & ~mask);
// set dac
else if (val >= 0) {
LOG(logINFO,
("Setting Power V%s to %d mV\n", powerNames[pwrIndex], val));
// validate value (already checked at tcp (funcs.c))
if (!isPowerValid(ind, val)) {
return;
}
// convert voltage to dac
int dacval = -1;
if (ConvertToDifferentRange(
POWER_RGLTR_MIN, POWER_RGLTR_MAX, LTC2620_D_GetMaxInput(),
LTC2620_D_GetMinInput(), val, &dacval) == FAIL) {
LOG(logERROR,
("\tCannot convert Power V%s to dac value. Invalid value of %d "
"mV. Is not between "
"%d and %d mV\n",
powerNames[pwrIndex], val, POWER_RGLTR_MIN, POWER_RGLTR_MAX));
return;
}
// set and power on/ update dac
LOG(logINFO, ("Setting Power V%s: %d mV (%d dac)\n",
powerNames[pwrIndex], val, dacval));
setDAC(ind, dacval, 0);
}
}
@ -1147,7 +1147,7 @@ int getSlowADC(int ichan, int *retval) {
#ifndef VIRTUAL
char fname[MAX_STR_LENGTH];
memset(fname, 0, MAX_STR_LENGTH);
sprintf(fname, SLOWADC_DRIVER_FILE_NAME, adcDeviceIndex, ichan);
sprintf(fname, SLOWADC_DRIVER_FILE_NAME, ichan);
LOG(logDEBUG1, ("fname %s\n", fname));
if (readParameterFromFile(fname, "slow adc", retval) == FAIL) {

View File

@ -25,14 +25,12 @@
#define DYNAMIC_RANGE (16)
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define DAC_DRIVER_NUM_DEVICES (3)
#define DAC_DRIVER_FILE_NAME \
("/sys/bus/iio/devices/iio:device%d/out_voltage%d_raw")
#define DAC_DRIVER_FILE_NAME ("/root/apps/xilinx-ctb/current_board_links/ao%d")
#define DAC_POWERDOWN_DRIVER_FILE_NAME \
("/sys/bus/iio/devices/iio:device%d/out_voltage%d_powerdown")
("/root/apps/xilinx-ctb/current_board_links/ao%d_pd")
#define SLOWADC_DRIVER_FILE_NAME \
("/sys/bus/iio/devices/iio:device%d/in_voltage%d_raw")
("/root/apps/xilinx-ctb/mythenIII_0.2_1.1/links/ai%d")
// #define SLOWDAC_CONVERTION_FACTOR_TO_UV (62.500953)
#define TEMP_DRIVER_FILE_NAME \
@ -61,7 +59,10 @@
#define MAX_DIGITAL_SAMPLES (0x3FFF)
#define DAC_MIN_MV (0)
#define DAC_MAX_MV (2500)
#define DAC_MAX_MV (2048)
#define POWER_RGLTR_MIN (1041)
#define POWER_RGLTR_MAX (2661)
#define VIO_MIN_MV (1200) // for fpga to function
#define TICK_CLK (20) // MHz (trig_timeFromStart, frametime, timeFromStart)
#define RUN_CLK \
@ -117,28 +118,35 @@ enum DACINDEX {
D_PWR_C
};
#define PWR_NAMES "D", "_unknown", "IO", "A", "B", "C"
/* Struct Definitions */
// For arm has to be multiple of 16
// We dont byteswap in the upd_gen so the order has to be different
typedef struct udp_header_struct {
uint32_t udp_destmac_msb;
uint16_t udp_srcmac_msb;
uint16_t udp_destmac_lsb;
uint32_t udp_srcmac_lsb;
uint32_t udp_destmac_msb;
uint8_t ip_tos;
uint8_t ip_ihl : 4, ip_ver : 4;
uint16_t udp_ethertype;
uint16_t ip_identification;
uint16_t ip_totallength;
uint32_t udp_srcmac_lsb;
uint8_t ip_protocol;
uint8_t ip_ttl;
uint16_t ip_fragmentoffset : 13, ip_flags : 3;
uint16_t ip_srcip_msb;
uint16_t ip_checksum;
uint16_t ip_identification;
uint16_t ip_totallength;
uint16_t ip_destip_msb;
uint16_t ip_srcip_lsb;
uint16_t udp_srcport;
uint16_t ip_destip_lsb;
uint16_t ip_srcip_msb;
uint16_t ip_checksum;
uint16_t udp_checksum;
uint16_t udp_destport;
uint16_t udp_srcport;
uint16_t ip_destip_lsb;
// padding
uint32_t padding0;
uint32_t padding1;
} udp_header;
#define IP_HEADER_SIZE (20)

View File

@ -82,10 +82,11 @@ if(SLS_USE_TEXTCLIENT)
set(det_bin_names "sls_detector_put"
"sls_detector_get"
"sls_detector_acquire"
"sls_detector_acquire_zmq"
"sls_detector_help"
"sls_detector"
)
set(det_cmd_name "PUT" "GET" "READOUT" "HELP" "INFER")
set(det_cmd_name "PUT" "GET" "READOUT" "READOUTZMQ" "HELP" "INFER")
list(LENGTH det_bin_names len1)
math(EXPR len2 "${len1} - 1")

View File

@ -71,6 +71,9 @@ class Caller {
using StringMap = std::map<std::string, std::string>;
Detector *ptr; // pointer to the detector that executes the command
static void EmptyDataCallBack(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex, void *this_pointer);
FunctionMap functions{
{"list", &Caller::list},

View File

@ -397,6 +397,9 @@ class Caller {
using StringMap = std::map<std::string, std::string>;
Detector *ptr; // pointer to the detector that executes the command
static void EmptyDataCallBack(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex, void *this_pointer);
FunctionMap functions{
{"list", &Caller::list},

View File

@ -212,6 +212,12 @@ std::string Caller::hostname(int action) {
}
return os.str();
}
void Caller::EmptyDataCallBack(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex, void *this_pointer) {
LOG(logDEBUG) << "EmptyDataCallBack to start up zmq sockets";
}
std::string Caller::acquire(int action) {
std::ostringstream os;
if (action == defs::HELP_ACTION) {
@ -232,6 +238,9 @@ std::string Caller::acquire(int action) {
if (det_id >= 0) {
throw RuntimeError("Individual detectors not allowed for readout.");
}
if (action == defs::READOUT_ZMQ_ACTION) {
det->registerDataCallback(&(EmptyDataCallBack), this);
}
det->acquire();
if (det->getUseReceiverFlag().squash(false)) {

View File

@ -20,6 +20,10 @@ int main(int argc, char *argv[]) {
int action = slsDetectorDefs::READOUT_ACTION;
#endif
#ifdef READOUTZMQ
int action = slsDetectorDefs::READOUT_ZMQ_ACTION;
#endif
#ifdef HELP
int action = slsDetectorDefs::HELP_ACTION;
#endif
@ -38,7 +42,8 @@ int main(int argc, char *argv[]) {
sls::CmdParser parser;
parser.Parse(argc, argv);
if (action == slsDetectorDefs::READOUT_ACTION)
if (action == slsDetectorDefs::READOUT_ACTION ||
action == slsDetectorDefs::READOUT_ZMQ_ACTION)
parser.setCommand("acquire");
if (parser.isHelp())

View File

@ -744,8 +744,9 @@ void DetectorImpl::readFrameFromReceiver() {
}
}
LOG(logDEBUG) << "Call Back Info:" << "\n\t nDetPixelsX: "
<< nDetPixelsX << "\n\t nDetPixelsY: " << nDetPixelsY
LOG(logDEBUG) << "Call Back Info:"
<< "\n\t nDetPixelsX: " << nDetPixelsX
<< "\n\t nDetPixelsY: " << nDetPixelsY
<< "\n\t databytes: " << multisize
<< "\n\t dynamicRange: " << dynamicRange;
@ -763,8 +764,8 @@ void DetectorImpl::readFrameFromReceiver() {
callbackImage = multigappixels;
imagesize = n;
}
LOG(logDEBUG) << "Image Info:" << "\n\tnDetActualPixelsX: "
<< nDetActualPixelsX
LOG(logDEBUG) << "Image Info:"
<< "\n\tnDetActualPixelsX: " << nDetActualPixelsX
<< "\n\tnDetActualPixelsY: " << nDetActualPixelsY
<< "\n\timagesize: " << imagesize
<< "\n\tdynamicRange: " << dynamicRange;
@ -799,7 +800,8 @@ void DetectorImpl::readFrameFromReceiver() {
int DetectorImpl::insertGapPixels(char *image, char *&gpImage, bool quadEnable,
int dr, int &nPixelsx, int &nPixelsy) {
LOG(logDEBUG) << "Insert Gap pixels:" << "\n\t nPixelsx: " << nPixelsx
LOG(logDEBUG) << "Insert Gap pixels:"
<< "\n\t nPixelsx: " << nPixelsx
<< "\n\t nPixelsy: " << nPixelsy
<< "\n\t quadEnable: " << quadEnable << "\n\t dr: " << dr;
@ -884,10 +886,12 @@ int DetectorImpl::insertGapPixels(char *image, char *&gpImage, bool quadEnable,
<< "nMod1Pixelsy: " << nMod1Pixelsy << "\n\t"
<< "nMod1GapPixelsx: " << nMod1GapPixelsx << "\n\t"
<< "nMod1GapPixelsy: " << nMod1GapPixelsy << "\n\t"
<< "nChipy: " << nChipy << "\n\t" << "nChipx: " << nChipx
<< "\n\t" << "nModx: " << nModx << "\n\t"
<< "nMody: " << nMody << "\n\t" << "nTotx: " << nTotx
<< "\n\t" << "nToty: " << nToty << "\n\t"
<< "nChipy: " << nChipy << "\n\t"
<< "nChipx: " << nChipx << "\n\t"
<< "nModx: " << nModx << "\n\t"
<< "nMody: " << nMody << "\n\t"
<< "nTotx: " << nTotx << "\n\t"
<< "nToty: " << nToty << "\n\t"
<< "bytesPerPixel: " << bytesPerPixel << "\n\t"
<< "imagesize: " << imagesize << "\n\t"
<< "nChipBytesx: " << nChipBytesx << "\n\t"
@ -1219,10 +1223,14 @@ int DetectorImpl::acquire() {
if (acquisition_finished != nullptr) {
// status
runStatus status = IDLE;
auto statusList = Parallel(&Module::getRunStatus, {});
status = statusList.squash(ERROR);
// difference, but none error
// if any slave still waiting, wait up to 1s (gotthard)
for (int i = 0; i != 20 && statusList.any(WAITING); ++i) {
std::this_thread::sleep_for(std::chrono::milliseconds(50));
statusList = Parallel(&Module::getRunStatus, {});
}
runStatus status = statusList.squash(ERROR);
// inconsistent status (squash error), but none of them in error
if (status == ERROR && (!statusList.any(ERROR))) {
// handle jf sync issue (master idle, slaves stopped)
if (statusList.contains_only(IDLE, STOPPED)) {
@ -1318,13 +1326,13 @@ void DetectorImpl::startAcquisition(const bool blocking, Positions pos) {
Parallel(&Module::startAndReadAll, masters);
// ensure all status normal (slaves not blocking)
// to catch those slaves that are still 'waiting'
auto status = Parallel(&Module::getRunStatus, pos);
// if any slave still waiting, wait up to 1s
for (int i = 0; i != 20 && status.any(WAITING); ++i) {
auto statusList = Parallel(&Module::getRunStatus, pos);
// if any slave still waiting, wait up to 1s (gotthard)
for (int i = 0; i != 20 && statusList.any(WAITING); ++i) {
std::this_thread::sleep_for(std::chrono::milliseconds(50));
status = Parallel(&Module::getRunStatus, pos);
statusList = Parallel(&Module::getRunStatus, pos);
}
if (!status.contains_only(IDLE, STOPPED, RUN_FINISHED)) {
if (!statusList.contains_only(IDLE, STOPPED, RUN_FINISHED)) {
throw RuntimeError("Acquisition not successful. "
"Unexpected detector status");
}

View File

@ -186,7 +186,7 @@ void HDF5DataFile::CreateFile() {
// property list
H5::DSetCreatPropList plist;
H5::DSetCreatPropList plistPara;
int fill_value = -1;
uint64_t fill_value = -1;
plist.setFillValue(dataType, &fill_value);
// plistPara.setFillValue(dataType, &fill_value);
plist.setChunk(DATA_RANK, dimsChunk);

View File

@ -215,7 +215,7 @@ std::string CreateVirtualHDF5File(
// property list
H5::DSetCreatPropList plist;
int fill_value = -1;
uint64_t fill_value = -1;
plist.setFillValue(dataType, &fill_value);
std::vector<H5::DSetCreatPropList> plistPara(paraSize);
// ignoring last fill (string)

View File

@ -216,7 +216,13 @@ typedef struct {
/**
type of action performed (for text client)
*/
enum { GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION };
enum {
GET_ACTION,
PUT_ACTION,
READOUT_ACTION,
HELP_ACTION,
READOUT_ZMQ_ACTION
};
/**
dimension indexes

View File

@ -4,11 +4,11 @@
#define RELEASE "developer"
#define APILIB "developer 0x230224"
#define APIRECEIVER "developer 0x230224"
#define APICTB "developer 0x240725"
#define APIGOTTHARD "developer 0x240725"
#define APIJUNGFRAU "developer 0x240725"
#define APIMYTHEN3 "developer 0x240725"
#define APIMOENCH "developer 0x240725"
#define APIXILINXCTB "developer 0x240725"
#define APIEIGER "developer 0x240725"
#define APIGOTTHARD2 "developer 0x240731"
#define APICTB "developer 0x240820"
#define APIGOTTHARD "developer 0x240820"
#define APIGOTTHARD2 "developer 0x240820"
#define APIMYTHEN3 "developer 0x240820"
#define APIMOENCH "developer 0x240820"
#define APIEIGER "developer 0x240820"
#define APIXILINXCTB "developer 0x240820"
#define APIJUNGFRAU "developer 0x240822"