diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.c b/slsDetectorServers/eigerDetectorServer/FebControl.c index 63c67772b..608207ea6 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.c +++ b/slsDetectorServers/eigerDetectorServer/FebControl.c @@ -709,6 +709,30 @@ int Feb_Control_AcquisitionInProgress() { return STATUS_IDLE; } +int Feb_Control_ProcessingInProgress() { + unsigned int regr = 0, regl = 0; + // deactivated should return end of processing + if (!Feb_Control_activated) + return IDLE; + + if (!Feb_Interface_ReadRegister(Feb_Control_rightAddress, + FEB_REG_STATUS, ®r)) { + LOG(logERROR, ("Could not read right FEB_REG_STATUS to get feb processing status\n")); + return STATUS_ERROR; + } + if (!Feb_Interface_ReadRegister(Feb_Control_leftAddress, + FEB_REG_STATUS, ®l)) { + LOG(logERROR, ("Could not read left FEB_REG_STATUS to get feb processing status\n")); + return STATUS_ERROR; + } + // processing done + if ((regr | regl) & FEB_REG_STATUS_ACQ_DONE_MSK) { + return STATUS_IDLE; + } + // processing running + return STATUS_RUNNING; +} + int Feb_Control_AcquisitionStartedBit() { unsigned int status_reg_r = 0, status_reg_l = 0; // deactivated should return acquisition started/ready @@ -1002,8 +1026,7 @@ int Feb_Control_StopAcquisition() { unsigned int orig_value = 0; if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(), DAQ_REG_CTRL, &orig_value)) { - LOG(logERROR, ("Could not read DAQ_REG_CHIP_CMDS to send software " - "trigger\n")); + LOG(logERROR, ("Could not read DAQ_REG_CTRL to stop acquisition (send complete frames)\n")); return 0; } if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(), @@ -1012,7 +1035,27 @@ int Feb_Control_StopAcquisition() { LOG(logERROR, ("Could not send last frames.\n")); return 0; } - usleep(100 *1000); + LOG(logINFOBLUE, ("send last frame value:0x%x\n", orig_value | DAQ_CTRL_STOP)); + + // wait for feb processing to be done + int is_processing = Feb_Control_ProcessingInProgress(); + int check_error = 0; + while (is_processing != STATUS_IDLE) { + usleep(500); + is_processing = Feb_Control_ProcessingInProgress(); + + // check error only 5 times (ensuring it is not something that happens + // sometimes) + if (is_processing == STATUS_ERROR) { + if (check_error == 5) + break; + check_error++; + } // reset check_error for next time + else + check_error = 0; + + } + // stop acquisition return Feb_Control_Reset(); } @@ -1904,15 +1947,15 @@ int Feb_Control_GetLeftFPGATemp() { if (!Feb_Control_activated) { return 0; } - unsigned int temperature = 0; + unsigned int value = 0; if (!Feb_Interface_ReadRegister(Feb_Control_leftAddress, FEB_REG_STATUS, - &temperature)) { + &value)) { LOG(logERROR, ("Trouble reading FEB_REG_STATUS reg to get left feb " "temperature\n")); return 0; } - temperature = temperature >> 16; + unsigned int temperature = ((value & FEB_REG_STATUS_TEMP_MSK) >> FEB_REG_STATUS_TEMP_OFST); temperature = ((((float)(temperature) / 65536.0f) / 0.00198421639f) - 273.15f) * 1000; // Static conversation, copied from xps sysmon standalone driver diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.h b/slsDetectorServers/eigerDetectorServer/FebControl.h index db8819c94..07921d65b 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.h +++ b/slsDetectorServers/eigerDetectorServer/FebControl.h @@ -40,6 +40,7 @@ unsigned int *Feb_Control_GetTrimbits(); // acquisition int Feb_Control_AcquisitionInProgress(); +int Feb_Control_ProcessingInProgress(); int Feb_Control_AcquisitionStartedBit(); int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag); int Feb_Control_WaitForFinishedFlag(int sleep_time_us, int tempLock); diff --git a/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h b/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h index a5ecd79ff..6d2da9af9 100644 --- a/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h +++ b/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h @@ -30,7 +30,14 @@ #define DAQ_REG_RO_OFFSET 20 #define DAQ_REG_STATUS (DAQ_REG_RO_OFFSET + 0) // also pg and fifo status register + #define FEB_REG_STATUS (DAQ_REG_RO_OFFSET + 3) + +#define FEB_REG_STATUS_ACQ_DONE_OFST (6) +#define FEB_REG_STATUS_ACQ_DONE_MSK (0x00000001 << FEB_REG_STATUS_ACQ_DONE_OFST) +#define FEB_REG_STATUS_TEMP_OFST (16) +#define FEB_REG_STATUS_TEMP_MSK (0x0000FFFF << FEB_REG_STATUS_TEMP_OFST) + #define MEAS_SUBPERIOD_REG (DAQ_REG_RO_OFFSET + 4) #define MEAS_PERIOD_REG (DAQ_REG_RO_OFFSET + 5) // clang-format on @@ -39,6 +46,7 @@ #define DAQ_CTRL_START 0x40000000 #define ACQ_CTRL_START 0x50000000 // this is 0x10000000 (acq) | 0x40000000 (daq) #define DAQ_CTRL_STOP 0x08000000 // sends last complete frame +#define DAQ_CTRL_DONE 0x00000040 // data processing done in feb // direct chip commands to the DAQ_REG_CHIP_CMDS register #define DAQ_SET_STATIC_BIT 0x00000001 diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 7171285fa..a042dc38d 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 7551c2053..a97f93544 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -2511,6 +2511,19 @@ void readFrame(int *ret, char *mess) { // wait for detector to send int isTransmitting = 1; while (isTransmitting) { + // wait for feb processing to be done + int i = Feb_Control_ProcessingInProgress(); + if (i == STATUS_ERROR) { + strcpy(mess, "Could not read feb processing done register\n"); + *ret = (int)FAIL; + return; + } + if (i == RUNNING) { + LOG(logINFOBLUE, ("Status: TRANSMITTING (feb processing)\n")); + isTransmitting = 1; + } + + // wait for beb to send out all packets if (Beb_IsTransmitting(&isTransmitting, send_to_ten_gig, 1) == FAIL) { strcpy(mess, "Could not read delay counters\n"); *ret = (int)FAIL; diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 468f6a20b..026931eee 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -3,10 +3,10 @@ #define APILIB 0x210225 #define APIRECEIVER 0x210225 #define APIGUI 0x210225 -#define APIEIGER 0x210621 #define APICTB 0x210621 #define APIGOTTHARD 0x210621 #define APIGOTTHARD2 0x210621 #define APIJUNGFRAU 0x210621 #define APIMYTHEN3 0x210621 #define APIMOENCH 0x210621 +#define APIEIGER 0x210624