diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db277142..a2281fb21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,6 +137,7 @@ sls_enable_cxx_warning("-Wnull-dereference") sls_enable_cxx_warning("-Wduplicated-cond") sls_disable_cxx_warning("-Wclass-memaccess") sls_disable_c_warning("-Wstringop-truncation") +sls_disable_c_warning("-Wformat-nonliteral") if(SLS_USE_SANITIZER) diff --git a/RELEASE.txt b/RELEASE.txt index 872f6e040..27cd5cec7 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -242,6 +242,10 @@ This document describes the differences between v6.0.0 and v5.1.0. values. 7. [Eiger] fast quad fix for loading trimbits + + 8. [Eiger] Can also use copydetectorserver command. + [All] copydetectorserver command also creates a link to the binary compied + with a shorter name ([detector]DetectorServer only) Receiver -------- diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer new file mode 100755 index 000000000..e921aa242 Binary files /dev/null and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h index 7e173e9f8..93d7569cb 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h @@ -7,6 +7,8 @@ #define MIN_REQRD_VRSN_T_RD_API 0x181130 #define REQRD_FRMWR_VRSN 0x201005 +#define LINKED_SERVER_NAME "ctbDetectorServer" + #define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000) /* Struct Definitions */ diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer new file mode 100755 index 000000000..b76382caa Binary files /dev/null and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h index 807985d46..3f0e5a288 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h @@ -3,6 +3,8 @@ #pragma once #include "sls/sls_detector_defs.h" +#define LINKED_SERVER_NAME "eigerDetectorServer" + #define REQUIRED_FIRMWARE_VERSION (29) // virtual ones renamed for consistency // real ones keep previous name for compatibility (already in production) @@ -11,8 +13,8 @@ #else #define ID_FILE "detid.txt" #endif -#define CONFIG_FILE ("config_eiger.txt") -#define WAIT_STOP_SERVER_START (1 * 1000 * 1000) +#define CONFIG_FILE ("config_eiger.txt") +#define WAIT_STOP_SERVER_START (1 * 1000 * 1000) #define STATUS_IDLE 0 #define STATUS_RUNNING 1 diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer new file mode 100755 index 000000000..a010150dc Binary files /dev/null and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h index 0f5f4971c..44fa5f4e6 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h @@ -7,34 +7,36 @@ #define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020" #define ID_FILE "detid_gotthard2.txt" +#define LINKED_SERVER_NAME "gotthard2DetectorServer" + #define CTRL_SRVR_INIT_TIME_US (300 * 1000) /* Hardware Definitions */ -#define NCHAN (128) -#define NCHIP (10) -#define NDAC (16) -#define NADC (32) -#define ONCHIP_NDAC (7) -#define DYNAMIC_RANGE (16) -#define HV_SOFT_MAX_VOLTAGE (500) -#define HV_HARD_MAX_VOLTAGE (530) -#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac") -#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac") -#define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac") -#define TYPE_FILE_NAME ("/etc/devlinks/type") -#define CONFIG_FILE ("config_gotthard2.txt") -#define DAC_MAX_MV (2048) -#define ONCHIP_DAC_MAX_VAL (0x3FF) -#define ADU_MAX_VAL (0xFFF) -#define ADU_MAX_BITS (12) -#define MAX_FRAMES_IN_BURST_MODE (2720) -#define TYPE_GOTTHARD2_MODULE_VAL (536) -#define TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL (683) -#define TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL (704) -#define TYPE_GOTTHARD2_MODULE_VAL (536) -#define TYPE_TOLERANCE (5) -#define TYPE_NO_MODULE_STARTING_VAL (800) -#define INITIAL_STARTUP_WAIT (1 * 1000 * 1000) +#define NCHAN (128) +#define NCHIP (10) +#define NDAC (16) +#define NADC (32) +#define ONCHIP_NDAC (7) +#define DYNAMIC_RANGE (16) +#define HV_SOFT_MAX_VOLTAGE (500) +#define HV_HARD_MAX_VOLTAGE (530) +#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac") +#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac") +#define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac") +#define TYPE_FILE_NAME ("/etc/devlinks/type") +#define CONFIG_FILE ("config_gotthard2.txt") +#define DAC_MAX_MV (2048) +#define ONCHIP_DAC_MAX_VAL (0x3FF) +#define ADU_MAX_VAL (0xFFF) +#define ADU_MAX_BITS (12) +#define MAX_FRAMES_IN_BURST_MODE (2720) +#define TYPE_GOTTHARD2_MODULE_VAL (536) +#define TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL (683) +#define TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL (704) +#define TYPE_GOTTHARD2_MODULE_VAL (536) +#define TYPE_TOLERANCE (5) +#define TYPE_NO_MODULE_STARTING_VAL (800) +#define INITIAL_STARTUP_WAIT (1 * 1000 * 1000) /** Default Parameters */ #define DEFAULT_BURST_MODE (BURST_INTERNAL) @@ -54,20 +56,20 @@ #define DEFAULT_TIMING_SOURCE (TIMING_INTERNAL) #define DEFAULT_ALGORITHM (ALG_HITS) -#define DEFAULT_READOUT_C0 (8) //(108333336) // rdo_clk, 144 MHz -#define DEFAULT_READOUT_C1 (8) //(108333336) // rdo_x2_clk, 144 MHz +#define DEFAULT_READOUT_C0 (8) //(108333336) // rdo_clk, 144 MHz +#define DEFAULT_READOUT_C1 (8) //(108333336) // rdo_x2_clk, 144 MHz #define DEFAULT_SYSTEM_C0 (5) //(144444448) // run_clk, 144 MHz #define DEFAULT_SYSTEM_C1 (10) //(72222224) // chip_clk, 72 MHz #define DEFAULT_SYSTEM_C2 (5) //(144444448) // sync_clk, 144 MHz #define DEFAULT_SYSTEM_C3 (5) //(144444448) // str_clk, 144 MHz -#define DEFAULT_READOUT_SPEED (G2_108MHZ) -#define SPEED_144_CLKDIV_0 (6) -#define SPEED_144_CLKDIV_1 (6) -#define SPEED_144_CLKPHASE_DEG_1 (122) // 125 not possible -#define SPEED_108_CLKDIV_0 (8) -#define SPEED_108_CLKDIV_1 (8) -#define SPEED_108_CLKPHASE_DEG_1 (268) // 270 not possible +#define DEFAULT_READOUT_SPEED (G2_108MHZ) +#define SPEED_144_CLKDIV_0 (6) +#define SPEED_144_CLKDIV_1 (6) +#define SPEED_144_CLKPHASE_DEG_1 (122) // 125 not possible +#define SPEED_108_CLKDIV_0 (8) +#define SPEED_108_CLKDIV_1 (8) +#define SPEED_108_CLKPHASE_DEG_1 (268) // 270 not possible /* Firmware Definitions */ #define FIXED_PLL_FREQUENCY (20000000) // 20MHz @@ -80,7 +82,7 @@ #define DEFAULT_ASIC_DOUT_RDY_SRC (0x5) #define DEFAULT_ASIC_DOUT_RDY_DLY (0x3) -#define VETO_DATA_SIZE (160) +#define VETO_DATA_SIZE (160) typedef struct { uint64_t frameNumber; uint64_t bunchId; @@ -159,17 +161,17 @@ enum PLLINDEX { READOUT_PLL, SYSTEM_PLL }; #define ASIC_ADC_MAX_VAL (0x7F) #define ASIC_GLOBAL_SETT_MAX_BITS (6) -#define ASIC_EXT_MEMCTRL_OFST (0) -#define ASIC_EXT_MEMCTRL_MSK (0x1 << ASIC_EXT_MEMCTRL_OFST) -#define ASIC_EXT_TIMING_OFST (1) -#define ASIC_EXT_TIMING_MSK (0x1 << ASIC_EXT_TIMING_OFST) -#define ASIC_CONT_MODE_OFST (2) -#define ASIC_CONT_MODE_MSK (0x1 << ASIC_CONT_MODE_OFST) -#define ASIC_FILTER_OFST (3) -#define ASIC_FILTER_MSK (0x3 << ASIC_FILTER_OFST) +#define ASIC_EXT_MEMCTRL_OFST (0) +#define ASIC_EXT_MEMCTRL_MSK (0x1 << ASIC_EXT_MEMCTRL_OFST) +#define ASIC_EXT_TIMING_OFST (1) +#define ASIC_EXT_TIMING_MSK (0x1 << ASIC_EXT_TIMING_OFST) +#define ASIC_CONT_MODE_OFST (2) +#define ASIC_CONT_MODE_MSK (0x1 << ASIC_CONT_MODE_OFST) +#define ASIC_FILTER_OFST (3) +#define ASIC_FILTER_MSK (0x3 << ASIC_FILTER_OFST) #define ASIC_FILTER_MAX_RES_VALUE (3) -#define ASIC_CDS_GAIN_OFST (5) -#define ASIC_CDS_GAIN_MSK (0x1 << ASIC_CDS_GAIN_OFST) +#define ASIC_CDS_GAIN_OFST (5) +#define ASIC_CDS_GAIN_MSK (0x1 << ASIC_CDS_GAIN_OFST) /* Struct Definitions */ typedef struct udp_header_struct { diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer new file mode 100755 index 000000000..973e34b85 Binary files /dev/null and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h index fa91cc1ee..b91bb9ab2 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h @@ -4,6 +4,8 @@ #include "sls/sls_detector_defs.h" #include +#define LINKED_SERVER_NAME "gotthardDetectorServer" + /* Enums */ enum ADCINDEX { TEMP_FPGA, TEMP_ADC }; enum DACINDEX { diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 9892591de..0bc288af1 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index 4f98c0b2e..67e899c24 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -8,6 +8,8 @@ #define REQRD_FRMWRE_VRSN_BOARD2 0x210831 // 1.0 pcb (version = 010) #define REQRD_FRMWRE_VRSN 0x211008 // 2.0 pcb (version = 011) +#define LINKED_SERVER_NAME "jungfrauDetectorServer" + #define CTRL_SRVR_INIT_TIME_US (300 * 1000) /* Struct Definitions */ @@ -65,9 +67,9 @@ enum DACINDEX { 420 /* J_VREF_COMP */ \ }; -#define NUMSETTINGS (2) -#define NSPECIALDACS (3) -#define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP}; +#define NUMSETTINGS (2) +#define NSPECIALDACS (3) +#define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP}; #define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \ { 1450, 480, 420 } #define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \ @@ -111,20 +113,20 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; #define DEFAULT_FILTER_RESISTOR (1) // higher resistor #define DEFAULT_FILTER_CELL (0) -#define HIGHVOLTAGE_MIN (60) -#define HIGHVOLTAGE_MAX (200) -#define DAC_MIN_MV (0) -#define DAC_MAX_MV (2500) -#define MAX_FILTER_CELL_VAL (12) +#define HIGHVOLTAGE_MIN (60) +#define HIGHVOLTAGE_MAX (200) +#define DAC_MIN_MV (0) +#define DAC_MAX_MV (2500) +#define MAX_FILTER_CELL_VAL (12) #define MIN_ROWS_PER_READOUT (8) #define MAX_ROWS_PER_READOUT (512) -#define READ_N_ROWS_MULTIPLE (8) //512 rows/128packets * 2 interfaces - +#define READ_N_ROWS_MULTIPLE (8) // 512 rows/128packets * 2 interfaces + /* Defines in the Firmware */ #define MAX_TIMESLOT_VAL (0x1F) #define MAX_THRESHOLD_TEMP_VAL (127999) // millidegrees #define MAX_STORAGE_CELL_VAL (15) // 0xF -#define MAX_STORAGE_CELL_CHIP11_VAL (3) +#define MAX_STORAGE_CELL_CHIP11_VAL (3) #define MAX_STORAGE_CELL_DLY_NS_VAL (ASIC_CTRL_EXPSRE_TMR_MAX_VAL) #define ACQ_TIME_MIN_CLOCK (2) #define ASIC_FILTER_MAX_RES_VALUE (1) @@ -137,32 +139,28 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; #define ADC_PORT_INVERT_VAL (0x5A5A5A5A) #define ADC_PORT_INVERT_BOARD2_VAL (0x453b2a9c) - - // 2.0 pcb (chipv1.1) -#define SAMPLE_ADC_FULL_SPEED_CHIP11 \ +#define SAMPLE_ADC_FULL_SPEED_CHIP11 \ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + \ SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_DECMT_FACTOR_FULL_VAL) // 0x0000 -#define SAMPLE_ADC_HALF_SPEED_CHIP11 \ +#define SAMPLE_ADC_HALF_SPEED_CHIP11 \ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + \ SAMPLE_DGTL_SAMPLE_1_VAL + SAMPLE_DECMT_FACTOR_HALF_VAL) // 0x1110 -#define SAMPLE_ADC_QUARTER_SPEED_CHIP11 \ +#define SAMPLE_ADC_QUARTER_SPEED_CHIP11 \ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_3_VAL + \ SAMPLE_DGTL_SAMPLE_2_VAL + SAMPLE_DECMT_FACTOR_QUARTER_VAL) // 0x2230 -#define ADC_PHASE_FULL_SPEED_CHIP11 (160) -#define ADC_PHASE_HALF_SPEED_CHIP11 (160) -#define ADC_PHASE_QUARTER_SPEED_CHIP11 (160) - -#define DBIT_PHASE_FULL_SPEED_CHIP11 (75) -#define DBIT_PHASE_HALF_SPEED_CHIP11 (135) -#define DBIT_PHASE_QUARTER_SPEED_CHIP11 (135) - -#define ADC_OFST_FULL_SPEED_VAL_CHIP11 (0x10) -#define ADC_OFST_HALF_SPEED_VAL_CHIP11 (0x08) -#define ADC_OFST_QUARTER_SPEED_VAL_CHIP11 (0x04) +#define ADC_PHASE_FULL_SPEED_CHIP11 (160) +#define ADC_PHASE_HALF_SPEED_CHIP11 (160) +#define ADC_PHASE_QUARTER_SPEED_CHIP11 (160) +#define DBIT_PHASE_FULL_SPEED_CHIP11 (75) +#define DBIT_PHASE_HALF_SPEED_CHIP11 (135) +#define DBIT_PHASE_QUARTER_SPEED_CHIP11 (135) +#define ADC_OFST_FULL_SPEED_VAL_CHIP11 (0x10) +#define ADC_OFST_HALF_SPEED_VAL_CHIP11 (0x08) +#define ADC_OFST_QUARTER_SPEED_VAL_CHIP11 (0x04) // 2.0 pcb (chipv1.0) #define SAMPLE_ADC_FULL_SPEED_CHIP10 \ @@ -175,19 +173,17 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_3_VAL + \ SAMPLE_DGTL_SAMPLE_6_VAL + SAMPLE_DECMT_FACTOR_QUARTER_VAL) // 0x2630 -#define ADC_PHASE_FULL_SPEED_CHIP10 (160) -#define ADC_PHASE_HALF_SPEED_CHIP10 (160) -#define ADC_PHASE_QUARTER_SPEED_CHIP10 (160) - -#define DBIT_PHASE_FULL_SPEED_CHIP10 (100) -#define DBIT_PHASE_HALF_SPEED_CHIP10 (150) -#define DBIT_PHASE_QUARTER_SPEED_CHIP10 (150) - -#define ADC_OFST_FULL_SPEED_VAL_CHIP10 (0x10) -#define ADC_OFST_HALF_SPEED_VAL_CHIP10 (0x08) -#define ADC_OFST_QUARTER_SPEED_VAL_CHIP10 (0x04) +#define ADC_PHASE_FULL_SPEED_CHIP10 (160) +#define ADC_PHASE_HALF_SPEED_CHIP10 (160) +#define ADC_PHASE_QUARTER_SPEED_CHIP10 (160) +#define DBIT_PHASE_FULL_SPEED_CHIP10 (100) +#define DBIT_PHASE_HALF_SPEED_CHIP10 (150) +#define DBIT_PHASE_QUARTER_SPEED_CHIP10 (150) +#define ADC_OFST_FULL_SPEED_VAL_CHIP10 (0x10) +#define ADC_OFST_HALF_SPEED_VAL_CHIP10 (0x08) +#define ADC_OFST_QUARTER_SPEED_VAL_CHIP10 (0x04) // 1.0 pcb (2 resistor network) #define SAMPLE_ADC_HALF_SPEED_BOARD2 \ @@ -197,11 +193,11 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + \ SAMPLE_DGTL_SAMPLE_6_VAL + SAMPLE_DECMT_FACTOR_QUARTER_VAL) // 0x2610 -#define ADC_PHASE_HALF_SPEED_BOARD2 (110) -#define ADC_PHASE_QUARTER_SPEED_BOARD2 (220) +#define ADC_PHASE_HALF_SPEED_BOARD2 (110) +#define ADC_PHASE_QUARTER_SPEED_BOARD2 (220) -#define DBIT_PHASE_HALF_SPEED_BOARD2 (150) -#define DBIT_PHASE_QUARTER_SPEED_BOARD2 (150) +#define DBIT_PHASE_HALF_SPEED_BOARD2 (150) +#define DBIT_PHASE_QUARTER_SPEED_BOARD2 (150) -#define ADC_OFST_HALF_SPEED_BOARD2_VAL (0x10) -#define ADC_OFST_QUARTER_SPEED_BOARD2_VAL (0x08) +#define ADC_OFST_HALF_SPEED_BOARD2_VAL (0x10) +#define ADC_OFST_QUARTER_SPEED_BOARD2_VAL (0x08) diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer new file mode 100755 index 000000000..77dc77373 Binary files /dev/null and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h index ffcd29bd3..a86f350d2 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h @@ -7,6 +7,8 @@ #define MIN_REQRD_VRSN_T_RD_API 0x180314 #define REQRD_FRMWR_VRSN 0x201005 +#define LINKED_SERVER_NAME "moenchDetectorServer" + #define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000) /* Struct Definitions */ diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer new file mode 100755 index 000000000..0a6059037 Binary files /dev/null and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index 74a021209..06ee3b36b 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -7,6 +7,8 @@ #define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020" #define ID_FILE "detid_mythen3.txt" +#define LINKED_SERVER_NAME "mythen3DetectorServer" + #define CTRL_SRVR_INIT_TIME_US (300 * 1000) /* Hardware Definitions */ diff --git a/slsDetectorServers/slsDetectorServer/src/programFpgaBlackfin.c b/slsDetectorServers/slsDetectorServer/src/programFpgaBlackfin.c index 32395b859..bfbe08b28 100644 --- a/slsDetectorServers/slsDetectorServer/src/programFpgaBlackfin.c +++ b/slsDetectorServers/slsDetectorServer/src/programFpgaBlackfin.c @@ -7,8 +7,8 @@ #include "slsDetectorServer_defs.h" #include -#include // usleep #include +#include // usleep /* global variables */ // clang-format off @@ -18,7 +18,7 @@ #define FLASH_BUFFER_MEMORY_SIZE (128 * 1024) // 500 KB // clang-format on -#define FLASH_DRIVE_NAME_SIZE 16 +#define FLASH_DRIVE_NAME_SIZE 16 char flashDriveName[FLASH_DRIVE_NAME_SIZE] = {0}; int gpioDefined = 0; @@ -71,16 +71,25 @@ void resetFPGA() { int deleteOldFile(char *mess) { char cmd[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; - sprintf(cmd, "rm -fr %s", TEMP_PROG_FILE_NAME); - if (FAIL == executeCommand(cmd, retvals, logDEBUG1)) { - strcpy(mess, - "Could not program fpga. (could not delete old file: "); - strncat(mess, retvals, MAX_STR_LENGTH - strlen(mess) - 1); - strcat(mess, "\n"); + + char *format = "rm -fr %s"; + if (snprintf(cmd, MAX_STR_LENGTH, format, TEMP_PROG_FILE_NAME) >= + MAX_STR_LENGTH) { + strcpy( + mess, + "Could not program fpga. Command to delete old file is too long\n"); LOG(logERROR, (mess)); return FAIL; } - LOG(logINFO, ("\tDeleted old programming file (%s)\n", TEMP_PROG_FILE_NAME)); + if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + snprintf(mess, MAX_STR_LENGTH, + "Could not program fpga. (could not delete old file: %s)\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand + return FAIL; + } + LOG(logINFO, + ("\tDeleted old programming file (%s)\n", TEMP_PROG_FILE_NAME)); return OK; } @@ -142,12 +151,11 @@ int copyToFlash(ssize_t fsize, char *clientChecksum, char *mess) { return FAIL; } -/* ignoring this until a consistent way to read from bfin flash - if (verifyChecksumFromFlash(mess, clientChecksum, flashDriveName, fsize) == - FAIL) { - return FAIL; - } -*/ + /* ignoring this until a consistent way to read from bfin flash + if (verifyChecksumFromFlash(mess, clientChecksum, flashDriveName, fsize) + == FAIL) { return FAIL; + } + */ if (waitForFPGAtoTouchFlash(mess) == FAIL) { return FAIL; } @@ -171,12 +179,13 @@ int getDrive(char *mess) { char cmd[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; + strcpy(cmd, CMD_GET_FLASH); if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { - strcpy(mess, "Could not program fpga. (could not get flash drive: "); - strncat(mess, retvals, sizeof(mess) - strlen(mess) - 1); - strcat(mess, "\n"); - LOG(logERROR, (mess)); + snprintf(mess, MAX_STR_LENGTH, + "Could not program fpga. (could not get flash drive: %s)\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand return FAIL; } @@ -230,15 +239,21 @@ int eraseFlash(char *mess) { #endif char cmd[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; - sprintf(cmd, "flash_eraseall %s", flashDriveName); - if (FAIL == executeCommand(cmd, retvals, logDEBUG1)) { - strcpy(mess, "Could not program fpga. (could not erase flash: "); - strncat(mess, retvals, sizeof(mess) - strlen(mess) - 1); - strcat(mess, "\n"); + char *format = "flash_eraseall %s"; + if (snprintf(cmd, MAX_STR_LENGTH, format, flashDriveName) >= + MAX_STR_LENGTH) { + strcpy(mess, + "Could not program fpga. Command to erase flash is too long\n"); LOG(logERROR, (mess)); return FAIL; } - + if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + snprintf(mess, MAX_STR_LENGTH, + "Could not program fpga. (could not erase flash: %s)\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand + return FAIL; + } LOG(logINFO, ("\tFlash erased\n")); return OK; } @@ -246,8 +261,7 @@ int eraseFlash(char *mess) { int writeToFlash(ssize_t fsize, FILE *flashfd, FILE *srcfd, char *mess) { LOG(logDEBUG1, ("writing to flash\n")); - - char* buffer = malloc(FLASH_BUFFER_MEMORY_SIZE); + char *buffer = malloc(FLASH_BUFFER_MEMORY_SIZE); if (buffer == NULL) { fclose(flashfd); fclose(srcfd); @@ -260,12 +274,13 @@ int writeToFlash(ssize_t fsize, FILE *flashfd, FILE *srcfd, char *mess) { int oldProgress = 0; ssize_t totalBytes = 0; - ssize_t bytes = fread((void*)buffer, sizeof(char), FLASH_BUFFER_MEMORY_SIZE, srcfd); + ssize_t bytes = + fread((void *)buffer, sizeof(char), FLASH_BUFFER_MEMORY_SIZE, srcfd); while (bytes > 0) { ssize_t bytesWritten = - fwrite((void*)buffer, sizeof(char), bytes, flashfd); + fwrite((void *)buffer, sizeof(char), bytes, flashfd); totalBytes += bytesWritten; if (bytesWritten != bytes) { @@ -289,9 +304,11 @@ int writeToFlash(ssize_t fsize, FILE *flashfd, FILE *srcfd, char *mess) { fflush(stdout); oldProgress = progress; } - } else printf("."); + } else + printf("."); - bytes = fread((void*)buffer, sizeof(char), FLASH_BUFFER_MEMORY_SIZE, srcfd); + bytes = fread((void *)buffer, sizeof(char), FLASH_BUFFER_MEMORY_SIZE, + srcfd); } if (fsize <= 0) { printf("\n"); @@ -302,15 +319,18 @@ int writeToFlash(ssize_t fsize, FILE *flashfd, FILE *srcfd, char *mess) { LOG(logINFO, ("\tWrote %ld bytes to flash\n", totalBytes)); if (totalBytes != fsize) { - sprintf(mess, "Could not program fpga. Incorrect bytes written to flash %lu [expected: %lu]\n", totalBytes, fsize); + sprintf(mess, + "Could not program fpga. Incorrect bytes written to flash %lu " + "[expected: %lu]\n", + totalBytes, fsize); LOG(logERROR, (mess)); - return FAIL; + return FAIL; } return OK; } -int waitForFPGAtoTouchFlash(char* mess) { - // touch and program +int waitForFPGAtoTouchFlash(char *mess) { + // touch and program FPGATouchFlash(); #ifdef VIRTUAL @@ -318,36 +338,41 @@ int waitForFPGAtoTouchFlash(char* mess) { #endif LOG(logINFO, ("\tWaiting for FPGA to program from flash\n")); int timeSpent = 0; - + int result = 0; while (result == 0) { // time taken for fpga to pick up from flash usleep(1000); timeSpent += 1000; if (timeSpent >= MAX_TIME_FPGA_TOUCH_FLASH_US) { - sprintf(mess, "Could not program fpga. (exceeded max time allowed: %ds)\n", - MAX_TIME_FPGA_TOUCH_FLASH_US/(1000 * 1000)); + sprintf( + mess, + "Could not program fpga. (exceeded max time allowed: %ds)\n", + MAX_TIME_FPGA_TOUCH_FLASH_US / (1000 * 1000)); LOG(logERROR, (mess)); return FAIL; } - // read gpio status + // read gpio status char retvals[MAX_STR_LENGTH] = {0}; - if (FAIL == executeCommand(CMD_FPGA_PICKED_STATUS, retvals, logDEBUG1)) { - strcpy(mess, - "Could not program fpga. (could not read gpio status: "); - strncat(mess, retvals, sizeof(mess) - strlen(mess) - 1); - strcat(mess, "\n"); - LOG(logERROR, (mess)); + if (FAIL == + executeCommand(CMD_FPGA_PICKED_STATUS, retvals, logDEBUG1)) { + snprintf( + mess, MAX_STR_LENGTH, + "Could not program fpga. (could not read gpio status: %s)\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand return FAIL; } // convert to int if (sscanf(retvals, "%d\n", &result) != 1) { - sprintf(mess, "Could not program fpga. (could not scan int for gpio status: [%s])\n", - retvals); + snprintf(mess, MAX_STR_LENGTH, + "Could not program fpga. (could not scan int for gpio " + "status: [%s])\n", + retvals); LOG(logERROR, (mess)); - return FAIL; + return FAIL; } LOG(logDEBUG1, ("gpi07 returned %d\n", result)); } diff --git a/slsDetectorServers/slsDetectorServer/src/programFpgaNios.c b/slsDetectorServers/slsDetectorServer/src/programFpgaNios.c index 61b49bb5d..c82685224 100644 --- a/slsDetectorServers/slsDetectorServer/src/programFpgaNios.c +++ b/slsDetectorServers/slsDetectorServer/src/programFpgaNios.c @@ -11,9 +11,9 @@ /* global variables */ -#define CMD_GET_FLASH "awk \'$5== \"Application\" {print $1}\' /proc/mtd" +#define CMD_GET_FLASH "awk \'$5== \"Application\" {print $1}\' /proc/mtd" -#define FLASH_DRIVE_NAME_SIZE 16 +#define FLASH_DRIVE_NAME_SIZE 16 char flashDriveName[FLASH_DRIVE_NAME_SIZE] = {0}; #define MICROCONTROLLER_FILE "/dev/ttyAL0" @@ -51,7 +51,7 @@ int eraseAndWriteToFlash(char *mess, char *checksum, char *fpgasrc, return FAIL; } - if (eraseFlash(mess) == FAIL) { + if (eraseFlash(mess) == FAIL) { fclose(flashfd); return FAIL; } @@ -88,10 +88,10 @@ int getDrive(char *mess) { char retvals[MAX_STR_LENGTH] = {0}; strcpy(cmd, CMD_GET_FLASH); if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { - strcpy(mess, "Could not program fpga. (could not get flash drive: "); - strncat(mess, retvals, sizeof(mess) - strlen(mess) - 1); - strcat(mess, "\n"); - LOG(logERROR, (mess)); + snprintf(mess, MAX_STR_LENGTH, + "Could not program fpga. (could not get flash drive: %s)\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand return FAIL; } @@ -129,14 +129,22 @@ int eraseFlash(char *mess) { #endif char cmd[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; - sprintf(cmd, "flash_erase %s 0 0", flashDriveName); - if (FAIL == executeCommand(cmd, retvals, logDEBUG1)) { - strcpy(mess, "Could not program fpga. (could not erase flash: "); - strncat(mess, retvals, sizeof(mess) - strlen(mess) - 1); - strcat(mess, "\n"); + + char *format = "flash_erase %s 0 0"; + if (snprintf(cmd, MAX_STR_LENGTH, format, flashDriveName) >= + MAX_STR_LENGTH) { + strcpy(mess, + "Could not program fpga. Command to erase flash is too long\n"); LOG(logERROR, (mess)); return FAIL; } + if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + snprintf(mess, MAX_STR_LENGTH, + "Could not program fpga. (could not erase flash: %s)\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand + return FAIL; + } LOG(logINFO, ("\tFlash erased\n")); return OK; @@ -148,10 +156,10 @@ int writeToFlash(ssize_t fsize, FILE *flashfd, char *buffer, char *mess) { ssize_t bytesWritten = fwrite((void *)buffer, sizeof(char), fsize, flashfd); if (bytesWritten != fsize) { fclose(flashfd); - sprintf( - mess, - "Could not program fpga. Incorrect bytes written to flash %lu [expected: %lu]\n", - (long int)bytesWritten, (long int)fsize); + sprintf(mess, + "Could not program fpga. Incorrect bytes written to flash %lu " + "[expected: %lu]\n", + (long int)bytesWritten, (long int)fsize); LOG(logERROR, (mess)); return FAIL; } diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 353c3ab4b..1c6299153 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -15,8 +15,8 @@ #include #include #include -#include #include +#include // defined in the detector specific Makefile #ifdef GOTTHARDD @@ -91,7 +91,7 @@ void init_detector() { udpDetails[0].dstport = DEFAULT_UDP_DST_PORTNO; #ifdef EIGERD udpDetails[0].dstport2 = DEFAULT_UDP_DST_PORTNO + 1; -#endif +#endif if (isControlServer) { basictests(); @@ -448,7 +448,7 @@ int executeCommand(char *command, char *result, enum TLogLevel level) { memset(result, 0, MAX_STR_LENGTH); // copy command - char cmd[MAX_STR_LENGTH]= {0}; + char cmd[MAX_STR_LENGTH] = {0}; sprintf(cmd, "%s 2>&1", command); LOG(level, ("Executing command:\n[%s]\n", cmd)); @@ -1060,7 +1060,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { ret = AD9257_SetVrefVoltage(val, mV); if (ret == FAIL) { sprintf(mess, "Could not set Adc Vpp. Please set a " - "proper value\n"); + "proper value\n"); LOG(logERROR, (mess)); } } @@ -1086,14 +1086,14 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { retval = setHighVoltage(val); LOG(logDEBUG1, ("High Voltage: %d\n", retval)); #if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \ -defined(GOTTHARD2D) || defined(MYTHEN3D) + defined(GOTTHARD2D) || defined(MYTHEN3D) validate(&ret, mess, val, retval, "set high voltage", DEC); #endif #ifdef GOTTHARDD if (retval == -1) { ret = FAIL; strcpy(mess, "Invalid Voltage. Valid values are 0, 90, " - "110, 120, 150, 180, 200\n"); + "110, 120, 150, 180, 200\n"); LOG(logERROR, (mess)); } else validate(&ret, mess, val, retval, "set high voltage", DEC); @@ -1107,10 +1107,10 @@ defined(GOTTHARD2D) || defined(MYTHEN3D) val); else if (retval == -2) strcpy(mess, "Setting high voltage failed. " - "Serial/i2c communication failed.\n"); + "Serial/i2c communication failed.\n"); else if (retval == -3) strcpy(mess, "Getting high voltage failed. " - "Serial/i2c communication failed.\n"); + "Serial/i2c communication failed.\n"); LOG(logERROR, (mess)); } #endif @@ -1140,13 +1140,13 @@ defined(GOTTHARD2D) || defined(MYTHEN3D) LOG(logERROR, (mess)); } else if (!isPowerValid(serverDacIndex, val)) { ret = FAIL; - sprintf(mess, - "Could not set power. Power regulator %d " - "should be between %d and %d mV\n", - ind, - (serverDacIndex == D_PWR_IO ? VIO_MIN_MV - : POWER_RGLTR_MIN), - (VCHIP_MAX_MV - VCHIP_POWER_INCRMNT)); + sprintf( + mess, + "Could not set power. Power regulator %d " + "should be between %d and %d mV\n", + ind, + (serverDacIndex == D_PWR_IO ? VIO_MIN_MV : POWER_RGLTR_MIN), + (VCHIP_MAX_MV - VCHIP_POWER_INCRMNT)); LOG(logERROR, (mess)); } else { setPower(serverDacIndex, val); @@ -1161,8 +1161,8 @@ defined(GOTTHARD2D) || defined(MYTHEN3D) if (val >= 0) { ret = FAIL; sprintf(mess, "Can not set Vchip. Can only be set " - "automatically in the background (+200mV " - "from highest power regulator voltage).\n"); + "automatically in the background (+200mV " + "from highest power regulator voltage).\n"); LOG(logERROR, (mess)); /* restrict users from setting vchip if (!mV) { @@ -1192,7 +1192,7 @@ defined(GOTTHARD2D) || defined(MYTHEN3D) if (!mV) { ret = FAIL; strcpy(mess, "Could not set power. VLimit should be in " - "mV and not dac units.\n"); + "mV and not dac units.\n"); LOG(logERROR, (mess)); } else { setVLimit(val); @@ -1221,10 +1221,9 @@ defined(GOTTHARD2D) || defined(MYTHEN3D) LOG(logERROR, (mess)); } else { #if defined(CHIPTESTBOARDD) || defined(MOENCHD) - if ((val != GET_FLAG && mV && - checkVLimitCompliant(val) == FAIL) || + if ((val != GET_FLAG && mV && checkVLimitCompliant(val) == FAIL) || (val != GET_FLAG && !mV && - checkVLimitDacCompliant(val) == FAIL)) { + checkVLimitDacCompliant(val) == FAIL)) { ret = FAIL; sprintf(mess, "Could not set dac %d to value %d. " @@ -1248,7 +1247,7 @@ defined(GOTTHARD2D) || defined(MYTHEN3D) case E_VCP: setSettings(UNDEFINED); LOG(logERROR, ("Settings has been changed " - "to undefined (changed specific dacs)\n")); + "to undefined (changed specific dacs)\n")); break; default: break; @@ -1600,34 +1599,34 @@ void validate_settings(enum detectorSettings sett) { case GAIN0: case HIGHGAIN0: #elif GOTTHARDD - case DYNAMICGAIN: - case HIGHGAIN: - case LOWGAIN: - case MEDIUMGAIN: - case VERYHIGHGAIN: + case DYNAMICGAIN: + case HIGHGAIN: + case LOWGAIN: + case MEDIUMGAIN: + case VERYHIGHGAIN: #elif GOTTHARD2D - case DYNAMICGAIN: - case FIXGAIN1: - case FIXGAIN2: + case DYNAMICGAIN: + case FIXGAIN1: + case FIXGAIN2: #elif MOENCHD - case G1_HIGHGAIN: - case G1_LOWGAIN: - case G2_HIGHCAP_HIGHGAIN: - case G2_HIGHCAP_LOWGAIN: - case G2_LOWCAP_HIGHGAIN: - case G2_LOWCAP_LOWGAIN: - case G4_HIGHGAIN: - case G4_LOWGAIN: + case G1_HIGHGAIN: + case G1_LOWGAIN: + case G2_HIGHCAP_HIGHGAIN: + case G2_HIGHCAP_LOWGAIN: + case G2_LOWCAP_HIGHGAIN: + case G2_LOWCAP_LOWGAIN: + case G4_HIGHGAIN: + case G4_LOWGAIN: #elif MYTHEN3D - case STANDARD: - case FAST: - case HIGHGAIN: + case STANDARD: + case FAST: + case HIGHGAIN: #endif - break; - default: - modeNotImplemented("Settings Index", (int)sett); - break; - } + break; + default: + modeNotImplemented("Settings Index", (int)sett); + break; + } } int set_settings(int file_des) { @@ -1719,16 +1718,16 @@ int acquire(int blocking, int file_des) { // only set if (Server_VerifyLock() == OK) { #ifdef JUNGFRAUD - // chipv1.1 has to be configured before acquisition - if (getChipVersion() == 11 && !isChipConfigured()) { + // chipv1.1 has to be configured before acquisition + if (getChipVersion() == 11 && !isChipConfigured()) { ret = FAIL; strcpy(mess, "Could not start acquisition. Chip is not configured. " "Power it on to configure it.\n"); LOG(logERROR, (mess)); - } else + } else #endif #ifdef MOENCHD - if (getNumAnalogSamples() <= 0) { + if (getNumAnalogSamples() <= 0) { ret = FAIL; sprintf(mess, "Could not start acquisition. Invalid number of analog " @@ -2078,7 +2077,8 @@ int set_num_additional_storage_cells(int file_des) { if (Server_VerifyLock() == OK) { if (getChipVersion() == 11) { ret = FAIL; - sprintf(mess, "Cannot set addl. number of storage cells for chip v1.1\n"); + sprintf(mess, + "Cannot set addl. number of storage cells for chip v1.1\n"); LOG(logERROR, (mess)); } else if (arg > getMaxStoragecellStart()) { ret = FAIL; @@ -2534,7 +2534,7 @@ int get_storage_cell_delay(int file_des) { } else { retval = getStorageCellDelay(); LOG(logDEBUG1, - ("retval storage cell delay %lld ns\n", (long long int)retval)); + ("retval storage cell delay %lld ns\n", (long long int)retval)); } #endif return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); @@ -2557,7 +2557,8 @@ int set_storage_cell_delay(int file_des) { if (Server_VerifyLock() == OK) { if (getChipVersion() == 11) { ret = FAIL; - strcpy(mess, "Storage cell delay is not applicable for chipv 1.1\n"); + strcpy(mess, + "Storage cell delay is not applicable for chipv 1.1\n"); LOG(logERROR, (mess)); } else if (arg > MAX_STORAGE_CELL_DLY_NS_VAL) { ret = FAIL; @@ -3702,7 +3703,10 @@ int program_fpga(int file_des) { fclose(fd); struct sysinfo info; sysinfo(&info); - sprintf(mess, "Could not allocate memory to get fpga program. Free space: %d MB\n", (int)(info.freeram/ (1024 * 1024))); + sprintf(mess, + "Could not allocate memory to get fpga program. Free " + "space: %d MB\n", + (int)(info.freeram / (1024 * 1024))); LOG(logERROR, (mess)); ret = FAIL; } @@ -3735,7 +3739,7 @@ int program_fpga(int file_des) { // unitprogramsize++; } else filesize -= unitprogramsize; - + // copy program if (fwrite((void *)src, sizeof(char), unitprogramsize, fd) != unitprogramsize) { @@ -3759,8 +3763,7 @@ int program_fpga(int file_des) { // checksum of copied program if (ret == OK) { - ret = - verifyChecksumFromFile(mess, checksum, TEMP_PROG_FILE_NAME); + ret = verifyChecksumFromFile(mess, checksum, TEMP_PROG_FILE_NAME); } Server_SendResult(file_des, INT32, NULL, 0); if (ret == FAIL) { @@ -3773,7 +3776,7 @@ int program_fpga(int file_des) { Server_SendResult(file_des, INT32, NULL, 0); if (ret == FAIL) { LOG(logERROR, ("Program FPGA FAIL!\n")); - return FAIL; + return FAIL; } #endif // end of Blackfin programming @@ -4027,7 +4030,8 @@ int storage_cell_start(int file_des) { if ((arg == GET_FLAG) || (Server_VerifyLock() == OK)) { if (arg > getMaxStoragecellStart()) { ret = FAIL; - sprintf(mess, "Max Storage cell number should not exceed %d\n", getMaxStoragecellStart()); + sprintf(mess, "Max Storage cell number should not exceed %d\n", + getMaxStoragecellStart()); LOG(logERROR, (mess)); } else { retval = selectStoragecellStart(arg); @@ -4210,7 +4214,7 @@ int copy_detector_server(int file_des) { if (receiveData(file_des, args, sizeof(args), OTHER) < 0) return printSocketReadError(); -#ifdef EIGERD +#ifdef VIRTUAL functionNotImplemented(); #else @@ -4219,57 +4223,114 @@ int copy_detector_server(int file_des) { char *sname = args[0]; char *hostname = args[1]; LOG(logINFOBLUE, ("Copying server %s from host %s\n", sname, hostname)); + char cmd[MAX_STR_LENGTH] = {0}; - char cmd[MAX_STR_LENGTH]; - memset(cmd, 0, MAX_STR_LENGTH); - - // copy server - strcpy(cmd, "tftp "); - strcat(cmd, hostname); - strcat(cmd, " -r "); - strcat(cmd, sname); - strcat(cmd, " -g"); - int success = executeCommand(cmd, retvals, logDEBUG1); - if (success == FAIL) { + // tftp server + char *format = "tftp %s -r %s -g"; + if (snprintf(cmd, MAX_STR_LENGTH, format, hostname, sname) >= + MAX_STR_LENGTH) { ret = FAIL; - strcpy(mess, retvals); + strcpy(mess, "Could not copy detector server. Command to copy " + "server too long\n"); + LOG(logERROR, (mess)); + } else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + ret = FAIL; + snprintf(mess, MAX_STR_LENGTH, + "Could not copy detector server (tftp). %s\n", retvals); // LOG(logERROR, (mess)); already printed in executecommand + } else { + LOG(logINFO, ("\tServer copied\n")); } - // success - else { - LOG(logINFO, ("Server copied successfully\n")); - // give permissions - strcpy(cmd, "chmod 777 "); - strcat(cmd, sname); - executeCommand(cmd, retvals, logDEBUG1); - -#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) - // edit /etc/inittab - // find line numbers in /etc/inittab where DetectorServer - strcpy(cmd, "sed -n '/DetectorServer/=' /etc/inittab"); - executeCommand(cmd, retvals, logDEBUG1); - while (strlen(retvals)) { - // get first linen number - int lineNumber = atoi(retvals); - // delete that line - sprintf(cmd, "sed -i \'%dd\' /etc/inittab", lineNumber); - executeCommand(cmd, retvals, logDEBUG1); - // find line numbers again - strcpy(cmd, "sed -n '/DetectorServer/=' /etc/inittab"); - executeCommand(cmd, retvals, logDEBUG1); + // give permissions + if (ret == OK) { + if (snprintf(cmd, MAX_STR_LENGTH, "chmod 777 %s", sname) >= + MAX_STR_LENGTH) { + ret = FAIL; + strcpy(mess, "Could not copy detector server. Command to give " + "permissions to server is too long\n"); + LOG(logERROR, (mess)); + } else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + ret = FAIL; + snprintf(mess, MAX_STR_LENGTH, + "Could not copy detector server (permissions). %s\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand + } else { + LOG(logINFO, ("\tPermissions modified\n")); } - LOG(logINFO, ("Deleted all lines containing DetectorServer in " - "/etc/inittab\n")); + } - // append line - strcpy(cmd, "echo \"ttyS0::respawn:/./"); - strcat(cmd, sname); - strcat(cmd, "\" >> /etc/inittab"); - executeCommand(cmd, retvals, logDEBUG1); + // symbolic link + if (ret == OK) { + if (snprintf(cmd, MAX_STR_LENGTH, "ln -sf %s %s", sname, + LINKED_SERVER_NAME) >= MAX_STR_LENGTH) { + ret = FAIL; + strcpy(mess, "Could not copy detector server. Command to " + "create symbolic link too long\n"); + LOG(logERROR, (mess)); + } else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + ret = FAIL; + snprintf(mess, MAX_STR_LENGTH, + "Could not copy detector server (symbolic link). %s\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand + } else { + LOG(logINFO, ("\tSymbolic link created\n")); + } + } - LOG(logINFO, ("/etc/inittab modified to have %s\n", sname)); + // blackfin boards (respawn) (only kept for backwards compatibility) +#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \ + defined(GOTTHARDD) + // delete every line with DetectorServer in /etc/inittab + if (ret == OK) { + strcpy(cmd, "sed -i '/DetectorServer/d' /etc/inittab"); + if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + ret = FAIL; + snprintf( + mess, MAX_STR_LENGTH, + "Could not copy detector server (del respawning). %s\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand + } else { + LOG(logINFO, ("\tinittab: DetectoServer line deleted\n")); + } + } + + // add new link name to /etc/inittab + if (ret == OK) { + format = "echo 'ttyS0::respawn:/./%s' >> /etc/inittab"; + if (snprintf(cmd, MAX_STR_LENGTH, format, LINKED_SERVER_NAME) >= + MAX_STR_LENGTH) { + ret = FAIL; + strcpy(mess, "Could not copy detector server. Command " + "to add new server for spawning is too long\n"); + LOG(logERROR, (mess)); + } else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + ret = FAIL; + snprintf(mess, MAX_STR_LENGTH, + "Could not copy detector server (respawning). %s\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand + } else { + LOG(logINFO, ("\tinittab: updated for respawning\n")); + } + } #endif + + // sync + if (ret == OK) { + strcpy(cmd, "sync"); + if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + ret = FAIL; + snprintf(mess, MAX_STR_LENGTH, + "Could not copy detector server (sync). %s\n", + retvals); + // LOG(logERROR, (mess)); already printed in executecommand + } else { + LOG(logINFO, ("\tsync\n")); + } } } #endif @@ -4756,14 +4817,15 @@ int set_read_n_rows(int file_des) { LOG(logERROR, (mess)); } else #elif JUNGFRAUD - if ((check_detector_idle("set number of rows") == OK) && (arg % READ_N_ROWS_MULTIPLE != 0)) { + if ((check_detector_idle("set number of rows") == OK) && + (arg % READ_N_ROWS_MULTIPLE != 0)) { ret = FAIL; sprintf(mess, "Could not set number of rows. %d must be a multiple " "of %d\n", arg, READ_N_ROWS_MULTIPLE); LOG(logERROR, (mess)); - } else + } else #endif { if (setReadNRows(arg) == FAIL) { @@ -4897,7 +4959,9 @@ int set_detector_position(int file_des) { // only set if (Server_VerifyLock() == OK) { - if (check_detector_idle("configure mac") == OK) { + // if in update mode, there is no need to do this (also detector not set + // up) + if (!updateFlag && check_detector_idle("configure mac") == OK) { maxydet = args[0]; detectorId = args[1]; calculate_and_set_position(); @@ -4923,44 +4987,52 @@ int check_detector_idle(const char *s) { int is_udp_configured() { for (int i = 0; i != numUdpDestinations; ++i) { if (udpDetails[i].dstip == 0) { - sprintf(configureMessage, "udp destination ip not configured [entry:%d]\n", i); + sprintf(configureMessage, + "udp destination ip not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } if (udpDetails[i].srcip == 0) { - sprintf(configureMessage, "udp source ip not configured [entry:%d]\n", i); + sprintf(configureMessage, + "udp source ip not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } if (udpDetails[i].srcmac == 0) { - sprintf(configureMessage, "udp source mac not configured [entry:%d]\n", i); + sprintf(configureMessage, + "udp source mac not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } if (udpDetails[i].dstmac == 0) { - sprintf(configureMessage, "udp destination mac not configured [entry:%d]\n", i); + sprintf(configureMessage, + "udp destination mac not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } #if defined(JUNGFRAUD) || defined(GOTTHARD2D) if (getNumberofUDPInterfaces() == 2) { if (udpDetails[i].srcip2 == 0) { - sprintf(configureMessage, "udp source ip2 not configured [entry:%d]\n", i); + sprintf(configureMessage, + "udp source ip2 not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } if (udpDetails[i].dstip2 == 0) { - sprintf(configureMessage, "udp destination ip2 not configured [entry:%d]\n", i); + sprintf(configureMessage, + "udp destination ip2 not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } if (udpDetails[i].srcmac2 == 0) { - sprintf(configureMessage, "udp source mac2 not configured [entry:%d]\n", i); + sprintf(configureMessage, + "udp source mac2 not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } if (udpDetails[i].dstmac2 == 0) { - sprintf(configureMessage, "udp destination mac2 not configured [entry:%d]\n", i); + sprintf(configureMessage, + "udp destination mac2 not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } @@ -4975,16 +5047,17 @@ void configure_mac() { if (is_udp_configured() == OK) { ret = configureMAC(); if (ret != OK) { - #if defined(CHIPTESTBOARDD) || defined(MOENCHD) +#if defined(CHIPTESTBOARDD) || defined(MOENCHD) if (ret == -1) { sprintf(mess, "Could not allocate RAM\n"); } else { - sprintf(mess, "Could not configure mac because of incorrect " - "udp 1G destination IP and port\n"); + sprintf(mess, + "Could not configure mac because of incorrect " + "udp 1G destination IP and port\n"); } - #else +#else sprintf(mess, "Configure Mac failed\n"); - #endif +#endif strcpy(configureMessage, mess); LOG(logERROR, (mess)); } else { @@ -5416,7 +5489,8 @@ int set_num_interfaces(int file_des) { } else if (check_detector_idle("configure mac") == OK) { if (getNumberofUDPInterfaces() != arg) { setNumberofUDPInterfaces(arg); - for (int iRxEntry = 0; iRxEntry != numUdpDestinations; ++iRxEntry) { + for (int iRxEntry = 0; iRxEntry != numUdpDestinations; + ++iRxEntry) { if (arg == 1) { udpDetails[iRxEntry].srcport2 = 0; udpDetails[iRxEntry].srcip2 = 0; @@ -5425,20 +5499,25 @@ int set_num_interfaces(int file_des) { udpDetails[iRxEntry].dstip2 = 0; udpDetails[iRxEntry].dstmac2 = 0; } else { - // if still 0, set defaults - udpDetails[iRxEntry].srcport2 = DEFAULT_UDP_SRC_PORTNO + 1; + // if still 0, set defaults + udpDetails[iRxEntry].srcport2 = + DEFAULT_UDP_SRC_PORTNO + 1; if (udpDetails[iRxEntry].dstport2 == 0) { - udpDetails[iRxEntry].dstport2 = 2 * iRxEntry + 1 + DEFAULT_UDP_DST_PORTNO; + udpDetails[iRxEntry].dstport2 = + 2 * iRxEntry + 1 + DEFAULT_UDP_DST_PORTNO; } // if still 0, copy from entry 0 if (iRxEntry != 0) { udpDetails[iRxEntry].srcip2 = udpDetails[0].srcip2; - udpDetails[iRxEntry].srcmac2 = udpDetails[0].srcmac2; + udpDetails[iRxEntry].srcmac2 = + udpDetails[0].srcmac2; if (udpDetails[iRxEntry].dstip2 == 0) { - udpDetails[iRxEntry].dstip2 = udpDetails[0].dstip2; + udpDetails[iRxEntry].dstip2 = + udpDetails[0].dstip2; } if (udpDetails[iRxEntry].dstmac2 == 0) { - udpDetails[iRxEntry].dstmac2 = udpDetails[0].dstmac2; + udpDetails[iRxEntry].dstmac2 = + udpDetails[0].dstmac2; } } } @@ -6023,7 +6102,7 @@ int set_clock_divider(int file_des) { if (args[0] >= NUM_CLOCKS) { modeNotImplemented("clock index (divider set)", args[0]); - } + } enum CLKINDEX c = 0; int val = args[1]; @@ -6078,11 +6157,11 @@ int get_clock_divider(int file_des) { functionNotImplemented(); #else // get only - if (arg >= NUM_CLOCKS) { - modeNotImplemented("clock index (divider set)", arg); - } + if (arg >= NUM_CLOCKS) { + modeNotImplemented("clock index (divider set)", arg); + } if (ret == OK) { - enum CLKINDEX c = (enum CLKINDEX)arg; + enum CLKINDEX c = (enum CLKINDEX)arg; retval = getClockDivider(c); char *clock_names[] = {CLK_NAMES}; LOG(logDEBUG1, ("retval %s clock (%d) divider: %d\n", clock_names[c], @@ -6696,8 +6775,8 @@ int set_current_source(int file_des) { int normal = args[2]; LOG(logDEBUG1, ("Setting current source [enable:%d, fix:%d, select:%lld, " - "normal:%d]\n", - enable, fix, (long long int)select, normal)); + "normal:%d]\n", + enable, fix, (long long int)select, normal)); #if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) functionNotImplemented(); @@ -6706,25 +6785,26 @@ int set_current_source(int file_des) { if (Server_VerifyLock() == OK) { if (enable != 0 && enable != 1) { ret = FAIL; - strcpy(mess, - "Could not enable/disable current source. Enable can be 0 or 1 only.\n"); + strcpy(mess, "Could not enable/disable current source. Enable can " + "be 0 or 1 only.\n"); LOG(logERROR, (mess)); - } + } // disable - else if (enable == 0 && (fix != -1 || normal != -1)) { + else if (enable == 0 && (fix != -1 || normal != -1)) { ret = FAIL; - strcpy(mess, - "Could not disable current source. Requires no parameters.\n"); - LOG(logERROR, (mess)); + strcpy( + mess, + "Could not disable current source. Requires no parameters.\n"); + LOG(logERROR, (mess)); } // enable else if (enable == 1) { -#ifdef GOTTHARD2D +#ifdef GOTTHARD2D // no parameters allowed if (fix != -1 || normal != -1) { ret = FAIL; - strcpy(mess, - "Could not enable current source. Fix and normal are invalid parameters for this detector.\n"); + strcpy(mess, "Could not enable current source. Fix and normal " + "are invalid parameters for this detector.\n"); LOG(logERROR, (mess)); } #else @@ -6747,7 +6827,8 @@ int set_current_source(int file_des) { if (fix != 0 && fix != 1) { ret = FAIL; strcpy(mess, - "Could not enable current source. Invalid value for parameter (fix). Options: 0 or 1.\n"); + "Could not enable current source. Invalid value " + "for parameter (fix). Options: 0 or 1.\n"); LOG(logERROR, (mess)); } else if (normal != -1) { ret = FAIL; @@ -6781,7 +6862,8 @@ int set_current_source(int file_des) { #endif int retval = getCurrentSource(); LOG(logDEBUG1, ("current source enable retval: %u\n", retval)); - validate(&ret, mess, enable, retval, "set current source enable", DEC); + validate(&ret, mess, enable, retval, "set current source enable", + DEC); } } #endif @@ -7847,10 +7929,11 @@ int set_filter_resistor(int file_des) { if (Server_VerifyLock() == OK) { if (arg < 0 || arg > ASIC_FILTER_MAX_RES_VALUE) { ret = FAIL; - sprintf(mess, - "Could not set filter resistor. Invalid filter argument %d. " - "Options [0-%d]\n", - arg, ASIC_FILTER_MAX_RES_VALUE); + sprintf( + mess, + "Could not set filter resistor. Invalid filter argument %d. " + "Options [0-%d]\n", + arg, ASIC_FILTER_MAX_RES_VALUE); LOG(logERROR, (mess)); } #ifdef JUNGFRAUD @@ -7866,7 +7949,7 @@ int set_filter_resistor(int file_des) { if (ret == FAIL) { ret = FAIL; strcpy(mess, "Could not set filter resistor.\n"); - LOG(logERROR, (mess)); + LOG(logERROR, (mess)); } #ifndef JUNGFRAUD // jungfrau might take time to update status register if acquiring @@ -8483,8 +8566,8 @@ int set_veto_algorithm(int file_des) { enum vetoAlgorithm alg = args[0]; enum streamingInterface interface = args[1]; - LOG(logDEBUG1, ("Setting vetoalgorithm (interface: %d): %u\n", (int)interface, - (int)alg)); + LOG(logDEBUG1, ("Setting vetoalgorithm (interface: %d): %u\n", + (int)interface, (int)alg)); #ifndef GOTTHARD2D functionNotImplemented(); @@ -8774,10 +8857,10 @@ int set_flip_rows(int file_des) { #else // only set if (Server_VerifyLock() == OK) { - if ((check_detector_idle("set flip rows") == OK) && (arg != 0 && arg != 1)) { + if ((check_detector_idle("set flip rows") == OK) && + (arg != 0 && arg != 1)) { ret = FAIL; - sprintf(mess, - "Could not set flip rows. Invalid argument %d.\n", + sprintf(mess, "Could not set flip rows. Invalid argument %d.\n", arg); LOG(logERROR, (mess)); } @@ -8803,7 +8886,6 @@ int set_flip_rows(int file_des) { return Server_SendResult(file_des, INT32, NULL, 0); } - int get_filter_cell(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); @@ -8839,7 +8921,8 @@ int set_filter_cell(int file_des) { if (arg < 0 || arg > MAX_FILTER_CELL_VAL) { ret = FAIL; sprintf(mess, - "Could not set filter cell. Invalid argument %d. Options: 0 - %d\n", + "Could not set filter cell. Invalid argument %d. Options: " + "0 - %d\n", arg, MAX_FILTER_CELL_VAL); LOG(logERROR, (mess)); } @@ -8851,7 +8934,8 @@ int set_filter_cell(int file_des) { LOG(logERROR, (mess)); } else { setFilterCell(arg); - // no validation as it might take time to update status register if acquiring + // no validation as it might take time to update status register if + // acquiring } } #endif @@ -9019,8 +9103,8 @@ int set_dest_udp_list(int file_des) { return printSocketReadError(); // swap ip - args[3] = __builtin_bswap32(args[3]); - args[4] = __builtin_bswap32(args[4]); + args[3] = __builtin_bswap32(args[3]); + args[4] = __builtin_bswap32(args[4]); // convert to string char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN]; @@ -9039,22 +9123,21 @@ int set_dest_udp_list(int file_des) { LOG(logINFOBLUE, ("Setting udp dest. [%d]: [port %d, port2 %d, ip %s, ip2 %s, " "mac %s, mac2 %s]\n", - entry, args[1], args[2], ip, ip2, mac, mac2)); + entry, args[1], args[2], ip, ip2, mac, mac2)); if (entry < 1 || entry >= MAX_UDP_DESTINATION) { ret = FAIL; - sprintf( - mess, - "Could not set udp destination. Invalid entry. Options: 1 - %d\n", - MAX_UDP_DESTINATION - 1); + sprintf(mess, + "Could not set udp destination. Invalid entry. Options: 1 " + "- %d\n", + MAX_UDP_DESTINATION - 1); LOG(logERROR, (mess)); - } + } #ifdef EIGERD else if (args[4] != 0 || args64[1] != 0) { ret = FAIL; - strcpy( - mess, - "Could not set udp destination. ip2 and mac2 not implemented for this detector.\n"); + strcpy(mess, "Could not set udp destination. ip2 and mac2 not " + "implemented for this detector.\n"); LOG(logERROR, (mess)); } #endif @@ -9063,7 +9146,7 @@ int set_dest_udp_list(int file_des) { if (args[1] != 0) { udpDetails[entry].dstport = args[1]; } - if (args[2] != 0) { + if (args[2] != 0) { udpDetails[entry].dstport2 = args[2]; } if (args[3] != 0) { @@ -9086,12 +9169,14 @@ int set_dest_udp_list(int file_des) { #endif udpDetails[entry].srcport = DEFAULT_UDP_SRC_PORTNO; if (udpDetails[entry].dstport == 0) { - udpDetails[entry].dstport = 2 * entry + DEFAULT_UDP_DST_PORTNO; + udpDetails[entry].dstport = + 2 * entry + DEFAULT_UDP_DST_PORTNO; } if (myDetectorType == EIGER || twoInterfaces) { udpDetails[entry].srcport2 = DEFAULT_UDP_SRC_PORTNO + 1; if (udpDetails[entry].dstport2 == 0) { - udpDetails[entry].dstport2 = 2 * entry + 1 + DEFAULT_UDP_DST_PORTNO; + udpDetails[entry].dstport2 = + 2 * entry + 1 + DEFAULT_UDP_DST_PORTNO; } } // if still 0, copy from entry 0 @@ -9161,11 +9246,12 @@ int get_num_dest_list(int file_des) { int retval1 = 0; if (getNumberofDestinations(&retval1) == FAIL || retval1 != retval) { - ret = FAIL; - sprintf( - mess, - "Could not get number of udp destinations. (server reads %d, fpga reads %d).\n", retval1, retval); - LOG(logERROR, (mess)); + ret = FAIL; + sprintf(mess, + "Could not get number of udp destinations. (server reads %d, " + "fpga reads %d).\n", + retval1, retval); + LOG(logERROR, (mess)); } #endif @@ -9232,10 +9318,11 @@ int set_udp_first_dest(int file_des) { if (check_detector_idle("set first udp destination") == OK) { setFirstUDPDestination(arg); int retval = getFirstUDPDestination(); - validate(&ret, mess, arg, retval, "set udp first destination", DEC); + validate(&ret, mess, arg, retval, "set udp first destination", + DEC); if (ret == OK) { firstUDPDestination = arg; - //configure_mac(); + // configure_mac(); } } } @@ -9244,7 +9331,6 @@ int set_udp_first_dest(int file_des) { return Server_SendResult(file_des, INT32, NULL, 0); } - int get_readout_speed(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); @@ -9282,25 +9368,26 @@ int set_readout_speed(int file_des) { #ifdef JUNGFRAUD if (arg == (int)FULL_SPEED && isHardwareVersion2()) { ret = FAIL; - strcpy(mess, - "Full speed not implemented for this board version (v1.0).\n"); + strcpy( + mess, + "Full speed not implemented for this board version (v1.0).\n"); LOG(logERROR, (mess)); - } -#endif + } +#endif if (ret == OK) { switch (arg) { #if defined(EIGERD) || defined(JUNGFRAUD) - case FULL_SPEED: - case HALF_SPEED: - case QUARTER_SPEED: + case FULL_SPEED: + case HALF_SPEED: + case QUARTER_SPEED: #elif GOTTHARD2D - case G2_108MHZ: - case G2_144MHZ: + case G2_108MHZ: + case G2_144MHZ: #endif - break; - default: - modeNotImplemented("readout speed index", arg); - break; + break; + default: + modeNotImplemented("readout speed index", arg); + break; } if (ret == OK) { ret = setReadoutSpeed(arg); @@ -9319,7 +9406,6 @@ int set_readout_speed(int file_des) { } } } - } #endif return Server_SendResult(file_des, INT32, NULL, 0); diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index adbc14d4a..6682be1a8 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -83,7 +83,8 @@ class Detector { /* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */ Result getSerialNumber(Positions pos = {}) const; - /** [Eiger][Gotthard2][Mythen3] 6 bit value (ideally unique) that is streamed out in the UDP header of the detector.*/ + /** [Eiger][Gotthard2][Mythen3] 6 bit value (ideally unique) that is + * streamed out in the UDP header of the detector.*/ Result getModuleId(Positions pos = {}) const; Result getReceiverVersion(Positions pos = {}) const; @@ -309,9 +310,9 @@ class Detector { * [Jungfrau] Options: FULL_SPEED, HALF_SPEED (Default), QUARTER_SPEED \n * [Eiger] Options: FULL_SPEED (Default), HALF_SPEED, QUARTER_SPEED \n * [Gotthard2] Options: G2_108MHZ (Default), G2_144MHZ \n - * [Jungfrau] FULL_SPEED option only available from v2.0 boards and is - * recommended to set number of interfaces to 2. \n Also overwrites adcphase to - * recommended default. + * [Jungfrau] FULL_SPEED option only available from v2.0 boards and is + * recommended to set number of interfaces to 2. \n Also overwrites adcphase + * to recommended default. */ void setReadoutSpeed(defs::speedLevel value, Positions pos = {}); @@ -404,8 +405,9 @@ class Detector { * [Moench] Default is disabled. \n * [Jungfrau] Default is disabled. Get will return power status. Can be off * if temperature event occured (temperature over temp_threshold with - * temp_control enabled. Will configure chip (only chip v1.1)\n [Mythen3][Gotthard2] Default is 1. If module not - * connected or wrong module, powerchip will fail. + * temp_control enabled. Will configure chip (only chip v1.1)\n + * [Mythen3][Gotthard2] Default is 1. If module not connected or wrong + * module, powerchip will fail. */ void setPowerChip(bool on, Positions pos = {}); @@ -518,7 +520,9 @@ class Detector { /** [Eiger] Number of rows to read out per half module * Options: 0 - 256. 256 is default. The permissible values depend on - * dynamic range and 10Gbe enabled. \n[Jungfrau] Number of rows per module starting from the centre. Options: 8 - 512, must be multiples of 8. Default is 512. + * dynamic range and 10Gbe enabled. \n[Jungfrau] Number of rows per module + * starting from the centre. Options: 8 - 512, must be multiples of 8. + * Default is 512. */ void setReadNRows(const int lines, Positions pos = {}); @@ -1209,7 +1213,8 @@ class Detector { Result getStorageCellStart(Positions pos = {}) const; /** [Jungfrau] Advanced. Sets the storage cell storing the first acquisition - * of the series. Options: 0-max. max is 15 (default) for chipv1.0 and 3 (default) for chipv1.1. + * of the series. Options: 0-max. max is 15 (default) for chipv1.0 and 3 + * (default) for chipv1.1. */ void setStorageCellStart(int cell, Positions pos = {}); @@ -1218,7 +1223,7 @@ class Detector { /** [Jungfrau] Advanced \n Additional time delay between 2 consecutive * exposures in burst mode. \n Options: (0-1638375 ns (resolution of 25ns)\n - * Only applicable for chipv1.0. + * Only applicable for chipv1.0. */ void setStorageCellDelay(ns value, Positions pos = {}); @@ -1350,14 +1355,15 @@ class Detector { /** [Gotthard2] */ Result getVetoStream(Positions pos = {}) const; - /** [Gotthard2] Options: NONE (Default), LOW_LATENCY_LINK, ETHERNET_10GB (debugging), ALL - * Enable or disable the 2 veto streaming interfaces available. Can - * concatenate more than one interface. \nLOW_LATENCY_LINK is the default - * interface to work with. \nETHERNET_10GB is for debugging and also enables second - * interface in receiver for listening to veto packets (writes a separate - * file if writing enabled). Also restarts client and receiver zmq sockets - * if zmq streaming enabled.*/ - void setVetoStream(const defs::streamingInterface value, Positions pos = {}); + /** [Gotthard2] Options: NONE (Default), LOW_LATENCY_LINK, ETHERNET_10GB + * (debugging), ALL Enable or disable the 2 veto streaming interfaces + * available. Can concatenate more than one interface. \nLOW_LATENCY_LINK is + * the default interface to work with. \nETHERNET_10GB is for debugging and + * also enables second interface in receiver for listening to veto packets + * (writes a separate file if writing enabled). Also restarts client and + * receiver zmq sockets if zmq streaming enabled.*/ + void setVetoStream(const defs::streamingInterface value, + Positions pos = {}); /** [Gotthard2] */ Result @@ -1529,7 +1535,7 @@ class Detector { /** [CTB] */ void setDBITClock(int value_in_MHz, Positions pos = {}); - /** + /** * [CTB] mV * Options: V_POWER_A, V_POWER_B, V_POWER_C, V_POWER_D, V_POWER_IO */ Result getMeasuredVoltage(defs::dacIndex index, @@ -1713,21 +1719,24 @@ class Detector { * * * ************************************************/ - /** Advanced user Function! - * [Jungfrau][CTB][Moench] fname is a pof file, rebooting the controller is - * recommended \n [Mythen3][Gotthard2] fname is an rbf file, power cycling - * the detector is recommended + /** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2] + * Advanced user Function! + * Program firmware from command line, after which detector controller is + * rebooted. [Jungfrau][CTB][Moench] fname is a pof file (full path) \n + * [Mythen3][Gotthard2] fname is an rbf file (full path) */ void programFPGA(const std::string &fname, Positions pos = {}); /** [Jungfrau][CTB][Moench] Advanced user Function! */ void resetFPGA(Positions pos = {}); - /** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2] + /** [Jungfrau][Eiger][Gotthard][CTB][Moench][Mythen3][Gotthard2] * Advanced user Function! \n - * Copy detector server fname from tftp folder of hostname to detector \n - * [Jungfrau][Gotthard][CTB][Moench] Also changes respawn server, which is - * effective after a reboot. + * Copy detector server fname from tftp folder of hostname to detector. Also + * creates a symbolic link to a shorter name (without vx.x.x). Then the + * detector controller reboots (except eiger) \n + * [Jungfrau][Gotthard][CTB][Moench] Also changes respawn server (to the + * link), which is effective after a reboot. */ void copyDetectorServer(const std::string &fname, const std::string &hostname, Positions pos = {}); @@ -1738,11 +1747,11 @@ class Detector { /** * Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the - * firmware, detector server and then reboots detector controller blackfin. - * \n [Mythen3][Gotthard2] Will still have old server starting up as the new - * server is not respawned \n sname is name of detector server binary found - * on tftp folder of host pc \n hostname is name of pc to tftp from \n fname - * is programming file name + * firmware, detector server, make a soft link and then reboots detector + * controller. \n [Mythen3][Gotthard2] Will require a script to start up the + * shorter named server link at start up \n sname is name of detector + * server binary found on tftp folder of host pc \n hostname is name of pc + * to tftp from \n fname is programming file name with full path to it */ void updateFirmwareAndServer(const std::string &sname, const std::string &hostname, diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index f4c72657b..2c46b78c0 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -612,13 +612,14 @@ std::string CmdProxy::ReadoutSpeed(int action) { os << cmd << ' '; if (action == defs::HELP_ACTION) { os << "\n\t[0 or full_speed|1 or half_speed|2 or " - "quarter_speed]\n\t\t[Eiger][Jungfrau] Readout " - "speed of chip.\n\t\t[Eiger] Default speed is full_speed." - "\n\t\t[Jungfrau] Default speed is half_speed. full_speed " - "option only available from v2.0 boards and is recommended to set " - "number of interfaces to 2. Also overwrites " - "adcphase to recommended default.\n\t [144|108]\n\t\t[Gotthard2] " - "Readout speed of chip in MHz. Default is 108." + "quarter_speed]\n\t\t[Eiger][Jungfrau] Readout " + "speed of chip.\n\t\t[Eiger] Default speed is full_speed." + "\n\t\t[Jungfrau] Default speed is half_speed. full_speed " + "option only available from v2.0 boards and is recommended to " + "set " + "number of interfaces to 2. Also overwrites " + "adcphase to recommended default.\n\t [144|108]\n\t\t[Gotthard2] " + "Readout speed of chip in MHz. Default is 108." << '\n'; } else { defs::detectorType type = det->getDetectorType().squash(); @@ -947,7 +948,8 @@ std::string CmdProxy::CurrentSource(int action) { std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "\n\t[0|1]\n\t\t[Gotthard2] Enable or disable current source. Default " + os << "\n\t[0|1]\n\t\t[Gotthard2] Enable or disable current source. " + "Default " "is disabled.\n\t[0|1] [fix|nofix] [select source] [(only for " "chipv1.1)normal|low]\n\t\t[Jungfrau] Disable or enable current " "source with some parameters. The select source is 0-63 for " @@ -1320,7 +1322,8 @@ std::string CmdProxy::Trigger(int action) { os << cmd << ' '; if (action == defs::HELP_ACTION) { if (cmd == "trigger") { - os << "\n\t[Eiger][Mythen3] Sends software trigger signal to detector"; + os << "\n\t[Eiger][Mythen3] Sends software trigger signal to " + "detector"; } else if (cmd == "blockingtrigger") { os << "\n\t[Eiger] Sends software trigger signal to detector and " "blocks till " @@ -2032,7 +2035,8 @@ std::string CmdProxy::VetoStreaming(int action) { if (action == defs::HELP_ACTION) { os << "[none|lll|10gbe|...]\n\t[Gotthard2] Enable or disable the 2 " "veto streaming interfaces available. Can include more than one " - "interface. \n\tDefault: none. lll (low latency link) is the default " + "interface. \n\tDefault: none. lll (low latency link) is the " + "default " "interface to work with. \n\t10GbE is for debugging and also " "enables second interface in receiver for listening to veto " "packets (writes a separate file if writing enabled). Also " @@ -2815,10 +2819,11 @@ std::string CmdProxy::ProgramFpga(int action) { std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb][Moench] Programs " - "FPGA from pof file. Rebooting controller is recommended. " - "\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file. Power " - "cycling the detector is recommended. " + os << "[fname.pof | fname.rbf (full path)]\n\t[Jungfrau][Ctb][Moench] " + "Programs FPGA from pof file (full path). Then, detector " + "controller is rebooted \n\t[Mythen3][Gotthard2] Programs FPGA " + "from rbf file (full path). Then, detector controller is " + "rebooted." << '\n'; } else if (action == defs::GET_ACTION) { throw sls::RuntimeError("Cannot get"); @@ -2838,11 +2843,13 @@ std::string CmdProxy::CopyDetectorServer(int action) { std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "[server_name] " - "[pc_host_name]\n\t[Jungfrau][Ctb][Moench][Mythen3][Gotthard2] " - "Copies detector server via tftp from pc. " - "\n\t[Jungfrau][Ctb][Moench]Also changes respawn server, which " - "is effective after a reboot." + os << "[server_name (in tftp folder)] " + "[pc_host_name]\n\t[Jungfrau][Eiger][Ctb][Moench][Mythen3][" + "Gotthard2] Copies detector server via tftp from pc. Ensure that " + "server is in the pc's tftp folder. Makes a symbolic link with a " + "shorter name (without vx.x.x). Then, detector reboots (except " + "Eiger).\n\t[Jungfrau][Ctb][Moench]Also changes respawn server " + "to the link, which is effective after a reboot." << '\n'; } else if (action == defs::GET_ACTION) { throw sls::RuntimeError("Cannot get"); @@ -2862,14 +2869,14 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) { std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "[server_name] [pc_host_name] " - "[fname.pof]\n\t[Jungfrau][Gotthard][CTB][Moench] Updates the " - "firmware, detector server and then reboots detector controller " - "blackfin. \n\t[Mythen3][Gotthard2] Will still have old server " - "starting up as the new server is not respawned \n\tsname is " - "name of detector server binary found on tftp folder of host pc " - "\n\thostname is name of pc to tftp from \n\tfname is " - "programming file name" + os << "[server_name (in tftp folder)] [pc_host_name] [fname.pof (incl " + "full path)]\n\t[Jungfrau][Gotthard][CTB][Moench] Updates the " + "firmware, detector server, creates the symbolic link and then " + "reboots detector controller. \n\t[Mythen3][Gotthard2] will " + "require a script to start up the shorter named server link at " + "start up. \n\tsname is name of detector server binary found on " + "tftp folder of host pc \n\thostname is name of pc to tftp from " + "\n\tfname is programming file name" << '\n'; } else if (action == defs::GET_ACTION) { throw sls::RuntimeError("Cannot get"); diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 61e90c6d6..30bad18b9 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -6,10 +6,10 @@ #define APILIB 0x211008 #define APIRECEIVER 0x211007 #define APIGUI 0x210819 -#define APICTB 0x211008 -#define APIGOTTHARD 0x211008 -#define APIGOTTHARD2 0x211008 -#define APIMYTHEN3 0x211008 -#define APIMOENCH 0x211008 -#define APIEIGER 0x211013 -#define APIJUNGFRAU 0x211018 +#define APICTB 0x211019 +#define APIGOTTHARD 0x211019 +#define APIGOTTHARD2 0x211019 +#define APIJUNGFRAU 0x211019 +#define APIMYTHEN3 0x211019 +#define APIMOENCH 0x211019 +#define APIEIGER 0x211019