M3badchannels (#526)

* badchannels for m3 and modify for g2 (file from single and multi)

* m3: invert polarity of bit 7 and 11 signals from setmodule, allow commas in bad channel file

* badchannel file can take commas, colons and comments (also taking care of spaces at the end of channel numbers)

* tests 'badchannels' and 'Channel file reading' added, removing duplicates in badchannel list, defining macro for num counters in client side

* fix segfault when list from file is empty, 

* fix tests assertion for ctbconfig (adding message) for c++11

* fixed badchannels in m3server (clocking in trimming) 

* badchannel tests can be run from any folder (finds the file)
This commit is contained in:
Dhanya Thattil
2022-09-01 15:30:04 +02:00
committed by GitHub
parent 02322bb3c2
commit 7de6f157b5
36 changed files with 499 additions and 221 deletions

View File

@@ -624,8 +624,11 @@ int getVetoStream();
enum vetoAlgorithm getVetoAlgorithm(enum streamingInterface interface);
void setVetoAlgorithm(enum vetoAlgorithm alg,
enum streamingInterface interface);
void setBadChannels(int nch, int *channels);
int *getBadChannels(int *nch);
#endif
#if defined(GOTTHARD2D) || defined(MYTHEN3D)
int setBadChannels(int numChannels, int *channelList);
int *getBadChannels(int *numChannels);
#endif
#if defined(JUNGFRAUD) || defined(EIGERD)

View File

@@ -31,8 +31,8 @@ extern int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
#endif
void initializePatternAddresses() {
LOG(logINFO, ("Setting default Loop and Wait Addresses(0x%x)\n",
MAX_PATTERN_LENGTH - 1));
LOG(logDEBUG1, ("Setting default Loop and Wait Addresses(0x%x)\n",
MAX_PATTERN_LENGTH - 1));
for (int i = 0; i != MAX_LEVELS; ++i) {
setPatternLoopAddresses(i, MAX_PATTERN_LENGTH - 1,
MAX_PATTERN_LENGTH - 1);

View File

@@ -1897,11 +1897,11 @@ int acquire(int blocking, int file_des) {
uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip);
sprintf(mess,
"Invalid udp source ip address for this detector. Must be "
"same "
"as hardware detector ip address %s in 1G readout mode \n",
src_ip);
sprintf(
mess,
"Invalid udp source ip address for this detector. Must be "
"same as hardware detector ip address %s in 1G readout mode \n",
src_ip);
LOG(logERROR, (mess));
} else
#endif
@@ -7981,7 +7981,7 @@ int get_bad_channels(int file_des) {
LOG(logDEBUG1, ("Getting bad channels\n"));
#ifndef GOTTHARD2D
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// get only
@@ -8022,44 +8022,53 @@ int set_bad_channels(int file_des) {
LOG(logDEBUG1, ("Setting %d bad channels\n", nargs));
#ifndef GOTTHARD2D
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
// validate bad channel number
int maxChannel = NCHAN * NCHIP;
#ifdef MYTHEN3D
maxChannel = NCHAN_1_COUNTER * NCHIP;
#endif
for (int i = 0; i < nargs; ++i) {
LOG(logDEBUG1, ("\t[%d]:%d\n", i, args[i]));
if (args[i] < 0 || args[i] >= (NCHAN * NCHIP)) {
if (args[i] < 0 || args[i] >= maxChannel) {
ret = FAIL;
sprintf(mess,
"Could not set bad channels. Invalid bad channel "
"number %d. Options [0-%d]\n",
args[i], NCHIP * NCHAN - 1);
args[i], maxChannel - 1);
LOG(logERROR, (mess));
break;
}
}
if (ret == OK) {
setBadChannels(nargs, args);
int nretvals = 0;
int *retvals = getBadChannels(&nretvals);
if (nretvals == -1) {
ret = FAIL;
strcpy(mess,
"Could not get bad channels. Memory allcoation error\n");
ret = setBadChannels(nargs, args);
if (ret == FAIL) {
strcpy(mess, "Could not set bad channels.\n");
LOG(logERROR, (mess));
} else if (nretvals != nargs) {
ret = FAIL;
sprintf(
mess,
"Could not set bad channels. Set %d channels, but read %d "
"channels\n",
nargs, nretvals);
LOG(logERROR, (mess));
}
if (retvals != NULL) {
free(retvals);
} else {
int nretvals = 0;
int *retvals = getBadChannels(&nretvals);
if (nretvals == -1) {
ret = FAIL;
strcpy(mess, "Could not get bad channels. Memory "
"allcoation error\n");
LOG(logERROR, (mess));
} else if (nretvals != nargs) {
ret = FAIL;
sprintf(mess,
"Could not set bad channels. Set %d channels, but "
"read %d "
"channels\n",
nargs, nretvals);
LOG(logERROR, (mess));
}
if (retvals != NULL) {
free(retvals);
}
}
}
}