readnlines->partialread, better debugging for TCP socket interface bug

This commit is contained in:
2021-08-13 12:34:50 +02:00
parent eb652557b6
commit 62d697e91f
35 changed files with 131 additions and 119 deletions

View File

@ -38,7 +38,7 @@ int Beb_top = 0;
uint64_t Beb_deactivatedNextFrameNumber = 0;
int Beb_quadEnable = 0;
int Beb_positions[2] = {0, 0};
int Beb_readNLines = MAX_ROWS_PER_READOUT;
int Beb_partialReadout = MAX_ROWS_PER_READOUT;
int Beb_deactivated_transmission_flowcontrol_10g = 0;
int Beb_deactivated_transmission_delay_frame = 0;
int Beb_deactivated_transmission_delay_left = 0;
@ -1214,7 +1214,7 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
unsigned int maxnl = MAX_ROWS_PER_READOUT;
unsigned int maxnp = (ten_gig ? 4 : 16) * Beb_bit_mode;
unsigned int nl = Beb_readNLines;
unsigned int nl = Beb_partialReadout;
unsigned int npackets = (nl * maxnp) / maxnl;
if ((nl * maxnp) % maxnl) {
LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image "
@ -1612,7 +1612,7 @@ int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable) {
return OK;
}
void Beb_SetReadNLines(int value) { Beb_readNLines = value; }
void Beb_SetPartialReadout(int value) { Beb_partialReadout = value; }
uint16_t Beb_swap_uint16(uint16_t val) { return (val << 8) | (val >> 8); }

View File

@ -108,7 +108,7 @@ int Beb_SetDetectorPosition(int pos[]);
int Beb_SetNextFrameNumber(uint64_t value);
int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable);
void Beb_SetReadNLines(int value);
void Beb_SetPartialReadout(int value);
uint16_t Beb_swap_uint16(uint16_t val);
int Beb_open(u_int32_t **csp0base, u_int32_t offset);

View File

@ -1554,24 +1554,24 @@ int Feb_Control_SetChipSignalsToTrimQuad(int enable) {
return 1;
}
int Feb_Control_SetReadNLines(int value) {
LOG(logINFO, ("Setting Read N Lines to %d\n", value));
int Feb_Control_SetPartialReadout(int value) {
LOG(logINFO, ("Setting Partial Readout to %d\n", value));
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
DAQ_REG_PARTIAL_READOUT, value, 0, 0)) {
LOG(logERROR, ("Could not write %d to read n lines reg\n", value));
LOG(logERROR, ("Could not write %d to Partial Readout reg\n", value));
return 0;
}
return 1;
}
int Feb_Control_GetReadNLines() {
int Feb_Control_GetPartialReadout() {
uint32_t regVal = 0;
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),
DAQ_REG_PARTIAL_READOUT, &regVal)) {
LOG(logERROR, ("Could not read back read n lines reg\n"));
LOG(logERROR, ("Could not read back Partial Readout reg\n"));
return -1;
}
LOG(logDEBUG1, ("Retval read n lines: %d\n", regVal));
LOG(logDEBUG1, ("Retval Partial Readout: %d\n", regVal));
return regVal;
}

View File

@ -88,8 +88,8 @@ void Feb_Control_SetMasterVariable(int val);
int Feb_Control_SetMaster(enum MASTERINDEX ind);
int Feb_Control_SetQuad(int val);
int Feb_Control_SetChipSignalsToTrimQuad(int enable);
int Feb_Control_SetReadNLines(int value);
int Feb_Control_GetReadNLines();
int Feb_Control_SetPartialReadout(int value);
int Feb_Control_GetPartialReadout();
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval);

View File

@ -88,7 +88,7 @@ uint64_t eiger_virtual_nextframenumber = 1;
int eiger_virtual_detPos[2] = {0, 0};
int eiger_virtual_test_mode = 0;
int eiger_virtual_quad_mode = 0;
int eiger_virtual_read_nlines = 256;
int eiger_virtual_partial_readout = 256;
int eiger_virtual_interrupt_subframe = 0;
int eiger_virtual_left_datastream = 1;
int eiger_virtual_right_datastream = 1;
@ -708,7 +708,7 @@ void setupDetector() {
setIODelay(DEFAULT_IO_DELAY);
setTiming(DEFAULT_TIMING_MODE);
setNextFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
setReadNLines(MAX_ROWS_PER_READOUT);
setPartialReadout(MAX_ROWS_PER_READOUT);
// SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
eiger_tau_ns = DEFAULT_RATE_CORRECTION;
setRateCorrection(DEFAULT_RATE_CORRECTION);
@ -1671,29 +1671,29 @@ int getInterruptSubframe() {
#endif
}
int setReadNLines(int value) {
int setPartialReadout(int value) {
if (value < 0)
return FAIL;
#ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (!Feb_Control_SetReadNLines(value)) {
if (!Feb_Control_SetPartialReadout(value)) {
sharedMemory_unlockLocalLink();
return FAIL;
}
sharedMemory_unlockLocalLink();
Beb_SetReadNLines(value);
Beb_SetPartialReadout(value);
#else
eiger_virtual_read_nlines = value;
eiger_virtual_partial_readout = value;
#endif
return OK;
}
int getReadNLines() {
int getPartialReadout() {
#ifdef VIRTUAL
return eiger_virtual_read_nlines;
return eiger_virtual_partial_readout;
#else
sharedMemory_lockLocalLink();
int retval = Feb_Control_GetReadNLines();
int retval = Feb_Control_GetPartialReadout();
sharedMemory_unlockLocalLink();
return retval;
#endif

View File

@ -409,8 +409,8 @@ int setQuad(int value);
int getQuad();
int setInterruptSubframe(int value);
int getInterruptSubframe();
int setReadNLines(int value);
int getReadNLines();
int setPartialReadout(int value);
int getPartialReadout();
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD) || \
defined(MYTHEN3D)

View File

@ -144,8 +144,8 @@ int set_quad(int);
int get_quad(int);
int set_interrupt_subframe(int);
int get_interrupt_subframe(int);
int set_read_n_lines(int);
int get_read_n_lines(int);
int set_partial_readout(int);
int get_partial_readout(int);
void calculate_and_set_position();
int set_detector_position(int);
int check_detector_idle();

View File

@ -273,8 +273,8 @@ void function_table() {
flist[F_GET_QUAD] = &get_quad;
flist[F_SET_INTERRUPT_SUBFRAME] = &set_interrupt_subframe;
flist[F_GET_INTERRUPT_SUBFRAME] = &get_interrupt_subframe;
flist[F_SET_READ_N_LINES] = &set_read_n_lines;
flist[F_GET_READ_N_LINES] = &get_read_n_lines;
flist[F_SET_PARTIAL_READOUT] = &set_partial_readout;
flist[F_GET_PARTIAL_READOUT] = &get_partial_readout;
flist[F_SET_POSITION] = &set_detector_position;
flist[F_SET_SOURCE_UDP_MAC] = &set_source_udp_mac;
flist[F_GET_SOURCE_UDP_MAC] = &get_source_udp_mac;
@ -4717,14 +4717,14 @@ int get_interrupt_subframe(int file_des) {
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_read_n_lines(int file_des) {
int set_partial_readout(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting read n lines: %u\n", arg));
LOG(logDEBUG1, ("Setting partial readout: %u\n", arg));
#ifndef EIGERD
functionNotImplemented();
@ -4734,7 +4734,7 @@ int set_read_n_lines(int file_des) {
if (arg <= 0 || arg > MAX_ROWS_PER_READOUT) {
ret = FAIL;
sprintf(mess,
"Could not set number of lines readout. Must be between 1 "
"Could not set partial readout. Must be between 1 "
"and %d\n",
MAX_ROWS_PER_READOUT);
LOG(logERROR, (mess));
@ -4746,24 +4746,24 @@ int set_read_n_lines(int file_des) {
if ((arg * maxnp) % maxnl) {
ret = FAIL;
sprintf(mess,
"Could not set %d number of lines readout. For %d bit "
"Could not set %d partial readout. For %d bit "
"mode and 10 giga %s, (%d (num "
"lines) x %d (max num packets for this mode)) must be "
"rows) x %d (max num packets for this mode)) must be "
"divisible by %d\n",
arg, dr, isTenGiga ? "enabled" : "disabled", arg, maxnp,
maxnl);
LOG(logERROR, (mess));
} else {
if (setReadNLines(arg) == FAIL) {
if (setPartialReadout(arg) == FAIL) {
ret = FAIL;
sprintf(mess, "Could not set read n lines to %d.\n", arg);
sprintf(mess, "Could not set partial readout to %d.\n", arg);
LOG(logERROR, (mess));
} else {
int retval = getReadNLines();
int retval = getPartialReadout();
if (arg != retval) {
ret = FAIL;
sprintf(mess,
"Could not set read n lines. Set %d, but "
"Could not set partial readout. Set %d, but "
"read %d\n",
retval, arg);
LOG(logERROR, (mess));
@ -4776,24 +4776,24 @@ int set_read_n_lines(int file_des) {
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_read_n_lines(int file_des) {
int get_partial_readout(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting read n lines\n"));
LOG(logDEBUG1, ("Getting partial readout\n"));
#ifndef EIGERD
functionNotImplemented();
#else
// get only
retval = getReadNLines();
retval = getPartialReadout();
if (retval == -1) {
ret = FAIL;
sprintf(mess, "Could not get read n lines. \n");
sprintf(mess, "Could not get partial readout. \n");
LOG(logERROR, (mess));
} else {
LOG(logDEBUG1, ("Read N Lines retval: %u\n", retval));
LOG(logDEBUG1, ("Partial readout retval: %u\n", retval));
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
@ -7126,9 +7126,9 @@ int get_receiver_parameters(int file_des) {
if (n < 0)
return printSocketReadError();
// readnlines
// partialReadout
#ifdef EIGERD
i32 = getReadNLines();
i32 = getPartialReadout();
#else
i32 = 0;
#endif