diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index bd191894d..a6a42693d 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -523,6 +523,9 @@ void setupDetector() { INA226_CalibrateCurrentRegister(I2C_POWER_VD_DEVICE_ID); setVchip(VCHIP_MIN_MV); + // set vio to minimum for fpga to function + setPower(D_PWR_IO, VIO_MIN_MV); + // altera pll ALTERA_PLL_SetDefines(PLL_CNTRL_REG, PLL_PARAM_REG, PLL_CNTRL_RCNFG_PRMTR_RST_MSK, PLL_CNTRL_WR_PRMTR_MSK, PLL_CNTRL_PLL_RST_MSK, PLL_CNTRL_ADDR_MSK, PLL_CNTRL_ADDR_OFST); @@ -1214,9 +1217,11 @@ int getADCIndexFromDACIndex(enum DACINDEX ind) { } } -int isPowerValid(int val) { +int isPowerValid(enum DACINDEX ind, int val) { + int min = (ind == D_PWR_IO) ? VIO_MIN_MV : POWER_RGLTR_MIN; + // not power_rgltr_max because it is allowed only upto vchip max - 200 - if (val != 0 && (val != LTC2620_PWR_DOWN_VAL) && (val < POWER_RGLTR_MIN || val > (VCHIP_MAX_MV - VCHIP_POWER_INCRMNT))) {//POWER_RGLTR_MAX)) { + if (val != 0 && (val != LTC2620_PWR_DOWN_VAL) && (val < min || val > (VCHIP_MAX_MV - VCHIP_POWER_INCRMNT))) { return 0; } return 1; @@ -1281,8 +1286,9 @@ void setPower(enum DACINDEX ind, int val) { FILE_LOG(logINFO, ("Setting Power to %d mV\n", val)); // validate value (already checked at tcp) - if (!isPowerValid(val)) { - FILE_LOG(logERROR, ("Invalid value of %d mV for Power %d. Is not between %d and %d mV\n", val, ind, POWER_RGLTR_MIN, POWER_RGLTR_MAX)); + if (!isPowerValid(ind, val)) { + FILE_LOG(logERROR, ("Invalid value of %d mV for Power %d. Is not between %d and %d mV\n", + val, ind, (ind == D_PWR_IO ? VIO_MIN_MV : POWER_RGLTR_MIN), POWER_RGLTR_MAX)); return; } @@ -1325,12 +1331,6 @@ void setPower(enum DACINDEX ind, int val) { return; } - if (dacval > LTC2620_MAX_VAL) - dacval = LTC2620_MAX_VAL; - if (dacval < LTC2620_MIN_VAL) - dacval = LTC2620_MIN_VAL; - FILE_LOG(logDEBUG1, ("Adjusted for tolerance, hence within limits, new dac val: %d\n", dacval)); - // set and power on/ update dac FILE_LOG(logINFO, ("Setting P%d (DAC %d): %d dac (%d mV)\n", adcIndex, ind, dacval, val)); setDAC(ind, dacval, 0); @@ -1725,12 +1725,12 @@ uint64_t writePatternClkControl(uint64_t word) { uint64_t readPatternWord(int addr) { // error (handled in tcp) if (addr < 0 || addr >= MAX_PATTERN_LENGTH) { - FILE_LOG(logERROR, ("Cannot get Pattern - Word. Invalid addr %d. " - "Should be within %d\n", addr, MAX_PATTERN_LENGTH)); + FILE_LOG(logERROR, ("Cannot get Pattern - Word. Invalid addr 0x%x. " + "Should be within 0x%x\n", addr, MAX_PATTERN_LENGTH)); return -1; } - FILE_LOG(logDEBUG1, ("Reading Pattern - Word (addr:%d)\n", addr)); + FILE_LOG(logDEBUG1, ("Reading Pattern - Word (addr:0x%x)\n", addr)); uint32_t reg = PATTERN_CNTRL_REG; // overwrite with only addr @@ -1739,13 +1739,13 @@ uint64_t readPatternWord(int addr) { // set read strobe bus_w(reg, bus_r(reg) | PATTERN_CNTRL_RD_MSK); - // read value - uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG); - FILE_LOG(logDEBUG1, ("Word(addr:%d): 0x%llx\n", addr, (long long int) retval)); - // unset read strobe bus_w(reg, bus_r(reg) & (~PATTERN_CNTRL_RD_MSK)); + // read value + uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG); + FILE_LOG(logDEBUG1, ("Word(addr:0x%x): 0x%llx\n", addr, (long long int) retval)); + return retval; } @@ -1756,16 +1756,17 @@ uint64_t writePatternWord(int addr, uint64_t word) { // error (handled in tcp) if (addr < 0 || addr >= MAX_PATTERN_LENGTH) { - FILE_LOG(logERROR, ("Cannot set Pattern - Word. Invalid addr %d. " - "Should be within %d\n", addr, MAX_PATTERN_LENGTH)); + FILE_LOG(logERROR, ("Cannot set Pattern - Word. Invalid addr 0x%x. " + "Should be within 0x%x\n", addr, MAX_PATTERN_LENGTH)); return -1; } - FILE_LOG(logINFO, ("Setting Pattern - Word (addr:%d, word:0x%llx)\n", addr, (long long int) word)); + FILE_LOG(logINFO, ("Setting Pattern - Word (addr:0x%x, word:0x%llx)\n", addr, (long long int) word)); uint32_t reg = PATTERN_CNTRL_REG; // write word set64BitReg(word, PATTERN_IN_LSB_REG, PATTERN_IN_MSB_REG); + FILE_LOG(logDEBUG1, ("Wrote word. PatternIn Reg: 0x%llx\n", get64BitReg(PATTERN_IN_LSB_REG, PATTERN_IN_MSB_REG))); // overwrite with only addr bus_w(reg, ((addr << PATTERN_CNTRL_ADDR_OFST) & PATTERN_CNTRL_ADDR_MSK)); @@ -1783,8 +1784,8 @@ int setPatternWaitAddress(int level, int addr) { // error (handled in tcp) if (addr >= (MAX_PATTERN_LENGTH + 1)) { - FILE_LOG(logERROR, ("Cannot set Pattern - Wait Address. Invalid addr %d. " - "Should be within %d\n", addr, MAX_PATTERN_LENGTH + 1)); + FILE_LOG(logERROR, ("Cannot set Pattern - Wait Address. Invalid addr 0x%x. " + "Should be within 0x%x\n", addr, MAX_PATTERN_LENGTH + 1)); return -1; } @@ -1809,20 +1810,20 @@ int setPatternWaitAddress(int level, int addr) { mask = PATTERN_WAIT_2_ADDR_MSK; break; default: - FILE_LOG(logERROR, ("Cannot set Pattern - Wait Address. Invalid level %d. " + FILE_LOG(logERROR, ("Cannot set Pattern - Wait Address. Invalid level 0x%x. " "Should be between 0 and 2.\n", level)); return -1; } // set if (addr >= 0) { - FILE_LOG(logINFO, ("Setting Pattern - Wait Address (level:%d, addr:%d)\n", level, addr)); + FILE_LOG(logINFO, ("Setting Pattern - Wait Address (level:%d, addr:0x%x)\n", level, addr)); bus_w(reg, ((addr << offset) & mask)); } // get uint32_t regval = bus_r((reg & mask) >> offset); - FILE_LOG(logDEBUG1, ("Wait Address (level:%d, addr:%d)\n", level, regval)); + FILE_LOG(logDEBUG1, ("Wait Address (level:%d, addr:0x%x)\n", level, regval)); return regval; } @@ -1866,16 +1867,16 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) { // level 0-2, addr upto patternlength + 1 (checked at tcp) if ((level != -1) && (*startAddr >= 0 || *stopAddr > (MAX_PATTERN_LENGTH + 1))) { - FILE_LOG(logERROR, ("Cannot set Pattern (Pattern Loop, level:%d, startaddr:%d, stopaddr:%d). " - "Addr must be less than %d\n", + FILE_LOG(logERROR, ("Cannot set Pattern (Pattern Loop, level:%d, startaddr:0x%x, stopaddr:0x%x). " + "Addr must be less than 0x%x\n", level, *startAddr, *stopAddr, MAX_PATTERN_LENGTH + 1)); } //level -1, addr upto patternlength (checked at tcp) else if ((level == -1) && (*startAddr >= 0 || *stopAddr > MAX_PATTERN_LENGTH)) { - FILE_LOG(logERROR, ("Cannot set Pattern (Pattern Loop, complete pattern, stopaddr:%d). " - "Addr must be less than %d\n", + FILE_LOG(logERROR, ("Cannot set Pattern (Pattern Loop, complete pattern, stopaddr:0x%x). " + "Addr must be less than 0x%x\n", *startAddr, *stopAddr, MAX_PATTERN_LENGTH)); } @@ -1939,17 +1940,17 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) { // set start and stop addr if (*startAddr == -1) { *startAddr = ((bus_r(addr) >> startOffset) & startMask); - FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop Start Address (level:%d, startAddr:%d was -1)\n", + FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop Start Address (level:%d, startAddr:0x%x was -1)\n", level, *startAddr)); } if (*stopAddr == -1) { *stopAddr = ((bus_r(addr) >> stopOffset) & stopMask); - FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop Stop Address (level:%d, stopAddr:%d, was -1)\n", + FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop Stop Address (level:%d, stopAddr:0x%x, was -1)\n", level, *stopAddr)); } // writing start and stop addr - FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop (level:%d, startaddr:%d, stopaddr:%d)\n", + FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop (level:%d, startaddr:0x%x, stopaddr:0x%x)\n", level, *startAddr, *stopAddr)); bus_w(addr, ((*startAddr << startOffset) & startMask) | ((*stopAddr << stopOffset) & stopMask)); } diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h index 3c44f5b5f..240ba3039 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h @@ -74,6 +74,7 @@ enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, #define POWER_RGLTR_MIN (636) #define POWER_RGLTR_MAX (2638) // min dac val (not vchip-max) because of dac conversions #define VCHIP_POWER_INCRMNT (200) +#define VIO_MIN_MV (1200) // for fpga to function /* Defines in the Firmware */ #define WAIT_TME_US_FR_LK_AT_ME_REG (100) // wait time in us after acquisition done to ensure there is no data in fifo diff --git a/slsDetectorServers/slsDetectorServer/INA226.h b/slsDetectorServers/slsDetectorServer/INA226.h index 71ba30b2e..b7f2769ee 100755 --- a/slsDetectorServers/slsDetectorServer/INA226.h +++ b/slsDetectorServers/slsDetectorServer/INA226.h @@ -1,6 +1,7 @@ #pragma once #include "I2C.h" +#include "math.h" /** * To be defined in @@ -52,6 +53,9 @@ #define INA226_getConvertedCurrentUnits(shuntV, calibReg) ((double)shuntV * (double)calibReg / (double)2048) double INA226_Shunt_Resistor_Ohm = 0.0; +int INA226_Calibration_Register_Value = 0; + +#define INA226_CALIBRATION_CURRENT_TOLERANCE (1.2268) /** @@ -84,7 +88,11 @@ void INA226_CalibrateCurrentRegister(uint32_t deviceId) { FILE_LOG(logINFO, ("Calibrating Current Register for Device ID: 0x%x\n", deviceId)); // get calibration value based on shunt resistor uint16_t calVal = ((uint16_t)INA226_getCalibrationValue(INA226_Shunt_Resistor_Ohm)) & INA226_CALIBRATION_MSK; - FILE_LOG(logINFO, ("\tWriting to Calibration reg: 0x%0x\n", calVal)); + FILE_LOG(logINFO, ("\tCalculated calibration reg value: 0x%0x (%d)\n", calVal, calVal)); + + calVal = ((double)calVal / INA226_CALIBRATION_CURRENT_TOLERANCE) + 0.5; + FILE_LOG(logINFO, ("\tRealculated (for tolerance) calibration reg value: 0x%0x (%d)\n", calVal, calVal)); + INA226_Calibration_Register_Value = calVal; // calibrate current register I2C_Write(deviceId, INA226_CALIBRATION_REG, calVal); @@ -132,71 +140,38 @@ int INA226_ReadCurrent(uint32_t deviceId) { // read shunt voltage register FILE_LOG(logDEBUG1, (" Reading shunt voltage reg\n")); uint32_t shuntVoltageRegVal = I2C_Read(deviceId, INA226_SHUNT_VOLTAGE_REG); - FILE_LOG(logDEBUG1, (" shunt voltage reg: 0x%x\n", shuntVoltageRegVal)); + FILE_LOG(logDEBUG1, (" shunt voltage reg: %d\n", shuntVoltageRegVal)); // read it once more as this error has occured once if (shuntVoltageRegVal == 0xFFFF) { FILE_LOG(logDEBUG1, (" Reading shunt voltage reg again\n")); shuntVoltageRegVal = I2C_Read(deviceId, INA226_SHUNT_VOLTAGE_REG); - FILE_LOG(logDEBUG1, (" shunt voltage reg: 0x%x\n", shuntVoltageRegVal)); + FILE_LOG(logDEBUG1, (" shunt voltage reg: %d\n", shuntVoltageRegVal)); } - - // get absolute value and if negative - int negative = (shuntVoltageRegVal & INA226_SHUNT_NEGATIVE_MSK) ? 1: 0; - int shuntabsnV = shuntVoltageRegVal & INA226_SHUNT_ABS_VALUE_MSK; - FILE_LOG(logDEBUG1, (" negative: %d, absolute: 0x%x\n", negative, shuntabsnV)); - - // negative, convert absolute to 2s complement - if (negative) { - shuntabsnV = ((~shuntabsnV) + 1); - FILE_LOG(logDEBUG1, (" new absolute for negative (2's comple): 0x%x\n", shuntabsnV)); - } - - // calculate shunt voltage - int shuntVoltagenV = 0; - ConvertToDifferentRange(0, INA226_SHUNT_VOLTAGE_MX_STPS, - INA226_SHUNT_VOLTAGE_VMIN_NV, INA226_SHUNT_VOLTAGE_VMAX_NV, - shuntabsnV, &shuntVoltagenV); - // if negative, put the sign - if (negative) - shuntVoltagenV = -(shuntVoltagenV); - FILE_LOG(logDEBUG1, (" shunt voltage: %d nV\n", shuntVoltagenV)); - int shuntVoltageUV = shuntVoltagenV / 1000; - FILE_LOG(logDEBUG1, (" shunt voltage: %d uV\n\n", shuntVoltageUV)); - - // read calibration register - FILE_LOG(logDEBUG1, (" Reading calibration reg\n")); - uint32_t calibrationRegVal = I2C_Read(deviceId, INA226_CALIBRATION_REG); - FILE_LOG(logDEBUG1, (" calibration reg: 0x%08x\n\n", calibrationRegVal)); - - // read it once more as this error has occured once - if (calibrationRegVal == 0xFFFF) { - FILE_LOG(logDEBUG1, (" Reading calibration reg again\n")); - calibrationRegVal = I2C_Read(deviceId, INA226_CALIBRATION_REG); - FILE_LOG(logDEBUG1, (" calibration reg: 0x%x\n", calibrationRegVal)); - } - // value for current - int retval = INA226_getConvertedCurrentUnits(shuntVoltageUV, calibrationRegVal); + int retval = INA226_getConvertedCurrentUnits(shuntVoltageRegVal, INA226_Calibration_Register_Value); FILE_LOG(logDEBUG1, (" current unit value: %d\n", retval)); - FILE_LOG(logDEBUG1, (" To TEST: should be same as curent unit value\n" - " Reading current reg\n")); + + // reading directly the current reg + FILE_LOG(logDEBUG1, (" Reading current reg\n")); int cuurentRegVal = I2C_Read(deviceId, INA226_CURRENT_REG); - FILE_LOG(logDEBUG1, (" current reg: 0x%x\n", cuurentRegVal)); + FILE_LOG(logDEBUG1, (" current reg: %d\n", cuurentRegVal)); // read it once more as this error has occured once if (cuurentRegVal >= 0xFFF0) { FILE_LOG(logDEBUG1, (" Reading current reg again\n")); cuurentRegVal = I2C_Read(deviceId, INA226_CURRENT_REG); - FILE_LOG(logDEBUG1, (" current reg: 0x%x\n", cuurentRegVal)); + FILE_LOG(logDEBUG1, (" current reg: %d\n", cuurentRegVal)); } + // should be the same + FILE_LOG(logDEBUG1, (" ===============current reg: %d, current unit cal:%d=================================\n", cuurentRegVal, retval)); // current in uA - int currentuA = retval * INA226_CURRENT_IMIN_UA; + int currentuA = cuurentRegVal * INA226_CURRENT_IMIN_UA; FILE_LOG(logDEBUG1, (" current: %d uA\n", currentuA)); // current in mA - int currentmA = currentuA / 1000; + int currentmA = (currentuA / 1000.00) + 0.5; FILE_LOG(logDEBUG1, (" current: %d mA\n", currentmA)); FILE_LOG(logINFO, ("Current via I2C (Device: 0x%x): %d mA\n", deviceId, currentmA)); diff --git a/slsDetectorServers/slsDetectorServer/LTC2620.h b/slsDetectorServers/slsDetectorServer/LTC2620.h index 560f6e724..77cd63346 100755 --- a/slsDetectorServers/slsDetectorServer/LTC2620.h +++ b/slsDetectorServers/slsDetectorServer/LTC2620.h @@ -200,12 +200,14 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) { */ void LTC2620_Set(int cmd, int data, int dacaddr, int chipIndex) { FILE_LOG(logDEBUG1, ("cmd:0x%x, data:%d, dacaddr:%d, chipIndex:%d\n", cmd, data, dacaddr, chipIndex)); + FILE_LOG(logDEBUG1, (" ================================================\n")); // ctb if (LTC2620_Ndac > LTC2620_NUMCHANNELS) LTC2620_SetDaisy(cmd, data, dacaddr, chipIndex); // others else LTC2620_SetSingle(cmd, data, dacaddr); + FILE_LOG(logDEBUG1, (" ================================================\n")); } diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h index b432d6433..b6b3985d8 100644 --- a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h @@ -178,7 +178,7 @@ void setVchip(int val); int getVChipToSet(enum DACINDEX ind, int val); int getDACIndexFromADCIndex(enum ADCINDEX ind); int getADCIndexFromDACIndex(enum DACINDEX ind); -int isPowerValid(int val); +int isPowerValid(enum DACINDEX ind, int val); int getPower(); void setPower(enum DACINDEX ind, int val); void powerOff(); diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index b6325ae26..576581ef6 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -800,9 +800,10 @@ int set_dac(int file_des) { ret = FAIL; sprintf(mess,"Could not set power. Power regulator %d exceeds voltage limit %d.\n", ind, getVLimit()); FILE_LOG(logERROR,(mess)); - } else if (!isPowerValid(val)) { + } else if (!isPowerValid(serverDacIndex, val)) { ret = FAIL; - sprintf(mess,"Could not set power. Power regulator %d should be between %d and %d mV\n", ind, POWER_RGLTR_MIN, (VCHIP_MAX_MV - VCHIP_POWER_INCRMNT)); + sprintf(mess,"Could not set power. Power regulator %d should be between %d and %d mV\n", + ind, (serverDacIndex == D_PWR_IO ? VIO_MIN_MV : POWER_RGLTR_MIN), (VCHIP_MAX_MV - VCHIP_POWER_INCRMNT)); FILE_LOG(logERROR,(mess)); } else { setPower(serverDacIndex, val); @@ -1795,7 +1796,7 @@ int set_readout_flags(int file_des) { return printSocketReadError(); FILE_LOG(logDEBUG1, ("Setting readout flags to %d\n", arg)); -#ifndef EIGERD +#if (!defined(EIGERD)) && (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) functionNotImplemented(); #else // set & get @@ -1809,6 +1810,11 @@ int set_readout_flags(int file_des) { case SAFE: case SHOW_OVERFLOW: case NOOVERFLOW: +#if defined(CHIPTESTBOARDD) || defined(MOENCHD) + case NORMAL_READOUT: + case DIGITAL_ONLY: + case ANALOG_AND_DIGITAL: +#endif retval = setReadOutFlags(arg); FILE_LOG(logDEBUG1, ("Read out flags: 0x%x\n", retval)); validate((int)arg, (int)(retval & arg), "set readout flag", HEX); @@ -2524,13 +2530,14 @@ int set_ctb_pattern(int file_des) { #else int addr = (int)args[0]; uint64_t word = args[1]; + FILE_LOG(logDEBUG1, ("addr:0x%x word:0x%llx\n", addr, word)); if ((word == -1) || (Server_VerifyLock() == OK)) { // address for set word should be valid (if not -1 or -2, it goes to setword) if (addr < -2 || addr > MAX_PATTERN_LENGTH) { ret = FAIL; - sprintf(mess, "Cannot set Pattern (Word, addr:%d). Addr must be less than %d\n", + sprintf(mess, "Cannot set Pattern (Word, addr:0x%x). Addr must be less than 0x%x\n", addr, MAX_PATTERN_LENGTH); FILE_LOG(logERROR, (mess)); } else { @@ -2580,6 +2587,7 @@ int set_ctb_pattern(int file_des) { int startAddr = (int)args[1]; int stopAddr = (int)args[2]; int numLoops = (int)args[3]; + FILE_LOG(logDEBUG1, ("loopLevel:%d startAddr:0x%x stopAddr:0x%x numLoops:%d word:0x%llx\n", loopLevel, startAddr, stopAddr, numLoops)); if (loopLevel < -1 || loopLevel > 2) { // -1 complete pattern ret = FAIL; @@ -2590,8 +2598,8 @@ int set_ctb_pattern(int file_des) { // level 0-2, addr upto patternlength + 1 else if ((loopLevel != -1) && (startAddr > (MAX_PATTERN_LENGTH + 1) || stopAddr > (MAX_PATTERN_LENGTH + 1))) { ret = FAIL; - sprintf(mess, "Cannot set Pattern (Pattern Loop, level:%d, startaddr:%d, stopaddr:%d). " - "Addr must be less than %d\n", + sprintf(mess, "Cannot set Pattern (Pattern Loop, level:%d, startaddr:0x%x, stopaddr:0x%x). " + "Addr must be less than 0x%x\n", loopLevel, startAddr, stopAddr, MAX_PATTERN_LENGTH + 1); FILE_LOG(logERROR, (mess)); } @@ -2599,8 +2607,8 @@ int set_ctb_pattern(int file_des) { //level -1, addr upto patternlength else if ((loopLevel == -1) && (startAddr > MAX_PATTERN_LENGTH || stopAddr > MAX_PATTERN_LENGTH)) { ret = FAIL; - sprintf(mess, "Cannot set Pattern (Pattern Loop, complete pattern, startaddr:%d, stopaddr:%d). " - "Addr must be less than %d\n", + sprintf(mess, "Cannot set Pattern (Pattern Loop, complete pattern, startaddr:0x%x, stopaddr:0x%x). " + "Addr must be less than 0x%x\n", startAddr, stopAddr, MAX_PATTERN_LENGTH); FILE_LOG(logERROR, (mess)); } @@ -2618,7 +2626,7 @@ int set_ctb_pattern(int file_des) { // mode 2: wait address - else if (mode == 1) { + else if (mode == 2) { // receive arguments uint64_t args[2] = {-1, -1}; if (receiveData(file_des, args, sizeof(args), INT64) < 0) @@ -2631,15 +2639,16 @@ int set_ctb_pattern(int file_des) { #else int loopLevel = (int)args[0]; int addr = (int)args[1]; + FILE_LOG(logDEBUG1, ("loopLevel:%d addr:0x%x\n", loopLevel, addr)); if ((addr == -1) || (Server_VerifyLock() == OK)) { if (loopLevel < 0 || loopLevel > 2) { ret = FAIL; - sprintf(mess, "Pattern (Wait Address) Level (%d) is not implemented for this detector\n", loopLevel); + sprintf(mess, "Pattern (Wait Address) Level (0x%x) is not implemented for this detector\n", loopLevel); FILE_LOG(logERROR,(mess)); } else if (addr > (MAX_PATTERN_LENGTH + 1)) { ret = FAIL; - sprintf(mess, "Cannot set Pattern (Wait Address, addr:%d). Addr must be less than %d\n", + sprintf(mess, "Cannot set Pattern (Wait Address, addr:0x%x). Addr must be less than 0x%x\n", addr, MAX_PATTERN_LENGTH + 1); FILE_LOG(logERROR, (mess)); } else { @@ -2660,7 +2669,7 @@ int set_ctb_pattern(int file_des) { // mode 3: wait time - else if (mode == 1) { + else if (mode == 3) { // receive arguments uint64_t args[2] = {-1, -1}; if (receiveData(file_des, args, sizeof(args), INT64) < 0) @@ -2671,8 +2680,9 @@ int set_ctb_pattern(int file_des) { functionNotImplemented(); return Server_SendResult(file_des, INT32, UPDATE, NULL, 0); #else - int loopLevel = (int)args[1]; - uint64_t timeval = (int)args[2]; + int loopLevel = (int)args[0]; + uint64_t timeval = args[1]; + FILE_LOG(logDEBUG1, ("loopLevel:%d timeval:0x%lld\n", loopLevel, timeval)); if ((timeval == -1) || (Server_VerifyLock() == OK)) { if (loopLevel < 0 || loopLevel > 2) { @@ -2684,9 +2694,9 @@ int set_ctb_pattern(int file_des) { memset(tempName, 0, 100); sprintf(tempName, "Pattern (Wait Time, Level:%d)", loopLevel); - FILE_LOG(logDEBUG1, ("Setting %s to 0x%llx\n", tempName, (long long int)timeval)); + FILE_LOG(logDEBUG1, ("Setting %s to 0x%lld\n", tempName, (long long int)timeval)); retval64 = setPatternWaitTime(loopLevel, timeval); - FILE_LOG(logDEBUG1, ("%s: 0x%llx\n", tempName, (long long int)retval64)); + FILE_LOG(logDEBUG1, ("%s: 0x%lld\n", tempName, (long long int)retval64)); validate64(timeval, retval64, tempName, HEX); } } @@ -2985,7 +2995,7 @@ int program_fpga(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); -#ifndef JUNGFRAUD +#if (!defined(JUNGFRAUD)) && (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) //to receive any arguments int n = 1; while (n > 0) @@ -3111,7 +3121,7 @@ int reset_fpga(int file_des) { memset(mess, 0, sizeof(mess)); FILE_LOG(logDEBUG1, ("Reset FPGA\n")); -#ifndef JUNGFRAUD +#if (!defined(JUNGFRAUD)) && (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) functionNotImplemented(); #else // only set diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 9fd0bcd03..cbc517ed8 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -4865,7 +4865,7 @@ uint64_t slsDetector::setCTBWord(int addr, uint64_t word) { int mode = 0; // sets word uint64_t args[3] = {(uint64_t)mode, (uint64_t)addr, word}; uint64_t retval = -1; - FILE_LOG(logINFO) << "Setting CTB word, addr: 0x" << std::hex << addr << ", word: 0x" << word << std::dec; + FILE_LOG(logDEBUG1) << "Setting CTB word, addr: 0x" << std::hex << addr << ", word: 0x" << word << std::dec; if (thisDetector->onlineFlag == ONLINE_FLAG) { auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index f37c9bd60..2ae77b080 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -1196,7 +1196,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { ++i; /*! \page settings - - v_io [i] mv Sets/gets value for Vio on the new chiptest board. Must be in mV. It should be the first power regulator to be set after server start up (fpga reset). To change again, reset fpga first. \c Returns \c (int ["mV"]) + - v_io [i] mv Sets/gets value for Vio on the new chiptest board. Must be in mV. It should be minimum 1200 mV and must be the first power regulator to be set after server start up (fpga reset). To change again, reset fpga first. \c Returns \c (int ["mV"]) */ descrToFuncMap[i].m_pFuncName = "v_io"; // descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;