mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
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:
@ -97,6 +97,10 @@ patternParameters *setChipStatusRegisterPattern(int csr) {
|
||||
return pat;
|
||||
}
|
||||
|
||||
void flipNegativePolarityBits(int *csr) {
|
||||
(*csr) ^= ((1 << _CSR_C10pre) | (1 << _CSR_C15pre));
|
||||
}
|
||||
|
||||
int getGainCaps() {
|
||||
int csr = chipStatusRegister;
|
||||
// Translates bit representation
|
||||
@ -209,7 +213,8 @@ int M3SetNegativePolarity(int enable) {
|
||||
return csr;
|
||||
}
|
||||
|
||||
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits) {
|
||||
patternParameters *setChannelRegisterChip(int ichip, char *mask,
|
||||
int *trimbits) {
|
||||
|
||||
patternParameters *pat = malloc(sizeof(patternParameters));
|
||||
memset(pat, 0, sizeof(patternParameters));
|
||||
@ -279,44 +284,44 @@ patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits) {
|
||||
// for each channel (all chips)
|
||||
for (int ich = 0; ich < NCHAN_1_COUNTER; ich++) {
|
||||
LOG(logDEBUG1, (" Chip %d, Channel %d\n", ichip, ich));
|
||||
int val =
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS + NCOUNTERS * ich] +
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS + NCOUNTERS * ich +
|
||||
1] *
|
||||
64 +
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS + NCOUNTERS * ich +
|
||||
2] *
|
||||
64 * 64;
|
||||
int chanReg =
|
||||
64 *
|
||||
(trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS + NCOUNTERS * ich] +
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS + NCOUNTERS * ich +
|
||||
1] *
|
||||
64 +
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS + NCOUNTERS * ich +
|
||||
2] *
|
||||
64 * 64);
|
||||
|
||||
// push 6 0 bits
|
||||
for (int i = 0; i < 3; i++) {
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = setBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (mask[i])
|
||||
patword = setBit(SIGNAL_serialIN, patword);
|
||||
else
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = setBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
for (int icounter = 0; icounter != 3; ++icounter) {
|
||||
if (mask[ichip * NCHAN + ich * NCOUNTERS + icounter]) {
|
||||
LOG(logDEBUG1,
|
||||
("badchannel [modCounter:%d, modChan:%d, ichip:%d, ich:%d, "
|
||||
"icounter:%d]\n",
|
||||
ichip * NCHAN + ich * NCOUNTERS + icounter,
|
||||
ichip * NCHAN_1_COUNTER + ich, ichip, ich, icounter));
|
||||
chanReg |= (0x1 << (3 + icounter));
|
||||
}
|
||||
}
|
||||
|
||||
// deserialize
|
||||
for (int i = 0; i < 18; i++) {
|
||||
if (val & (1 << i)) {
|
||||
if (chanReg & CHAN_REG_BAD_CHANNEL_MSK) {
|
||||
LOG(logINFOBLUE,
|
||||
("badchannel [chanReg:0x%x modCounter:%d, modChan:%d, "
|
||||
"ichip:%d, ich:%d]\n",
|
||||
chanReg, ichip * NCHAN + ich * NCOUNTERS,
|
||||
ichip * NCHAN_1_COUNTER + ich, ichip, ich));
|
||||
}
|
||||
for (int i = 0; i < 24; i++) {
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
|
||||
if (chanReg & (1 << (i + 1))) {
|
||||
patword = setBit(SIGNAL_serialIN, patword);
|
||||
} else {
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
}
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
|
||||
patword = setBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
|
Reference in New Issue
Block a user