mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
@ -1125,7 +1125,7 @@ int64_t getMeasuredSubPeriod() {
|
||||
|
||||
/* parameters - channel, module, settings */
|
||||
|
||||
void getModule(sls_detector_module* myMod) {
|
||||
void getModule(sls_detector_module *myMod) {
|
||||
// serial number
|
||||
myMod->serialnumber = detectorModules->serialnumber;
|
||||
// reg (settings)
|
||||
@ -1133,7 +1133,7 @@ void getModule(sls_detector_module* myMod) {
|
||||
// iodelay
|
||||
myMod->iodelay = setIODelay(-1);
|
||||
// tau
|
||||
myMod->tau = (int) getCurrentTau();
|
||||
myMod->tau = (int)getCurrentTau();
|
||||
// eV
|
||||
myMod->eV[0] = detectorModules->eV[0];
|
||||
// dacs
|
||||
@ -1150,8 +1150,10 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
LOG(logINFO, ("Setting module with settings %d\n", myMod.reg));
|
||||
|
||||
if (((myMod.nchan) > (detectorModules->nchan)) || ((myMod.ndac) > (detectorModules->ndac))) {
|
||||
strcpy(mess, "Could not set module as the number of channels or dacs do not match to the one in the detector server\n");
|
||||
if (((myMod.nchan) > (detectorModules->nchan)) ||
|
||||
((myMod.ndac) > (detectorModules->ndac))) {
|
||||
strcpy(mess, "Could not set module as the number of channels or dacs "
|
||||
"do not match to the one in the detector server\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -2158,7 +2160,7 @@ void setExternalGating(int enable[]) {
|
||||
enable[1] = eiger_extgatingpolarity;
|
||||
}
|
||||
|
||||
int setTrimbits(int* chanregs, char* mess) {
|
||||
int setTrimbits(int *chanregs, char *mess) {
|
||||
LOG(logINFO, ("Setting module with trimbits\n"));
|
||||
#ifndef VIRTUAL
|
||||
// include gap pixels
|
||||
@ -2190,7 +2192,7 @@ int setTrimbits(int* chanregs, char* mess) {
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random "
|
||||
"trim file)\n"));
|
||||
"trim file)\n"));
|
||||
|
||||
// if quad, reset M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(0)) {
|
||||
@ -2219,7 +2221,6 @@ int setTrimbits(int* chanregs, char* mess) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int setAllTrimbits(int val) {
|
||||
LOG(logINFO, ("Setting all trimbits to %d\n", val));
|
||||
#ifndef VIRTUAL
|
||||
|
@ -2305,9 +2305,9 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
int64_t period = getPeriod();
|
||||
int64_t delayAfterTrigger = getDelayAfterTrigger();
|
||||
int64_t burstPeriod = getBurstPeriod();
|
||||
|
||||
|
||||
systemFrequency = ((double)getVCOFrequency(SYSTEM_C0) /
|
||||
(double)clkDivider[SYSTEM_C0]);
|
||||
(double)clkDivider[SYSTEM_C0]);
|
||||
|
||||
setExpTime(exptime);
|
||||
setPeriod(period);
|
||||
|
@ -67,11 +67,11 @@
|
||||
#define SPEED_144_CLKDIV_0 (6)
|
||||
#define SPEED_144_CLKDIV_1 (6)
|
||||
#define SPEED_144_CLKPHASE_DEG_1 (122) // 125 not possible
|
||||
#define SPEED_144_DBIT_PIPELINE (1)
|
||||
#define SPEED_144_DBIT_PIPELINE (1)
|
||||
#define SPEED_108_CLKDIV_0 (8)
|
||||
#define SPEED_108_CLKDIV_1 (8)
|
||||
#define SPEED_108_CLKPHASE_DEG_1 (268) // 270 not possible
|
||||
#define SPEED_108_DBIT_PIPELINE (1)
|
||||
#define SPEED_108_DBIT_PIPELINE (1)
|
||||
|
||||
/* Firmware Definitions */
|
||||
#define FIXED_PLL_FREQUENCY (20000000) // 20MHz
|
||||
|
@ -862,7 +862,8 @@ int setROI(ROI arg) {
|
||||
rois.ymin = -1;
|
||||
rois.ymax = -1;
|
||||
} else {
|
||||
LOG(logINFO, ("Setting ROI:(%d, %d, %d, %d)\n", arg.xmin, arg.xmax, arg.ymin, arg.ymax));
|
||||
LOG(logINFO, ("Setting ROI:(%d, %d, %d, %d)\n", arg.xmin, arg.xmax,
|
||||
arg.ymin, arg.ymax));
|
||||
// validation
|
||||
// xmin divisible by 256 and less than 1280
|
||||
if (((arg.xmin % NCHAN_PER_ADC) != 0) ||
|
||||
@ -896,7 +897,8 @@ ROI getROI() {
|
||||
if (rois.xmin == -1) {
|
||||
LOG(logINFO, ("\tROI: None\n"));
|
||||
} else {
|
||||
LOG(logINFO, ("ROI: (%d,%d,%d,%d)\n", rois.xmin, rois.xmax, rois.ymin, rois.ymax));
|
||||
LOG(logINFO, ("ROI: (%d,%d,%d,%d)\n", rois.xmin, rois.xmax, rois.ymin,
|
||||
rois.ymax));
|
||||
}
|
||||
return rois;
|
||||
}
|
||||
|
@ -572,7 +572,6 @@
|
||||
#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
|
||||
#define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT)
|
||||
|
||||
|
||||
/* Pattern Loop 3 Address RW regiser */
|
||||
#define PATTERN_LOOP_3_ADDR_REG (0x84 << MEM_MAP_SHIFT)
|
||||
|
||||
|
@ -422,7 +422,7 @@ void allocateDetectorStructureMemory() {
|
||||
detectorDacs[idac] = 0;
|
||||
}
|
||||
|
||||
// trimbits start at 0
|
||||
// trimbits start at 0
|
||||
for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
|
||||
*((detectorModules->chanregs) + ichan) = 0;
|
||||
}
|
||||
@ -488,7 +488,6 @@ void setupDetector() {
|
||||
// dynamic range
|
||||
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
|
||||
|
||||
|
||||
// Initialization of acquistion parameters
|
||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||
setNumTriggers(DEFAULT_NUM_CYCLES);
|
||||
@ -1102,7 +1101,7 @@ void updateVthAndCounterMask() {
|
||||
setVthDac(2, 0);
|
||||
} else {
|
||||
// previous counter values
|
||||
setCounterMaskWithUpdateFlag(counterMask, 0);
|
||||
setCounterMaskWithUpdateFlag(counterMask, 0);
|
||||
}
|
||||
if (pumpProbe) {
|
||||
// enable only vth2
|
||||
@ -1280,7 +1279,7 @@ int setDACS(int *dacs) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
void getModule(sls_detector_module* myMod) {
|
||||
void getModule(sls_detector_module *myMod) {
|
||||
// serial number
|
||||
myMod->serialnumber = detectorModules->serialnumber;
|
||||
// csr reg
|
||||
@ -1302,8 +1301,10 @@ void getModule(sls_detector_module* myMod) {
|
||||
int setModule(sls_detector_module myMod, char *mess) {
|
||||
LOG(logINFO, ("Setting module\n"));
|
||||
|
||||
if (((myMod.nchan) > (detectorModules->nchan)) || ((myMod.ndac) > (detectorModules->ndac))) {
|
||||
strcpy(mess, "Could not set module as the number of channels or dacs do not match to the one in the detector server\n");
|
||||
if (((myMod.nchan) > (detectorModules->nchan)) ||
|
||||
((myMod.ndac) > (detectorModules->ndac))) {
|
||||
strcpy(mess, "Could not set module as the number of channels or dacs "
|
||||
"do not match to the one in the detector server\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -1359,7 +1360,8 @@ int setTrimbits(int *trimbits) {
|
||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||
|
||||
// set to trimming clock
|
||||
if (setClockDividerWithTimeUpdateOption(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) {
|
||||
if (setClockDividerWithTimeUpdateOption(
|
||||
SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not start trimming. Could not set to trimming clock\n"));
|
||||
return FAIL;
|
||||
@ -1479,7 +1481,7 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
void validateSettings() {
|
||||
LOG(logWARNING, ("Not validating dac settings temporarily"));
|
||||
return;
|
||||
|
||||
|
||||
// if any special dac value is changed individually => undefined
|
||||
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
||||
int *specialDacValues[] = {defaultDacValue_standard, defaultDacValue_fast,
|
||||
@ -1541,7 +1543,7 @@ void setDAC(enum DACINDEX ind, int val, int mV, int counterEnableCheck) {
|
||||
return;
|
||||
}
|
||||
|
||||
// threshold dacs
|
||||
// threshold dacs
|
||||
// remember value, vthreshold: skip disabled,
|
||||
// others: disable or enable dac if counter mask
|
||||
// setDAC called directly: will set independent of counter enable
|
||||
@ -1569,8 +1571,8 @@ void setDAC(enum DACINDEX ind, int val, int mV, int counterEnableCheck) {
|
||||
// skip setting vthx dac (value remembered anyway)
|
||||
if (ind == M_VTHRESHOLD) {
|
||||
continue;
|
||||
}
|
||||
// disable dac (except when setting dac directly)
|
||||
}
|
||||
// disable dac (except when setting dac directly)
|
||||
if (counterEnableCheck) {
|
||||
val = DEFAULT_COUNTER_DISABLED_VTH_VAL;
|
||||
}
|
||||
@ -1624,7 +1626,7 @@ void setVthDac(int index, int enable) {
|
||||
if (enable) {
|
||||
value = vthEnabledVals[index];
|
||||
}
|
||||
setGeneralDAC(vthdacs[index], value, 0);
|
||||
setGeneralDAC(vthdacs[index], value, 0);
|
||||
}
|
||||
|
||||
int getDAC(enum DACINDEX ind, int mV) {
|
||||
@ -1790,11 +1792,11 @@ int setGainCaps(int caps) {
|
||||
int setInterpolation(int enable) {
|
||||
LOG(logINFO,
|
||||
("%s Interpolation\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||
|
||||
|
||||
int csr = M3SetInterpolation(enable);
|
||||
int ret = setChipStatusRegister(csr);
|
||||
if (ret == OK) {
|
||||
updateVthAndCounterMask();
|
||||
updateVthAndCounterMask();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -2271,7 +2273,8 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
return setClockDividerWithTimeUpdateOption(ind, val, 1);
|
||||
}
|
||||
|
||||
int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, int timeUpdate) {
|
||||
int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val,
|
||||
int timeUpdate) {
|
||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||
LOG(logERROR, ("Unknown clock index %d to set clock divider\n", ind));
|
||||
return FAIL;
|
||||
@ -2310,7 +2313,7 @@ int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, int timeUpda
|
||||
}
|
||||
int64_t period = getPeriod();
|
||||
int64_t delayAfterTrigger = getDelayAfterTrigger();
|
||||
|
||||
|
||||
clkDivider[ind] = val;
|
||||
|
||||
for (int i = 0; i != 3; ++i) {
|
||||
@ -2461,8 +2464,8 @@ void *start_timer(void *arg) {
|
||||
|
||||
for (int i = 0; i < nchannels; ++i) {
|
||||
switch (dr) {
|
||||
//case 1: // TODO: Not implemented in firmware yet
|
||||
// break;
|
||||
// case 1: // TODO: Not implemented in firmware yet
|
||||
// break;
|
||||
case 8:
|
||||
*((uint8_t *)(imageData + i)) = (uint8_t)i;
|
||||
break;
|
||||
@ -2470,7 +2473,8 @@ void *start_timer(void *arg) {
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)i;
|
||||
break;
|
||||
case 32:
|
||||
*((uint32_t *)(imageData + i * sizeof(uint32_t))) = ((uint32_t)i & 0xFFFFFF); // 24 bit
|
||||
*((uint32_t *)(imageData + i * sizeof(uint32_t))) =
|
||||
((uint32_t)i & 0xFFFFFF); // 24 bit
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -2491,8 +2495,7 @@ void *start_timer(void *arg) {
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
for (int i = 0; i != packetsPerFrame; ++i) {
|
||||
@ -2712,7 +2715,8 @@ int setChipStatusRegister(int csr) {
|
||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||
|
||||
// set to trimming clock
|
||||
if (setClockDividerWithTimeUpdateOption(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) {
|
||||
if (setClockDividerWithTimeUpdateOption(
|
||||
SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not set to trimming clock in order to change CSR\n"));
|
||||
return FAIL;
|
||||
|
@ -105,7 +105,7 @@ enum DACINDEX {
|
||||
1220, /* vIpreOut */ \
|
||||
2800, /* Vth3 */ \
|
||||
2800, /* Vth1 */ \
|
||||
800, /* vIcin */ \
|
||||
800, /* vIcin */ \
|
||||
1800, /* cas */ \
|
||||
1100, /* Vrpreamp */ \
|
||||
1100, /* Vcal_n */ \
|
||||
|
@ -29,9 +29,10 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
ssize_t fsize, int forceDeleteNormalFile);
|
||||
int getDrive(char *mess, enum PROGRAM_INDEX index);
|
||||
/** Notify fpga not to touch flash, open src and flash drive to write */
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
|
||||
int forceDeleteNormalFile);
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile);
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd,
|
||||
FILE **srcfd, int forceDeleteNormalFile);
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index,
|
||||
int forceDeleteNormalFile);
|
||||
int eraseFlash(char *mess);
|
||||
/* write from tmp file to flash */
|
||||
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, FILE *srcfd);
|
||||
|
@ -310,14 +310,14 @@ int64_t getMeasurementTime();
|
||||
|
||||
// parameters - module, settings
|
||||
#if defined(MYTHEN3D) || defined(EIGERD)
|
||||
void getModule(sls_detector_module* myMod);
|
||||
void getModule(sls_detector_module *myMod);
|
||||
#endif
|
||||
#if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(GOTTHARD2D))
|
||||
int setModule(sls_detector_module myMod, char *mess);
|
||||
#endif
|
||||
|
||||
#ifdef EIGERD
|
||||
int setTrimbits(int* chanregs, char* mess);
|
||||
int setTrimbits(int *chanregs, char *mess);
|
||||
#endif
|
||||
#ifdef MYTHEN3D
|
||||
int setTrimbits(int *trimbits);
|
||||
@ -569,7 +569,8 @@ int getFrequency(enum CLKINDEX ind);
|
||||
int getVCOFrequency(enum CLKINDEX ind);
|
||||
int getMaxClockDivider();
|
||||
int setClockDivider(enum CLKINDEX ind, int val);
|
||||
int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, int timeUpdate);
|
||||
int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val,
|
||||
int timeUpdate);
|
||||
int getClockDivider(enum CLKINDEX ind);
|
||||
|
||||
#elif GOTTHARD2D
|
||||
|
@ -411,14 +411,14 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
LOG(level, ("Sending Module\n"));
|
||||
int ts = 0, n = 0;
|
||||
|
||||
n = sendData(file_des, &(myMod->serialnumber),
|
||||
sizeof(myMod->serialnumber), INT32);
|
||||
n = sendData(file_des, &(myMod->serialnumber), sizeof(myMod->serialnumber),
|
||||
INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
LOG(level, ("serialno sent %d bytes. serialno: %d\n", n,
|
||||
myMod->serialnumber));
|
||||
LOG(level,
|
||||
("serialno sent %d bytes. serialno: %d\n", n, myMod->serialnumber));
|
||||
n = sendData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
@ -448,8 +448,7 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
LOG(level,
|
||||
("iodelay sent %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||
LOG(level, ("iodelay sent %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||
n = sendData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
@ -471,7 +470,7 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
LOG(level, ("dacs sent %d bytes.\n", n));
|
||||
// channels
|
||||
n = sendData(file_des, myMod->chanregs, sizeof(int) * (myMod->nchan),
|
||||
INT32);
|
||||
INT32);
|
||||
LOG(level, ("chanregs sent %d bytes.\n", n));
|
||||
if (!n) {
|
||||
return -1;
|
||||
@ -494,8 +493,8 @@ int receiveModule(int file_des, sls_detector_module *myMod) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
LOG(level, ("serialno received %d bytes. serialno: %d\n", n,
|
||||
myMod->serialnumber));
|
||||
LOG(level,
|
||||
("serialno received %d bytes. serialno: %d\n", n, myMod->serialnumber));
|
||||
n = receiveData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
@ -525,8 +524,7 @@ int receiveModule(int file_des, sls_detector_module *myMod) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
LOG(level,
|
||||
("iodelay received %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||
LOG(level, ("iodelay received %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||
n = receiveData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
|
@ -164,8 +164,10 @@ void writePatternWord(int addr, uint64_t word) {
|
||||
int validate_getPatternWaitAddresses(char *message, int level, int *addr) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(message,
|
||||
"Cannot get patwait address. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
sprintf(
|
||||
message,
|
||||
"Cannot get patwait address. Level %d must be between 0 and %d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -203,8 +205,10 @@ int getPatternWaitAddress(int level) {
|
||||
int validate_setPatternWaitAddresses(char *message, int level, int addr) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(message,
|
||||
"Cannot set patwait address. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
sprintf(
|
||||
message,
|
||||
"Cannot set patwait address. Level %d must be between 0 and %d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -274,7 +278,8 @@ int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(message,
|
||||
"Cannot get patwaittime. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
"Cannot get patwaittime. Level %d must be between 0 and %d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -313,7 +318,8 @@ int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(message,
|
||||
"Cannot set patwaittime. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
"Cannot set patwaittime. Level %d must be between 0 and %d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -376,7 +382,8 @@ int validate_getPatternLoopCycles(char *message, int level, int *numLoops) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(message,
|
||||
"Cannot get patnloop. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
"Cannot get patnloop. Level %d must be between 0 and %d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -409,7 +416,8 @@ int validate_setPatternLoopCycles(char *message, int level, int numLoops) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(message,
|
||||
"Cannot set patnloop. Level %d must be between 0 and %d.\n", level, MAX_LEVELS);
|
||||
"Cannot set patnloop. Level %d must be between 0 and %d.\n",
|
||||
level, MAX_LEVELS);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -519,9 +527,10 @@ int validate_getPatternLoopAddresses(char *message, int level, int *startAddr,
|
||||
int *stopAddr) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(
|
||||
message,
|
||||
"Cannot get patloop addresses. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
sprintf(message,
|
||||
"Cannot get patloop addresses. Level %d must be between 0 and "
|
||||
"%d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -591,9 +600,10 @@ int validate_setPatternLoopAddresses(char *message, int level, int startAddr,
|
||||
int stopAddr) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(
|
||||
message,
|
||||
"Cannot set patloop addresses. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
sprintf(message,
|
||||
"Cannot set patloop addresses. Level %d must be between 0 and "
|
||||
"%d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -970,13 +980,13 @@ int loadPatternFile(char *patFname, char *errMessage) {
|
||||
}
|
||||
|
||||
// patloop
|
||||
if (!strncmp(line, "patloop", strlen("patloop"))){
|
||||
if (!strncmp(line, "patloop", strlen("patloop"))) {
|
||||
int level = -1;
|
||||
int startAddr = 0;
|
||||
int stopAddr = 0;
|
||||
// cannot scan values
|
||||
if (sscanf(line, "%s %d 0x%x 0x%x", command, &level, &startAddr, &stopAddr) !=
|
||||
4) {
|
||||
if (sscanf(line, "%s %d 0x%x 0x%x", command, &level, &startAddr,
|
||||
&stopAddr) != 4) {
|
||||
strcpy(temp, "Could not scan patloop arguments.\n");
|
||||
break;
|
||||
}
|
||||
|
@ -110,7 +110,8 @@ int defineGPIOpins(char *mess) {
|
||||
if (access(CMD_GPIO9_EXIST, F_OK) != 0) {
|
||||
if (executeCommand(CMD_GPIO9_DEFINE, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not define gpio9 (nConfig) for fpga (%s)\n", retvals);
|
||||
"Could not define gpio9 (nConfig) for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -146,7 +147,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
||||
// define gpio9 as output
|
||||
if (executeCommand(CMD_GPIO9_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio9 (nConfig) as output for fpga (%s)\n", retvals);
|
||||
"Could not set gpio9 (nConfig) as output for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -156,7 +158,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
||||
if (programming && latestKernelVerified == 1) {
|
||||
if (executeCommand(CMD_GPIO3_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio3 (nCE) as output for fpga (%s)\n", retvals);
|
||||
"Could not set gpio3 (nCE) as output for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -166,9 +169,10 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
||||
// tell FPGA to not: gpio9
|
||||
if (executeCommand(CMD_GPIO9_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
||||
FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio9 (nConfig) to not touch flash for fpga (%s)\n",
|
||||
retvals);
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio9 (nConfig) to not touch flash for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -178,9 +182,10 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
||||
if (programming && latestKernelVerified == 1) {
|
||||
if (executeCommand(CMD_GPIO3_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
||||
FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio3 (nCE) to not touch flash for fpga (%s)\n",
|
||||
retvals);
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio3 (nCE) to not touch flash for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -198,7 +203,8 @@ int FPGATouchFlash(char *mess, int programming) {
|
||||
// tell FPGA to touch flash to program itself
|
||||
if (executeCommand(CMD_GPIO9_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio9 (nConfig) as input for fpga (%s)\n", retvals);
|
||||
"Could not set gpio9 (nConfig) as input for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -207,7 +213,8 @@ int FPGATouchFlash(char *mess, int programming) {
|
||||
if (programming && latestKernelVerified == 1) {
|
||||
if (executeCommand(CMD_GPIO3_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio3 (nCE) as input for fpga (%s)\n", retvals);
|
||||
"Could not set gpio3 (nCE) as input for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -341,8 +348,8 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
|
||||
FILE *flashfd = NULL;
|
||||
FILE *srcfd = NULL;
|
||||
if (openFileForFlash(mess, index, &flashfd, &srcfd, forceDeleteNormalFile) ==
|
||||
FAIL) {
|
||||
if (openFileForFlash(mess, index, &flashfd, &srcfd,
|
||||
forceDeleteNormalFile) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -446,8 +453,8 @@ int getDrive(char *mess, enum PROGRAM_INDEX index) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
|
||||
int forceDeleteNormalFile) {
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd,
|
||||
FILE **srcfd, int forceDeleteNormalFile) {
|
||||
// open src file
|
||||
*srcfd = fopen(TEMP_PROG_FILE_NAME, "r");
|
||||
if (*srcfd == NULL) {
|
||||
@ -480,13 +487,13 @@ int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE
|
||||
return OK;
|
||||
}
|
||||
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile) {
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index,
|
||||
int forceDeleteNormalFile) {
|
||||
#ifndef VIRTUAL
|
||||
// check if its a normal file or special file
|
||||
struct stat buf;
|
||||
if (stat(flashDriveName, &buf) == -1) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to find the flash drive %s\n",
|
||||
sprintf(mess, "Could not %s. Unable to find the flash drive %s\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
@ -507,17 +514,21 @@ int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalF
|
||||
// user does not allow to fix it (default)
|
||||
if (forceDeleteNormalFile == 0) {
|
||||
sprintf(mess,
|
||||
"Could not %s. The flash drive %s found for fpga programming is a normal file. To "
|
||||
"fix this (by deleting this file, creating the flash drive and proceeding with "
|
||||
"programming), re-run the programming command 'programfpga' with parameter "
|
||||
"'--force-delete-normal-file'\n",
|
||||
messageType, flashDriveName);
|
||||
"Could not %s. The flash drive %s found for fpga "
|
||||
"programming is a normal file. To "
|
||||
"fix this (by deleting this file, creating the flash drive "
|
||||
"and proceeding with "
|
||||
"programming), re-run the programming command "
|
||||
"'programfpga' with parameter "
|
||||
"'--force-delete-normal-file'\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
// fpga memory stays after a reboot, user allowed to fix it
|
||||
LOG(logWARNING, ("Flash drive invalidated (normal file). Fixing it...\n"));
|
||||
LOG(logWARNING,
|
||||
("Flash drive invalidated (normal file). Fixing it...\n"));
|
||||
|
||||
// user allows to fix it, so force delete normal file
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
@ -678,7 +689,8 @@ int waitForFPGAtoTouchFlash(char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFO, ("\tWaiting for FPGA to program from flash... \n\t[gpio7 (CD) should be High when done]\n"));
|
||||
LOG(logINFO, ("\tWaiting for FPGA to program from flash... \n\t[gpio7 (CD) "
|
||||
"should be High when done]\n"));
|
||||
int timeSpent = 0;
|
||||
|
||||
int result = 0;
|
||||
@ -718,6 +730,7 @@ int waitForFPGAtoTouchFlash(char *mess) {
|
||||
}
|
||||
LOG(logDEBUG1, ("gpi07 (CD)returned %d\n", result));
|
||||
}
|
||||
LOG(logINFO, ("\tFPGA has picked up the program from flash. gpio7 (CD) is High\n"));
|
||||
LOG(logINFO,
|
||||
("\tFPGA has picked up the program from flash. gpio7 (CD) is High\n"));
|
||||
return OK;
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
/* global variables */
|
||||
|
||||
@ -151,8 +151,7 @@ int openFileForFlash(char *mess, FILE **flashfd) {
|
||||
// check if its a normal file or special file
|
||||
struct stat buf;
|
||||
if (stat(flashDriveName, &buf) == -1) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to find the flash drive %s\n",
|
||||
sprintf(mess, "Could not %s. Unable to find the flash drive %s\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
|
@ -1292,7 +1292,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
||||
// ignore counter enable to force vth dac values
|
||||
setDAC(serverDacIndex, val, mV, 0);
|
||||
#else
|
||||
setDAC(serverDacIndex, val, mV);
|
||||
setDAC(serverDacIndex, val, mV);
|
||||
#endif
|
||||
retval = getDAC(serverDacIndex, mV);
|
||||
}
|
||||
@ -1573,7 +1573,7 @@ int get_module(int file_des) {
|
||||
|
||||
#if !defined(MYTHEN3D) && !defined(EIGERD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
#else
|
||||
|
||||
// allocate to receive module structure
|
||||
// allocate dacs
|
||||
@ -1605,7 +1605,8 @@ int get_module(int file_des) {
|
||||
|
||||
// ensure nchan is not 0, else trimbits not copied
|
||||
if (module.nchan == 0) {
|
||||
strcpy(mess, "Could not get module as the number of channels to copy is 0\n");
|
||||
strcpy(mess, "Could not get module as the number of channels to "
|
||||
"copy is 0\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -1625,7 +1626,6 @@ int get_module(int file_des) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int set_module(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -1881,55 +1881,57 @@ int acquire(int blocking, int file_des) {
|
||||
#ifdef EIGERD
|
||||
// check for hardware mac and hardware ip
|
||||
if (udpDetails[0].srcmac != getDetectorMAC()) {
|
||||
ret = FAIL;
|
||||
uint64_t sourcemac = getDetectorMAC();
|
||||
char src_mac[MAC_ADDRESS_SIZE];
|
||||
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
|
||||
sprintf(mess,
|
||||
ret = FAIL;
|
||||
uint64_t sourcemac = getDetectorMAC();
|
||||
char src_mac[MAC_ADDRESS_SIZE];
|
||||
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
|
||||
sprintf(
|
||||
mess,
|
||||
"Invalid udp source mac address for this detector. Must be "
|
||||
"same as hardware detector mac address %s\n",
|
||||
src_mac);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (!enableTenGigabitEthernet(GET_FLAG) &&
|
||||
(udpDetails[0].srcip != getDetectorIP())) {
|
||||
ret = FAIL;
|
||||
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);
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
#endif
|
||||
if (configured == FAIL) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not start acquisition because ");
|
||||
strcat(mess, configureMessage);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not start acquisition because a scan is "
|
||||
"already running!\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
memset(scanErrMessage, 0, MAX_STR_LENGTH);
|
||||
sharedMemory_setScanStop(0);
|
||||
sharedMemory_setScanStatus(IDLE); // if it was error
|
||||
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
|
||||
&blocking)) {
|
||||
LOG(logERROR, (mess));
|
||||
} else if (!enableTenGigabitEthernet(GET_FLAG) &&
|
||||
(udpDetails[0].srcip != getDetectorIP())) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not start acquisition thread!\n");
|
||||
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);
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
#endif
|
||||
if (configured == FAIL) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not start acquisition because ");
|
||||
strcat(mess, configureMessage);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not start acquisition because a scan is "
|
||||
"already running!\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
// only does not wait for non blocking and scan
|
||||
if (blocking || !scan) {
|
||||
pthread_join(pthread_tid, NULL);
|
||||
memset(scanErrMessage, 0, MAX_STR_LENGTH);
|
||||
sharedMemory_setScanStop(0);
|
||||
sharedMemory_setScanStatus(IDLE); // if it was error
|
||||
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
|
||||
&blocking)) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not start acquisition thread!\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
// only does not wait for non blocking and scan
|
||||
if (blocking || !scan) {
|
||||
pthread_join(pthread_tid, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
@ -2118,7 +2120,8 @@ int set_num_frames(int file_des) {
|
||||
arg > MAX_FRAMES_IN_BURST_MODE) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set number of frames %lld. Must be less than equal to %d in "
|
||||
"Could not set number of frames %lld. Must be less "
|
||||
"than equal to %d in "
|
||||
"burst mode.\n",
|
||||
(long long unsigned int)arg, MAX_FRAMES_IN_BURST_MODE);
|
||||
LOG(logERROR, (mess));
|
||||
@ -9260,11 +9263,12 @@ int clear_all_udp_dst(int file_des) {
|
||||
#endif
|
||||
{
|
||||
numUdpDestinations = numdest;
|
||||
LOG(logINFOBLUE, ("Number of UDP Destinations: %d\n",
|
||||
numUdpDestinations));
|
||||
LOG(logINFOBLUE,
|
||||
("Number of UDP Destinations: %d\n", numUdpDestinations));
|
||||
ret = configureMAC();
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not clear all destinations in the fpga.\n");
|
||||
strcpy(mess,
|
||||
"Could not clear all destinations in the fpga.\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
@ -9968,21 +9972,22 @@ int set_interpolation(int file_des) {
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (getPumpProbe() && arg) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set interpolation. Disable pump probe mode first.\n");
|
||||
sprintf(mess, "Could not set interpolation. Disable pump probe "
|
||||
"mode first.\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
} else {
|
||||
ret = setInterpolation(arg);
|
||||
if (ret == FAIL) {
|
||||
if (arg)
|
||||
sprintf(mess, "Could not set interpolation or enable all "
|
||||
"counters for it.\n");
|
||||
"counters for it.\n");
|
||||
else
|
||||
sprintf(mess, "Could not set interpolation\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
int retval = getInterpolation();
|
||||
validate(&ret, mess, (int)arg, (int)retval, "set interpolation",
|
||||
DEC);
|
||||
DEC);
|
||||
LOG(logDEBUG1, ("interpolation retval: %u\n", retval));
|
||||
}
|
||||
}
|
||||
@ -10024,16 +10029,18 @@ int set_pump_probe(int file_des) {
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (getInterpolation() && arg) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set pump probe mode. Disable interpolation mode first.\n");
|
||||
sprintf(mess, "Could not set pump probe mode. Disable "
|
||||
"interpolation mode first.\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
} else {
|
||||
ret = setPumpProbe(arg);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set pump probe\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
int retval = getPumpProbe();
|
||||
validate(&ret, mess, (int)arg, (int)retval, "set pump probe", DEC);
|
||||
validate(&ret, mess, (int)arg, (int)retval, "set pump probe",
|
||||
DEC);
|
||||
LOG(logDEBUG1, ("pump probe retval: %u\n", retval));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user