From 08fda2b6620353e69f4b654f8bf4c3ea4be60b1e Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Thu, 1 Feb 2018 17:48:43 +0100 Subject: [PATCH] in between in terms of mythen3 server, done with setdac and set power --- .../commonFiles/sls_detector_defs.h | 8 +- .../mythen3DetectorServer/AD9257.h | 142 +- .../mythen3DetectorServer/Makefile | 31 +- .../mythen3DetectorServer/Makefile.virtual | 25 + .../mythen3DetectorServer/RegisterDefs.h | 101 + .../mythen3DetectorServer/ansi.h | 1 + .../mythen3DetectorServer/bf_init.sh | 1 - .../commonServerFunctions.h | 61 +- .../communication_funcs.c | 1 + .../communication_funcs.h | 1 + .../mythen3DetectorServer/err.txt | 602 -- .../mythen3DetectorServer/gitInfo.txt | 9 + .../mythen3DetectorServer/gitInfoMythen3.h | 6 + .../mythen3DetectorServer/gitInfoMythen3Tmp.h | 6 + .../mythen3FunctionList.c | 1201 ---- .../mythen3FunctionList.h | 249 - .../mythen3RegisterDefs.h | 551 -- .../mythen3Server_defs.h | 93 - .../mythen3Server_funcs.c | 4916 ----------------- .../mythen3Server_funcs.h | 94 - .../mythen3DetectorServer/programfpga.h | 179 +- .../slsDetectorFunctionList.c | 1304 +++++ .../slsDetectorFunctionList.h | 1 + .../mythen3DetectorServer/slsDetectorServer.c | 121 +- .../slsDetectorServer_defs.h | 167 + .../slsDetectorServer_funcs.c | 1 + .../slsDetectorServer_funcs.h | 1 + .../slsDetector_stopServer.c | 46 - .../mythen3DetectorServer/sls_detector_defs.h | 1 + .../sls_detector_funcs.h | 1 + .../mythen3DetectorServer/sls_receiver_defs.h | 1 + .../sls_receiver_funcs.h | 1 + .../mythen3DetectorServer/updateGitVersion.sh | 31 + .../slsDetectorServer/commonServerFunctions.h | 72 +- .../slsDetectorFunctionList.h | 46 +- .../slsDetectorServer_funcs.c | 780 ++- 36 files changed, 2324 insertions(+), 8528 deletions(-) mode change 100755 => 120000 slsDetectorSoftware/mythen3DetectorServer/AD9257.h create mode 100644 slsDetectorSoftware/mythen3DetectorServer/Makefile.virtual create mode 100644 slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h create mode 120000 slsDetectorSoftware/mythen3DetectorServer/ansi.h delete mode 100755 slsDetectorSoftware/mythen3DetectorServer/bf_init.sh mode change 100755 => 120000 slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h create mode 120000 slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c create mode 120000 slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h delete mode 100644 slsDetectorSoftware/mythen3DetectorServer/err.txt create mode 100644 slsDetectorSoftware/mythen3DetectorServer/gitInfo.txt create mode 100644 slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3.h create mode 100644 slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3Tmp.h delete mode 100644 slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.c delete mode 100644 slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.h delete mode 100644 slsDetectorSoftware/mythen3DetectorServer/mythen3RegisterDefs.h delete mode 100644 slsDetectorSoftware/mythen3DetectorServer/mythen3Server_defs.h delete mode 100755 slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.c delete mode 100755 slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.h mode change 100755 => 120000 slsDetectorSoftware/mythen3DetectorServer/programfpga.h create mode 100644 slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c create mode 120000 slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h mode change 100755 => 120000 slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c create mode 100644 slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h create mode 120000 slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c create mode 120000 slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h delete mode 100755 slsDetectorSoftware/mythen3DetectorServer/slsDetector_stopServer.c create mode 120000 slsDetectorSoftware/mythen3DetectorServer/sls_detector_defs.h create mode 120000 slsDetectorSoftware/mythen3DetectorServer/sls_detector_funcs.h create mode 120000 slsDetectorSoftware/mythen3DetectorServer/sls_receiver_defs.h create mode 120000 slsDetectorSoftware/mythen3DetectorServer/sls_receiver_funcs.h create mode 100755 slsDetectorSoftware/mythen3DetectorServer/updateGitVersion.sh diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h index b4709ccee..1d8d993bb 100755 --- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_defs.h @@ -373,13 +373,13 @@ enum dacIndex { TEMPERATURE_FPGA3, /**< temperature sensor (fpga3 (eiger:febr) */ M_vIpre, /**< mythen 3 >*/ M_vIbias, /**< mythen 3 >*/ - M_Vth2, /**< mythen 3 >*/ - M_Vth3, /**< mythen 3 >*/ - M_VPL, /**< mythen 3 >*/ M_vIinSh, /**< mythen 3 >*/ M_VdcSh, /**< mythen 3 >*/ - M_cas, /**< mythen 3 >*/ + M_Vth2, /**< mythen 3 >*/ + M_VPL, /**< mythen 3 >*/ + M_Vth3, /**< mythen 3 >*/ M_casSh, /**< mythen 3 >*/ + M_cas, /**< mythen 3 >*/ M_vIbiasSh, /**< mythen 3 >*/ M_vIcin, /**< mythen 3 >*/ M_vIpreOut, /**< mythen 3 >*/ diff --git a/slsDetectorSoftware/mythen3DetectorServer/AD9257.h b/slsDetectorSoftware/mythen3DetectorServer/AD9257.h deleted file mode 100755 index a716af64c..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/AD9257.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef AD9257_H -#define AD9257_H - -#include "ansi.h" - -#include "commonServerFunctions.h" -#include - -/* AD9257 ADC DEFINES */ -#define AD9257_ADC_NUMBITS (24) - -#define AD9257_DEV_IND_2_REG (0x04) -#define AD9257_CHAN_H_OFST (0) -#define AD9257_CHAN_H_MSK (0x00000001 << AD9257_CHAN_H_OFST) -#define AD9257_CHAN_G_OFST (1) -#define AD9257_CHAN_G_MSK (0x00000001 << AD9257_CHAN_G_OFST) -#define AD9257_CHAN_F_OFST (2) -#define AD9257_CHAN_F_MSK (0x00000001 << AD9257_CHAN_F_OFST) -#define AD9257_CHAN_E_OFST (3) -#define AD9257_CHAN_E_MSK (0x00000001 << AD9257_CHAN_E_OFST) - -#define AD9257_DEV_IND_1_REG (0x05) -#define AD9257_CHAN_D_OFST (0) -#define AD9257_CHAN_D_MSK (0x00000001 << AD9257_CHAN_D_OFST) -#define AD9257_CHAN_C_OFST (1) -#define AD9257_CHAN_C_MSK (0x00000001 << AD9257_CHAN_C_OFST) -#define AD9257_CHAN_B_OFST (2) -#define AD9257_CHAN_B_MSK (0x00000001 << AD9257_CHAN_B_OFST) -#define AD9257_CHAN_A_OFST (3) -#define AD9257_CHAN_A_MSK (0x00000001 << AD9257_CHAN_A_OFST) -#define AD9257_CLK_CH_DCO_OFST (4) -#define AD9257_CLK_CH_DCO_MSK (0x00000001 << AD9257_CLK_CH_DCO_OFST) -#define AD9257_CLK_CH_IFCO_OFST (5) -#define AD9257_CLK_CH_IFCO_MSK (0x00000001 << AD9257_CLK_CH_IFCO_OFST) - -#define AD9257_POWER_MODE_REG (0x08) -#define AD9257_POWER_INTERNAL_OFST (0) -#define AD9257_POWER_INTERNAL_MSK (0x00000003 << AD9257_POWER_INTERNAL_OFST) -#define AD9257_INT_RESET_VAL (0x3) -#define AD9257_INT_CHIP_RUN_VAL (0x0) -#define AD9257_POWER_EXTERNAL_OFST (5) -#define AD9257_POWER_EXTERNAL_MSK (0x00000001 << AD9257_POWER_EXTERNAL_OFST) -#define AD9257_EXT_FULL_POWER_VAL (0x0) -#define AD9257_EXT_STANDBY_VAL (0x1) - -#define AD9257_OUT_MODE_REG (0x14) -#define AD9257_OUT_FORMAT_OFST (0) -#define AD9257_OUT_FORMAT_MSK (0x00000001 << AD9257_OUT_FORMAT_OFST) -#define AD9257_OUT_BINARY_OFST_VAL (0) -#define AD9257_OUT_TWOS_COMPL_VAL (1) -#define AD9257_OUT_LVDS_OPT_OFST (6) -#define AD9257_OUT_LVDS_OPT_MSK (0x00000001 << AD9257_OUT_LVDS_OPT_OFST) -#define AD9257_OUT_LVDS_ANSI_VAL (0) -#define AD9257_OUT_LVDS_IEEE_VAL (1) - -#define AD9257_OUT_PHASE_REG (0x16) -#define AD9257_OUT_CLK_OFST (0) -#define AD9257_OUT_CLK_MSK (0x0000000F << AD9257_OUT_CLK_OFST) -#define AD9257_OUT_CLK_60_VAL (0x1) -#define AD9257_IN_CLK_OFST (4) -#define AD9257_IN_CLK_MSK (0x00000007 << AD9257_IN_CLK_OFST) -#define AD9257_IN_CLK_0_VAL (0x0) - -#define AD9257_VREF_REG (0x18) -#define AD9257_VREF_OFST (0) -#define AD9257_VREF_MSK (0x00000003 << AD9257_VREF_OFST) -#define AD9257_VREF_1_33_VAL (0x2) - -#define AD9257_TEST_MODE_REG (0x0D) -#define AD9257_OUT_TEST_OFST (0) -#define AD9257_OUT_TEST_MSK (0x0000000F << AD9257_OUT_TEST_OFST) -#define AD9257_NONE_VAL (0x0) -#define AD9257_MIXED_BIT_FREQ_VAL (0xC) -#define AD9257_TEST_RESET_SHORT_GEN (4) -#define AD9257_TEST_RESET_LONG_GEN (5) -#define AD9257_USER_IN_MODE_OFST (6) -#define AD9257_USER_IN_MODE_MSK (0x00000003 << AD9257_USER_IN_MODE_OFST) - - -void setAdc(int addr, int val) { - - u_int32_t codata; - codata = val + (addr << 8); - printf(" Setting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr); - serializeToSPI(ADC_SPI_REG, codata, ADC_SERIAL_CS_OUT_MSK, AD9257_ADC_NUMBITS, - ADC_SERIAL_CLK_OUT_MSK, ADC_SERIAL_DATA_OUT_MSK, ADC_SERIAL_DATA_OUT_OFST); -} - -void prepareADC(){ - printf("\n\nPreparing ADC ... \n"); - - //power mode reset - printf("power mode reset:\n"); - setAdc(AD9257_POWER_MODE_REG, - (AD9257_INT_RESET_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK); - - //power mode chip run - printf("power mode chip run:\n"); - setAdc(AD9257_POWER_MODE_REG, - (AD9257_INT_CHIP_RUN_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK); - - //output clock phase - printf("output clock phase:\n"); - setAdc(AD9257_OUT_PHASE_REG, - (AD9257_OUT_CLK_60_VAL << AD9257_OUT_CLK_OFST) & AD9257_OUT_CLK_MSK); - - // lvds-iee reduced , binary offset - printf("lvds-iee reduced, binary offset:\n"); - setAdc(AD9257_OUT_MODE_REG, - (AD9257_OUT_LVDS_IEEE_VAL << AD9257_OUT_LVDS_OPT_OFST) & AD9257_OUT_LVDS_OPT_MSK); - - // all devices on chip to receive next command - printf("all devices on chip to receive next command:\n"); - setAdc(AD9257_DEV_IND_2_REG, - AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK); - setAdc(AD9257_DEV_IND_1_REG, - AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK | - AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK); - - // vref 1.33 - printf("vref 1.33:\n"); - setAdc(AD9257_VREF_REG, - (AD9257_VREF_1_33_VAL << AD9257_VREF_OFST) & AD9257_VREF_MSK); - - // no test mode - printf("no test mode:\n"); - setAdc(AD9257_TEST_MODE_REG, - (AD9257_NONE_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK); - -#ifdef TESTADC - printf("***************************************** *******\n"); - printf("******* PUTTING ADC IN TEST MODE!!!!!!!!! *******\n"); - printf("***************************************** *******\n"); - // mixed bit frequency test mode - printf("mixed bit frequency test mode:\n"); - setAdc(AD9257_TEST_MODE_REG, - (AD9257_MIXED_BIT_FREQ_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK); -#endif -} - -#endif //AD9257_H diff --git a/slsDetectorSoftware/mythen3DetectorServer/AD9257.h b/slsDetectorSoftware/mythen3DetectorServer/AD9257.h new file mode 120000 index 000000000..87b70e097 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/AD9257.h @@ -0,0 +1 @@ +../slsDetectorServer/AD9257.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/Makefile b/slsDetectorSoftware/mythen3DetectorServer/Makefile index 9810c82c0..ba8ffe5f1 100644 --- a/slsDetectorSoftware/mythen3DetectorServer/Makefile +++ b/slsDetectorSoftware/mythen3DetectorServer/Makefile @@ -1,28 +1,33 @@ CROSS = bfin-uclinux- CC = $(CROSS)gcc #CC = gcc -CLAGS += -Wall -DVIRTUAL -DDACS_INT -DMYTHEN3D -DVERBOSE -DSLS_DETECTOR_FUNCTION_LIST #-DGENERICD -LDLIBS += -lm -INCS = -I. -I../../slsReceiverSoftware/include/ -I../commonFiles -PROGS = mythen3Server -#DESTDIR ?= bin +CLAGS += -Wall -DMYTHEN3D -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE +LDLIBS += -lm -lstdc++ + + +PROGS = mythen3DetectorServer +DESTDIR ?= bin INSTMODE = 0777 -SRC_CLNT = slsDetectorServer.c mythen3Server_funcs.c ../commonFiles/communication_funcs.c mythen3FunctionList.c +SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c OBJS = $(SRC_CLNT:.c=.o) -all: clean $(PROGS) +all: clean versioning $(PROGS) boot: $(OBJS) -$(PROGS): - echo $(OBJS) -# mkdir -p $(DESTDIR) - $(CC) $(SRC_CLNT) $(CLAGS) $(LDLIBS) $(INCS) -o $@ -# mv $(PROGS) $(DESTDIR) +versioning: + @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;` +$(PROGS): $(OBJS) +# echo $(OBJS) + mkdir -p $(DESTDIR) + $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) + mv $(PROGS) $(DESTDIR) + rm *.gdb clean: - rm -rf $(PROGS) *.o + rm -rf $(DESTDIR)/$(PROGS) *.o + diff --git a/slsDetectorSoftware/mythen3DetectorServer/Makefile.virtual b/slsDetectorSoftware/mythen3DetectorServer/Makefile.virtual new file mode 100644 index 000000000..de7284bcc --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/Makefile.virtual @@ -0,0 +1,25 @@ +CC = gcc +CFLAGS += -Wall -DVIRTUAL -DMYTHEN3D -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE +LDLIBS += -lm -lstdc++ + +PROGS = virtualMythen3DetectorServer +DESTDIR ?= bin +INSTMODE = 0777 + +SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c +OBJS = $(SRC_CLNT:.c=.o) + +all: clean $(PROGS) + +boot: $(OBJS) + +$(PROGS): $(OBJS) + echo $(OBJS) + mkdir -p $(DESTDIR) + $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) + mv $(PROGS) $(DESTDIR) + rm *.gdb + +clean: + rm -rf $(DESTDIR)/$(PROGS) *.o + diff --git a/slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h b/slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h new file mode 100644 index 000000000..1fa922d3b --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h @@ -0,0 +1,101 @@ +#ifndef REGISTERS_G_H +#define REGISTERS_G_H + +/* Definitions for FPGA*/ + +/* FPGA Version register */ +#define FPGA_VERSION_REG (0x00 << 11) + +#define BOARD_REVISION_OFST (0) +#define BOARD_REVISION_MSK (0x00FFFFFF << BOARD_REVISION_OFST) +#define DETECTOR_TYPE_OFST (24) +#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST) + +/* Fix pattern register */ +#define FIX_PATT_REG (0x01 << 11) + + +/* Timer 64 bit Regiser */ +#define SET_DELAY_LSB_REG (0x60 << 11) //96<<11 //0x68<<11 +#define SET_DELAY_MSB_REG (0x61 << 11) //97<<11 //0x69<<11 +#define SET_CYCLES_LSB_REG (0x62 << 11) //98<<11//0x6c<<11 +#define SET_CYCLES_MSB_REG (0x63 << 11) //99<<11//0x6d<<11 +#define SET_FRAMES_LSB_REG (0x64 << 11) //(100<<11)/** to hex */ +#define SET_FRAMES_MSB_REG (0x65 << 11) //101<<11//0x71<<11 +#define SET_PERIOD_LSB_REG (0x66 << 11) //102<<11//0x74<<11 +#define SET_PERIOD_MSB_REG (0x67 << 11) //103<<11//0x75<<11 +#define SET_GATES_LSB_REG (0x6A << 11) /*check in firmware*///106<<11//0x7c<<11 +#define SET_GATES_MSB_REG (0x6B << 11) //107<<11//0x7d<<11 +#define SET_EXPTIME_LSB_REG (0x72 << 11) /** check in firmware *///114<<11//0x78<<11 +#define SET_EXPTIME_MSB_REG (0x73 << 11) //115<<11//0x79<<11 + +#define GET_ACTUAL_TIME_LSB_REG (0x10 << 11) //16<<11 +#define GET_ACTUAL_TIME_MSB_REG (0x11 << 11) //17<<11 +#define GET_DELAY_LSB_REG (0x12 << 11) //18<<11//0x6a<<11 +#define GET_DELAY_MSB_REG (0x13 << 11) //19<<11//0x6b<<11 +#define GET_CYCLES_LSB_REG (0x14 << 11) //20<<11//0x6e<<11 +#define GET_CYCLES_MSB_REG (0x15 << 11) //21<<11//0x6f<<11 +#define GET_FRAMES_LSB_REG (0x16 << 11) //22<<11//0x72<<11 +#define GET_FRAMES_MSB_REG (0x17 << 11) //23<<11//0x73<<11 +#define GET_PERIOD_LSB_REG (0x18 << 11) //24<<11//0x76<<11 +#define GET_PERIOD_MSB_REG (0x19 << 11) //25<<11//0x77<<11 +#define GET_EXPTIME_LSB_REG (0x1A << 11) //26<<11//0x7a<<11 +#define GET_EXPTIME_MSB_REG (0x1B << 11) //27<<11//0x7b<<11 +#define GET_GATES_LSB_REG (0x1C << 11) //28<<11//0x7e<<11 +#define GET_GATES_MSB_REG (0x1D << 11) //29<<11//0x7f<<11 + +#define FRAMES_FROM_START_LSB_REG (0x22 << 11) //34<<11 +#define FRAMES_FROM_START_MSB_REG (0x23 << 11) //35<<11 +#define FRAMES_FROM_START_PG_LSB_REG (0x24 << 11) //36<<11 +#define FRAMES_FROM_START_PG_MSB_REG (0x25 << 11) //37<<11 +#define GET_MEASUREMENT_TIME_LSB_REG (0x26 << 11) //38<<11 +#define GET_MEASUREMENT_TIME_MSB_REG (0x27 << 11) //39<<11 + + +/* SPI (Serial Peripheral Interface) Register */ +#define SPI_REG (0x40 << 11) + +#define DAC_SERIAL_DIGITAL_OUT_OFST (0) +#define DAC_SERIAL_DIGITAL_OUT_MSK (0x00000001 << DAC_SERIAL_DIGITAL_OUT_OFST) +#define DAC_SERIAL_CLK_OUT_OFST (1) +#define DAC_SERIAL_CLK_OUT_MSK (0x00000001 << DAC_SERIAL_CLK_OUT_OFST) +#define DAC_SERIAL_CS_OUT_OFST (2) +#define DAC_SERIAL_CS_OUT_MSK (0x00000001 << DAC_SERIAL_CS_OUT_OFST) +#define HV_SERIAL_DIGITAL_OUT_OFST (8) +#define HV_SERIAL_DIGITAL_OUT_MSK (0x00000001 << HV_SERIAL_DIGITAL_OUT_OFST) +#define HV_SERIAL_CLK_OUT_OFST (9) +#define HV_SERIAL_CLK_OUT_MSK (0x00000001 << HV_SERIAL_CLK_OUT_OFST) +#define HV_SERIAL_CS_OUT_OFST (10) +#define HV_SERIAL_CS_OUT_MSK (0x00000001 << HV_SERIAL_CS_OUT_OFST) + +/* Control Register */ +#define CONTROL_REG (0x4F << 11) //(79 << 11) /** to hex */ + + +/* Reconfiguratble PLL Control Regiser */ +#define PLL_CONTROL_REG (0x51 << 11) //(81 << 11)/** to hex */ + +//#define PLL_CTRL_RECONFIG_RST_OFST (0) //parameter reset +//#define PLL_CTRL_RECONFIG_RST_MSK (0x00000001 << PLL_CTRL_RECONFIG_RST_OFST) //parameter reset +//#define PLL_CTRL_WR_PARAMETER_OFST (2) +//#define PLL_CTRL_WR_PARAMETER_MSK (0x00000001 << PLL_CTRL_WR_PARAMETER_OFST) +#define PLL_CTRL_RST_OFST (3) +#define PLL_CTRL_RST_MSK (0x00000001 << PLL_CTRL_RST_OFST) +//#define PLL_CTRL_ADDR_OFST (16) +//#define PLL_CTRL_ADDR_MSK (0x0000003F << PLL_CTRL_ADDR_OFST) + +/* Samples Register */ +#define NSAMPLES_REG (0x5D << 11) //93<<11 + +/* Power On Register */ +#define POWER_ON_REG (0x5e<<11) + +#define POWER_ENABLE_OFST (16) + +/* Dac Registers */ +#define DAC_VAL_REG (0x79 << 11) //121<<11 +#define DAC_NUM_REG (0x80 << 11) //122<<11 +#define DAC_VAL_OUT_REG (0x2A << 11) //42<<11 + +#endif + diff --git a/slsDetectorSoftware/mythen3DetectorServer/ansi.h b/slsDetectorSoftware/mythen3DetectorServer/ansi.h new file mode 120000 index 000000000..a122db0ad --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/ansi.h @@ -0,0 +1 @@ +../../slsReceiverSoftware/include/ansi.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/bf_init.sh b/slsDetectorSoftware/mythen3DetectorServer/bf_init.sh deleted file mode 100755 index 88eccadb4..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/bf_init.sh +++ /dev/null @@ -1 +0,0 @@ -export PATH=/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin:$PATH diff --git a/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h b/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h deleted file mode 100755 index 4122fb7cf..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef COMMON_SERVER_FUNCTIONS_H -#define COMMON_SERVER_FUNCTIONS_H - -#ifndef GOTTHARDD //gotthard already had bus_w etc defined in its firmware_funcs.c (not yet made with common files) -#include "blackfin.h" -#endif - -/* global variables */ -void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) { -#ifdef VERBOSE - if (numbitstosend == 16) - printf("Writing to SPI Register: 0x%04x\n",val); - else - printf("Writing to SPI Register: 0x%08x\n", val); -#endif - - u_int32_t valw; - - // start point - valw = 0xffffffff; // old board compatibility (not using specific bits) - bus_w (addr, valw); - - // chip sel bar down - valw &= ~csmask; /* todo with test: done a bit different, not with previous value */ - bus_w (addr, valw); - - { - int i = 0; - for (i = 0; i < numbitstosend; ++i) { - - // clk down - valw &= ~clkmask; - bus_w (addr, valw); - - // write data (i) - valw = ((valw & ~digoutmask) + // unset bit - (((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb - bus_w (addr, valw); - - // clk up - valw |= clkmask ; - bus_w (addr, valw); - } - } - - // chip sel bar up - valw |= csmask; /* todo with test: not done for spi */ - bus_w (addr, valw); - - //clk down - valw &= ~clkmask; - bus_w (addr, valw); - - // stop point = start point of course - valw = 0xffffffff; // old board compatibility (not using specific bits) - bus_w (addr, valw); -} - - -#endif //COMMON_SERVER_FUNCTIONS_H diff --git a/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h b/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h new file mode 120000 index 000000000..33bdd8d53 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h @@ -0,0 +1 @@ +../slsDetectorServer/commonServerFunctions.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c new file mode 120000 index 000000000..87a4f95d1 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c @@ -0,0 +1 @@ +../commonFiles/communication_funcs.c \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h new file mode 120000 index 000000000..f220903b2 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h @@ -0,0 +1 @@ +../commonFiles/communication_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/err.txt b/slsDetectorSoftware/mythen3DetectorServer/err.txt deleted file mode 100644 index 530f6676f..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/err.txt +++ /dev/null @@ -1,602 +0,0 @@ -rm -rf mythen3Server *.o -echo slsDetectorServer.o mythen3Server_funcs.o communication_funcs.o mythen3FunctionList.o -slsDetectorServer.o mythen3Server_funcs.o communication_funcs.o mythen3FunctionList.o -bfin-uclinux-gcc slsDetectorServer.c mythen3Server_funcs.c communication_funcs.c mythen3FunctionList.c -Wall -DVIRTUAL -DDACS_INT -DMYTHEN3D -DVERBOSE -DSLS_DETECTOR_FUNCTION_LIST -lm -I. -I../../slsReceiverSoftware/include/ -o mythen3Server -In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:27, - from communication_funcs.h:7, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/uio.h: In function ‘setDAC’: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/uio.h:40: error: storage class specified for parameter ‘readv’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/uio.h:50: error: storage class specified for parameter ‘writev’ -In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:35, - from communication_funcs.h:7, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:36: error: storage class specified for parameter ‘socklen_t’ -In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:142, - from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:35, - from communication_funcs.h:7, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/sockaddr.h:29: error: storage class specified for parameter ‘sa_family_t’ -In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:35, - from communication_funcs.h:7, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:147: error: expected specifier-qualifier-list before ‘sa_family_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:164: error: expected specifier-qualifier-list before ‘sa_family_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:223: error: expected specifier-qualifier-list before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:271: error: storage class specified for parameter ‘__cmsg_nxthdr’ -In file included from communication_funcs.h:7, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:100: error: storage class specified for parameter ‘socket’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:107: error: storage class specified for parameter ‘socketpair’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:110: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:111: error: storage class specified for parameter ‘bind’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:115: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:115: error: storage class specified for parameter ‘getsockname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:124: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:124: error: storage class specified for parameter ‘connect’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:129: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:129: error: storage class specified for parameter ‘getpeername’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:136: error: storage class specified for parameter ‘send’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:143: error: storage class specified for parameter ‘recv’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:152: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:152: error: storage class specified for parameter ‘sendto’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:163: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:163: error: storage class specified for parameter ‘recvfrom’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:172: error: storage class specified for parameter ‘sendmsg’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:179: error: storage class specified for parameter ‘recvmsg’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:187: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:187: error: storage class specified for parameter ‘getsockopt’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:193: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:193: error: storage class specified for parameter ‘setsockopt’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:199: error: storage class specified for parameter ‘listen’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:210: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:210: error: storage class specified for parameter ‘accept’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:218: error: storage class specified for parameter ‘shutdown’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:231: error: storage class specified for parameter ‘isfdtype’ -In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:23, - from communication_funcs.h:10, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:93: error: storage class specified for parameter ‘in_port_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:137: error: storage class specified for parameter ‘in_addr_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:140: error: expected specifier-qualifier-list before ‘in_addr_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:207: error: storage class specified for parameter ‘in6addr_any’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:208: error: storage class specified for parameter ‘in6addr_loopback’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:223: error: expected specifier-qualifier-list before ‘sa_family_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:238: error: expected specifier-qualifier-list before ‘sa_family_t’ -In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:23, - from communication_funcs.h:10, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:357: error: storage class specified for parameter ‘ntohl’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:359: error: storage class specified for parameter ‘ntohs’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:361: error: storage class specified for parameter ‘htonl’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:363: error: storage class specified for parameter ‘htons’ -In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:23, - from communication_funcs.h:10, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:431: error: storage class specified for parameter ‘bindresvport’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:435: error: storage class specified for parameter ‘bindresvport6’ -In file included from communication_funcs.h:10, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inet_addr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inet_lnaof’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:42: error: expected ‘)’ before ‘__net’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inet_netof’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:50: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inet_network’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:54: error: storage class specified for parameter ‘inet_ntoa’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:56: error: storage class specified for parameter ‘inet_ntoa_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:62: error: storage class specified for parameter ‘inet_pton’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:68: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:69: error: storage class specified for parameter ‘inet_ntop’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:76: error: storage class specified for parameter ‘inet_aton’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:80: error: expected ‘)’ before ‘__net’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:86: error: storage class specified for parameter ‘inet_net_ntop’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:92: error: storage class specified for parameter ‘inet_net_pton’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:98: error: storage class specified for parameter ‘inet_nsap_addr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:103: error: storage class specified for parameter ‘inet_nsap_ntoa’ -In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:33, - from communication_funcs.h:11, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:53: error: storage class specified for parameter ‘setrpcent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:54: error: storage class specified for parameter ‘endrpcent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:55: error: storage class specified for parameter ‘getrpcbyname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:56: error: storage class specified for parameter ‘getrpcbynumber’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:57: error: storage class specified for parameter ‘getrpcent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:62: error: storage class specified for parameter ‘getrpcbyname_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:66: error: storage class specified for parameter ‘getrpcbynumber_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:69: error: storage class specified for parameter ‘getrpcent_r’ -In file included from communication_funcs.h:11, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:60: error: storage class specified for parameter ‘h_errno’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:66: error: storage class specified for parameter ‘__h_errno_location’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:93: error: storage class specified for parameter ‘herror’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:96: error: storage class specified for parameter ‘hstrerror’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:116: error: storage class specified for parameter ‘sethostent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:122: error: storage class specified for parameter ‘endhostent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:129: error: storage class specified for parameter ‘gethostent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:137: error: storage class specified for parameter ‘gethostbyaddr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:143: error: storage class specified for parameter ‘gethostbyname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:154: error: storage class specified for parameter ‘gethostbyname2’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:169: error: storage class specified for parameter ‘gethostent_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:176: error: storage class specified for parameter ‘gethostbyaddr_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:182: error: storage class specified for parameter ‘gethostbyname_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:188: error: storage class specified for parameter ‘gethostbyname2_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:197: error: storage class specified for parameter ‘setnetent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:203: error: storage class specified for parameter ‘endnetent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:210: error: storage class specified for parameter ‘getnetent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:217: error: storage class specified for parameter ‘getnetbyaddr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:223: error: storage class specified for parameter ‘getnetbyname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:272: error: storage class specified for parameter ‘setservent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:278: error: storage class specified for parameter ‘endservent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:285: error: storage class specified for parameter ‘getservent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:293: error: storage class specified for parameter ‘getservbyname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:300: error: storage class specified for parameter ‘getservbyport’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:313: error: storage class specified for parameter ‘getservent_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:319: error: storage class specified for parameter ‘getservbyname_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:324: error: storage class specified for parameter ‘getservbyport_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:341: error: storage class specified for parameter ‘setprotoent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:347: error: storage class specified for parameter ‘endprotoent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:354: error: storage class specified for parameter ‘getprotoent’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:360: error: storage class specified for parameter ‘getprotobyname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:366: error: storage class specified for parameter ‘getprotobynumber’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:379: error: storage class specified for parameter ‘getprotoent_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:384: error: storage class specified for parameter ‘getprotobyname_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:389: error: storage class specified for parameter ‘getprotobynumber_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:446: error: storage class specified for parameter ‘ruserpass’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:464: error: storage class specified for parameter ‘rcmd’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:495: error: storage class specified for parameter ‘rexec’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:508: error: expected declaration specifiers or ‘...’ before ‘sa_family_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:508: error: storage class specified for parameter ‘rexec_af’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:519: error: storage class specified for parameter ‘ruserok’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:543: error: storage class specified for parameter ‘rresvport’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:568: error: expected specifier-qualifier-list before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:640: error: storage class specified for parameter ‘getaddrinfo’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:643: error: storage class specified for parameter ‘freeaddrinfo’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:646: error: storage class specified for parameter ‘gai_strerror’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:653: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:654: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:655: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:655: error: storage class specified for parameter ‘getnameinfo’ -In file included from communication_funcs.h:13, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:256: error: storage class specified for parameter ‘access’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:299: error: storage class specified for parameter ‘lseek’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:318: error: storage class specified for parameter ‘close’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:325: error: storage class specified for parameter ‘read’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:331: error: storage class specified for parameter ‘write’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:382: error: storage class specified for parameter ‘pipe’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:391: error: storage class specified for parameter ‘alarm’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:403: error: storage class specified for parameter ‘sleep’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:411: error: storage class specified for parameter ‘ualarm’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:418: error: storage class specified for parameter ‘usleep’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:427: error: storage class specified for parameter ‘pause’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:432: error: storage class specified for parameter ‘chown’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:436: error: storage class specified for parameter ‘fchown’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:442: error: storage class specified for parameter ‘lchown’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:455: error: storage class specified for parameter ‘chdir’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:459: error: storage class specified for parameter ‘fchdir’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:469: error: storage class specified for parameter ‘getcwd’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:488: error: storage class specified for parameter ‘dup’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:491: error: storage class specified for parameter ‘dup2’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:494: error: storage class specified for parameter ‘__environ’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:503: error: storage class specified for parameter ‘execve’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:515: error: storage class specified for parameter ‘execv’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:520: error: storage class specified for parameter ‘execle’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:525: error: storage class specified for parameter ‘execl’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:530: error: storage class specified for parameter ‘execvp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:536: error: storage class specified for parameter ‘execlp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:541: error: storage class specified for parameter ‘nice’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:546: error: storage class specified for parameter ‘_exit’ -In file included from communication_funcs.h:13, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:556: error: storage class specified for parameter ‘pathconf’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:559: error: storage class specified for parameter ‘fpathconf’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:562: error: storage class specified for parameter ‘sysconf’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:566: error: storage class specified for parameter ‘confstr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:571: error: storage class specified for parameter ‘getpid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:574: error: storage class specified for parameter ‘getppid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:579: error: storage class specified for parameter ‘getpgrp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:589: error: storage class specified for parameter ‘__getpgid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:598: error: storage class specified for parameter ‘setpgid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:615: error: storage class specified for parameter ‘setpgrp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:632: error: storage class specified for parameter ‘setsid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:640: error: storage class specified for parameter ‘getuid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:643: error: storage class specified for parameter ‘geteuid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:646: error: storage class specified for parameter ‘getgid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:649: error: storage class specified for parameter ‘getegid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:654: error: storage class specified for parameter ‘getgroups’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:665: error: storage class specified for parameter ‘setuid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:670: error: storage class specified for parameter ‘setreuid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:675: error: storage class specified for parameter ‘seteuid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:682: error: storage class specified for parameter ‘setgid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:687: error: storage class specified for parameter ‘setregid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:692: error: storage class specified for parameter ‘setegid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:732: error: storage class specified for parameter ‘vfork’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:738: error: storage class specified for parameter ‘ttyname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:743: error: storage class specified for parameter ‘ttyname_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:747: error: storage class specified for parameter ‘isatty’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:759: error: storage class specified for parameter ‘link’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:772: error: storage class specified for parameter ‘symlink’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:779: error: storage class specified for parameter ‘readlink’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:794: error: storage class specified for parameter ‘unlink’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:803: error: storage class specified for parameter ‘rmdir’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:807: error: storage class specified for parameter ‘tcgetpgrp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:810: error: storage class specified for parameter ‘tcsetpgrp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:817: error: storage class specified for parameter ‘getlogin’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:825: error: storage class specified for parameter ‘getlogin_r’ -In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:840, - from communication_funcs.h:13, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:61: error: storage class specified for parameter ‘optarg’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:75: error: storage class specified for parameter ‘optind’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:80: error: storage class specified for parameter ‘opterr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:84: error: storage class specified for parameter ‘optopt’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:155: error: storage class specified for parameter ‘getopt’ -In file included from communication_funcs.h:13, - from mythen3Server_funcs.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:848: error: storage class specified for parameter ‘gethostname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:856: error: storage class specified for parameter ‘sethostname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:860: error: storage class specified for parameter ‘sethostid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:867: error: storage class specified for parameter ‘getdomainname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:869: error: storage class specified for parameter ‘setdomainname’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:875: error: storage class specified for parameter ‘vhangup’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:896: error: storage class specified for parameter ‘acct’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:900: error: storage class specified for parameter ‘getusershell’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:901: error: storage class specified for parameter ‘endusershell’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:902: error: storage class specified for parameter ‘setusershell’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:908: error: storage class specified for parameter ‘daemon’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:915: error: storage class specified for parameter ‘chroot’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:919: error: storage class specified for parameter ‘getpass’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:928: error: storage class specified for parameter ‘fsync’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:935: error: storage class specified for parameter ‘gethostid’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:938: error: storage class specified for parameter ‘sync’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:943: error: storage class specified for parameter ‘getpagesize’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:948: error: storage class specified for parameter ‘getdtablesize’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:954: error: storage class specified for parameter ‘truncate’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:975: error: storage class specified for parameter ‘ftruncate’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:995: error: storage class specified for parameter ‘brk’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:1001: error: storage class specified for parameter ‘sbrk’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:1016: error: storage class specified for parameter ‘syscall’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:1039: error: storage class specified for parameter ‘lockf’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:1071: error: storage class specified for parameter ‘fdatasync’ -In file included from communication_funcs.h:15, - from mythen3Server_funcs.c:5: -sls_detector_defs.h:594: error: expected declaration specifiers before ‘;’ token -In file included from mythen3Server_funcs.c:5: -communication_funcs.h:24: error: storage class specified for parameter ‘intType’ -communication_funcs.h:34: error: expected declaration specifiers or ‘...’ before ‘intType’ -communication_funcs.h:35: error: expected declaration specifiers or ‘...’ before ‘intType’ -communication_funcs.h:36: error: expected declaration specifiers or ‘...’ before ‘intType’ -In file included from mythen3RegisterDefs.h:5, - from mythen3Server_funcs.c:7: -sls_detector_defs.h:594: error: expected declaration specifiers before ‘;’ token -In file included from mythen3Server_funcs.c:7: -mythen3RegisterDefs.h:456: warning: empty declaration -In file included from blackfin.h:7, - from mythen3Server_funcs.c:8: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:74: error: storage class specified for parameter ‘fcntl’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:93: error: storage class specified for parameter ‘open’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:138: error: storage class specified for parameter ‘creat’ -In file included from blackfin.h:8, - from mythen3Server_funcs.c:8: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:59: error: storage class specified for parameter ‘mmap’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:77: error: storage class specified for parameter ‘munmap’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:82: error: storage class specified for parameter ‘mprotect’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:97: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:104: error: storage class specified for parameter ‘madvise’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:134: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:135: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:136: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:137: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:148: error: storage class specified for parameter ‘mincore’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:168: error: storage class specified for parameter ‘shm_open’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:171: error: storage class specified for parameter ‘shm_unlink’ -In file included from mythen3Server_funcs.c:8: -blackfin.h:12: error: parameter ‘CSP0BASE’ is initialized -blackfin.h:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:56: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:68: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:86: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:105: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:114: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:123: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -In file included from mythen3Server_funcs.c:11: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:40: error: storage class specified for parameter ‘memcpy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:44: error: storage class specified for parameter ‘memmove’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:53: error: storage class specified for parameter ‘memccpy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:59: error: storage class specified for parameter ‘memset’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:63: error: storage class specified for parameter ‘memcmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:67: error: storage class specified for parameter ‘memchr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:85: error: storage class specified for parameter ‘strcpy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:89: error: storage class specified for parameter ‘strncpy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:93: error: storage class specified for parameter ‘strcat’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:96: error: storage class specified for parameter ‘strncat’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:100: error: storage class specified for parameter ‘strcmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:103: error: storage class specified for parameter ‘strncmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:107: error: storage class specified for parameter ‘strcoll’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:111: error: storage class specified for parameter ‘strxfrm’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:131: error: storage class specified for parameter ‘strdup’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:168: error: storage class specified for parameter ‘strchr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:171: error: storage class specified for parameter ‘strrchr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:185: error: storage class specified for parameter ‘strcspn’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:189: error: storage class specified for parameter ‘strspn’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:192: error: storage class specified for parameter ‘strpbrk’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:195: error: storage class specified for parameter ‘strstr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:200: error: storage class specified for parameter ‘strtok’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:214: error: storage class specified for parameter ‘strtok_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:247: error: storage class specified for parameter ‘strlen’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:260: error: storage class specified for parameter ‘strerror’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:286: error: storage class specified for parameter ‘__glibc_strerror_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:288: error: storage class specified for parameter ‘strerror_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:307: error: storage class specified for parameter ‘bcopy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:310: error: storage class specified for parameter ‘bzero’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:314: error: storage class specified for parameter ‘bcmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:318: error: storage class specified for parameter ‘index’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:322: error: storage class specified for parameter ‘rindex’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:339: error: storage class specified for parameter ‘ffs’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:353: error: storage class specified for parameter ‘strcasecmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:357: error: storage class specified for parameter ‘strncasecmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:377: error: storage class specified for parameter ‘strsep’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:430: error: storage class specified for parameter ‘strlcat’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:432: error: storage class specified for parameter ‘strlcpy’ -mythen3Server_funcs.c:16: error: storage class specified for parameter ‘lockStatus’ -mythen3Server_funcs.c:17: error: storage class specified for parameter ‘lastClientIP’ -mythen3Server_funcs.c:18: error: storage class specified for parameter ‘thisClientIP’ -mythen3Server_funcs.c:19: error: storage class specified for parameter ‘differentClients’ -mythen3Server_funcs.c:40: error: parameter ‘myDetectorType’ is initialized -mythen3Server_funcs.c:45: error: parameter ‘dataBytes’ is initialized -mythen3Server_funcs.c:46: error: parameter ‘isControlServer’ is initialized -mythen3Server_funcs.c:47: error: parameter ‘debugflag’ is initialized -mythen3Server_funcs.c:49: error: parameter ‘N_DAC’ is initialized -mythen3Server_funcs.c:50: error: parameter ‘N_PWR’ is initialized -mythen3Server_funcs.c:52: error: parameter ‘vPowerLimit’ is initialized -mythen3Server_funcs.c:56: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:61: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:69: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:92: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:124: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:203: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:295: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:321: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:361: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:380: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:408: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:462: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:505: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:579: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:642: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:724: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:836: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:855: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:874: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:894: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1239: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1340: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1398: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1441: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1459: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1478: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1549: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1620: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1641: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1717: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1784: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:1805: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2020: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2135: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2155: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2221: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2278: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2349: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2386: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2425: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2475: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2502: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2532: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2577: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2595: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2686: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2766: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2865: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:2949: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3049: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3128: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3215: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3229: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3271: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3286: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3350: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3359: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3489: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3618: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3696: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3747: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3796: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3857: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3911: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:3971: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4031: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4102: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4121: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4179: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4238: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4290: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4344: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4397: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4471: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4515: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4604: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4747: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4792: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4858: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4918: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:4963: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3Server_funcs.c:5007: error: old-style parameter declarations in prototyped function definition -mythen3Server_funcs.c:5005: error: expected ‘{’ at end of input -communication_funcs.c: In function ‘receiveModuleGeneral’: -communication_funcs.c:540: warning: unused variable ‘id’ -In file included from blackfin.h:7, - from commonServerFunctions.h:5, - from AD9257.h:6, - from mythen3FunctionList.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h: In function ‘setDAC’: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:74: error: storage class specified for parameter ‘fcntl’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:93: error: storage class specified for parameter ‘open’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:138: error: storage class specified for parameter ‘creat’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:167: error: storage class specified for parameter ‘lockf’ -In file included from blackfin.h:8, - from commonServerFunctions.h:5, - from AD9257.h:6, - from mythen3FunctionList.c:5: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:59: error: storage class specified for parameter ‘mmap’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:77: error: storage class specified for parameter ‘munmap’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:82: error: storage class specified for parameter ‘mprotect’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:97: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:104: error: storage class specified for parameter ‘madvise’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:134: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:135: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:136: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:137: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:148: error: storage class specified for parameter ‘mincore’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:168: error: storage class specified for parameter ‘shm_open’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:171: error: storage class specified for parameter ‘shm_unlink’ -In file included from commonServerFunctions.h:5, - from AD9257.h:6, - from mythen3FunctionList.c:5: -blackfin.h:12: error: parameter ‘CSP0BASE’ is initialized -blackfin.h:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:56: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:68: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:86: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:105: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:114: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -blackfin.h:123: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -In file included from AD9257.h:6, - from mythen3FunctionList.c:5: -commonServerFunctions.h:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -In file included from mythen3FunctionList.c:5: -AD9257.h:80: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -AD9257.h:89: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -In file included from mythen3FunctionList.c:8: -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:40: error: storage class specified for parameter ‘memcpy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:44: error: storage class specified for parameter ‘memmove’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:53: error: storage class specified for parameter ‘memccpy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:59: error: storage class specified for parameter ‘memset’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:63: error: storage class specified for parameter ‘memcmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:67: error: storage class specified for parameter ‘memchr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:85: error: storage class specified for parameter ‘strcpy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:89: error: storage class specified for parameter ‘strncpy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:93: error: storage class specified for parameter ‘strcat’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:96: error: storage class specified for parameter ‘strncat’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:100: error: storage class specified for parameter ‘strcmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:103: error: storage class specified for parameter ‘strncmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:107: error: storage class specified for parameter ‘strcoll’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:111: error: storage class specified for parameter ‘strxfrm’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:131: error: storage class specified for parameter ‘strdup’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:168: error: storage class specified for parameter ‘strchr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:171: error: storage class specified for parameter ‘strrchr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:185: error: storage class specified for parameter ‘strcspn’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:189: error: storage class specified for parameter ‘strspn’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:192: error: storage class specified for parameter ‘strpbrk’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:195: error: storage class specified for parameter ‘strstr’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:200: error: storage class specified for parameter ‘strtok’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:214: error: storage class specified for parameter ‘strtok_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:247: error: storage class specified for parameter ‘strlen’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:260: error: storage class specified for parameter ‘strerror’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:286: error: storage class specified for parameter ‘__glibc_strerror_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:288: error: storage class specified for parameter ‘strerror_r’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:307: error: storage class specified for parameter ‘bcopy’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:310: error: storage class specified for parameter ‘bzero’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:314: error: storage class specified for parameter ‘bcmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:318: error: storage class specified for parameter ‘index’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:322: error: storage class specified for parameter ‘rindex’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:339: error: storage class specified for parameter ‘ffs’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:353: error: storage class specified for parameter ‘strcasecmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:357: error: storage class specified for parameter ‘strncasecmp’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:377: error: storage class specified for parameter ‘strsep’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:430: error: storage class specified for parameter ‘strlcat’ -/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:432: error: storage class specified for parameter ‘strlcpy’ -mythen3FunctionList.c:11: error: parameter ‘nChans’ is initialized -mythen3FunctionList.c:12: error: parameter ‘nChips’ is initialized -mythen3FunctionList.c:13: error: parameter ‘nDacs’ is initialized -mythen3FunctionList.c:14: error: parameter ‘nAdcs’ is initialized -mythen3FunctionList.c:15: error: parameter ‘allSelected’ is initialized -mythen3FunctionList.c:16: error: parameter ‘noneSelected’ is initialized -mythen3FunctionList.c:18: error: parameter ‘detectorModules’ is initialized -mythen3FunctionList.c:19: error: parameter ‘detectorChips’ is initialized -mythen3FunctionList.c:20: error: parameter ‘detectorChans’ is initialized -mythen3FunctionList.c:21: error: parameter ‘detectorDacs’ is initialized -mythen3FunctionList.c:22: error: parameter ‘detectorAdcs’ is initialized -mythen3FunctionList.c:24: error: parameter ‘nModY’ is initialized -mythen3FunctionList.c:25: error: parameter ‘nModX’ is initialized -mythen3FunctionList.c:26: error: parameter ‘dynamicRange’ is initialized -mythen3FunctionList.c:27: error: parameter ‘dataBytes’ is initialized -mythen3FunctionList.c:28: error: parameter ‘masterMode’ is initialized -mythen3FunctionList.c:29: error: parameter ‘syncMode’ is initialized -mythen3FunctionList.c:30: error: parameter ‘timingMode’ is initialized -mythen3FunctionList.c:37: error: storage class specified for parameter ‘dataBytes’ -mythen3FunctionList.c:37: error: redefinition of parameter ‘dataBytes’ -mythen3FunctionList.c:27: error: previous definition of ‘dataBytes’ was here -mythen3FunctionList.c:40: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:89: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:110: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:116: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:127: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:136: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:145: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:164: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:176: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:188: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:197: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:203: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:235: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:256: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:356: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:492: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:500: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:507: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:514: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:520: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:525: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:530: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:535: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:542: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:550: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:557: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:568: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:576: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:583: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:590: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:599: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:668: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:682: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:688: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:696: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:702: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:716: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:724: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:730: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:736: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:741: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:746: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:751: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:756: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:760: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:761: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:762: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:763: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:764: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:765: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:766: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:767: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:775: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:785: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:836: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:954: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:1086: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token -mythen3FunctionList.c:1197: error: old-style parameter declarations in prototyped function definition -mythen3FunctionList.c:1193: error: expected ‘{’ at end of input -make: *** [mythen3Server] Error 1 diff --git a/slsDetectorSoftware/mythen3DetectorServer/gitInfo.txt b/slsDetectorSoftware/mythen3DetectorServer/gitInfo.txt new file mode 100644 index 000000000..4df512cd8 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/gitInfo.txt @@ -0,0 +1,9 @@ +Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer +URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git +Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git +Repsitory UUID: 2f3dc8d109de8607f3217cf429619073dc9cc60e +Revision: 103 +Branch: developer +Last Changed Author: Dhanya_Maliakal +Last Changed Rev: 3397 +Last Changed Date: 2017-12-04 18:23:05.000000002 +0100 ./RegisterDefs.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3.h b/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3.h new file mode 100644 index 000000000..1acd1f071 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3.h @@ -0,0 +1,6 @@ +#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git" +#define GITREPUUID "2f3dc8d109de8607f3217cf429619073dc9cc60e" +#define GITAUTH "Dhanya_Maliakal" +#define GITREV 0x3397 +#define GITDATE 0x20171204 +#define GITBRANCH "developer" diff --git a/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3Tmp.h b/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3Tmp.h new file mode 100644 index 000000000..dfd9bb246 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3Tmp.h @@ -0,0 +1,6 @@ +#define GITURL "" +#define GITREPUUID "" +#define GITAUTH "" +#define GITREV "" +#define GITDATE "" +#define GITBRANCH "" diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.c b/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.c deleted file mode 100644 index 04623d1b9..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.c +++ /dev/null @@ -1,1201 +0,0 @@ -#ifdef SLS_DETECTOR_FUNCTION_LIST - -#include "mythen3FunctionList.h" -#include "mythen3RegisterDefs.h" -#include "mythen3Server_defs.h" -#include "blackfin.h" -// #include "AD9257.h" - -#include -#include - - -const int nChans=NCHAN; -const int nChips=NCHIP; -const int nDacs=NDAC; -const int nAdcs=NADC; -const int allSelected=-2; -const int noneSelected=-1; - -sls_detector_module *detectorModules=NULL; -int *detectorChips=NULL; -int *detectorChans=NULL; -dacs_t *detectorDacs=NULL; -dacs_t *detectorAdcs=NULL; - -int nModY = NMAXMOD; -int nModX = NMAXMOD; -int dynamicRange= DYNAMIC_RANGE; -// int dataBytes = NMAXMOD*NCHIP*NCHAN*2; -int masterMode = NO_MASTER; -int syncMode = NO_SYNCHRONIZATION; -int timingMode = AUTO_TIMING; - -int vLimit=-100; - -enum detectorSettings thisSettings; -int sChan, sChip, sMod, sDac, sAdc; -int nModBoard; -extern int dataBytes; -extern enum detectorType myDetectorType; -extern int N_DAC; - -int initializeDetectorStructure(){ - - int imod; - int n=getNModBoard(X)*getNModBoard(Y); -#ifdef VERBOSE - printf("Board is for %d modules\n",n); -#endif - detectorModules=malloc(n*sizeof(sls_detector_module)); - detectorChips=malloc(n*NCHIP*sizeof(int)); - detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int)); - detectorDacs=malloc(n*NDAC*sizeof(int)); - detectorAdcs=malloc(n*NADC*sizeof(int)); -#ifdef VERBOSE - printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n)); - printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP)); - printf("chans from 0x%x to 0x%x\n",(unsigned int)(detectorChans), (unsigned int)(detectorChans+n*NCHIP*NCHAN)); - printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC)); - printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC)); -#endif - for (imod=0; imoddacs=detectorDacs+imod*NDAC; - (detectorModules+imod)->adcs=detectorAdcs+imod*NADC; - (detectorModules+imod)->chipregs=detectorChips+imod*NCHIP; - (detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN; - (detectorModules+imod)->ndac=NDAC; - (detectorModules+imod)->nadc=NADC; - (detectorModules+imod)->nchip=NCHIP; - (detectorModules+imod)->nchan=NCHIP*NCHAN; - (detectorModules+imod)->module=imod; - (detectorModules+imod)->gain=0; - (detectorModules+imod)->offset=0; - (detectorModules+imod)->reg=0; - /* initialize registers, dacs, retrieve sn, adc values etc */ - } - thisSettings=UNINITIALIZED; - sChan=noneSelected; - sChip=noneSelected; - sMod=noneSelected; - sDac=noneSelected; - sAdc=noneSelected; - - return OK; -} - - - - - - -int setupDetector(){ - //testFpga(); - //testRAM(); - - //setSettings(GET_SETTINGS,-1); - //setFrames(1); - //setTrains(1); - //setExposureTime(1e6); - //setPeriod(1e9); - //setDelay(0); - //setGates(0); - - //setTiming(GET_EXTERNAL_COMMUNICATION_MODE); - //setMaster(GET_MASTER); - //setSynchronization(GET_SYNCHRONIZATION_MODE); - return OK; -} - - - - -int setNMod(int nm, enum dimension dim){ - return 1; -} - - - -int getNModBoard(enum dimension arg){ - return 1; -} - - - - - - - - -int64_t getModuleId(enum idMode arg, int imod){ - //DETECTOR_SERIAL_NUMBER - //DETECTOR_FIRMWARE_VERSION - return 0; -} - - - - -int64_t getDetectorId(enum idMode arg){ - //DETECTOR_SOFTWARE_VERSION defined in slsDetector_defs.h? - return 0; -} - - - - - -int moduleTest( enum digitalTestMode arg, int imod){ - //template testShiftIn from mcb_funcs.c - - //CHIP_TEST - //testShiftIn - //testShiftOut - //testShiftStSel - //testDataInOutMux - //testExtPulseMux - //testOutMux - //testFpgaMux - - return OK; -} - - - - - -int detectorTest( enum digitalTestMode arg){ - //templates from firmware_funcs.c - - //DETECTOR_FIRMWARE_TEST:testFpga() - //DETECTOR_MEMORY_TEST:testRAM() - //DETECTOR_BUS_TEST:testBus() - //DETECTOR_SOFTWARE_TEST:testFpga() - return OK; -} - -int getDacRegister(int dacnum) { - - bus_w(DAC_NUM_REG, dacnum); - printf("READ dac register value %d address %d\n",(int16_t)bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ; - return (int16_t)bus_r(DAC_VAL_REG); -} - -int setDacRegister(int dacnum,int dacvalue) { - - bus_w(DAC_NUM_REG, dacnum); - bus_w(DAC_VAL_REG, dacvalue); - bus_w(DAC_NUM_REG, dacnum | (1<<16)); - bus_w(DAC_NUM_REG, dacnum); - printf("Wrote dac register value %d address %d\n",bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ; - return getDacRegister(dacnum); -} - - - -int dacSPI(int codata) { - u_int32_t offw; - int valw, vv; - int i, ddx,cdx; - - ddx=0; cdx=1; - - offw=DAC_REG; - valw=bus_r(offw); - // codata=((cmd&0xf)<=0) { - cmd=0x3; - } - else if (dacvalue==-100) { - cmd=0x4; - } - codata=cmd< conversion done in slsDetectorServer_funcs.c-> set_dac() - - //if normal dac: - - int dacval = val; // in DAC - u_int32_t offw; - u_int32_t ichip; // DAC-chip (3 chips with each 8 DACs) - u_int16_t valw; - int i,ddx,csdx,cdx; // ddx=data, cdx=clk, csdx=chipselect - - //select dac-chip: - if (myDetectorType==JUNGFRAUCTB || myDetectorType==MYTHEN3){ - ichip=2-ind/8; - printf("This is a CTB (or mythen3)\n"); - } - else { - ichip=ind/8; - printf("This is not a CTB\n"); - } - - // if(val>0 && mV){ // convert to DACu, if val is given in mV - // dacval = val * 4095 / 2500; // convert to DAC - if (val == -1){ - return getDacRegister(ind); - } - else if(dacval<0 || dacval>4095){ - dacval = -1; - printf("The DAC is out of range! Error!\n"); - return getDacRegister(ind); - } - // } - - else if(dacval>=0 && dacval<=4095){ - printf("\nSetting of DAC %d to %d DACunits\n",ind,dacval); - ddx=0; // data is first bit in DAC_REG - cdx=1; // clk is 2nd bit in DAC_REG - if (myDetectorType==JUNGFRAUCTB || myDetectorType==MYTHEN3) - csdx=2; - else - csdx=ichip+2; - - //setting int reference - offw=DAC_REG; - valw=bus_r(offw)|0xff; // alles (ddx,cdx,csdx) auf 1 setzen (for START) - bus_w(offw,(valw)); // start point - //chip select down: - valw=((valw&(~(0x1<=0) { // v_a, v_b, v_c, v_d, v_io - printf("vpower\n"); - dacval=((vmax-val)*4095)/(vmax-vmin); - if (dacval<0) - dacval=0; - if (dacval>4095) - dacval=-100; - if (val==-100) - dacval=-100; - - - } else if (dacindex>=0) {// v_chip - printf("vchip\n"); - dacval=((2700-val)*4095)/1000; - if (dacval<0) - dacval=0; - if (dacval>4095) - dacval=4095; - - } else { // v_limit - vLimit=val; - printf("vlimit %d\n",vLimit ); - } - - } - - if (pwrindex>=0 && val!=-1) {// v_a, v_b, v_c, v_d, v_io - preg=bus_r(POWER_ON_REG); - printf("power reg is %08x\n",bus_r(POWER_ON_REG)); - printf("Switching off power %d\n", pwrindex); - bus_w(POWER_ON_REG,preg&(~(1<<(16+pwrindex)))); - setDAC(dacindex,-100,-1,1); - printf("power reg is %08x\n",bus_r(POWER_ON_REG)); - retval=0; - } - - if (dacindex>0 && dacval!=-100) {// v_a, v_b, v_c, v_d, v_io, v_chip - - printf("Setting power %d to %d mV\n",ind,val); - printf("Setting DAC %d to value %d\n",dacindex,dacval); - retval=setDAC(dacindex,dacval,-1,1);// in mV - if (pwrindex>=0 && dacval>=0 ) {// v_a, v_b, v_c, v_d, v_io - preg=bus_r(POWER_ON_REG); - printf("power reg is %08x\n",bus_r(POWER_ON_REG)); - printf("Switching on power %d\n", pwrindex); - bus_w(POWER_ON_REG,preg|((1<<(16+pwrindex)))); - printf("power reg is %08x\n",bus_r(POWER_ON_REG)); - } - } - - if (pwrindex>=0) {// v_a, v_b, v_c, v_d, v_io - if (bus_r(POWER_ON_REG)&(1<<(16+pwrindex))){ - vmax=2700-(getDacRegister(19)*1000)/4095-200; // 19=v_chip - printf("Vchip id %d mV\n",vmax+200); - // retval1=vmax-(retval*(vmax-vmin))/4095; - retval1=vmax-retval; // mV - printf("Vdac id %d mV\n",retval1); - if (retval1>vmax) - retval1=vmax; - if (retval1=0) { //v_chip - if (retval>=0) { - retval1=2700-(retval*1000)/4095; - printf("Vchip is %d mV\n",vmax); - } else - retval1=-1; - } else { - printf("Get vlimit %d\n",vLimit); - retval=vLimit; - retval1=vLimit; - } - - return retval1; -} - - - - - - - -int setChannel(sls_detector_channel myChan){ - //template initChannelByNumber() from mcb_funcs.c - - return myChan.reg; -} - - -int getChannel(sls_detector_channel *myChan){ - //template getChannelbyNumber() from mcb_funcs.c - return FAIL; -} - - - -int setChip(sls_detector_chip myChip){ - //template initChipbyNumber() from mcb_funcs.c - return myChip.reg; -} - - -int getChip(sls_detector_chip *myChip){ - //template getChipbyNumber() from mcb_funcs.c - return FAIL; -} - -int setModule(sls_detector_module myChan){ - //template initModulebyNumber() from mcb_funcs.c - return OK; -} - -int getModule(sls_detector_module *myChan){ - //template getModulebyNumber() from mcb_funcs.c - return FAIL; -} - -int getThresholdEnergy(int imod){ - //template getThresholdEnergy() from mcb_funcs.c - //depending on settings - return FAIL; -} - - -int setThresholdEnergy(int thr, int imod){ - //template getThresholdEnergy() from mcb_funcs.c - //depending on settings - return FAIL; -} - - - -enum detectorSettings setSettings(enum detectorSettings sett, int imod){ - //template setSettings() from mcb_funcs.c - //reads the dac registers from fpga to confirm which settings, if weird, undefined - - return OK; -} - -int startStateMachine(){ - //template startStateMachine() from firmware_funcs.c - /* - fifoReset(); - now_ptr=(char*)ram_values; - //send start acquisition to fpga - */ - return FAIL; -} - - -int stopStateMachine(){ - //template stopStateMachine() from firmware_funcs.c - // send stop to fpga - //if status = busy after 500us, return FAIL - return FAIL; -} - - -int startReadOut(){ - //template startReadOut() from firmware_funcs.c - //send fpga start readout - return FAIL; -} - - -enum runStatus getRunStatus(){ - //template runState() from firmware_funcs.c - //get status from fpga - return ERROR; -} - - -char *readFrame(int *ret, char *mess){ - //template fifo_read_event() from firmware_funcs.c - //checks if state machine running and if fifo has data(look_at_me_reg) and accordingly reads frame - // memcpy(now_ptr, values, dataBytes); - //returns ptr to values - return NULL; -} - - -int64_t setTimer(enum timerIndex ind, int64_t val){ - //template setDelay() from firmware_funcs.c - //writes to reg - //FRAME_NUMBER --> defined in sls_receiver_defs.h - //ACQUISITION_TIME - //FRAME_PERIOD -> how many frames per trigger - //DELAY_AFTER_TRIGGER - //GATES_NUMBER - //PROBES_NUMBER = # counters - //CYCLES_NUMBER -> how many triggers - - int64_t retval = -1; // return value to check - - switch(ind){ // only change the timer corresponding to ind - - case FRAME_NUMBER: - if(val >= 0) - printf("\nSetting #frames: %lld\n",(long long int)val); - retval = set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG); - printf("Getting #frames: %lld\n",(long long int)retval); - break; - - case ACQUISITION_TIME: // defined in sls_receiver_defs.h - if(val>=0){ - printf("\n Setting the exposure time: %lld ns \n",(long long int)val); - val *= (1E-3 * CLK_RUN); // convert from ns to clk-cycles - // CLK_RUN is defined in slsDetectorServer_defs.h - } - retval = set64BitReg(val,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG )/(1E-3 * CLK_RUN); // set the register to val and read back, convert back to ns - // SET_EXPTIME_LSB_REG are defined in RegisterDefs.h - printf("Getting the exposure time: %lld ns \n", (long long int)retval); - break; - - case FRAME_PERIOD: // how many frames per trigger - if(val >= 0){ - printf("\nSetting period to %lldns\n",(long long int)val); - val *= (1E-3 * CLK_SYNC); - } - retval = set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG )/ (1E-3 * CLK_SYNC); - // CLK_SYN is defined in slsDetectorServer_defs.h - printf("Getting period: %lldns\n", (long long int)retval); - break; - - case DELAY_AFTER_TRIGGER: - if(val >= 0){ - printf("\nSetting delay to %lldns\n", (long long int)val); - val *= (1E-3 * CLK_SYNC); - } - retval = set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC); - printf("Getting delay: %lldns\n", (long long int)retval); - break; - - // case PROBES_NUMBER: - - case CYCLES_NUMBER: // how many triggers - if(val >= 0) - printf("\nSetting #cycles to %lld\n", (long long int)val); - retval = set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG); - printf("Getting #cycles: %lld\n", (long long int)retval); - break; - - default: - cprintf(RED,"Warning: Timer Index not implemented for this detector: %d\n", ind); - break; - } - return retval; -} - - -int64_t getTimeLeft(enum timerIndex ind){ - //template getDelay() from firmware_funcs.c - //reads from reg - //FRAME_NUMBER - //ACQUISITION_TIME - //FRAME_PERIOD - //DELAY_AFTER_TRIGGER - //GATES_NUMBER - //PROBES_NUMBER - //CYCLES_NUMBER - return -1; -} - - -int setDynamicRange(int dr){ - //template setDynamicRange() from firmware_funcs.c - return 0; -} - - -enum readOutFlags setReadOutFlags(enum readOutFlags val){ - //template setStoreInRAM from firmware_funcs.c - return -1; -} - - - - -int setROI(int n, ROI arg[], int *retvalsize, int *ret){ - return FAIL; -} - - - -int setSpeed(enum speedVariable arg, int val){ - //template setClockDivider() from firmware_funcs.c - //CLOCK_DIVIDER - //WAIT_STATES - //SET_SIGNAL_LENGTH - //TOT_CLOCK_DIVIDER - //TOT_DUTY_CYCLE - - //returns eg getClockDivider from firmware_funcs.c - return 0; -} - - - -int executeTrimming(enum trimMode mode, int par1, int par2, int imod){ - // template trim_with_noise from trimming_funcs.c - return FAIL; -} - - - - -// int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb){ -// //detector specific. -// return FAIL; -// } - -int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival){ - return FAIL; -}; - - -int loadImage(enum imageType index, char *imageVals){ - //detector specific. - return FAIL; -} - - -int readCounterBlock(int startACQ, char *counterVals){ - //detector specific. - return FAIL; -} - -int resetCounterBlock(int startACQ){ - //detector specific. - return FAIL; -} - -int startReceiver(int d){ - - return 0; -} - -int calibratePedestal(int frames){ - - return 0; -} - -int calculateDataBytes(){ - return 0; -} - -int getTotalNumberOfChannels(){return 0;} -int getTotalNumberOfChips(){return 0;} -int getTotalNumberOfModules(){return 0;} -int getNumberOfChannelsPerChip(){return 0;} -int getNumberOfChannelsPerModule(){return 0;} -int getNumberOfChipsPerModule(){return 0;} -int getNumberOfDACsPerModule(){return 0;} -int getNumberOfADCsPerModule(){return 0;} - - - - - - - -enum externalSignalFlag getExtSignal(int signalindex){ - //template getExtSignal from firmware_funcs.c - //return signals[signalindex]; - return -1; -} - - - - - -enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag){ - //template setExtSignal from firmware_funcs.c - - //in short..sets signals array, checks if agrees with timing mode, writes to fpga reg, calls synchronization and then settiming - /* - if (signalindex>=0 && signalindex<4) { - signals[signalindex]=flag; -#ifdef VERBOSE - printf("settings signal variable number %d to value %04x\n", signalindex, signals[signalindex]); -#endif - // if output signal, set it! - switch (flag) { - case GATE_IN_ACTIVE_HIGH: - case GATE_IN_ACTIVE_LOW: - if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER)//timingMode = AUTO_TIMING by default and is set in setTiming() - setFPGASignal(signalindex,flag); //not implemented here, checks if flag within limits and writes to fpga reg - else - setFPGASignal(signalindex,SIGNAL_OFF); - break; - case TRIGGER_IN_RISING_EDGE: - case TRIGGER_IN_FALLING_EDGE: - if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER) - setFPGASignal(signalindex,flag); - else - setFPGASignal(signalindex,SIGNAL_OFF); - break; - case RO_TRIGGER_IN_RISING_EDGE: - case RO_TRIGGER_IN_FALLING_EDGE: - if (timingMode==BURST_TRIGGER) - setFPGASignal(signalindex,flag); - else - setFPGASignal(signalindex,SIGNAL_OFF); - break; - case MASTER_SLAVE_SYNCHRONIZATION: - setSynchronization(syncMode);//syncmode = NO_SYNCHRONIZATION by default and set with this function - break; - default: - setFPGASignal(signalindex,mode); - } - - setTiming(GET_EXTERNAL_COMMUNICATION_MODE); - } - */ - return getExtSignal(signalindex); -} - - - - - - -enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){ - //template setTiming from firmware_funcs.c - //template getFPGASignal from firmware_funcs.c - - - //getFPGASignal(signalindex) used later on in this fucntion - //gets flag from fpga reg, checks if flag within limits, - //if( flag=SIGNAL_OFF and signals[signalindex]==MASTER_SLAVE_SYNCHRONIZATION), return -1, (ensures masterslaveflag !=off now) - //else return flag - - int ret=GET_EXTERNAL_COMMUNICATION_MODE; - //sets timingmode variable - //ensures that the signals are in acceptance with timing mode and according sets the timing mode - /* - int g=-1, t=-1, rot=-1; - - int i; - - switch (ti) { - case AUTO_TIMING: - timingMode=ti; - // disable all gates/triggers in except if used for master/slave synchronization - for (i=0; i<4; i++) { - if (getFPGASignal(i)>0 && getFPGASignal(i)=0 && t>=0 && rot<0) { - ret=GATE_WITH_START_TRIGGER; - } else if (g<0 && t>=0 && rot<0) { - ret=TRIGGER_EXPOSURE; - } else if (g>=0 && t<0 && rot<0) { - ret=GATE_FIX_NUMBER; - } else if (g<0 && t<0 && rot>0) { - ret=TRIGGER_READOUT; - } else if (g<0 && t<0 && rot<0) { - ret=AUTO_TIMING; - } - - */ - return ret; -} - - - -enum masterFlags setMaster(enum masterFlags arg){ - //template setMaster from firmware_funcs.c - /* - int i; - switch(f) { - case NO_MASTER: - // switch of gates or triggers - masterMode=NO_MASTER; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - setFPGASignal(i,SIGNAL_OFF); - } - } - break; - case IS_MASTER: - // configure gate or trigger out - masterMode=IS_MASTER; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - switch (syncMode) { - case NO_SYNCHRONIZATION: - setFPGASignal(i,SIGNAL_OFF); - break; - case MASTER_GATES: - setFPGASignal(i,GATE_OUT_ACTIVE_HIGH); - break; - case MASTER_TRIGGERS: - setFPGASignal(i,TRIGGER_OUT_RISING_EDGE); - break; - case SLAVE_STARTS_WHEN_MASTER_STOPS: - setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE); - break; - default: - ; - } - } - } - break; - case IS_SLAVE: - // configure gate or trigger in - masterMode=IS_SLAVE; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - switch (syncMode) { - case NO_SYNCHRONIZATION: - setFPGASignal(i,SIGNAL_OFF); - break; - case MASTER_GATES: - setFPGASignal(i,GATE_IN_ACTIVE_HIGH); - break; - case MASTER_TRIGGERS: - setFPGASignal(i,TRIGGER_IN_RISING_EDGE); - break; - case SLAVE_STARTS_WHEN_MASTER_STOPS: - setFPGASignal(i,TRIGGER_IN_RISING_EDGE); - break; - default: - ; - } - } - } - break; - default: - //do nothing - ; - } - - switch(masterMode) { - case NO_MASTER: - return NO_MASTER; - - - case IS_MASTER: - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - switch (syncMode) { - case NO_SYNCHRONIZATION: - return IS_MASTER; - case MASTER_GATES: - if (getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH) - return IS_MASTER; - else - return NO_MASTER; - case MASTER_TRIGGERS: - if (getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE) - return IS_MASTER; - else - return NO_MASTER; - case SLAVE_STARTS_WHEN_MASTER_STOPS: - if (getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE) - return IS_MASTER; - else - return NO_MASTER; - default: - return NO_MASTER; - } - - } - } - - case IS_SLAVE: - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - switch (syncMode) { - case NO_SYNCHRONIZATION: - return IS_SLAVE; - case MASTER_GATES: - if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH) - return IS_SLAVE; - else - return NO_MASTER; - case MASTER_TRIGGERS: - case SLAVE_STARTS_WHEN_MASTER_STOPS: - if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE) - return IS_SLAVE; - else - return NO_MASTER; - default: - return NO_MASTER; - } - - } - } - - } - */ - - return NO_MASTER; -} - - - -enum synchronizationMode setSynchronization(enum synchronizationMode arg){ - /* - int i; - - switch(s) { - case NO_SYNCHRONIZATION: - syncMode=NO_SYNCHRONIZATION; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - setFPGASignal(i,SIGNAL_OFF); - } - } - break; - // disable external signals? - case MASTER_GATES: - // configure gate in or out - syncMode=MASTER_GATES; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER) - setFPGASignal(i,GATE_OUT_ACTIVE_HIGH); - else if (masterMode==IS_SLAVE) - setFPGASignal(i,GATE_IN_ACTIVE_HIGH); - } - } - - break; - case MASTER_TRIGGERS: - // configure trigger in or out - syncMode=MASTER_TRIGGERS; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER) - setFPGASignal(i,TRIGGER_OUT_RISING_EDGE); - else if (masterMode==IS_SLAVE) - setFPGASignal(i,TRIGGER_IN_RISING_EDGE); - } - } - break; - - - case SLAVE_STARTS_WHEN_MASTER_STOPS: - // configure trigger in or out - syncMode=SLAVE_STARTS_WHEN_MASTER_STOPS; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER) - setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE); - else if (masterMode==IS_SLAVE) - setFPGASignal(i,TRIGGER_IN_RISING_EDGE); - } - } - break; - - - default: - //do nothing - ; - } - - switch (syncMode) { - - case NO_SYNCHRONIZATION: - return NO_SYNCHRONIZATION; - - case MASTER_GATES: - - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER && getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH) - return MASTER_GATES; - else if (masterMode==IS_SLAVE && getFPGASignal(i)==GATE_IN_ACTIVE_HIGH) - return MASTER_GATES; - } - } - return NO_SYNCHRONIZATION; - - case MASTER_TRIGGERS: - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER && getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE) - return MASTER_TRIGGERS; - else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE) - return MASTER_TRIGGERS; - } - } - return NO_SYNCHRONIZATION; - - case SLAVE_STARTS_WHEN_MASTER_STOPS: - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER && getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE) - return SLAVE_STARTS_WHEN_MASTER_STOPS; - else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE) - return SLAVE_STARTS_WHEN_MASTER_STOPS; - } - } - return NO_SYNCHRONIZATION; - - default: - return NO_SYNCHRONIZATION; - - } - - - */ - return NO_SYNCHRONIZATION; -} - -void checkFirmwareCompatibility(int flag){ - -} - -#endif diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.h b/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.h deleted file mode 100644 index 39c6a06a2..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.h +++ /dev/null @@ -1,249 +0,0 @@ -#ifdef SLS_DETECTOR_FUNCTION_LIST -#ifndef SLS_DETECTOR_FUNCTION_LIST_H -#define SLS_DETECTOR_FUNCTION_LIST_H - -#include "sls_receiver_defs.h" -#include "mythen3Server_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h - -#include -#include // FILE - - -/**************************************************** -This functions are used by the slsDetectroServer_funcs interface. -Here are the definitions, but the actual implementation should be done for each single detector. - -****************************************************/ - - -// basic tests -void checkFirmwareCompatibility(int flag); -#ifdef JUNGFRAUD -int checkType(); -u_int32_t testFpga(void); -int testBus(void); -#endif - -#if defined(MYTHEND) || defined(JUNGFRAUD) || defined(MTHEN3D) -int moduleTest( enum digitalTestMode arg, int imod); -#endif -int detectorTest( enum digitalTestMode arg); - -// Ids -int64_t getDetectorId(enum idMode arg); -u_int64_t getFirmwareVersion(); -#ifdef MYTHEND -int64_t getModuleId(enum idMode arg, int imod); -#elif JUNGFRAUDN_DAC -u_int16_t getHardwareVersionNumber(); -u_int16_t getHardwareSerialNumber(); -#endif -u_int32_t getDetectorNumber(); -u_int64_t getDetectorMAC(); -u_int32_t getDetectorIP(); - - -// initialization -void initControlServer(); -void initStopServer(); -#ifdef EIGERD -void getModuleConfiguration(); -#endif - -// set up detector -void allocateDetectorStructureMemory(); -int setupDetector(); - - -// advanced read/write reg -#ifndef EIGERD -extern u_int32_t writeRegister(u_int32_t offset, u_int32_t data); // blackfin.h -extern u_int32_t readRegister(u_int32_t offset); // blackfin.h -#else -uint32_t writeRegister(uint32_t offset, uint32_t data); -uint32_t readRegister(uint32_t offset); -#endif - - -// firmware functions (resets) -#ifdef JUNGFRAUD -int powerChip (int on); -void cleanFifos(); -void resetCore(); -void resetPeripheral(); -int adcPhase(int st); -int getPhase(); -#endif - -// parameters - nmod, dr, roi -int setNMod(int nm, enum dimension dim); // mythen specific, but for detector compatibility as a get -int getNModBoard(enum dimension arg); // mythen specific, but for detector compatibility as a get -int setDynamicRange(int dr); -#ifdef GOTTHARD -int setROI(int n, ROI arg[], int *retvalsize, int *ret); -#endif - -// parameters - readout -int setSpeed(enum speedVariable arg, int val); -#if defined(EIGERD) || defined(MYTHEND) -enum readOutFlags setReadOutFlags(enum readOutFlags val); -#endif -#ifdef MYTHEND -int executeTrimming(enum trimMode mode, int par1, int par2, int imod); -#endif - -// parameters - timer -int64_t setTimer(enum timerIndex ind, int64_t val); -#ifndef EIGERD -int64_t getTimeLeft(enum timerIndex ind); -#endif - - -// parameters - channel, chip, module, settings -#ifdef MYTHEND -int setChannel(sls_detector_channel myChan); -int getChannel(sls_detector_channel *myChan); -int setChip(sls_detector_chip myChip); -int getChip(sls_detector_chip *myChip); -#endif -#ifdef EIGERD -int setModule(sls_detector_module myMod, int delay); -#else -int setModule(sls_detector_module myMod); -#endif -int getModule(sls_detector_module *myMod); -enum detectorSettings setSettings(enum detectorSettings sett, int imod); -enum detectorSettings getSettings(); - - -// parameters - threshold -#if defined(MYTHEND) || defined(EIGERD) -int getThresholdEnergy(int imod); -int setThresholdEnergy(int ev, int imod); -#endif - -// parameters - dac, adc, hv -#ifdef JUNGFRAUD -void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset); -void initDac(int dacnum); -extern void setAdc(int addr, int val); // AD9257.h -int voltageToDac(int value); -int dacToVoltage(unsigned int digital); -#endif -// void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]); -double setDAC(enum DACINDEX ind, double val, int imod, int mV); - -#ifndef MYTHEND -int setHighVoltage(int val); -#endif - - - -// parameters - timing, extsig -#ifdef MYTHEND -enum externalSignalFlag getExtSignal(int signalindex); -enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag); -#endif -enum externalCommunicationMode setTiming( enum externalCommunicationMode arg); - -// configure mac -#ifdef JUNGFRAUD -long int calcChecksum(int sourceip, int destip); -#endif -#ifndef MYTHEND -int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival); -// int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb); -#endif -#if defined(JUNGFRAUD) || defined(EIGERD) -int setDetectorPosition(int pos[]); -#endif - - -// very detector specific - -// gotthard specific - image, pedestal -#ifdef GOTTHARDD -int loadImage(enum imageType index, char *imageVals); -int readCounterBlock(int startACQ, char *counterVals); -int resetCounterBlock(int startACQ); -int calibratePedestal(int frames); - -// jungfrau specific - pll, flashing firmware -#elif JUNGFRAUD -void resetPLL(); -u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); -void configurePll(); -extern void eraseFlash(); // programfpga.h -extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h -extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h -extern int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp); // programfpga.h - -// eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter -#elif EIGERD -int setIODelay(int val, int imod); -int enableTenGigabitEthernet(int val); -int setCounterBit(int val); -int pulsePixel(int n, int x, int y); -int pulsePixelNMove(int n, int x, int y); -int pulseChip(int n); -int64_t setRateCorrection(int64_t custom_tau_in_nsec); -int getRateCorrectionEnable(); -int getDefaultSettingsTau_in_nsec(); -void setDefaultSettingsTau_in_nsec(int t); -int64_t getCurrentTau(); -void setExternalGating(int enable[]); -int setAllTrimbits(int val); -int getAllTrimbits(); -int getBebFPGATemp(); -int activate(int enable); -int setNetworkParameter(enum NETWORKINDEX mode, int value); -#endif - - - - -// aquisition -#if defined(EIGERD) || defined(GOTTHARD) -int prepareAcquisition(); -#endif -int startStateMachine(); -#ifdef VIRTUAL -void* start_timer(void* arg); -#endif -int stopStateMachine(); -#ifndef JUNGFRAUD -int startReadOut(); -#endif -enum runStatus getRunStatus(); -// void readFrame(int *ret, char *mess); -char *readFrame(int *ret, char *mess); -#ifdef JUNGFRAUD -u_int32_t runBusy(void); -#endif - - -//common -int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod); -int calculateDataBytes(); -int getTotalNumberOfChannels(); -int getTotalNumberOfChips(); -int getTotalNumberOfModules(); -int getNumberOfChannelsPerModule(); -int getNumberOfChipsPerModule(); -int getNumberOfDACsPerModule(); -int getNumberOfADCsPerModule(); -#ifdef EIGERD -int getNumberOfGainsPerModule(); -int getNumberOfOffsetsPerModule(); -#endif -int getNumberOfChannelsPerChip(); - -// sync -enum masterFlags setMaster(enum masterFlags arg); -enum synchronizationMode setSynchronization(enum synchronizationMode arg); - -int setPower(int ind, int val); - - -#endif -#endif diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3RegisterDefs.h b/slsDetectorSoftware/mythen3DetectorServer/mythen3RegisterDefs.h deleted file mode 100644 index e475e8fcb..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/mythen3RegisterDefs.h +++ /dev/null @@ -1,551 +0,0 @@ -#ifndef REGISTERS_G_H -#define REGISTERS_G_H - - -#include "sls_detector_defs.h" - - -/* Definitions for FPGA*/ -#define CSP0 0x20200000 -#define MEM_SIZE 0x100000 - - - -/* values defined for FPGA */ -#define MCSNUM 0x0 -#define FIXED_PATT_VAL 0xacdc1980 - - -#define FPGA_INIT_PAT 0x60008 -#define FPGA_INIT_ADDR 0xb0000000 - -//#ifdef JUNGFRAU_DHANYA -#define POWER_ON_REG 0x5e<<11 -// Pwr_I2C_SDA <= PowerReg_s(1) when PowerReg_s(3)='1' else 'Z'; -// Pwr_I2C_SCL <= PowerReg_s(0) when PowerReg_s(2)='1' else 'Z'; - -#define PWR_I2C_SCL_BIT 0 -#define PWR_I2C_SDA_BIT 1 -#define PWR_I2C_SCL_EN_BIT 2 -#define PWR_I2C_SDA_EN_BIT 3 - -#define POWER_STATUS_REG 41<<11 - -#define ADCREG1 0x08 -#define ADCREG2 0x14//20 -#define ADCREG3 0x4 -#define ADCREG4 0x5 -#define ADCREG_VREFS 24 -#define DBIT_PIPELINE_REG 89<<11 //0x59 same PATTERN_N_LOOP2_REG -#define MEM_MACHINE_FIFOS_REG 79<<11 //from gotthard -#define CONFGAIN_REG 93<<11 //from gotthard -#define ADC_PIPELINE_REG 66<<11 //0x42 same as ADC_OFFSET_REG -//#endif - -//#define ADC_OFFSET_REG 93<<11 //same as DAQ_REG -#define ADC_INVERSION_REG 67<<11 - -#define DAC_REG 64<<11//0x17<<11// control the dacs -//ADC -#define ADC_WRITE_REG 65<<11//0x18<<11 -//#define ADC_SYNC_REG 66<<11//0x19<<11 -//#define HV_REG 67<<11//0x20<<11 - - - - -//#define MUTIME_REG 0x1a<<11 -//temperature -#define TEMP_IN_REG 0x1b<<11 -#define TEMP_OUT_REG 0x1c<<11 -//configure MAC -#define TSE_CONF_REG 0x1d<<11 -#define ENET_CONF_REG 0x1e<<11 -//#define WRTSE_SHAD_REG 0x1f<<11 -//HV - - -#define DUMMY_REG 68<<11//0x21<<11 -#define FPGA_VERSION_REG 0<<11 //0x22<<11 -#define PCB_REV_REG 0<<11 -#define FIX_PATT_REG 1<<11 //0x23<<11 -#define CONTROL_REG 79<<11//0x24<<11 -#define STATUS_REG 2<<11 //0x25<<11 -#define CONFIG_REG 77<<11//0x26<<11 -#define EXT_SIGNAL_REG 78<<11// 0x27<<11 -//#define FPGA_SVN_REG 0x29<<11 - - -#define CHIP_OF_INTRST_REG 0x2A<<11 - -//FIFO -#define LOOK_AT_ME_REG 3<<11 //0x28<<11 -#define SYSTEM_STATUS_REG 4<<11 - -#define FIFO_DATA_REG 6<<11 -#define FIFO_STATUS_REG 7<<11 - -// constant FifoDigitalInReg_c : integer := 60; -#define FIFO_DIGITAL_DATA_LSB_REG 60<<11 -#define FIFO_DIGITAL_DATA_MSB_REG 61<<11 - -#define FIFO_DATA_REG_OFF 0x50<<11 /////// -//to read back dac registers -//#define MOD_DACS1_REG 0x65<<11 -//#define MOD_DACS2_REG 0x66<<11 -//#define MOD_DACS3_REG 0x67<<11 - -//user entered - - - - - - -#define GET_ACTUAL_TIME_LSB_REG 16<<11 -#define GET_ACTUAL_TIME_MSB_REG 17<<11 - -#define GET_MEASUREMENT_TIME_LSB_REG 38<<11 -#define GET_MEASUREMENT_TIME_MSB_REG 39<<11 - - -#define SET_DELAY_LSB_REG 96<<11 //0x68<<11 -#define SET_DELAY_MSB_REG 97<<11 //0x69<<11 -#define GET_DELAY_LSB_REG 18<<11//0x6a<<11 -#define GET_DELAY_MSB_REG 19<<11//0x6b<<11 - -#define SET_CYCLES_LSB_REG 98<<11//0x6c<<11 -#define SET_CYCLES_MSB_REG 99<<11//0x6d<<11 -#define GET_CYCLES_LSB_REG 20<<11//0x6e<<11 -#define GET_CYCLES_MSB_REG 21<<11//0x6f<<11 - -#define SET_FRAMES_LSB_REG 100<<11//0x70<<11 -#define SET_FRAMES_MSB_REG 101<<11//0x71<<11 -#define GET_FRAMES_LSB_REG 22<<11//0x72<<11 -#define GET_FRAMES_MSB_REG 23<<11//0x73<<11 - -#define SET_PERIOD_LSB_REG 102<<11//0x74<<11 -#define SET_PERIOD_MSB_REG 103<<11//0x75<<11 -#define GET_PERIOD_LSB_REG 24<<11//0x76<<11 -#define GET_PERIOD_MSB_REG 25<<11//0x77<<11 - -//#define PATTERN_WAIT0_TIME_REG_LSB 114<<11 -//#define PATTERN_WAIT0_TIME_REG_MSB 115<<11 -#define SET_EXPTIME_LSB_REG 114<<11//0x78<<11 -#define SET_EXPTIME_MSB_REG 115<<11//0x79<<11 -#define GET_EXPTIME_LSB_REG 26<<11//0x7a<<11 -#define GET_EXPTIME_MSB_REG 27<<11//0x7b<<11 - -#define SET_GATES_LSB_REG 106<<11//0x7c<<11 -#define SET_GATES_MSB_REG 107<<11//0x7d<<11 -#define GET_GATES_LSB_REG 28<<11//0x7e<<11 -#define GET_GATES_MSB_REG 29<<11//0x7f<<11 - -#define DATA_IN_LSB_REG 30<<11 -#define DATA_IN_MSB_REG 31<<11 - -#define PATTERN_OUT_LSB_REG 32<<11 -#define PATTERN_OUT_MSB_REG 33<<11 - -#define FRAMES_FROM_START_LSB_REG 34<<11 -#define FRAMES_FROM_START_MSB_REG 35<<11 - -#define FRAMES_FROM_START_PG_LSB_REG 36<<11 -#define FRAMES_FROM_START_PG_MSB_REG 37<<11 - -#define SLOW_ADC_REG 43<<11 - - - -#define PLL_PARAM_REG 80<<11//0x37<<11 -#define PLL_PARAM_OUT_REG 5<<11 //0x38<<11 -#define PLL_CNTRL_REG 81<<11//0x34<<11 - - -#ifdef NEW_GBE_INTERFACE -#define GBE_PARAM_OUT_REG 40<<11 -#define GBE_PARAM_REG 69<<11 -#define GBE_CNTRL_REG 70<<11 -#else -#define RX_UDP_AREG 69<<11 //rx_udpip_AReg_c : integer:= 69; *\/ -#define UDPPORTS_AREG 70<<11// udpports_AReg_c : integer:= 70; *\/ -#define RX_UDPMACL_AREG 71<<11//rx_udpmacL_AReg_c : integer:= 71; *\/ -#define RX_UDPMACH_AREG 72<<11//rx_udpmacH_AReg_c : integer:= 72; *\/ -#define DETECTORMACL_AREG 73<<11//detectormacL_AReg_c : integer:= 73; *\/ -#define DETECTORMACH_AREG 74<<11//detectormacH_AReg_c : integer:= 74; *\/ -#define DETECTORIP_AREG 75<<11//detectorip_AReg_c : integer:= 75; *\/ -#define IPCHKSUM_AREG 76<<11//ipchksum_AReg_c : integer:= 76; *\/ */ -#endif - - -#define PATTERN_CNTRL_REG 82<<11 // address of patword -#define PATTERN_LIMITS_AREG 83<<11 // start/stop pattern - -#define PATTERN_LOOP0_AREG 84<<11 // start/stop of loop -#define PATTERN_N_LOOP0_REG 85<<11 // # loops - -#define PATTERN_LOOP1_AREG 86<<11 -#define PATTERN_N_LOOP1_REG 87<<11 - -#define PATTERN_LOOP2_AREG 88<<11 -#define PATTERN_N_LOOP2_REG 89<<11 - -#define PATTERN_WAIT0_AREG 90<<11 // address where to wait -#define PATTERN_WAIT1_AREG 91<<11 -#define PATTERN_WAIT2_AREG 92<<11 - - - -//#define DAQ_REG 93<<11 //unused -#define NSAMPLES_REG 93<<11 //unused - - -#define HV_REG 95<<11 - - - -#define PATTERN_IOCTRL_REG_LSB 108<<11 // if output or not -#define PATTERN_IOCTRL_REG_MSB 109<<11 - -#define PATTERN_IOCLKCTRL_REG_LSB 110<<11//unused -#define PATTERN_IOCLKCTRL_REG_MSB 111<<11//unused -#define PATTERN_IN_REG_LSB 112<<11 // write word -#define PATTERN_IN_REG_MSB 113<<11 -#define PATTERN_WAIT0_TIME_REG_LSB 114<<11 // how long to wait -#define PATTERN_WAIT0_TIME_REG_MSB 115<<11 -#define PATTERN_WAIT1_TIME_REG_LSB 116<<11 -#define PATTERN_WAIT1_TIME_REG_MSB 117<<11 -#define PATTERN_WAIT2_TIME_REG_LSB 118<<11 -#define PATTERN_WAIT2_TIME_REG_MSB 119<<11 - -//#define DAC_REG_OFF 120 -//#define DAC_0_1_VAL_REG 120<<11 -//#define DAC_2_3_VAL_REG 121<<11 -//#define DAC_4_5_VAL_REG 122<<11 -//#define DAC_6_7_VAL_REG 123<<11 -//#define DAC_8_9_VAL_REG 124<<11 -//#define DAC_10_11_VAL_REG 125<<11 -//#define DAC_12_13_VAL_REG 126<<11 -//#define DAC_14_15_VAL_REG 127<<11 -#define DAC_VAL_REG 121<<11 // value of the DAC -#define DAC_NUM_REG 122<<11 // Index of the DAC, only JCTB -#define DAC_VAL_OUT_REG 42<<11 -#define ADC_LATCH_DISABLE_REG 120<<11 - - - - - - - - -/* registers defined in FPGA */ -#define GAIN_REG 0 -//#define FLOW_CONTROL_REG 0x11<<11 -//#define FLOW_STATUS_REG 0x12<<11 -//#define FRAME_REG 0x13<<11 -#define MULTI_PURPOSE_REG 0 -//#define TIME_FROM_START_REG 0x16<<11 - - -#define ROI_REG 0 // 0x35<<11 -#define OVERSAMPLING_REG 0 // 0x36<<11 -#define MOENCH_CNTR_REG 0 // 0x31<<11 -#define MOENCH_CNTR_OUT_REG 0 // 0x33<<11 -#define MOENCH_CNTR_CONF_REG 0 // 0x32<<11 - - - -//image -#define DARK_IMAGE_REG 0 // 0x81<<11 -#define GAIN_IMAGE_REG 0 // 0x82<<11 - -//counter block memory -#define COUNTER_MEMORY_REG 0 // 0x85<<11 //gotthard - - -//not used -//#define MCB_DOUT_REG_OFF 0 // 0x200000 -//#define FIFO_CNTRL_REG_OFF 0 // 0x300000 -//#define FIFO_COUNTR_REG_OFF 0 // 0x400000 -//not used so far -//#define SPEED_REG 0 // 0x006000 -//#define SET_NBITS_REG 0 // 0x008000 -//not used -//#define GET_SHIFT_IN_REG 0 // 0x022000 - - - -#define SHIFTMOD 2 -#define SHIFTFIFO 9 - -/** for PCB_REV_REG */ -#define DETECTOR_TYPE_MASK 0xFF000000 -#define DETECTOR_TYPE_OFFSET 24 -#define BOARD_REVISION_MASK 0xFFFFFF -#define MOENCH03_MODULE_ID 2 -#define JUNGFRAU_MODULE_ID 1 -#define JUNGFRAU_CTB_ID 3 - - - - -/* for control register (16bit only)*/ -#define START_ACQ_BIT 0x0001 -#define STOP_ACQ_BIT 0x0002 -#define START_FIFOTEST_BIT 0x0004 // ????? -#define STOP_FIFOTEST_BIT 0x0008 // ?????? -#define START_READOUT_BIT 0x0010 -#define STOP_READOUT_BIT 0x0020 -#define START_EXPOSURE_BIT 0x0040 -#define STOP_EXPOSURE_BIT 0x0080 -#define START_TRAIN_BIT 0x0100 -#define STOP_TRAIN_BIT 0x0200 -#define FIFO_RESET_BIT 0x8000 -#define SYNC_RESET 0x0400 -#define GB10_RESET_BIT 0x0800 -#define MEM_RESET_BIT 0x1000 - -/* for status register */ -#define RUN_BUSY_BIT 0x00000001 -#define READOUT_BUSY_BIT 0x00000002 -#define FIFOTEST_BUSY_BIT 0x00000004 //???? -#define WAITING_FOR_TRIGGER_BIT 0x00000008 -#define DELAYBEFORE_BIT 0x00000010 -#define DELAYAFTER_BIT 0x00000020 -#define EXPOSING_BIT 0x00000040 -#define COUNT_ENABLE_BIT 0x00000080 -#define READSTATE_0_BIT 0x00000100 -#define READSTATE_1_BIT 0x00000200 -#define READSTATE_2_BIT 0x00000400 -#define LAM_BIT 0x00000400 // error! -#define SOME_FIFO_FULL_BIT 0x00000800 // error! - - - -#define RUNSTATE_0_BIT 0x00001000 -#define RUNSTATE_1_BIT 0x00002000 -#define RUNSTATE_2_BIT 0x00004000 -#define STOPPED_BIT 0x00008000 // stopped! -#define ALL_FIFO_EMPTY_BIT 0x00010000 // data ready -#define RUNMACHINE_BUSY_BIT 0x00020000 -#define READMACHINE_BUSY_BIT 0x00040000 -#define PLL_RECONFIG_BUSY 0x00100000 - - - -/* for fifo status register */ -#define FIFO_ENABLED_BIT 0x80000000 -#define FIFO_DISABLED_BIT 0x01000000 -#define FIFO_ERROR_BIT 0x08000000 -#define FIFO_EMPTY_BIT 0x04000000 -#define FIFO_DATA_READY_BIT 0x02000000 -#define FIFO_COUNTER_MASK 0x000001ff -#define FIFO_NM_MASK 0x00e00000 -#define FIFO_NM_OFF 21 -#define FIFO_NC_MASK 0x001ffe00 -#define FIFO_NC_OFF 9 - -/* for config register *///not really used yet -#define TOT_ENABLE_BIT 0x00000002 -#define TIMED_GATE_BIT 0x00000004 -#define CONT_RO_ENABLE_BIT 0x00080000 -#define GB10_NOT_CPU_BIT 0x00001000 -#define ADC_OUTPUT_DISABLE_BIT 0x00100 -#define DIGITAL_OUTPUT_ENABLE_BIT 0x00200 - - -/* for speed register */ -#define CLK_DIVIDER_MASK 0x000000ff -#define CLK_DIVIDER_OFFSET 0 -#define SET_LENGTH_MASK 0x00000f00 -#define SET_LENGTH_OFFSET 8 -#define WAIT_STATES_MASK 0x0000f000 -#define WAIT_STATES_OFFSET 12 -#define TOTCLK_DIVIDER_MASK 0xff000000 -#define TOTCLK_DIVIDER_OFFSET 24 -#define TOTCLK_DUTYCYCLE_MASK 0x00ff0000 -#define TOTCLK_DUTYCYCLE_OFFSET 16 - -/* for external signal register */ -#define SIGNAL_OFFSET 4 -#define SIGNAL_MASK 0xF -#define EXT_SIG_OFF 0x0 -#define EXT_GATE_IN_ACTIVEHIGH 0x1 -#define EXT_GATE_IN_ACTIVELOW 0x2 -#define EXT_TRIG_IN_RISING 0x3 -#define EXT_TRIG_IN_FALLING 0x4 -#define EXT_RO_TRIG_IN_RISING 0x5 -#define EXT_RO_TRIG_IN_FALLING 0x6 -#define EXT_GATE_OUT_ACTIVEHIGH 0x7 -#define EXT_GATE_OUT_ACTIVELOW 0x8 -#define EXT_TRIG_OUT_RISING 0x9 -#define EXT_TRIG_OUT_FALLING 0xA -#define EXT_RO_TRIG_OUT_RISING 0xB -#define EXT_RO_TRIG_OUT_FALLING 0xC - - - -/* for temperature register */ -#define T1_CLK_BIT 0x00000001 -#define T1_CS_BIT 0x00000002 -#define T2_CLK_BIT 0x00000004 -#define T2_CS_BIT 0x00000008 - - - -/* fifo control register */ -//#define FIFO_RESET_BIT 0x00000001 -//#define FIFO_DISABLE_TOGGLE_BIT 0x00000002 - - -//chip shiftin register meaning -#define OUTMUX_OFF 20 -#define OUTMUX_MASK 0x1f -#define PROBES_OFF 4 -#define PROBES_MASK 0x7f -#define OUTBUF_OFF 0 -#define OUTBUF_MASK 1 - - -/* multi purpose register */ -#define PHASE_STEP_BIT 0x00000001 -#define PHASE_STEP_OFFSET 0 -// #define xxx_BIT 0x00000002 -#define RESET_COUNTER_BIT 0x00000004 -#define RESET_COUNTER_OFFSET 2 -//#define xxx_BIT 0x00000008 -//#define xxx_BIT 0x00000010 -#define SW1_BIT 0x00000020 -#define SW1_OFFSET 5 -#define WRITE_BACK_BIT 0x00000040 -#define WRITE_BACK_OFFSET 6 -#define RESET_BIT 0x00000080 -#define RESET_OFFSET 7 -#define ENET_RESETN_BIT 0x00000800 -#define ENET_RESETN_OFFSET 11 -#define INT_RSTN_BIT 0x00002000 -#define INT_RSTN_OFFSET 13 -#define DIGITAL_TEST_BIT 0x00004000 -#define DIGITAL_TEST_OFFSET 14 -//#define CHANGE_AT_POWER_ON_BIT 0x00008000 -//#define CHANGE_AT_POWER_ON_OFFSET 15 - - -/* settings/conf gain register */ -#define GAIN_MASK 0x0000000f -#define GAIN_OFFSET 0 -#define SETTINGS_MASK 0x000000f0 -#define SETTINGS_OFFSET 4 - - -/* CHIP_OF_INTRST_REG */ -#define CHANNEL_MASK 0xffff0000 -#define CHANNEL_OFFSET 16 -#define ACTIVE_ADC_MASK 0x0000001f - - - -/**ADC SYNC CLEAN FIFO*/ -#define ADCSYNC_CLEAN_FIFO_BITS 0x300000 -#define CLEAN_FIFO_MASK 0x0fffff - - - - -enum {run_clk_c, adc_clk_c, sync_clk_c, dbit_clk_c}; - - - - -#define PLL_CNTR_ADDR_OFF 16 //PLL_CNTR_REG bits 21 downto 16 represent the counter address - -#define PLL_CNTR_RECONFIG_RESET_BIT 0 -#define PLL_CNTR_READ_BIT 1 -#define PLL_CNTR_WRITE_BIT 2 -#define PLL_CNTR_PLL_RESET_BIT 3 - - -#define PLL_CNTR_PHASE_EN_BIT 8 -#define PLL_CNTR_UPDN_BIT 9 -#define PLL_CNTR_CNTSEL_OFF 10 - - - - - -#define PLL_MODE_REG 0x0 -#define PLL_STATUS_REG 0x1 -#define PLL_START_REG 0x2 -#define PLL_N_COUNTER_REG 0x3 -#define PLL_M_COUNTER_REG 0x4 -#define PLL_C_COUNTER_REG 0x5 //which ccounter stands in param 22:18; 7:0 lowcount 15:8 highcount; 16 bypassenable; 17 oddivision -#define PLL_PHASE_SHIFT_REG 0x6 // which ccounter stands in param 16:20; 21 updown (1 up, 0 down) -#define PLL_K_COUNTER_REG 0x7 -#define PLL_BANDWIDTH_REG 0x8 -#define PLL_CHARGEPUMP_REG 0x9 -#define PLL_VCO_DIV_REG 0x1c -#define PLL_MIF_REG 0x1f - -#define PPL_M_CNT_PARAM_DEFAULT 0x4040 -#define PPL_N_CNT_PARAM_DEFAULT 0x20D0C -#define PPL_C0_CNT_PARAM_DEFAULT 0x20D0C -#define PPL_C1_CNT_PARAM_DEFAULT 0xA0A0 -#define PPL_C2_CNT_PARAM_DEFAULT 0x20D0C -#define PPL_C3_CNT_PARAM_DEFAULT 0x0808 -#define PPL_BW_PARAM_DEFAULT 0x2EE0 -#define PPL_VCO_PARAM_DEFAULT 0x1 - -#define NEW_PLL_RECONFIG - -#ifdef NEW_PLL_RECONFIG -#define PLL_VCO_FREQ_MHZ 400//480//800 -#else -#define PLL_VCO_FREQ_MHZ 480//800 -#endif - - - - - -/* - GBE parameter and control registers definitions -*/ - -#define GBE_CTRL_WSTROBE 0 -#define GBE_CTRL_VAR_OFFSET 16 -#define GBE_CTRL_VAR_MASK 0XF -#define GBE_CTRL_RAMADDR_OFFSET 24 -#define GBE_CTRL_RAMADDR_MASK 0X3F -#define GBE_CTRL_INTERFACE 23 - -#define RX_UDP_IP_ADDR 0 -#define RX_UDP_PORTS_ADDR 1 -#define RX_UDP_MAC_L_ADDR 2 -#define RX_UDP_MAC_H_ADDR 3 -#define IPCHECKSUM_ADDR 4 -#define GBE_DELAY_ADDR 5 -#define GBE_RESERVED1_ADDR 6 -#define GBE_RESERVED2_ADDR 7 -#define DETECTOR_MAC_L_ADDR 8 -#define DETECTOR_MAC_H_ADDR 9 -#define DETECTOR_IP_ADDR 10 - - - -/**------------------ --- pattern registers definitions ---------------------------------------------- */ -#define IOSIGNALS_MASK 0xfffffffffffff -#define ADC_ENABLE_BIT 63 -#define APATTERN_MASK 0xffff -#define ASTART_OFFSET 0 -#define ASTOP_OFFSET 16 -#define PATTERN_CTRL_WRITE_BIT 0 -#define PATTERN_CTRL_READ_BIT 1 -#define PATTERN_CTRL_ADDR_OFFSET 16 -#define MAX_PATTERN_LENGTH 1024 - - -#endif - diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_defs.h b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_defs.h deleted file mode 100644 index 705a9f891..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_defs.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * mythen3Server_defs.h - * - * Created on: Jan 24, 2013 - * Author: l_maliakal_d, changed my Marie A. - */ - -#ifndef SLSDETECTORSERVER_DEFS_H_ -#define SLSDETECTORSERVER_DEFS_H_ - -#include "sls_detector_defs.h" -#include - -/** This is only an example file!!! */ - - - -#define GOODBYE (-200) -enum ADCINDEX {TEMP_FPGA, TEMP_ADC}; -enum DACINDEX {vIpre, vIbias, Vrf, VrfSh, vIinSh, VdcSh, Vth2, VPL, Vth1, Vth3, Vtrim, casSh, cas, vIbiasSh, vIcin, VPH, NC, vIpreOut}; // Mythen 3.01 -#define DEFAULT_DAC_VALS { 2150, /* vIpre */ \ - 1200, /* vIbias */ \ - 900, /* Vrf */ \ - 1050, /* VrfSh */ \ - 1400, /* vIinSh */ \ - 655, /* VdcSh */ \ - 850, /* Vth2 */ \ - 1400, /* VPL */ \ - 850, /* Vth1 */ \ - 850, /* Vth3 */ \ - 2294, /* Vtrim */ \ - 983, /* casSh */ \ - 1474, /* cas */ \ - 1200, /* vIbiasSh */ \ - 1600, /* vIcin */ \ - 1520, /* VPH */ \ - 0, /* NC */ \ - 1000 /* vIpreOut */ \ - }; - -/*Hardware Definitions -#define NMAXMOD (1) -#define NMOD (1) -#define NCHAN (256 * 256) -#define NCHIP (4) -#define NADC (0) -#define NDAC (16) -#define NGAIN (0) -#define NOFFSET (0) -*/ - -/** Default Parameters */ -#define DEFAULT_EXPTIME (10*1000) //ns - -/* Hardware Definitions */ -//#define NMAXMOD (1) -#define NMOD (1) -//#define NCHAN (256 * 256) -//#define NCHIP (8) -//#define NADC (0) -#define NDAC (8) -#define NDAC_OLDBOARD (16) -#define DYNAMIC_RANGE (16) -#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8) -#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL) -#define IP_PACKETSIZE (0x2052) -#define CLK_RUN (40) /* MHz */ -#define CLK_SYNC (20) /* MHz */ - - -// Hardware definitions - -#define NCHAN 36 -#define NCHIP 1 -#define NADC 9 // - -/* #ifdef CTB */ -/* #define NDAC 24 */ -/* #define NPWR 5 */ -/* #else */ -/* #define NDAC 16 */ -/* #define NPWR 0 */ -/* #endif */ -#define DAC_CMD_OFF 20 - -#define NMAXMODX 1 -#define NMAXMODY 1 -#define NMAXMOD (NMAXMODX*NMAXMODY) - -#define NCHANS (NCHAN*NCHIP*NMAXMOD) -#define NDACS (NDAC*NMAXMOD) - -#endif /* SLSDETECTORSERVER_DEFS_H_ */ diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.c b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.c deleted file mode 100755 index 5631c4187..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.c +++ /dev/null @@ -1,4916 +0,0 @@ - -#include "sls_detector_defs.h" -#include "mythen3Server_funcs.h" -#include "mythen3FunctionList.h" -#include "communication_funcs.h" -#include "mythen3Server_defs.h" -// #include "mythen3RegisterDefs.h" -// #include "blackfin.h" - -#include -#include -#include - - -// Global variables -extern int lockStatus; -extern char lastClientIP[INET_ADDRSTRLEN]; -extern char thisClientIP[INET_ADDRSTRLEN]; -extern int differentClients; - -//defined in the detector specific Makefile -/*#ifdef MYTHEND -const enum detectorType myDetectorType=MYTHEN; -#elif GOTTHARDD -const enum detectorType myDetectorType=GOTTHARD; -#elif EIGERD -const enum detectorType myDetectorType=EIGER; -#elif PICASSOD -const enum detectorType myDetectorType=PICASSO; -#elif MOENCHD -const enum detectorType myDetectorType=MOENCH; -#elif JUNGFRAUD -const enum detectorType myDetectorType=JUNGFRAU; -#elif MYTHEN3D -const enum detectorType myDetectorType=MYTHEN3D; -#else -const enum detectorType myDetectorType=GENERIC; -#endif -*/ -enum detectorType myDetectorType=MYTHEN3; - -int sockfd; // (updated in slsDetectorServer) as extern -int (*flist[NUM_DET_FUNCTIONS])(int); -char mess[MAX_STR_LENGTH]; -int dataBytes = 10; -int isControlServer = 0; -int debugflag = 0; - -int N_DAC=24; -int N_PWR=5; - -int vPowerLimit = 1400; // mV - -/* initialization functions */ - -int printSocketReadError() { - cprintf(BG_RED, "Error reading from socket. Possible socket crash\n"); - return FAIL; -} - -void basictests(int flag) { - debugflag = flag; -#ifdef SLS_DETECTOR_FUNCTION_LIST - checkFirmwareCompatibility(debugflag); -#endif -} - - -void init_detector(int controlserver) { -// #ifdef VIRTUAL -// printf("This is a VIRTUAL detector\n"); -// #endif - -// #ifdef SLS_DETECTOR_FUNCTION_LIST -// if (controlserver) { -// isControlServer = 1; -// initControlServer(); -// } -// else initStopServer(); -// #endif - - strcpy(mess,"dummy message"); - strcpy(lastClientIP,"none"); - strcpy(thisClientIP,"none1"); - lockStatus=0; - #ifdef MYTHEN3D -printf("This is a mythen3 detector\n"); - #endif -} - - -int decode_function(int file_des) { - int fnum,n; - int ret=FAIL; -#ifdef VERBOSE - printf( "\nreceive data\n"); -#endif - n = receiveData(file_des,&fnum,sizeof(fnum),INT32); - if (n <= 0) { -#ifdef VERBOSE - printf("ERROR reading from socket %d, %d %d (%s)\n", n, fnum, file_des, getFunctionName((enum detFuncs)fnum)); -#endif - return FAIL; - } -#ifdef VERBOSE - else - printf("size of data received %d\n",n); -#endif - -#ifdef VERBOSE - printf(" calling function fnum=%d, (%s) located at 0x%x\n", fnum, getFunctionName((enum detFuncs)fnum), (unsigned int)flist[fnum]); -#endif - if (fnum<0 || fnum>=NUM_DET_FUNCTIONS) { - cprintf(BG_RED,"Unknown function enum %d\n", fnum); - ret=(M_nofunc)(file_des); - }else - ret=(*flist[fnum])(file_des); - if (ret == FAIL) - cprintf(RED, "Error executing the function = %d (%s)\n", fnum, getFunctionName((enum detFuncs)fnum)); - return ret; -} - - -const char* getFunctionName(enum detFuncs func) { - switch (func) { - case F_EXEC_COMMAND: return "F_EXEC_COMMAND"; - case F_GET_ERROR: return "F_GET_ERROR"; - case F_GET_DETECTOR_TYPE: return "F_GET_DETECTOR_TYPE"; - case F_SET_NUMBER_OF_MODULES: return "F_SET_NUMBER_OF_MODULES"; - case F_GET_MAX_NUMBER_OF_MODULES: return "F_GET_MAX_NUMBER_OF_MODULES"; - case F_SET_EXTERNAL_SIGNAL_FLAG: return "F_SET_EXTERNAL_SIGNAL_FLAG"; - case F_SET_EXTERNAL_COMMUNICATION_MODE: return "F_SET_EXTERNAL_COMMUNICATION_MODE"; - case F_GET_ID: return "F_GET_ID"; - case F_DIGITAL_TEST: return "F_DIGITAL_TEST"; - case F_ANALOG_TEST: return "F_ANALOG_TEST"; - case F_ENABLE_ANALOG_OUT: return "F_ENABLE_ANALOG_OUT"; - case F_CALIBRATION_PULSE: return "F_CALIBRATION_PULSE"; - case F_SET_DAC: return "F_SET_DAC"; - case F_GET_ADC: return "F_GET_ADC"; - case F_WRITE_REGISTER: return "F_WRITE_REGISTER"; - case F_READ_REGISTER: return "F_READ_REGISTER"; - case F_WRITE_MEMORY: return "F_WRITE_MEMORY"; - case F_READ_MEMORY: return "F_READ_MEMORY"; - case F_SET_CHANNEL: return "F_SET_CHANNEL"; - case F_GET_CHANNEL: return "F_GET_CHANNEL"; - case F_SET_ALL_CHANNELS: return "F_SET_ALL_CHANNELS"; - case F_SET_CHIP: return "F_SET_CHIP"; - case F_GET_CHIP: return "F_GET_CHIP"; - case F_SET_ALL_CHIPS: return "F_SET_ALL_CHIPS"; - case F_SET_MODULE: return "F_SET_MODULE"; - case F_GET_MODULE: return "F_GET_MODULE"; - case F_SET_ALL_MODULES: return "F_SET_ALL_MODULES"; - case F_SET_SETTINGS: return "F_SET_SETTINGS"; - case F_GET_THRESHOLD_ENERGY: return "F_GET_THRESHOLD_ENERGY"; - case F_SET_THRESHOLD_ENERGY: return "F_SET_THRESHOLD_ENERGY"; - case F_START_ACQUISITION: return "F_START_ACQUISITION"; - case F_STOP_ACQUISITION: return "F_STOP_ACQUISITION"; - case F_START_READOUT: return "F_START_READOUT"; - case F_GET_RUN_STATUS: return "F_GET_RUN_STATUS"; - case F_START_AND_READ_ALL: return "F_START_AND_READ_ALL"; - case F_READ_FRAME: return "F_READ_FRAME"; - case F_READ_ALL: return "F_READ_ALL"; - case F_SET_TIMER: return "F_SET_TIMER"; - case F_GET_TIME_LEFT: return "F_GET_TIME_LEFT"; - case F_SET_DYNAMIC_RANGE: return "F_SET_DYNAMIC_RANGE"; - case F_SET_READOUT_FLAGS: return "F_SET_READOUT_FLAGS"; - case F_SET_ROI: return "F_SET_ROI"; - case F_SET_SPEED: return "F_SET_SPEED"; - case F_EXECUTE_TRIMMING: return "F_EXECUTE_TRIMMING"; - case F_EXIT_SERVER: return "F_EXIT_SERVER"; - case F_LOCK_SERVER: return "F_LOCK_SERVER"; - case F_GET_LAST_CLIENT_IP: return "F_GET_LAST_CLIENT_IP"; - case F_SET_PORT: return "F_SET_PORT"; - case F_UPDATE_CLIENT: return "F_UPDATE_CLIENT"; - case F_CONFIGURE_MAC: return "F_CONFIGURE_MAC"; - case F_LOAD_IMAGE: return "F_LOAD_IMAGE"; - case F_SET_MASTER: return "F_SET_MASTER"; - case F_SET_SYNCHRONIZATION_MODE: return "F_SET_SYNCHRONIZATION_MODE"; - case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK"; - case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK"; - case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL"; - case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA"; - case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS"; - case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN"; - case F_WRITE_ADC_REG: return "F_WRITE_ADC_REG"; - case F_SET_COUNTER_BIT: return "F_SET_COUNTER_BIT"; - case F_PULSE_PIXEL: return "F_PULSE_PIXEL"; - case F_PULSE_PIXEL_AND_MOVE: return "F_PULSE_PIXEL_AND_MOVE"; - case F_PULSE_CHIP: return "F_PULSE_CHIP"; - case F_SET_RATE_CORRECT: return "F_SET_RATE_CORRECT"; - case F_GET_RATE_CORRECT: return "F_GET_RATE_CORRECT"; - case F_SET_NETWORK_PARAMETER: return "F_SET_NETWORK_PARAMETER"; - case F_PROGRAM_FPGA: return "F_PROGRAM_FPGA"; - case F_RESET_FPGA: return "F_RESET_FPGA"; - case F_POWER_CHIP: return "F_POWER_CHIP"; - case F_ACTIVATE: return "F_ACTIVATE"; - case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION"; - case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION"; - default: return "Unknown Function"; - } -} - -void function_table() { - flist[F_EXEC_COMMAND] = &exec_command; - flist[F_GET_ERROR] = &get_error; - flist[F_GET_DETECTOR_TYPE] = &get_detector_type; - flist[F_SET_NUMBER_OF_MODULES] = &set_number_of_modules; - flist[F_GET_MAX_NUMBER_OF_MODULES] = &get_max_number_of_modules; - flist[F_SET_EXTERNAL_SIGNAL_FLAG] = &set_external_signal_flag; - flist[F_SET_EXTERNAL_COMMUNICATION_MODE] = &set_external_communication_mode; - flist[F_GET_ID] = &get_id; - flist[F_DIGITAL_TEST] = &digital_test; - flist[F_ANALOG_TEST] = &analog_test; - flist[F_ENABLE_ANALOG_OUT] = &enable_analog_out; - flist[F_CALIBRATION_PULSE] = &calibration_pulse; - flist[F_SET_DAC] = &set_dac; - flist[F_GET_ADC] = &get_adc; - flist[F_WRITE_REGISTER] = &write_register; - flist[F_READ_REGISTER] = &read_register; - flist[F_WRITE_MEMORY] = &write_memory; - flist[F_READ_MEMORY] = &read_memory; - flist[F_SET_CHANNEL] = &set_channel; - flist[F_GET_CHANNEL] = &get_channel; - flist[F_SET_ALL_CHANNELS] = &set_all_channels; - flist[F_SET_CHIP] = &set_chip; - flist[F_GET_CHIP] = &get_chip; - flist[F_SET_ALL_CHIPS] = &set_all_chips; - flist[F_SET_MODULE] = &set_module; - flist[F_GET_MODULE] = &get_module; - flist[F_SET_ALL_MODULES] = &set_all_modules; - flist[F_SET_SETTINGS] = &set_settings; - flist[F_GET_THRESHOLD_ENERGY] = &get_threshold_energy; - flist[F_SET_THRESHOLD_ENERGY] = &set_threshold_energy; - flist[F_START_ACQUISITION] = &start_acquisition; - flist[F_STOP_ACQUISITION] = &stop_acquisition; - flist[F_START_READOUT] = &start_readout; - flist[F_GET_RUN_STATUS] = &get_run_status; - flist[F_START_AND_READ_ALL] = &start_and_read_all; - flist[F_READ_FRAME] = &read_frame; - flist[F_READ_ALL] = &read_all; - flist[F_SET_TIMER] = &set_timer; - flist[F_GET_TIME_LEFT] = &get_time_left; - flist[F_SET_DYNAMIC_RANGE] = &set_dynamic_range; - flist[F_SET_READOUT_FLAGS] = &set_readout_flags; - flist[F_SET_ROI] = &set_roi; - flist[F_SET_SPEED] = &set_speed; - flist[F_EXECUTE_TRIMMING] = &execute_trimming; - flist[F_EXIT_SERVER] = &exit_server; - flist[F_LOCK_SERVER] = &lock_server; - flist[F_GET_LAST_CLIENT_IP] = &get_last_client_ip; - flist[F_SET_PORT] = &set_port; - flist[F_UPDATE_CLIENT] = &update_client; - flist[F_CONFIGURE_MAC] = &configure_mac; - flist[F_LOAD_IMAGE] = &load_image; - flist[F_SET_MASTER] = &set_master; - flist[F_SET_SYNCHRONIZATION_MODE] = &set_synchronization; - flist[F_READ_COUNTER_BLOCK] = &read_counter_block; - flist[F_RESET_COUNTER_BLOCK] = &reset_counter_block; - flist[F_CALIBRATE_PEDESTAL] = &calibrate_pedestal; - flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga; - flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits; - flist[F_SET_CTB_PATTERN] = &set_ctb_pattern; - flist[F_WRITE_ADC_REG] = &write_adc_register; - flist[F_SET_COUNTER_BIT] = &set_counter_bit; - flist[F_PULSE_PIXEL] = &pulse_pixel; - flist[F_PULSE_PIXEL_AND_MOVE] = &pulse_pixel_and_move; - flist[F_PULSE_CHIP] = &pulse_chip; - flist[F_SET_RATE_CORRECT] = &set_rate_correct; - flist[F_GET_RATE_CORRECT] = &get_rate_correct; - flist[F_SET_NETWORK_PARAMETER] = &set_network_parameter; - flist[F_PROGRAM_FPGA] = &program_fpga; - flist[F_RESET_FPGA] = &reset_fpga; - flist[F_POWER_CHIP] = &power_chip; - flist[F_ACTIVATE] = &set_activate; - flist[F_PREPARE_ACQUISITION] = &prepare_acquisition; - flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition; - - // check - if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) { - cprintf(BG_RED,"The last detector function enum has reached its limit\nGoodbye!\n"); - exit(EXIT_FAILURE); - } - -#ifdef VERYVERBOSE - { - int i=0; - for (i = 0; i < NUM_DET_FUNCTIONS ; i++) { - printf("function fnum=%d, (%s) located at 0x%x\n", i, getFunctionName((enum detFuncs)i), (unsigned int)flist[i]); - } - } -#endif -} - - -int M_nofunc(int file_des){ - int ret=FAIL,ret1=FAIL; - int n=0; - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - sprintf(mess,"Unrecognized Function. Please do not proceed.\n"); - cprintf(BG_RED,"Error: %s",mess); - n = sendData(file_des,&ret1,sizeof(ret1),INT32); - n = sendData(file_des,mess,sizeof(mess),OTHER); - - // return ok / fail - return ret; -} - - - - - - -/* functions called by client */ - - - -int exec_command(int file_des) { - int ret=OK,ret1=OK; - int n=0; - char cmd[MAX_STR_LENGTH]=""; - int sysret=0; - - // receive arguments - n = receiveData(file_des,cmd,MAX_STR_LENGTH,OTHER); - if (n < 0) return printSocketReadError(); - - // execute action if the arguments correctly arrived -#ifdef VERBOSE - printf("executing command %s\n", cmd); -#endif - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } else { - sysret=system(cmd); - //should be replaced by popen - if (sysret==0) { - sprintf(mess,"Succeeded\n"); - } else { - ret = FAIL; - sprintf(mess,"Executing Command failed\n"); - cprintf(RED, "Warning: %s", mess); - } - } - - ret1=ret; - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int get_error(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Get Error) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int get_detector_type(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum detectorType retval=-1; - - // execute action - retval=myDetectorType; -#ifdef VERBOSE - printf("Returning detector type %d\n",retval); -#endif - - if (differentClients) - ret=FORCE_UPDATE; - - // send ok / fail - n += sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; - - -} - - - - -int set_number_of_modules(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=0; - int arg[2]={-1,-1}; - sprintf(mess,"set number of modules failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - enum dimension dim=arg[0]; - int nm=arg[1]; - - // execute action -#ifdef VERBOSE - printf("Setting the number of modules in dimension %d to %d\n",dim,nm ); -#endif - if (lockStatus && differentClients && nm!=GET_FLAG) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - retval=setNMod(nm, dim); - dataBytes=calculateDataBytes(); - } -#endif - - if (retval==nm || nm==GET_FLAG) { - ret=OK; - if (differentClients) - ret=FORCE_UPDATE; - } else - ret=FAIL; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int get_max_number_of_modules(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - enum dimension arg=0; - sprintf(mess,"get max number of modules failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action -#ifdef VERBOSE - printf("Getting the max number of modules in dimension %d \n",arg); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=getNModBoard(arg); -#endif -#ifdef VERBOSE - printf("Max number of module in dimension %d is %d\n",arg,retval ); -#endif - if (differentClients && ret==OK) { - ret=FORCE_UPDATE; - } - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int set_external_signal_flag(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum externalSignalFlag retval=GET_EXTERNAL_SIGNAL_FLAG; - sprintf(mess,"set external signal flag failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set External Signal Flag) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - int signalindex=arg[0]; - enum externalSignalFlag flag=arg[1]; - - // execute action - if (lockStatus && differentClients && flag!=GET_EXTERNAL_SIGNAL_FLAG) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - -#ifdef SLS_DETECTOR_FUNCTION_LIST - else{ -#ifdef VERBOSE - printf("Setting external signal %d to flag %d\n",signalindex,flag); -#endif - switch (flag) { - case GET_EXTERNAL_SIGNAL_FLAG: - retval=getExtSignal(signalindex); - break; - default: - retval=setExtSignal(signalindex,flag); - if (retval!=flag) { - ret=FAIL; - sprintf(mess,"External signal %d flag should be 0x%04x but is 0x%04x\n", signalindex, flag, retval); - cprintf(RED, "%s", mess); - } - break; - } -#ifdef VERBOSE - printf("Set to flag %d\n",retval); -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; - -} - - -int set_external_communication_mode(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum externalCommunicationMode arg=GET_EXTERNAL_COMMUNICATION_MODE; - enum externalCommunicationMode retval=GET_EXTERNAL_COMMUNICATION_MODE; - sprintf(mess,"set external communication mode failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action -#ifdef VERBOSE - printf("Setting external communication mode to %d\n", arg); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - switch(arg){ -#ifdef EIGERD - case GET_EXTERNAL_COMMUNICATION_MODE: - case AUTO_TIMING: - case TRIGGER_EXPOSURE: - case GATE_FIX_NUMBER: - case BURST_TRIGGER: -#elif JUNGFRAUD - case GET_EXTERNAL_COMMUNICATION_MODE: - case AUTO_TIMING: - case TRIGGER_EXPOSURE: -#endif - retval=setTiming(arg); - break; - default: - ret = FAIL; - sprintf(mess,"Timing mode (%d) is not implemented for this detector\n",(int)arg); - cprintf(RED, "Warning: %s", mess); - break; - } -#ifdef VERBOSE - if(ret==OK) - printf("retval:%d\n",retval); -#endif - if (ret==OK && differentClients==1) - ret=FORCE_UPDATE; - -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int get_id(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum idMode arg=0; - int imod=-1; - int64_t retval=-1; - sprintf(mess,"get id failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - if (arg == MODULE_FIRMWARE_VERSION) { - n = receiveData(file_des,&imod,sizeof(imod),INT32); - if (n < 0) return printSocketReadError(); - } - - // execute action -#ifdef VERBOSE - printf("Getting id %d\n", arg); -#endif - -#ifdef SLS_DETECTOR_FUNCTION_LIST - switch (arg) { -#ifdef MYTHEND - case MODULE_SERIAL_NUMBER: - case MODULE_FIRMWARE_VERSION: -#ifdef VERBOSE - printf("of module %d\n", imod); -#endif - - if (imod>=0 && imod 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Digital Test) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - enum digitalTestMode arg=0; - int imod=-1; - int ival=-1; - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - if (arg == CHIP_TEST) { - n = receiveData(file_des,&imod,sizeof(imod),INT32); - if (n < 0) return printSocketReadError(); - } - - if (arg == DIGITAL_BIT_TEST) { - n = receiveData(file_des,&ival,sizeof(ival),INT32); - if (n < 0) return printSocketReadError(); - } - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } else { -#ifdef VERBOSE - printf("Digital test mode %d\n",arg ); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - switch (arg) { - -#ifdef GOTTHARD - case DIGITAL_BIT_TEST: - retval=0; - break; - -#elif MYTHEND - case CHIP_TEST: -#ifdef VERBOSE - printf("of module %d\n", imod); -#endif - if (imod>=0 && imod 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int enable_analog_out(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Enable Analog Out) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int calibration_pulse(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Calibration Pulse) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - - -int set_dac(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg[3]={-1,-1,-1}; - int val=-1; - enum dacIndex ind=0; - int imod=-1; - double retval[2]={-1,-1}; - int mV=0; - sprintf(mess,"set DAC failed\n"); - - // receive arguments - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - ind=arg[0]; - imod=arg[1]; - mV=arg[2]; - - if (mV) - printf("DAC will be set in mV %d!\n",mV); - else - printf("DAC will be set in DACu! %d\n", mV); - - n = receiveData(file_des,&val,sizeof(val),INT32); - if (n < 0) return printSocketReadError(); - printf("ind = %d val = %d \n", ind,val); - // checks - -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (imod>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - cprintf(RED, "Warning: %s", mess); - } -#endif - - // check if dac exists for this detector - enum DACINDEX idac=0; - idac=ind; - printf("idac=%d, ind=%d \n",idac,ind); - printf("Set DAC of Mythen 3 \n"); - - switch (ind) { - - case M_vIpre: - idac = vIpre; - printf("vIpre\n"); - break; - case M_vIbias: - idac = vIbias; - printf("vIbias \n"); - break; - case PREAMP: - idac = Vrf; - printf("Vrf\n"); - break; - case SHAPER1: - idac = VrfSh; - printf("VrfSh\n"); - break; - case M_vIinSh: - idac = vIinSh; - printf("vIinSh \n"); - break; - case M_VdcSh: - idac = VdcSh; - printf("VdcSh \n"); - break; - case THRESHOLD: - idac = Vth1; - printf("Vth1\n"); - break; - case M_Vth2: - idac = Vth2; - printf("Vth2\n"); - break; - case M_Vth3: - idac = Vth3; - printf("Vth3\n"); - break; - case M_VPL: - idac = VPL; - printf("VPL\n"); - break; - case CALIBRATION_PULSE: // !!! pulse height + 1400 DACu - idac = VPH; - printf("VPH\n"); - break; - case TRIMBIT_SIZE: - idac = Vtrim; - printf("Vtrim\n"); - break; - case M_casSh: - idac = casSh; - printf("casSh\n"); - break; - case M_cas: - idac = cas; - pritnf("cas\n"); - break; - case M_vIbiasSh: - idac = vIbiasSh; - printf("vIbiasSh\n"); - break; - case M_vIcin: - idac = vIcin; - printf("vIcin\n"); - break; - case M_vIpreOut: - idac = vIpreOut; - printf("vIpreOut\n"); - break; - case V_POWER_A: - case V_POWER_B: - //case V_POWER_C: - //case V_POWER_D: - case V_POWER_IO: - case V_POWER_CHIP: - case V_LIMIT: - break; - - default: - if(ind<0){ - ret = FAIL; - sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); - cprintf(RED, "Warning: %s", mess); - } - else{ - printf("The dac has no name yet. \n"); - } - break; - } - - - printf("idac=%d, ind=%d \n",idac,ind); - - // execute action -//#ifdef VERBOSE - printf("Setting DAC %d of module %d to %d \n", idac, imod, val); -//#endif -//#ifdef SLS_DETECTOR_FUNCTION_LIST - double temp; - if (ret==OK) { - if (differentClients && lockStatus && val!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - - if(ind == V_POWER_A || ind == V_POWER_B || ind == V_POWER_IO){ - printf("Setting a power: %d \n",ind); - if(mV){ - - if( val >=0 && val <=vPowerLimit){ - retval[1] = setPower(ind,val); // in mV - retval[0] = retval[1]*4095/2500.; - } - else if(val==-1){ - retval[1] = setPower(ind,val); - retval[0] = retval[1]*4095/2500.; - printf("READ ONLY: val=-1, read %f mV",retval[1]); - } - else{ - printf("********power %d exceeds voltage limits", ind); - } - } - else{ - printf("********power %d should be set in mV instead of DACu", ind); - } - } - else if(ind == V_LIMIT){ - if(mV){ // without safetycheck - retval[1] = setPower(ind, val); - retval[0] = 0; // to avoid wrong error messages - } - else{ - printf("********power %d should be set in mV instead of DACu", ind); - } - } - //dac: - else{ - if(val==-1){ - retval[0]=setDAC(idac,val,imod,mV); - retval[1]=retval[0]*2500./4095; - printf("READ ONLY: val=-1, read %4.0f DAC \n",retval[0]); - } - else if(mV && (val>0 && val<2500)){ // val given in mV, check that val is not out of range - int dacval = (int)val*4095./2500.; // convert to DACu - retval[1] = setDAC(idac,dacval,imod,mV); - retval[0] = retval[1]*4095./2500.; // convert to DACu (for later printout) - } - else if(!mV && (val>0 && val<4095)){ // val given in DACu - retval[0] = setDAC(idac,val,imod,mV); - retval[1] = retval[0] *2500/4095; // convert to mV - } - - //check - if(retval[0]==-1 || retval[1] == -1){// something in setDAC failed (should never occur) - ret = FAIL; - sprintf(mess,"Setting DAC %d of module %d: wrote %d but read %f\n", idac, imod, val, temp); - cprintf(RED, "Warning: %s", mess); - } - if(mV) - temp = retval[1]; - else - temp = retval[0]; - if ((abs(temp-val)<=5) || val==-1) { // ??? - ret=OK; - } - else { - ret = FAIL; - sprintf(mess,"Setting dac %d of module %d: wrote %d but read %f\n", idac, imod, val, temp); - cprintf(RED, "Warning: %s", mess); - } - } // end else dac - } // end else "detector not locked" - } // end if ret==OK -//#endif -//#ifdef VERBOSE - if(ret==OK){ - printf("DAC set to %4.0f in dac units and %f mV\n", retval[0],retval[1]); - } - else{ - printf("ERROR! Not able to set DAC to %4.0f in dac units and %f mV\n", retval[0],retval[1]); - } -//#endif - - if(ret == OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - - -int get_adc(int file_des) { - int ret=OK; //ret1=OK; -// int n=0; -// int arg[2]={-1,-1}; -// int retval=-1; -// enum dacIndex ind=0; -// int imod=-1; -// sprintf(mess,"get ADC failed\n"); - -// // receive arguments -// n = receiveData(file_des,arg,sizeof(arg),INT32); -// if (n < 0) return printSocketReadError(); -// ind=arg[0]; -// imod=arg[1]; - -// #ifdef MYTHEND -// #ifdef SLS_DETECTOR_FUNCTION_LIST -// if (imod>=getTotalNumberOfModules() || imod<0) { -// ret = FAIL; -// sprintf(mess,"Module number %d out of range\n",imod); -// cprintf(RED, "Warning: %s", mess); -// } -// #endif -// #endif - -// enum ADCINDEX iadc=0; -// switch (ind) { -// #ifdef EIGERD -// case TEMPERATURE_FPGAEXT: -// iadc = TEMP_FPGAEXT; -// break; -// case TEMPERATURE_10GE: -// iadc = TEMP_10GE; -// break; -// case TEMPERATURE_DCDC: -// iadc = TEMP_DCDC; -// break; -// case TEMPERATURE_SODL: -// iadc = TEMP_SODL; -// break; -// case TEMPERATURE_SODR: -// iadc = TEMP_SODR; -// break; -// case TEMPERATURE_FPGA: -// iadc = TEMP_FPGA; -// break; -// case TEMPERATURE_FPGA2: -// iadc = TEMP_FPGAFEBL; -// break; -// case TEMPERATURE_FPGA3: -// iadc = TEMP_FPGAFEBR; -// break; -// #endif -// #if defined(GOTTHARD) || defined(JUNGFRAUD) -// case TEMPERATURE_FPGA: -// iadc = TEMP_FPGA; -// break; -// case TEMPERATURE_ADC: -// iadc = TEMP_ADC; -// break; -// #endif -// default: -// ret = FAIL; -// sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); -// cprintf(RED, "Warning: %s", mess); -// break; -// } - -// #ifdef VERBOSE -// printf("Getting ADC %d of module %d\n", iadc, imod); -// #endif -// #ifdef SLS_DETECTOR_FUNCTION_LIST -// if (ret==OK) -// retval=getADC(iadc,imod); -// #endif -// #ifdef VERBOSE -// printf("ADC is %f\n", retval); -// #endif - -// if (ret==OK && differentClients) -// ret=FORCE_UPDATE; - -// // ret could be swapped during sendData -// ret1 = ret; -// // send ok / fail -// n = sendData(file_des,&ret1,sizeof(ret),INT32); -// // send return argument -// if (ret!=FAIL) { -// n += sendData(file_des,&retval,sizeof(retval),INT32); -// } else { -// n += sendData(file_des,mess,sizeof(mess),OTHER); -// } - - // return ok / fail - return ret; -} - - - - - -int write_register(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"write to register failed\n"); - - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - int addr=arg[0]; - int val=arg[1]; - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("writing to register 0x%x data 0x%x\n", addr, val); -#endif - retval=writeRegister(addr,val); - if (retval!=val) { - ret = FAIL; - sprintf(mess,"Writing to register 0x%x failed: wrote 0x%x but read 0x%x\n", addr, val, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif -#ifdef VERBOSE - printf("Data set to 0x%x\n", retval); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; - -} - - - - - -int read_register(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"read register failed\n"); - - // receive arguments - int arg=0; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - int addr=arg; - - // execute action -#ifdef VERBOSE - printf("reading register 0x%x\n", addr); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=readRegister(addr); -#endif -#ifdef VERBOSE - printf("Returned value 0x%x\n", retval); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int write_memory(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Write Memory) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - -int read_memory(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Read Memory) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int set_channel(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set channel failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set Channel) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - sls_detector_channel myChan; - n=receiveChannel(file_des, &myChan); - if (n < 0) return printSocketReadError(); - - // execute action -#ifdef VERBOSE - printf("Setting channel\n"); - printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg); -#endif - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else if (myChan.chan>=getNumberOfChannelsPerChip()) { - ret = FAIL; - sprintf(mess,"channel number %d too large!\n",myChan.chan); - cprintf(RED, "Warning: %s", mess); - } - else if (myChan.chip>=getNumberOfChipsPerModule()) { - ret = FAIL; - sprintf(mess,"chip number %d too large!\n",myChan.chip); - cprintf(RED, "Warning: %s", mess); - } - else if (myChan.module>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"module number %d too large!\n",myChan.module); - cprintf(RED, "Warning: %s", mess); - } - else - retval=setChannel(myChan); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int get_channel(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sls_detector_channel retval; - sprintf(mess,"get channel failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get Channel) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - int ichan=arg[0]; - int ichip=arg[1]; - int imod=arg[2]; -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (ichan>=getNumberOfChannelsPerChip()) { - ret=FAIL; - sprintf(mess, "channel number %d too large!\n",myChan.chan); - cprintf(RED, "Warning: %s", mess); - } else - retval.chan=ichan; - if (ichip>=getNumberOfChipsPerModule()) { - ret=FAIL; - sprintf(mess, "chip number %d too large!\n",myChan.chip); - cprintf(RED, "Warning: %s", mess); - } else - retval.chip=ichip; - - if (imod>=getTotalNumberOfModules()) { - ret=FAIL; - sprintf(mess, "module number %d too large!\n",myChan.module); - cprintf(RED, "Warning: %s", mess); - } else { - retval.module=imod; - ret=getChannel(&retval); -#ifdef VERBOSE - printf("Returning channel %d %d %d, 0x%llx\n", retval.chan, retval.chip, retval.mod, (retval.reg)); -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - ret=sendChannel(file_des, &retval); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - -int set_all_channels(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Set All Channels) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - - - -int set_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set chip failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set Channel) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - sls_detector_chip myChip; - -#ifdef SLS_DETECTOR_FUNCTION_LIST - myChip.nchan=getNumberOfChannelsPerChip(); - int *ch(int*)malloc((myChip.nchan)*sizeof(int)); - myChip.chanregs=ch; - - // receive arguments - n=receiveChip(file_des, &myChip); -#ifdef VERBOSE - printf("Chip received\n"); -#endif - if(n < 0) return FAIL; - - // execute action - if (differentClients==1 && lockStatus==1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else{ -#ifdef VERBOSE - printf("Setting chip\n"); - printf("chip number is %d, module number is %d, register is %d, nchan %d\n",myChip.chip, myChip.module, myChip.reg, myChip.nchan); -#endif - if (myChip.chip>=getNumberOfChipsPerModule()) { - ret = FAIL; - sprintf(mess,"chip number %d too large!\n",myChan.chip); - cprintf(RED, "Warning: %s", mess); - } - else if (myChip.module>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"module number %d too large!\n",myChan.module); - cprintf(RED, "Warning: %s", mess); - } - else - retval=setChip(myChip); - } - free(ch); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int get_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sls_detector_chip retval; - sprintf(mess,"get chip failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set Channel) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - -#ifdef SLS_DETECTOR_FUNCTION_LIST - int ichip=arg[0]; - int imod=arg[1]; - - // execute action - if (ichip>=getNumberOfChipsPerModule()) { - ret = FAIL; - sprintf(mess,"channel number %d too large!\n",myChan.chan); - cprintf(RED, "Warning: %s", mess); - } else - retval.chip=ichip; - - if (imod>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"module number %d too large!\n",imod); - cprintf(RED, "Warning: %s", mess); - } else - retval.module=imod; - - if (ret==OK) - ret=getChip(&retval); -#endif -#ifdef VERBOSE - printf("Returning chip %d %d\n", ichip, imod); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - ret=sendChip(file_des, &retval); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int set_all_chips(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Set All Chips) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - - - -int set_module(int file_des) { - return -1; -} - /*int ret=OK,ret1=OK; - int n=0; - sls_detector_module myModule; - int retval=-1; -#ifdef EIGERD - int myIODelay=-1; - int myTau=-1; - int myEV=-1; -#endif - sprintf(mess,"set module failed\n"); - -#ifdef SLS_DETECTOR_FUNCTION_LIST - int *myDac=NULL; - int *myAdc=NULL; - int *myChip = NULL; - int *myChan = NULL; - - myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int)); - if (getNumberOfDACsPerModule() > 0 && myDac == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate dacs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.dacs=myDac; - myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int)); - if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate adcs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.adcs=myAdc; - //no chips and chans allocated for jungfrau, too much memory -#ifdef JUNGFRAUD - myModule.chipregs=NULL; - myModule.chanregs=NULL; -#else - myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int)); - if (getNumberOfChipsPerModule() > 0 && myChip == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chips\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chipregs=myChip; - myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int)); - if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chans\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chanregs=myChan; -#endif - myModule.nchip=getNumberOfChipsPerModule(); - myModule.nchan=getNumberOfChannelsPerModule(); - myModule.ndac=getNumberOfDACsPerModule(); - myModule.nadc=getNumberOfADCsPerModule(); - - - // receive arguments -#ifdef VERBOSE - printf("Setting module\n"); -#endif - n=receiveModuleGeneral(file_des, &myModule, -#ifdef JUNGFRAUD - 0 //0 is to receive partially (without trimbits etc.) -#else - 1 -#endif - ); - if (n<0) return FAIL; -#ifdef VERBOSE - printf("module number is %d,register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n", - myModule.module, myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset); -#endif -#ifdef EIGERD - n = receiveData(file_des,&myIODelay,sizeof(myIODelay),INT32); - if (n<0) return FAIL; - n = receiveData(file_des,&myTau,sizeof(myTau),INT32); - if (n<0) return FAIL; - n = receiveData(file_des,&myEV,sizeof(myEV),INT32); - if (n<0) return FAIL; -#ifdef VERBOSE - printf("IO Delay:%d\n",myIODelay); - printf("Tau:%d\n",myTau); - printf("eV:%d\n",myEV); -#endif -#endif -#ifndef JUNGFRAUD - } - } -#endif - } - } - - //check settings index - if (ret==OK) { -#ifdef MYTHEND - if (myModule.module>=getNModBoard()) { - ret = FAIL; - sprintf(mess,"Module Number to Set Module (%d) is too large\n", myModule.module); - cprintf(RED, "Warning: %s", mess); - } - if (myModule.module<0) - myModule.module=ALLMOD; -#endif -#if defined(JUNGFRAUD) || defined(EIGERD) - switch(myModule.reg){ - case GET_SETTINGS: - case UNINITIALIZED: -#ifdef EIGERD - case STANDARD: - case HIGHGAIN: - case LOWGAIN: - case VERYHIGHGAIN: - case VERYLOWGAIN: -#elif JUNGFRAUD - case DYNAMICGAIN: - case DYNAMICHG0: - case FIXGAIN1: - case FIXGAIN2: - case FORCESWITCHG1: - case FORCESWITCHG2: -#endif - break; - default: - ret = FAIL; - sprintf(mess,"Setting (%d) is not implemented for this detector\n", myModule.reg); - cprintf(RED, "Warning: %s", mess); - break; - } - } -#endif - - - // execute action - if (ret==OK) { - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef EIGERD - //set dacs, trimbits and iodelay - ret=setModule(myModule, myIODelay); - //set threshhold - if (myEV >= 0) - setThresholdEnergy(myEV,-1); - else { - //changes settings to undefined (loading a random trim file) - setSettings(UNDEFINED,-1); - cprintf(RED,"Settings has been changed to undefined (random trim file)\n"); - } - //rate correction - //switch off rate correction: no value read from load calib/load settings) - if(myTau == -1){ - if(getRateCorrectionEnable()){ - setRateCorrection(0); - ret = FAIL; - strcat(mess,"Cannot set Rate correction. No default tau provided. Deactivating Rate Correction\n"); - cprintf(RED, "Warning: %s", mess); - } - } - //normal tau value (only if enabled) - else{ - setDefaultSettingsTau_in_nsec(myTau); - if (getRateCorrectionEnable()){ - int64_t retvalTau = setRateCorrection(myTau); - if(myTau != retvalTau){ - cprintf(RED,"%s",mess); - ret=FAIL; - } - } - } - retval = getSettings(); -#else - retval=setModule(myModule); - if (retval != myModule.reg) - ret = FAIL; -#endif - if(myChip != NULL) free(myChip); - if(myChan != NULL) free(myChan); - if(myDac != NULL) free(myDac); - if(myAdc != NULL) free(myAdc); - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -}*/ - - - - - - - - - -int get_module(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg=-1; - int imod=-1; - sls_detector_module myModule; - sprintf(mess,"get module failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - imod=arg; - - // execute action -#ifdef SLS_DETECTOR_FUNCTION_LIST - int *myDac=NULL; - int *myAdc=NULL; - int *myChip = NULL; - int *myChan = NULL; - - if (imod<0 || imod>getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"Module Index (%d) is out of range\n", imod); - cprintf(RED, "Warning: %s", mess); - } - else { - myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int)); - if (getNumberOfDACsPerModule() > 0 && myDac == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate dacs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.dacs=myDac; - myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int)); - if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate adcs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.adcs=myAdc; - //no chips and chans allocated for jungfrau, too much memory -#ifdef JUNGFRAUD - myModule.chipregs=NULL; - myModule.chanregs=NULL; -#else - myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int)); - if (getNumberOfChipsPerModule() > 0 && myChip == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chips\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chipregs=myChip; - myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int)); - if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chans\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chanregs=myChan; -#endif - myModule.nchip=getNumberOfChipsPerModule(); - myModule.nchan=getNumberOfChannelsPerModule(); - myModule.ndac=getNumberOfDACsPerModule(); - myModule.nadc=getNumberOfADCsPerModule(); - myModule.module=imod; - getModule(&myModule); -#ifdef VERBOSE - printf("Returning module %d of register %x\n", imod, myModule.reg); -#endif -#ifndef JUNGFRAUD - } - } -#endif - } - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - ret=sendModuleGeneral(file_des, &myModule, -#ifdef JUNGFRAUD - 0 //0 is to receive partially (without trimbits etc.) -#else - 1 -#endif - ); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - -#ifdef SLS_DETECTOR_FUNCTION_LIST - if(myChip != NULL) free(myChip); - if(myChan != NULL) free(myChan); - if(myDac != NULL) free(myDac); - if(myAdc != NULL) free(myAdc); -#endif - - // return ok / fail - return ret; - -} - - - -int set_all_modules(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Set All Modules) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - - -int set_settings(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg[2]={-1,-1}; - int retval=-1; - int imod=-1; - enum detectorSettings isett=-1; - sprintf(mess,"set settings failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - imod=arg[1]; - isett=arg[0]; - - // execute action - if (differentClients && lockStatus && isett!=GET_SETTINGS) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else if (imod>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("Changing settings of module %d to %d\n", imod, isett); -#endif - retval=setSettings(isett, imod); -#ifdef VERBOSE - printf("Settings changed to %d\n", isett); -#endif - if (retval==isett || isett<0) { - ret=OK; - } else { - ret = FAIL; - sprintf(mess,"Changing settings of module %d: wrote %d but read %d\n", imod, isett, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int get_threshold_energy(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"get threshold energy failed\n"); - -#if !defined(MYTHEND) && !defined(EIGERD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get Threshold Energy) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int imod=-1; - n = receiveData(file_des,&imod,sizeof(imod),INT32); - if (n < 0) return printSocketReadError(); - - // execute action -#ifdef VERBOSE - printf("Getting threshold energy of module %d\n", imod); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (imod>=getTotalNumberOfModules()) { - ret=FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - } - else { - retval=getThresholdEnergy(imod); -#ifdef VERBOSE - printf("Threshold is %d eV\n", retval); -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int set_threshold_energy(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set thhreshold energy failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; -#ifdef EIGERD - sprintf(mess,"Function (Set Threshold Energy) is only implemented via Set Settings for this detector\n"); -#else - sprintf(mess,"Function (Set Threshold Energy) is not implemented for this detector\n"); -#endif - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - int ethr=arg[0]; - int imod=arg[1]; - enum detectorSettings isett=arg[2]; - if (differentClients && lockStatus) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else if (imod>=getTotalNumberOfModules()) { - ret=FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - } - else { - printf("Setting threshold energy of module %d to %d eV with settings %d\n", imod, ethr, isett); - retval=setThresholdEnergy(ethr, imod); -#ifdef VERBOSE - printf("Threshold set to %d eV\n", retval); -#endif - if (retval!=ethr) { - ret=FAIL; - sprintf(mess,"Setting threshold of module %d: wrote %d but read %d\n", imod, ethr, retval); - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int start_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"start acquisition failed\n"); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - printf("Starting acquisition\n"); - ret=startStateMachine(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - -int stop_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"stop acquisition failed\n"); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - printf("Stopping acquisition\n"); - ret=stopStateMachine(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int start_readout(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"start readout failed\n"); - -#ifdef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Start Readout) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - printf("Starting readout\n"); - ret=startReadOut(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - - -int get_run_status(int file_des) { - int ret=OK,ret1=OK; - enum runStatus s=ERROR; - - // execute action -#ifdef VERBOSE - printf("Getting status\n"); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - s= getRunStatus(); -#endif - if (differentClients) - ret=FORCE_UPDATE; - - // send ok / fail - sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - sendData(file_des,&s,sizeof(s),INT32); - - // return ok / fail - return ret; -} - - - - - -int start_and_read_all(int file_des) { - int dataret1=FAIL, dataret=FAIL; -#ifdef VERBOSE - printf("Starting and reading all frames\n"); -#endif - - // execute action - if (differentClients && lockStatus) { - dataret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - // ret could be swapped during sendData - dataret1 = dataret; - // send fail - sendData(file_des,&dataret1,sizeof(dataret),INT32); - // send return argument - sendData(file_des,mess,sizeof(mess),OTHER); - // return fail - return dataret; - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - startStateMachine(); - read_all(file_des); -#endif - return OK; -} - - - - -int read_frame(int file_des) { - int dataret1=FAIL, dataret=FAIL; - int n=0; - sprintf(mess, "read frame failed\n"); - - // execute action - if (differentClients && lockStatus) { - dataret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - // ret could be swapped during sendData - dataret1 = dataret; - // send fail - sendData(file_des,&dataret1,sizeof(dataret),INT32); - // send return argument - sendData(file_des,mess,sizeof(mess),OTHER); - // return fail - return dataret; - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - readFrame(&dataret, mess); -#endif - if(dataret == FAIL) - cprintf(RED,"%s\n",mess); - else - cprintf(GREEN,"%s",mess); - - if (differentClients) - dataret=FORCE_UPDATE; - - //dataret could be swapped during sendData - dataret1 = dataret; - // send finished / fail - n=sendData(file_des,&dataret1,sizeof(dataret1),INT32); - if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket - // send return argument - n=sendData(file_des,mess,sizeof(mess),OTHER); - if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket - // return finished / fail - return dataret; -} - - - - -int read_all(int file_des) { -#ifdef SLS_DETECTOR_FUNCTION_LIST - while(read_frame(file_des)==OK) { -#ifdef VERBOSE - printf("frame read\n"); -#endif - ; - } -#endif -#ifdef VERBOSE - printf("Frames finished or failed\n"); -#endif - return OK; -} - - - - -int set_timer(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum timerIndex ind=0; - int64_t tns=-1; - int64_t retval=-1; - sprintf(mess,"set timer failed\n"); - - // receive arguments - n = receiveData(file_des,&ind,sizeof(ind),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,&tns,sizeof(tns),INT64); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && tns!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting timer %d to %lld ns\n",ind,tns); -#endif - switch(ind) { -#ifdef EIGERD - case SUBFRAME_ACQUISITION_TIME: - if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){ - ret=FAIL; - strcpy(mess,"Sub Frame exposure time should not exceed 5.368 seconds\n"); - break; - } -#endif -#ifdef MYTHEN - case PROBES_NUMBER: - case GATES_NUMBER: - case DELAY_AFTER_TRIGGER: -#elif JUNGFRAUD - case DELAY_AFTER_TRIGGER: -#endif - case FRAME_NUMBER: - case ACQUISITION_TIME: // for all detectors - case FRAME_PERIOD: - case CYCLES_NUMBER: - retval = setTimer(ind,tns); - break; - default: - ret = FAIL; - sprintf(mess,"Timer Index (%d) is not implemented for this detector\n", (int) ind); - cprintf(RED, "%s", mess); - break; - } -#if defined(MYTHEND) || defined(GOTTHARD) - if (ret == OK && ind==FRAME_NUMBER) { - ret=allocateRAM(); - if (ret!=OK) { - ret = FAIL; - sprintf(mess,"Could not allocate RAM for %lld frames\n", tns); - cprintf(RED, "%s", mess); - } - } -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT64); - - // return ok / fail - return ret; -} - - - - - - - - - -int get_time_left(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int64_t retval=-1; - sprintf(mess,"get timer left failed\n"); - - - -#ifdef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get Timer Left) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // receive arguments - enum timerIndex ind=0; - n = receiveData(file_des,&ind,sizeof(ind),INT32); - if (n < 0) return printSocketReadError(); - -#ifdef VERBOSE - printf("getting time left on timer %d \n",ind); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - switch(ind) { -#ifdef MYTHEND - case PROBES_NUMBER: -#endif - case FRAME_NUMBER: - case ACQUISITION_TIME: - case FRAME_PERIOD: - case DELAY_AFTER_TRIGGER: -#ifndef JUNGFRAUD - case GATES_NUMBER: -#endif - case CYCLES_NUMBER: - case PROGRESS: - case ACTUAL_TIME: - case MEASUREMENT_TIME: -#ifdef JUNGFRAUD - case FRAMES_FROM_START: - case FRAMES_FROM_START_PG: -#endif - retval=getTimeLeft(ind); - break; - default: - ret = FAIL; - sprintf(mess,"Timer Left Index (%d) is not implemented for this detector\n", (int)ind); - cprintf(RED, "%s", mess); - break; - } -#ifdef VERBOSE - printf("Time left on timer %d is %lld\n",ind, retval); -#endif -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT64); - - // return ok / fail - return ret; -} - - - - - - -int set_dynamic_range(int file_des) { - int ret=OK,ret1=OK; - int rateret=OK,rateret1=OK; - int n=0; - int dr=-1; - int retval=-1; - sprintf(mess,"set dynamic range failed\n"); - - // receive arguments - n = receiveData(file_des,&dr,sizeof(dr),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && dr>=0) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - switch(dr){ - case -1: - case 16: -#ifdef EIGERD - case 4: case 8: case 32: -#endif - break; - default: - ret = FAIL; - sprintf(mess,"Dynamic Range (%d) is not implemented for this detector\n", dr); - cprintf(RED, "Warning: %s", mess); - } - } - if(ret == OK){ -#ifdef EIGERD - int old_dr = setDynamicRange(-1); - retval=setDynamicRange(dr); - if (dr>=0 && retval!=dr) - ret=FAIL; - //look at rate correction only if dr change worked - if((ret==OK) && (dr!=32) && (dr!=16) && (dr!=-1) && (getRateCorrectionEnable())){ - setRateCorrection(0); - rateret = FAIL; - strcpy(mess,"Switching off Rate Correction. Must be in 32 or 16 bit mode\n"); - cprintf(RED,"%s",mess); - }else{ - //setting it if dr changed from 16 to 32 or vice versa with tau value as in rate table - if((dr!=-1) && (old_dr != dr) && getRateCorrectionEnable() && (dr == 16 || dr == 32)){ - setRateCorrection(-1); //tau_ns will not be -1 here - if(!getRateCorrectionEnable()){ - ret = FAIL; - strcpy(mess,"Deactivating Rate Correction. Could not set it.\n"); - cprintf(RED,"%s",mess); - } - } - } - -#else - retval = setDynamicRange(dr); -#endif - if (dr>=0) dataBytes=calculateDataBytes(); - } -#endif - if ((ret == OK) && dr>=0 && retval!=dr) { - ret = FAIL; - cprintf(RED,"%s",mess); - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - //rate correction ret - // ret could be swapped during sendData - rateret1 = rateret; - // send ok / fail - n = sendData(file_des,&rateret1,sizeof(rateret1),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - -int set_readout_flags(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum readOutFlags retval=-1; - sprintf(mess,"set readout flags failed\n"); - -#if !defined(MYTHEND) && !defined(EIGERD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Set Read Out Flags) is not implemented for this detector\n"); - cprintf(RED, "%s",mess); -#else - - // receive arguments - enum readOutFlags arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=GET_READOUT_FLAGS) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting readout flags to %d\n",arg); -#endif - switch(arg) { - case GET_READOUT_FLAGS: -#ifdef MYTHEND - case TOT_MODE: - case NORMAL_READOUT: - case STORE_IN_RAM: - case CONTINOUS_RO: -#elif EIGERD - case STORE_IN_RAM: - case CONTINOUS_RO: - case PARALLEL: - case NONPARALLEL: - case SAFE: -#endif - retval=setReadOutFlags(arg); - break; - default: - ret = FAIL; - sprintf(mess,"Readout Flag Index (%d) is not implemented for this detector\n", (int)arg); - cprintf(RED, "Warning: %s", mess); - break; - } -#endif - if (ret==OK && ((retval == -1) || ((arg!=-1) && ((retval&arg)!=arg)))){ - ret = FAIL; - sprintf(mess,"Could not change readout flag: should be 0x%x but is 0x%x\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - -int set_roi(int file_des) { - int ret=OK,ret1=OK; - int n=0; - strcpy(mess,"set nroi failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Set ROI) is not implemented for this detector\n"); - cprintf(RED, "%s",mess); -#else - - ROI* retval=0; - int retvalsize=0,retvalsize1=0; - - // receive arguments - int nroi=-1; - ROI arg[MAX_ROIS]; - n = receiveData(file_des,&nroi,sizeof(nroi),INT32); - if (n < 0) return printSocketReadError(); - - { - int i; - if(nroi!=-1){ - for(i=0;i=0) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting speed variable %d to %d\n",arg,val); -#endif - switch (arg) { -#ifdef JUNGFRAUD - case ADC_PHASE: - adcPhase(val); - break; -#endif -#ifdef MYTHEND - case CLOCK_DIVIDER: - case WAIT_STATES: - case SET_SIGNAL_LENGTH: - case TOT_CLOCK_DIVIDER: - case TOT_DUTY_CYCLE: -#elif EIGERD - case CLOCK_DIVIDER: -#elif JUNGFRAUD - case CLOCK_DIVIDER: -#endif - retval=setSpeed(arg, val); - if ((retval!=val) && (val>=0)) { - ret=FAIL; - sprintf(mess,"could not change speed variable %d: should be %d but is %d \n",arg, val, retval); - cprintf(RED, "Warning: %s", mess); - } - break; - default: - ret = FAIL; - sprintf(mess,"Speed Index (%d) is not implemented for this detector\n",(int) arg); - cprintf(RED, "Warning: %s", mess); - break; - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int execute_trimming(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"execute trimming failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Execute Trimming) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - int retval=-1; - - // receive arguments - enum trimMode mode=0; - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,&mode,sizeof(mode),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - int imod, par1,par2; - imod=arg[0]; - par1=arg[1]; - par2=arg[2]; - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else if (imod>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"Module Number (%d) is out of range\n"); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("trimming module %d mode %d, parameters %d %d \n",imod,mode, par1, par2); -#endif - switch(mode) { - case NOISE_TRIMMING: - case BEAM_TRIMMING: - case IMPROVE_TRIMMING: - case FIXEDSETTINGS_TRIMMING: - retval=executeTrimming(mode, par1, par2, imod); - if ((ret!=OK) && (retval>0)) { - ret=FAIL; - sprintf(mess,"Could not trim %d channels\n", retval); - cprintf(RED, "Warning: %s", mess); - } - break; - default: - ret = FAIL; - sprintf(mess,"Trimming Mode (%d) is not implemented for this detector\n", (int) mode); - cprintf(RED, "Warning: %s", mess); - break; - } - - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int exit_server(int file_des) { - int ret=FAIL; - sprintf(mess,"Closing Server\n"); - cprintf(BG_RED,"Error: %s",mess); - // send ok / fail - sendData(file_des,&ret,sizeof(ret),INT32); - // send return argument - sendData(file_des,mess,sizeof(mess),OTHER); - return GOODBYE; -} - - - - -int lock_server(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int lock=0; - sprintf(mess,"lock server failed\n"); - - // receive arguments - n = receiveData(file_des,&lock,sizeof(lock),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (lock>=0) { - if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0) { - lockStatus=lock; - strcpy(lastClientIP,thisClientIP); - } else { - ret = FAIL; - sprintf(mess,"Server already locked by %s\n", lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&lockStatus,sizeof(lockStatus),INT32); - - // return ok / fail - return ret; -} - - - - - -int get_last_client_ip(int file_des) { - int ret=OK,ret1=OK; - if (differentClients) - ret=FORCE_UPDATE; - // send ok / fail - sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER); - // return ok / fail - return ret; -} - - - - -int set_port(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum portType p_type=0; - int p_number=-1; - sprintf(mess,"set port failed\n"); - - // receive arguments - n = receiveData(file_des,&p_type,sizeof(p_type),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,&p_number,sizeof(p_number),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - int sd=-1; - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - if (p_number<1024) { - ret = FAIL; - sprintf(mess,"Port Number (%d) too low\n", p_number); - cprintf(RED, "Warning: %s", mess); - } - printf("set port %d to %d\n",p_type, p_number); - sd=bindSocket(p_number); - if (sd<0) { - ret = FAIL; - sprintf(mess,"Could not bind port %d\n", p_number); - cprintf(RED, "Warning: %s", mess); - if (sd==-10) { - ret = FAIL; - sprintf(mess,"Port %d already set\n", p_number); - cprintf(RED, "Warning: %s", mess); - } - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n = sendData(file_des,mess,sizeof(mess),OTHER); - } else { - n = sendData(file_des,&p_number,sizeof(p_number),INT32); - closeConnection(file_des); - exitServer(sockfd); - sockfd=sd; - } - - // return ok / fail - return ret; -} - - - - -int update_client(int file_des) { - int ret=OK; - sendData(file_des,&ret,sizeof(ret),INT32); - return send_update(file_des); -} - - - - -int send_update(int file_des) { - int n=0; // if (n<0) should fail to stop talking to a closed client socket - int nm=0; - int64_t retval = 0; - enum detectorSettings t; - - n = sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - nm=setNMod(GET_FLAG,X); -#endif - n = sendData(file_des,&nm,sizeof(nm),INT32); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - nm=setNMod(GET_FLAG,Y); -#endif - n = sendData(file_des,&nm,sizeof(nm),INT32); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - nm=setDynamicRange(GET_FLAG); -#endif - n = sendData(file_des,&nm,sizeof(nm),INT32); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - dataBytes=calculateDataBytes(); -#endif - n = sendData(file_des,&dataBytes,sizeof(dataBytes),INT32); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - t=setSettings(GET_SETTINGS, GET_FLAG); -#endif - n = sendData(file_des,&t,sizeof(t),INT32); - if (n < 0) return printSocketReadError(); - - -#if defined(MYTHEND) || defined(EIGERD) -#ifdef SLS_DETECTOR_FUNCTION_LIST - nm=getThresholdEnergy(GET_FLAG); -#endif - n = sendData(file_des,&nm,sizeof(nm),INT32); - if (n < 0) return printSocketReadError(); -#endif - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(FRAME_NUMBER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(ACQUISITION_TIME,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); - - -#ifdef EIGERD -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); -#endif - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(FRAME_PERIOD,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); - - -#ifndef EIGERD -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(DELAY_AFTER_TRIGGER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); -#endif - - -#if !defined(EIGERD) && !defined(JUNGFRAUD) -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(GATES_NUMBER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); -#endif - - -#ifdef MYTHEND -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(PROBES_NUMBER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); -#endif - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(CYCLES_NUMBER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); - - - if (lockStatus==0) { - strcpy(lastClientIP,thisClientIP); - } - - return OK; -} - - - - - - -int configure_mac(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-100; - sprintf(mess,"configure mac failed\n"); - -#ifdef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Configure MAC) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - char arg[6][50]; - memset(arg,0,sizeof(arg)); - n = receiveData(file_des,arg,sizeof(arg),OTHER); -#if defined(JUNGFRAUD) || defined(EIGERD) - int pos[3]={0,0,0}; - n = receiveData(file_des,pos,sizeof(pos),INT32); -#endif - if (n < 0) return printSocketReadError(); - - uint32_t ipad; - uint64_t imacadd; - uint64_t idetectormacadd; - uint32_t udpport; - uint32_t udpport2; - uint32_t detipad; - sscanf(arg[0], "%x", &ipad); -#ifdef VIRTUAL - sscanf(arg[1], "%lx", &imacadd); -#else - sscanf(arg[1], "%llx", &imacadd); -#endif - sscanf(arg[2], "%x", &udpport); -#ifdef VIRTUAL - sscanf(arg[3], "%lx", &idetectormacadd); -#else - sscanf(arg[3], "%llx", &idetectormacadd); -#endif - sscanf(arg[4], "%x", &detipad); - sscanf(arg[5], "%x", &udpport2); - - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - int i; - //#ifdef GOTTHARD - //printf("\ndigital_test_bit in server %d\t",digitalTestBit); - //#endif - printf("\nipadd %x\t",ipad); - printf("destination ip is %d.%d.%d.%d = 0x%x \n",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff,ipad); - printf("macad:%llx\n",imacadd); - for (i=0;i<6;i++) - printf("mac adress %d is 0x%x \n",6-i,(unsigned int)(((imacadd>>(8*i))&0xFF))); - printf("udp port:0x%x\n",udpport); - printf("detector macad:%llx\n",idetectormacadd); - for (i=0;i<6;i++) - printf("detector mac adress %d is 0x%x \n",6-i,(unsigned int)(((idetectormacadd>>(8*i))&0xFF))); - printf("detipad %x\n",detipad); - printf("udp port2:0x%x\n",udpport2); - printf("\n"); - //printf("Configuring MAC of module %d at port %x\n", imod, udpport); - -#if defined(JUNGFRAUD) || defined(EIGERD) - printf("Position: [%d,%d,%d]\n", pos[0],pos[1],pos[2]); -#endif -#endif - if(getRunStatus() == RUNNING){ - ret = stopStateMachine(); - } - if(ret==FAIL) { - sprintf(mess,"Could not stop detector acquisition to configure mac\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); //digitalTestBit); - if(retval==-1) { - ret = FAIL; - sprintf(mess,"Configure Mac failed\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - printf("Configure MAC successful\n"); -#if defined(JUNGFRAUD) || defined(EIGERD) - ret = setDetectorPosition(pos); - if (ret == FAIL) { - sprintf(mess,"could not set detector position\n"); - cprintf(RED, "Warning: %s", mess); - } -#endif - } -#ifdef VERBOSE - printf("Configured MAC with retval %d\n", retval); -#endif - } - - } -#endif - if (differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int load_image(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"Loading image failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Load Image) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - enum imageType index=0; - char ImageVals[dataBytes]; - memset(ImageVals,0,dataBytes); - n = receiveData(file_des,&index,sizeof(index),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,ImageVals,dataBytes,OTHER); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - switch (index) { - case DARK_IMAGE : -#ifdef VERBOSE - printf("Loading Dark image\n"); -#endif - case GAIN_IMAGE : -#ifdef VERBOSE - printf("Loading Gain image\n"); -#endif - retval=loadImage(index,ImageVals); - if (retval==-1) { - ret = FAIL; - cprintf(RED, "Warning: %s", mess); - } - break; - default: - ret = FAIL; - sprintf(mess,"Load Image Index (%d) is not implemented for this detector\n", (int)index); - cprintf(RED, "Warning: %s", mess); - break; - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int set_master(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum masterFlags arg=GET_MASTER; - enum masterFlags retval=GET_MASTER; - sprintf(mess,"set master failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && ((int)arg!=(int)GET_MASTER)) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting master flags to %d\n",arg); -#endif - retval=setMaster(arg); - if (retval==GET_MASTER) - ret=FAIL; - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - - -int set_synchronization(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum synchronizationMode arg=GET_SYNCHRONIZATION_MODE; - enum synchronizationMode retval=GET_SYNCHRONIZATION_MODE; - sprintf(mess,"synchronization mode failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && ((int)arg!=(int)GET_SYNCHRONIZATION_MODE)) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting master flags to %d\n",arg); -#endif - retval=setSynchronization(arg); - if (retval==GET_SYNCHRONIZATION_MODE) - ret=FAIL; - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int read_counter_block(int file_des) { - int ret=OK,ret1=OK; - int n=0; - char CounterVals[dataBytes]; - memset(CounterVals,0,dataBytes); - sprintf(mess,"Read counter block failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Read Counter Block) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int startACQ=-1; - n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=readCounterBlock(startACQ,CounterVals); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); -#ifdef VERBOSE - int i; - for(i=0;i<6;i++) - printf("%d:%d\t",i,CounterVals[i]); -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,CounterVals,dataBytes,OTHER); - - // return ok / fail - return ret; -} - - - - - -int reset_counter_block(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Reset counter block failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Reset Counter Block) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int startACQ=-1; - n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=resetCounterBlock(startACQ); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int calibrate_pedestal(int file_des){ - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"calibrate pedestal failed\n"); - - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Calibrate Pedestal) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int frames=-1; - n = receiveData(file_des,&frames,sizeof(frames),INT32); - if (n < 0) return printSocketReadError(); - - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=calibratePedestal(frames); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - - - -int enable_ten_giga(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"Enabling/disabling 10GbE failed\n"); - - // execute action -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Enable 10 GbE) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("Enabling/Disabling 10Gbe :%d \n",arg); -#endif - retval=enableTenGigabitEthernet(arg); - if((arg != -1) && (retval != arg)) { - ret=FAIL; - cprintf(RED, "Warning: %s", mess); - } - else if (differentClients) - ret=FORCE_UPDATE; - } -#endif -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int set_all_trimbits(int file_des){ - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"setting all trimbits failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set All Trimbits) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting all trimbits to %d\n",arg); -#endif - if(arg < -1){ - ret = FAIL; - strcpy(mess,"Cant set trimbits to this value\n"); - cprintf(RED, "Warning: %s", mess); - }else { - if(arg >= 0){ - ret = setAllTrimbits(arg); - //changes settings to undefined - setSettings(UNDEFINED,-1); - cprintf(RED,"Settings has been changed to undefined (change all trimbits)\n"); - } - retval = getAllTrimbits(); - if (arg!=-1 && arg!=retval) { - ret=FAIL; - sprintf(mess,"Could not set all trimbits: should be %d but is %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - -int set_ctb_pattern(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Set CTB Pattern) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int write_adc_register(int file_des) { - int ret=OK, ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"write to adc register failed\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Write ADC Register) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - int addr=arg[0]; - int val=arg[1]; - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("writing to register 0x%x data 0x%x\n", addr, val); -#endif - setAdc(addr,val); -#ifdef VERBOSE - printf("Data set to 0x%x\n", retval); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int set_counter_bit(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set counter bit failed \n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Set Counter Bit) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("Getting/Setting/Resetting counter bit :%d \n",arg); -#endif - retval=setCounterBit(arg); - if((arg != -1) && (retval != arg)) { - ret=FAIL; - cprintf(RED, "Warning: %s", mess); - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int pulse_pixel(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"pulse pixel failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Pulse Pixel) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=pulsePixel(arg[0],arg[1],arg[2]); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int pulse_pixel_and_move(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"pulse pixel and move failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Pulse Pixel and Move) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=pulsePixelNMove(arg[0],arg[1],arg[2]); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - - -int pulse_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"pulse chip failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Pulse Chip) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg = -1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=pulseChip(arg); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int set_rate_correct(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Set rate correct failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Rate Correction) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int64_t tau_ns=-1; - n = receiveData(file_des,&tau_ns,sizeof(tau_ns),INT64); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - printf("Setting rate correction to %lld ns\n",(long long int)tau_ns); - //set rate - //wrong bit mode - if((setDynamicRange(-1)!=32) && (setDynamicRange(-1)!=16) && (tau_ns!=0)){ - ret=FAIL; - strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n"); - cprintf(RED, "Warning: %s", mess); - } - //16 or 32 bit mode - else{ - if(tau_ns < 0) - tau_ns = getDefaultSettingsTau_in_nsec(); - else if(tau_ns > 0){ - //changing tau to a user defined value changes settings to undefined - setSettings(UNDEFINED,-1); - cprintf(RED,"Settings has been changed to undefined (tau changed)\n"); - } - - int64_t retval = setRateCorrection(tau_ns); - if(tau_ns != retval){ - ret=FAIL; - cprintf(RED, "Warning: %s", mess); - } - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n = sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int get_rate_correct(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int64_t retval=-1; - sprintf(mess,"Get Rate correct failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Get Rate Correction) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - -#ifdef SLS_DETECTOR_FUNCTION_LIST - - // execute action - retval = getCurrentTau(); - printf("Getting rate correction %lld\n",(long long int)retval); - -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT64); - - // return ok / fail - return ret; -} - - - - - -int set_network_parameter(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set network parameter failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function(Set Network Parmaeter) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - enum NETWORKINDEX index; - - // receive arguments - enum networkParameter mode=0; - int value=-1; - n = receiveData(file_des,&mode,sizeof(mode),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,&value,sizeof(value),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && value<0) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting network parameter mode %d to %d\n",(int)mode,value); -#endif - switch (mode) { - case DETECTOR_TXN_DELAY_LEFT: - index = TXN_LEFT; - break; - case DETECTOR_TXN_DELAY_RIGHT: - index = TXN_RIGHT; - break; - case DETECTOR_TXN_DELAY_FRAME: - index = TXN_FRAME; - break; - case FLOW_CONTROL_10G: - index = FLOWCTRL_10G; - break; - default: - ret=FAIL; - sprintf(mess,"Network Parameter Index (%d) is not implemented for this detector\n",(int) mode); - cprintf(RED, "Warning: %s", mess); - break; - } - if (ret==OK) { - retval=setNetworkParameter(index, value); - if ((retval!=value) && (value>=0)) { - ret=FAIL; - sprintf(mess,"could not change network parameter mode %d: should be %d but is %d \n",index, value, retval); - cprintf(RED, "Warning: %s", mess); - } - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - -int program_fpga(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"program FPGA failed\n"); - - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Program FPGA) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - size_t filesize = 0; - size_t totalsize = 0; - size_t unitprogramsize = 0; - char* fpgasrc = NULL; - FILE* fp = NULL; - - // receive arguments - filesize - n = receiveData(file_des,&filesize,sizeof(filesize),INT32); - if (n < 0) return printSocketReadError(); - totalsize = filesize; -#ifdef VERY_VERBOSE - printf("\n\n Total size is:%d\n",totalsize); -#endif - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - //opening file pointer to flash and telling FPGA to not touch flash - if(startWritingFPGAprogram(&fp) != OK) { - ret=FAIL; - sprintf(mess,"Could not write to flash. Error at startup.\n"); - cprintf(RED,"%s",mess); - } - - //---------------- first ret ---------------- - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - //---------------- first ret ---------------- - - if(ret!=FAIL) { - //erasing flash - eraseFlash(); - fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE); - } - - //writing to flash part by part - while(ret != FAIL && filesize){ - - unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb - if(unitprogramsize > filesize) //less than 2mb - unitprogramsize = filesize; - #ifdef VERY_VERBOSE - printf("unit size to receive is:%d\n",unitprogramsize); - printf("filesize:%d currentpointer:%d\n",filesize,currentPointer); - #endif - - //receive - n = receiveData(file_des,fpgasrc,unitprogramsize,OTHER); - if (n < 0) return printSocketReadError(); - - if(!(unitprogramsize - filesize)){ - fpgasrc[unitprogramsize]='\0'; - filesize-=unitprogramsize; - unitprogramsize++; - }else - filesize-=unitprogramsize; - - ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp); - - //---------------- middle rets ---------------- - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - cprintf(RED,"Failure: Breaking out of program receiving\n"); - } - //---------------- middle rets ---------------- - - if(ret != FAIL){ - //print progress - printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) ); - fflush(stdout); - } - } - - printf("\n"); - - //closing file pointer to flash and informing FPGA - stopWritingFPGAprogram(fp); - - //free resources - if(fpgasrc != NULL) - free(fpgasrc); - if(fp!=NULL) - fclose(fp); -#ifdef VERY_VERBOSE - printf("Done with program receiving command\n"); -#endif - if (isControlServer) - basictests(debugflag); - init_detector(isControlServer); - } -#endif - if (ret==OK) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int reset_fpga(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Reset FPGA unsuccessful\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Start Readout) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - if (isControlServer) - basictests(debugflag); - init_detector(isControlServer); - ret = FORCE_UPDATE; - } -#endif -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - -int power_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"power chip failed\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Power Chip) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("Power chip to %d\n", arg); -#endif - retval=powerChip(arg); - -#ifdef VERBOSE - printf("Chip powered: %d\n",retval); -#endif - if (retval==arg || arg<0) { - ret=OK; - } else { - ret=FAIL; - sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int set_activate(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"Activate/Deactivate failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Set Activate) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("Setting activate mode of detector to %d\n",arg); -#endif - retval=activate(arg); - if ((retval!=arg) && (arg!=-1)) { - ret=FAIL; - sprintf(mess,"Could not set activate mode to %d, is set to %d\n",arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int prepare_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - strcpy(mess,"prepare acquisition failed\n"); - -#if !defined(GOTTHARDD) && !defined(EIGERD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Prepare Acquisition) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret = prepareAcquisition(); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - -int cleanup_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - strcpy(mess,"prepare acquisition failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else {//to be implemented when used here - ret = FAIL; - sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.h deleted file mode 100755 index bae48f17c..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef SERVER_FUNCS_H -#define SERVER_FUNCS_H - -#include "sls_receiver_defs.h" -#include - -// initialization functions -int printSocketReadError(); -void basictests(int); -void init_detector(int); -// void init_detector(int,int); -int decode_function(int); -const char* getFunctionName(enum detFuncs func); -void function_table(); -int M_nofunc(int); - -// functions called by client -int exec_command(int); -int get_error(int); -int get_detector_type(int); -int set_number_of_modules(int); -int get_max_number_of_modules(int); -int set_external_signal_flag(int); -int set_external_communication_mode(int); -int get_id(int); -int digital_test(int); -int analog_test(int); -int enable_analog_out(int); -int calibration_pulse(int); -int set_dac(int); -int get_adc(int); -int write_register(int); -int read_register(int); -int write_memory(int); -int read_memory(int); -int set_channel(int); -int get_channel(int); -int set_all_channels(int); -int set_chip(int); -int get_chip(int); -int set_all_chips(int); -int set_module(int); -int get_module(int); -int set_all_modules(int); -int set_settings(int); -int get_threshold_energy(int); -int set_threshold_energy(int); -int start_acquisition(int); -int stop_acquisition(int); -int start_readout(int); -int get_run_status(int); -int start_and_read_all(int); -int read_frame(int); -int read_all(int); -int set_timer(int); -int get_time_left(int); -int set_dynamic_range(int); -int set_readout_flags(int); -int set_roi(int); -int set_speed(int); -int execute_trimming(int); -int exit_server(int); -int lock_server(int); -int get_last_client_ip(int); -int set_port(int); -int update_client(int); -int send_update(int); -int configure_mac(int); -int load_image(int); -int set_master(int); -int set_synchronization(int); -int read_counter_block(int); -int reset_counter_block(int); -int calibrate_pedestal(int); -int enable_ten_giga(int); -int set_all_trimbits(int); -int set_ctb_pattern(int); -int write_adc_register(int); -int set_counter_bit(int); -int pulse_pixel(int); -int pulse_pixel_and_move(int); -int pulse_chip(int); -int set_rate_correct(int); -int get_rate_correct(int); -int set_network_parameter(int); -int program_fpga(int); -int reset_fpga(int); -int power_chip(int); -int set_activate(int); -int prepare_acquisition(int); -int cleanup_acquisition(int); - - -#endif diff --git a/slsDetectorSoftware/mythen3DetectorServer/programfpga.h b/slsDetectorSoftware/mythen3DetectorServer/programfpga.h deleted file mode 100755 index db7b1cfb8..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/programfpga.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef PROGRAM_FPGA_H -#define PROGRAM_FPGA_H - -#include "ansi.h" - -#include -#include // usleep -#include - - -/* global variables */ -#define CTRL_SRVR_INIT_TIME_US (300 * 1000) -int gpioDefined=0; -char mtdvalue[10]; - - - -/** - * Define GPIO pins if not defined - */ -void defineGPIOpins(){ - if (!gpioDefined) { - //define the gpio pins - system("echo 7 > /sys/class/gpio/export"); - system("echo 9 > /sys/class/gpio/export"); - //define their direction - system("echo in > /sys/class/gpio/gpio7/direction"); - system("echo out > /sys/class/gpio/gpio9/direction"); - printf("gpio pins defined\n"); - gpioDefined = 1; - }else printf("gpio pins already defined earlier\n"); -} - -/** - * Notify FPGA to not touch flash - */ -void FPGAdontTouchFlash(){ - //tell FPGA to not touch flash - system("echo 0 > /sys/class/gpio/gpio9/value"); - //usleep(100*1000); -} - - -/** - * Notify FPGA to program from flash - */ -void FPGATouchFlash(){ - //tell FPGA to touch flash to program itself - system("echo 1 > /sys/class/gpio/gpio9/value"); -} - -/** - * Reset FPGA - */ -void resetFPGA(){ - cprintf(BLUE,"\n*** Reseting FPGA ***\n"); - FPGAdontTouchFlash(); - FPGATouchFlash(); - usleep(CTRL_SRVR_INIT_TIME_US); -} - -/** - * Erasing flash - */ -void eraseFlash(){ -#ifdef VERY_VERBOSE - printf("\nErasing Flash\n"); -#endif - char command[255]; - sprintf(command,"flash_eraseall %s",mtdvalue); - system(command); - printf("flash erased\n"); -} - -/** - * Open the drive to copy program and - * notify FPGA not to touch the program - * @param filefp pointer to flash - * @return 0 for success, 1 for fail (cannot open file for writing program) - */ -int startWritingFPGAprogram(FILE** filefp){ -#ifdef VERY_VERBOSE - printf("\nStart Writing of FPGA program\n"); -#endif - - //getting the drive - char output[255]; - FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r"); - fgets(output, sizeof(output), fp); - pclose(fp); - strcpy(mtdvalue,"/dev/"); - char* pch = strtok(output,":"); - if(pch == NULL){ - cprintf(RED,"Could not get mtd value\n"); - return FAIL; - } - strcat(mtdvalue,pch); - printf ("\nFlash drive found: %s\n",mtdvalue); - - FPGAdontTouchFlash(); - - //writing the program to flash - *filefp = fopen(mtdvalue, "w"); - if(*filefp == NULL){ - cprintf(RED,"Unable to open %s in write mode\n",mtdvalue); - return 1; - } - printf("flash ready for writing\n"); - - return 0; -} - -/** - * When done writing the program, close file pointer and - * notify FPGA to pick up the program from flash - * @param filefp pointer to flash - */ -void stopWritingFPGAprogram(FILE* filefp){ -#ifdef VERY_VERBOSE - printf("\nStopping of writing FPGA program\n"); -#endif - - int wait = 0; - if(filefp!= NULL){ - fclose(filefp); - wait = 1; - } - - //touch and program - FPGATouchFlash(); - - if(wait){ -#ifdef VERY_VERBOSE - printf("Waiting for FPGA to program from flash\n"); -#endif - //waiting for success or done - char output[255]; - int res=0; - while(res == 0){ - FILE* sysFile = popen("cat /sys/class/gpio/gpio7/value", "r"); - fgets(output, sizeof(output), sysFile); - pclose(sysFile); - sscanf(output,"%d",&res); -#ifdef VERY_VERBOSE - printf("gpi07 returned %d\n",res); -#endif - } - } - printf("FPGA has picked up the program from flash\n\n"); -} - - -/** - * Write FPGA Program to flash - * @param fpgasrc source program - * @param fsize size of program - * @param filefp pointer to flash - * @return 0 for success, 1 for fail (cannot write) - */ -int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){ -#ifdef VERY_VERBOSE - printf("\nWriting of FPGA Program\n"); - cprintf(BLUE,"address of fpgasrc:%p\n",(void *)fpgasrc); - cprintf(BLUE,"fsize:%d\n",fsize); - cprintf(BLUE,"pointer:%p\n",(void*)filefp); -#endif - - if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){ - cprintf(RED,"Could not write FPGA source to flash\n"); - return 1; - } -#ifdef VERY_VERBOSE - cprintf(BLUE, "program written to flash\n"); -#endif - return 0; -} - -#endif //PROGRAM_FPGA_H diff --git a/slsDetectorSoftware/mythen3DetectorServer/programfpga.h b/slsDetectorSoftware/mythen3DetectorServer/programfpga.h new file mode 120000 index 000000000..72c54d21d --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/programfpga.h @@ -0,0 +1 @@ +../slsDetectorServer/programfpga.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c new file mode 100644 index 000000000..fbc6f1a6a --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c @@ -0,0 +1,1304 @@ +//#ifdef SLS_DETECTOR_FUNCTION_LIST + + +#include "slsDetectorFunctionList.h" +#include "gitInfoMythen3.h" + + +#include "AD9257.h" // include "commonServerFunctions.h", which in turn includes "blackfin.h" +#include "programfpga.h" +#include "RegisterDefs.h" + +/* global variables */ +sls_detector_module *detectorModules=NULL; +int *detectorChips=NULL; +int *detectorChans=NULL; +dacs_t *detectorDacs=NULL; +dacs_t *detectorAdcs=NULL; + +enum detectorSettings thisSettings; +enum masterFlags masterMode = NO_MASTER; +int32_t clkPhase[2] = {0, 0}; +int vlimit = -1; + + + +/* basic tests */ + +void checkFirmwareCompatibility(int flag) { + + defineGPIOpins(); + resetFPGA(); + if (mapCSP0() == FAIL) { + cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); + exit(EXIT_FAILURE); + } + + // does check only if flag is 0 (by default), set by command line + if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { + cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); + exit(EXIT_FAILURE); + } + + uint32_t ipadd = getDetectorIP(); + uint64_t macadd = getDetectorMAC(); + int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION); + int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION); + //int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION); + cprintf(BLUE,"\n\n" + "********************************************************\n" + "****************** Mythen3 Server *********************\n" + "********************************************************\n\n" + + "Detector IP Addr:\t\t 0x%x\n" + "Detector MAC Addr:\t\t 0x%llx\n" + + "Firmware Version:\t\t 0x%llx\n" + "Software Version:\t\t 0x%llx\n" + //"F/w-S/w API Version:\t\t 0x%llx\n" + //"Required Firmware Version:\t 0x%x\n" + "\n" + "********************************************************\n", + hversion, hsnumber, + ipadd, macadd, + fwversion, swversion + //, sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION + ); + + +/* + * printf("Testing firmware capability... "); + //cant read versions + if(!fwversion || !sw_fw_apiversion){ + cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n"); + cprintf(RED,"Exiting Server. Goodbye!\n\n"); + exit(-1); + } + + //check for API compatibility - old server + if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){ + cprintf(RED,"FATAL ERROR: This software version is incompatible.\n" + "Please update it to be compatible with this firmware\n\n"); + cprintf(RED,"Exiting Server. Goodbye!\n\n"); + exit(-1); + } + + //check for firmware compatibility - old firmware + if( REQUIRED_FIRMWARE_VERSION > fwversion){ + cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n" + "Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION); + cprintf(RED,"Exiting Server. Goodbye!\n\n"); + exit(-1); + } +*/ +} + + +int checkType() { + volatile u_int32_t type = ((bus_r(FPGA_VERSION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST); + if (type != JUNGFRAUCTB){ + cprintf(BG_RED,"This is not a Mythen 3 Server (read %d, expected %d)\n",type, JUNGFRAUCTB); + return FAIL; + } + + return OK; +} + + + +u_int32_t testFpga(void) { + printf("\nTesting FPGA...\n"); + + //fixed pattern + int ret = OK; + volatile u_int32_t val = bus_r(FIX_PATT_REG); + if (val == FIX_PATT_VAL) { + printf("Fixed pattern: successful match 0x%08x\n",val); + } else { + cprintf(RED,"Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n", val, FIX_PATT_VAL); + ret = FAIL; + } + return ret; +} + + +int testBus() { + printf("\nTesting Bus...\n"); + + int ret = OK; + u_int32_t addr = SET_DELAY_LSB_REG; + int times = 1000 * 1000; + int i = 0; + + for (i = 0; i < times; ++i) { + bus_w(addr, i * 100); + if (i * 100 != bus_r(SET_DELAY_LSB_REG)) { + cprintf(RED,"ERROR: Mismatch! Wrote 0x%x, read 0x%x\n", i * 100, bus_r(SET_DELAY_LSB_REG)); + ret = FAIL; + } + } + + if (ret == OK) + printf("Successfully tested bus %d times\n", times); + return ret; +} + + + + +int detectorTest( enum digitalTestMode arg){ + switch(arg){ + case DETECTOR_FIRMWARE_TEST: return testFpga(); + case DETECTOR_BUS_TEST: return testBus(); + default: + cprintf(RED,"Warning: Test not implemented for this detector %d\n", (int)arg); + break; + } + return OK; +} + + + + + +/* Ids */ + +int64_t getDetectorId(enum idMode arg){ + int64_t retval = -1; + + switch(arg){ + case DETECTOR_SERIAL_NUMBER: + retval = getDetectorMAC(); + break; + case DETECTOR_FIRMWARE_VERSION: + retval = getFirmwareVersion(); + break; + //case SOFTWARE_FIRMWARE_API_VERSION: + //return GetFirmwareSoftwareAPIVersion(); + case DETECTOR_SOFTWARE_VERSION: + retval= GITREV; + retval= (retval <<32) | GITDATE; + break; + default: + break; + } + + return retval; +} + +u_int64_t getFirmwareVersion() { + return ((bus_r(FPGA_VERSION_REG) & BOARD_REVISION_MSK) >> BOARD_REVISION_OFST); +} + + + +u_int64_t getDetectorMAC() { + char output[255],mac[255]=""; + u_int64_t res=0; + FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r"); + fgets(output, sizeof(output), sysFile); + pclose(sysFile); + //getting rid of ":" + char * pch; + pch = strtok (output,":"); + while (pch != NULL){ + strcat(mac,pch); + pch = strtok (NULL, ":"); + } + sscanf(mac,"%llx",&res); + return res; +} + +u_int32_t getDetectorIP(){ + char temp[50]=""; + u_int32_t res=0; + //execute and get address + char output[255]; + FILE* sysFile = popen("ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2", "r"); + fgets(output, sizeof(output), sysFile); + pclose(sysFile); + + //converting IPaddress to hex. + char* pcword = strtok (output,"."); + while (pcword != NULL) { + sprintf(output,"%02x",atoi(pcword)); + strcat(temp,output); + pcword = strtok (NULL, "."); + } + strcpy(output,temp); + sscanf(output, "%x", &res); + //printf("ip:%x\n",res); + + return res; +} + + + + + + + + +/* initialization */ + +void initControlServer(){ + clkPhase[0] = 0; clkPhase[1] = 0; + setupDetector(); + printf("\n"); +} + + + +void initStopServer() { + + usleep(CTRL_SRVR_INIT_TIME_US); + if (mapCSP0() == FAIL) { + cprintf(BG_RED, "Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"); + exit(EXIT_FAILURE); + } +} + + + + + + +/* set up detector */ + +void allocateDetectorStructureMemory(){ + printf("This Server is for 1 Jungfrau module (500k)\n"); + + //Allocation of memory + if (detectorModules!=NULL) free(detectorModules); + if (detectorChans!=NULL) free(detectorChans); + if (detectorChips!=NULL) free(detectorChips); + if (detectorDacs!=NULL) free(detectorDacs); + if (detectorAdcs!=NULL) free(detectorAdcs); + detectorModules=malloc(sizeof(sls_detector_module)); + detectorChips=malloc(NCHIP*sizeof(int)); + detectorChans=malloc(NCHIP*NCHAN*sizeof(int)); + detectorDacs=malloc(NDAC*sizeof(dacs_t)); + detectorAdcs=malloc(NADC*sizeof(dacs_t)); +#ifdef VERBOSE + printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n); + printf("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs+n*NDAC); + printf("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs+n*NADC); +#endif + (detectorModules)->dacs=detectorDacs; + (detectorModules)->adcs=detectorAdcs; + (detectorModules)->ndac=NDAC; + (detectorModules)->nadc=NADC; + (detectorModules)->nchip=NCHIP; + (detectorModules)->nchan=NCHIP*NCHAN; + (detectorModules)->module=0; + (detectorModules)->gain=0; + (detectorModules)->offset=0; + (detectorModules)->reg=0; + thisSettings = UNINITIALIZED; + + // if trimval requested, should return -1 to acknowledge unknown + int ichan=0; + for (ichan=0; ichan<(detectorModules->nchan); ichan++) { + *((detectorModules->chanregs)+ichan) = -1; + } +} + + + +void setupDetector() { + + allocateDetectorStructureMemory(); + + resetPLL(); + resetCore(); + resetPeripheral(); + cleanFifos(); + + //initialize dac series + initDac(0); + initDac(8); + initDac(16); + + //set dacs + printf("Setting Default Dac values\n"); + { + int i = 0; + int retval[2]={-1,-1}; + const int defaultvals[NDAC] = DEFAULT_DAC_VALS; + for(i = 0; i < NDAC; ++i) { + setDAC((enum DACINDEX)i,defaultvals[i],0,0,retval); + if (retval[0] != defaultvals[i]) + cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]); + } + } + + /*setSamples(1); + bus_w(DAC_REG,0xffff); + setSpeed + cleanFifos(); /* todo might work without + resetCore(); /* todo might work without */ + + //Initialization of acquistion parameters + setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES); + setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES); + setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME); + setTimer(FRAME_PERIOD, DEFAULT_PERIOD); + setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY); +} + + + + + + + +/* firmware functions (resets) */ + +int powerChip (int on){ + + /* set all the required voltages */ + return 0; +} + + +void cleanFifos() { printf("\nClearing Acquisition Fifos - Not doing anything\n"); + /* printf("\nClearing Acquisition Fifos\n"); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_ACQ_FIFO_CLR_MSK);*/ +} + +void resetCore() {printf("\nResetting Core - Not doing anything\n"); + /*printf("\nResetting Core\n"); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CORE_RST_MSK); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_CORE_RST_MSK);*/ +} + +void resetPeripheral() {printf("\nResetting Peripheral - Not doing anything\n"); + /* printf("\nResetting Peripheral\n"); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PERIPHERAL_RST_MSK); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_PERIPHERAL_RST_MSK);*/ +} + +int getPhase(int i) { + if (i>=0 && i<4) + return clkPhase[i]; + else + return -1; +} + + +int configurePhase(int val, int i) { /** compare with old jungfrau software and add in */ + + u_int32_t l=0x0c; + u_int32_t h=0x0d; + u_int32_t vv; + int32_t phase=0, inv=0; + + u_int32_t tot; + u_int32_t odd=1;//0; + + if (i<0 || i>3) + return -1; + + if (val>65535 || val<-65535) + return clkPhase[i]; + + resetPLL(); + + setPllReconfigReg(PLL_MODE_REG, 1, 0); + printf("phase in %d\n",clkPhase[1]); + + if (val>0) { + inv=0; + phase=val&0xffff; + } else { + inv=0; + val=-1*val; + phase=(~val)&0xffff; + } + + + vv=phase | (i<<16);// | (inv<<21); + + setPllReconfigReg(PLL_PHASE_SHIFT_REG,vv,0); + + clkPhase[i]=val; + return clkPhase[i]; +} + + + +int configureFrequency(int val, enum CLKINDEX i) { /** compare with old jungfrau software and add in */ + + + u_int32_t l=0x0c; + u_int32_t h=0x0d; + u_int32_t vv; + int32_t phase=0, inv=0; + + u_int32_t tot; + u_int32_t odd=1;//0; + printf("Want to configure frequency of counter %d to %d\n",i,val); + // printf("PLL reconfig reset\N"); bus_w(PLL_CNTRL_REG,(1<3) { + printf("wrong counter number %d\n",i); + return -1; + } + + if (val<=0) { + + printf("get value %d %d \n",i,clkDivider[i]); + return clkDivider[i]; + } + if (i==adc_clk_c){ + if (val>40) + { + printf("Too high frequency %d MHz for these ADCs!\n", val); + return clkDivider[i]; + } + } + + tot= PLL_VCO_FREQ_MHZ/val; + l=tot/2; + h=l; + if (tot>2*l) { + h=l+1; + odd=1; + } + else + { + odd=0; + } + + printf("Counter %d: Low is %d, High is %d\n",i, l,h); + + + vv= (i<<18)| (odd<<17) | l | (h<<8); + + printf("Counter %d, val: %08x\n", i, vv); + setPllReconfigReg(PLL_C_COUNTER_REG, vv,0); + + + usleep(10000); + + resetPLL(); + + clkDivider[i]=PLL_VCO_FREQ_MHZ/(l+h); + + printf("Frequency of clock %d is %d\n", i, clkDivider[i]); + + return clkDivider[i]; +} + + + + + + + + +/* set parameters - nmod, dr, roi */ + +int setNMod(int nm, enum dimension dim){ + return NMOD; +} + + +int getNModBoard(enum dimension arg){ + return NMAXMOD; +} + + +int setDynamicRange(int dr){ + /* edit functionality */ + return 16; +} + + + + +/* parameters - readout */ + +int setSpeed(enum speedVariable arg, int val) { + int retval = -1; + + switch (arg) { + case DBIT_PHASE: + if (val==-1) + retval=getPhase(DBIT_CLK_C); + else + retval=configurePhase(val,DBIT_CLK_C); + break; + case DBIT_CLOCK: + retval=configureFrequency(val,DBIT_CLK_C); + if (configureFrequency(-1,SYNC_CLK_C)>retval){ + configureFrequency(retval,SYNC_CLK_C); + printf("--Configuring sync clk to %d MHz\n",val); + } else if (configureFrequency(-1,ADC_CLK_C)>retval && configureFrequency(-1,RUN_CLK_C)>retval) { + printf("++Configuring sync clk to %d MHz\n",val); + configureFrequency(retval,SYNC_CLK_C); + } + break; + default: + sprintf(mess,"Unknown speed parameter %d",arg); + break; + } + return retval; +} + + + + + + +/* parameters - timer */ + +int64_t setTimer(enum timerIndex ind, int64_t val) { + + int64_t retval = -1; + switch(ind){ + + case FRAME_NUMBER: + if(val >= 0) + printf("\nSetting #frames: %lld\n",(long long int)val); + retval = set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG); + printf("Getting #frames: %lld\n",(long long int)retval); + break; + + case ACQUISITION_TIME: + if(val >= 0){ + printf("\nSetting exptime: %lldns\n", (long long int)val); + val *= (1E-3 * CLK_RUN); /* ?? */ + } + retval = set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) / (1E-3 * CLK_RUN); + printf("Getting exptime: %lldns\n", (long long int)retval); + break; + + case FRAME_PERIOD: + if(val >= 0){ + printf("\nSetting period to %lldns\n",(long long int)val); + val *= (1E-3 * CLK_SYNC); /* ?? */ + } + retval = set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG )/ (1E-3 * CLK_SYNC); + printf("Getting period: %lldns\n", (long long int)retval); + break; + + case DELAY_AFTER_TRIGGER: + if(val >= 0){ + printf("\nSetting delay to %lldns\n", (long long int)val); + val *= (1E-3 * CLK_SYNC); /* ?? */ + } + retval = set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC); + printf("Getting delay: %lldns\n", (long long int)retval); + break; + + case CYCLES_NUMBER: + if(val >= 0) + printf("\nSetting #cycles to %lld\n", (long long int)val); + retval = set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG); + printf("Getting #cycles: %lld\n", (long long int)retval); + break; + + case GATES_NUMBER: + if(val >= 0) + printf("\nSetting #gates to %lld\n", (long long int)val); + retval = set64BitReg(val, SET_GATES_LSB_REG, SET_GATES_MSB_REG); + printf("Getting #gates: %lld\n", (long long int)retval); + break; + + case PROBES_NUMBER: /* does not exist in firmware_funcs.c*/ + /*if(val >= 0) + printf("\nSetting #probes to %lld\n", (long long int)val); + retval = set64BitReg(val, SET_PROBES_LSB_REG, SET_PROBES_MSB_REG); + printf("Getting #probes: %lld\n", (long long int)retval); + */ + break; + + case SAMPLES_JCTB: + if(val >= 0) + printf("\nSetting #samples to %lld\n", (long long int)val); + retval = bus_w(NSAMPLES_REG, val); + printf("Getting #samples: %lld\n", (long long int)retval); + + break; + + default: + cprintf(RED,"Warning: Timer Index not implemented for this detector: %d\n", ind); + break; + } + + return retval; + +} + + + +int64_t getTimeLeft(enum timerIndex ind){ + int64_t retval = -1; + switch(ind){ + + case FRAME_NUMBER: + retval = get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG); + printf("Getting number of frames left: %lld\n",(long long int)retval); + break; + + case FRAME_PERIOD: + retval = get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) / (1E-3 * CLK_SYNC); + printf("Getting period left: %lldns\n", (long long int)retval); + break; + + case DELAY_AFTER_TRIGGER: + retval = get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC); + printf("Getting delay left: %lldns\n", (long long int)retval); + break; + + /** acquisition time and period gives in time left in func.c, pls check with anna */ + + case CYCLES_NUMBER: + retval = get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG); + printf("Getting number of cycles left: %lld\n", (long long int)retval); + break; + + case ACTUAL_TIME: + retval = get64BitReg(GET_ACTUAL_TIME_LSB_REG, GET_ACTUAL_TIME_MSB_REG) / (1E-9 * CLK_SYNC); + printf("Getting actual time (time from start): %lld\n", (long long int)retval); + break; + + case MEASUREMENT_TIME: + retval = get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG) / (1E-9 * CLK_SYNC); + printf("Getting measurement time (timestamp/ start frame time): %lld\n", (long long int)retval); + break; + + case FRAMES_FROM_START: + retval = get64BitReg(FRAMES_FROM_START_LSB_REG, FRAMES_FROM_START_MSB_REG); + printf("Getting frames from start run control %lld\n", (long long int)retval); + break; + + case FRAMES_FROM_START_PG: /** ask anna, seems to be calling previous function (frames_from_start) */ + retval = get64BitReg(FRAMES_FROM_START_PG_LSB_REG, FRAMES_FROM_START_PG_MSB_REG); + printf("Getting frames from start run control %lld\n", (long long int)retval); + break; + + default: + cprintf(RED, "Warning: Remaining Timer index not implemented for this detector: %d\n", ind); + break; + } + + return retval; +} + + + + + + +/* parameters - channel, chip, module, settings */ + + +int setModule(sls_detector_module myMod){ + return thisSettings; +} + + +int getModule(sls_detector_module *myMod){ + return OK; +} + + + +enum detectorSettings setSettings(enum detectorSettings sett, int imod){ + return getSettings(); + +} + + +enum detectorSettings getSettings(){ + return thisSettings; +} + + + + + +/* parameters - dac, adc, hv */ + + + + + + +void initDac(int dacnum) { + printf("\nInitializing dac for %d to \n",dacnum); + + u_int32_t codata; + int csdx = dacnum / NDAC_PER_SET + DAC_SERIAL_CS_OUT_OFST; //,so can be DAC_SERIAL_CS_OUT_OFST or +1 + int dacchannel = 0xf; // all channels + int dacvalue = 0x6; // can be any random value (just writing to power up) + printf(" Write to Input Register\n" + " Chip select bit:%d\n" + " Dac Channel:0x%x\n" + " Dac Value:0x%x\n", + csdx, dacchannel, dacvalue); + + codata = LTC2620_DAC_CMD_WRITE + // command to write to input register + ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) + // all channels + ((dacvalue << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK); // any random value + serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS, + DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); +} + + + + + + + + + +int voltageToDac(int value){ + int vmin = 0; + int vmax = MAX_DACVOLTVAL; + int nsteps = MAX_DACVAL; + if ((value < vmin) || (value > vmax)) { + cprintf(RED,"Voltage value (to convert to dac value) is outside bounds: %d\n", value); + return -1; + } + return (int)(((value - vmin) / (vmax - vmin)) * (nsteps - 1) + 0.5); +} + +int dacToVoltage(unsigned int digital){ + int vmin = 0; + int vmax = MAX_DACVOLTVAL; + int nsteps = MAX_DACVAL; + int v = vmin + (vmax - vmin) * digital / (nsteps - 1); + if((v < 0) || (v > nsteps - 1)) { + cprintf(RED,"Voltage value (converted from dac value) is outside bounds: %d\n", v); + return -1; + } + return v; +} + +int powerToDac(int value, int chip) { + int nsteps = MAX_DACVAL; + int vchip = MAX_VCHIPVAL - (getDacRegister(V_CHIP)*1000)/(nsteps -1); + printf("Current V_Chip: %d mV\n",vchip); + + int vmax = vchip - MIN_VCHIP_OFSTVAL; + int vmin = MIN_VCHIP_VAL; + + // recalculating only for v_chip + if (chip) { + printf("vchip\n"); + vmax = MAX_VCHIPVAL; + vmin = MAX_VCHIPVAL - 1000; + } + else + printf("vpower\n"); + + int v = (int)(((vmax - value) * (nsteps - 1) / (vmax - vmin)) ); /***+0.5 removed is this correct? seems different from voltageToDac maybe get rid of 0.5*/ + + + if (v < 0) v = 0; + if (v > nsteps - 1) v = nsteps - 1; + if (value == -100) v = -100; + + return v; +} + +int dacToPower(int value, int chip) { + int retval1 = -1; + int nsteps = MAX_DACVAL; + int vchip = MAX_VCHIPVAL - (getDacRegister(V_CHIP)*1000)/(nsteps -1); + printf("Vchip id %d mV\n",vmax); + int vmax = vchip - MIN_VCHIP_OFSTVAL; + int vmin = MIN_VCHIP_VAL; + + // recalculating only for v_chip + if (chip) { + printf("vchip\n"); + vmax = MAX_VCHIPVAL; + vmin = MAX_VCHIPVAL - 1000; + } + else + printf("vpower\n"); + + retval1 = vmax - (value * (vmax - vmin)) / (nsteps - 1); + if (retval1 > vmax) retval1 = vmax; + if (retval1 < vmin) retval1 = vmin; + if (value < 0) retval1 = value; + return retval1; +} + + + +void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){ + + int dacval = val; + + // dacs: if set and mv, convert to dac + if (ind < val > 0 && mV) { + val = voltageToDac(val); //gives -1 on error + } + + + if ( (val >= 0) || (val == -100)) { + + + u_int32_t ichip = 2 - ind / NDAC_PER_SET; + u_int32_t valw = 0; + int i; + + // start and chip select bar down ----------------- + SPIChipSelect (valw, SPI_REG, (0x1 << csdx)); + + + // next dac -------------------------------------- + for (i = 0; i < ichip; ++i) { + printf("%d next DAC\n", i); + sendDataToSPI (valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS, + DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); + } + + + // this dac ---------------------------------------- + u_int32_t codata; + int csdx = DAC_SERIAL_CS_OUT_OFST; + int dacchannel = ind % NDAC_PER_SET; + + printf("\nSetting of DAC %d : %d dac units (%d mV)\n",ind, dacval, val); + // command + if (val >= 0) { + printf(" Write to Input Register and Update\n"); + codata = LTC2620_DAC_CMD_SET; + + } else if (val == -100) { + printf(" POWER DOWN\n"); + codata = LTC2620_DAC_CMD_POWER_DOWN; + } + // address + printf(" Chip select bit:%d\n" + " Dac Channel:0x%x\n" + " Dac Value:0x%x\n", + csdx, dacchannel, val); + codata += ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) + + ((val << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK); + // to spi + serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS, + DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); + + + printf("--------done setting dac set %d \n",i); + + // next dac ----------------------------------------------------------- + for (i = ichip+1; i < (N_DAC / NDAC_PER_SET); ++i) { + printf("%d next DAC\n", i); + sendDataToSPI (valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS, + DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); + } + + + //chip select bar up, clk down and stop -------------------------------- + SPIChipDeselect (valw, SPI_REG, (0x1 << csdx), DAC_SERIAL_CLK_OUT_MSK); + + // writes to register + setDacRegister(ind, dacval); + } + + // reading dac value from register + printf("Getting DAC %d : ",ind); + retval[0] = getDacRegister(ind); printf("%d dac units ", retval[0]); + retval[1] = dacToVoltage(retval[0]);printf("(%d mV)\n", retval[1]); +} + + +int setPower(enum DACINDEX ind, int val) { + + // not implemented yet + if ((ind == V_D) || (ind == V_C)) + return -1; + + // vlimit software limit + else if (ind == V_LIMIT) { + if (val >= 0) + vlimit = val; + return vlimit; + } + + int pwrindex = -1; + int dacval = val; + int retval=-1, retval1=-1; + u_int32_t preg = 0; + int temp[2] = {-1,-1}; + + // get + if (val == -1) + dacval = -1; + + // vchip + else if (ind == V_CHIP) + dacval = powerToDac(val, 1); + + // power a, b, c , d, io + else { + dacval = powerToDac(val, 0); + + switch (ind) { + case V_IO: pwrindex = 0;break; + case V_A: pwrindex = 1; break; + case V_B: pwrindex = 2; break; + default:break; + } + + // shut down + preg = bus_r(POWER_ON_REG); + printf("power reg is %08x\n",bus_r(POWER_ON_REG)); + printf("Switching off power %d\n", ind); + bus_w(POWER_ON_REG,preg &(~(1 << (POWER_ENABLE_OFST + pwrindex)))); + setDac(ind,-100, 0, 1, temp); + printf("power reg is %08x\n",bus_r(POWER_ON_REG)); + retval=0; + } + + // actual setting + if (val != -100) { + printf("Setting power %d to %d mV (%d dac val)\n",ind, val, dacval); + retval = setDac(ind, dacval); + // setting power a, b, c, d, io + if (pwrindex >= 0 && dacval >= 0 ) { + preg = bus_r(POWER_ON_REG); + printf("power reg is %08x\n", bus_r(POWER_ON_REG)); + printf("Switching on power %d\n", pwrindex); + bus_w(POWER_ON_REG, preg | ((1 << (POWER_ENABLE_OFST + pwrindex)))); + printf("power reg is %08x\n",bus_r(POWER_ON_REG)); + } + } + + if (pwrindex >= 0) { + if (bus_r(POWER_ON_REG) & (1 << (POWER_ENABLE_OFST + pwrindex))) { + retval1 = dacToPower(retval, 0); + printf("Vdac id %d mV\n",retval1); + } else + retval1 = 0; + } else { + if (retval >= 0) { + retval1 = dacToPower(retval, 1); + /*printf("Vchip is %d mV\n",vmax); makes no sense.. should be printing retval1??? */ + } else + retval1=-1; + } + + return retval1; +} + +int getVLimit() { + return vlimit; +} + +void setDacRegister(int dacnum,int dacvalue) { + bus_w(DAC_NUM_REG, dacnum); + bus_w(DAC_VAL_REG, dacvalue); + bus_w(DAC_NUM_REG, dacnum | (1<<16));/** super strange writing dac num in weird ways */ + bus_w(DAC_NUM_REG, dacnum); + printf("Wrote dac register value %d address %d\n",bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ; +} + +int getDacRegister(int dacnum) {/** super strange, reading out in some other register than written */ + bus_w(DAC_NUM_REG, dacnum); + printf("READ dac register value %d address %d\n",(int16_t)bus_r(DAC_VAL_OUT_REG),bus_r(DAC_NUM_REG)) ; + return (int16_t)bus_r(DAC_VAL_OUT_REG); +} + + + + + +/* parameters - timing, extsig */ + + +enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){ + return AUTO_TIMING; +} + + + + +/* jungfrau specific - pll, flashing fpga */ + + + +void resetPLL() { + // reset PLL Reconfiguration and PLL + bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) | PLL_CTRL_RECONFIG_RST_MSK | PLL_CTRL_RST_MSK); + usleep(100); + bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) & ~PLL_CTRL_RECONFIG_RST_MSK & ~PLL_CTRL_RST_MSK); +} + + +u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val) { + + // set parameter + bus_w(PLL_PARAM_REG, val); + + // set address + bus_w(PLL_CONTROL_REG, (reg << PLL_CTRL_ADDR_OFST) & PLL_CTRL_ADDR_MSK); + usleep(10*1000); + + //write parameter + bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) | PLL_CTRL_WR_PARAMETER_MSK); + bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) & ~PLL_CTRL_WR_PARAMETER_MSK); + usleep(10*1000); + + return val; +} + + + + +void configurePll() { + u_int32_t val; + int32_t phase=0, inv=0; + + printf(" phase in %d\n", clkPhase[1]); + if (clkPhase[1]>0) { + inv=0; + phase=clkPhase[1]; + } else { + inv=1; + phase=-1*clkPhase[1]; + } + printf(" phase out %d (0x%08x)\n", phase, phase); + + if (inv) { + val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) + PLL_SHIFT_CNT_SLCT_C1_VAL + PLL_SHIFT_UP_DOWN_NEG_VAL; + printf(" phase word 0x%08x\n", val); + setPllReconfigReg(PLL_PHASE_SHIFT_REG, val); + } else { + val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) + PLL_SHIFT_CNT_SLCT_C0_VAL + PLL_SHIFT_UP_DOWN_NEG_VAL; + printf(" phase word 0x%08x\n", val); + setPllReconfigReg(PLL_PHASE_SHIFT_REG, val); + + printf(" phase word 0x%08x\n", val); + val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) + PLL_SHIFT_CNT_SLCT_C2_VAL; + setPllReconfigReg(PLL_PHASE_SHIFT_REG, val); + } + usleep(10000); +} + + + + +/* aquisition */ + +int startStateMachine(){ + printf("*******Starting State Machine*******\n"); + + cleanFifos(); + + //start state machine + bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_START_ACQ_MSK); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_START_ACQ_MSK); + + printf("Status Register: %08x\n",bus_r(STATUS_REG)); + return OK; +} + + +int stopStateMachine(){ + cprintf(BG_RED,"*******Stopping State Machine*******\n"); + + //stop state machine + bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STOP_ACQ_MSK); + usleep(100); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STOP_ACQ_MSK); + + printf("Status Register: %08x\n",bus_r(STATUS_REG)); + return OK; +} + + + + + +enum runStatus getRunStatus(){ +#ifdef VERBOSE + printf("Getting status\n"); +#endif + + enum runStatus s; + u_int32_t retval = bus_r(STATUS_REG); + printf("Status Register: %08x\n",retval); + + //running + if(((retval & RUN_BUSY_MSK) >> RUN_BUSY_OFST)) { + if ((retval & WAITING_FOR_TRIGGER_MSK) >> WAITING_FOR_TRIGGER_OFST) { + printf("-----------------------------------WAITING-----------------------------------\n"); + s=WAITING; + } + else{ + printf("-----------------------------------RUNNING-----------------------------------\n"); + s=RUNNING; + } + } + + //not running + else { + if ((retval & STOPPED_MSK) >> STOPPED_OFST) { + printf("-----------------------------------STOPPED--------------------------\n"); + s=STOPPED; + } else if ((retval & RUNMACHINE_BUSY_MSK) >> RUNMACHINE_BUSY_OFST) { + printf("-----------------------------------READ MACHINE BUSY--------------------------\n"); + s=TRANSMITTING; + } else if (!retval) { + printf("-----------------------------------IDLE--------------------------------------\n"); + s=IDLE; + } else { + printf("-----------------------------------Unknown status %08x--------------------------------------\n", retval); + s=ERROR; + } + } + + return s; +} + + + +void readFrame(int *ret, char *mess){ + + // wait for status to be done + while(runBusy()){ + usleep(500); + } + + // frames left to give status + int64_t retval = getTimeLeft(FRAME_NUMBER) + 1; + if ( retval > 0) { + *ret = (int)FAIL; + sprintf(mess,"no data and run stopped: %lld frames left\n",retval); + cprintf(RED,"%s\n",mess); + } else { + *ret = (int)FINISHED; + sprintf(mess,"acquisition successfully finished\n"); + printf("%s",mess); + } +} + + + +u_int32_t runBusy(void) { + u_int32_t s = ((bus_r(STATUS_REG) & RUN_BUSY_MSK) >> RUN_BUSY_OFST); +#ifdef VERBOSE + printf("Status Register: %08x\n", s); +#endif + return s; +} + + + + + + + + +/* common */ + +//jungfrau doesnt require chips and chans (save memory) +int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){ + + int idac, iadc; + int ret=OK; + +#ifdef VERBOSE + printf("Copying module %x to module %x\n",srcMod,destMod); +#endif + + if (srcMod->module>=0) { +#ifdef VERBOSE + printf("Copying module number %d to module number %d\n",srcMod->module,destMod->module); +#endif + destMod->module=srcMod->module; + } + if (srcMod->serialnumber>=0){ + + destMod->serialnumber=srcMod->serialnumber; + } + if ((srcMod->nchip)>(destMod->nchip)) { + printf("Number of chip of source is larger than number of chips of destination\n"); + return FAIL; + } + if ((srcMod->nchan)>(destMod->nchan)) { + printf("Number of channels of source is larger than number of channels of destination\n"); + return FAIL; + } + if ((srcMod->ndac)>(destMod->ndac)) { + printf("Number of dacs of source is larger than number of dacs of destination\n"); + return FAIL; + } + if ((srcMod->nadc)>(destMod->nadc)) { + printf("Number of dacs of source is larger than number of dacs of destination\n"); + return FAIL; + } + +#ifdef VERBOSE + printf("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac); + printf("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc); + printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip); + printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan); + +#endif + destMod->ndac=srcMod->ndac; + destMod->nadc=srcMod->nadc; + destMod->nchip=srcMod->nchip; + destMod->nchan=srcMod->nchan; + if (srcMod->reg>=0) + destMod->reg=srcMod->reg; +#ifdef VERBOSE + printf("Copying register %x (%x)\n",destMod->reg,srcMod->reg ); +#endif + if (srcMod->gain>=0) + destMod->gain=srcMod->gain; + if (srcMod->offset>=0) + destMod->offset=srcMod->offset; + + for (idac=0; idac<(srcMod->ndac); idac++) { + if (*((srcMod->dacs)+idac)>=0) + *((destMod->dacs)+idac)=*((srcMod->dacs)+idac); + } + for (iadc=0; iadc<(srcMod->nadc); iadc++) { + if (*((srcMod->adcs)+iadc)>=0) + *((destMod->adcs)+iadc)=*((srcMod->adcs)+iadc); + } + return ret; +} + + +int calculateDataBytes(){ + return DATA_BYTES; +} + +int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerModule() * (int)getTotalNumberOfModules());} +int getTotalNumberOfChips(){return ((int)getNumberOfChipsPerModule() * (int)getTotalNumberOfModules());} +int getTotalNumberOfModules(){return NMOD;} +int getNumberOfChannelsPerModule(){return ((int)getNumberOfChannelsPerChip() * (int)getTotalNumberOfChips());} +int getNumberOfChipsPerModule(){return NCHIP;} +int getNumberOfDACsPerModule(){return NDAC;} +int getNumberOfADCsPerModule(){return NADC;} +int getNumberOfChannelsPerChip(){return NCHAN;} + + + +/* sync */ + +enum masterFlags setMaster(enum masterFlags arg){ + return NO_MASTER; +} + +enum synchronizationMode setSynchronization(enum synchronizationMode arg){ + return NO_SYNCHRONIZATION; +} + + + + + + +//#endif diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h new file mode 120000 index 000000000..345b8c029 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h @@ -0,0 +1 @@ +../slsDetectorServer/slsDetectorFunctionList.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c deleted file mode 100755 index cb952fd35..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c +++ /dev/null @@ -1,120 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ - -#include "sls_detector_defs.h" -#include "mythen3Server_defs.h" - -#include "communication_funcs.h" -#include "mythen3Server_funcs.h" - -#include -#include -#include -#include - - -extern int sockfd; - - -void error(char *msg){ - perror(msg); -} - -int main(int argc, char *argv[]){ - int portno, b; - int retval=OK; - int sd, fd; - int debugflag = 0; - - // if socket crash, ignores SISPIPE, prevents global signal handler - // subsequent read/write to socket gives error - must handle locally - signal(SIGPIPE, SIG_IGN); - - // circumvent the basic tests - if(argc > 1) { - if(!strcasecmp(argv[1],"-debug")){ - debugflag = 1; - argc=1; - } - } - - -#ifdef STOP_SERVER - char cmd[100]; -#endif - if (argc==1) { - portno = DEFAULT_PORTNO; - cprintf(BLUE, - "********************************************************\n" - "********* opening control server on port %d **********\n" - "********************************************************\n\n" - , portno); - b=1; - basictests(debugflag); -#ifdef STOP_SERVER - sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1); - //cprintf(BLUE,"cmd:%s\n", cmd); - system(cmd); -#endif - } else { - portno = DEFAULT_PORTNO+1; - if ( sscanf(argv[1],"%d",&portno) == 0) { - printf("could not open stop server: unknown port\n"); - return 1; - } - cprintf(BLUE, - "********************************************************\n" - "*********** opening stop server on port %d ***********\n" - "********************************************************\n\n" - , portno); - b=0; - } - - init_detector(b); //defined in slsDetectorServer_funcs - - sd=bindSocket(portno); //defined in communication_funcs - sockfd=sd; - if (getServerError(sd)) { //defined in communication_funcs - printf("server error!\n"); - return -1; - } - - /* assign function table */ - function_table(); //defined in slsDetectorServer_funcs -#ifdef VERBOSE - printf("function table assigned \n"); -#endif - - - printf("\nReady...\n\n"); - - /* waits for connection */ - while(retval!=GOODBYE) { -#ifdef VERBOSE - printf("\n"); -#endif -#ifdef VERY_VERBOSE - printf("Waiting for client call\n"); -#endif - fd=acceptConnection(sockfd); //defined in communication_funcs -#ifdef VERY_VERBOSE - printf("Connection accepted\n"); -#endif - if (fd>0) { - retval=decode_function(fd); //defined in slsDetectorServer_funcs -#ifdef VERY_VERBOSE - printf("function executed\n"); -#endif - closeConnection(fd); //defined in communication_funcs -#ifdef VERY_VERBOSE - printf("connection closed\n"); -#endif - } - } - - exitServer(sockfd); //defined in communication_funcs - printf("Goodbye!\n"); - - return 0; -} - diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c new file mode 120000 index 000000000..a7eb59acb --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c @@ -0,0 +1 @@ +../slsDetectorServer/slsDetectorServer.c \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h new file mode 100644 index 000000000..e638f840e --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h @@ -0,0 +1,167 @@ +/* + * mythen3Server_defs.h + * + * Created on: Jan 24, 2013 + * Author: l_maliakal_d, changed my Marie A. + */ + +#ifndef SLSDETECTORSERVER_DEFS_H_ +#define SLSDETECTORSERVER_DEFS_H_ + +#include "sls_detector_defs.h" +#include + +/** This is only an example file!!! */ + + + +#define GOODBYE (-200) +enum DACINDEX {vIpre, vIbias, Vrf, VrfSh, vIinSh, VdcSh, Vth2, VPL, Vth1, Vth3, Vtrim, casSh, cas, vIbiasSh, vIcin, VPH, NC, vIpreOut, V_D, V_CHIP, V_C, V_B, V_A, V_IO, V_LIM}; // Mythen 3.01 +enum PWRINDEX {PWR_IO, PWR_A, PWR_B, PWR_C, PWR_D, PWR_CHIP=-1, PWR_LIMIT=-1}; +enum CLKINDEX {RUN_CLK_C, ADC_CLK_C, SYNC_CLK_C, DBIT_CLK_C}; + +#define DEFAULT_DAC_VALS { 2150, /* vIpre */ \ + 1200, /* vIbias */ \ + 900, /* Vrf */ \ + 1050, /* VrfSh */ \ + 1400, /* vIinSh */ \ + 655, /* VdcSh */ \ + 850, /* Vth2 */ \ + 1400, /* VPL */ \ + 850, /* Vth1 */ \ + 850, /* Vth3 */ \ + 2294, /* Vtrim */ \ + 983, /* casSh */ \ + 1474, /* cas */ \ + 1200, /* vIbiasSh */ \ + 1600, /* vIcin */ \ + 1520, /* VPH */ \ + 0, /* NC */ \ + 1000 /* vIpreOut */ \ + 0 /* V_D */ \ + 0 /* V_CHIP */ \ + 0 /* V_C */ \ + 1335 /* V_B */ \ + 1335 /* V_A */ \ + 1350 /* V_IO */ \ + }; + +#define DEFAULT_DAC_NAMES { "vIpre", \ + "vIbias", \ + "Vrf", \ + "VrfSh", \ + "vIinSh", \ + "VdcSh", \ + "Vth2", \ + "VPL", \ + "Vth1", \ + "Vth3", \ + "Vtrim", \ + "casSh", \ + "cas", \ + "vIbiasSh", \ + "vIcin", \ + "VPH", \ + "NC", \ + "vIpreOut" \ + "v_d" \ + "v_chip" \ + "v_c" \ + "v_b" \ + "v_a" \ + "v_io" \ + }; + +/*Hardware Definitions */ +#define NMAXMOD (1) +#define NMOD (1) +#define NCHAN (32) +#define NCHIP (1) +#define NADC (0) +#define NDAC (24) +#define NDAC_PER_SET (8) + + +#define NPWR (5) +#define MAX_DACVOLTVAL (2500) //mV +#define MAX_DACVAL (4096) // dac val +#define MAX_VCHIPVAL (2700) //mV /** name ???? */ +#define MIN_VCHIP_OFSTVAL (200) //mV /** name ???? */ +#define MIN_VCHIP_VAL (600) //mV /** name ???? */ + + +/** Default Parameters */ +#define DEFAULT_NUM_FRAMES (1) +#define DEFAULT_NUM_CYCLES (1) +#define DEFAULT_EXPTIME (200*1000) //ns +#define DEFAULT_PERIOD (1*1000*1000) //ns +#define DEFAULT_DELAY (0) +#define DEFAULT_HIGH_VOLTAGE (0) +#define DEFAULT_TIMING_MODE (AUTO_TIMING) + + +/* Defines in the Firmware */ +#define FIX_PATT_VAL (0xACDC1980) + +/* LTC2620 DAC DEFINES */ +#define LTC2620_DAC_CMD_OFST (20) +#define LTC2620_DAC_CMD_MSK (0x0000000F << LTC2620_DAC_CMD_OFST) +#define LTC2620_DAC_ADDR_OFST (16) +#define LTC2620_DAC_ADDR_MSK (0x0000000F << LTC2620_DAC_ADDR_OFST) +#define LTC2620_DAC_DATA_OFST (4) +#define LTC2620_DAC_DATA_MSK (0x00000FFF << LTC2620_DAC_DATA_OFST) + +#define LTC2620_DAC_CMD_WRITE (0x00000000 << LTC2620_DAC_CMD_OFST) +#define LTC2620_DAC_CMD_SET (0x00000003 << LTC2620_DAC_CMD_OFST) +#define LTC2620_DAC_CMD_POWER_DOWN (0x00000004 << LTC2620_DAC_CMD_OFST) +#define LTC2620_DAC_NUMBITS (24) + +/** PLL Reconfiguration Registers */ +//https://www.altera.com/documentation/mcn1424769382940.html +#define PLL_MODE_REG (0x00) +#define PLL_STATUS_REG (0x01) +#define PLL_START_REG (0x02) +#define PLL_N_COUNTER_REG (0x03) +#define PLL_M_COUNTER_REG (0x04) +#define PLL_C_COUNTER_REG (0x05) +#define PLL_PHASE_SHIFT_REG (0x06) + +#define PLL_SHIFT_NUM_SHIFTS_OFST (0) +#define PLL_SHIFT_NUM_SHIFTS_MSK (0x0000FFFF << PLL_SHIFT_NUM_SHIFTS_OFST) + +#define PLL_SHIFT_CNT_SELECT_OFST (16) +#define PLL_SHIFT_CNT_SELECT_MSK (0x0000001F << PLL_SHIFT_CNT_SELECT_OFST) +#define PLL_SHIFT_CNT_SLCT_C0_VAL ((0x0 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C1_VAL ((0x1 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C2_VAL ((0x2 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C3_VAL ((0x3 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C4_VAL ((0x4 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C5_VAL ((0x5 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C6_VAL ((0x6 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C7_VAL ((0x7 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C8_VAL ((0x8 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C9_VAL ((0x9 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C10_VAL ((0x10 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C11_VAL ((0x11 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C12_VAL ((0x12 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C13_VAL ((0x13 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C14_VAL ((0x14 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C15_VAL ((0x15 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C16_VAL ((0x16 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) +#define PLL_SHIFT_CNT_SLCT_C17_VAL ((0x17 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) + +#define PLL_SHIFT_UP_DOWN_OFST (21) +#define PLL_SHIFT_UP_DOWN_MSK (0x00000001 << PLL_SHIFT_UP_DOWN_OFST) +#define PLL_SHIFT_UP_DOWN_NEG_VAL ((0x0 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK) +#define PLL_SHIFT_UP_DOWN_POS_VAL ((0x1 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK) + +#define PLL_K_COUNTER_REG (0x07) +#define PLL_BANDWIDTH_REG (0x08) +#define PLL_CHARGEPUMP_REG (0x09) +#define PLL_VCO_DIV_REG (0x1c) +#define PLL_MIF_REG (0x1f) + +#define PLL_VCO_FREQ_MHZ 400 + + +#endif /* SLSDETECTORSERVER_DEFS_H_ */ diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c new file mode 120000 index 000000000..a7532ccd4 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c @@ -0,0 +1 @@ +../slsDetectorServer/slsDetectorServer_funcs.c \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h new file mode 120000 index 000000000..7569daf47 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h @@ -0,0 +1 @@ +../slsDetectorServer/slsDetectorServer_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetector_stopServer.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetector_stopServer.c deleted file mode 100755 index 1772ce2b6..000000000 --- a/slsDetectorSoftware/mythen3DetectorServer/slsDetector_stopServer.c +++ /dev/null @@ -1,46 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ -#include "communication_funcs.h" - -#include "slsDetectorFunctionList.h"/*#include "slsDetector_firmware.h" for the time being*/ -#include "slsDetectorServer_defs.h" - -#include -#include - -int sockfd; - -int main(int argc, char *argv[]) -{ - int portno; - int retval=0; - int sd,fd; - - portno = DEFAULT_PORTNO; - - - sd=bindSocket(portno); //defined in communication_funcs - if (getServerError(sd)) //defined in communication_funcs - return -1; - - - - /* waits for connection */ - while(retval!=GOODBYE) { -#ifdef VERBOSE - printf("\n"); -#endif -#ifdef VERY_VERBOSE - printf("Stop server: waiting for client call\n"); -#endif - fd=acceptConnection(sd); //defined in communication_funcs - retval=stopStateMachine();//defined in slsDetectorFirmare_funcs - closeConnection(fd); //defined in communication_funcs - } - - exitServer(sd); //defined in communication_funcs - printf("Goodbye!\n"); - - return 0; -} - diff --git a/slsDetectorSoftware/mythen3DetectorServer/sls_detector_defs.h b/slsDetectorSoftware/mythen3DetectorServer/sls_detector_defs.h new file mode 120000 index 000000000..c5062e03f --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/sls_detector_defs.h @@ -0,0 +1 @@ +../commonFiles/sls_detector_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/sls_detector_funcs.h new file mode 120000 index 000000000..844b67129 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/sls_detector_funcs.h @@ -0,0 +1 @@ +../commonFiles/sls_detector_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/mythen3DetectorServer/sls_receiver_defs.h new file mode 120000 index 000000000..1de31caf5 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/sls_receiver_defs.h @@ -0,0 +1 @@ +../../slsReceiverSoftware/include/sls_receiver_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/sls_receiver_funcs.h new file mode 120000 index 000000000..c2ea4ded9 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/sls_receiver_funcs.h @@ -0,0 +1 @@ +../../slsReceiverSoftware/include/sls_receiver_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythen3DetectorServer/updateGitVersion.sh b/slsDetectorSoftware/mythen3DetectorServer/updateGitVersion.sh new file mode 100755 index 000000000..0c25e7f1e --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/updateGitVersion.sh @@ -0,0 +1,31 @@ +SERVER=jungfrauDetectorServer +MAINDIR=slsDetectorsPackage +SPECDIR=slsDetectorSoftware/$SERVER +TMPFILE=gitInfoJungfrauTmp.h +INCLFILE=gitInfoJungfrau.h + + +#evaluate the variables +EVALFILE=../../evalVersionVariables.sh +source $EVALFILE + + +#get modified date +#RDATE1='git log --pretty=format:"%ci" -1' +RDATE1="find ../slsDetectorServer . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v 'gitInfo|bin|.git|updateGitVersion|.o' | head -n 1" +RDATE=`eval $RDATE1` +NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') +NEWDATE=${NEWDATE/#/0x} + + +#get old date from INCLFILE +OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') + + +#update INCLFILE if changes +if [ "$OLDDATE" != "$NEWDATE" ]; then + echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt + cd ../../ + ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE + cd $WD +fi \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h b/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h index 4122fb7cf..8b2575089 100755 --- a/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h +++ b/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h @@ -16,44 +16,56 @@ void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbits u_int32_t valw; - // start point - valw = 0xffffffff; // old board compatibility (not using specific bits) - bus_w (addr, valw); + SPIChipSelect (valw, addr, csmask); - // chip sel bar down - valw &= ~csmask; /* todo with test: done a bit different, not with previous value */ - bus_w (addr, valw); + sendDataToSPI(valw, addr, val, numbitstosend, clkmask, digoutmask, digofset); - { - int i = 0; - for (i = 0; i < numbitstosend; ++i) { + SPIChipDeselect(valw, addr, csmask, clkmask); +} - // clk down - valw &= ~clkmask; - bus_w (addr, valw); +void SPIChipSelect (u_int32_t& valw, u_int32_t addr, u_int32_t csmask) { - // write data (i) - valw = ((valw & ~digoutmask) + // unset bit - (((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb - bus_w (addr, valw); + // start point + valw = 0xffffffff; // old board compatibility (not using specific bits) + bus_w (addr, valw); - // clk up - valw |= clkmask ; - bus_w (addr, valw); - } - } + // chip sel bar down + valw &= ~csmask; /* todo with test: done a bit different, not with previous value */ + bus_w (addr, valw); +} - // chip sel bar up - valw |= csmask; /* todo with test: not done for spi */ - bus_w (addr, valw); - //clk down - valw &= ~clkmask; - bus_w (addr, valw); +void SPIChipDeselect (u_int32_t& valw, u_int32_t addr, u_int32_t csmask, u_int32_t clkmask) { + // chip sel bar up + valw |= csmask; /* todo with test: not done for spi */ + bus_w (addr, valw); - // stop point = start point of course - valw = 0xffffffff; // old board compatibility (not using specific bits) - bus_w (addr, valw); + //clk down + valw &= ~clkmask; + bus_w (addr, valw); + + // stop point = start point of course + valw = 0xffffffff; // old board compatibility (not using specific bits) + bus_w (addr, valw); +} + +void sendDataToSPI (u_int32_t& valw, u_int32_t addr, u_int32_t val, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) { + int i = 0; + for (i = 0; i < numbitstosend; ++i) { + + // clk down + valw &= ~clkmask; + bus_w (addr, valw); + + // write data (i) + valw = ((valw & ~digoutmask) + // unset bit + (((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb + bus_w (addr, valw); + + // clk up + valw |= clkmask ; + bus_w (addr, valw); + } } diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h index 4da4a3d8b..a162209e6 100644 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h @@ -18,14 +18,16 @@ Here are the definitions, but the actual implementation should be done for each // basic tests void checkFirmwareCompatibility(int flag); -#ifdef JUNGFRAUD +#if defined(MYTHEN3D) || defined(JUNGFRAUD) int checkType(); u_int32_t testFpga(void); int testBus(void); #endif -#if defined(MYTHEND) || defined(JUNGFRAUD) +#if defined(MYTHEND) || defined(JUNGFRAUD) || defined(MYTHEN3D) int moduleTest( enum digitalTestMode arg, int imod); +#endif +#if defined(MYTHEND) || defined(JUNGFRAUD) int detectorTest( enum digitalTestMode arg); #endif @@ -38,7 +40,9 @@ int64_t getModuleId(enum idMode arg, int imod); u_int16_t getHardwareVersionNumber(); u_int16_t getHardwareSerialNumber(); #endif +#ifndef MYTHEN3D u_int32_t getDetectorNumber(); +#endif u_int64_t getDetectorMAC(); u_int32_t getDetectorIP(); @@ -66,11 +70,16 @@ uint32_t readRegister(uint32_t offset); // firmware functions (resets) -#ifdef JUNGFRAUD +#if defined(MYTHEN3D) || defined(JUNGFRAUD) int powerChip (int on); void cleanFifos(); void resetCore(); void resetPeripheral(); +int getPhase(int i); +int configurePhase(int val, enum CLKINDEX i); +int configureFrequency(int val, int i); +#endif +#ifdef JUNGFRAUD int adcPhase(int st); int getPhase(); #endif @@ -123,16 +132,33 @@ int setThresholdEnergy(int ev, int imod); #endif // parameters - dac, adc, hv -#ifdef JUNGFRAUD +#if defined(MYTHEN3D) || defined(JUNGFRAUD) void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset); void initDac(int dacnum); -extern void setAdc(int addr, int val); // AD9257.h -int voltageToDac(int value); -int dacToVoltage(unsigned int digital); +int voltageToDac(int value); +int dacToVoltage(unsigned int digital); #endif +#ifdef MYTHEN3D +int setPower(enum DACINDEX ind, int val); +int powerToDac(int value, int chip); +int dacToPower(int value, int chip); +#endif + +#ifdef JUNGFRAUD +extern void setAdc(int addr, int val); // AD9257.h +#endif + void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]); +#ifdef MYTHEN3D +int getVLimit(); +void setDacRegister(int dacnum,int dacvalue); +int getDacRegister(int dacnum); +#endif +#ifndef MYTHEN3D int getADC(enum ADCINDEX ind, int imod); -#ifndef MYTHEND +#endif + +#if !defined(MYTHEN3D) && !defined(MYTHEND) int setHighVoltage(int val); #endif @@ -149,7 +175,7 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg); #ifdef JUNGFRAUD long int calcChecksum(int sourceip, int destip); #endif -#ifndef MYTHEND +#if !defined(MYTHEN3D) && !defined(MYTHEND) int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival); #endif #if defined(JUNGFRAUD) || defined(EIGERD) @@ -167,7 +193,7 @@ int resetCounterBlock(int startACQ); int calibratePedestal(int frames); // jungfrau specific - pll, flashing firmware -#elif JUNGFRAUD +#elif defined(JUNGFRAUD) || defined(MYTHEN3D) void resetPLL(); u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); void configurePll(); diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c index 8d6df11df..27bcb0af8 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c @@ -29,6 +29,8 @@ const enum detectorType myDetectorType=PICASSO; const enum detectorType myDetectorType=MOENCH; #elif JUNGFRAUD const enum detectorType myDetectorType=JUNGFRAU; +#elif MYTHEN3D +const enum detectorType myDetectorType=MYTHEN3; #else const enum detectorType myDetectorType=GENERIC; #endif @@ -877,134 +879,134 @@ int calibration_pulse(int file_des) { int set_dac(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg[3]={-1,-1,-1}; - int val=-1; - enum dacIndex ind=0; - int imod=-1; - int retval[2]={-1,-1}; - int mV=0; - sprintf(mess,"set DAC failed\n"); + int ret=OK,ret1=OK; + int n=0; + int arg[3]={-1,-1,-1}; + int val=-1; + enum dacIndex ind=0; + int imod=-1; + int retval[2]={-1,-1}; + int mV=0; + sprintf(mess,"set DAC failed\n"); - // receive arguments - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - ind=arg[0]; - imod=arg[1]; - mV=arg[2]; + // receive arguments + n = receiveData(file_des,arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + ind=arg[0]; + imod=arg[1]; + mV=arg[2]; - n = receiveData(file_des,&val,sizeof(val),INT32); - if (n < 0) return printSocketReadError(); + n = receiveData(file_des,&val,sizeof(val),INT32); + if (n < 0) return printSocketReadError(); - // checks + // checks #ifdef MYTHEND #ifdef SLS_DETECTOR_FUNCTION_LIST - if (imod>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - cprintf(RED, "Warning: %s", mess); - } + if (imod>=getTotalNumberOfModules()) { + ret = FAIL; + sprintf(mess,"Module number %d out of range\n",imod); + cprintf(RED, "Warning: %s", mess); + } #endif #endif - // check if dac exists for this detector - enum DACINDEX idac=0; + // check if dac exists for this detector + enum DACINDEX idac=0; #ifdef JUNGFRAUD - if ((ind != HV_NEW) && (ind >= NDAC_OLDBOARD)) { //for compatibility with old board - ret = FAIL; - sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); - cprintf(RED, "Warning: %s", mess); - }else - idac = ind; + if ((ind != HV_NEW) && (ind >= NDAC_OLDBOARD)) { //for compatibility with old board + ret = FAIL; + sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); + cprintf(RED, "Warning: %s", mess); + }else + idac = ind; #else - switch (ind) { + switch (ind) { #ifdef MYTHEND - case TRIMBIT_SIZE: //ind = VTRIM; - case THRESHOLD: - case SHAPER1: - case SHAPER2: - case CALIBRATION_PULSE: - case PREAMP: - break; + case TRIMBIT_SIZE: //ind = VTRIM; + case THRESHOLD: + case SHAPER1: + case SHAPER2: + case CALIBRATION_PULSE: + case PREAMP: + break; #elif GOTTHARDD - case G_VREF_DS : - break; - case G_VCASCN_PB: - break; - case G_VCASCP_PB: - break; - case G_VOUT_CM: - break; - case G_VCASC_OUT: - break; - case G_VIN_CM: - break; - case G_VREF_COMP: - break; - case G_IB_TESTC: - break; - case HV_POT: - break; + case G_VREF_DS : + break; + case G_VCASCN_PB: + break; + case G_VCASCP_PB: + break; + case G_VOUT_CM: + break; + case G_VCASC_OUT: + break; + case G_VIN_CM: + break; + case G_VREF_COMP: + break; + case G_IB_TESTC: + break; + case HV_POT: + break; #elif EIGERD - case TRIMBIT_SIZE: - idac = VTR; - break; - case THRESHOLD: - idac = VTHRESHOLD; - break; - case E_SvP: - idac = SVP; - break; - case E_SvN: - idac = SVN; - break; - case E_Vtr: - idac = VTR; - break; - case E_Vrf: - idac = VRF; - break; - case E_Vrs: - idac = VRS; - break; - case E_Vtgstv: - idac = VTGSTV; - break; - case E_Vcmp_ll: - idac = VCMP_LL; - break; - case E_Vcmp_lr: - idac = VCMP_LR; - break; - case E_cal: - idac = CAL; - break; - case E_Vcmp_rl: - idac = VCMP_RL; - break; - case E_Vcmp_rr: - idac = VCMP_RR; - break; - case E_rxb_rb: - idac = RXB_RB; - break; - case E_rxb_lb: - idac = RXB_LB; - break; - case E_Vcp: - idac = VCP; - break; - case E_Vcn: - idac = VCN; - break; - case E_Vis: - idac = VIS; - break; - case HV_NEW: - break; - case IO_DELAY: - break; - /* + case TRIMBIT_SIZE: + idac = VTR; + break; + case THRESHOLD: + idac = VTHRESHOLD; + break; + case E_SvP: + idac = SVP; + break; + case E_SvN: + idac = SVN; + break; + case E_Vtr: + idac = VTR; + break; + case E_Vrf: + idac = VRF; + break; + case E_Vrs: + idac = VRS; + break; + case E_Vtgstv: + idac = VTGSTV; + break; + case E_Vcmp_ll: + idac = VCMP_LL; + break; + case E_Vcmp_lr: + idac = VCMP_LR; + break; + case E_cal: + idac = CAL; + break; + case E_Vcmp_rl: + idac = VCMP_RL; + break; + case E_Vcmp_rr: + idac = VCMP_RR; + break; + case E_rxb_rb: + idac = RXB_RB; + break; + case E_rxb_lb: + idac = RXB_LB; + break; + case E_Vcp: + idac = VCP; + break; + case E_Vcn: + idac = VCN; + break; + case E_Vis: + idac = VIS; + break; + case HV_NEW: + break; + case IO_DELAY: + break; + /* #elif JUNGFRAUD case V_DAC0: idac = VB_COMP; @@ -1032,107 +1034,233 @@ int set_dac(int file_des) { break; case HV_POT: break; - */ + */ +#elif MYTHEN3D + case M_vIpre: + idac = vIpre; + break; + case M_vIbias: + idac = vIbias; + break; + case PREAMP: + idac = Vrf; + break; + case SHAPER1: + idac = VrfSh; + break; + case M_vIinSh: + idac = vIinSh; + break; + case M_VdcSh: + idac = VdcSh; + break; + case M_Vth2: + idac = Vth2; + break; + case M_VPL: + idac = VPL; + break; + case THRESHOLD: + idac = Vth1; + break; + case M_Vth3: + idac = Vth3; + break; + case TRIMBIT_SIZE: + idac = Vtrim; + break; + case M_casSh: + idac = casSh; + break; + case M_cas: + idac = cas; + break; + case M_vIbiasSh: + idac = vIbiasSh; + break; + case M_vIcin: + idac = vIcin; + break; + case CALIBRATION_PULSE: // !!! pulse height + 1400 DACu + idac = VPH; + break; + case M_vIpreOut: + idac = vIpreOut; + break; + case V_POWER_A: + idac = V_A; + break; + case V_POWER_B: + ipwr = V_B; + break; + case V_POWER_IO: + idac = V_IO; + break; + case V_POWER_CHIP: + idac = V_CHIP; + break; + case V_LIMIT: + idac = V_LIM; + break; #endif - default: - ret = FAIL; - sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); - cprintf(RED, "Warning: %s", mess); - break; - } + default: + ret = FAIL; + sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); + cprintf(RED, "Warning: %s", mess); + break; + } #endif - // execute action + // execute action #ifdef VERBOSE - printf("Setting DAC %d of module %d to %d \n", idac, imod, val); + printf("Setting DAC %d of module %d to %d \n", idac, imod, val); #endif #ifdef SLS_DETECTOR_FUNCTION_LIST - int temp; - if (ret==OK) { - if (differentClients && lockStatus && val!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } else { + int temp; + if (ret==OK) { + if (differentClients && lockStatus && val!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } else { #ifdef EIGERD - //iodelay - if(ind == IO_DELAY) - retval[0] = setIODelay(val,imod); - //high voltage - else + //iodelay + if(ind == IO_DELAY) + retval[0] = setIODelay(val,imod); + //high voltage + else #endif - if((ind == HV_POT) || (ind == HV_NEW)) { - retval[0] = setHighVoltage(val); + if((ind == HV_POT) || (ind == HV_NEW)) { + retval[0] = setHighVoltage(val); #ifdef EIGERD - if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) { - ret = FAIL; - if(retval[0] == -1) - sprintf(mess, "Setting high voltage failed.Bad value %d. The range is from 0 to 200 V.\n",val); - else if(retval[0] == -2) - strcpy(mess, "Setting high voltage failed. Serial/i2c communication failed.\n"); - else if(retval[0] == -3) - strcpy(mess, "Getting high voltage failed. Serial/i2c communication failed.\n"); - cprintf(RED, "Warning: %s", mess); - } + if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) { + ret = FAIL; + if(retval[0] == -1) + sprintf(mess, "Setting high voltage failed.Bad value %d. The range is from 0 to 200 V.\n",val); + else if(retval[0] == -2) + strcpy(mess, "Setting high voltage failed. Serial/i2c communication failed.\n"); + else if(retval[0] == -3) + strcpy(mess, "Getting high voltage failed. Serial/i2c communication failed.\n"); + cprintf(RED, "Warning: %s", mess); + } #endif - } - //dac - else{ - setDAC(idac,val,imod,mV,retval); + } +#ifdef MYTHEN3D + else if ((ind >= V_POWER_A && ind <= V_POWER_CHIP) || ind == V_LIMIT) { + printf("Setting a power %d to %d\n",ind, val); + + if (!mV) { + ret = FAIL; + strcpy(mess, "Power of index %d should be set in mV instead of DACu", idac); + cprintf(RED, "Warning: %s", mess); + val = -1; + } + + int lim = getVLimit(); + if (ind != V_LIMIT && lim != -1 && val > lim) { + ret = FAIL; + strcpy(mess, "Power of index %d is %d, should be less than %dmV\n", idac, val, lim); + cprintf(RED, "Warning: %s", mess); + val = -1; + } + + retval[1] = retval[0] = setPower(idac,val); + if (val >= 0 && retval[1] != val) { + ret = FAIL; + sprintf(mess,"Setting power %d failed: wrote %d but read %d\n", idac, val, retval[1]); + cprintf(RED, "Warning: %s", mess); + } + } +#endif + //dac + else{ +#ifdef MYTHEN3D + if( mV && val > MAX_DACVOLTVAL) { + ret = FAIL; + strcpy(mess, "Dac of index %d should be less than %dmV\n", idac, val, MAX_DACVOLTVAL); + cprintf(RED, "Warning: %s", mess); + val = -1; + } + else if( !mV && val >= MAX_DACVAL) { + ret = FAIL; + strcpy(mess, "Dac of index %d should be less than %d (dac value)\n", idac, val, MAX_DACVAL); + cprintf(RED, "Warning: %s", mess); + val = -1; + } + + if (val >= 0) { + // conver to mV + int v = val; + if (!mV) + v = dacToVoltage(val); + + //checkvlimit compliant + int lim = getVLimit(); + if (lim!= -1 && v > lim) { + ret = FAIL; + strcpy(mess, "Dac of index %d should be less than %dmV (%d dac value)\n", idac, lim, voltageToDac(lim)); + cprintf(RED, "Warning: %s", mess); + val = -1; + } + } +#endif + setDAC(idac,val,imod,mV,retval); #ifdef EIGERD - if(val != -1) { - //changing dac changes settings to undefined - switch(idac){ - case VCMP_LL: - case VCMP_LR: - case VCMP_RL: - case VCMP_RR: - case VRF: - case VCP: - setSettings(UNDEFINED,-1); - cprintf(RED,"Settings has been changed to undefined (changed specific dacs)\n"); - break; - default: - break; - } - } + if(val != -1) { + //changing dac changes settings to undefined + switch(idac){ + case VCMP_LL: + case VCMP_LR: + case VCMP_RL: + case VCMP_RR: + case VRF: + case VCP: + setSettings(UNDEFINED,-1); + cprintf(RED,"Settings has been changed to undefined (changed specific dacs)\n"); + break; + default: + break; + } + } #endif - //check - if(mV) - temp = retval[1]; - else - temp = retval[0]; - if ((abs(temp-val)<=5) || val==-1) { - ret=OK; - } else { - ret = FAIL; - sprintf(mess,"Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp); - cprintf(RED, "Warning: %s", mess); - } - } - } - } + //check + if (ret == OK) { + if(mV) + temp = retval[1]; + else + temp = retval[0]; + if ((abs(temp-val)<=5) || val==-1) { + ret = OK; + } else { + ret = FAIL; + sprintf(mess,"Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp); + cprintf(RED, "Warning: %s", mess); + } + } + } + } + } #endif #ifdef VERBOSE - printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]); + printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]); #endif - if(ret == OK && differentClients) - ret=FORCE_UPDATE; + if(ret == OK && differentClients) + ret=FORCE_UPDATE; - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } - // return ok / fail - return ret; + // return ok / fail + return ret; } @@ -1149,6 +1277,15 @@ int get_adc(int file_des) { int imod=-1; sprintf(mess,"get ADC failed\n"); +#ifdef MYTHEN3D + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Get ADC) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + // receive arguments n = receiveData(file_des,arg,sizeof(arg),INT32); if (n < 0) return printSocketReadError(); @@ -1217,6 +1354,7 @@ int get_adc(int file_des) { #endif #ifdef VERBOSE printf("ADC is %f\n", retval); +#endif #endif if (ret==OK && differentClients) @@ -1553,7 +1691,7 @@ int set_chip(int file_des) { while (n > 0) n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); ret = FAIL; - sprintf(mess,"Function (Set Channel) is not implemented for this detector\n"); + sprintf(mess,"Function (Set Chip) is not implemented for this detector\n"); cprintf(RED, "Warning: %s", mess); #else sls_detector_chip myChip; @@ -1629,7 +1767,7 @@ int get_chip(int file_des) { while (n > 0) n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); ret = FAIL; - sprintf(mess,"Function (Set Channel) is not implemented for this detector\n"); + sprintf(mess,"Function (Get Chip) is not implemented for this detector\n"); cprintf(RED, "Warning: %s", mess); #else @@ -1718,6 +1856,17 @@ int set_module(int file_des) { #endif sprintf(mess,"set module failed\n"); + +#ifdef MYTHEN3D + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Set Module) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + #ifdef SLS_DETECTOR_FUNCTION_LIST int *myDac=NULL; int *myAdc=NULL; @@ -1896,6 +2045,7 @@ int set_module(int file_des) { } if (ret==OK && differentClients) ret=FORCE_UPDATE; +#endif #endif // ret could be swapped during sendData @@ -1928,6 +2078,15 @@ int get_module(int file_des) { sls_detector_module myModule; sprintf(mess,"get module failed\n"); +#ifdef MYTHEN3D + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Get Module) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + // receive arguments n = receiveData(file_des,&arg,sizeof(arg),INT32); if (n < 0) return printSocketReadError(); @@ -2000,6 +2159,7 @@ int get_module(int file_des) { } } } +#endif #endif if (ret==OK && differentClients) ret=FORCE_UPDATE; @@ -2064,6 +2224,16 @@ int set_settings(int file_des) { enum detectorSettings isett=-1; sprintf(mess,"set settings failed\n"); +#ifdef MYTHEN3D + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Set Settings) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments n = receiveData(file_des,&arg,sizeof(arg),INT32); if (n < 0) return printSocketReadError(); @@ -2098,6 +2268,7 @@ int set_settings(int file_des) { cprintf(RED, "Warning: %s", mess); } } +#endif #endif if (ret==OK && differentClients) @@ -2536,6 +2707,11 @@ int set_timer(int file_des) { case DELAY_AFTER_TRIGGER: #elif JUNGFRAUD case DELAY_AFTER_TRIGGER: +#elif MYTHEN3D + case DELAY_AFTER_TRIGGER: + case GATES_NUMBER: + case PROBES_NUMBER: + case SAMPLES_JCTB: #endif case FRAME_NUMBER: case ACQUISITION_TIME: @@ -2615,22 +2791,25 @@ int get_time_left(int file_des) { switch(ind) { #ifdef MYTHEND case PROBES_NUMBER: +#elif JUNGFRAUD + case FRAMES_FROM_START: + case FRAMES_FROM_START_PG: +#elif MYTHEN3D + case GATES_NUMBER: + case PROBES_NUMBER: + case SAMPLES_JCTB: +#endif +#ifndef JUNGFRAUD + case GATES_NUMBER: #endif case FRAME_NUMBER: case ACQUISITION_TIME: case FRAME_PERIOD: case DELAY_AFTER_TRIGGER: -#ifndef JUNGFRAUD - case GATES_NUMBER: -#endif case CYCLES_NUMBER: case PROGRESS: case ACTUAL_TIME: case MEASUREMENT_TIME: -#ifdef JUNGFRAUD - case FRAMES_FROM_START: - case FRAMES_FROM_START_PG: -#endif retval=getTimeLeft(ind); break; default: @@ -2991,6 +3170,9 @@ int set_speed(int file_des) { case CLOCK_DIVIDER: #elif JUNGFRAUD case CLOCK_DIVIDER: +#elif MYTHEN3D + case DBIT_CLOCK: + case DBIT_PHASE: #endif retval=setSpeed(arg, val); if ((retval!=val) && (val>=0)) { @@ -4003,20 +4185,180 @@ int set_all_trimbits(int file_des){ int set_ctb_pattern(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Set CTB Pattern) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); + int ret=OK,ret1=OK; + int n=0; + int retval=-1; - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + int mode = -1; + int addr = -1, level = -1, nl = -1, start = -1, stop = -1; + uint64_t word = -1,retval64 = -1, t = -1; + sprintf(mess,"Could not set pattern\n"); - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); +#ifndef MYTHEN3D + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - // return ok / fail - return ret; + ret = FAIL; + sprintf(mess,"Function (Set CTB Pattern) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + n += sendData(file_des,mess,sizeof(mess),OTHER); + + return ret; + +#endif + n = receiveDataOnly(file_des, &mode, sizeof(mode)); + printf("pattern mode is %d\n",mode); + + switch (mode) { + + case 0: //sets word + n = receiveDataOnly(file_des,&addr,sizeof(addr)); + n = receiveDataOnly(file_des,&word,sizeof(word)); + ret=OK; + + printf("pattern addr is %d %x\n",addr, word); + switch (addr) { + case -1: + retval64=writePatternIOControl(word); + break; + case -2: + retval64=writePatternClkControl(word); + break; + default: + retval64=writePatternWord(addr,word); + }; + + + //write word; + //@param addr address of the word, -1 is I/O control register, -2 is clk control register + //@param word 64bit word to be written, -1 gets + + n = sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret==FAIL) + n += sendDataOnly(file_des,mess,sizeof(mess)); + else + n += sendDataOnly(file_des,&retval64,sizeof(retval64)); + break; + + case 1: //pattern loop + // printf("loop\n"); + n = receiveDataOnly(file_des,&level,sizeof(level)); + n = receiveDataOnly(file_des,&start,sizeof(start)); + n = receiveDataOnly(file_des,&stop,sizeof(stop)); + n = receiveDataOnly(file_des,&nl,sizeof(nl)); + + + + // printf("level %d start %x stop %x nl %d\n",level, start, stop, nl); + /** Sets the pattern or loop limits in the CTB + @param level -1 complete pattern, 0,1,2, loop level + @param start start address if >=0 + @param stop stop address if >=0 + @param n number of loops (if level >=0) + @returns OK/FAIL + */ + ret=setPatternLoop(level, &start, &stop, &nl); + + n = sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret==FAIL) + n += sendDataOnly(file_des,mess,sizeof(mess)); + else { + n += sendDataOnly(file_des,&start,sizeof(start)); + n += sendDataOnly(file_des,&stop,sizeof(stop)); + n += sendDataOnly(file_des,&nl,sizeof(nl)); + } + break; + + + + case 2: //wait address + printf("wait\n"); + n = receiveDataOnly(file_des,&level,sizeof(level)); + n = receiveDataOnly(file_des,&addr,sizeof(addr)); + + + + /** Sets the wait address in the CTB + @param level 0,1,2, wait level + @param addr wait address, -1 gets + @returns actual value + */ + printf("wait addr %d %x\n",level, addr); + retval=setPatternWaitAddress(level,addr); + printf("ret: wait addr %d %x\n",level, retval); + ret=OK; + n = sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret==FAIL) + n += sendDataOnly(file_des,mess,sizeof(mess)); + else { + n += sendDataOnly(file_des,&retval,sizeof(retval)); + + } + + + break; + + + case 3: //wait time + printf("wait time\n"); + n = receiveDataOnly(file_des,&level,sizeof(level)); + n = receiveDataOnly(file_des,&t,sizeof(t)); + + + /** Sets the wait time in the CTB + @param level 0,1,2, wait level + @param t wait time, -1 gets + @returns actual value + */ + + ret=OK; + + retval64=setPatternWaitTime(level,t); + + n = sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret==FAIL) + n += sendDataOnly(file_des,mess,sizeof(mess)); + else + n += sendDataOnly(file_des,&retval64,sizeof(retval64)); + + break; + + + + case 4: + n = receiveDataOnly(file_des,pat,sizeof(pat)); + for (addr=0; addr<1024; addr++) + writePatternWord(addr,word); + ret=OK; + retval=0; + n = sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret==FAIL) + n += sendDataOnly(file_des,mess,sizeof(mess)); + else + n += sendDataOnly(file_des,&retval64,sizeof(retval64)); + + break; + + + + default: + ret=FAIL; + printf(mess); + sprintf(mess,"%s - wrong mode %d\n",mess, mode); + n = sendDataOnly(file_des,&ret,sizeof(ret)); + n += sendDataOnly(file_des,mess,sizeof(mess)); + } + + + // return ok / fail + return ret; }