* g2: new hdi values, write hdi value to reg, set slave/master to reg, able to set master from server config file, server command line and client

* print versions for virtual as well
This commit is contained in:
Dhanya Thattil 2022-08-16 09:31:13 +02:00 committed by GitHub
parent 409a3977db
commit 22b9562629
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 251 additions and 241 deletions

View File

@ -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 - 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) - 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 - 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 - 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 -help should not create a new object

View File

@ -1479,8 +1479,8 @@ class Detector(CppDetectorApi):
@element @element
def master(self): def master(self):
""" """
[Eiger] Sets half module to master and others to slaves.\n [Eiger][Gotthard2] Sets (half) module to master and other(s) to slaves.\n
[Gotthard][Gotthard2][Mythen3][Eiger] Gets if the current module/ half module is master. [Gotthard][Gotthard2][Mythen3][Eiger] Gets if the current (half) module is master.
""" """
return self.getMaster() return self.getMaster()

View File

@ -85,17 +85,9 @@ void basictests() {
initCheckDone = 0; initCheckDone = 0;
memset(initErrorMessage, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
LOG(logINFOBLUE, LOG(logINFOBLUE, ("********* Chip Test Board Virtual Server *********\n"));
("******** 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;
#else #else
LOG(logINFOBLUE, ("************* Chip Test Board Server *************\n"));
initError = defineGPIOpins(initErrorMessage); initError = defineGPIOpins(initErrorMessage);
if (initError == FAIL) { if (initError == FAIL) {
return; return;
@ -104,14 +96,15 @@ void basictests() {
if (initError == FAIL) { if (initError == FAIL) {
return; return;
} }
#endif
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(initErrorMessage, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage)); LOG(logERROR, (initErrorMessage));
initError = FAIL; initError = FAIL;
return; return;
} }
#ifndef VIRTUAL
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && (!updateFlag) && if ((!debugflag) && (!updateFlag) &&
((checkType() == FAIL) || (testFpga() == FAIL) || ((checkType() == FAIL) || (testFpga() == FAIL) ||
@ -122,7 +115,7 @@ void basictests() {
initError = FAIL; initError = FAIL;
return; return;
} }
#endif
uint16_t hversion = getHardwareVersionNumber(); uint16_t hversion = getHardwareVersionNumber();
uint16_t hsnumber = getHardwareSerialNumber(); uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
@ -135,7 +128,7 @@ void basictests() {
if (fwversion >= MIN_REQRD_VRSN_T_RD_API) if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getFirmwareAPIVersion(); sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE, LOG(logINFOBLUE,
("************ Chip Test Board Server *********************\n" ("**************************************************\n"
"Hardware Version:\t\t 0x%x\n" "Hardware Version:\t\t 0x%x\n"
"Hardware Serial Nr:\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)sw_fw_apiversion, REQRD_FRMWR_VRSN,
(long long int)client_sw_apiversion)); (long long int)client_sw_apiversion));
#ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (debugflag || updateFlag) { if (debugflag || updateFlag) {
return; return;

View File

@ -109,7 +109,10 @@ void basictests() {
memset(initErrorMessage, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
LOG(logINFOBLUE, LOG(logINFOBLUE,
("************ EIGER Virtual Server *****************\n\n")); ("************ EIGER Virtual Server ****************\n\n"));
#else
LOG(logINFOBLUE,
("**************** EIGER Server ********************\n\n"));
#endif #endif
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
@ -119,7 +122,7 @@ void basictests() {
int64_t client_sw_apiversion = getClientServerAPIVersion(); int64_t client_sw_apiversion = getClientServerAPIVersion();
LOG(logINFOBLUE, LOG(logINFOBLUE,
("**************** EIGER Server *********************\n\n" ("**************************************************\n"
"Detector IP Addr:\t\t 0x%x\n" "Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%llx\n" "Detector MAC Addr:\t\t 0x%llx\n"
@ -142,9 +145,7 @@ void basictests() {
udpDetails[iRxEntry].srcmac = macadd; udpDetails[iRxEntry].srcmac = macadd;
} }
#ifdef VIRTUAL #ifndef VIRTUAL
return;
#endif
// return if debugflag is not zero, debug mode // return if debugflag is not zero, debug mode
if (debugflag || updateFlag) { if (debugflag || updateFlag) {
return; return;
@ -186,6 +187,7 @@ void basictests() {
return; return;
} }
LOG(logINFO, ("Compatibility - success\n")); LOG(logINFO, ("Compatibility - success\n"));
#endif
} }
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -100,6 +100,12 @@
#define CONFIG_VETO_CH_10GBE_ALG_MSK (0x00000007 << CONFIG_VETO_CH_10GBE_ALG_OFST) #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_OFST (15)
#define CONFIG_VETO_CH_10GBE_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_10GBE_ENBL_OFST) #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_HITS_VAL (0x0)
#define ALGORITHM_RAW_VAL (0x7) #define ALGORITHM_RAW_VAL (0x7)

View File

@ -73,7 +73,6 @@ int64_t burstPeriodReg = 0;
int filterResistor = 0; int filterResistor = 0;
int cdsGain = 0; int cdsGain = 0;
int detPos[2] = {}; int detPos[2] = {};
int master = 1;
int isInitCheckDone() { return initCheckDone; } int isInitCheckDone() { return initCheckDone; }
@ -87,7 +86,10 @@ void basictests() {
initCheckDone = 0; initCheckDone = 0;
memset(initErrorMessage, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
LOG(logINFOBLUE, ("******** Gotthard2 Virtual Server *****************\n")); LOG(logINFOBLUE, ("************ Gotthard2 Virtual Server ************\n"));
#else
LOG(logINFOBLUE, ("**************** Gotthard2 Server ****************\n"));
#endif
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(initErrorMessage, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
@ -95,16 +97,7 @@ void basictests() {
initError = FAIL; initError = FAIL;
return; return;
} }
return; #ifndef VIRTUAL
#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;
}
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && (!updateFlag) && if ((!debugflag) && (!updateFlag) &&
((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || ((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) ||
@ -118,7 +111,7 @@ void basictests() {
initError = FAIL; initError = FAIL;
return; return;
} }
#endif
uint16_t hversion = getHardwareVersionNumber(); uint16_t hversion = getHardwareVersionNumber();
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
@ -129,7 +122,7 @@ void basictests() {
uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN; uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN;
LOG(logINFOBLUE, LOG(logINFOBLUE,
("*************************************************\n" ("**************************************************\n"
"Hardware Version:\t\t 0x%x\n" "Hardware Version:\t\t 0x%x\n"
"Detector IP Addr:\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)sw_fw_apiversion, requiredFirmwareVersion,
(long long int)client_sw_apiversion)); (long long int)client_sw_apiversion));
#ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (debugflag || updateFlag) { if (debugflag || updateFlag) {
return; return;
@ -234,6 +228,7 @@ int testBus() {
int ret = OK; int ret = OK;
u_int32_t addr = DTA_OFFSET_REG; u_int32_t addr = DTA_OFFSET_REG;
u_int32_t prevValue = bus_r(addr);
u_int32_t times = 1000 * 1000; u_int32_t times = 1000 * 1000;
for (u_int32_t i = 0; i < times; ++i) { 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) { if (ret == OK) {
LOG(logINFO, ("Successfully tested bus %d times\n", times)); LOG(logINFO, ("Successfully tested bus %d times\n", times));
@ -388,8 +383,9 @@ void initStopServer() {
} }
#ifdef VIRTUAL #ifdef VIRTUAL
sharedMemory_setStop(0); sharedMemory_setStop(0);
// not reading config file (nothing of interest to stop server) setMaster(OW_MASTER);
if (checkCommandLineConfiguration() == FAIL) { if (readConfigFile() == FAIL ||
checkCommandLineConfiguration() == FAIL) {
initCheckDone = 1; initCheckDone = 1;
return; return;
} }
@ -464,35 +460,15 @@ void setupDetector() {
setHighVoltage(DEFAULT_HIGH_VOLTAGE); setHighVoltage(DEFAULT_HIGH_VOLTAGE);
// check module type attached if not in debug mode // check module type attached if not in debug mode
{ if (initError == FAIL)
int ret = checkDetectorType(); return;
if (checkModuleFlag) { if (!checkModuleFlag) {
switch (ret) { LOG(logINFOBLUE, ("In No-Module mode: Ignoring module type...\n"));
case -1: } else {
sprintf(initErrorMessage, initError = checkDetectorType(initErrorMessage);
"Could not get the module type attached.\n"); }
initError = FAIL; if (initError == FAIL) {
LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); return;
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"));
}
} }
// power on chip // power on chip
@ -710,8 +686,35 @@ int readConfigFile() {
strlen(line) - 1, line)); strlen(line) - 1, line));
memset(command, 0, LZ); 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 // vetoref command
if (!strncmp(line, "vetoref", strlen("vetoref"))) { else if (!strncmp(line, "vetoref", strlen("vetoref"))) {
int igain = 0; int igain = 0;
int value = 0; int value = 0;
@ -957,15 +960,15 @@ int readConfigFile() {
int checkCommandLineConfiguration() { int checkCommandLineConfiguration() {
if (masterCommandLine != -1) { if (masterCommandLine != -1) {
#ifdef VIRTUAL LOG(logINFOBLUE, ("Setting %s from Command Line\n",
master = masterCommandLine; (masterCommandLine == 1 ? "Master" : "Slave")));
#else if (setMaster(masterCommandLine == 1 ? OW_MASTER : OW_SLAVE) == FAIL) {
initError = FAIL; initError = FAIL;
strcpy(initErrorMessage, sprintf(initErrorMessage, "Could not set %s from command line.\n",
"Cannot set Master from command line for this detector. " (masterCommandLine == 1 ? "Master" : "Slave"));
"Should have been caught before!\n"); LOG(logERROR, (initErrorMessage));
return FAIL; return FAIL;
#endif }
} }
return OK; return OK;
} }
@ -1497,8 +1500,38 @@ int setHighVoltage(int val) {
/* parameters - timing */ /* 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) { 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; return OK;
} }
@ -1950,54 +1983,71 @@ int *getDetectorPosition() { return detPos; }
// Detector Specific // Detector Specific
int checkDetectorType() { int checkDetectorType(char *mess) {
#ifdef VIRTUAL #ifdef VIRTUAL
setMaster(OW_MASTER);
return OK; return OK;
#endif #endif
LOG(logINFO, ("Checking type of module\n")); LOG(logINFO, ("Checking module type\n"));
FILE *fd = fopen(TYPE_FILE_NAME, "r"); FILE *fd = fopen(TYPE_FILE_NAME, "r");
if (fd == NULL) { if (fd == NULL) {
LOG(logERROR, sprintf(mess,
("Could not open file %s to get type of the module attached\n", "Could not open file %s to get type of the module attached\n",
TYPE_FILE_NAME)); TYPE_FILE_NAME);
return -1; return FAIL;
} }
char buffer[MAX_STR_LENGTH]; char buffer[MAX_STR_LENGTH];
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
fread(buffer, MAX_STR_LENGTH, sizeof(char), fd); fread(buffer, MAX_STR_LENGTH, sizeof(char), fd);
fclose(fd); fclose(fd);
if (strlen(buffer) == 0) { if (strlen(buffer) == 0) {
LOG(logERROR, sprintf(mess,
("Could not read file %s to get type of the module attached\n", "Could not read file %s to get type of the module attached\n",
TYPE_FILE_NAME)); TYPE_FILE_NAME);
return -1; LOG(logERROR, (mess));
return FAIL;
} }
int type = atoi(buffer); int type = atoi(buffer);
if (type > TYPE_NO_MODULE_STARTING_VAL) { enum MASTERINDEX master = OW_MASTER;
LOG(logERROR, if (abs(type - TYPE_GOTTHARD2_25UM_MASTER_HD1_V1_VAL) <= TYPE_TOLERANCE) {
("No Module attached! Expected %d, %d or %d for Gotthard2, got " LOG(logINFOBLUE, ("MASTER 25um Module (HDI v1.0)\n"));
"%d\n", } else if (abs(type - TYPE_GOTTHARD2_25UM_MASTER_HD1_V2_VAL) <=
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) <=
TYPE_TOLERANCE) { TYPE_TOLERANCE) {
master = 0; LOG(logINFOBLUE, ("MASTER 25um Module (HDI v2.0)\n"));
LOG(logINFOBLUE, ("SLAVE 25um Module\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) { } else if (abs(type - TYPE_GOTTHARD2_MODULE_VAL) <= TYPE_TOLERANCE) {
master = -1;
LOG(logINFOBLUE, ("50um Module\n")); 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 { } else {
LOG(logERROR, sprintf(mess,
("Wrong Module attached! Expected %d, %d or %d for Gotthard2, got " "Wrong Module attached! Expected %d, %d, %d, %d or %d for "
"%d\n", "Gotthard2, got %d\n",
TYPE_GOTTHARD2_MODULE_VAL, TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL, TYPE_GOTTHARD2_MODULE_VAL,
TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL, type)); 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 FAIL;
} }
return OK; return OK;

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include "sls/sls_detector_defs.h" #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 KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
#define ID_FILE "detid_gotthard2.txt" #define ID_FILE "detid_gotthard2.txt"
@ -31,8 +31,10 @@
#define ADU_MAX_BITS (12) #define ADU_MAX_BITS (12)
#define MAX_FRAMES_IN_BURST_MODE (2720) #define MAX_FRAMES_IN_BURST_MODE (2720)
#define TYPE_GOTTHARD2_MODULE_VAL (536) #define TYPE_GOTTHARD2_MODULE_VAL (536)
#define TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL (683) #define TYPE_GOTTHARD2_25UM_MASTER_HD1_V1_VAL (683)
#define TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL (704) #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_GOTTHARD2_MODULE_VAL (536)
#define TYPE_TOLERANCE (5) #define TYPE_TOLERANCE (5)
#define TYPE_NO_MODULE_STARTING_VAL (800) #define TYPE_NO_MODULE_STARTING_VAL (800)
@ -146,6 +148,9 @@ enum CLKINDEX {
enum PLLINDEX { READOUT_PLL, SYSTEM_PLL }; enum PLLINDEX { READOUT_PLL, SYSTEM_PLL };
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MASTER_NAMES "hardware (master/slave)", "master", "slave"
/** Chip Definitions */ /** Chip Definitions */
#define ASIC_ADDR_MAX_BITS (4) #define ASIC_ADDR_MAX_BITS (4)
#define ASIC_CURRENT_INJECT_ADDR (0x9) #define ASIC_CURRENT_INJECT_ADDR (0x9)

View File

@ -82,22 +82,16 @@ void basictests() {
memset(initErrorMessage, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
LOG(logINFOBLUE, ("******** Gotthard Virtual Server *****************\n")); LOG(logINFOBLUE, ("******** Gotthard Virtual Server *****************\n"));
#else
LOG(logINFOBLUE, ("**************** Gotthard Server *****************\n"));
#endif
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(initErrorMessage, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
LOG(logERROR, (initErrorMessage)); LOG(logERROR, (initErrorMessage));
initError = FAIL; initError = FAIL;
} }
return; #ifndef VIRTUAL
#else
if (mapCSP0() == FAIL) {
strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage));
initError = FAIL;
return;
}
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && (!updateFlag) && if ((!debugflag) && (!updateFlag) &&
((checkType() == FAIL) || (testFpga() == FAIL) || ((checkType() == FAIL) || (testFpga() == FAIL) ||
@ -108,7 +102,7 @@ void basictests() {
initError = FAIL; initError = FAIL;
return; return;
} }
#endif
uint32_t boardrev = getBoardRevision(); uint32_t boardrev = getBoardRevision();
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
@ -117,7 +111,7 @@ void basictests() {
int64_t client_sw_apiversion = getClientServerAPIVersion(); int64_t client_sw_apiversion = getClientServerAPIVersion();
LOG(logINFOBLUE, LOG(logINFOBLUE,
("************ Gotthard Server *********************\n" ("**************************************************\n"
"Board Revision : 0x%x\n" "Board Revision : 0x%x\n"
"Detector IP Addr : 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)fwversion, (long long int)swversion,
(long long int)client_sw_apiversion)); (long long int)client_sw_apiversion));
#ifndef VIRTUAL
if (!debugflag || updateFlag) { if (!debugflag || updateFlag) {
LOG(logINFO, ("Basic Tests - success\n")); LOG(logINFO, ("Basic Tests - success\n"));
} }

View File

@ -67,14 +67,9 @@ void basictests() {
memset(initErrorMessage, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
LOG(logINFOBLUE, ("******** Jungfrau Virtual Server *****************\n")); 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 #else
LOG(logINFOBLUE, ("************ Jungfrau Server *********************\n"));
initError = defineGPIOpins(initErrorMessage); initError = defineGPIOpins(initErrorMessage);
if (initError == FAIL) { if (initError == FAIL) {
return; return;
@ -83,14 +78,14 @@ void basictests() {
if (initError == FAIL) { if (initError == FAIL) {
return; return;
} }
#endif
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(initErrorMessage, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage)); LOG(logERROR, (initErrorMessage));
initError = FAIL; initError = FAIL;
return;
} }
#ifndef VIRTUAL
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && (!updateFlag) && if ((!debugflag) && (!updateFlag) &&
((checkType() == FAIL) || (testFpga() == FAIL) || ((checkType() == FAIL) || (testFpga() == FAIL) ||
@ -101,7 +96,7 @@ void basictests() {
initError = FAIL; initError = FAIL;
return; return;
} }
#endif
uint16_t hversion = getHardwareVersionNumber(); uint16_t hversion = getHardwareVersionNumber();
uint16_t hsnumber = getHardwareSerialNumber(); uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
@ -135,6 +130,7 @@ void basictests() {
(long long int)sw_fw_apiversion, requiredFirmwareVersion, (long long int)sw_fw_apiversion, requiredFirmwareVersion,
(long long int)client_sw_apiversion)); (long long int)client_sw_apiversion));
#ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (debugflag || updateFlag) { if (debugflag || updateFlag) {
return; return;

View File

@ -88,16 +88,9 @@ void basictests() {
initCheckDone = 0; initCheckDone = 0;
memset(initErrorMessage, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
LOG(logINFOBLUE, LOG(logINFOBLUE, ("********* Moench Detector Virtual Server *********\n"));
("******** 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;
#else #else
LOG(logINFOBLUE, ("************* Moench Detector Server *************\n"));
initError = defineGPIOpins(initErrorMessage); initError = defineGPIOpins(initErrorMessage);
if (initError == FAIL) { if (initError == FAIL) {
@ -107,6 +100,7 @@ void basictests() {
if (initError == FAIL) { if (initError == FAIL) {
return; return;
} }
#endif
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(initErrorMessage, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
@ -114,7 +108,7 @@ void basictests() {
initError = FAIL; initError = FAIL;
return; return;
} }
#ifndef VIRTUAL
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && (!updateFlag) && if ((!debugflag) && (!updateFlag) &&
((checkType() == FAIL) || (testFpga() == FAIL) || ((checkType() == FAIL) || (testFpga() == FAIL) ||
@ -125,7 +119,7 @@ void basictests() {
initError = FAIL; initError = FAIL;
return; return;
} }
#endif
uint16_t hversion = getHardwareVersionNumber(); uint16_t hversion = getHardwareVersionNumber();
uint16_t hsnumber = getHardwareSerialNumber(); uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
@ -138,7 +132,7 @@ void basictests() {
if (fwversion >= MIN_REQRD_VRSN_T_RD_API) if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getFirmwareAPIVersion(); sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE, LOG(logINFOBLUE,
("************ Moench Detector Server *********************\n" ("**************************************************\n"
"Hardware Version:\t\t 0x%x\n" "Hardware Version:\t\t 0x%x\n"
"Hardware Serial Nr:\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)sw_fw_apiversion, REQRD_FRMWR_VRSN,
(long long int)client_sw_apiversion)); (long long int)client_sw_apiversion));
#ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (debugflag || updateFlag) { if (debugflag || updateFlag) {
return; return;

View File

@ -82,23 +82,17 @@ void basictests() {
initCheckDone = 0; initCheckDone = 0;
memset(initErrorMessage, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
LOG(logINFOBLUE, ("******** Mythen3 Virtual Server *****************\n")); LOG(logINFOBLUE, ("************* Mythen3 Virtual Server *************\n"));
#else
LOG(logINFOBLUE, ("***************** Mythen3 Server *****************\n"));
#endif
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(initErrorMessage, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
LOG(logERROR, (initErrorMessage)); LOG(logERROR, (initErrorMessage));
initError = FAIL; initError = FAIL;
} }
return; #ifndef VIRTUAL
#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;
}
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && (!updateFlag) && if ((!debugflag) && (!updateFlag) &&
((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || ((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) ||
@ -110,6 +104,7 @@ void basictests() {
initError = FAIL; initError = FAIL;
return; return;
} }
#endif
uint16_t hversion = getHardwareVersionNumber(); uint16_t hversion = getHardwareVersionNumber();
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
@ -121,7 +116,7 @@ void basictests() {
uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN; uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN;
LOG(logINFOBLUE, LOG(logINFOBLUE,
("*************************************************\n" ("**************************************************\n"
"Hardware Version:\t\t 0x%x\n" "Hardware Version:\t\t 0x%x\n"
"Detector IP Addr:\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)sw_fw_apiversion, requiredFirmwareVersion,
(long long int)client_sw_apiversion)); (long long int)client_sw_apiversion));
#ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (debugflag || updateFlag) { if (debugflag || updateFlag) {
return; return;
@ -506,35 +502,15 @@ void setupDetector() {
setSettings(DEFAULT_SETTINGS); setSettings(DEFAULT_SETTINGS);
// check module type attached if not in debug mode // check module type attached if not in debug mode
{ if (initError == FAIL)
int ret = checkDetectorType(); return;
if (checkModuleFlag) { if (!checkModuleFlag) {
switch (ret) { LOG(logINFOBLUE, ("In No-Module mode: Ignoring module type...\n"));
case -1: } else {
sprintf(initErrorMessage, initError = checkDetectorType(initErrorMessage);
"Could not get the module type attached.\n"); }
initError = FAIL; if (initError == FAIL) {
LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); return;
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"));
}
} }
powerChip(1); powerChip(1);
@ -2095,39 +2071,40 @@ int enableTenGigabitEthernet(int val) {
return oneG ? 0 : 1; return oneG ? 0 : 1;
} }
int checkDetectorType() { int checkDetectorType(char *mess) {
#ifdef VIRTUAL #ifdef VIRTUAL
return OK; return OK;
#endif #endif
LOG(logINFO, ("Checking type of module\n")); LOG(logINFO, ("Checking type of module\n"));
FILE *fd = fopen(TYPE_FILE_NAME, "r"); FILE *fd = fopen(TYPE_FILE_NAME, "r");
if (fd == NULL) { if (fd == NULL) {
LOG(logERROR, sprintf(mess,
("Could not open file %s to get type of the module attached\n", "Could not open file %s to get type of the module attached\n",
TYPE_FILE_NAME)); TYPE_FILE_NAME);
return -1; return FAIL;
} }
char buffer[MAX_STR_LENGTH]; char buffer[MAX_STR_LENGTH];
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
fread(buffer, MAX_STR_LENGTH, sizeof(char), fd); fread(buffer, MAX_STR_LENGTH, sizeof(char), fd);
fclose(fd); fclose(fd);
if (strlen(buffer) == 0) { if (strlen(buffer) == 0) {
LOG(logERROR, sprintf(mess,
("Could not read file %s to get type of the module attached\n", "Could not read file %s to get type of the module attached\n",
TYPE_FILE_NAME)); TYPE_FILE_NAME);
return -1; return FAIL;
} }
int type = atoi(buffer); int type = atoi(buffer);
if (type > TYPE_NO_MODULE_STARTING_VAL) { if (type > TYPE_NO_MODULE_STARTING_VAL) {
LOG(logERROR, ("No Module attached! Expected %d for Mythen, got %d\n", sprintf(mess, "No Module attached! Run server with -nomodule.\n");
TYPE_MYTHEN3_MODULE_VAL, type)); LOG(logERROR, (mess));
return -2; return FAIL;
} }
if (abs(type - TYPE_MYTHEN3_MODULE_VAL) > TYPE_TOLERANCE) { if (abs(type - TYPE_MYTHEN3_MODULE_VAL) > TYPE_TOLERANCE) {
LOG(logERROR, sprintf(mess,
("Wrong Module attached! Expected %d for Mythen3, got %d\n", "Wrong Module attached! Expected %d for Mythen3, got %d\n",
TYPE_MYTHEN3_MODULE_VAL, type)); TYPE_MYTHEN3_MODULE_VAL, type);
LOG(logERROR, (mess));
return FAIL; return FAIL;
} }
return OK; return OK;

View File

@ -385,8 +385,10 @@ int getADC(enum ADCINDEX ind);
int setHighVoltage(int val); int setHighVoltage(int val);
// parameters - timing, extsig // parameters - timing, extsig
#ifdef EIGERD #if defined(EIGERD) || defined(GOTTHARD2D)
int setMaster(enum MASTERINDEX m); int setMaster(enum MASTERINDEX m);
#endif
#ifdef EIGERD
int setTop(enum TOPINDEX t); int setTop(enum TOPINDEX t);
int isTop(int *retval); int isTop(int *retval);
#endif #endif
@ -558,7 +560,7 @@ int setDataStream(enum portPosition port, int enable);
int setPhase(enum CLKINDEX ind, int val, int degrees); int setPhase(enum CLKINDEX ind, int val, int degrees);
#elif MYTHEN3D #elif MYTHEN3D
int checkDetectorType(); int checkDetectorType(char *mess);
int powerChip(int on); int powerChip(int on);
int setPhase(enum CLKINDEX ind, int val, int degrees); int setPhase(enum CLKINDEX ind, int val, int degrees);
int getPhase(enum CLKINDEX ind, 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); int getClockDivider(enum CLKINDEX ind);
#elif GOTTHARD2D #elif GOTTHARD2D
int checkDetectorType(); int checkDetectorType(char *mess);
int powerChip(int on); int powerChip(int on);
void setDBITPipeline(int val); void setDBITPipeline(int val);
int getDBITPipeline(); int getDBITPipeline();

View File

@ -114,7 +114,6 @@ int printSocketReadError() {
void init_detector() { void init_detector() {
memset(udpDetails, 0, sizeof(udpDetails)); memset(udpDetails, 0, sizeof(udpDetails));
#ifdef VIRTUAL #ifdef VIRTUAL
LOG(logINFO, ("This is a VIRTUAL detector\n"));
udpDetails[0].srcip = LOCALHOSTIP_INT; udpDetails[0].srcip = LOCALHOSTIP_INT;
udpDetails[0].srcip2 = LOCALHOSTIP_INT; udpDetails[0].srcip2 = LOCALHOSTIP_INT;
#endif #endif
@ -3849,27 +3848,14 @@ int power_chip(int file_des) {
#if defined(MYTHEN3D) || defined(GOTTHARD2D) #if defined(MYTHEN3D) || defined(GOTTHARD2D)
// check only when powering on // check only when powering on
if (arg != -1 && arg != 0) { if (arg != -1 && arg != 0) {
if (checkModuleFlag) { if (!checkModuleFlag) {
int type_ret = checkDetectorType(); LOG(logINFOBLUE,
if (type_ret == -1) { ("In No-Module mode: Ignoring module type. Continuing.\n"));
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));
}
} else { } else {
LOG(logINFOBLUE, ("In No-Module mode: Ignoring module " ret = checkDetectorType(mess);
"type. Continuing.\n")); if (ret == FAIL) {
LOG(logERROR, ("Could not power on chip.\n"));
}
} }
} }
#endif #endif
@ -8270,7 +8256,7 @@ int set_master(int file_des) {
return printSocketReadError(); return printSocketReadError();
LOG(logDEBUG1, ("Setting master: %u\n", (int)arg)); LOG(logDEBUG1, ("Setting master: %u\n", (int)arg));
#ifndef EIGERD #if !defined(EIGERD) && !defined(GOTTHARD2D)
functionNotImplemented(); functionNotImplemented();
#else #else
// only set // only set

View File

@ -197,10 +197,11 @@ class Detector {
*/ */
void setFlipRows(bool value, Positions pos = {}); void setFlipRows(bool value, Positions pos = {});
/** [Eiger][Mythen3][Gotthard1] via stop server **/ /** [Eiger][Mythen3][Gotthard1][Gotthard2] via stop server **/
Result<bool> getMaster(Positions pos = {}) const; Result<bool> 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); void setMaster(bool value, int pos);
Result<bool> isVirtualDetectorServer(Positions pos = {}) const; Result<bool> isVirtualDetectorServer(Positions pos = {}) const;

View File

@ -1298,9 +1298,9 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID_GET( INTEGER_COMMAND_VEC_ID_GET(
master, getMaster, setMaster, StringTo<int>, master, getMaster, setMaster, StringTo<int>,
"[0, 1]\n\t[Eiger] Sets half module to master and " "[0, 1]\n\t[Eiger][Gotthard2] Sets (half) module to master and "
"others to slaves.\n\t[Gotthard][Gotthard2][Mythen3][Eiger] " "other(s) to slaves.\n\t[Gotthard][Gotthard2][Mythen3][Eiger] "
"Gets if the current module/ half module is master."); "Gets if the current (half) module is master.");
/* acquisition parameters */ /* acquisition parameters */

View File

@ -586,7 +586,7 @@ TEST_CASE("master", "[.cmd]") {
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 || if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) { det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) {
REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET)); REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET));
if (det_type == defs::EIGER) { if (det_type == defs::EIGER || det_type == defs::GOTTHARD2) {
// get previous master // get previous master
int prevMaster = 0; int prevMaster = 0;
{ {

View File

@ -5,10 +5,10 @@
#define APILIB 0x220609 #define APILIB 0x220609
#define APIRECEIVER 0x220609 #define APIRECEIVER 0x220609
#define APIGUI 0x220609 #define APIGUI 0x220609
#define APICTB 0x220714 #define APICTB 0x220816
#define APIGOTTHARD 0x220714 #define APIGOTTHARD 0x220816
#define APIJUNGFRAU 0x220714 #define APIGOTTHARD2 0x220816
#define APIMYTHEN3 0x220714 #define APIJUNGFRAU 0x220816
#define APIMOENCH 0x220714 #define APIMYTHEN3 0x220816
#define APIEIGER 0x220714 #define APIMOENCH 0x220816
#define APIGOTTHARD2 0x220811 #define APIEIGER 0x220816