Dev/chip version string (#1525)
Build and Deploy on local RHEL9 / build (push) Successful in 2m6s
Build on RHEL9 docker image / build (push) Successful in 3m46s
Build and Deploy on local RHEL8 / build (push) Successful in 5m9s
Build on RHEL8 docker image / build (push) Successful in 5m14s
Run Simulator Tests on local RHEL9 / build (push) Successful in 20m6s
Run Simulator Tests on local RHEL8 / build (push) Successful in 23m30s

* changed api from double to string return for getchipversion, updated python bindings, added to versions command, fixed appropriately to send string from server, fixed tests accordingly to convert the string to int to do the tests

* binary in

* minor

* fixed tests

* updated help for chipversion
This commit is contained in:
2026-08-17 11:53:00 +02:00
committed by GitHub
parent 473d31c4b3
commit adaeaaa409
20 changed files with 153551 additions and 45 deletions
+9 -2
View File
@@ -2140,6 +2140,8 @@ class Detector(CppDetectorApi):
firmware_febl = "Unknown"
firmware_febr = "Unknown"
firmware_beb = "Unknown"
jungfrau = False
chip = "Unknown"
receiver_in_shm = False
release = self.packageversion
@@ -2149,6 +2151,7 @@ class Detector(CppDetectorApi):
# shared memory has detectors
type = self.type
eiger = (self.type == detectorType.EIGER)
jungfrau = (self.type == detectorType.JUNGFRAU)
receiver_in_shm = self.use_receiver
if receiver_in_shm:
# cannot connect to receiver
@@ -2166,6 +2169,8 @@ class Detector(CppDetectorApi):
firmware_beb = self.firmwareversion
firmware_febl = self.getFrontEndFirmwareVersion(slsDetectorDefs.fpgaPosition.FRONT_LEFT)
firmware_febr = self.getFrontEndFirmwareVersion(slsDetectorDefs.fpgaPosition.FRONT_RIGHT)
if jungfrau:
chip = self.chipversion
except Exception as e:
pass
@@ -2178,6 +2183,8 @@ class Detector(CppDetectorApi):
version_list ['firmware (Febr)'] = {firmware_febr}
else:
version_list ['firmware'] = {firmware}
if jungfrau:
version_list ['chip'] = {chip}
version_list ['detectorserver'] = {detectorserver}
version_list ['kernel'] = kernel
version_list ['hardware'] = hardware
@@ -2738,12 +2745,12 @@ class Detector(CppDetectorApi):
@element
def chipversion(self):
"""
[Jungfrau] Chip version of module. Can be 1.0, 1.1 or 1.2.
[Jungfrau] Chip version of module.
Example
-------
>>> d.chipversion
'1.0'
'1.2 Normal'
"""
return self.getChipVersion()
+5 -4
View File
@@ -1197,10 +1197,11 @@ void init_det(py::module &m) {
CppDetectorApi.def(
"setTop", (void (Detector::*)(bool, sls::Positions)) & Detector::setTop,
py::arg(), py::arg() = Positions{});
CppDetectorApi.def("getChipVersion",
(Result<double>(Detector::*)(sls::Positions) const) &
Detector::getChipVersion,
py::arg() = Positions{});
CppDetectorApi.def(
"getChipVersion",
(Result<std::string>(Detector::*)(sls::Positions) const) &
Detector::getChipVersion,
py::arg() = Positions{});
CppDetectorApi.def("getThresholdTemperature",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getThresholdTemperature,
@@ -131,12 +131,17 @@ void basictests() {
if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getFirmwareAPIVersion();
char chipVersion[MAX_STR_LENGTH] = {0};
memset(chipVersion, 0, MAX_STR_LENGTH);
getChipVersionInFPGA(chipVersion, initErrorMessage);
LOG(logINFOBLUE,
("************ Jungfrau Server *********************\n"
"Hardware Version:\t\t %s\n"
"Hardware Serial Nr:\t\t 0x%x\n"
"Chip Version:\t\t\t %s\n"
"Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%llx\n\n"
@@ -145,7 +150,7 @@ void basictests() {
"F/w-S/w API Version:\t\t 0x%llx\n"
"Required Firmware Version:\t 0x%x\n"
"********************************************************\n",
hversion, hsnumber, ipadd, (long long unsigned int)macadd,
hversion, hsnumber, chipVersion, ipadd, (long long unsigned int)macadd,
(long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
requiredFirmwareVersion));
@@ -329,20 +334,24 @@ int isHardwareVersion_1_0() {
return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
}
int getChipVersionInFPGA() {
const int vals[] = CHIP_VALS;
int getChipVersionInFPGA(char *version, char *mess) {
char *chip_names[] = {CHIP_NAMES};
int val = ((bus_r(DAQ_REG) & DAQ_CHIP_VRSN_MSK) >> DAQ_CHIP_VRSN_OFST);
switch (val) {
case 0:
return vals[(int)v1_0];
strcpy(version, chip_names[(int)v1_0]);
return OK;
case 1:
return vals[(int)v1_1];
strcpy(version, chip_names[(int)v1_1]);
return OK;
case 2:
return vals[(int)v1_2_NORMAL] / 10;
strcpy(version, chip_names[(int)v1_2_NORMAL]);
return OK;
default:
LOG(logERROR,
("Read undefined value as chip version from FPGA: %d\n", val));
return -1;
sprintf(mess, "Read undefined value as chip version from FPGA: %d\n",
val);
LOG(logERROR, (mess));
return FAIL;
}
}
@@ -57,7 +57,7 @@ void getHardwareVersion(char *version);
u_int16_t getHardwareVersionNumber();
u_int16_t getHardwareSerialNumber();
int isHardwareVersion_1_0();
int getChipVersionInFPGA();
int getChipVersionInFPGA(char *retvals, char *mess);
int findChipIndex(enum CHIPINDEX *ind, char *cval, char *mess);
int setChipVersionIntFromConfigFile(int val,
char *mess); // for backward compatibility
@@ -8700,14 +8700,15 @@ int set_veto_algorithm(int file_des) {
int get_chip_version(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
char retvals[MAX_STR_LENGTH];
memset(retvals, 0, MAX_STR_LENGTH);
#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
retval = getChipVersionInFPGA();
ret = getChipVersionInFPGA(retvals, mess);
#endif
LOG(logDEBUG1, ("chip version retval: %d\n", retval));
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
LOG(logDEBUG1, ("chip version retval: %s\n", retvals));
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
}
int get_default_dac(int file_des) {
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1969,7 +1969,7 @@ rx_threads:
chipversion:
inherit_actions: GET_COMMAND
help: "\n\t[Jungfrau] Returns chip version. Can be 1.0, 1.1 or 1.2"
help: "\n\t[Jungfrau] Returns chip version as string. For example, 'v1.1' or 'v1.2 Low Noise'"
actions:
GET:
function: getChipVersion
@@ -1117,7 +1117,8 @@ chipversion:
store_result_in_t: true
command_name: chipversion
function_alias: chipversion
help: "\n\t[Jungfrau] Returns chip version. Can be 1.0 or 1.1"
help: "\n\t[Jungfrau] Returns chip version as string. For example, 'v1.1' or 'v1.2\
\ Low Noise'"
infer_action: true
template: true
clearbit:
+1 -1
View File
@@ -1301,7 +1301,7 @@ class Detector {
* ************************************************/
/** [Jungfrau] */
Result<double> getChipVersion(Positions pos = {}) const;
Result<std::string> getChipVersion(Positions pos = {}) const;
/** [Jungfrau][Moench] */
Result<int> getThresholdTemperature(Positions pos = {}) const;
+1 -1
View File
@@ -1427,7 +1427,7 @@ std::string Caller::chipversion(int action) {
// print help
if (action == slsDetectorDefs::HELP_ACTION) {
os << R"V0G0N(
[Jungfrau] Returns chip version. Can be 1.0 or 1.1 )V0G0N"
[Jungfrau] Returns chip version as string. For example, 'v1.1' or 'v1.2 Low Noise' )V0G0N"
<< std::endl;
return os.str();
}
+10
View File
@@ -313,6 +313,8 @@ std::string Caller::versions(int action) {
std::string vBebFirmware = "Unknown";
std::string vFeblFirmware = "Unknown";
std::string vFebrFirmware = "Unknown";
bool jungfrau = false;
std::string vChipVersion = "Unknown";
bool receiver = false;
std::string vReceiver = "Unknown";
@@ -323,6 +325,7 @@ std::string Caller::versions(int action) {
// shared memory has detectors
vType = OutString(det->getDetectorType());
eiger = (det->getDetectorType().squash() == defs::EIGER);
jungfrau = (det->getDetectorType().squash() == defs::JUNGFRAU);
receiver = det->getUseReceiverFlag().squash(false);
if (receiver) {
// cannot connect to receiver
@@ -350,6 +353,10 @@ std::string Caller::versions(int action) {
vFebrFirmware = OutString(det->getFrontEndFirmwareVersion(
defs::FRONT_RIGHT, std::vector<int>{det_id}));
}
if (jungfrau) {
vChipVersion = OutString(
det->getChipVersion(std::vector<int>{det_id}));
}
} catch (const std::exception &e) {
}
}
@@ -364,6 +371,9 @@ std::string Caller::versions(int action) {
} else {
os << "\nFirmware : " << vFirmware;
}
if (jungfrau) {
os << "\nChip : " << vChipVersion;
}
os << "\nServer : " << vServer
<< "\nKernel : " << vKernel
<< "\nHardware : " << vHardware;
+1 -1
View File
@@ -1793,7 +1793,7 @@ void Detector::setTop(bool value, Positions pos) {
}
// Jungfrau/moench Specific
Result<double> Detector::getChipVersion(Positions pos) const {
Result<std::string> Detector::getChipVersion(Positions pos) const {
return pimpl->Parallel(&Module::getChipVersion, pos);
}
+4 -2
View File
@@ -1851,8 +1851,10 @@ void Module::setTop(bool value) {
}
// Jungfrau/Moench Specific
double Module::getChipVersion() const {
return (sendToDetector<int>(F_GET_CHIP_VERSION)) / 10.00;
std::string Module::getChipVersion() const {
char retval[MAX_STR_LENGTH]{};
sendToDetector(F_GET_CHIP_VERSION, nullptr, retval);
return retval;
}
int Module::getThresholdTemperature() const {
+1 -1
View File
@@ -401,7 +401,7 @@ class Module : public virtual slsDetectorDefs {
* Jungfrau/Moench Specific *
* *
* ************************************************/
double getChipVersion() const;
std::string getChipVersion() const;
int getThresholdTemperature() const;
void setThresholdTemperature(int val);
bool getTemperatureControl() const;
@@ -8,8 +8,18 @@
#include "tests/globals.h"
#include "catch.hpp"
#include <regex>
namespace sls {
int chipVersionToX10(const std::string &chipVersion) {
static const std::regex versionRegex(R"(v?\s*([0-9]+)\.([0-9]+))",
std::regex::icase);
std::smatch match;
if (!std::regex_search(chipVersion, match, versionRegex)) {
throw sls::RuntimeError("Could not parse chip version: " + chipVersion);
}
return std::stoi(match[1].str()) * 10 + std::stoi(match[2].str());
}
namespace acq = sls::test::acquire;
@@ -8,10 +8,13 @@
#include <chrono>
#include <filesystem>
#include <optional>
#include <string>
#include <thread>
namespace sls {
int chipVersionToX10(const std::string &chipVersion);
namespace acq = sls::test::acquire;
namespace mf = sls::test::master_file;
namespace checks = sls::test::checks;
@@ -285,7 +285,7 @@ TEST_CASE("extrastoragecells", "[.detectorintegration]") {
Caller caller(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
auto chipVersion = det.getChipVersion().squash() * 10;
auto chipVersion = chipVersionToX10(det.getChipVersion().squash());
// chip version 1.0 and 1.2
if (chipVersion == 10 || chipVersion == 12) {
auto prev_val = det.getNumberOfAdditionalStorageCells().tsquash(
@@ -335,8 +335,9 @@ TEST_CASE("storagecell_start", "[.detectorintegration]") {
caller.call("storagecell_start", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecell_start 1\n");
}
// chip version 1.0
if (det.getChipVersion().squash() * 10 == 10) {
auto chipVersion = chipVersionToX10(det.getChipVersion().squash());
// chip version 1.0 and chip version 1.2
if (chipVersion == 10 || chipVersion == 12) {
std::ostringstream oss;
caller.call("storagecell_start", {"15"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecell_start 15\n");
@@ -375,7 +376,7 @@ TEST_CASE("storagecell_delay", "[.detectorintegration]") {
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
// chip version 1.0 and 1.2
auto chipVersion = det.getChipVersion().squash() * 10;
auto chipVersion = chipVersionToX10(det.getChipVersion().squash());
if (chipVersion == 10 || chipVersion == 12) {
auto prev_val = det.getStorageCellDelay();
{
@@ -466,7 +467,7 @@ TEST_CASE("filtercells", "[.detectorintegration]") {
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
// chip version 1.1
if (det.getChipVersion().squash() * 10 == 11) {
if (chipVersionToX10(det.getChipVersion().squash()) == 11) {
auto prev_val = det.getNumberOfFilterCells();
{
std::ostringstream oss;
@@ -1121,13 +1121,16 @@ TEST_CASE("readoutspeed", "[.detectorintegration]") {
det_type == defs::MOENCH || det_type == defs::GOTTHARD2 ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getReadoutSpeed();
bool fullSpeedSupportedJungfrauBoards = false;
if (det_type == defs::JUNGFRAU) {
auto chipVersion = chipVersionToX10(det.getChipVersion().squash());
fullSpeedSupportedJungfrauBoards = (chipVersion >= 11);
}
// full speed for jungfrau/moench only works for new boards (chipv1.1 is
// with new board [hw1.0 and chipv1.0 not tested here])
if (((det_type == defs::JUNGFRAU) &&
det.getChipVersion().squash() * 10 == 11) ||
det_type == defs::EIGER || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
// full speed for jungfrau/moench only works for new boards [hw1.0 and
// chipv1.0 not tested here]
if (fullSpeedSupportedJungfrauBoards || det_type == defs::EIGER ||
det_type == defs::MOENCH || det_type == defs::MYTHEN3) {
std::ostringstream oss1, oss2, oss3, oss4;
caller.call("readoutspeed", {"0"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "readoutspeed full_speed\n");
@@ -1693,10 +1696,9 @@ TEST_CASE("filterresistor", "[.detectorintegration]") {
Caller caller(&det);
auto det_type = det.getDetectorType().squash();
// only for chipv1.1
bool hasFeature = false;
if (det_type == defs::JUNGFRAU) {
auto chipVersion = det.getChipVersion().squash() * 10;
auto chipVersion = chipVersionToX10(det.getChipVersion().squash());
hasFeature = (chipVersion == 11 || chipVersion == 12);
}
@@ -1867,9 +1869,8 @@ TEST_CASE("currentsource", "[.detectorintegration]") {
else {
int chipVersion = 10;
if (det_type == defs::JUNGFRAU) {
chipVersion = det.getChipVersion().tsquash(
"inconsistent chip versions to test") *
10;
chipVersion = chipVersionToX10(det.getChipVersion().tsquash(
"inconsistent chip versions to test"));
}
if (chipVersion == 10) {
REQUIRE_THROWS(caller.call("currentsource", {"1"}, -1, PUT));
@@ -1910,7 +1911,7 @@ TEST_CASE("currentsource", "[.detectorintegration]") {
"currentsource [enabled, nofix, 63]\n");
}
}
// chipv1.1 abd chip v1.2
// chipv1.1 and chip v1.2
else {
REQUIRE_THROWS(caller.call("currentsource", {"1"}, -1, PUT));
REQUIRE_THROWS(