diff --git a/slsDetectorServers/ctbDetectorServer/RegisterDefs.h b/slsDetectorServers/ctbDetectorServer/RegisterDefs.h index 6c30913c3..3c269edfc 100755 --- a/slsDetectorServers/ctbDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/ctbDetectorServer/RegisterDefs.h @@ -497,14 +497,14 @@ #define PATTERN_WAIT_TIMER_2_LSB_REG (0x76 << MEM_MAP_SHIFT) #define PATTERN_WAIT_TIMER_2_MSB_REG (0x77 << MEM_MAP_SHIFT) -/* ADC Disable RW register TODO */ -#define ADC_DISABLE_REG (0x78 << MEM_MAP_SHIFT) +/* Readout enable RW register */ +#define READOUT_10G_ENABLE_REG (0x79 << MEM_MAP_SHIFT) -/* DAC Value RW register TODO */ -//#define DAC_VALUE_REG (0x79 << MEM_MAP_SHIFT) +#define READOUT_10G_ENABLE_ANLG_OFST (0) +#define READOUT_10G_ENABLE_ANLG_MSK (0x000000FF << READOUT_10G_ENABLE_ANLG_OFST) +#define READOUT_10G_ENABLE_DGTL_OFST (8) +#define READOUT_10G_ENABLE_DGTL_MSK (0x00000001 << READOUT_10G_ENABLE_DGTL_OFST) -/* DAC Number RW register TODO */ -//#define DAC_NUMBER_REG (0x7A << MEM_MAP_SHIFT) /* Digital Bit External Trigger RW register */ #define DBIT_EXT_TRG_REG (0x7B << MEM_MAP_SHIFT) @@ -548,9 +548,8 @@ #define I2C_SDA_HOLD_REG (0x10A << MEM_MAP_SHIFT) //fixme: upto 0x10f - - - +/* Round Robin */ +#define RXR_ENDPOINT_START_REG (0x1000 << MEM_MAP_SHIFT) diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index cce517490..26fd6c725 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index e3ea051c8..04b651d5c 100755 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -41,6 +41,7 @@ int virtual_status = 0; int virtual_stop = 0; #endif +// 1g readout int dataBytes = 0; int analogDataBytes = 0; int digitalDataBytes = 0; @@ -48,18 +49,19 @@ char* analogData = 0; char* digitalData = 0; char volatile *analogDataPtr = 0; char volatile *digitalDataPtr = 0; - char udpPacketData[UDP_PACKET_DATA_BYTES + sizeof(sls_detector_header)]; +uint32_t adcEnableMask_1g = 0; + +// 10g readout +uint8_t adcEnableMask_10g = 0; + int32_t clkPhase[NUM_CLOCKS] = {0, 0, 0, 0}; uint32_t clkFrequency[NUM_CLOCKS] = {40, 20, 20, 200}; - int dacValues[NDAC] = {0}; // software limit that depends on the current chip on the ctb int vLimit = 0; - int highvoltage = 0; -uint32_t adcEnableMask = 0; int analogEnable = 1; int digitalEnable = 0; int naSamples = 1; @@ -459,7 +461,8 @@ void setupDetector() { } vLimit = DEFAULT_VLIMIT; highvoltage = 0; - adcEnableMask = BIT_32_MSK; + adcEnableMask_1g = 0; + adcEnableMask_10g = 0; analogEnable = 1; digitalEnable = 0; naSamples = 1; @@ -533,22 +536,22 @@ void setupDetector() { setPeriod(DEFAULT_PERIOD); setDelayAfterTrigger(DEFAULT_DELAY); setTiming(DEFAULT_TIMING_MODE); - setReadoutMode(ANALOG_ONLY); - - // enable all ADC channels - setADCEnableMask(BIT_32_MSK); + setADCEnableMask(BIT32_MSK); + setADCEnableMask_10G(BIT32_MSK); + if (setReadoutMode(ANALOG_ONLY) == FAIL) { + strcpy(initErrorMessage, + "Could not set readout mode to analog only.\n"); + FILE_LOG(logERROR, ("%s\n\n", initErrorMessage)); + initError = FAIL; + } } -int allocateRAM() { +int updateDatabytesandAllocateRAM() { + int oldAnalogDataBytes = analogDataBytes; int oldDigitalDataBytes = digitalDataBytes; updateDataBytes(); - // only allcoate RAM for 1 giga udp (if 10G, return) - if (enableTenGigabitEthernet(-1)) - return OK; - - // update only if change in databytes if (analogDataBytes == oldAnalogDataBytes && digitalDataBytes == oldDigitalDataBytes) { FILE_LOG(logDEBUG1, ("RAM size (Analog:%d, Digital:%d) already allocated. Nothing to be done.\n", @@ -602,12 +605,12 @@ void updateDataBytes() { // analog if (analogEnable) { - if (adcEnableMask == BIT_32_MSK) + if (adcEnableMask_1g == BIT32_MSK) nachans = 32; else { int ichan = 0; for (ichan = 0; ichan < NCHAN_ANALOG; ++ichan) { - if (adcEnableMask & (1 << ichan)) + if (adcEnableMask_1g & (1 << ichan)) ++nachans; } } @@ -666,23 +669,71 @@ int setDynamicRange(int dr){ } int setADCEnableMask(uint32_t mask) { - FILE_LOG(logINFO, ("Setting adcEnableMask to 0x%08x\n", mask)); - adcEnableMask = mask; - - // get disable mask - mask ^= BIT_32_MSK; - bus_w(ADC_DISABLE_REG, mask); - - // update databytes and allocate ram - return allocateRAM(); + if (mask == 0u) { + FILE_LOG(logERROR, ("Cannot set 1gb adc mask to 0\n")); + return FAIL; + } + FILE_LOG(logINFO, ("Setting adcEnableMask 1G to 0x%08x\n", mask)); + adcEnableMask_1g = mask; + // 1Gb enabled + if (!enableTenGigabitEthernet(-1)) { + if (updateDatabytesandAllocateRAM() == FAIL) { + return FAIL; + } + } + return OK; } uint32_t getADCEnableMask() { - uint32_t retval = bus_r(ADC_DISABLE_REG); + return adcEnableMask_1g; +} - // get enable mask - retval ^= BIT_32_MSK; - adcEnableMask = retval; +void setADCEnableMask_10G(uint32_t mask) { + if (mask == 0u) { + FILE_LOG(logERROR, ("Cannot set 10gb adc mask to 0\n")); + return; + } + // convert 32 bit mask to 8 bit mask + uint8_t actualMask = 0; + if (mask != 0) { + int ival = 0; + int ich = 0; + for (ich = 0; ich < NCHAN_ANALOG; ich = ich + 4) { + if ((1 << ich) & mask) { + actualMask |= (1 << ival++); + } + } + } + + FILE_LOG(logINFO, ("Setting adcEnableMask 10G to 0x%x (from 0x%08x)\n", actualMask, mask)); + adcEnableMask_10g = actualMask; + if (analogEnable) { + uint32_t addr = READOUT_10G_ENABLE_REG; + bus_w(addr, bus_r(addr) & (~READOUT_10G_ENABLE_ANLG_MSK)); + bus_w(addr, bus_r(addr) | ((adcEnableMask_10g << READOUT_10G_ENABLE_ANLG_OFST) & READOUT_10G_ENABLE_ANLG_MSK)); + } +} + +uint32_t getADCEnableMask_10G() { + if (analogEnable) { + adcEnableMask_10g = ((bus_r(READOUT_10G_ENABLE_REG) & READOUT_10G_ENABLE_ANLG_MSK) >> READOUT_10G_ENABLE_ANLG_OFST); + } + + // convert 8 bit mask to 32 bit mask + uint32_t retval = 0; + if (adcEnableMask_10g) { + int ival = 0; + int iloop = 0; + for (ival = 0; ival < 8; ++ival) { + // if bit in 8 bit mask set + if ((1 << ival) & adcEnableMask_10g) { + // set it for 4 bits in 32 bit mask + for (iloop = 0; iloop < 4; ++iloop) { + retval |= (1 << (ival * 4 + iloop)); + } + } + } + } return retval; } @@ -722,31 +773,61 @@ int setExternalSampling(int val) { /* parameters - readout */ int setReadoutMode(enum readoutMode mode) { - uint32_t addr = CONFIG_REG; + analogEnable = 0; + digitalEnable = 0; switch(mode) { case ANALOG_ONLY: FILE_LOG(logINFO, ("Setting Analog Only Readout\n")); - bus_w(addr, bus_r(addr) & (~CONFIG_DSBL_ANLG_OTPT_MSK) & (~CONFIG_ENBLE_DGTL_OTPT_MSK)); + analogEnable = 1; break; case DIGITAL_ONLY: FILE_LOG(logINFO, ("Setting Digital Only Readout\n")); - bus_w(addr, bus_r(addr) | CONFIG_DSBL_ANLG_OTPT_MSK | CONFIG_ENBLE_DGTL_OTPT_MSK); + digitalEnable = 1; break; case ANALOG_AND_DIGITAL: FILE_LOG(logINFO, ("Setting Analog & Digital Readout\n")); - bus_w(addr, (bus_r(addr) & (~CONFIG_DSBL_ANLG_OTPT_MSK)) | CONFIG_ENBLE_DGTL_OTPT_MSK); + analogEnable = 1; + digitalEnable = 1; break; default: FILE_LOG(logERROR, ("Cannot set unknown readout flag. 0x%x\n", mode)); return FAIL; } - uint32_t regval = bus_r(addr); - analogEnable = (((regval & CONFIG_DSBL_ANLG_OTPT_MSK) >> CONFIG_DSBL_ANLG_OTPT_OFST) ? 0 : 1); - digitalEnable = ((regval & CONFIG_ENBLE_DGTL_OTPT_MSK) >> CONFIG_ENBLE_DGTL_OTPT_OFST); - // update databytes and allocate ram - if (allocateRAM() == FAIL) { - return FAIL; + + uint32_t addr = CONFIG_REG; + uint32_t addr_readout_10g = READOUT_10G_ENABLE_REG; + // default: analog only + bus_w(addr, bus_r(addr) & (~CONFIG_DSBL_ANLG_OTPT_MSK) & (~CONFIG_ENBLE_DGTL_OTPT_MSK)); + bus_w(addr_readout_10g, bus_r(addr_readout_10g) & (~READOUT_10G_ENABLE_ANLG_MSK) & ~(READOUT_10G_ENABLE_DGTL_MSK)); + bus_w(addr_readout_10g, bus_r(addr_readout_10g) | ((adcEnableMask_10g << READOUT_10G_ENABLE_ANLG_OFST) & READOUT_10G_ENABLE_ANLG_MSK)); + + // disable analog (digital only) + if (!analogEnable) { + bus_w(addr, bus_r(addr) | CONFIG_DSBL_ANLG_OTPT_MSK); + bus_w(addr_readout_10g, bus_r(addr_readout_10g) & (~READOUT_10G_ENABLE_ANLG_MSK)); + } + // enable digital (analog and digital) + if (digitalEnable) { + bus_w(addr, bus_r(addr) | CONFIG_ENBLE_DGTL_OTPT_MSK); + bus_w(addr_readout_10g, bus_r(addr_readout_10g) | READOUT_10G_ENABLE_DGTL_MSK); + } + + + // 1Gb + if (!enableTenGigabitEthernet(-1)) { + if (updateDatabytesandAllocateRAM() == FAIL) { + return FAIL; + } + } + + // 10Gb + else { + // validate adcenablemask for 10g + if (analogEnable && adcEnableMask_10g != ((bus_r(READOUT_10G_ENABLE_REG) & READOUT_10G_ENABLE_ANLG_MSK) >> READOUT_10G_ENABLE_ANLG_OFST)) { + FILE_LOG(logERROR, ("Setting readout mode failed. Could not set 10g adc enable mask to 0x%x\n.", adcEnableMask_10g)); + return FAIL; + } } return OK; } @@ -800,8 +881,12 @@ int setNumAnalogSamples(int val) { naSamples = val; bus_w(SAMPLES_REG, bus_r(SAMPLES_REG) &~ SAMPLES_ANALOG_MSK); bus_w(SAMPLES_REG, bus_r(SAMPLES_REG) | ((val << SAMPLES_ANALOG_OFST) & SAMPLES_ANALOG_MSK)); - if (allocateRAM() == FAIL) { - return FAIL; + + // 1Gb + if (!enableTenGigabitEthernet(-1)) { + if (updateDatabytesandAllocateRAM() == FAIL) { + return FAIL; + } } return OK; } @@ -819,8 +904,11 @@ int setNumDigitalSamples(int val) { ndSamples = val; bus_w(SAMPLES_REG, bus_r(SAMPLES_REG) &~ SAMPLES_DIGITAL_MSK); bus_w(SAMPLES_REG, bus_r(SAMPLES_REG) | ((val << SAMPLES_DIGITAL_OFST) & SAMPLES_DIGITAL_MSK)); - if (allocateRAM() == FAIL) { - return FAIL; + // 1Gb + if (!enableTenGigabitEthernet(-1)) { + if (updateDatabytesandAllocateRAM() == FAIL) { + return FAIL; + } } return OK; } @@ -1359,42 +1447,39 @@ enum timingMode getTiming() { /* configure mac */ -long int calcChecksum(int sourceip, int destip) { - ip_header ip; - ip.ip_ver = 0x4; - ip.ip_ihl = 0x5; - ip.ip_tos = 0x0; - ip.ip_len = IP_PACKETSIZE; - ip.ip_ident = 0x0000; - ip.ip_flag = 0x2; //not nibble aligned (flag& offset - ip.ip_offset = 0x000; - ip.ip_ttl = 0x40; - ip.ip_protocol = 0x11; - ip.ip_chksum = 0x0000 ; // pseudo - ip.ip_sourceip = sourceip; - ip.ip_destip = destip; - - int count = sizeof(ip); - - unsigned short *addr; - addr = (unsigned short*) &(ip); /* warning: assignment from incompatible pointer type */ - +void calcChecksum(udp_header* udp) { + int count = IP_HEADER_SIZE; long int sum = 0; - while( count > 1 ) { + + // start at ip_tos as the memory is not continous for ip header + uint16_t *addr = (uint16_t*) (&(udp->ip_tos)); + + sum += *addr++; + count -= 2; + + // ignore ethertype (from udp header) + addr++; + + // from identification to srcip_lsb + while( count > 2 ) { sum += *addr++; count -= 2; } + + // ignore src udp port (from udp header) + addr++; + if (count > 0) sum += *addr; // Add left-over byte, if any - while (sum>>16) + while (sum >> 16) sum = (sum & 0xffff) + (sum >> 16);// Fold 32-bit sum to 16 bits - long int checksum = (~sum) & 0xffff; - FILE_LOG(logINFO, ("IP checksum is 0x%lx\n",checksum)); - return checksum; + long int checksum = sum & 0xffff; + checksum += UDP_IP_HEADER_LENGTH_BYTES; + FILE_LOG(logINFO, ("\tIP checksum is 0x%lx\n",checksum)); + udp->ip_checksum = checksum; } - int configureMAC(){ uint32_t sourceip = udpDetails.srcip; uint32_t destip = udpDetails.dstip; @@ -1409,8 +1494,7 @@ int configureMAC(){ // 1 giga udp if (!enableTenGigabitEthernet(-1)) { FILE_LOG(logINFOBLUE, ("Configuring 1G MAC\n")); - // if it was in 10G mode, it was not allocating RAM - if (allocateRAM() == FAIL) + if (updateDatabytesandAllocateRAM() == FAIL) return -1; char cDestIp[MAX_STR_LENGTH]; memset(cDestIp, 0, MAX_STR_LENGTH); @@ -1450,35 +1534,40 @@ int configureMAC(){ (long long unsigned int)destmac)); FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",destport, destport)); - long int checksum=calcChecksum(sourceip, destip); - bus_w(TX_IP_REG, sourceip); - bus_w(RX_IP_REG, destip); + // start addr + uint32_t addr = RXR_ENDPOINT_START_REG; + // get struct memory + udp_header *udp = (udp_header*) (Blackfin_getBaseAddress() + addr * 2); + memset(udp, 0, sizeof(udp_header)); - uint32_t val = 0; + // mac addresses + // msb (32) + lsb (16) + udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK); + udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK); + // msb (16) + lsb (32) + udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK); + udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK); - val = ((sourcemac >> LSB_OF_64_BIT_REG_OFST) & BIT_32_MSK); - bus_w(TX_MAC_LSB_REG, val); - FILE_LOG(logDEBUG1, ("Read from TX_MAC_LSB_REG: 0x%08x\n", bus_r(TX_MAC_LSB_REG))); + // ip addresses + udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK); + udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK); + udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK); + udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK); - val = ((sourcemac >> MSB_OF_64_BIT_REG_OFST) & BIT_32_MSK); - bus_w(TX_MAC_MSB_REG,val); - FILE_LOG(logDEBUG1, ("Read from TX_MAC_MSB_REG: 0x%08x\n", bus_r(TX_MAC_MSB_REG))); + // source port + udp->udp_srcport = sourceport; + udp->udp_destport = destport; - val = ((destmac >> LSB_OF_64_BIT_REG_OFST) & BIT_32_MSK); - bus_w(RX_MAC_LSB_REG, val); - FILE_LOG(logDEBUG1, ("Read from RX_MAC_LSB_REG: 0x%08x\n", bus_r(RX_MAC_LSB_REG))); + // other defines + udp->udp_ethertype = 0x800; + udp->ip_ver = 0x4; + udp->ip_ihl = 0x5; + udp->ip_flags = 0x2; //FIXME + udp->ip_ttl = 0x40; + udp->ip_protocol = 0x11; + // total length is redefined in firmware - val = ((destmac >> MSB_OF_64_BIT_REG_OFST) & BIT_32_MSK); - bus_w(RX_MAC_MSB_REG, val); - FILE_LOG(logDEBUG1, ("Read from RX_MAC_MSB_REG: 0x%08x\n", bus_r(RX_MAC_MSB_REG))); - - val = (((sourceport << UDP_PORT_TX_OFST) & UDP_PORT_TX_MSK) | - ((destport << UDP_PORT_RX_OFST) & UDP_PORT_RX_MSK)); - bus_w(UDP_PORT_REG, val); - FILE_LOG(logDEBUG1, ("Read from UDP_PORT_REG: 0x%08x\n", bus_r(UDP_PORT_REG))); - - bus_w(TX_IP_CHECKSUM_REG,(checksum << TX_IP_CHECKSUM_OFST) & TX_IP_CHECKSUM_MSK); - FILE_LOG(logDEBUG1, ("Read from TX_IP_CHECKSUM_REG: 0x%08x\n", bus_r(TX_IP_CHECKSUM_REG))); + calcChecksum(udp); cleanFifos();//FIXME: resetPerpheral() for ctb? resetPeripheral(); @@ -2327,7 +2416,7 @@ void readSample(int ns) { for (ich = 0; ich < NCHAN_ANALOG; ++ich) { // if channel is in enable mask - if ((1 << ich) & (adcEnableMask)) { + if ((1 << ich) & (adcEnableMask_1g)) { // unselect channel bus_w(addr, bus_r(addr) & ~(DUMMY_FIFO_CHNNL_SLCT_MSK)); diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h index dd3fffaea..dd26567da 100755 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h @@ -4,23 +4,36 @@ #define MIN_REQRD_VRSN_T_RD_API 0x181130 -#define REQRD_FRMWR_VRSN 0x190821 +#define REQRD_FRMWR_VRSN 0x191127 #define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000) /* Struct Definitions */ -typedef struct ip_header_struct { - uint16_t ip_len; - uint8_t ip_tos; - uint8_t ip_ihl:4 ,ip_ver:4; - uint16_t ip_offset:13,ip_flag:3; - uint16_t ip_ident; - uint16_t ip_chksum; - uint8_t ip_protocol; - uint8_t ip_ttl; - uint32_t ip_sourceip; - uint32_t ip_destip; -} ip_header; +typedef struct udp_header_struct { + uint32_t udp_destmac_msb; + uint16_t udp_srcmac_msb; + uint16_t udp_destmac_lsb; + uint32_t udp_srcmac_lsb; + uint8_t ip_tos; + uint8_t ip_ihl: 4, ip_ver: 4; + uint16_t udp_ethertype; + uint16_t ip_identification; + uint16_t ip_totallength; + uint8_t ip_protocol; + uint8_t ip_ttl; + uint16_t ip_fragmentoffset: 13, ip_flags: 3; + uint16_t ip_srcip_msb; + uint16_t ip_checksum; + uint16_t ip_destip_msb; + uint16_t ip_srcip_lsb; + uint16_t udp_srcport; + uint16_t ip_destip_lsb; + uint16_t udp_checksum; + uint16_t udp_destport; +} udp_header; + +#define IP_HEADER_SIZE (20) +#define UDP_IP_HEADER_LENGTH_BYTES (28) /* Enums */ enum ADCINDEX {V_PWR_IO, V_PWR_A, V_PWR_B, V_PWR_C, V_PWR_D, I_PWR_IO, I_PWR_A, I_PWR_B, I_PWR_C, I_PWR_D}; @@ -91,9 +104,9 @@ enum CLKINDEX {RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS}; /* MSB & LSB DEFINES */ #define MSB_OF_64_BIT_REG_OFST (32) #define LSB_OF_64_BIT_REG_OFST (0) -#define BIT_32_MSK (0xFFFFFFFF) +#define BIT32_MSK (0xFFFFFFFF) +#define BIT16_MASK (0xFFFF) -#define IP_PACKETSIZE (0x2032) #define ADC_PORT_INVERT_VAL (0x453b2593) #define MAXIMUM_ADC_CLK (65) #define PLL_VCO_FREQ_MHZ (800) diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index 2276b519c..22a7af021 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index 71c6955fc..5a9bdfa5e 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 38441123d..78316b51a 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index b12bd35c5..7dfd62082 100755 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -33,7 +33,8 @@ typedef struct udp_header_struct { uint16_t udp_destport; } udp_header; -#define IP_HEADER_SIZE 20 +#define IP_HEADER_SIZE (20) +#define UDP_IP_HEADER_LENGTH_BYTES (28) /* Enums */ @@ -93,7 +94,6 @@ enum CLKINDEX {RUN_CLK, ADC_CLK, NUM_CLOCKS}; #define MAX_PHASE_SHIFTS (160) #define BIT16_MASK (0xFFFF) -#define UDP_IP_HEADER_LENGTH_BYTES (28) diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 92ef7a182..ac5b75476 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 6a00e5ddb..331d91373 100755 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -80,7 +80,7 @@ void allocateDetectorStructureMemory(); #endif void setupDetector(); #if defined(CHIPTESTBOARDD) || defined(MOENCHD) -int allocateRAM(); +int updateDatabytesandAllocateRAM(); void updateDataBytes(); #endif @@ -138,6 +138,8 @@ uint32_t getADCInvertRegister(); #if defined(CHIPTESTBOARDD) || defined(MOENCHD) int setADCEnableMask(uint32_t mask); uint32_t getADCEnableMask(); +void setADCEnableMask_10G(uint32_t mask); +uint32_t getADCEnableMask_10G(); void setADCInvertRegister(uint32_t val); uint32_t getADCInvertRegister(); int setExternalSamplingSource(int val); @@ -305,12 +307,9 @@ void selectPrimaryInterface(int val); int getPrimaryInterface(); void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, uint64_t destmac, uint32_t destport, uint64_t sourcemac, uint32_t sourceip, uint32_t sourceport); #endif -#if defined(JUNGFRAUD) || defined(GOTTHARD2D) || defined(MYTHEN3D) +#if defined(JUNGFRAUD) || defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD) || defined(MOENCHD) void calcChecksum(udp_header* udp); #endif -#if defined(CHIPTESTBOARDD) || defined(MOENCHD) -long int calcChecksum(int sourceip, int destip); -#endif #ifdef GOTTHARDD int getAdcConfigured(); #endif diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index ba833e0c4..bd2e1bee0 100755 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -201,4 +201,6 @@ int set_veto_photon(int); int get_veto_photon(int); int set_veto_refernce(int); int get_burst_mode(int); -int set_burst_mode(int); \ No newline at end of file +int set_burst_mode(int); +int set_adc_enable_mask_10g(int); +int get_adc_enable_mask_10g(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 4a44cc69e..8a8e3fd8c 100755 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -303,6 +303,8 @@ const char* getFunctionName(enum detFuncs func) { case F_SET_VETO_REFERENCE: return "F_SET_VETO_REFERENCE"; case F_GET_BURST_MODE: return "F_GET_BURST_MODE"; case F_SET_BURST_MODE: return "F_SET_BURST_MODE"; + case F_SET_ADC_ENABLE_MASK_10G: return "F_SET_ADC_ENABLE_MASK_10G"; + case F_GET_ADC_ENABLE_MASK_10G: return "F_GET_ADC_ENABLE_MASK_10G"; default: return "Unknown Function"; } @@ -483,6 +485,8 @@ void function_table() { flist[F_SET_VETO_REFERENCE] = &set_veto_refernce; flist[F_GET_BURST_MODE] = &get_burst_mode; flist[F_SET_BURST_MODE] = &set_burst_mode; + flist[F_SET_ADC_ENABLE_MASK_10G] = &set_adc_enable_mask_10g; + flist[F_GET_ADC_ENABLE_MASK_10G] = &get_adc_enable_mask_10g; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -2783,12 +2787,23 @@ int send_update(int file_des) { sendData(file_des, &retval.xmin, sizeof(int), INT32); sendData(file_des, &retval.xmax, sizeof(int), INT32); #endif + + // tengiga +#if defined(EIGERD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) + i32 = enableTenGigabitEthernet(-1); + n = sendData(file_des,&i32,sizeof(i32),INT32); + if (n < 0) return printSocketReadError(); +#endif #if defined(CHIPTESTBOARDD) || defined(MOENCHD) - // adcmask + // 1g adcmask i32 = getADCEnableMask(); n = sendData(file_des,&i32,sizeof(i32),INT32); if (n < 0) return printSocketReadError(); + // 10g adc mask + i32 = getADCEnableMask_10G(); + n = sendData(file_des,&i32,sizeof(i32),INT32); + if (n < 0) return printSocketReadError(); #endif // num udp interfaces @@ -4231,7 +4246,7 @@ int set_adc_enable_mask(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG1, ("Seting ADC Enable Mask to %u\n", arg)); + FILE_LOG(logDEBUG1, ("Seting 1Gb ADC Enable Mask to %u\n", arg)); #if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) functionNotImplemented(); @@ -4240,13 +4255,13 @@ int set_adc_enable_mask(int file_des) { if (Server_VerifyLock() == OK) { ret = setADCEnableMask(arg); if (ret == FAIL) { - sprintf(mess, "Could not set ADC Enable mask to 0x%x. Could not allocate ram\n", arg); + sprintf(mess, "Could not set 1Gb ADC Enable mask to 0x%x.\n", arg); FILE_LOG(logERROR,(mess)); } else { uint32_t retval = getADCEnableMask(); if (arg != retval) { ret = FAIL; - sprintf(mess, "Could not set ADC Enable mask. Set 0x%x, but read 0x%x\n", arg, retval); + sprintf(mess, "Could not set 1Gb ADC Enable mask. Set 0x%x, but read 0x%x\n", arg, retval); FILE_LOG(logERROR,(mess)); } } @@ -4261,14 +4276,58 @@ int get_adc_enable_mask(int file_des) { memset(mess, 0, sizeof(mess)); uint32_t retval = -1; - FILE_LOG(logDEBUG1, ("Getting ADC Enable Mask \n")); + FILE_LOG(logDEBUG1, ("Getting 1Gb ADC Enable Mask \n")); #if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) functionNotImplemented(); #else // get retval = getADCEnableMask(); - FILE_LOG(logDEBUG1, ("ADC Enable Mask retval: %u\n", retval)); + FILE_LOG(logDEBUG1, ("1Gb ADC Enable Mask retval: %u\n", retval)); +#endif + return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval)); +} + +int set_adc_enable_mask_10g(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + uint32_t arg = 0; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG1, ("Seting 10Gb ADC Enable Mask to %u\n", arg)); + +#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) + functionNotImplemented(); +#else + // only set + if (Server_VerifyLock() == OK) { + setADCEnableMask_10G(arg); + uint32_t retval = getADCEnableMask_10G(); + if (arg != retval) { + ret = FAIL; + sprintf(mess, "Could not set 10Gb ADC Enable mask. Set 0x%x, but read 0x%x\n", arg, retval); + FILE_LOG(logERROR,(mess)); + } + } +#endif + return Server_SendResult(file_des, INT32, UPDATE, NULL, 0); +} + + +int get_adc_enable_mask_10g(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + uint32_t retval = -1; + + FILE_LOG(logDEBUG1, ("Getting 10Gb ADC Enable Mask\n")); + +#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) + functionNotImplemented(); +#else + // get + retval = getADCEnableMask_10G(); + FILE_LOG(logDEBUG1, ("10Gb ADC Enable Mask retval: %u\n", retval)); #endif return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval)); } @@ -5481,7 +5540,7 @@ int set_readout_mode(int file_des) { if (ret == OK) { if (setReadoutMode(arg) == FAIL) { ret = FAIL; - sprintf(mess, "Could not set allocate RAM to set readout mode\n"); + sprintf(mess, "Could not set readout mode\n"); FILE_LOG(logERROR,(mess)); } else { int retval = getReadoutMode(); diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 2df9aad90..4091c662e 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -1015,6 +1015,12 @@ class Detector { /** [CTB]*/ void setADCEnableMask(uint32_t mask, Positions pos = {}); + /** [CTB]*/ + Result getTenGigaADCEnableMask(Positions pos = {}) const; + + /** [CTB]*/ + void setTenGigaADCEnableMask(uint32_t mask, Positions pos = {}); + /** [CTB] */ Result getADCInvert(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 3f1501321..d790e8d09 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -497,6 +497,8 @@ class CmdProxy { {"rx_udpmac2", "udp_dstmac2"}, {"rx_udpport", "udp_dstport"}, {"rx_udpport2", "udp_dstport2"}, + {"flowcontrol_10g", "flowcontrol10g"}, + /* Receiver Config */ {"r_silent", "rx_silent"}, @@ -698,7 +700,7 @@ class CmdProxy { {"udp_dstport2", &CmdProxy::udp_dstport2}, {"rx_printconfig", &CmdProxy::rx_printconfig}, {"tengiga", &CmdProxy::tengiga}, - {"flowcontrol_10g", &CmdProxy::flowcontrol_10g}, + {"flowcontrol10g", &CmdProxy::flowcontrol10g}, {"txndelay_frame", &CmdProxy::txndelay_frame}, {"txndelay_left", &CmdProxy::txndelay_left}, {"txndelay_right", &CmdProxy::txndelay_right}, @@ -815,6 +817,7 @@ class CmdProxy { {"im_io", &CmdProxy::im_io}, {"adc", &CmdProxy::SlowAdc}, {"adcenable", &CmdProxy::adcenable}, + {"adcenable10g", &CmdProxy::adcenable10g}, {"adcinvert", &CmdProxy::adcinvert}, {"extsampling", &CmdProxy::extsampling}, {"extsamplingsrc", &CmdProxy::extsamplingsrc}, @@ -1343,7 +1346,7 @@ class CmdProxy { INTEGER_COMMAND(tengiga, getTenGiga, setTenGiga, std::stoi, "[0, 1]\n\t[Eiger][Ctb] 10GbE Enable."); - INTEGER_COMMAND(flowcontrol_10g, getTenGigaFlowControl, setTenGigaFlowControl, std::stoi, + INTEGER_COMMAND(flowcontrol10g, getTenGigaFlowControl, setTenGigaFlowControl, std::stoi, "[0, 1]\n\t[Eiger][Jungfrau] 10GbE Flow Control."); INTEGER_COMMAND(txndelay_frame, getTransmissionDelayFrame, setTransmissionDelayFrame, std::stoi, @@ -1607,7 +1610,10 @@ class CmdProxy { "\n\t[Ctb] Measured current of power supply io in mA."); INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask, stoiHex, - "[bitmask]\n\t[Ctb] ADC Enable Mask."); + "[bitmask]\n\t[Ctb] ADC Enable Mask for 1Gb Mode for each 32 ADC channel."); + + INTEGER_COMMAND_HEX(adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask, stoiHex, + "[bitmask]\n\t[Ctb] ADC Enable Mask for 10Gb mode for each 32 ADC channel. However, if any of consecutive 4 bits are enabled, the complete 4 bits are enabled."); INTEGER_COMMAND_HEX(adcinvert, getADCInvert, setADCInvert, stoiHex, "[bitmask]\n\t[Ctb][Jungfrau] ADC Inversion Mask.\n\t[Jungfrau] Inversions on top of the default mask."); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 887bbec9c..795045780 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1368,6 +1368,14 @@ void Detector::setADCEnableMask(uint32_t mask, Positions pos) { pimpl->Parallel(&slsDetector::setADCEnableMask, pos, mask); } +Result Detector::getTenGigaADCEnableMask(Positions pos) const { + return pimpl->Parallel(&slsDetector::getTenGigaADCEnableMask, pos); +} + +void Detector::setTenGigaADCEnableMask(uint32_t mask, Positions pos) { + pimpl->Parallel(&slsDetector::setTenGigaADCEnableMask, pos, mask); +} + Result Detector::getADCInvert(Positions pos) const { return pimpl->Parallel(&slsDetector::getADCInvert, pos); } diff --git a/slsDetectorSoftware/src/multiSlsDetector.h b/slsDetectorSoftware/src/multiSlsDetector.h index 8398c392c..e992658c9 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.h +++ b/slsDetectorSoftware/src/multiSlsDetector.h @@ -17,7 +17,7 @@ class detectorData; #include #define MULTI_SHMAPIVERSION 0x190809 -#define MULTI_SHMVERSION 0x190814 +#define MULTI_SHMVERSION 0x190819 #define SHORT_STRING_LENGTH 50 #define DATE_LENGTH 30 diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index 3b1a971e3..e50065973 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -323,7 +323,8 @@ void slsDetector::initializeDetectorStructure(detectorType type) { sls::strcpy_safe(shm()->settingsDir, getenv("HOME")); shm()->roi.xmin = -1; shm()->roi.xmax = -1; - shm()->adcEnableMask = BIT32_MASK; + shm()->adcEnableMaskOneGiga = BIT32_MASK; + shm()->adcEnableMaskTenGiga = BIT32_MASK; shm()->roMode = ANALOG_ONLY; shm()->currentSettings = UNINITIALIZED; shm()->currentThresholdEV = -1; @@ -334,8 +335,8 @@ void slsDetector::initializeDetectorStructure(detectorType type) { sls::strcpy_safe(shm()->rxHostname, "none"); shm()->rxTCPPort = DEFAULT_PORTNO + 2; shm()->useReceiverFlag = false; - shm()->tenGigaEnable = 0; - shm()->flippedDataX = 0; + shm()->tenGigaEnable = false; + shm()->flippedDataX = false; shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO + (detId * ((shm()->myDetectorType == EIGER) ? 2 : 1)); shm()->rxZmqport = DEFAULT_ZMQ_RX_PORTNO + @@ -552,7 +553,7 @@ void slsDetector::updateNumberOfChannels() { // analog channels (normal, analog/digital readout) if (shm()->roMode == slsDetectorDefs::ANALOG_ONLY || shm()->roMode == slsDetectorDefs::ANALOG_AND_DIGITAL) { - uint32_t mask = shm()->adcEnableMask; + uint32_t mask = shm()->tenGigaEnable ? shm()->adcEnableMaskTenGiga : shm()->adcEnableMaskOneGiga; if (mask == BIT32_MASK) { nachans = 32; } else { @@ -771,14 +772,27 @@ void slsDetector::updateCachedDetectorVariables() { shm()->roi.xmax = i32; } + // 10GbE + if (shm()->myDetectorType == EIGER || + shm()->myDetectorType == CHIPTESTBOARD || + shm()->myDetectorType == MOENCH) { + n += client.Receive(&i32, sizeof(i32)); + shm()->tenGigaEnable = static_cast(i32); + } + if (shm()->myDetectorType == CHIPTESTBOARD || shm()->myDetectorType == MOENCH) { - // adcmask + // 1gb adcmask uint32_t u32 = 0; n += client.Receive(&u32, sizeof(u32)); - shm()->adcEnableMask = u32; + shm()->adcEnableMaskOneGiga = u32; + + // 10gb adcmask + n += client.Receive(&u32, sizeof(u32)); + shm()->adcEnableMaskTenGiga = u32; + if (shm()->myDetectorType == MOENCH) - setAdditionalJsonParameter("adcmask", std::to_string(u32)); + setAdditionalJsonParameter("adcmask", std::to_string(shm()->tenGigaEnable ? shm()->adcEnableMaskTenGiga : shm()->adcEnableMaskOneGiga)); // update #nchan, as it depends on #samples, adcmask, updateNumberOfChannels(); @@ -1780,16 +1794,17 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) { setDeactivatedRxrPaddingMode( static_cast(shm()->rxPadDeactivatedModules)); enableGapPixels(shm()->gappixels); - enableTenGigabitEthernet(shm()->tenGigaEnable); + enableTenGigabitEthernet(static_cast(shm()->tenGigaEnable)); setQuad(getQuad()); break; case CHIPTESTBOARD: setNumberOfAnalogSamples(getNumberOfAnalogSamples()); setNumberOfDigitalSamples(getNumberOfDigitalSamples()); - enableTenGigabitEthernet(shm()->tenGigaEnable); + enableTenGigabitEthernet(static_cast(shm()->tenGigaEnable)); setReadoutMode(shm()->roMode); - setADCEnableMask(shm()->adcEnableMask); + setADCEnableMask(shm()->adcEnableMaskOneGiga); + setTenGigaADCEnableMask(shm()->adcEnableMaskTenGiga); setReceiverDbitOffset(shm()->rxDbitOffset); setReceiverDbitList(shm()->rxDbitList); break; @@ -1797,8 +1812,9 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) { case MOENCH: setNumberOfAnalogSamples(getNumberOfAnalogSamples()); setNumberOfDigitalSamples(getNumberOfDigitalSamples()); - enableTenGigabitEthernet(shm()->tenGigaEnable); - setADCEnableMask(shm()->adcEnableMask); + enableTenGigabitEthernet(static_cast(shm()->tenGigaEnable)); + setADCEnableMask(shm()->adcEnableMaskOneGiga); + setTenGigaADCEnableMask(shm()->adcEnableMaskTenGiga); break; case GOTTHARD: @@ -2589,20 +2605,20 @@ void slsDetector::setADCEnableMask(uint32_t mask) { FILE_LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex << arg << std::dec; sendToDetector(F_SET_ADC_ENABLE_MASK, &arg, sizeof(arg), nullptr, 0); - shm()->adcEnableMask = mask; + shm()->adcEnableMaskOneGiga = mask; // update #nchan, as it depends on #samples, adcmask, updateNumberOfChannels(); // send to processor - if (shm()->myDetectorType == MOENCH) + if (shm()->myDetectorType == MOENCH && shm()->tenGigaEnable == 0) setAdditionalJsonParameter("adcmask", - std::to_string(shm()->adcEnableMask)); + std::to_string(shm()->adcEnableMaskOneGiga)); if (shm()->useReceiverFlag) { int fnum = F_RECEIVER_SET_ADC_MASK; int retval = -1; - mask = shm()->adcEnableMask; + mask = shm()->adcEnableMaskOneGiga; FILE_LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex << mask << std::dec << " in receiver"; sendToReceiver(fnum, mask, retval); @@ -2613,10 +2629,45 @@ uint32_t slsDetector::getADCEnableMask() { uint32_t retval = -1; FILE_LOG(logDEBUG1) << "Getting ADC Enable mask"; sendToDetector(F_GET_ADC_ENABLE_MASK, nullptr, 0, &retval, sizeof(retval)); - shm()->adcEnableMask = retval; + shm()->adcEnableMaskOneGiga = retval; FILE_LOG(logDEBUG1) << "ADC Enable Mask: 0x" << std::hex << retval << std::dec; - return shm()->adcEnableMask; + return shm()->adcEnableMaskOneGiga; +} + +void slsDetector::setTenGigaADCEnableMask(uint32_t mask) { + uint32_t arg = mask; + FILE_LOG(logDEBUG1) << "Setting 10Gb ADC Enable mask to 0x" << std::hex << arg + << std::dec; + sendToDetector(F_SET_ADC_ENABLE_MASK_10G, &arg, sizeof(arg), nullptr, 0); + shm()->adcEnableMaskTenGiga = mask; + + // update #nchan, as it depends on #samples, adcmask, + updateNumberOfChannels(); + + // send to processor + if (shm()->myDetectorType == MOENCH && shm()->tenGigaEnable == 1) + setAdditionalJsonParameter("adcmask", + std::to_string(shm()->adcEnableMaskTenGiga)); + + if (shm()->useReceiverFlag) { + int fnum = F_RECEIVER_SET_ADC_MASK_10G; + int retval = -1; + mask = shm()->adcEnableMaskTenGiga; + FILE_LOG(logDEBUG1) << "Setting 10Gb ADC Enable mask to 0x" << std::hex + << mask << std::dec << " in receiver"; + sendToReceiver(fnum, mask, retval); + } +} + +uint32_t slsDetector::getTenGigaADCEnableMask() { + uint32_t retval = -1; + FILE_LOG(logDEBUG1) << "Getting 10Gb ADC Enable mask"; + sendToDetector(F_GET_ADC_ENABLE_MASK_10G, nullptr, 0, &retval, sizeof(retval)); + shm()->adcEnableMaskTenGiga = retval; + FILE_LOG(logDEBUG1) << "10Gb ADC Enable Mask: 0x" << std::hex << retval + << std::dec; + return shm()->adcEnableMaskTenGiga; } void slsDetector::setADCInvert(uint32_t value) { @@ -2742,23 +2793,22 @@ bool slsDetector::setDeactivatedRxrPaddingMode(int padding) { return shm()->rxPadDeactivatedModules; } -int slsDetector::getFlippedDataX() const { return shm()->flippedDataX; } +bool slsDetector::getFlippedDataX() const { return shm()->flippedDataX; } -int slsDetector::setFlippedDataX(int value) { +void slsDetector::setFlippedDataX(int value) { // replace get with shm value (write to shm right away as it is a det value, // not rx value) if (value > -1) { - shm()->flippedDataX = (value > 0) ? 1 : 0; + shm()->flippedDataX = (value > 0); } int retval = -1; - int arg = shm()->flippedDataX; + int arg = static_cast(shm()->flippedDataX); FILE_LOG(logDEBUG1) << "Setting flipped data across x axis with value: " << arg; if (shm()->useReceiverFlag) { sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, arg, retval); FILE_LOG(logDEBUG1) << "Flipped data:" << retval; } - return shm()->flippedDataX; } int slsDetector::setAllTrimbits(int val) { @@ -3595,15 +3645,15 @@ bool slsDetector::enableDataStreamingFromReceiver(int enable) { return shm()->rxUpstream; } -int slsDetector::enableTenGigabitEthernet(int value) { +bool slsDetector::enableTenGigabitEthernet(int value) { int retval = -1; FILE_LOG(logDEBUG1) << "Enabling / Disabling 10Gbe: " << value; sendToDetector(F_ENABLE_TEN_GIGA, value, retval); FILE_LOG(logDEBUG1) << "10Gbe: " << retval; - shm()->tenGigaEnable = retval; + shm()->tenGigaEnable = static_cast(retval); if (shm()->useReceiverFlag) { retval = -1; - value = shm()->tenGigaEnable; + value = static_cast(shm()->tenGigaEnable); FILE_LOG(logDEBUG1) << "Sending 10Gbe enable to receiver: " << value; sendToReceiver(F_ENABLE_RECEIVER_TEN_GIGA, value, retval); FILE_LOG(logDEBUG1) << "Receiver 10Gbe enable: " << retval; diff --git a/slsDetectorSoftware/src/slsDetector.h b/slsDetectorSoftware/src/slsDetector.h index ad9d00d5d..82a55f1dd 100755 --- a/slsDetectorSoftware/src/slsDetector.h +++ b/slsDetectorSoftware/src/slsDetector.h @@ -13,7 +13,7 @@ class ServerInterface; #define SLS_SHMAPIVERSION 0x190726 -#define SLS_SHMVERSION 0x191030 +#define SLS_SHMVERSION 0x191127 /** * @short structure allocated in shared memory to store detector settings for @@ -65,8 +65,11 @@ struct sharedSlsDetector { /** roi */ slsDetectorDefs::ROI roi; - /** adc enable mask */ - uint32_t adcEnableMask; + /** 1gb adc enable mask */ + uint32_t adcEnableMaskOneGiga; + + /** 10gb adc enable mask */ + uint32_t adcEnableMaskTenGiga; /** readout mode */ slsDetectorDefs::readoutMode roMode; @@ -100,10 +103,10 @@ struct sharedSlsDetector { bool useReceiverFlag; /** 10 Gbe enable*/ - int tenGigaEnable; + bool tenGigaEnable; /** flipped data across x or y axis */ - int flippedDataX; + bool flippedDataX; /** tcp port from gui/different process to receiver (only data) */ int zmqport; @@ -1172,6 +1175,18 @@ class slsDetector : public virtual slsDetectorDefs { */ uint32_t getADCEnableMask(); + /** + * Set 10Gb ADC Enable Mask (CTB, Moench) + * @param mask ADC Enable mask + */ + void setTenGigaADCEnableMask(uint32_t mask); + + /** + * Get 10Gb ADC Enable Mask (CTB, Moench) + * @returns ADC Enable mask + */ + uint32_t getTenGigaADCEnableMask(); + /** * Set ADC invert register (CTB, Moench) * @param value ADC invert value @@ -1269,17 +1284,16 @@ class slsDetector : public virtual slsDetectorDefs { /** * Returns the enable if data will be flipped across x axis (Eiger) - * @returns 1 for flipped, else 0 + * @returns if flipped across x axis */ - int getFlippedDataX() const; + bool getFlippedDataX() const; /** * Sets the enable which determines if * data will be flipped across x axis (Eiger) * @param value 0 or 1 to reset/set or -1 to get value - * @returns enable flipped data across x axis */ - int setFlippedDataX(int value = -1); + void setFlippedDataX(int value = -1); /** * Sets all the trimbits to a particular value (Eiger) @@ -1694,7 +1708,7 @@ class slsDetector : public virtual slsDetectorDefs { * @param i is -1 to get, 0 to disable and 1 to enable * @returns if 10Gbe is enabled */ - int enableTenGigabitEthernet(int value = -1); + bool enableTenGigabitEthernet(int value = -1); /** * Set/get receiver fifo depth diff --git a/slsReceiverSoftware/include/ClientInterface.h b/slsReceiverSoftware/include/ClientInterface.h index 09a3e38f2..ca7a3c7a5 100755 --- a/slsReceiverSoftware/include/ClientInterface.h +++ b/slsReceiverSoftware/include/ClientInterface.h @@ -118,6 +118,7 @@ class ClientInterface : private virtual slsDetectorDefs { int set_udp_port(sls::ServerInterface2 &socket); int set_udp_port2(sls::ServerInterface2 &socket); int set_num_interfaces(sls::ServerInterface2 &socket); + int set_adc_mask_10g(sls::ServerInterface2 &socket); detectorType myDetectorType; std::unique_ptr receiver{nullptr}; diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index b96415014..890e5ee40 100755 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -632,20 +632,21 @@ public: nPixelsY = 1; // 10G if (t) { - /* headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header); - dataSize = UDP_PACKET_DATA_BYTES; + dataSize = 464; packetSize = headerSizeinPacket + dataSize; imageSize = adatabytes + ddatabytes; packetsPerFrame = ceil((double)imageSize / (double)dataSize); standardheader = true; - */ + + /* headerSizeinPacket = 22; dataSize = 8192; packetSize = headerSizeinPacket + dataSize; imageSize = adatabytes + ddatabytes; packetsPerFrame = ceil((double)imageSize / (double)dataSize); standardheader = false; + */ } // 1g udp (via fifo readout) else { diff --git a/slsReceiverSoftware/include/Implementation.h b/slsReceiverSoftware/include/Implementation.h index 634a5461d..800344859 100755 --- a/slsReceiverSoftware/include/Implementation.h +++ b/slsReceiverSoftware/include/Implementation.h @@ -186,6 +186,9 @@ class Implementation : private virtual slsDetectorDefs { uint32_t getADCEnableMask() const; /* [Ctb][Moench] */ int setADCEnableMask(const uint32_t mask); + uint32_t getTenGigaADCEnableMask() const; + /* [Ctb][Moench] */ + int setTenGigaADCEnableMask(const uint32_t mask); std::vector getDbitList() const; /* [Ctb] */ void setDbitList(const std::vector v); @@ -284,7 +287,8 @@ class Implementation : private virtual slsDetectorDefs { bool deactivatedPaddingEnable; int numLinesReadout; readoutMode readoutType; - uint32_t adcEnableMask; + uint32_t adcEnableMaskOneGiga; + uint32_t adcEnableMaskTenGiga; std::vector ctbDbitList; int ctbDbitOffset; int ctbAnalogDataBytes; diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 03629ce24..91f5f2a9a 100755 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -203,6 +203,8 @@ int ClientInterface::function_table(){ flist[F_SET_RECEIVER_UDP_PORT] = &ClientInterface::set_udp_port; flist[F_SET_RECEIVER_UDP_PORT2] = &ClientInterface::set_udp_port2; flist[F_SET_RECEIVER_NUM_INTERFACES] = &ClientInterface::set_num_interfaces; + flist[F_RECEIVER_SET_ADC_MASK_10G] = &ClientInterface::set_adc_mask_10g; + for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) { // FILE_LOG(logDEBUG1) << "function fnum: " << i << " (" << @@ -1137,16 +1139,16 @@ int ClientInterface::set_readout_mode(Interface &socket) { int ClientInterface::set_adc_mask(Interface &socket) { auto arg = socket.Receive(); VerifyIdle(socket); - FILE_LOG(logDEBUG1) << "Setting ADC enable mask: " << arg; + FILE_LOG(logDEBUG1) << "Setting 1Gb ADC enable mask: " << arg; impl()->setADCEnableMask(arg); auto retval = impl()->getADCEnableMask(); if (retval != arg) { std::ostringstream os; - os << "Could not ADC enable mask. Set 0x" << std::hex << arg + os << "Could not set 1Gb ADC enable mask. Set 0x" << std::hex << arg << " but read 0x" << std::hex << retval; throw RuntimeError(os.str()); } - FILE_LOG(logDEBUG1) << "ADC enable mask retval: " << retval; + FILE_LOG(logDEBUG1) << "1Gb ADC enable mask retval: " << retval; return socket.sendResult(retval); } @@ -1298,4 +1300,20 @@ int ClientInterface::set_num_interfaces(Interface &socket) { throw RuntimeError("Failed to set number of interfaces"); } return socket.Send(OK); +} + +int ClientInterface::set_adc_mask_10g(Interface &socket) { + auto arg = socket.Receive(); + VerifyIdle(socket); + FILE_LOG(logDEBUG1) << "Setting 10Gb ADC enable mask: " << arg; + impl()->setTenGigaADCEnableMask(arg); + auto retval = impl()->getTenGigaADCEnableMask(); + if (retval != arg) { + std::ostringstream os; + os << "Could not 10gb ADC enable mask. Set 0x" << std::hex << arg + << " but read 0x" << std::hex << retval; + throw RuntimeError(os.str()); + } + FILE_LOG(logDEBUG1) << "10Gb ADC enable mask retval: " << retval; + return socket.sendResult(retval); } \ No newline at end of file diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 9599ae08a..4503eee2b 100755 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -111,7 +111,9 @@ void Implementation::InitializeMembers() { deactivatedPaddingEnable = true; numLinesReadout = MAX_EIGER_ROWS_PER_READOUT; readoutType = ANALOG_ONLY; - adcEnableMask = BIT32_MASK; + adcEnableMaskOneGiga = BIT32_MASK; + adcEnableMaskTenGiga = BIT32_MASK; + ctbDbitOffset = 0; ctbAnalogDataBytes = 0; @@ -882,7 +884,7 @@ int Implementation::SetupWriter() { attr.quadEnable = quadEnable; attr.analogFlag = (readoutType == ANALOG_ONLY || readoutType == ANALOG_AND_DIGITAL) ? 1 : 0; attr.digitalFlag = (readoutType == DIGITAL_ONLY || readoutType == ANALOG_AND_DIGITAL) ? 1 : 0; - attr.adcmask = adcEnableMask; + attr.adcmask = tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga; attr.dbitoffset = ctbDbitOffset; attr.dbitlist = 0; attr.roiXmin = roi.xmin; @@ -1310,7 +1312,8 @@ int Implementation::setNumberofAnalogSamples(const uint32_t i) { numberOfAnalogSamples = i; ctbAnalogDataBytes = generalData->setImageSize( - adcEnableMask, numberOfAnalogSamples, numberOfDigitalSamples, + tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga, + numberOfAnalogSamples, numberOfDigitalSamples, tengigaEnable, readoutType); for (const auto &it : dataProcessor) @@ -1334,7 +1337,8 @@ int Implementation::setNumberofDigitalSamples(const uint32_t i) { numberOfDigitalSamples = i; ctbAnalogDataBytes = generalData->setImageSize( - adcEnableMask, numberOfAnalogSamples, numberOfDigitalSamples, + tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga, + numberOfAnalogSamples, numberOfDigitalSamples, tengigaEnable, readoutType); for (const auto &it : dataProcessor) @@ -1415,7 +1419,8 @@ int Implementation::setTenGigaEnable(const bool b) { case MOENCH: case CHIPTESTBOARD: ctbAnalogDataBytes = generalData->setImageSize( - adcEnableMask, numberOfAnalogSamples, numberOfDigitalSamples, + tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga, + numberOfAnalogSamples, numberOfDigitalSamples, tengigaEnable, readoutType); break; default: @@ -1558,7 +1563,8 @@ int Implementation::setReadoutMode(const readoutMode f) { // side effects ctbAnalogDataBytes = generalData->setImageSize( - adcEnableMask, numberOfAnalogSamples, numberOfDigitalSamples, + tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga, + numberOfAnalogSamples, numberOfDigitalSamples, tengigaEnable, readoutType); for (const auto &it : dataProcessor) it->SetPixelDimension(); @@ -1574,15 +1580,16 @@ int Implementation::setReadoutMode(const readoutMode f) { uint32_t Implementation::getADCEnableMask() const { FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; - return adcEnableMask; + return adcEnableMaskOneGiga; } int Implementation::setADCEnableMask(uint32_t mask) { - if (adcEnableMask != mask) { - adcEnableMask = mask; + if (adcEnableMaskOneGiga != mask) { + adcEnableMaskOneGiga = mask; ctbAnalogDataBytes = generalData->setImageSize( - mask, numberOfAnalogSamples, numberOfDigitalSamples, + tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga, + numberOfAnalogSamples, numberOfDigitalSamples, tengigaEnable, readoutType); for (const auto &it : dataProcessor) @@ -1591,7 +1598,34 @@ int Implementation::setADCEnableMask(uint32_t mask) { return FAIL; } - FILE_LOG(logINFO) << "ADC Enable Mask: 0x" << std::hex << adcEnableMask + FILE_LOG(logINFO) << "ADC Enable Mask for 1Gb mode: 0x" << std::hex << adcEnableMaskOneGiga + << std::dec; + FILE_LOG(logINFO) << "Packets per Frame: " + << (generalData->packetsPerFrame); + return OK; +} + +uint32_t Implementation::getTenGigaADCEnableMask() const { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return adcEnableMaskTenGiga; +} + +int Implementation::setTenGigaADCEnableMask(uint32_t mask) { + if (adcEnableMaskTenGiga != mask) { + adcEnableMaskTenGiga = mask; + + ctbAnalogDataBytes = generalData->setImageSize( + tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga, + numberOfAnalogSamples, numberOfDigitalSamples, + tengigaEnable, readoutType); + + for (const auto &it : dataProcessor) + it->SetPixelDimension(); + if (SetupFifoStructure() == FAIL) + return FAIL; + } + + FILE_LOG(logINFO) << "ADC Enable Mask for 10Gb mode: 0x" << std::hex << adcEnableMaskTenGiga << std::dec; FILE_LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame); diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index 5f6d020e4..c814599c1 100755 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -184,6 +184,8 @@ enum detFuncs{ F_SET_VETO_REFERENCE, F_GET_BURST_MODE, F_SET_BURST_MODE, + F_SET_ADC_ENABLE_MASK_10G, + F_GET_ADC_ENABLE_MASK_10G, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */ @@ -253,6 +255,7 @@ enum detFuncs{ F_SET_RECEIVER_UDP_PORT, F_SET_RECEIVER_UDP_PORT2, F_SET_RECEIVER_NUM_INTERFACES, + F_RECEIVER_SET_ADC_MASK_10G, NUM_REC_FUNCTIONS }; @@ -433,6 +436,8 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_VETO_REFERENCE: return "F_SET_VETO_REFERENCE"; case F_GET_BURST_MODE: return "F_GET_BURST_MODE"; case F_SET_BURST_MODE: return "F_SET_BURST_MODE"; + case F_SET_ADC_ENABLE_MASK_10G: return "F_SET_ADC_ENABLE_MASK_10G"; + case F_GET_ADC_ENABLE_MASK_10G: return "F_GET_ADC_ENABLE_MASK_10G"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; @@ -503,6 +508,7 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_RECEIVER_UDP_PORT: return "F_SET_RECEIVER_UDP_PORT"; case F_SET_RECEIVER_UDP_PORT2: return "F_SET_RECEIVER_UDP_PORT2"; case F_SET_RECEIVER_NUM_INTERFACES: return "F_SET_RECEIVER_NUM_INTERFACES"; + case F_RECEIVER_SET_ADC_MASK_10G: return "F_RECEIVER_SET_ADC_MASK_10G"; case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS"; default: return "Unknown Function"; diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 142af1c0d..c0356b1cd 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -4,9 +4,9 @@ #define APIRECEIVER 0x190722 #define APIGUI 0x190723 #define APIMOENCH 0x190820 -#define APIGOTTHARD 0x191111 -#define APIJUNGFRAU 0x191111 #define APIEIGER 0x191111 -#define APIMYTHEN3 0x191125 -#define APIGOTTHARD2 0x191125 #define APICTB 0x191127 +#define APIGOTTHARD 0x191127 +#define APIGOTTHARD2 0x191127 +#define APIJUNGFRAU 0x191127 +#define APIMYTHEN3 0x191127