diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index f6da7ad81..c4389e6ff 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 65ffa1a32..b743f10a7 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -1074,17 +1074,18 @@ int setInjectChannel(int offset, int increment) { int startCh = 4; // 4 due to padding int ich = 0; for (ich = startCh + offset; ich < startCh + NCHAN; ich = ich + increment) { - buffer[ich] = 1; + int byteIndex = ich / 8; + int bitIndex = ich % 8; + buffer[byteIndex] |= (1 << (8 - 1 - bitIndex)); } - for (ich = 0; ich < sizeof(buffer); ++ich) { - printf("%d : 0x%02hhx\n", ich, buffer[ich]); - } + // address at the end + buffer[16] |= (ASIC_CURRENT_INJECT_ADDR); - //int chipIndex = -1; // for all chips - //if (ASIC_Driver_Set(chipIndex, sizeof(buffer), buffer) == FAIL) { - // return FAIL; - //} + int chipIndex = -1; // for all chips + if (ASIC_Driver_Set(chipIndex, sizeof(buffer), buffer) == FAIL) { + return FAIL; + } injectedChannelsOffset = offset; injectedChannelsIncrement = increment; diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h index 5431a3d2b..256e9a226 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h @@ -78,6 +78,11 @@ enum CLKINDEX {READOUT_C0, READOUT_C1, SYSTEM_C0, SYSTEM_C enum PLLINDEX {READOUT_PLL, SYSTEM_PLL}; + +/** Chip Definitions */ +#define ASIC_CURRENT_INJECT_ADDR (0x9) + + /* Struct Definitions */ typedef struct udp_header_struct { uint32_t udp_destmac_msb; diff --git a/slsDetectorServers/slsDetectorServer/src/ASIC_Driver.c b/slsDetectorServers/slsDetectorServer/src/ASIC_Driver.c index 39af05e55..b8494e3be 100755 --- a/slsDetectorServers/slsDetectorServer/src/ASIC_Driver.c +++ b/slsDetectorServers/slsDetectorServer/src/ASIC_Driver.c @@ -30,22 +30,12 @@ int ASIC_Driver_Set (int index, int length, char* buffer) { sprintf(fname, "%s%d", ASIC_Driver_DriverFileName, index + 1); FILE_LOG(logDEBUG1, ("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname)); { - char printbuffer[2 * length + 15]; - memset(printbuffer, 0, 2 * length); - strcpy(printbuffer, "\t[values: "); + FILE_LOG(logDEBUG1, ("\t[values: \n")); int i; for (i = 0; i < length; ++i) { - char bytes[10]=""; - sprintf(bytes, "0x%02hhx", buffer[i]); - strcat(printbuffer, bytes); - if (i < length - 1) { - strcat(printbuffer, "\t"); - } + FILE_LOG(logDEBUG1, ("\t%d: 0x%02hhx\n", i, buffer[i])); } - int len = strlen(printbuffer); - printbuffer[len - 1] = ']'; - printbuffer[len] = '\0'; - FILE_LOG(logDEBUG1, ("%s\n", printbuffer)); + FILE_LOG(logDEBUG1, ("\t]\n")); } int fd=open(fname, O_RDWR); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index acdda0e2d..dcde8320a 100755 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -6177,7 +6177,7 @@ int set_inject_channel(int file_des) { ret = setInjectChannel(offset, increment); if (ret == FAIL) { ret = FAIL; - sprintf(mess, "Could not inject channel\n", offset, increment); + strcpy(mess, "Could not inject channel\n"); FILE_LOG(logERROR, (mess)); } } diff --git a/slsDetectorSoftware/include/CmdProxy.h b/slsDetectorSoftware/include/CmdProxy.h index 60ebb3708..9eaac65f1 100644 --- a/slsDetectorSoftware/include/CmdProxy.h +++ b/slsDetectorSoftware/include/CmdProxy.h @@ -925,6 +925,7 @@ class CmdProxy { std::string ROI(int action); std::string ClearROI(int action); /* Gotthard2 Specific */ + std::string InjectChannel(int action); /* CTB Specific */ std::string Samples(int action); std::string Dbitphase(int action); diff --git a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp index 0ea597571..ac50f4123 100644 --- a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp +++ b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp @@ -9,6 +9,26 @@ auto GET = slsDetectorDefs::GET_ACTION; auto PUT = slsDetectorDefs::PUT_ACTION; +TEST_CASE("inj_ch", "[.cmd][.gotthard2]") { + if (test::type == slsDetectorDefs::GOTTHARD2) { + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("inj_ch 0 1", PUT, nullptr, oss)); + REQUIRE(oss.str() == "inj_ch [0, 1]\n"); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("inj_ch", GET, nullptr, oss)); + REQUIRE(oss.str() == "inj_ch [0, 1]\n"); + } + REQUIRE_THROWS(multiSlsDetectorClient("inj_ch -1 1", PUT)); + REQUIRE_THROWS(multiSlsDetectorClient("inj_ch 0 1", PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("inj_ch", GET)); + } +} + + TEST_CASE("vchip", "[.cmd]") { int prev_val = 0;