mythen3 trim one chip fix

This commit is contained in:
maliakal_d 2020-05-08 11:03:00 +02:00
parent 2ac7451a99
commit 01d1c86403

View File

@ -591,7 +591,7 @@ int setTrimbits(int *trimbits) {
LOG(logINFOBLUE, ("Setting trimbits\n")); LOG(logINFOBLUE, ("Setting trimbits\n"));
// validate // validate
for (int ichan = 0; ichan < NCHAN; ++ichan) { for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
if (trimbits[ichan] < 0 || trimbits[ichan] > 63) { if (trimbits[ichan] < 0 || trimbits[ichan] > 63) {
LOG(logERROR, ("Trimbit value (%d) for channel %d is invalid\n", LOG(logERROR, ("Trimbit value (%d) for channel %d is invalid\n",
trimbits[ichan], ichan)); trimbits[ichan], ichan));
@ -720,7 +720,7 @@ int setTrimbits(int *trimbits) {
} }
// copy trimbits locally // copy trimbits locally
for (int ichan = 0; ichan < NCHAN; ++ichan) { for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
detectorChans[ichan] = trimbits[ichan]; detectorChans[ichan] = trimbits[ichan];
} }
trimmingPrint = logINFO; trimmingPrint = logINFO;
@ -728,8 +728,8 @@ int setTrimbits(int *trimbits) {
} }
int setAllTrimbits(int val) { int setAllTrimbits(int val) {
int *trimbits = malloc(sizeof(int) * NCHAN); int *trimbits = malloc(sizeof(int) * ((detectorModules)->nchan));
for (int ichan = 0; ichan < NCHAN; ++ichan) { for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
trimbits[ichan] = val; trimbits[ichan] = val;
} }
if (setTrimbits(trimbits) == FAIL) { if (setTrimbits(trimbits) == FAIL) {
@ -748,7 +748,7 @@ int setAllTrimbits(int val) {
int getAllTrimbits() { int getAllTrimbits() {
int value = detectorChans[0]; int value = detectorChans[0];
if (detectorModules) { if (detectorModules) {
for (int ichan = 0; ichan < NCHAN; ichan++) { for (int ichan = 0; ichan < ((detectorModules)->nchan); ichan++) {
if (detectorChans[ichan] != value) { if (detectorChans[ichan] != value) {
value = -1; value = -1;
break; break;