diff --git a/RELEASE.txt b/RELEASE.txt index 3395b5bd9..57ff96fd4 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -85,6 +85,7 @@ This document describes the differences between v7.0.0 and v6.x.x - number of storage cells is not updated in teh receiver. done. and also allowing it to be modified in running status - refactored memory structure in receiver and listener code (maybe resolves stuck issue, need to check) - callback modified to have rx header and not rx header pointer +- adapted for g2 hdi v2.0. able to set master from server command line, server config file, and client. - rx udp socket refactored (maybe resolves getting stuck?)remove check for eiger header and isntead checks for malformed packets for every detector -help should not create a new object diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index ca841825a..4283132a9 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -1479,8 +1479,8 @@ class Detector(CppDetectorApi): @element def master(self): """ - [Eiger] Sets half module to master and others to slaves.\n - [Gotthard][Gotthard2][Mythen3][Eiger] Gets if the current module/ half module is master. + [Eiger][Gotthard2] Sets (half) module to master and other(s) to slaves.\n + [Gotthard][Gotthard2][Mythen3][Eiger] Gets if the current (half) module is master. """ return self.getMaster() diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 705e5b90d..096f1c63d 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 d2f416637..976ef486d 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -85,17 +85,9 @@ void basictests() { initCheckDone = 0; memset(initErrorMessage, 0, MAX_STR_LENGTH); #ifdef VIRTUAL - LOG(logINFOBLUE, - ("******** Chip Test Board Virtual Server *****************\n")); - if (mapCSP0() == FAIL) { - strcpy(initErrorMessage, - "Could not map to memory. Dangerous to continue.\n"); - LOG(logERROR, (initErrorMessage)); - initError = FAIL; - } - return; + LOG(logINFOBLUE, ("********* Chip Test Board Virtual Server *********\n")); #else - + LOG(logINFOBLUE, ("************* Chip Test Board Server *************\n")); initError = defineGPIOpins(initErrorMessage); if (initError == FAIL) { return; @@ -104,14 +96,15 @@ void basictests() { if (initError == FAIL) { return; } +#endif if (mapCSP0() == FAIL) { strcpy(initErrorMessage, "Could not map to memory. Dangerous to continue.\n"); - LOG(logERROR, ("%s\n\n", initErrorMessage)); + LOG(logERROR, (initErrorMessage)); initError = FAIL; return; } - +#ifndef VIRTUAL // does check only if flag is 0 (by default), set by command line if ((!debugflag) && (!updateFlag) && ((checkType() == FAIL) || (testFpga() == FAIL) || @@ -122,7 +115,7 @@ void basictests() { initError = FAIL; return; } - +#endif uint16_t hversion = getHardwareVersionNumber(); uint16_t hsnumber = getHardwareSerialNumber(); uint32_t ipadd = getDetectorIP(); @@ -135,7 +128,7 @@ void basictests() { if (fwversion >= MIN_REQRD_VRSN_T_RD_API) sw_fw_apiversion = getFirmwareAPIVersion(); LOG(logINFOBLUE, - ("************ Chip Test Board Server *********************\n" + ("**************************************************\n" "Hardware Version:\t\t 0x%x\n" "Hardware Serial Nr:\t\t 0x%x\n" @@ -153,6 +146,7 @@ void basictests() { (long long int)sw_fw_apiversion, REQRD_FRMWR_VRSN, (long long int)client_sw_apiversion)); +#ifndef VIRTUAL // return if flag is not zero, debug mode if (debugflag || updateFlag) { return; diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index e866db31c..a0fda2018 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 54ca07f07..a674babec 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -109,7 +109,10 @@ void basictests() { memset(initErrorMessage, 0, MAX_STR_LENGTH); #ifdef VIRTUAL LOG(logINFOBLUE, - ("************ EIGER Virtual Server *****************\n\n")); + ("************ EIGER Virtual Server ****************\n\n")); +#else + LOG(logINFOBLUE, + ("**************** EIGER Server ********************\n\n")); #endif uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); @@ -119,7 +122,7 @@ void basictests() { int64_t client_sw_apiversion = getClientServerAPIVersion(); LOG(logINFOBLUE, - ("**************** EIGER Server *********************\n\n" + ("**************************************************\n" "Detector IP Addr:\t\t 0x%x\n" "Detector MAC Addr:\t\t 0x%llx\n" @@ -142,9 +145,7 @@ void basictests() { udpDetails[iRxEntry].srcmac = macadd; } -#ifdef VIRTUAL - return; -#endif +#ifndef VIRTUAL // return if debugflag is not zero, debug mode if (debugflag || updateFlag) { return; @@ -186,6 +187,7 @@ void basictests() { return; } LOG(logINFO, ("Compatibility - success\n")); +#endif } #ifdef VIRTUAL diff --git a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h index a5a1fb87a..80096497b 100644 --- a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h @@ -100,6 +100,12 @@ #define CONFIG_VETO_CH_10GBE_ALG_MSK (0x00000007 << CONFIG_VETO_CH_10GBE_ALG_OFST) #define CONFIG_VETO_CH_10GBE_ENBL_OFST (15) #define CONFIG_VETO_CH_10GBE_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_10GBE_ENBL_OFST) +#define CONFIG_SLAVE_OFST (16) +#define CONFIG_SLAVE_MSK (0x00000001 << CONFIG_SLAVE_OFST) +#define CONFIG_HDI_MOD_ID_OFST (17) +#define CONFIG_HDI_MOD_ID_MSK (0x00000007 << CONFIG_HDI_MOD_ID_OFST) +#define CONFIG_FLIP_DATA_STREAM_OFST (20) +#define CONFIG_FLIP_DATA_STREAM_MSK (0x00000001 << CONFIG_FLIP_DATA_STREAM_OFST) #define ALGORITHM_HITS_VAL (0x0) #define ALGORITHM_RAW_VAL (0x7) diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index a17968377..77acb0cca 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index cfa68014a..804a52a81 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -73,7 +73,6 @@ int64_t burstPeriodReg = 0; int filterResistor = 0; int cdsGain = 0; int detPos[2] = {}; -int master = 1; int isInitCheckDone() { return initCheckDone; } @@ -87,7 +86,10 @@ void basictests() { initCheckDone = 0; memset(initErrorMessage, 0, MAX_STR_LENGTH); #ifdef VIRTUAL - LOG(logINFOBLUE, ("******** Gotthard2 Virtual Server *****************\n")); + LOG(logINFOBLUE, ("************ Gotthard2 Virtual Server ************\n")); +#else + LOG(logINFOBLUE, ("**************** Gotthard2 Server ****************\n")); +#endif if (mapCSP0() == FAIL) { strcpy(initErrorMessage, "Could not map to memory. Dangerous to continue.\n"); @@ -95,16 +97,7 @@ void basictests() { initError = FAIL; return; } - return; -#else - LOG(logINFOBLUE, ("************ Gotthard2 Server *********************\n")); - if (mapCSP0() == FAIL) { - strcpy(initErrorMessage, - "Could not map to memory. Dangerous to continue.\n"); - LOG(logERROR, ("%s\n\n", initErrorMessage)); - initError = FAIL; - return; - } +#ifndef VIRTUAL // does check only if flag is 0 (by default), set by command line if ((!debugflag) && (!updateFlag) && ((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || @@ -118,7 +111,7 @@ void basictests() { initError = FAIL; return; } - +#endif uint16_t hversion = getHardwareVersionNumber(); uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); @@ -129,7 +122,7 @@ void basictests() { uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN; LOG(logINFOBLUE, - ("*************************************************\n" + ("**************************************************\n" "Hardware Version:\t\t 0x%x\n" "Detector IP Addr:\t\t 0x%x\n" @@ -146,6 +139,7 @@ void basictests() { (long long int)sw_fw_apiversion, requiredFirmwareVersion, (long long int)client_sw_apiversion)); +#ifndef VIRTUAL // return if flag is not zero, debug mode if (debugflag || updateFlag) { return; @@ -234,6 +228,7 @@ int testBus() { int ret = OK; u_int32_t addr = DTA_OFFSET_REG; + u_int32_t prevValue = bus_r(addr); u_int32_t times = 1000 * 1000; for (u_int32_t i = 0; i < times; ++i) { @@ -245,7 +240,7 @@ int testBus() { } } - bus_w(addr, 0); + bus_w(addr, prevValue); if (ret == OK) { LOG(logINFO, ("Successfully tested bus %d times\n", times)); @@ -388,8 +383,9 @@ void initStopServer() { } #ifdef VIRTUAL sharedMemory_setStop(0); - // not reading config file (nothing of interest to stop server) - if (checkCommandLineConfiguration() == FAIL) { + setMaster(OW_MASTER); + if (readConfigFile() == FAIL || + checkCommandLineConfiguration() == FAIL) { initCheckDone = 1; return; } @@ -464,35 +460,15 @@ void setupDetector() { setHighVoltage(DEFAULT_HIGH_VOLTAGE); // check module type attached if not in debug mode - { - int ret = checkDetectorType(); - if (checkModuleFlag) { - switch (ret) { - case -1: - sprintf(initErrorMessage, - "Could not get the module type attached.\n"); - initError = FAIL; - LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); - return; - case -2: - sprintf(initErrorMessage, - "No Module attached! Run server with -nomodule.\n"); - initError = FAIL; - LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); - return; - case FAIL: - sprintf(initErrorMessage, - "Wrong Module (Not Gotthard2) attached!\n"); - initError = FAIL; - LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); - return; - default: - break; - } - } else { - LOG(logINFOBLUE, - ("In No-Module mode: Ignoring module type. Continuing.\n")); - } + if (initError == FAIL) + return; + if (!checkModuleFlag) { + LOG(logINFOBLUE, ("In No-Module mode: Ignoring module type...\n")); + } else { + initError = checkDetectorType(initErrorMessage); + } + if (initError == FAIL) { + return; } // power on chip @@ -710,8 +686,35 @@ int readConfigFile() { strlen(line) - 1, line)); memset(command, 0, LZ); + // master command + if (!strncmp(line, "master", strlen("master"))) { + int m = -1; + // cannot scan values + if (sscanf(line, "%s %d", command, &m) != 2) { + sprintf(initErrorMessage, + "Could not scan master commands from on-board server " + "config file. Line:[%s].\n", + line); + break; + } + // validations + if (m != 0 && m != 1) { + sprintf(initErrorMessage, + "Invalid master argument from on-board server " + "config file. Line:[%s].\n", + line); + break; + } + if (setMaster(m == 1 ? OW_MASTER : OW_SLAVE) == FAIL) { + sprintf(initErrorMessage, + "Could not set master from config file. Line:[%s].\n", + line); + break; + } + } + // vetoref command - if (!strncmp(line, "vetoref", strlen("vetoref"))) { + else if (!strncmp(line, "vetoref", strlen("vetoref"))) { int igain = 0; int value = 0; @@ -957,15 +960,15 @@ int readConfigFile() { int checkCommandLineConfiguration() { if (masterCommandLine != -1) { -#ifdef VIRTUAL - master = masterCommandLine; -#else - initError = FAIL; - strcpy(initErrorMessage, - "Cannot set Master from command line for this detector. " - "Should have been caught before!\n"); - return FAIL; -#endif + LOG(logINFOBLUE, ("Setting %s from Command Line\n", + (masterCommandLine == 1 ? "Master" : "Slave"))); + if (setMaster(masterCommandLine == 1 ? OW_MASTER : OW_SLAVE) == FAIL) { + initError = FAIL; + sprintf(initErrorMessage, "Could not set %s from command line.\n", + (masterCommandLine == 1 ? "Master" : "Slave")); + LOG(logERROR, (initErrorMessage)); + return FAIL; + } } return OK; } @@ -1497,8 +1500,38 @@ int setHighVoltage(int val) { /* parameters - timing */ +int setMaster(enum MASTERINDEX m) { + char *master_names[] = {MASTER_NAMES}; + LOG(logINFOBLUE, ("Setting up as %s in (%s server)\n", master_names[m], + (isControlServer ? "control" : "stop"))); + int retval = -1; + switch (m) { + case OW_MASTER: + bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_SLAVE_MSK); + isMaster(&retval); + if (retval != 1) { + LOG(logERROR, ("Could not set master\n")); + return FAIL; + } + break; + case OW_SLAVE: + bus_w(CONFIG_REG, bus_r(CONFIG_REG) | CONFIG_SLAVE_MSK); + isMaster(&retval); + if (retval != 0) { + LOG(logERROR, ("Could not set slave\n")); + return FAIL; + } + break; + default: + // hardware settings (do nothing) + break; + } + return OK; +} + int isMaster(int *retval) { - *retval = master; + int slave = ((bus_r(CONFIG_REG) & CONFIG_SLAVE_MSK) >> CONFIG_SLAVE_OFST); + *retval = (slave == 1 ? 0 : 1); return OK; } @@ -1950,54 +1983,71 @@ int *getDetectorPosition() { return detPos; } // Detector Specific -int checkDetectorType() { +int checkDetectorType(char *mess) { #ifdef VIRTUAL + setMaster(OW_MASTER); return OK; #endif - LOG(logINFO, ("Checking type of module\n")); + LOG(logINFO, ("Checking module type\n")); FILE *fd = fopen(TYPE_FILE_NAME, "r"); if (fd == NULL) { - LOG(logERROR, - ("Could not open file %s to get type of the module attached\n", - TYPE_FILE_NAME)); - return -1; + sprintf(mess, + "Could not open file %s to get type of the module attached\n", + TYPE_FILE_NAME); + return FAIL; } char buffer[MAX_STR_LENGTH]; memset(buffer, 0, sizeof(buffer)); fread(buffer, MAX_STR_LENGTH, sizeof(char), fd); fclose(fd); if (strlen(buffer) == 0) { - LOG(logERROR, - ("Could not read file %s to get type of the module attached\n", - TYPE_FILE_NAME)); - return -1; + sprintf(mess, + "Could not read file %s to get type of the module attached\n", + TYPE_FILE_NAME); + LOG(logERROR, (mess)); + return FAIL; } int type = atoi(buffer); - if (type > TYPE_NO_MODULE_STARTING_VAL) { - LOG(logERROR, - ("No Module attached! Expected %d, %d or %d for Gotthard2, got " - "%d\n", - TYPE_GOTTHARD2_MODULE_VAL, TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL, - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL, type)); - return -2; - } - - if (abs(type - TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL) <= TYPE_TOLERANCE) { - LOG(logINFOBLUE, ("MASTER 25um Module\n")); - master = 1; - } else if (abs(type - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL) <= + enum MASTERINDEX master = OW_MASTER; + if (abs(type - TYPE_GOTTHARD2_25UM_MASTER_HD1_V1_VAL) <= TYPE_TOLERANCE) { + LOG(logINFOBLUE, ("MASTER 25um Module (HDI v1.0)\n")); + } else if (abs(type - TYPE_GOTTHARD2_25UM_MASTER_HD1_V2_VAL) <= TYPE_TOLERANCE) { - master = 0; - LOG(logINFOBLUE, ("SLAVE 25um Module\n")); + LOG(logINFOBLUE, ("MASTER 25um Module (HDI v2.0)\n")); + } else if (abs(type - TYPE_GOTTHARD2_25UM_SLAVE_HDI_V1_VAL) <= + TYPE_TOLERANCE) { + LOG(logINFOBLUE, ("SLAVE 25um Module (HDI v1.0)\n")); + master = OW_SLAVE; + } else if (abs(type - TYPE_GOTTHARD2_25UM_SLAVE_HDI_V2_VAL) <= + TYPE_TOLERANCE) { + LOG(logINFOBLUE, ("SLAVE 25um Module (HDI v2.0)\n")); + master = OW_SLAVE; } else if (abs(type - TYPE_GOTTHARD2_MODULE_VAL) <= TYPE_TOLERANCE) { - master = -1; LOG(logINFOBLUE, ("50um Module\n")); + } + // no module or invalid module + else if (type > TYPE_NO_MODULE_STARTING_VAL) { + sprintf(mess, "No Module attached! Run server with -nomodule.\n"); + LOG(logERROR, (mess)); + return FAIL; } else { - LOG(logERROR, - ("Wrong Module attached! Expected %d, %d or %d for Gotthard2, got " - "%d\n", - TYPE_GOTTHARD2_MODULE_VAL, TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL, - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL, type)); + sprintf(mess, + "Wrong Module attached! Expected %d, %d, %d, %d or %d for " + "Gotthard2, got %d\n", + TYPE_GOTTHARD2_MODULE_VAL, + TYPE_GOTTHARD2_25UM_MASTER_HD1_V1_VAL, + TYPE_GOTTHARD2_25UM_SLAVE_HDI_V1_VAL, + TYPE_GOTTHARD2_25UM_MASTER_HD1_V2_VAL, + TYPE_GOTTHARD2_25UM_SLAVE_HDI_V2_VAL, type); + LOG(logERROR, (mess)); + return FAIL; + } + bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_HDI_MOD_ID_MSK); + bus_w(CONFIG_REG, bus_r(CONFIG_REG) | ((type << CONFIG_HDI_MOD_ID_OFST) & + CONFIG_HDI_MOD_ID_MSK)); + if (setMaster(master) == FAIL) { + strcpy(mess, "Could not set to master/slave."); + LOG(logERROR, (mess)); return FAIL; } return OK; diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h index 543e1ff20..c13f88540 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h @@ -3,7 +3,7 @@ #pragma once #include "sls/sls_detector_defs.h" -#define REQRD_FRMWRE_VRSN (0x210527) +#define REQRD_FRMWRE_VRSN (0x220720) #define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021" #define ID_FILE "detid_gotthard2.txt" @@ -31,8 +31,10 @@ #define ADU_MAX_BITS (12) #define MAX_FRAMES_IN_BURST_MODE (2720) #define TYPE_GOTTHARD2_MODULE_VAL (536) -#define TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL (683) -#define TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL (704) +#define TYPE_GOTTHARD2_25UM_MASTER_HD1_V1_VAL (683) +#define TYPE_GOTTHARD2_25UM_SLAVE_HDI_V1_VAL (704) +#define TYPE_GOTTHARD2_25UM_MASTER_HD1_V2_VAL (723) +#define TYPE_GOTTHARD2_25UM_SLAVE_HDI_V2_VAL (747) #define TYPE_GOTTHARD2_MODULE_VAL (536) #define TYPE_TOLERANCE (5) #define TYPE_NO_MODULE_STARTING_VAL (800) @@ -146,6 +148,9 @@ enum CLKINDEX { enum PLLINDEX { READOUT_PLL, SYSTEM_PLL }; +enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE }; +#define MASTER_NAMES "hardware (master/slave)", "master", "slave" + /** Chip Definitions */ #define ASIC_ADDR_MAX_BITS (4) #define ASIC_CURRENT_INJECT_ADDR (0x9) diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index 96599022d..35b74f6a3 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index 221676690..cef343ba6 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -82,22 +82,16 @@ void basictests() { memset(initErrorMessage, 0, MAX_STR_LENGTH); #ifdef VIRTUAL LOG(logINFOBLUE, ("******** Gotthard Virtual Server *****************\n")); +#else + LOG(logINFOBLUE, ("**************** Gotthard Server *****************\n")); +#endif if (mapCSP0() == FAIL) { strcpy(initErrorMessage, "Could not map to memory. Dangerous to continue.\n"); LOG(logERROR, (initErrorMessage)); initError = FAIL; } - return; -#else - if (mapCSP0() == FAIL) { - strcpy(initErrorMessage, - "Could not map to memory. Dangerous to continue.\n"); - LOG(logERROR, ("%s\n\n", initErrorMessage)); - initError = FAIL; - return; - } - +#ifndef VIRTUAL // does check only if flag is 0 (by default), set by command line if ((!debugflag) && (!updateFlag) && ((checkType() == FAIL) || (testFpga() == FAIL) || @@ -108,7 +102,7 @@ void basictests() { initError = FAIL; return; } - +#endif uint32_t boardrev = getBoardRevision(); uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); @@ -117,7 +111,7 @@ void basictests() { int64_t client_sw_apiversion = getClientServerAPIVersion(); LOG(logINFOBLUE, - ("************ Gotthard Server *********************\n" + ("**************************************************\n" "Board Revision : 0x%x\n" "Detector IP Addr : 0x%x\n" @@ -134,6 +128,7 @@ void basictests() { (long long int)fwversion, (long long int)swversion, (long long int)client_sw_apiversion)); +#ifndef VIRTUAL if (!debugflag || updateFlag) { LOG(logINFO, ("Basic Tests - success\n")); } diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index d5e74d794..a9225da3d 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 0a4e6fe89..9c9954d7c 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -67,14 +67,9 @@ void basictests() { memset(initErrorMessage, 0, MAX_STR_LENGTH); #ifdef VIRTUAL LOG(logINFOBLUE, ("******** Jungfrau Virtual Server *****************\n")); - if (mapCSP0() == FAIL) { - strcpy(initErrorMessage, - "Could not map to memory. Dangerous to continue.\n"); - LOG(logERROR, (initErrorMessage)); - initError = FAIL; - } - return; #else + LOG(logINFOBLUE, ("************ Jungfrau Server *********************\n")); + initError = defineGPIOpins(initErrorMessage); if (initError == FAIL) { return; @@ -83,14 +78,14 @@ void basictests() { if (initError == FAIL) { return; } +#endif if (mapCSP0() == FAIL) { strcpy(initErrorMessage, "Could not map to memory. Dangerous to continue.\n"); - LOG(logERROR, ("%s\n\n", initErrorMessage)); + LOG(logERROR, (initErrorMessage)); initError = FAIL; - return; } - +#ifndef VIRTUAL // does check only if flag is 0 (by default), set by command line if ((!debugflag) && (!updateFlag) && ((checkType() == FAIL) || (testFpga() == FAIL) || @@ -101,7 +96,7 @@ void basictests() { initError = FAIL; return; } - +#endif uint16_t hversion = getHardwareVersionNumber(); uint16_t hsnumber = getHardwareSerialNumber(); uint32_t ipadd = getDetectorIP(); @@ -135,6 +130,7 @@ void basictests() { (long long int)sw_fw_apiversion, requiredFirmwareVersion, (long long int)client_sw_apiversion)); +#ifndef VIRTUAL // return if flag is not zero, debug mode if (debugflag || updateFlag) { return; diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index 862873808..d8ab6b401 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index dc8c0d9b8..4d3a9df81 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -88,16 +88,9 @@ void basictests() { initCheckDone = 0; memset(initErrorMessage, 0, MAX_STR_LENGTH); #ifdef VIRTUAL - LOG(logINFOBLUE, - ("******** Moench Detector Virtual Server *****************\n")); - if (mapCSP0() == FAIL) { - strcpy(initErrorMessage, - "Could not map to memory. Dangerous to continue.\n"); - LOG(logERROR, (initErrorMessage)); - initError = FAIL; - } - return; + LOG(logINFOBLUE, ("********* Moench Detector Virtual Server *********\n")); #else + LOG(logINFOBLUE, ("************* Moench Detector Server *************\n")); initError = defineGPIOpins(initErrorMessage); if (initError == FAIL) { @@ -107,6 +100,7 @@ void basictests() { if (initError == FAIL) { return; } +#endif if (mapCSP0() == FAIL) { strcpy(initErrorMessage, "Could not map to memory. Dangerous to continue.\n"); @@ -114,7 +108,7 @@ void basictests() { initError = FAIL; return; } - +#ifndef VIRTUAL // does check only if flag is 0 (by default), set by command line if ((!debugflag) && (!updateFlag) && ((checkType() == FAIL) || (testFpga() == FAIL) || @@ -125,7 +119,7 @@ void basictests() { initError = FAIL; return; } - +#endif uint16_t hversion = getHardwareVersionNumber(); uint16_t hsnumber = getHardwareSerialNumber(); uint32_t ipadd = getDetectorIP(); @@ -138,7 +132,7 @@ void basictests() { if (fwversion >= MIN_REQRD_VRSN_T_RD_API) sw_fw_apiversion = getFirmwareAPIVersion(); LOG(logINFOBLUE, - ("************ Moench Detector Server *********************\n" + ("**************************************************\n" "Hardware Version:\t\t 0x%x\n" "Hardware Serial Nr:\t\t 0x%x\n" @@ -156,6 +150,7 @@ void basictests() { (long long int)sw_fw_apiversion, REQRD_FRMWR_VRSN, (long long int)client_sw_apiversion)); +#ifndef VIRTUAL // return if flag is not zero, debug mode if (debugflag || updateFlag) { return; diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 9d33157f0..0d0629659 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 67f35ea67..257f16e0d 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -82,23 +82,17 @@ void basictests() { initCheckDone = 0; memset(initErrorMessage, 0, MAX_STR_LENGTH); #ifdef VIRTUAL - LOG(logINFOBLUE, ("******** Mythen3 Virtual Server *****************\n")); + LOG(logINFOBLUE, ("************* Mythen3 Virtual Server *************\n")); +#else + LOG(logINFOBLUE, ("***************** Mythen3 Server *****************\n")); +#endif if (mapCSP0() == FAIL) { strcpy(initErrorMessage, "Could not map to memory. Dangerous to continue.\n"); LOG(logERROR, (initErrorMessage)); initError = FAIL; } - return; -#else - LOG(logINFOBLUE, ("************ Mythen3 Server *********************\n")); - if (mapCSP0() == FAIL) { - strcpy(initErrorMessage, - "Could not map to memory. Dangerous to continue.\n"); - LOG(logERROR, ("%s\n\n", initErrorMessage)); - initError = FAIL; - return; - } +#ifndef VIRTUAL // does check only if flag is 0 (by default), set by command line if ((!debugflag) && (!updateFlag) && ((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || @@ -110,6 +104,7 @@ void basictests() { initError = FAIL; return; } +#endif uint16_t hversion = getHardwareVersionNumber(); uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); @@ -121,7 +116,7 @@ void basictests() { uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN; LOG(logINFOBLUE, - ("*************************************************\n" + ("**************************************************\n" "Hardware Version:\t\t 0x%x\n" "Detector IP Addr:\t\t 0x%x\n" @@ -138,6 +133,7 @@ void basictests() { (long long int)sw_fw_apiversion, requiredFirmwareVersion, (long long int)client_sw_apiversion)); +#ifndef VIRTUAL // return if flag is not zero, debug mode if (debugflag || updateFlag) { return; @@ -506,35 +502,15 @@ void setupDetector() { setSettings(DEFAULT_SETTINGS); // check module type attached if not in debug mode - { - int ret = checkDetectorType(); - if (checkModuleFlag) { - switch (ret) { - case -1: - sprintf(initErrorMessage, - "Could not get the module type attached.\n"); - initError = FAIL; - LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); - return; - case -2: - sprintf(initErrorMessage, - "No Module attached! Run server with -nomodule.\n"); - initError = FAIL; - LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); - return; - case FAIL: - sprintf(initErrorMessage, - "Wrong Module (Not Mythen3) attached!\n"); - initError = FAIL; - LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); - return; - default: - break; - } - } else { - LOG(logINFOBLUE, - ("In No-Module mode: Ignoring module type. Continuing.\n")); - } + if (initError == FAIL) + return; + if (!checkModuleFlag) { + LOG(logINFOBLUE, ("In No-Module mode: Ignoring module type...\n")); + } else { + initError = checkDetectorType(initErrorMessage); + } + if (initError == FAIL) { + return; } powerChip(1); @@ -2095,39 +2071,40 @@ int enableTenGigabitEthernet(int val) { return oneG ? 0 : 1; } -int checkDetectorType() { +int checkDetectorType(char *mess) { #ifdef VIRTUAL return OK; #endif LOG(logINFO, ("Checking type of module\n")); FILE *fd = fopen(TYPE_FILE_NAME, "r"); if (fd == NULL) { - LOG(logERROR, - ("Could not open file %s to get type of the module attached\n", - TYPE_FILE_NAME)); - return -1; + sprintf(mess, + "Could not open file %s to get type of the module attached\n", + TYPE_FILE_NAME); + return FAIL; } char buffer[MAX_STR_LENGTH]; memset(buffer, 0, sizeof(buffer)); fread(buffer, MAX_STR_LENGTH, sizeof(char), fd); fclose(fd); if (strlen(buffer) == 0) { - LOG(logERROR, - ("Could not read file %s to get type of the module attached\n", - TYPE_FILE_NAME)); - return -1; + sprintf(mess, + "Could not read file %s to get type of the module attached\n", + TYPE_FILE_NAME); + return FAIL; } int type = atoi(buffer); if (type > TYPE_NO_MODULE_STARTING_VAL) { - LOG(logERROR, ("No Module attached! Expected %d for Mythen, got %d\n", - TYPE_MYTHEN3_MODULE_VAL, type)); - return -2; + sprintf(mess, "No Module attached! Run server with -nomodule.\n"); + LOG(logERROR, (mess)); + return FAIL; } if (abs(type - TYPE_MYTHEN3_MODULE_VAL) > TYPE_TOLERANCE) { - LOG(logERROR, - ("Wrong Module attached! Expected %d for Mythen3, got %d\n", - TYPE_MYTHEN3_MODULE_VAL, type)); + sprintf(mess, + "Wrong Module attached! Expected %d for Mythen3, got %d\n", + TYPE_MYTHEN3_MODULE_VAL, type); + LOG(logERROR, (mess)); return FAIL; } return OK; diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index e8bd5e397..63eccf967 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -385,8 +385,10 @@ int getADC(enum ADCINDEX ind); int setHighVoltage(int val); // parameters - timing, extsig -#ifdef EIGERD +#if defined(EIGERD) || defined(GOTTHARD2D) int setMaster(enum MASTERINDEX m); +#endif +#ifdef EIGERD int setTop(enum TOPINDEX t); int isTop(int *retval); #endif @@ -558,7 +560,7 @@ int setDataStream(enum portPosition port, int enable); int setPhase(enum CLKINDEX ind, int val, int degrees); #elif MYTHEN3D -int checkDetectorType(); +int checkDetectorType(char *mess); int powerChip(int on); int setPhase(enum CLKINDEX ind, int val, int degrees); int getPhase(enum CLKINDEX ind, int degrees); @@ -574,7 +576,7 @@ int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, int getClockDivider(enum CLKINDEX ind); #elif GOTTHARD2D -int checkDetectorType(); +int checkDetectorType(char *mess); int powerChip(int on); void setDBITPipeline(int val); int getDBITPipeline(); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index ae93ba936..794024016 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -114,7 +114,6 @@ int printSocketReadError() { void init_detector() { memset(udpDetails, 0, sizeof(udpDetails)); #ifdef VIRTUAL - LOG(logINFO, ("This is a VIRTUAL detector\n")); udpDetails[0].srcip = LOCALHOSTIP_INT; udpDetails[0].srcip2 = LOCALHOSTIP_INT; #endif @@ -3849,27 +3848,14 @@ int power_chip(int file_des) { #if defined(MYTHEN3D) || defined(GOTTHARD2D) // check only when powering on if (arg != -1 && arg != 0) { - if (checkModuleFlag) { - int type_ret = checkDetectorType(); - if (type_ret == -1) { - ret = FAIL; - sprintf(mess, "Could not power on chip. Could not open " - "file to get type of module attached.\n"); - LOG(logERROR, (mess)); - } else if (type_ret == -2) { - ret = FAIL; - sprintf(mess, - "Could not power on chip. No module attached!\n"); - LOG(logERROR, (mess)); - } else if (type_ret == FAIL) { - ret = FAIL; - sprintf(mess, "Could not power on chip. Wrong module " - "attached!\n"); - LOG(logERROR, (mess)); - } + if (!checkModuleFlag) { + LOG(logINFOBLUE, + ("In No-Module mode: Ignoring module type. Continuing.\n")); } else { - LOG(logINFOBLUE, ("In No-Module mode: Ignoring module " - "type. Continuing.\n")); + ret = checkDetectorType(mess); + if (ret == FAIL) { + LOG(logERROR, ("Could not power on chip.\n")); + } } } #endif @@ -8270,7 +8256,7 @@ int set_master(int file_des) { return printSocketReadError(); LOG(logDEBUG1, ("Setting master: %u\n", (int)arg)); -#ifndef EIGERD +#if !defined(EIGERD) && !defined(GOTTHARD2D) functionNotImplemented(); #else // only set diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index cc566adb4..9e3cb65f7 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -197,10 +197,11 @@ class Detector { */ void setFlipRows(bool value, Positions pos = {}); - /** [Eiger][Mythen3][Gotthard1] via stop server **/ + /** [Eiger][Mythen3][Gotthard1][Gotthard2] via stop server **/ Result getMaster(Positions pos = {}) const; - /** [Eiger] Set half module to master and the others to slaves */ + /** [Eiger][Gotthard2] Set (half) module to master and the other(s) to + * slaves */ void setMaster(bool value, int pos); Result isVirtualDetectorServer(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index f1476db99..1a0d1ddd9 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1298,9 +1298,9 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID_GET( master, getMaster, setMaster, StringTo, - "[0, 1]\n\t[Eiger] Sets half module to master and " - "others to slaves.\n\t[Gotthard][Gotthard2][Mythen3][Eiger] " - "Gets if the current module/ half module is master."); + "[0, 1]\n\t[Eiger][Gotthard2] Sets (half) module to master and " + "other(s) to slaves.\n\t[Gotthard][Gotthard2][Mythen3][Eiger] " + "Gets if the current (half) module is master."); /* acquisition parameters */ diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 703c54858..7db7d699e 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -586,7 +586,7 @@ TEST_CASE("master", "[.cmd]") { if (det_type == defs::EIGER || det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) { REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET)); - if (det_type == defs::EIGER) { + if (det_type == defs::EIGER || det_type == defs::GOTTHARD2) { // get previous master int prevMaster = 0; { diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 5e4aaba1a..412f62cfc 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -5,10 +5,10 @@ #define APILIB 0x220609 #define APIRECEIVER 0x220609 #define APIGUI 0x220609 -#define APICTB 0x220714 -#define APIGOTTHARD 0x220714 -#define APIJUNGFRAU 0x220714 -#define APIMYTHEN3 0x220714 -#define APIMOENCH 0x220714 -#define APIEIGER 0x220714 -#define APIGOTTHARD2 0x220811 +#define APICTB 0x220816 +#define APIGOTTHARD 0x220816 +#define APIGOTTHARD2 0x220816 +#define APIJUNGFRAU 0x220816 +#define APIMYTHEN3 0x220816 +#define APIMOENCH 0x220816 +#define APIEIGER 0x220816