From eea67014b7d0d7b57bcc3be10e66366c820af99d Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 13 May 2020 17:50:18 +0200 Subject: [PATCH] gotthard2 with veto data on second interface --- .../slsDetectorFunctionList.c | 4 +- .../gotthard2DetectorServer/RegisterDefs.h | 281 +++++++++--------- .../slsDetectorFunctionList.c | 210 +++++++++---- .../slsDetectorServer_defs.h | 4 +- .../slsDetectorFunctionList.c | 1 - .../include/slsDetectorFunctionList.h | 5 +- .../src/slsDetectorServer_funcs.c | 31 +- slsDetectorSoftware/include/Detector.h | 7 +- slsDetectorSoftware/src/CmdProxy.h | 11 +- slsDetectorSoftware/src/DetectorImpl.cpp | 17 +- slsDetectorSoftware/src/Module.h | 7 +- slsReceiverSoftware/src/ClientInterface.cpp | 9 +- slsReceiverSoftware/src/DataProcessor.cpp | 4 +- slsReceiverSoftware/src/DataStreamer.cpp | 12 +- slsReceiverSoftware/src/GeneralData.h | 150 +++------- slsReceiverSoftware/src/Implementation.cpp | 22 +- slsReceiverSoftware/src/Listener.cpp | 59 ++-- 17 files changed, 455 insertions(+), 379 deletions(-) diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index c9e4a71df..fae9b0e4d 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -2156,7 +2156,7 @@ void *start_timer(void *arg) { sls_detector_header *header = (sls_detector_header *)(packetData); header->detType = (uint16_t)myDetectorType; - header->version = SLS_DETECTOR_HEADER_VERSION - 1; + header->version = SLS_DETECTOR_HEADER_VERSION; header->frameNumber = frameNr + iframes; header->packetNumber = i; header->row = row; @@ -2166,7 +2166,7 @@ void *start_timer(void *arg) { memset(packetData2, 0, packetsize); header = (sls_detector_header *)(packetData2); header->detType = (uint16_t)myDetectorType; - header->version = SLS_DETECTOR_HEADER_VERSION - 1; + header->version = SLS_DETECTOR_HEADER_VERSION; header->frameNumber = frameNr + iframes; header->packetNumber = i; header->row = row; diff --git a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h index 0bc78098b..7c7c5a03c 100644 --- a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h @@ -1,110 +1,112 @@ #pragma once - +// clang-format off #define REG_OFFSET (4) /* Base addresses 0x1804 0000 ---------------------------------------------*/ /* Reconfiguration core for readout pll */ -#define BASE_READOUT_PLL (0x0000) // 0x1804_0000 - 0x1804_07FF +#define BASE_READOUT_PLL (0x0000) // 0x1804_0000 - 0x1804_07FF /* Reconfiguration core for system pll */ -#define BASE_SYSTEM_PLL (0x0800) // 0x1804_0800 - 0x1804_0FFF +#define BASE_SYSTEM_PLL (0x0800) // 0x1804_0800 - 0x1804_0FFF /* Clock Generation */ #define BASE_CLK_GENERATION (0x1000) // 0x1804_1000 - 0x1804_XXXX //TODO /* Base addresses 0x1806 0000 ---------------------------------------------*/ /* General purpose control and status registers */ -#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF +#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF // https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/ctrl/ctrl.vhd /* ASIC Control */ -#define BASE_ASIC (0x0100) // 0x1806_0100 - 0x1806_011F +#define BASE_ASIC (0x0100) // 0x1806_0100 - 0x1806_011F // https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/asic/asic_ctrl.vhd /* ASIC Digital Interface. Data recovery core */ -#define BASE_ADIF (0x0120) // 0x1806_0120 - 0x1806_012F +#define BASE_ADIF (0x0120) // 0x1806_0120 - 0x1806_012F // https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/adif/adif_ctrl.vhd /* Formatting of data core */ -#define BASE_FMT (0x0130) // 0x1806_0130 - 0x1806_013F +#define BASE_FMT (0x0130) // 0x1806_0130 - 0x1806_013F /* Packetizer */ -#define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F +#define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F // https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/pkt/pkt_ctrl.vhd /* Flow control and status registers */ -#define BASE_FLOW_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF +#define BASE_FLOW_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF // https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/f37608230b4721661f29aacc20124555705ee705/flow/flow_ctrl.vhd /* UDP datagram generator */ -#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF +#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF + /* Clock Generation registers * ------------------------------------------------------*/ -#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION) +#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION) -#define PLL_RESET_READOUT_OFST (0) -#define PLL_RESET_READOUT_MSK (0x00000001 << PLL_RESET_READOUT_OFST) -#define PLL_RESET_SYSTEM_OFST (1) -#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST) +#define PLL_RESET_READOUT_OFST (0) +#define PLL_RESET_READOUT_MSK (0x00000001 << PLL_RESET_READOUT_OFST) +#define PLL_RESET_SYSTEM_OFST (1) +#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST) /* Control registers --------------------------------------------------*/ /* Module Control Board Serial Number register */ -#define MCB_SERIAL_NO_REG (0x00 * REG_OFFSET + BASE_CONTROL) +#define MCB_SERIAL_NO_REG (0x00 * REG_OFFSET + BASE_CONTROL) -#define MCB_SERIAL_NO_VRSN_OFST (16) -#define MCB_SERIAL_NO_VRSN_MSK (0x0000001F << MCB_SERIAL_NO_VRSN_OFST) +#define MCB_SERIAL_NO_VRSN_OFST (16) +#define MCB_SERIAL_NO_VRSN_MSK (0x0000001F << MCB_SERIAL_NO_VRSN_OFST) /* FPGA Version register */ -#define FPGA_VERSION_REG (0x01 * REG_OFFSET + BASE_CONTROL) +#define FPGA_VERSION_REG (0x01 * REG_OFFSET + BASE_CONTROL) -#define FPGA_COMPILATION_DATE_OFST (0) -#define FPGA_COMPILATION_DATE_MSK (0x00FFFFFF << FPGA_COMPILATION_DATE_OFST) -#define DETECTOR_TYPE_OFST (24) -#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST) +#define FPGA_COMPILATION_DATE_OFST (0) +#define FPGA_COMPILATION_DATE_MSK (0x00FFFFFF << FPGA_COMPILATION_DATE_OFST) +#define DETECTOR_TYPE_OFST (24) +#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST) /* API Version register */ -#define API_VERSION_REG (0x02 * REG_OFFSET + BASE_CONTROL) +#define API_VERSION_REG (0x02 * REG_OFFSET + BASE_CONTROL) -#define API_VERSION_OFST (0) -#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST) -#define API_VERSION_DETECTOR_TYPE_OFST (24) // Not used in software -#define API_VERSION_DETECTOR_TYPE_MSK \ - (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) // Not used in software +#define API_VERSION_OFST (0) +#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST) +#define API_VERSION_DETECTOR_TYPE_OFST (24) // Not used in software +#define API_VERSION_DETECTOR_TYPE_MSK (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) // Not used in software /* Fix pattern register */ -#define FIX_PATT_REG (0x03 * REG_OFFSET + BASE_CONTROL) -#define FIX_PATT_VAL (0xACDC2019) +#define FIX_PATT_REG (0x03 * REG_OFFSET + BASE_CONTROL) +#define FIX_PATT_VAL (0xACDC2019) /* Status register */ -#define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL) +#define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL) /* Look at me read only register */ -#define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL) +#define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL) /* System status register */ -#define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL) +#define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL) /* Config RW regiseter */ -#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL) +#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL) + +#define CONFIG_VETO_ENBL_OFST (0) +#define CONFIG_VETO_ENBL_MSK (0x00000001 << CONFIG_VETO_ENBL_OFST) /* Control RW register */ -#define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL) +#define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL) -#define CONTROL_STRT_ACQSTN_OFST (0) -#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST) -#define CONTROL_STP_ACQSTN_OFST (1) -#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST) -#define CONTROL_CRE_RST_OFST (10) -#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST) -#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10? -#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST) -#define CONTROL_CLR_ACQSTN_FIFO_OFST (15) -#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST) -#define CONTROL_TIMING_SOURCE_EXT_OFST (17) -#define CONTROL_TIMING_SOURCE_EXT_MSK \ - (0x00000001 << CONTROL_TIMING_SOURCE_EXT_OFST) -#define CONTROL_PWR_CHIP_OFST (31) -#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST) +#define CONTROL_STRT_ACQSTN_OFST (0) +#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST) +#define CONTROL_STP_ACQSTN_OFST (1) +#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST) +#define CONTROL_CRE_RST_OFST (10) +#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST) +#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10? +#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST) +#define CONTROL_CLR_ACQSTN_FIFO_OFST (15) +#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST) +#define CONTROL_TIMING_SOURCE_EXT_OFST (17) +#define CONTROL_TIMING_SOURCE_EXT_MSK (0x00000001 << CONTROL_TIMING_SOURCE_EXT_OFST) +#define CONTROL_PWR_CHIP_OFST (31) +#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST) /** DTA Offset Register */ #define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL) @@ -114,143 +116,138 @@ /* ASIC Config register */ #define ASIC_CONFIG_REG (0x00 * REG_OFFSET + BASE_ASIC) -#define ASIC_CONFIG_RUN_MODE_OFST (0) -#define ASIC_CONFIG_RUN_MODE_MSK (0x00000003 << ASIC_CONFIG_RUN_MODE_OFST) -#define ASIC_CONFIG_RUN_MODE_INT_BURST_VAL \ - ((0x1 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK) -#define ASIC_CONFIG_RUN_MODE_CONT_VAL \ - ((0x2 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK) -#define ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL \ - ((0x3 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK) -#define ASIC_CONFIG_GAIN_OFST (4) -#define ASIC_CONFIG_GAIN_MSK (0x00000003 << ASIC_CONFIG_GAIN_OFST) -#define ASIC_CONFIG_DYNAMIC_GAIN_VAL \ - ((0x0 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) -#define ASIC_CONFIG_FIX_GAIN_1_VAL \ - ((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) -#define ASIC_CONFIG_FIX_GAIN_2_VAL \ - ((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) -#define ASIC_CONFIG_RESERVED_VAL \ - ((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) -#define ASIC_CONFIG_CURRENT_SRC_EN_OFST (7) -#define ASIC_CONFIG_CURRENT_SRC_EN_MSK \ - (0x00000001 << ASIC_CONFIG_CURRENT_SRC_EN_OFST) -#define ASIC_CONFIG_RST_DAC_OFST (15) -#define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST) -#define ASIC_CONFIG_DONE_OFST (31) -#define ASIC_CONFIG_DONE_MSK (0x00000001 << ASIC_CONFIG_DONE_OFST) +#define ASIC_CONFIG_RUN_MODE_OFST (0) +#define ASIC_CONFIG_RUN_MODE_MSK (0x00000003 << ASIC_CONFIG_RUN_MODE_OFST) +#define ASIC_CONFIG_RUN_MODE_INT_BURST_VAL ((0x1 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK) +#define ASIC_CONFIG_RUN_MODE_CONT_VAL ((0x2 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK) +#define ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL ((0x3 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK) +#define ASIC_CONFIG_GAIN_OFST (4) +#define ASIC_CONFIG_GAIN_MSK (0x00000003 << ASIC_CONFIG_GAIN_OFST) +#define ASIC_CONFIG_DYNAMIC_GAIN_VAL ((0x0 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) +#define ASIC_CONFIG_FIX_GAIN_1_VAL ((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) +#define ASIC_CONFIG_FIX_GAIN_2_VAL ((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) +#define ASIC_CONFIG_RESERVED_VAL ((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) +#define ASIC_CONFIG_CURRENT_SRC_EN_OFST (7) +#define ASIC_CONFIG_CURRENT_SRC_EN_MSK (0x00000001 << ASIC_CONFIG_CURRENT_SRC_EN_OFST) +#define ASIC_CONFIG_RST_DAC_OFST (15) +#define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST) +#define ASIC_CONFIG_DONE_OFST (31) +#define ASIC_CONFIG_DONE_MSK (0x00000001 << ASIC_CONFIG_DONE_OFST) /* ASIC Internal Frames Register */ -#define ASIC_INT_FRAMES_REG (0x01 * REG_OFFSET + BASE_ASIC) +#define ASIC_INT_FRAMES_REG (0x01 * REG_OFFSET + BASE_ASIC) -#define ASIC_INT_FRAMES_OFST (0) -#define ASIC_INT_FRAMES_MSK (0x00000FFF << ASIC_INT_FRAMES_OFST) +#define ASIC_INT_FRAMES_OFST (0) +#define ASIC_INT_FRAMES_MSK (0x00000FFF << ASIC_INT_FRAMES_OFST) /* ASIC Period 64bit Register */ -#define ASIC_INT_PERIOD_LSB_REG (0x02 * REG_OFFSET + BASE_ASIC) -#define ASIC_INT_PERIOD_MSB_REG (0x03 * REG_OFFSET + BASE_ASIC) +#define ASIC_INT_PERIOD_LSB_REG (0x02 * REG_OFFSET + BASE_ASIC) +#define ASIC_INT_PERIOD_MSB_REG (0x03 * REG_OFFSET + BASE_ASIC) /* ASIC Exptime 64bit Register */ -#define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC) -#define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC) +#define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC) +#define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC) /* Packetizer -------------------------------------------------------------*/ /* Packetizer Config Register */ -#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT) +#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT) -#define PKT_CONFIG_NRXR_MAX_OFST (0) -#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST) -#define PKT_CONFIG_RXR_START_ID_OFST (8) -#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST) +#define PKT_CONFIG_NRXR_MAX_OFST (0) +#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST) +#define PKT_CONFIG_RXR_START_ID_OFST (8) +#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST) /* Module Coordinates Register */ -#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT) -#define COORD_ROW_OFST (0) -#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST) -#define COORD_COL_OFST (16) -#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST) +#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT) +#define COORD_ROW_OFST (0) +#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST) +#define COORD_COL_OFST (16) +#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST) /* Module ID Register */ -#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT) -#define COORD_RESERVED_OFST (0) -#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST) -#define COORD_ID_OFST (16) // Not connected in firmware TODO -#define COORD_ID_MSK \ - (0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO +#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT) +#define COORD_RESERVED_OFST (0) +#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST) +#define COORD_ID_OFST (16) // Not connected in firmware TODO +#define COORD_ID_MSK (0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO /* Flow control registers --------------------------------------------------*/ /* Flow status Register*/ -#define FLOW_STATUS_REG (0x00 * REG_OFFSET + BASE_FLOW_CONTROL) +#define FLOW_STATUS_REG (0x00 * REG_OFFSET + BASE_FLOW_CONTROL) -#define FLOW_STATUS_RUN_BUSY_OFST (0) -#define FLOW_STATUS_RUN_BUSY_MSK (0x00000001 << FLOW_STATUS_RUN_BUSY_OFST) -#define FLOW_STATUS_WAIT_FOR_TRGGR_OFST (3) -#define FLOW_STATUS_WAIT_FOR_TRGGR_MSK \ - (0x00000001 << FLOW_STATUS_WAIT_FOR_TRGGR_OFST) -#define FLOW_STATUS_DLY_BFRE_TRGGR_OFST (4) -#define FLOW_STATUS_DLY_BFRE_TRGGR_MSK \ - (0x00000001 << FLOW_STATUS_DLY_BFRE_TRGGR_OFST) -#define FLOW_STATUS_FIFO_FULL_OFST (5) -#define FLOW_STATUS_FIFO_FULL_MSK (0x00000001 << FLOW_STATUS_FIFO_FULL_OFST) -#define FLOW_STATUS_DLY_AFTR_TRGGR_OFST (15) -#define FLOW_STATUS_DLY_AFTR_TRGGR_MSK \ - (0x00000001 << FLOW_STATUS_DLY_AFTR_TRGGR_OFST) -#define FLOW_STATUS_CSM_BUSY_OFST (17) -#define FLOW_STATUS_CSM_BUSY_MSK (0x00000001 << FLOW_STATUS_CSM_BUSY_OFST) +#define FLOW_STATUS_RUN_BUSY_OFST (0) +#define FLOW_STATUS_RUN_BUSY_MSK (0x00000001 << FLOW_STATUS_RUN_BUSY_OFST) +#define FLOW_STATUS_WAIT_FOR_TRGGR_OFST (3) +#define FLOW_STATUS_WAIT_FOR_TRGGR_MSK (0x00000001 << FLOW_STATUS_WAIT_FOR_TRGGR_OFST) +#define FLOW_STATUS_DLY_BFRE_TRGGR_OFST (4) +#define FLOW_STATUS_DLY_BFRE_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_BFRE_TRGGR_OFST) +#define FLOW_STATUS_FIFO_FULL_OFST (5) +#define FLOW_STATUS_FIFO_FULL_MSK (0x00000001 << FLOW_STATUS_FIFO_FULL_OFST) +#define FLOW_STATUS_DLY_AFTR_TRGGR_OFST (15) +#define FLOW_STATUS_DLY_AFTR_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_AFTR_TRGGR_OFST) +#define FLOW_STATUS_CSM_BUSY_OFST (17) +#define FLOW_STATUS_CSM_BUSY_MSK (0x00000001 << FLOW_STATUS_CSM_BUSY_OFST) /* Delay left 64bit Register */ -#define GET_DELAY_LSB_REG (0x02 * REG_OFFSET + BASE_FLOW_CONTROL) -#define GET_DELAY_MSB_REG (0x03 * REG_OFFSET + BASE_FLOW_CONTROL) +#define GET_DELAY_LSB_REG (0x02 * REG_OFFSET + BASE_FLOW_CONTROL) +#define GET_DELAY_MSB_REG (0x03 * REG_OFFSET + BASE_FLOW_CONTROL) /* Triggers left 64bit Register */ -#define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_FLOW_CONTROL) -#define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_FLOW_CONTROL) +#define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_FLOW_CONTROL) +#define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_FLOW_CONTROL) /* Frames left 64bit Register */ -#define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_FLOW_CONTROL) -#define GET_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_FLOW_CONTROL) +#define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_FLOW_CONTROL) +#define GET_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_FLOW_CONTROL) /* Period left 64bit Register */ -#define GET_PERIOD_LSB_REG (0x08 * REG_OFFSET + BASE_FLOW_CONTROL) -#define GET_PERIOD_MSB_REG (0x09 * REG_OFFSET + BASE_FLOW_CONTROL) +#define GET_PERIOD_LSB_REG (0x08 * REG_OFFSET + BASE_FLOW_CONTROL) +#define GET_PERIOD_MSB_REG (0x09 * REG_OFFSET + BASE_FLOW_CONTROL) /* Time from Start 64 bit register */ -#define TIME_FROM_START_LSB_REG (0x0A * REG_OFFSET + BASE_FLOW_CONTROL) -#define TIME_FROM_START_MSB_REG (0x0B * REG_OFFSET + BASE_FLOW_CONTROL) +#define TIME_FROM_START_LSB_REG (0x0A * REG_OFFSET + BASE_FLOW_CONTROL) +#define TIME_FROM_START_MSB_REG (0x0B * REG_OFFSET + BASE_FLOW_CONTROL) /* Get Frames from Start 64 bit register (frames from last reset using * CONTROL_CRST) */ -#define FRAMES_FROM_START_LSB_REG (0x0C * REG_OFFSET + BASE_FLOW_CONTROL) -#define FRAMES_FROM_START_MSB_REG (0x0D * REG_OFFSET + BASE_FLOW_CONTROL) +#define FRAMES_FROM_START_LSB_REG (0x0C * REG_OFFSET + BASE_FLOW_CONTROL) +#define FRAMES_FROM_START_MSB_REG (0x0D * REG_OFFSET + BASE_FLOW_CONTROL) /* Measurement Time 64 bit register (timestamp at a frame start until reset)*/ -#define START_FRAME_TIME_LSB_REG (0x0E * REG_OFFSET + BASE_FLOW_CONTROL) -#define START_FRAME_TIME_MSB_REG (0x0F * REG_OFFSET + BASE_FLOW_CONTROL) +#define START_FRAME_TIME_LSB_REG (0x0E * REG_OFFSET + BASE_FLOW_CONTROL) +#define START_FRAME_TIME_MSB_REG (0x0F * REG_OFFSET + BASE_FLOW_CONTROL) /* Delay 64bit Write-register */ -#define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL) -#define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL) /* Cylces (also #bursts) 64bit Write-register */ -#define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL) -#define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL) /* Frames 64bit Write-register */ -#define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL) -#define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL) /* Period (also burst period) 64bit Write-register */ -#define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL) -#define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL) /* External Signal register */ -#define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_FLOW_CONTROL) +#define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_FLOW_CONTROL) -#define EXT_SIGNAL_OFST (0) -#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST) +#define EXT_SIGNAL_OFST (0) +#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST) /* Trigger Delay 64 bit register */ -#define SET_TRIGGER_DELAY_LSB_REG (0x32 * REG_OFFSET + BASE_FLOW_CONTROL) -#define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_TRIGGER_DELAY_LSB_REG (0x32 * REG_OFFSET + BASE_FLOW_CONTROL) +#define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_FLOW_CONTROL) + + +/* UDP datagram registers --------------------------------------------------*/ +#define RXR_ENDPOINTS_MAX (32) +#define RXR_ENDPOINT_OFST (0x10) + +// clang-format on \ No newline at end of file diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index eec0389c1..97293d541 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -1290,44 +1290,42 @@ enum timingMode getTiming() { return AUTO_TIMING; } -int configureMAC() { +/* configure mac */ +void setNumberofUDPInterfaces(int val) { + uint32_t addr = CONFIG_REG; - uint32_t srcip = udpDetails.srcip; - uint32_t dstip = udpDetails.dstip; - uint64_t srcmac = udpDetails.srcmac; - uint64_t dstmac = udpDetails.dstmac; - int srcport = udpDetails.srcport; - int dstport = udpDetails.dstport; - - LOG(logINFOBLUE, ("Configuring MAC\n")); - char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], - dst_ip[INET_ADDRSTRLEN]; - getMacAddressinString(src_mac, 50, srcmac); - getMacAddressinString(dst_mac, 50, dstmac); - getIpAddressinString(src_ip, srcip); - getIpAddressinString(dst_ip, dstip); - - LOG(logINFO, ("\tSource IP : %s\n" - "\tSource MAC : %s\n" - "\tSource Port : %d\n" - "\tDest IP : %s\n" - "\tDest MAC : %s\n" - "\tDest Port : %d\n", - src_ip, src_mac, srcport, dst_ip, dst_mac, dstport)); - -#ifdef VIRTUAL - if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) { - LOG(logERROR, ("could not set udp destination IP and port\n")); - return FAIL; + // 2 interfaces (enable veto) + if (val > 1) { + LOG(logINFOBLUE, + ("Setting #Interfaces: 2 (enabling veto streaming)\n")); + bus_w(addr, bus_r(addr) | CONFIG_VETO_ENBL_MSK); } - return OK; -#endif + // 1 interface (disable veto) + else { + LOG(logINFOBLUE, + ("Setting #Interfaces: 1 (disabling veto streaming)\n")); + bus_w(addr, bus_r(addr) & ~CONFIG_VETO_ENBL_MSK); + } + LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr))); +} + +int getNumberofUDPInterfaces() { + LOG(logDEBUG, ("config reg:0x%x\n", bus_r(CONFIG_REG))); + // return 2 if veto enabled, else 1 + return ((bus_r(CONFIG_REG) & CONFIG_VETO_ENBL_MSK) ? 2 : 1); +} + +void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, + uint64_t destmac, uint32_t destport, uint64_t sourcemac, + uint32_t sourceip, uint32_t sourceport) { // start addr uint32_t addr = BASE_UDP_RAM; // calculate rxr endpoint offset - // addr += (iRxEntry * RXR_ENDPOINT_OFST);//TODO: is there round robin - // already implemented? + if (vetoInterface == 1) { + iRxEntry += RXR_ENDPOINTS_MAX; + } + addr += (iRxEntry * RXR_ENDPOINT_OFST); // get struct memory udp_header *udp = (udp_header *)(Nios_getBaseAddress() + addr / (sizeof(u_int32_t))); @@ -1335,21 +1333,21 @@ int configureMAC() { // mac addresses // msb (32) + lsb (16) - udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK); - udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK); + udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK); + udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK); // msb (16) + lsb (32) - udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK); - udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK); + udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK); + udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK); // ip addresses - udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK); - udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK); - udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK); - udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK); + udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK); + udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK); + udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK); + udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK); // source port - udp->udp_srcport = srcport; - udp->udp_destport = dstport; + udp->udp_srcport = sourceport; + udp->udp_destport = destport; // other defines udp->udp_ethertype = 0x800; @@ -1361,12 +1359,6 @@ int configureMAC() { // total length is redefined in firmware calcChecksum(udp); - - // TODO? - cleanFifos(); - resetCore(); - // alignDeserializer(); - return OK; } void calcChecksum(udp_header *udp) { @@ -1401,6 +1393,88 @@ void calcChecksum(udp_header *udp) { udp->ip_checksum = checksum; } +int configureMAC() { + + uint32_t srcip = udpDetails.srcip; + uint32_t srcip2 = udpDetails.srcip2; + uint32_t dstip = udpDetails.dstip; + uint32_t dstip2 = udpDetails.dstip2; + uint64_t srcmac = udpDetails.srcmac; + uint64_t srcmac2 = udpDetails.srcmac2; + uint64_t dstmac = udpDetails.dstmac; + uint64_t dstmac2 = udpDetails.dstmac2; + int srcport = udpDetails.srcport; + int srcport2 = udpDetails.srcport2; + int dstport = udpDetails.dstport; + int dstport2 = udpDetails.dstport2; + + LOG(logINFOBLUE, ("Configuring MAC\n")); + char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], + dst_ip[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac, 50, srcmac); + getMacAddressinString(dst_mac, 50, dstmac); + getIpAddressinString(src_ip, srcip); + getIpAddressinString(dst_ip, dstip); + char src_mac2[50], src_ip2[INET_ADDRSTRLEN], dst_mac2[50], + dst_ip2[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac2, 50, srcmac2); + getMacAddressinString(dst_mac2, 50, dstmac2); + getIpAddressinString(src_ip2, srcip2); + getIpAddressinString(dst_ip2, dstip2); + + int numInterfaces = getNumberofUDPInterfaces(); + LOG(logINFO, ("\t#Interfaces : %d\n", numInterfaces)); + + LOG(logINFO, ("\tData Interface \n")); + LOG(logINFO, ("\tSource IP : %s\n" + "\tSource MAC : %s\n" + "\tSource Port : %d\n" + "\tDest IP : %s\n" + "\tDest MAC : %s\n" + "\tDest Port : %d\n", + src_ip, src_mac, srcport, dst_ip, dst_mac, dstport)); + + LOG(logINFO, ("\tVeto Interface (%s)\n", + (numInterfaces == 2 ? "enabled" : "disabled"))); + LOG(logINFO, ("\tSource IP2 : %s\n" + "\tSource MAC2 : %s\n" + "\tSource Port2: %d\n" + "\tDest IP2 : %s\n" + "\tDest MAC2 : %s\n" + "\tDest Port2 : %d\n", + src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2)); + +#ifdef VIRTUAL + if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) { + LOG(logERROR, ("could not set udp destination IP and port\n")); + return FAIL; + } + if (numInterfaces == 2 && + setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) { + LOG(logERROR, + ("could not set udp destination IP and port for interface 2\n")); + return FAIL; + } + return OK; +#endif + // default one rxr entry (others not yet implemented in client yet) + int iRxEntry = 0; + + // data + setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, srcport); + + // veto + if (numInterfaces == 2) { + setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2, + srcport2); + } + + cleanFifos(); + resetCore(); + // alignDeserializer(); + return OK; +} + int setDetectorPosition(int pos[]) { memcpy(detPos, pos, sizeof(detPos)); @@ -2142,6 +2216,9 @@ int startStateMachine() { if (createUDPSocket(0) != OK) { return FAIL; } + if (getNumberofUDPInterfaces() == 2 && createUDPSocket(1) != OK) { + return FAIL; + } LOG(logINFOBLUE, ("Starting State Machine\n")); // set status to running virtual_status = 1; @@ -2181,6 +2258,7 @@ void *start_timer(void *arg) { return NULL; } + int numInterfaces = getNumberofUDPInterfaces(); int numRepeats = getNumTriggers(); if (getTiming() == AUTO_TIMING) { if (burstMode == BURST_OFF) { @@ -2196,6 +2274,8 @@ void *start_timer(void *arg) { int imagesize = NCHAN * NCHIP * 2; int datasize = imagesize; int packetsize = datasize + sizeof(sls_detector_header); + int vetodatasize = VETO_DATA_SIZE; + int vetopacketsize = vetodatasize + sizeof(sls_detector_header); // Generate data char imageData[imagesize]; @@ -2203,6 +2283,11 @@ void *start_timer(void *arg) { for (int i = 0; i < imagesize; i += sizeof(uint16_t)) { *((uint16_t *)(imageData + i)) = i; } + char vetoData[vetodatasize]; + memset(vetoData, 0, sizeof(vetodatasize)); + for (int i = 0; i < vetodatasize; i += sizeof(uint8_t)) { + *((uint16_t *)(vetoData + i)) = i; + } { int frameHeaderNr = 0; @@ -2227,6 +2312,7 @@ void *start_timer(void *arg) { clock_gettime(CLOCK_REALTIME, &begin); usleep(expUs); + // first interface char packetData[packetsize]; memset(packetData, 0, packetsize); // set header @@ -2235,19 +2321,38 @@ void *start_timer(void *arg) { header->detType = (uint16_t)myDetectorType; header->version = SLS_DETECTOR_HEADER_VERSION - 1; header->frameNumber = frameHeaderNr; - ++frameHeaderNr; header->packetNumber = 0; header->modId = 0; header->row = detPos[X]; header->column = detPos[Y]; - // fill data memcpy(packetData + sizeof(sls_detector_header), imageData, datasize); - // send 1 packet = 1 frame sendUDPPacket(0, packetData, packetsize); + // second interface (veto) + char packetData2[packetsize]; + memset(packetData2, 0, packetsize); + if (numInterfaces == 2) { + // set header + sls_detector_header *header = + (sls_detector_header *)(packetData2); + header->detType = (uint16_t)myDetectorType; + header->version = SLS_DETECTOR_HEADER_VERSION - 1; + header->frameNumber = frameHeaderNr; + header->packetNumber = 0; + header->modId = 0; + header->row = detPos[X]; + header->column = detPos[Y]; + // fill data + memcpy(packetData2 + sizeof(sls_detector_header), vetoData, + vetodatasize); + // send 1 packet = 1 frame + sendUDPPacket(1, packetData2, vetopacketsize); + } + ++frameHeaderNr; + clock_gettime(CLOCK_REALTIME, &end); LOG(logINFO, ("Sent frame: %d (bursts: %d)\n", frameNr, repeatNr)); @@ -2275,6 +2380,9 @@ void *start_timer(void *arg) { } closeUDPSocket(0); + if (numInterfaces == 2) { + closeUDPSocket(1); + } virtual_status = 0; if (isControlServer) { diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h index c7e07ae57..dad6a1a51 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h @@ -52,12 +52,11 @@ #define DEFAULT_SYSTEM_C3 (5) //(144444448) // str_clk, 144 MHz /* Firmware Definitions */ -#define IP_HEADER_SIZE (20) #define FIXED_PLL_FREQUENCY (20000000) // 20MHz #define INT_SYSTEM_C0_FREQUENCY (144000000) // 144 MHz #define READOUT_PLL_VCO_FREQ_HZ (866666688) // 866 MHz #define SYSTEM_PLL_VCO_FREQ_HZ (722222224) // 722 MHz - +#define VETO_DATA_SIZE (160) /** Other Definitions */ #define BIT16_MASK (0xFFFF) @@ -156,4 +155,5 @@ typedef struct udp_header_struct { uint16_t udp_checksum; uint16_t udp_destport; } udp_header; +#define IP_HEADER_SIZE (20) #define UDP_IP_HEADER_LENGTH_BYTES (28) \ No newline at end of file diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index fce3c6507..468653e8c 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -46,7 +46,6 @@ int highvoltage = 0; int dacValues[NDAC] = {}; int32_t clkPhase[NUM_CLOCKS] = {}; int detPos[4] = {}; -int numUDPInterfaces = 1; int isInitCheckDone() { return initCheckDone; } diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index e06e7c4b6..7fe2f46de 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -329,9 +329,12 @@ int getExtSignal(); // configure mac #ifdef GOTTHARDD void calcChecksum(mac_conf *mac, int sourceip, int destip); -#elif JUNGFRAUD +#endif +#if defined(JUNGFRAUD) || defined(GOTTHARD2D) void setNumberofUDPInterfaces(int val); int getNumberofUDPInterfaces(); +#endif +#ifdef JUNGFRAUD void selectPrimaryInterface(int val); int getPrimaryInterface(); void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index c63a4a7bf..3d931d12c 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -5041,6 +5041,7 @@ void calculate_and_set_position() { return; } int maxy = maxydet; + // position does not change for gotthard2 (2 interfaces) #ifdef JUNGFRAUD maxy *= getNumberofUDPInterfaces(); #endif @@ -5076,7 +5077,7 @@ void calculate_and_set_position() { udpDetails.srcmac = (udpDetails.srcmac << 8) + a[i]; } } -#ifdef JUNGFRAUD +#if defined(JUNGFRAUD) || defined(GOTTHARD2D) if (getNumberofUDPInterfaces() > 1) { if (udpDetails.srcmac2 == 0) { char dmac2[50]; @@ -5154,7 +5155,7 @@ int is_configurable() { LOG(logWARNING, ("%s", configureMessage)); return FAIL; } -#ifdef JUNGFRAUD +#if defined(JUNGFRAUD) || defined(GOTTHARD2D) if (getNumberofUDPInterfaces() == 2) { if (udpDetails.srcip2 == 0) { strcpy(configureMessage, "udp source ip2 not configured\n"); @@ -5253,7 +5254,7 @@ int set_source_udp_ip2(int file_des) { arg = __builtin_bswap32(arg); LOG(logINFO, ("Setting udp source ip2: 0x%x\n", arg)); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // only set @@ -5275,7 +5276,7 @@ int get_source_udp_ip2(int file_des) { uint32_t retval = -1; LOG(logDEBUG1, ("Getting udp source ip2\n")); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // get only @@ -5332,7 +5333,7 @@ int set_dest_udp_ip2(int file_des) { arg = __builtin_bswap32(arg); LOG(logINFO, ("Setting udp destination ip2: 0x%x\n", arg)); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // only set @@ -5354,7 +5355,7 @@ int get_dest_udp_ip2(int file_des) { uint32_t retval = -1; LOG(logDEBUG1, ("Getting udp destination ip2\n")); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // get only @@ -5408,7 +5409,7 @@ int set_source_udp_mac2(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting udp source mac2: 0x%lx\n", arg)); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // only set @@ -5430,7 +5431,7 @@ int get_source_udp_mac2(int file_des) { uint64_t retval = -1; LOG(logDEBUG1, ("Getting udp source mac2\n")); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // get only @@ -5483,7 +5484,7 @@ int set_dest_udp_mac2(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting udp destination mac2: 0x%lx\n", arg)); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // only set @@ -5505,7 +5506,7 @@ int get_dest_udp_mac2(int file_des) { uint64_t retval = -1; LOG(logDEBUG1, ("Getting udp destination mac2\n")); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // get only @@ -5558,7 +5559,7 @@ int set_dest_udp_port2(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting udp destination port2: %u\n", arg)); -#if !defined(JUNGFRAUD) && !defined(EIGERD) +#if !defined(JUNGFRAUD) && !defined(EIGERD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // only set @@ -5580,7 +5581,7 @@ int get_dest_udp_port2(int file_des) { int retval = -1; LOG(logDEBUG1, ("Getting destination port2\n")); -#if !defined(JUNGFRAUD) && !defined(EIGERD) +#if !defined(JUNGFRAUD) && !defined(EIGERD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // get only @@ -5599,7 +5600,7 @@ int set_num_interfaces(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting number of interfaces: %d\n", arg)); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // only set @@ -5627,7 +5628,7 @@ int get_num_interfaces(int file_des) { int retval = -1; LOG(logDEBUG1, ("Getting number of udp interfaces\n")); -#ifndef JUNGFRAUD +#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) retval = 1; #else // get only @@ -7156,7 +7157,7 @@ int get_receiver_parameters(int file_des) { // sending real detector parameters // udp interfaces -#ifdef JUNGFRAUD +#if defined(JUNGFRAUD) || defined(GOTTHARD2D) i32 = getNumberofUDPInterfaces(); #else i32 = 1; diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 9124ea932..47e4c8a7e 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -379,10 +379,13 @@ class Detector { * * * ************************************************/ - /** [Jungfrau] */ + /** [Jungfrau][Gotthard2] */ Result getNumberofUDPInterfaces(Positions pos = {}) const; - /** [Jungfrau] Also restarts client and receiver sockets */ + /** [Jungfrau][Gotthard2] Also restarts client and receiver zmq sockets + * [Gotthard2] second interface enabled to send veto information for + * debugging + * n can be 1 or 2 */ void setNumberofUDPInterfaces(int n, Positions pos = {}); /** [Jungfrau] */ diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 6bd00844b..cd4b4db3f 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1517,10 +1517,13 @@ class CmdProxy { /* Network Configuration (Detector<->Receiver) */ - INTEGER_COMMAND(numinterfaces, getNumberofUDPInterfaces, - setNumberofUDPInterfaces, StringTo, - "[1, 2]\n\t[Jungfrau] Number of udp interfaces to stream " - "data from detector. Default: 1."); + INTEGER_COMMAND( + numinterfaces, getNumberofUDPInterfaces, setNumberofUDPInterfaces, + StringTo, + "[1, 2]\n\t[Jungfrau][Gotthard2] Number of udp interfaces to stream " + "data from detector. Default: 1.\n\t" + "[Gotthard2] Second interface enabled to send veto information for " + "debugging."); INTEGER_COMMAND( selinterface, getSelectedUDPInterface, selectUDPInterface, diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index 5cb1c185c..d4308c4ce 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -383,8 +383,12 @@ int DetectorImpl::createReceivingDataSockets(const bool destroy) { if (multi_shm()->multiDetectorType == EIGER) { numSocketsPerDetector = 2; } - if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() == 2) { - numSocketsPerDetector = 2; + // gotthard2 second interface is only for veto debugging + else if (multi_shm()->multiDetectorType != GOTTHARD2) { + if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() == + 2) { + numSocketsPerDetector = 2; + } } numSockets *= numSocketsPerDetector; @@ -424,9 +428,12 @@ void DetectorImpl::readFrameFromReceiver() { int nDetPixelsY = 0; bool quadEnable = false; bool eiger = false; - bool numInterfaces = Parallel(&Module::getNumberofUDPInterfacesFromShm, {}) - .squash(); // cannot pick up from zmq - + bool numInterfaces = 1; + // gotthard2 second interface is veto debugging + if (multi_shm()->multiDetectorType != GOTTHARD2) { + numInterfaces = Parallel(&Module::getNumberofUDPInterfacesFromShm, {}) + .squash(); // cannot pick up from zmq + } bool runningList[zmqSocket.size()], connectList[zmqSocket.size()]; int numRunning = 0; for (size_t i = 0; i < zmqSocket.size(); ++i) { diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index c7dc1e716..c25d56976 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -780,12 +780,7 @@ class Module : public virtual slsDetectorDefs { */ int getDestinationUDPPort2(); - /** - * Sets the number of UDP interfaces to stream data from detector (Jungfrau - * only) - * @param n number of interfaces. Options 1 or 2. - * @returns the number of interface - */ + /** [Jungfrau][Gotthard2] */ void setNumberofUDPInterfaces(int n); /** Returns the number of udp interfaces from shared memory */ diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 5faac0a04..a6c65f00f 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -394,7 +394,7 @@ int ClientInterface::setup_receiver(Interface &socket) { } impl()->setUDPPortNumber(arg.udp_dstport); impl()->setUDPPortNumber2(arg.udp_dstport2); - if (myDetectorType == JUNGFRAU) { + if (myDetectorType == JUNGFRAU || myDetectorType == GOTTHARD2) { try { impl()->setNumberofUDPInterfaces(arg.udpInterfaces); } catch (const RuntimeError &e) { @@ -1531,7 +1531,7 @@ sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) { int ClientInterface::set_udp_ip2(Interface &socket) { auto arg = socket.Receive(); verifyIdle(socket); - if (myDetectorType != JUNGFRAU) { + if (myDetectorType != JUNGFRAU && myDetectorType != GOTTHARD2) { throw RuntimeError( "UDP Destination IP2 not implemented for this detector"); } @@ -1552,7 +1552,8 @@ int ClientInterface::set_udp_port(Interface &socket) { int ClientInterface::set_udp_port2(Interface &socket) { auto arg = socket.Receive(); verifyIdle(socket); - if (myDetectorType != JUNGFRAU && myDetectorType != EIGER) { + if (myDetectorType != JUNGFRAU && myDetectorType != EIGER && + myDetectorType != GOTTHARD2) { throw RuntimeError( "UDP Destination Port2 not implemented for this detector"); } @@ -1565,7 +1566,7 @@ int ClientInterface::set_num_interfaces(Interface &socket) { auto arg = socket.Receive(); arg = (arg > 1 ? 2 : 1); verifyIdle(socket); - if (myDetectorType != JUNGFRAU) { + if (myDetectorType != JUNGFRAU && myDetectorType != GOTTHARD2) { throw RuntimeError( "Number of interfaces not implemented for this detector"); } diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index 0c3ff3d4a..9725032a1 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -74,7 +74,6 @@ void DataProcessor::RecordFirstIndex(uint64_t fnum) { void DataProcessor::SetGeneralData(GeneralData *g) { generalData = g; - generalData->Print(); if (file != nullptr) { if (file->GetFileType() == HDF5) { file->SetNumberofPixels(generalData->nPixelsX, @@ -352,6 +351,9 @@ void DataProcessor::PadMissingPackets(char *buf) { sls_bitset pmask = header->packetsMask; uint32_t dsize = generalData->dataSize; + if (myDetectorType == GOTTHARD2 && index != 0) { + dsize = generalData->vetoDataSize; + } uint32_t fifohsize = generalData->fifoBufferHeaderSize; uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - generalData->imageSize); diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index 6be20b3ea..3b06dcd46 100644 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -41,10 +41,8 @@ void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) { delete[] completeBuffer; completeBuffer = nullptr; } - if (roi->xmin != -1) { - if (generalData->myDetectorType == GOTTHARD) { - adcConfigured = generalData->GetAdcConfigured(index, *roi); - } + if (generalData->myDetectorType == GOTTHARD && roi->xmin != -1) { + adcConfigured = generalData->GetAdcConfigured(index, *roi); completeBuffer = new char[generalData->imageSizeComplete]; memset(completeBuffer, 0, generalData->imageSizeComplete); } @@ -57,10 +55,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum) { LOG(logDEBUG1) << index << " First Index: " << firstIndex; } -void DataStreamer::SetGeneralData(GeneralData *g) { - generalData = g; - generalData->Print(); -} +void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; } void DataStreamer::SetNumberofDetectors(int *nd) { numDet[0] = nd[0]; @@ -147,7 +142,6 @@ void DataStreamer::ProcessAnImage(char *buf) { // shortframe gotthard if (completeBuffer) { - // disregarding the size modified from callback (always using // imageSizeComplete // instead of buf (32 bit) because gui needs imagesizecomplete and diff --git a/slsReceiverSoftware/src/GeneralData.h b/slsReceiverSoftware/src/GeneralData.h index 3bd322edc..21e3591f3 100644 --- a/slsReceiverSoftware/src/GeneralData.h +++ b/slsReceiverSoftware/src/GeneralData.h @@ -17,86 +17,41 @@ class GeneralData { public: - /** DetectorType */ - slsDetectorDefs::detectorType myDetectorType; - - /** Number of Pixels in x axis */ - uint32_t nPixelsX; - - /** Number of Pixels in y axis */ - uint32_t nPixelsY; - - /** Size of header in Packet */ - uint32_t headerSizeinPacket; - + slsDetectorDefs::detectorType myDetectorType{slsDetectorDefs::GENERIC}; + uint32_t nPixelsX{0}; + uint32_t nPixelsY{0}; + uint32_t headerSizeinPacket{0}; /** Size of just data in 1 packet (in bytes) */ - uint32_t dataSize; - - /** Size of 1 packet (in bytes) */ - uint32_t packetSize; - + uint32_t dataSize{0}; + uint32_t packetSize{0}; /** Number of packets in an image (for each listening UDP port) */ - uint32_t packetsPerFrame; - + uint32_t packetsPerFrame{0}; /** Image size (in bytes, for each listening UDP port) */ - uint32_t imageSize; - - /** Frame Number Mask */ - uint64_t frameIndexMask; - - /** Frame Index Offset */ - uint32_t frameIndexOffset; - - /** Packet Index Mask */ - uint32_t packetIndexMask; - - /** Packet Index Offset */ - uint32_t packetIndexOffset; - - /** Max Frames per binary file */ - uint32_t maxFramesPerFile; - + uint32_t imageSize{0}; + uint64_t frameIndexMask{0}; + uint32_t frameIndexOffset{0}; + uint32_t packetIndexMask{0}; + uint32_t packetIndexOffset{0}; + uint32_t maxFramesPerFile{0}; /** Header size of data saved into fifo buffer at a time*/ - uint32_t fifoBufferHeaderSize; - - /** Default Fifo depth */ - uint32_t defaultFifoDepth; - - /** Threads per receiver */ - uint32_t threadsPerReceiver; - - /** Size of a header packet */ - uint32_t headerPacketSize; - - /** Streaming (for ROI - mainly short Gotthard) - Number of Pixels in x axis - */ - uint32_t nPixelsXComplete; - - /** Streaming (for ROI - mainly short Gotthard) - Number of Pixels in y axis - */ - uint32_t nPixelsYComplete; - + uint32_t fifoBufferHeaderSize{0}; + uint32_t defaultFifoDepth{0}; + uint32_t threadsPerReceiver{1}; + uint32_t headerPacketSize{0}; + /** Streaming (for ROI - mainly short Gotthard) */ + uint32_t nPixelsXComplete{0}; + /** Streaming (for ROI - mainly short Gotthard) */ + uint32_t nPixelsYComplete{0}; /** Streaming (for ROI - mainly short Gotthard) - Image size (in bytes) */ - uint32_t imageSizeComplete; - + uint32_t imageSizeComplete{0}; /** if standard header implemented in firmware */ - bool standardheader; + bool standardheader{false}; + uint32_t defaultUdpSocketBufferSize{RECEIVE_SOCKET_BUFFER_SIZE}; + uint32_t vetoDataSize{0}; + uint32_t vetoPacketSize{0}; + uint32_t vetoImageSize{0}; - /** default udp socket buffer size */ - uint32_t defaultUdpSocketBufferSize; - - /** Cosntructor */ - GeneralData() - : myDetectorType(slsDetectorDefs::GENERIC), nPixelsX(0), nPixelsY(0), - headerSizeinPacket(0), dataSize(0), packetSize(0), packetsPerFrame(0), - imageSize(0), frameIndexMask(0), frameIndexOffset(0), - packetIndexMask(0), packetIndexOffset(0), maxFramesPerFile(0), - fifoBufferHeaderSize(0), defaultFifoDepth(0), threadsPerReceiver(1), - headerPacketSize(0), nPixelsXComplete(0), nPixelsYComplete(0), - imageSizeComplete(0), standardheader(false), - defaultUdpSocketBufferSize(RECEIVE_SOCKET_BUFFER_SIZE){}; - - /** Destructor */ + GeneralData(){}; virtual ~GeneralData(){}; /** @@ -203,35 +158,6 @@ class GeneralData { LOG(logERROR) << "SetNumberofCounters is a generic function that " "should be overloaded by a derived class"; } - - /** - * Print all variables - */ - virtual void Print(TLogLevel level = logDEBUG1) const { - LOG(level) << "\n\nDetector Data Variables:"; - LOG(level) << "myDetectorType: " << sls::ToString(myDetectorType); - LOG(level) << "Pixels X: " << nPixelsX; - LOG(level) << "Pixels Y: " << nPixelsY; - LOG(level) << "Header Size in Packet: " << headerSizeinPacket; - LOG(level) << "Data Size: " << dataSize; - LOG(level) << "Packet Size: " << packetSize; - LOG(level) << "Packets per Frame: " << packetsPerFrame; - LOG(level) << "Image Size: " << imageSize; - LOG(level) << "Frame Index Mask: " << frameIndexMask; - LOG(level) << "Frame Index Offset: " << frameIndexOffset; - LOG(level) << "Packet Index Mask: " << packetIndexMask; - LOG(level) << "Packet Index Offset: " << packetIndexOffset; - LOG(level) << "Max Frames Per File: " << maxFramesPerFile; - LOG(level) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize; - LOG(level) << "Default Fifo Depth: " << defaultFifoDepth; - LOG(level) << "Threads Per Receiver: " << threadsPerReceiver; - LOG(level) << "Header Packet Size: " << headerPacketSize; - LOG(level) << "Complete Pixels X: " << nPixelsXComplete; - LOG(level) << "Complete Pixels Y: " << nPixelsYComplete; - LOG(level) << "Complete Image Size: " << imageSizeComplete; - LOG(level) << "Standard Header: " << standardheader; - LOG(level) << "UDP Socket Buffer Size: " << defaultUdpSocketBufferSize; - }; }; class GotthardData : public GeneralData { @@ -475,7 +401,7 @@ class JungfrauData : public GeneralData { threadsPerReceiver = 1; defaultUdpSocketBufferSize = (1000 * 1024 * 1024); } - } + }; }; class Mythen3Data : public GeneralData { @@ -561,6 +487,24 @@ class Gotthard2Data : public GeneralData { defaultFifoDepth = 50000; standardheader = true; defaultUdpSocketBufferSize = (1000 * 1024 * 1024); + vetoDataSize = 160; + vetoPacketSize = headerSizeinPacket + vetoDataSize; + vetoImageSize = vetoDataSize * packetsPerFrame; + }; + + /** + * set number of interfaces + * @param number of interfaces + */ + void SetNumberofInterfaces(const int n) { + // 2 interfaces (+veto) + if (n == 2) { + threadsPerReceiver = 2; + } + // 1 interface (data only) + else { + threadsPerReceiver = 1; + } }; }; diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index f8a53babf..8534471ef 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -178,13 +178,16 @@ void Implementation::SetupFifoStructure() { fifo.clear(); for (int i = 0; i < numThreads; ++i) { + uint32_t datasize = generalData->imageSize; + // veto data size + if (myDetectorType == GOTTHARD2 && i != 0) { + datasize = generalData->vetoImageSize; + } // create fifo structure try { fifo.push_back(sls::make_unique( - i, - (generalData->imageSize) + (generalData->fifoBufferHeaderSize), - fifoDepth)); + i, datasize + (generalData->fifoBufferHeaderSize), fifoDepth)); } catch (...) { fifo.clear(); fifoDepth = 0; @@ -199,14 +202,15 @@ void Implementation::SetupFifoStructure() { dataProcessor[i]->SetFifo(fifo[i].get()); if (dataStreamer.size()) dataStreamer[i]->SetFifo(fifo[i].get()); + + LOG(logINFO) << "Memory Allocated for Fifo " << i << ": " + << (double)(((size_t)(datasize) + + (size_t)(generalData->fifoBufferHeaderSize)) * + (size_t)fifoDepth) / + (double)(1024 * 1024) + << " MB"; } - LOG(logINFO) << "Memory Allocated Per Fifo: " - << (double)(((size_t)(generalData->imageSize) + - (size_t)(generalData->fifoBufferHeaderSize)) * - (size_t)fifoDepth) / - (double)(1024 * 1024) - << " MB"; LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed"; } diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index 5016bbba0..0caacb1ca 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -63,10 +63,14 @@ void Listener::ResetParametersforNewAcquisition() { currentFrameIndex = 0; lastCaughtFrameIndex = 0; carryOverFlag = false; - carryOverPacket = sls::make_unique(generalData->packetSize); - memset(carryOverPacket.get(), 0, generalData->packetSize); - listeningPacket = sls::make_unique(generalData->packetSize); - memset(carryOverPacket.get(), 0, generalData->packetSize); + uint32_t packetSize = generalData->packetSize; + if (myDetectorType == GOTTHARD2 && index != 0) { + packetSize = generalData->vetoPacketSize; + } + carryOverPacket = sls::make_unique(packetSize); + memset(carryOverPacket.get(), 0, packetSize); + listeningPacket = sls::make_unique(packetSize); + memset(carryOverPacket.get(), 0, packetSize); numPacketsStatistic = 0; numFramesStatistic = 0; @@ -89,10 +93,7 @@ void Listener::RecordFirstIndex(uint64_t fnum) { } } -void Listener::SetGeneralData(GeneralData *g) { - generalData = g; - generalData->Print(); -} +void Listener::SetGeneralData(GeneralData *g) { generalData = g; } void Listener::CreateUDPSockets() { if (!(*activated)) { @@ -108,10 +109,16 @@ void Listener::CreateUDPSockets() { } ShutDownUDPSocket(); + + uint32_t packetSize = generalData->packetSize; + if (myDetectorType == GOTTHARD2 && index != 0) { + packetSize = generalData->vetoPacketSize; + } + // InterfaceNameToIp(eth).str().c_str() try { udpSocket = sls::make_unique( - *udpPortNumber, generalData->packetSize, + *udpPortNumber, packetSize, ((*eth).length() ? sls::InterfaceNameToIp(*eth).str().c_str() : nullptr), *udpSocketBufferSize); @@ -152,9 +159,14 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) { (*eth) = ""; } + uint32_t packetSize = generalData->packetSize; + if (myDetectorType == GOTTHARD2 && index != 0) { + packetSize = generalData->vetoPacketSize; + } + // create dummy socket try { - sls::UdpRxSocket g(*udpPortNumber, generalData->packetSize, + sls::UdpRxSocket g(*udpPortNumber, packetSize, ((*eth).length() ? sls::InterfaceNameToIp(*eth).str().c_str() : nullptr), @@ -260,19 +272,24 @@ uint32_t Listener::ListenToAnImage(char *buf) { uint32_t pnum = 0; uint32_t numpackets = 0; uint32_t dsize = generalData->dataSize; - uint32_t hsize = generalData->headerSizeinPacket; //(includes empty header) + uint32_t imageSize = generalData->imageSize; + uint32_t packetSize = generalData->packetSize; + if (myDetectorType == GOTTHARD2 && index != 0) { + dsize = generalData->vetoDataSize; + imageSize = generalData->vetoImageSize; + packetSize = generalData->vetoPacketSize; + } + uint32_t hsize = generalData->headerSizeinPacket; uint32_t fifohsize = generalData->fifoBufferHeaderSize; uint32_t pperFrame = generalData->packetsPerFrame; bool isHeaderEmpty = true; sls_detector_header *old_header = nullptr; sls_receiver_header *new_header = nullptr; bool standardheader = generalData->standardheader; - uint32_t corrected_dsize = - dsize - ((pperFrame * dsize) - generalData->imageSize); + uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - imageSize); // reset to -1 memset(buf, 0, fifohsize); - /*memset(buf + fifohsize, 0xFF, generalData->imageSize);*/ new_header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES); // deactivated (eiger) @@ -294,7 +311,7 @@ uint32_t Listener::ListenToAnImage(char *buf) { new_header->detHeader.column = column; new_header->detHeader.detType = (uint8_t)generalData->myDetectorType; new_header->detHeader.version = (uint8_t)SLS_DETECTOR_HEADER_VERSION; - return generalData->imageSize; + return imageSize; } // look for carry over @@ -338,7 +355,7 @@ uint32_t Listener::ListenToAnImage(char *buf) { new_header->detHeader.row = row; new_header->detHeader.column = column; } - return generalData->imageSize; + return imageSize; } // copy packet @@ -427,8 +444,7 @@ uint32_t Listener::ListenToAnImage(char *buf) { new_header->detHeader.row = row; new_header->detHeader.column = column; } - return generalData - ->imageSize; // empty packet now, but not empty image + return imageSize; // empty packet now, but not empty image } // update parameters @@ -489,8 +505,7 @@ uint32_t Listener::ListenToAnImage(char *buf) { // detectors) if (fnum != currentFrameIndex) { carryOverFlag = true; - memcpy(carryOverPacket.get(), &listeningPacket[0], - generalData->packetSize); + memcpy(carryOverPacket.get(), &listeningPacket[0], packetSize); switch (*frameDiscardMode) { case DISCARD_EMPTY_FRAMES: @@ -508,7 +523,7 @@ uint32_t Listener::ListenToAnImage(char *buf) { new_header->detHeader.row = row; new_header->detHeader.column = column; } - return generalData->imageSize; + return imageSize; } // copy packet @@ -568,7 +583,7 @@ uint32_t Listener::ListenToAnImage(char *buf) { // complete image new_header->detHeader.packetNumber = numpackets; // number of packets caught - return generalData->imageSize; + return imageSize; } void Listener::PrintFifoStatistics() {