diff --git a/evalVersionVariables.sh b/evalVersionVariables.sh deleted file mode 100755 index 6cd4d8b8f..000000000 --- a/evalVersionVariables.sh +++ /dev/null @@ -1,24 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -GITREPO1='git remote -v' -GITREPO2=" | grep \"fetch\" | cut -d' ' -f1" -BRANCH1='git branch -v' -BRANCH2=" | grep '*' | cut -d' ' -f2" -REPUID1='git log --pretty=format:"%H" -1' -AUTH1_1='git log --pretty=format:"%cn" -1' -AUTH1_2=" | cut -d' ' -f1" -AUTH2_1='git log --pretty=format:"%cn" -1' -AUTH2_2=" | cut -d' ' -f2" -FOLDERREV1='git log --oneline . ' #used for all the individual server folders -FOLDERREV2=" | wc -l" #used for all the individual server folders -REV1='git log --oneline ' -REV2=" | wc -l" - -GITREPO=`eval $GITREPO1 $GITREPO2` -BRANCH=`eval $BRANCH1 $BRANCH2` -REPUID=`eval $REPUID1` -AUTH1=`eval $AUTH1_1 $AUTH1_2` -AUTH2=`eval $AUTH2_1 $AUTH2_2` -REV=`eval $REV1 $REV2` -FOLDERREV=`eval $FOLDERREV1 $FOLDERREV2` - diff --git a/genVersionHeader.sh b/genVersionHeader.sh deleted file mode 100755 index 5b1ee9076..000000000 --- a/genVersionHeader.sh +++ /dev/null @@ -1,27 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -#####! /bin/awk -f - - -if [ $# -lt 3 ] -then - echo "wrong usage" - exit -1 -fi - - -fin=$1 -ftmp=$2 -fout=$3 - - -#dat=echo "date '+%Y%m%d'" - -echo "Updating $fout" -#echo "in: $fin tmp: $ftmp out: $fout" - -#awk 'NR==FNR {if ($3=="Date:") {l[FNR]=$4; gsub("-","",l[FNR]);} else { if (match($0,"Rev")) {l[FNR]=$(NF);} else {l[FNR]="\""$(NF)"\"";};};next} {$0=$1" "$2" "l[FNR]}1' $fin $ftmp > $fout - -awk 'BEGIN {l[0]=0; "date +%Y%m%d" | getline l[1]; l[2]="\"/\""; l[3]="\"nobody\""; l[3]="\"nobody\""; l[4]="\"0000-0000-0000\"";} \ -NR==FNR {if (match($0,"Rev")) {l[0]="0x"$(NF);} else if (match($0,"Date")) {l[1]="0x"$4; gsub("-","",l[1]);} else if (match($0,"URL")) {l[2]="\""$(NF)"\"";} else if (match($0,"Author")) {l[3]="\""$(NF)"\"";} else if (match($0,"UUID")) {l[4]="\""$(NF)"\"";} else if (match($0,"Branch")) {l[5]="\""$(NF)"\"";};next;} -{if (match($2,"REV")) {$0=$1" "$2" "l[0];} else if (match($2,"DATE")) {$0=$1" "$2" "l[1];} else if (match($2,"URL")) {$0=$1" "$2" "l[2];} else if (match($2,"AUTH")) {$0=$1" "$2" "l[3];} else if (match($2,"UUID")) {$0=$1" "$2" "l[4];} else if (match($2,"BRANCH")) {$0=$1" "$2" "l[5];}}1' $fin $ftmp > $fout diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index de158f54e..b14f582c8 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -225,9 +225,9 @@ class Detector(CppDetectorApi): Example ------- >>> d.detectorserverversion - '0x200910' + '7.0.0' """ - return ut.lhex(self.getDetectorServerVersion()) + return self.getDetectorServerVersion() @property @element @@ -249,15 +249,15 @@ class Detector(CppDetectorApi): Example ------- >>> d.clientversion - '0x200810' + '7.0.1' """ - return hex(self.getClientVersion()) + return self.getClientVersion() @property @element def rx_version(self): - """Receiver version in format [0xYYMMDD].""" - return ut.lhex(self.getReceiverVersion()) + """Receiver version """ + return self.getReceiverVersion() @property @element diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 380e7129e..8b1e1e0b2 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -55,16 +55,17 @@ void init_det(py::module &m) { (int (Detector::*)() const) & Detector::getShmId); CppDetectorApi.def("getPackageVersion", (std::string(Detector::*)() const) & Detector::getPackageVersion); - CppDetectorApi.def("getClientVersion", (int64_t(Detector::*)() const) & + CppDetectorApi.def("getClientVersion", (std::string(Detector::*)() const) & Detector::getClientVersion); CppDetectorApi.def("getFirmwareVersion", (Result(Detector::*)(sls::Positions) const) & Detector::getFirmwareVersion, py::arg() = Positions{}); - CppDetectorApi.def("getDetectorServerVersion", - (Result(Detector::*)(sls::Positions) const) & - Detector::getDetectorServerVersion, - py::arg() = Positions{}); + CppDetectorApi.def( + "getDetectorServerVersion", + (Result(Detector::*)(sls::Positions) const) & + Detector::getDetectorServerVersion, + py::arg() = Positions{}); CppDetectorApi.def( "getKernelVersion", (Result(Detector::*)(sls::Positions) const) & @@ -78,10 +79,11 @@ void init_det(py::module &m) { (Result(Detector::*)(sls::Positions) const) & Detector::getModuleId, py::arg() = Positions{}); - CppDetectorApi.def("getReceiverVersion", - (Result(Detector::*)(sls::Positions) const) & - Detector::getReceiverVersion, - py::arg() = Positions{}); + CppDetectorApi.def( + "getReceiverVersion", + (Result(Detector::*)(sls::Positions) const) & + Detector::getReceiverVersion, + py::arg() = Positions{}); CppDetectorApi.def( "getDetectorType", (Result(Detector::*)(sls::Positions) const) & @@ -202,6 +204,16 @@ void init_det(py::module &m) { CppDetectorApi.def( "setSynchronization", (void (Detector::*)(bool)) & Detector::setSynchronization, py::arg()); + CppDetectorApi.def( + "getBadChannels", + (void (Detector::*)(const std::string &, sls::Positions) const) & + Detector::getBadChannels, + py::arg(), py::arg() = Positions{}); + CppDetectorApi.def( + "setBadChannels", + (void (Detector::*)(const std::string &, sls::Positions)) & + Detector::setBadChannels, + py::arg(), py::arg() = Positions{}); CppDetectorApi.def("isVirtualDetectorServer", (Result(Detector::*)(sls::Positions) const) & Detector::isVirtualDetectorServer, @@ -1340,16 +1352,6 @@ void init_det(py::module &m) { (void (Detector::*)(const int, const int, const int, sls::Positions)) & Detector::setADCConfiguration, py::arg(), py::arg(), py::arg(), py::arg() = Positions{}); - CppDetectorApi.def( - "getBadChannels", - (void (Detector::*)(const std::string &, sls::Positions) const) & - Detector::getBadChannels, - py::arg(), py::arg() = Positions{}); - CppDetectorApi.def( - "setBadChannels", - (void (Detector::*)(const std::string &, sls::Positions)) & - Detector::setBadChannels, - py::arg(), py::arg() = Positions{}); CppDetectorApi.def("getCounterMask", (Result(Detector::*)(sls::Positions) const) & Detector::getCounterMask, @@ -1493,6 +1495,14 @@ void init_det(py::module &m) { (void (Detector::*)(defs::dacIndex, int, sls::Positions)) & Detector::setVoltage, py::arg(), py::arg(), py::arg() = Positions{}); + CppDetectorApi.def("getADCVpp", + (Result(Detector::*)(bool, sls::Positions) const) & + Detector::getADCVpp, + py::arg() = false, py::arg() = Positions{}); + CppDetectorApi.def("setADCVpp", + (void (Detector::*)(int, bool, sls::Positions)) & + Detector::setADCVpp, + py::arg(), py::arg() = false, py::arg() = Positions{}); CppDetectorApi.def("getADCEnableMask", (Result(Detector::*)(sls::Positions) const) & Detector::getADCEnableMask, diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index b0f553d2d..2eaa8ae4f 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -21,16 +21,25 @@ #include #include +#include "sls/Version.h" #include #include #include +std::string getClientVersion() { + try { + sls::Version v(APILIB); + return v.concise(); + } catch (...) { + return std::string("unknown"); + } +} + int main(int argc, char **argv) { // options std::string fname; bool isDeveloper = false; - int64_t tempval = 0; int multiId = 0; // parse command line for config @@ -72,9 +81,7 @@ int main(int argc, char **argv) { break; case 'v': - tempval = APIGUI; - LOG(sls::logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x" - << std::hex << tempval << ")"; + LOG(sls::logINFO) << "SLS Detector GUI " << getClientVersion(); return 0; case 'h': @@ -463,10 +470,9 @@ void qDetectorMain::ExecuteHelp(QAction *action) { LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, " "Gotthard, Gotthard2 and Moench detectors"; - std::string guiVersion = ToStringHex(APIGUI); std::string clientVersion = "unknown"; try { - clientVersion = ToStringHex(det->getClientVersion()); + clientVersion = det->getClientVersion(); } CATCH_DISPLAY("Could not get client version.", "qDetectorMain::ExecuteHelp") @@ -475,9 +481,8 @@ void qDetectorMain::ExecuteHelp(QAction *action) { qDefs::INFORMATION, "

" - "SLS Detector GUI version:   " + - guiVersion + - "
SLS Detector Client version: " + clientVersion + + "SLS Detector Client version: " + + clientVersion + "

" "Common GUI to control the SLS Detectors: " diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index b906bdfe6..c9e1c3441 100644 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -184,10 +184,8 @@ void qTabDebugging::SetParameters(QTreeWidgetItem *item) { std::to_string((unsigned long)det->getFirmwareVersion( {comboDetector->currentIndex()})[0]); lblDetectorFirmware->setText(QString(retval.c_str())); - retval = - std::string("0x") + - std::to_string((unsigned long)det->getDetectorServerVersion( - {comboDetector->currentIndex()})[0]); + retval = det->getDetectorServerVersion( + {comboDetector->currentIndex()})[0]; lblDetectorSoftware->setText(QString(retval.c_str())); } CATCH_DISPLAY("Could not get versions.", "qTabDebugging::SetParameters") diff --git a/slsDetectorServers/compileAllServers.sh b/slsDetectorServers/compileAllServers.sh index 3158da364..c79f4dc5b 100644 --- a/slsDetectorServers/compileAllServers.sh +++ b/slsDetectorServers/compileAllServers.sh @@ -1,43 +1,84 @@ # SPDX-License-Identifier: LGPL-3.0-or-other # Copyright (C) 2021 Contributors to the SLS Detector Package + +# empty branch = developer branch in updateAPIVersion.sh +branch="" +det_list=("ctbDetectorServer" + "gotthardDetectorServer" + "gotthard2DetectorServer" + "jungfrauDetectorServer" + "mythen3DetectorServer" + "moenchDetectorServer" + ) +usage="\nUsage: compileAllServers.sh [server|all(opt)] [branch(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tNo 'branch' input means 'developer branch'" + +# arguments if [ $# -eq 0 ]; then - declare -a det=("ctbDetectorServer" - "gotthardDetectorServer" - "gotthard2DetectorServer" - "jungfrauDetectorServer" - "mythen3DetectorServer" - "moenchDetectorServer" - ) + # no argument, all servers + declare -a det=${det_list[@]} + echo "Compiling all servers" +elif [ $# -eq 1 ] || [ $# -eq 2 ]; then + # 'all' servers + if [[ $1 == "all" ]]; then + declare -a det=${det_list[@]} + echo "Compiling all servers" + else + # only one server + # arg not in list + if [[ $det_list != *$1* ]]; then + echo -e "Invalid argument 1: $1. $usage" + return -1 + fi + declare -a det=("${1}") + #echo "Compiling only $1" + fi + # branch + if [ $# -eq 2 ]; then + # arg in list + if [[ $det_list == *$2* ]]; then + echo -e "Invalid argument 2: $2. $usage" + return -1 + fi + branch+=$2 + #echo "with branch $branch" + fi else - declare -a det=("${1}") + echo -e "Too many arguments.$usage" + return -1 fi declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK") -for ((i=0;i<${#det[@]};++i)) +echo -e "list is ${det[@]}" + +# compile each server +idet=0 +for i in ${det[@]} do - dir=${det[i]} - file="${det[i]}_developer" + dir=$i + file="${i}_developer" echo -e "Compiling $dir [$file]" cd $dir make clean - if make version; then - deterror[i]="OK" + if make version API_BRANCH=$branch; then + deterror[$idet]="OK" else - deterror[i]="FAIL" + deterror[$idet]="FAIL" fi - mv bin/$dir bin/$file git add -f bin/$file cp bin/$file /tftpboot/ cd .. echo -e "\n\n" + ((++idet)) done echo -e "Results:" -for ((i=0;i<${#det[@]};++i)) +idet=0 +for i in ${det[@]} do - printf "%s\t\t= %s\n" "${det[i]}" "${deterror[i]}" + printf "%s\t\t= %s\n" "$i" "${deterror[$idet]}" + ((++idet)) done diff --git a/slsDetectorServers/compileEigerServer.sh b/slsDetectorServers/compileEigerServer.sh index 94e3343ca..35aff3f80 100644 --- a/slsDetectorServers/compileEigerServer.sh +++ b/slsDetectorServers/compileEigerServer.sh @@ -1,32 +1,32 @@ # SPDX-License-Identifier: LGPL-3.0-or-other # Copyright (C) 2021 Contributors to the SLS Detector Package -declare -a det=("eigerDetectorServer") +deterror="OK" +dir="eigerDetectorServer" +file="${dir}_developer" +branch="" -declare -a deterror=("OK" "OK" "OK" "OK") +# arguments +if [ $# -eq 1 ]; then + branch+=$1 + #echo "with branch $branch" +elif [ ! $# -eq 0 ]; then + echo -e "Only one optional argument allowed for branch." + return -1 +fi -for ((i=0;i<${#det[@]};++i)) -do - dir=${det[i]} - file="${det[i]}_developer" - echo -e "Compiling $dir [$file]" - cd $dir - make clean - if make version; then - deterror[i]="OK" - else - deterror[i]="FAIL" - fi - - mv bin/$dir bin/$file - git add -f bin/$file - cp bin/$file /tftpboot/ - cd .. - echo -e "\n\n" -done - -echo -e "Results:" -for ((i=0;i<${#det[@]};++i)) -do - printf "%s\t\t= %s\n" "${det[i]}" "${deterror[i]}" -done +echo -e "Compiling $dir [$file]" +cd $dir +make clean +if make version API_BRANCH=$branch; then + deterror="OK" +else + deterror="FAIL" +fi + +mv bin/$dir bin/$file +git add -f bin/$file +cp bin/$file /tftpboot/ +cd .. +echo -e "\n\n" +printf "Result:\t\t= %s\n" "${deterror}" diff --git a/slsDetectorServers/ctbDetectorServer/Makefile b/slsDetectorServers/ctbDetectorServer/Makefile index 0d9229472..67039b768 100755 --- a/slsDetectorServers/ctbDetectorServer/Makefile +++ b/slsDetectorServers/ctbDetectorServer/Makefile @@ -25,10 +25,11 @@ version: clean versioning $(PROGS) boot: $(OBJS) +version_branch=$(API_BRANCH) version_name=APICTB version_path=slsDetectorServers/ctbDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 7128c4e50..f41604498 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index 84c63a4a4..84d904f45 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -121,9 +121,10 @@ void basictests() { uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); int64_t fwversion = getFirmwareVersion(); - int64_t swversion = getServerVersion(); + char swversion[MAX_STR_LENGTH] = {0}; + memset(swversion, 0, MAX_STR_LENGTH); + getServerVersion(swversion); int64_t sw_fw_apiversion = 0; - int64_t client_sw_apiversion = getClientServerAPIVersion(); if (fwversion >= MIN_REQRD_VRSN_T_RD_API) sw_fw_apiversion = getFirmwareAPIVersion(); @@ -136,15 +137,13 @@ void basictests() { "Detector MAC Addr:\t\t 0x%llx\n\n" "Firmware Version:\t\t 0x%llx\n" - "Software Version:\t\t 0x%llx\n" + "Software Version:\t\t %s\n" "F/w-S/w API Version:\t\t 0x%llx\n" "Required Firmware Version:\t 0x%x\n" - "Client-Software API Version:\t 0x%llx\n" "********************************************************\n", hversion, hsnumber, ipadd, (long long unsigned int)macadd, - (long long int)fwversion, (long long int)swversion, - (long long int)sw_fw_apiversion, REQRD_FRMWR_VRSN, - (long long int)client_sw_apiversion)); + (long long int)fwversion, swversion, (long long int)sw_fw_apiversion, + REQRD_FRMWR_VRSN)); #ifndef VIRTUAL // return if flag is not zero, debug mode @@ -325,9 +324,7 @@ int testBus() { /* Ids */ -uint64_t getServerVersion() { return APICTB; } - -uint64_t getClientServerAPIVersion() { return APICTB; } +void getServerVersion(char *version) { strcpy(version, APICTB); } uint64_t getFirmwareVersion() { #ifdef VIRTUAL diff --git a/slsDetectorServers/eigerDetectorServer/Makefile b/slsDetectorServers/eigerDetectorServer/Makefile index c242d3bb1..5d896249f 100755 --- a/slsDetectorServers/eigerDetectorServer/Makefile +++ b/slsDetectorServers/eigerDetectorServer/Makefile @@ -25,10 +25,11 @@ version: clean versioning $(PROGS) #hv9m_blackfin_server boot: $(OBJS) +version_branch=$(API_BRANCH) version_name=APIEIGER version_path=slsDetectorServers/eigerDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index b4bb800d6..d5ef4f520 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 63b8a3a2c..0420a5d2b 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -117,9 +117,10 @@ void basictests() { uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); int64_t fwversion = getFirmwareVersion(); - int64_t swversion = getServerVersion(); + char swversion[MAX_STR_LENGTH] = {0}; + memset(swversion, 0, MAX_STR_LENGTH); + getServerVersion(swversion); int64_t sw_fw_apiversion = getFirmwareAPIVersion(); - int64_t client_sw_apiversion = getClientServerAPIVersion(); LOG(logINFOBLUE, ("**************************************************\n" @@ -127,16 +128,13 @@ void basictests() { "Detector MAC Addr:\t\t 0x%llx\n" "Firmware Version:\t\t %lld\n" - "Software Version:\t\t 0x%llx\n" + "Software Version:\t\t %s\n" "F/w-S/w API Version:\t\t %lld\n" "Required Firmware Version:\t %d\n" - "Client-Software API Version:\t 0x%llx\n" - "\n" "********************************************************\n", (unsigned int)ipadd, (long long unsigned int)macadd, - (long long int)fwversion, (long long int)swversion, - (long long int)sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION, - (long long int)client_sw_apiversion)); + (long long int)fwversion, swversion, (long long int)sw_fw_apiversion, + REQUIRED_FIRMWARE_VERSION)); // update default udpdstip and udpdstmac (1g is hardware ip and hardware // mac) @@ -208,9 +206,7 @@ int getTestImageMode() { return eiger_virtual_test_mode; } /* Ids */ -uint64_t getServerVersion() { return APIEIGER; } - -uint64_t getClientServerAPIVersion() { return APIEIGER; } +void getServerVersion(char *version) { strcpy(version, APIEIGER); } u_int64_t getFirmwareVersion() { #ifdef VIRTUAL diff --git a/slsDetectorServers/gotthard2DetectorServer/Makefile b/slsDetectorServers/gotthard2DetectorServer/Makefile index 817babe0e..f5fa63f14 100755 --- a/slsDetectorServers/gotthard2DetectorServer/Makefile +++ b/slsDetectorServers/gotthard2DetectorServer/Makefile @@ -24,10 +24,11 @@ version: clean versioning $(PROGS) boot: $(OBJS) +version_branch=$(API_BRANCH) version_name=APIGOTTHARD2 version_path=slsDetectorServers/gotthard2DetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/detid_gotthard2.txt b/slsDetectorServers/gotthard2DetectorServer/bin/detid_gotthard2.txt new file mode 100755 index 000000000..274c0052d --- /dev/null +++ b/slsDetectorServers/gotthard2DetectorServer/bin/detid_gotthard2.txt @@ -0,0 +1 @@ +1234 \ No newline at end of file diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index 544421c06..c07767962 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 eea6d4ff8..b6a9d3dd7 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -117,9 +117,10 @@ void basictests() { uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); int64_t fwversion = getFirmwareVersion(); - int64_t swversion = getServerVersion(); + char swversion[MAX_STR_LENGTH] = {0}; + memset(swversion, 0, MAX_STR_LENGTH); + getServerVersion(swversion); int64_t sw_fw_apiversion = getFirmwareAPIVersion(); - int64_t client_sw_apiversion = getClientServerAPIVersion(); uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN; LOG(logINFOBLUE, @@ -130,15 +131,13 @@ void basictests() { "Detector MAC Addr:\t\t 0x%llx\n\n" "Firmware Version:\t\t 0x%llx\n" - "Software Version:\t\t 0x%llx\n" + "Software Version:\t\t %s\n" "F/w-S/w API Version:\t\t 0x%llx\n" "Required Firmware Version:\t 0x%x\n" - "Client-Software API Version:\t 0x%llx\n" "********************************************************\n", hversion, ipadd, (long long unsigned int)macadd, - (long long int)fwversion, (long long int)swversion, - (long long int)sw_fw_apiversion, requiredFirmwareVersion, - (long long int)client_sw_apiversion)); + (long long int)fwversion, swversion, (long long int)sw_fw_apiversion, + requiredFirmwareVersion)); #ifndef VIRTUAL // return if flag is not zero, debug mode @@ -251,9 +250,7 @@ int testBus() { /* Ids */ -uint64_t getServerVersion() { return APIGOTTHARD2; } - -uint64_t getClientServerAPIVersion() { return APIGOTTHARD2; } +void getServerVersion(char *version) { strcpy(version, APIGOTTHARD2); } u_int64_t getFirmwareVersion() { #ifdef VIRTUAL diff --git a/slsDetectorServers/gotthardDetectorServer/Makefile b/slsDetectorServers/gotthardDetectorServer/Makefile index 68af42ee7..57ead7418 100755 --- a/slsDetectorServers/gotthardDetectorServer/Makefile +++ b/slsDetectorServers/gotthardDetectorServer/Makefile @@ -23,10 +23,11 @@ version: clean versioning $(PROGS) boot: $(OBJS) +version_branch=$(API_BRANCH) version_name=APIGOTTHARD version_path=slsDetectorServers/gotthardDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index 1ccf5fbfb..170df1ca8 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index f5e81ec4b..20641ed84 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -107,8 +107,9 @@ void basictests() { uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); int64_t fwversion = getFirmwareVersion(); - int64_t swversion = getServerVersion(); - int64_t client_sw_apiversion = getClientServerAPIVersion(); + char swversion[MAX_STR_LENGTH] = {0}; + memset(swversion, 0, MAX_STR_LENGTH); + getServerVersion(swversion); LOG(logINFOBLUE, ("**************************************************\n" @@ -118,15 +119,13 @@ void basictests() { "Detector MAC Addr : 0x%llx\n\n" "Firmware Version : 0x%llx\n" - "Software Version : 0x%llx\n" - "Client-S/w API Version : 0x%llx\n" + "Software Version : %s\n" "********************************************************\n", boardrev, ipadd, (long long unsigned int)macadd, - (long long int)fwversion, (long long int)swversion, - (long long int)client_sw_apiversion)); + (long long int)fwversion, swversion)); #ifndef VIRTUAL if (!debugflag || updateFlag) { @@ -270,9 +269,7 @@ int getTestImageMode() { /* Ids */ -uint64_t getServerVersion() { return APIGOTTHARD; } - -uint64_t getClientServerAPIVersion() { return APIGOTTHARD; } +void getServerVersion(char *version) { strcpy(version, APIGOTTHARD); } u_int64_t getFirmwareVersion() { #ifdef VIRTUAL diff --git a/slsDetectorServers/jungfrauDetectorServer/Makefile b/slsDetectorServers/jungfrauDetectorServer/Makefile index 5f2e93dc4..95437b5b9 100755 --- a/slsDetectorServers/jungfrauDetectorServer/Makefile +++ b/slsDetectorServers/jungfrauDetectorServer/Makefile @@ -24,10 +24,11 @@ version: clean versioning $(PROGS) boot: $(OBJS) +version_branch=$(API_BRANCH) version_name=APIJUNGFRAU version_path=slsDetectorServers/jungfrauDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/config_jungfrau.txt b/slsDetectorServers/jungfrauDetectorServer/bin/config_jungfrau.txt new file mode 100755 index 000000000..48fea871e --- /dev/null +++ b/slsDetectorServers/jungfrauDetectorServer/bin/config_jungfrau.txt @@ -0,0 +1,4 @@ + + +#chip version version (multiplied by 10) +chipversion 11 diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 75f19d925..655355a0b 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 596935166..881c7234b 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -102,9 +102,10 @@ void basictests() { uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); int64_t fwversion = getFirmwareVersion(); - int64_t swversion = getServerVersion(); + char swversion[MAX_STR_LENGTH] = {0}; + memset(swversion, 0, MAX_STR_LENGTH); + getServerVersion(swversion); int64_t sw_fw_apiversion = 0; - int64_t client_sw_apiversion = getClientServerAPIVersion(); uint32_t requiredFirmwareVersion = (isHardwareVersion2() ? REQRD_FRMWRE_VRSN_BOARD2 : REQRD_FRMWRE_VRSN); @@ -120,15 +121,13 @@ void basictests() { "Detector MAC Addr:\t\t 0x%llx\n\n" "Firmware Version:\t\t 0x%llx\n" - "Software Version:\t\t 0x%llx\n" + "Software Version:\t\t %s\n" "F/w-S/w API Version:\t\t 0x%llx\n" "Required Firmware Version:\t 0x%x\n" - "Client-Software API Version:\t 0x%llx\n" "********************************************************\n", hversion, hsnumber, ipadd, (long long unsigned int)macadd, - (long long int)fwversion, (long long int)swversion, - (long long int)sw_fw_apiversion, requiredFirmwareVersion, - (long long int)client_sw_apiversion)); + (long long int)fwversion, swversion, (long long int)sw_fw_apiversion, + requiredFirmwareVersion)); #ifndef VIRTUAL // return if flag is not zero, debug mode @@ -257,9 +256,7 @@ int getTestImageMode() { return virtual_image_test_mode; } /* Ids */ -uint64_t getServerVersion() { return APIJUNGFRAU; } - -uint64_t getClientServerAPIVersion() { return APIJUNGFRAU; } +void getServerVersion(char *version) { strcpy(version, APIJUNGFRAU); } u_int64_t getFirmwareVersion() { #ifdef VIRTUAL diff --git a/slsDetectorServers/moenchDetectorServer/Makefile b/slsDetectorServers/moenchDetectorServer/Makefile index e57e80a03..e3592fcf3 100755 --- a/slsDetectorServers/moenchDetectorServer/Makefile +++ b/slsDetectorServers/moenchDetectorServer/Makefile @@ -25,10 +25,11 @@ version: clean versioning $(PROGS) boot: $(OBJS) +version_branch=$(API_BRANCH) version_name=APIMOENCH version_path=slsDetectorServers/moenchDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index 87f3fb8d3..f111afb6d 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 793936673..570032810 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -125,9 +125,10 @@ void basictests() { uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); int64_t fwversion = getFirmwareVersion(); - int64_t swversion = getServerVersion(); + char swversion[MAX_STR_LENGTH] = {0}; + memset(swversion, 0, MAX_STR_LENGTH); + getServerVersion(swversion); int64_t sw_fw_apiversion = 0; - int64_t client_sw_apiversion = getClientServerAPIVersion(); if (fwversion >= MIN_REQRD_VRSN_T_RD_API) sw_fw_apiversion = getFirmwareAPIVersion(); @@ -140,15 +141,13 @@ void basictests() { "Detector MAC Addr:\t\t 0x%llx\n\n" "Firmware Version:\t\t 0x%llx\n" - "Software Version:\t\t 0x%llx\n" + "Software Version:\t\t %s\n" "F/w-S/w API Version:\t\t 0x%llx\n" "Required Firmware Version:\t 0x%x\n" - "Client-Software API Version:\t 0x%llx\n" "********************************************************\n", hversion, hsnumber, ipadd, (long long unsigned int)macadd, - (long long int)fwversion, (long long int)swversion, - (long long int)sw_fw_apiversion, REQRD_FRMWR_VRSN, - (long long int)client_sw_apiversion)); + (long long int)fwversion, swversion, (long long int)sw_fw_apiversion, + REQRD_FRMWR_VRSN)); #ifndef VIRTUAL // return if flag is not zero, debug mode @@ -329,9 +328,7 @@ int testBus() { /* Ids */ -uint64_t getServerVersion() { return APIMOENCH; } - -uint64_t getClientServerAPIVersion() { return APIMOENCH; } +void getServerVersion(char *version) { strcpy(version, APIMOENCH); } uint64_t getFirmwareVersion() { #ifdef VIRTUAL diff --git a/slsDetectorServers/mythen3DetectorServer/Makefile b/slsDetectorServers/mythen3DetectorServer/Makefile index 42b412f48..fb03c9d12 100755 --- a/slsDetectorServers/mythen3DetectorServer/Makefile +++ b/slsDetectorServers/mythen3DetectorServer/Makefile @@ -25,10 +25,11 @@ version: clean versioning $(PROGS) boot: $(OBJS) +version_branch=$(API_BRANCH) version_name=APIMYTHEN3 version_path=slsDetectorServers/mythen3DetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/mythen3DetectorServer/bin/detid_mythen3.txt b/slsDetectorServers/mythen3DetectorServer/bin/detid_mythen3.txt new file mode 100755 index 000000000..c22708346 --- /dev/null +++ b/slsDetectorServers/mythen3DetectorServer/bin/detid_mythen3.txt @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 1296e8039..68e9b18cc 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 8cb2a7e0e..af62de78d 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -110,10 +110,10 @@ void basictests() { uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); int64_t fwversion = getFirmwareVersion(); - int64_t swversion = getServerVersion(); + char swversion[MAX_STR_LENGTH] = {0}; + memset(swversion, 0, MAX_STR_LENGTH); + getServerVersion(swversion); int64_t sw_fw_apiversion = getFirmwareAPIVersion(); - ; - int64_t client_sw_apiversion = getClientServerAPIVersion(); uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN; LOG(logINFOBLUE, @@ -124,15 +124,13 @@ void basictests() { "Detector MAC Addr:\t\t 0x%llx\n\n" "Firmware Version:\t\t 0x%llx\n" - "Software Version:\t\t 0x%llx\n" + "Software Version:\t\t %s\n" "F/w-S/w API Version:\t\t 0x%llx\n" "Required Firmware Version:\t 0x%x\n" - "Client-Software API Version:\t 0x%llx\n" "********************************************************\n", hversion, ipadd, (long long unsigned int)macadd, - (long long int)fwversion, (long long int)swversion, - (long long int)sw_fw_apiversion, requiredFirmwareVersion, - (long long int)client_sw_apiversion)); + (long long int)fwversion, swversion, (long long int)sw_fw_apiversion, + requiredFirmwareVersion)); #ifndef VIRTUAL // return if flag is not zero, debug mode @@ -245,9 +243,7 @@ int testBus() { /* Ids */ -uint64_t getServerVersion() { return APIMYTHEN3; } - -uint64_t getClientServerAPIVersion() { return APIMYTHEN3; } +void getServerVersion(char *version) { strcpy(version, APIMYTHEN3); } u_int64_t getFirmwareVersion() { #ifdef VIRTUAL diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 166d2d45a..70ce754c1 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -75,8 +75,7 @@ int getTestImageMode(); #endif // Ids -u_int64_t getServerVersion(); -u_int64_t getClientServerAPIVersion(); +void getServerVersion(char *version); u_int64_t getFirmwareVersion(); u_int64_t getFirmwareAPIVersion(); #if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \ diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 4c2c50b6c..7164ad869 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -127,7 +127,7 @@ int temp_control(int); int temp_event(int); int auto_comp_disable(int); int storage_cell_start(int); -int check_version(int); +int initial_checks(int); int software_trigger(int); int led(int); int digital_io_delay(int); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c index 9ccbecc93..3542ba431 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c @@ -55,7 +55,8 @@ int main(int argc, char *argv[]) { debugflag = 0; updateFlag = 0; checkModuleFlag = 1; - int version = 0; + char version[MAX_STR_LENGTH] = {0}; + memset(version, 0, MAX_STR_LENGTH); ignoreConfigFileFlag = 0; #if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \ defined(MYTHEN3D) @@ -142,22 +143,21 @@ int main(int argc, char *argv[]) { case 'v': #ifdef GOTTHARDD - version = APIGOTTHARD; + strcpy(version, APIGOTTHARD); #elif EIGERD - version = APIEIGER; + strcpy(version, APIEIGER); #elif JUNGFRAUD - version = APIJUNGFRAU; + strcpy(version, APIJUNGFRAU); #elif CHIPTESTBOARDD - version = APICTB; + strcpy(version, APICTB); #elif MOENCHD - version = APIMOENCH; + strcpy(version, APIMOENCH); #elif MYTHEN3D - version = APIMYTHEN3; + strcpy(version, APIMYTHEN3); #elif GOTTHARD2D - version = APIGOTTHARD2; + strcpy(version, APIGOTTHARD2); #endif - LOG(logINFO, ("SLS Detector Server Version: %s (0x%x)\n", GITBRANCH, - version)); + LOG(logINFO, ("SLS Detector Server Version: %s\n", version)); exit(EXIT_SUCCESS); case 'p': diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 6b8f6da74..47c986fc5 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -84,7 +84,7 @@ int updateModeAllowedFunction(int file_des) { F_EXEC_COMMAND, F_GET_DETECTOR_TYPE, F_GET_FIRMWARE_VERSION, F_GET_SERVER_VERSION, F_GET_SERIAL_NUMBER, F_WRITE_REGISTER, F_READ_REGISTER, F_LOCK_SERVER, F_GET_LAST_CLIENT_IP, - F_PROGRAM_FPGA, F_RESET_FPGA, F_CHECK_VERSION, + F_PROGRAM_FPGA, F_RESET_FPGA, F_INITIAL_CHECKS, F_REBOOT_CONTROLLER, F_GET_KERNEL_VERSION, F_UPDATE_KERNEL, F_UPDATE_DETECTOR_SERVER, F_GET_UPDATE_MODE, F_SET_UPDATE_MODE, F_GET_NUM_CHANNELS, F_GET_NUM_INTERFACES, F_ACTIVATE}; @@ -303,7 +303,7 @@ void function_table() { flist[F_TEMP_EVENT] = &temp_event; flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable; flist[F_STORAGE_CELL_START] = &storage_cell_start; - flist[F_CHECK_VERSION] = &check_version; + flist[F_INITIAL_CHECKS] = &initial_checks; flist[F_SOFTWARE_TRIGGER] = &software_trigger; flist[F_LED] = &led; flist[F_DIGITAL_IO_DELAY] = &digital_io_delay; @@ -737,10 +737,11 @@ int get_firmware_version(int file_des) { int get_server_version(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - int64_t retval = -1; - retval = getServerVersion(); - LOG(logDEBUG1, ("server version retval: 0x%llx\n", (long long int)retval)); - return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); + char retvals[MAX_STR_LENGTH]; + memset(retvals, 0, MAX_STR_LENGTH); + getServerVersion(retvals); + LOG(logDEBUG1, ("server version retval: %s\n", retvals)); + return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals)); } int get_serial_number(int file_des) { @@ -4075,13 +4076,9 @@ int storage_cell_start(int file_des) { return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } -int check_version(int file_des) { +int initial_checks(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - int64_t arg = -1; - - if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0) - return printSocketReadError(); // check software- firmware compatibility and basic tests LOG(logDEBUG1, ("Checking software-firmware compatibility and basic " @@ -4107,39 +4104,6 @@ int check_version(int file_des) { LOG(logERROR, (mess)); } } - - if (ret == OK) { - LOG(logDEBUG1, - ("Checking versioning compatibility with value 0x%llx\n", arg)); - - int64_t client_requiredVersion = arg; - int64_t det_apiVersion = getClientServerAPIVersion(); - int64_t det_version = getServerVersion(); - - // old client - if (det_apiVersion > client_requiredVersion) { - ret = FAIL; - sprintf(mess, - "Client's detector SW API version: (0x%llx). " - "Detector's SW API Version: (0x%llx). " - "Incompatible, update client!\n", - (long long int)client_requiredVersion, - (long long int)det_apiVersion); - LOG(logERROR, (mess)); - } - - // old software - else if (client_requiredVersion > det_version) { - ret = FAIL; - sprintf(mess, - "Detector SW Version: (0x%llx). " - "Client's detector SW API Version: (0x%llx). " - "Incompatible, update detector software!\n", - (long long int)det_version, - (long long int)client_requiredVersion); - LOG(logERROR, (mess)); - } - } return Server_SendResult(file_des, INT32, NULL, 0); } diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 8509579b6..6398c50b0 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -74,11 +74,11 @@ class Detector { /** package git branch */ std::string getPackageVersion() const; - int64_t getClientVersion() const; + std::string getClientVersion() const; Result getFirmwareVersion(Positions pos = {}) const; - Result getDetectorServerVersion(Positions pos = {}) const; + Result getDetectorServerVersion(Positions pos = {}) const; Result getKernelVersion(Positions pos = {}) const; @@ -89,7 +89,7 @@ class Detector { * streamed out in the UDP header of the detector.*/ Result getModuleId(Positions pos = {}) const; - Result getReceiverVersion(Positions pos = {}) const; + Result getReceiverVersion(Positions pos = {}) const; /** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2, * CHIPTESTBOARD */ diff --git a/slsDetectorSoftware/src/CmdLineApp.cpp b/slsDetectorSoftware/src/CmdLineApp.cpp index 186c29c9b..c1955f528 100644 --- a/slsDetectorSoftware/src/CmdLineApp.cpp +++ b/slsDetectorSoftware/src/CmdLineApp.cpp @@ -37,9 +37,7 @@ int main(int argc, char *argv[]) { // Check for --version in the arguments for (int i = 1; i < argc; ++i) { if (!(strcmp(argv[i], "--version")) || !(strcmp(argv[i], "-v"))) { - int64_t tempval = APILIB; - std::cout << argv[0] << " " << GITBRANCH << " (0x" << std::hex - << tempval << ")" << std::endl; + std::cout << argv[0] << " " << APILIB << std::endl; return 0; } } diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 08d8d11cb..d138096f7 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -277,21 +277,20 @@ std::string CmdProxy::Versions(int action) { auto t = det->getFirmwareVersion(std::vector{det_id}); os << "\nDetector Type: " << OutString(det->getDetectorType()) << "\nPackage Version: " << det->getPackageVersion() << std::hex - << "\nClient Version: 0x" << det->getClientVersion(); + << "\nClient Version: " << det->getClientVersion(); if (det->getDetectorType().squash() == defs::EIGER) { os << "\nFirmware Version: " << OutString(t); } else { os << "\nFirmware Version: " << OutStringHex(t); } os << "\nDetector Server Version: " - << OutStringHex( + << OutString( det->getDetectorServerVersion(std::vector{det_id})); - os << "\nDetector Server Version: " + os << "\nDetector Kernel Version: " << OutString(det->getKernelVersion({std::vector{det_id}})); if (det->getUseReceiverFlag().squash(true)) { os << "\nReceiver Version: " - << OutStringHex( - det->getReceiverVersion(std::vector{det_id})); + << OutString(det->getReceiverVersion(std::vector{det_id})); } os << std::dec << '\n'; } else if (action == defs::PUT_ACTION) { @@ -324,12 +323,12 @@ std::string CmdProxy::ClientVersion(int action) { std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "\n\tClient software version in format [0xYYMMDD]." << '\n'; + os << "\n\tClient software version" << '\n'; } else if (action == defs::GET_ACTION) { if (!args.empty()) { WrongNumberOfParameters(0); } - os << ToStringHex(det->getClientVersion()) << '\n'; + os << det->getClientVersion() << '\n'; } else if (action == defs::PUT_ACTION) { throw RuntimeError("cannot put"); } else { @@ -2563,8 +2562,7 @@ std::string CmdProxy::AdcVpp(int action) { if (action == defs::HELP_ACTION) { os << "[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of " "ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> " - "2V. " - "\n\tAdvanced User function!\n" + "2V. \n\tAdvanced User function!\n" << '\n'; return os.str(); } diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 93cc2b039..ac551f4c4 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1232,16 +1232,14 @@ class CmdProxy { "[fname]\n\tSets detector measurement parameters to those contained in " "fname. Set up per measurement."); - GET_COMMAND_HEX( - detectorserverversion, getDetectorServerVersion, - "\n\tOn-board detector server software version in format [0xYYMMDD]."); + GET_COMMAND(detectorserverversion, getDetectorServerVersion, + "\n\tOn-board detector server software version"); GET_COMMAND( kernelversion, getKernelVersion, "\n\tGet kernel version on the detector including time and date."); - GET_COMMAND_HEX(rx_version, getReceiverVersion, - "\n\tReceiver version in format [0xYYMMDD]."); + GET_COMMAND(rx_version, getReceiverVersion, "\n\tReceiver version"); GET_COMMAND_HEX(serialnumber, getSerialNumber, "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]" diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index ffa780f0f..78c954a1c 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -9,6 +9,7 @@ #include "DetectorImpl.h" #include "Module.h" #include "sls/Pattern.h" +#include "sls/Version.h" #include "sls/container_utils.h" #include "sls/file_utils.h" #include "sls/logger.h" @@ -112,15 +113,18 @@ void Detector::setVirtualDetectorServers(int numServers, int startingPort) { int Detector::getShmId() const { return pimpl->getDetectorIndex(); } -std::string Detector::getPackageVersion() const { return GITBRANCH; } +std::string Detector::getPackageVersion() const { return RELEASE; } -int64_t Detector::getClientVersion() const { return APILIB; } +std::string Detector::getClientVersion() const { + Version v(APILIB); + return v.concise(); +} Result Detector::getFirmwareVersion(Positions pos) const { return pimpl->Parallel(&Module::getFirmwareVersion, pos); } -Result Detector::getDetectorServerVersion(Positions pos) const { +Result Detector::getDetectorServerVersion(Positions pos) const { return pimpl->Parallel(&Module::getDetectorServerVersion, pos); } @@ -136,7 +140,7 @@ Result Detector::getModuleId(Positions pos) const { return pimpl->Parallel(&Module::getModuleId, pos); } -Result Detector::getReceiverVersion(Positions pos) const { +Result Detector::getReceiverVersion(Positions pos) const { return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos); } @@ -1123,14 +1127,16 @@ Result Detector::getRxHostname(Positions pos) const { } void Detector::setRxHostname(const std::string &receiver, Positions pos) { - pimpl->Parallel(&Module::setReceiverHostname, pos, receiver); + pimpl->Parallel(&Module::setReceiverHostname, pos, receiver, + pimpl->getInitialChecks()); updateRxRateCorrections(); } void Detector::setRxHostname(const std::vector &name) { // set all to same rx_hostname if (name.size() == 1) { - pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]); + pimpl->Parallel(&Module::setReceiverHostname, {}, name[0], + pimpl->getInitialChecks()); } else { if ((int)name.size() != size()) { throw RuntimeError( @@ -1139,7 +1145,8 @@ void Detector::setRxHostname(const std::vector &name) { } // set each rx_hostname for (int idet = 0; idet < size(); ++idet) { - pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]); + pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet], + pimpl->getInitialChecks()); } } updateRxRateCorrections(); diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 856f4a07f..b35bb2b16 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -4,6 +4,7 @@ #include "SharedMemory.h" #include "sls/ClientSocket.h" #include "sls/ToString.h" +#include "sls/Version.h" #include "sls/bit_utils.h" #include "sls/container_utils.h" #include "sls/file_utils.h" @@ -72,6 +73,7 @@ void Module::setHostname(const std::string &hostname, auto client = DetectorSocket(shm()->hostname, shm()->controlPort); client.close(); try { + initialDetectorServerChecks(); checkDetectorVersionCompatibility(); LOG(logINFO) << "Module Version Compatibility - Success"; } catch (const DetectorError &e) { @@ -90,8 +92,21 @@ int64_t Module::getFirmwareVersion() const { return sendToDetector(F_GET_FIRMWARE_VERSION); } -int64_t Module::getDetectorServerVersion() const { - return sendToDetector(F_GET_SERVER_VERSION); +std::string Module::getControlServerLongVersion() const { + char retval[MAX_STR_LENGTH]{}; + sendToDetector(F_GET_SERVER_VERSION, nullptr, retval); + return retval; +} + +std::string Module::getStopServerLongVersion() const { + char retval[MAX_STR_LENGTH]{}; + sendToDetectorStop(F_GET_SERVER_VERSION, nullptr, retval); + return retval; +} + +std::string Module::getDetectorServerVersion() const { + Version v(getControlServerLongVersion()); + return v.concise(); } std::string Module::getKernelVersion() const { @@ -106,11 +121,15 @@ int64_t Module::getSerialNumber() const { int Module::getModuleId() const { return sendToDetector(F_GET_MODULE_ID); } -int64_t Module::getReceiverSoftwareVersion() const { - if (shm()->useReceiverFlag) { - return sendToReceiver(F_GET_RECEIVER_VERSION); - } - return -1; +std::string Module::getReceiverLongVersion() const { + char retval[MAX_STR_LENGTH]{}; + sendToReceiver(F_GET_RECEIVER_VERSION, nullptr, retval); + return retval; +} + +std::string Module::getReceiverSoftwareVersion() const { + Version v(getReceiverLongVersion()); + return v.concise(); } // static function @@ -1279,7 +1298,8 @@ std::string Module::getReceiverHostname() const { return std::string(shm()->rxHostname); } -void Module::setReceiverHostname(const std::string &receiverIP) { +void Module::setReceiverHostname(const std::string &receiverIP, + const bool initialChecks) { LOG(logDEBUG1) << "Setting up Receiver hostname with " << receiverIP; if (getRunStatus() == RUNNING) { @@ -1303,8 +1323,17 @@ void Module::setReceiverHostname(const std::string &receiverIP) { } strcpy_safe(shm()->rxHostname, host.c_str()); shm()->useReceiverFlag = true; - checkReceiverVersionCompatibility(); + try { + checkReceiverVersionCompatibility(); + LOG(logINFO) << "Receiver Version Compatibility - Success"; + } catch (const RuntimeError &e) { + if (!initialChecks) { + LOG(logWARNING) << "Bypassing Initial Checks at your own risk!"; + } else { + throw; + } + } // populate parameters from detector rxParameters retval; sendToDetector(F_GET_RECEIVER_PARAMETERS, nullptr, retval); @@ -3216,41 +3245,95 @@ void Module::initializeModuleStructure(detectorType type) { shm()->nDacs = parameters.nDacs; } +void Module::initialDetectorServerChecks() { + sendToDetector(F_INITIAL_CHECKS); + sendToDetectorStop(F_INITIAL_CHECKS); +} + void Module::checkDetectorVersionCompatibility() { - int64_t arg = 0; + std::string detServers[2] = {getControlServerLongVersion(), + getStopServerLongVersion()}; + for (int i = 0; i != 2; ++i) { + // det and client (sem. versioning) + Version det(detServers[i]); + Version client(APILIB); + if (det.hasSemanticVersioning() && client.hasSemanticVersioning()) { + if (!det.isBackwardCompatible(client)) { + std::ostringstream oss; + oss << "Detector (" << (i == 0 ? "Control" : "Stop") + << ") version (" << det.concise() + << ") is incompatible with client version (" + << client.concise() << "). Please update " + << (det <= client ? "detector" : "client"); + throw sls::RuntimeError(oss.str()); + } + } + // comparing dates(exact match to expected) + else { + Version expectedDetector(getDetectorAPI()); + if (det != expectedDetector) { + std::ostringstream oss; + oss << "Detector (" << (i == 0 ? "Control" : "Stop") + << ") version (" << det.getDate() + << ") is incompatible with client-detector API version (" + << expectedDetector.getDate() << "). Please update " + << (det <= expectedDetector ? "detector" : "client"); + throw sls::RuntimeError(oss.str()); + } + } + LOG(logDEBUG) << "Detector compatible"; + } +} + +const std::string Module::getDetectorAPI() const { switch (shm()->detType) { case EIGER: - arg = APIEIGER; - break; + return APIEIGER; case JUNGFRAU: - arg = APIJUNGFRAU; - break; + return APIJUNGFRAU; case GOTTHARD: - arg = APIGOTTHARD; - break; + return APIGOTTHARD; case CHIPTESTBOARD: - arg = APICTB; - break; + return APICTB; case MOENCH: - arg = APIMOENCH; - break; + return APIMOENCH; case MYTHEN3: - arg = APIMYTHEN3; - break; + return APIMYTHEN3; case GOTTHARD2: - arg = APIGOTTHARD2; - break; + return APIGOTTHARD2; default: throw NotImplementedError( - "Check version compatibility is not implemented for this detector"); + "Detector type not implemented to get Detector API"); } - sendToDetector(F_CHECK_VERSION, arg, nullptr); - sendToDetectorStop(F_CHECK_VERSION, arg, nullptr); } void Module::checkReceiverVersionCompatibility() { - // TODO! Verify that this works as intended when version don't match - sendToReceiver(F_RECEIVER_CHECK_VERSION, int64_t(APIRECEIVER), nullptr); + // rxr and client (sem. versioning) + Version rxr(getReceiverLongVersion()); + Version client(APILIB); + if (rxr.hasSemanticVersioning() && client.hasSemanticVersioning()) { + if (!rxr.isBackwardCompatible(client)) { + std::ostringstream oss; + oss << "Receiver version (" << rxr.concise() + << ") is incompatible with client version (" << client.concise() + << "). Please update " + << (rxr <= client ? "receiver" : "client"); + throw sls::RuntimeError(oss.str()); + } + } + // comparing dates(exact match to expected) + else { + Version expectedReceiver(APIRECEIVER); + if (rxr != expectedReceiver) { + std::ostringstream oss; + oss << "Receiver version (" << rxr.getDate() + << ") is incompatible with client-receiver API version (" + << expectedReceiver.getDate() << "). Please update " + << (rxr <= expectedReceiver ? "receiver" : "client"); + throw sls::RuntimeError(oss.str()); + } + } + LOG(logDEBUG) << "Receiver compatible"; } void Module::setModule(sls_detector_module &module, bool trimbits) { diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index ce6c89506..9f031b85d 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -90,11 +90,13 @@ class Module : public virtual slsDetectorDefs { void setHostname(const std::string &hostname, const bool initialChecks); int64_t getFirmwareVersion() const; - int64_t getDetectorServerVersion() const; + std::string getControlServerLongVersion() const; + std::string getStopServerLongVersion() const; + std::string getDetectorServerVersion() const; std::string getKernelVersion() const; int64_t getSerialNumber() const; int getModuleId() const; - int64_t getReceiverSoftwareVersion() const; + std::string getReceiverSoftwareVersion() const; static detectorType getTypeFromDetector(const std::string &hostname, int cport = DEFAULT_TCP_CNTRL_PORTNO); @@ -276,7 +278,8 @@ class Module : public virtual slsDetectorDefs { * ************************************************/ bool getUseReceiverFlag() const; std::string getReceiverHostname() const; - void setReceiverHostname(const std::string &receiver); + void setReceiverHostname(const std::string &receiver, + const bool initialChecks); int getReceiverPort() const; int setReceiverPort(int port_number); int getReceiverFifoDepth() const; @@ -600,6 +603,8 @@ class Module : public virtual slsDetectorDefs { int64_t getMeasurementTime() const; private: + std::string getReceiverLongVersion() const; + void checkArgs(const void *args, size_t args_size, void *retval, size_t retval_size) const; @@ -737,6 +742,8 @@ class Module : public virtual slsDetectorDefs { Called when new shared memory is created */ void initializeModuleStructure(detectorType type); + void initialDetectorServerChecks(); + const std::string getDetectorAPI() const; void checkDetectorVersionCompatibility(); void checkReceiverVersionCompatibility(); void setModule(sls_detector_module &module, bool trimbits = true); diff --git a/slsReceiverSoftware/include/sls/Receiver.h b/slsReceiverSoftware/include/sls/Receiver.h index 5eed72df8..a7af073bd 100644 --- a/slsReceiverSoftware/include/sls/Receiver.h +++ b/slsReceiverSoftware/include/sls/Receiver.h @@ -36,7 +36,7 @@ class Receiver : private virtual slsDetectorDefs { * get get Receiver Version \returns id */ - int64_t getReceiverVersion(); + std::string getReceiverVersion(); /** * Start Acquisition Call back (slsMultiReceiver writes data if file write diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 72c1acf36..bad6ab5d6 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -51,7 +51,7 @@ ClientInterface::ClientInterface(int portNumber) make_unique(&ClientInterface::startTCPServer, this); } -int64_t ClientInterface::getReceiverVersion() { return APIRECEIVER; } +std::string ClientInterface::getReceiverVersion() { return APIRECEIVER; } /***callback functions***/ void ClientInterface::registerCallBackStartAcquisition( @@ -180,7 +180,6 @@ int ClientInterface::functionTable(){ flist[F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE]= &ClientInterface::get_real_udp_socket_buffer_size; flist[F_SET_RECEIVER_FRAMES_PER_FILE] = &ClientInterface::set_frames_per_file; flist[F_GET_RECEIVER_FRAMES_PER_FILE] = &ClientInterface::get_frames_per_file; - flist[F_RECEIVER_CHECK_VERSION] = &ClientInterface::check_version_compatibility; flist[F_SET_RECEIVER_DISCARD_POLICY] = &ClientInterface::set_discard_policy; flist[F_GET_RECEIVER_DISCARD_POLICY] = &ClientInterface::get_discard_policy; flist[F_SET_RECEIVER_PADDING] = &ClientInterface::set_padding_enable; @@ -312,7 +311,9 @@ int ClientInterface::get_last_client_ip(Interface &socket) { } int ClientInterface::get_version(Interface &socket) { - return socket.sendResult(getReceiverVersion()); + auto version = getReceiverVersion(); + version.resize(MAX_STR_LENGTH); + return socket.sendResult(version); } int ClientInterface::setup_receiver(Interface &socket) { @@ -1218,33 +1219,6 @@ int ClientInterface::get_frames_per_file(Interface &socket) { return socket.sendResult(retval); } -int ClientInterface::check_version_compatibility(Interface &socket) { - auto arg = socket.Receive(); - LOG(logDEBUG1) << "Checking versioning compatibility with value " << arg; - int64_t client_requiredVersion = arg; - int64_t rx_apiVersion = APIRECEIVER; - int64_t rx_version = getReceiverVersion(); - - if (rx_apiVersion > client_requiredVersion) { - std::ostringstream os; - os << "Incompatible versions.\n Client's receiver API Version: (0x" - << std::hex << client_requiredVersion - << "). Receiver API Version: (0x" << std::hex - << ").\n Please update the client!\n"; - throw RuntimeError(os.str()); - } else if (client_requiredVersion > rx_version) { - std::ostringstream os; - os << "This receiver is incompatible.\n Receiver Version: (0x" - << std::hex << rx_version << "). Client's receiver API Version: (0x" - << std::hex << client_requiredVersion - << ").\n Please update the receiver"; - throw RuntimeError(os.str()); - } else { - LOG(logINFO) << "Compatibility with Client: Successful"; - } - return socket.Send(OK); -} - int ClientInterface::set_discard_policy(Interface &socket) { auto index = socket.Receive(); if (index < 0 || index > NUM_DISCARD_POLICIES) { diff --git a/slsReceiverSoftware/src/ClientInterface.h b/slsReceiverSoftware/src/ClientInterface.h index f060c654e..288c1d02f 100644 --- a/slsReceiverSoftware/src/ClientInterface.h +++ b/slsReceiverSoftware/src/ClientInterface.h @@ -30,7 +30,7 @@ class ClientInterface : private virtual slsDetectorDefs { public: virtual ~ClientInterface(); ClientInterface(int portNumber = -1); - int64_t getReceiverVersion(); + std::string getReceiverVersion(); //***callback functions*** /** params: file path, file name, file index, image size */ @@ -128,7 +128,6 @@ class ClientInterface : private virtual slsDetectorDefs { int get_real_udp_socket_buffer_size(ServerInterface &socket); int set_frames_per_file(ServerInterface &socket); int get_frames_per_file(ServerInterface &socket); - int check_version_compatibility(ServerInterface &socket); int set_discard_policy(ServerInterface &socket); int get_discard_policy(ServerInterface &socket); int set_padding_enable(ServerInterface &socket); diff --git a/slsReceiverSoftware/src/Receiver.cpp b/slsReceiverSoftware/src/Receiver.cpp index c7f0cbe67..892448983 100644 --- a/slsReceiverSoftware/src/Receiver.cpp +++ b/slsReceiverSoftware/src/Receiver.cpp @@ -71,8 +71,7 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) { break; case 'v': - std::cout << "SLS Receiver Version: " << GITBRANCH << " (0x" - << std::hex << APIRECEIVER << ")" << std::endl; + std::cout << "SLS Receiver Version: " << APIRECEIVER << std::endl; LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]"; exit(EXIT_SUCCESS); @@ -124,7 +123,7 @@ Receiver::Receiver(int tcpip_port_no) { tcpipInterface = make_unique(tcpip_port_no); } -int64_t Receiver::getReceiverVersion() { +std::string Receiver::getReceiverVersion() { return tcpipInterface->getReceiverVersion(); } diff --git a/slsSupportLib/CMakeLists.txt b/slsSupportLib/CMakeLists.txt index 1d43aa386..4129b26b5 100755 --- a/slsSupportLib/CMakeLists.txt +++ b/slsSupportLib/CMakeLists.txt @@ -13,6 +13,7 @@ set(SOURCES src/UdpRxSocket.cpp src/sls_detector_exceptions.cpp src/md5_helper.cpp + src/Version.cpp ) # Header files to install as a part of the library @@ -50,6 +51,7 @@ if(SLS_DEVEL_HEADERS) include/sls/bit_utils.h include/sls/md5.h include/sls/md5_helper.h + include/sls/Version.h ) endif() diff --git a/slsSupportLib/include/sls/Version.h b/slsSupportLib/include/sls/Version.h new file mode 100644 index 000000000..33d10c27e --- /dev/null +++ b/slsSupportLib/include/sls/Version.h @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#pragma once + +#include +#include + +namespace sls { + +class Version { + private: + std::string version_; + std::string date_; + const std::string defaultBranch_ = "developer"; + + public: + explicit Version(const std::string &s); + + bool hasSemanticVersioning() const; + std::string getVersion() const; + std::string getDate() const; + std::string concise() const; + int getMajorVersion() const; + + // expects semantic versioning + bool isBackwardCompatible(const Version &other) const; + bool operator!=(const Version &other) const; + bool operator==(const Version &other) const; + bool operator<=(const Version &other) const; +}; + +std::ostream &operator<<(std::ostream &out, const Version &v); +} // namespace sls diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index ea25b4db4..9afcd56ba 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -107,7 +107,7 @@ enum detFuncs { F_TEMP_EVENT, F_AUTO_COMP_DISABLE, F_STORAGE_CELL_START, - F_CHECK_VERSION, + F_INITIAL_CHECKS, F_SOFTWARE_TRIGGER, F_LED, F_DIGITAL_IO_DELAY, @@ -339,7 +339,6 @@ enum detFuncs { F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, F_SET_RECEIVER_FRAMES_PER_FILE, F_GET_RECEIVER_FRAMES_PER_FILE, - F_RECEIVER_CHECK_VERSION, F_SET_RECEIVER_DISCARD_POLICY, F_GET_RECEIVER_DISCARD_POLICY, F_SET_RECEIVER_PADDING, @@ -488,7 +487,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_TEMP_EVENT: return "F_TEMP_EVENT"; case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE"; case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START"; - case F_CHECK_VERSION: return "F_CHECK_VERSION"; + case F_INITIAL_CHECKS: return "F_INITIAL_CHECKS"; case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER"; case F_LED: return "F_LED"; case F_DIGITAL_IO_DELAY: return "F_DIGITAL_IO_DELAY"; @@ -718,7 +717,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE"; case F_SET_RECEIVER_FRAMES_PER_FILE: return "F_SET_RECEIVER_FRAMES_PER_FILE"; case F_GET_RECEIVER_FRAMES_PER_FILE: return "F_GET_RECEIVER_FRAMES_PER_FILE"; - case F_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION"; case F_SET_RECEIVER_DISCARD_POLICY: return "F_SET_RECEIVER_DISCARD_POLICY"; case F_GET_RECEIVER_DISCARD_POLICY: return "F_GET_RECEIVER_DISCARD_POLICY"; case F_SET_RECEIVER_PADDING: return "F_SET_RECEIVER_PADDING"; diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 9a49266f9..8689f8c2a 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -1,14 +1,13 @@ // SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package /** API versions */ -#define GITBRANCH "developer" -#define APILIB 0x220609 -#define APIRECEIVER 0x220609 -#define APIGUI 0x220609 -#define APICTB 0x221018 -#define APIGOTTHARD 0x221018 -#define APIGOTTHARD2 0x221018 -#define APIJUNGFRAU 0x221018 -#define APIMOENCH 0x221018 -#define APIMYTHEN3 0x221107 -#define APIEIGER 0x221107 +#define RELEASE "developer" +#define APICTB "developer 0x221108" +#define APIGOTTHARD "developer 0x221108" +#define APIGOTTHARD2 "developer 0x221108" +#define APIJUNGFRAU "developer 0x221108" +#define APIMYTHEN3 "developer 0x221108" +#define APIMOENCH "developer 0x221108" +#define APIEIGER "developer 0x221108" +#define APILIB "developer 0x221108" +#define APIRECEIVER "developer 0x221108" diff --git a/slsSupportLib/src/Version.cpp b/slsSupportLib/src/Version.cpp new file mode 100644 index 000000000..2be4e6c3e --- /dev/null +++ b/slsSupportLib/src/Version.cpp @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "sls/Version.h" +#include "sls/sls_detector_exceptions.h" +#include "sls/string_utils.h" +#include + +namespace sls { + +Version::Version(const std::string &s) { + auto list = split(s, ' '); + // only date from previous releases + if (list.size() == 1) { + date_ = list[0]; + } + // semantic versioning + date + else { + version_ = list[0]; + date_ = list[1]; + } +} + +bool Version::hasSemanticVersioning() const { + return version_ != defaultBranch_; +} + +std::string Version::getVersion() const { return version_; } +std::string Version::getDate() const { return date_; } + +std::string Version::concise() const { + if (hasSemanticVersioning()) + return version_; + return date_; +} + +int Version::getMajorVersion() const { + int major = 0, minor = 0, patch = 0; + if (sscanf(version_.c_str(), "%d.%d.%d", &major, &minor, &patch) == 3) { + return major; + } + throw sls::RuntimeError("Could not get major version from " + version_); +} + +bool Version::isBackwardCompatible(const Version &other) const { + return getMajorVersion() == other.getMajorVersion(); +} + +bool Version::operator!=(const Version &other) const { + return !(*this == other); +} + +bool Version::operator==(const Version &other) const { + // both have semantic versioning + if (hasSemanticVersioning() && other.hasSemanticVersioning()) { + return version_ == other.getVersion(); + } + // compare dates + return date_ == other.getDate(); +} + +bool Version::operator<=(const Version &other) const { + // both have semantic versioning + if (hasSemanticVersioning() && other.hasSemanticVersioning()) { + // release version + std::string otherVersion = other.getVersion(); + if (version_ == otherVersion) + return true; + // less than + return (std::lexicographical_compare(version_.begin(), version_.end(), + otherVersion.begin(), + otherVersion.end())); + } + // compare dates + return date_ <= other.getDate(); +} + +std::ostream &operator<<(std::ostream &out, const Version &v) { + std::ostringstream oss; + oss << v.getVersion() << " " << v.getDate(); + return out << oss.str(); +} + +} // namespace sls diff --git a/updateAPIVersion.sh b/updateAPIVersion.sh index 499f9c3ed..8c45e0c48 100755 --- a/updateAPIVersion.sh +++ b/updateAPIVersion.sh @@ -1,8 +1,9 @@ # SPDX-License-Identifier: LGPL-3.0-or-other # Copyright (C) 2021 Contributors to the SLS Detector Package -#require 2 arguments, API_NAME API_DIR (relative to package) +usage="\nUsage: updateAPIVersion.sh [API_NAME] [API_DIR] [API_BRANCH(opt)]." + if [ $# -lt 2 ]; then - echo "Wrong usage of updateVersion.sh. Requires atleast 2 arguments [API_NAME, API_DIR]" + echo -e "Requires atleast 2 arguments. $usage" return [-1] fi @@ -12,6 +13,11 @@ API_DIR=$PACKAGE_DIR/$2 API_FILE=$PACKAGE_DIR/slsSupportLib/include/sls/versionAPI.h CURR_DIR=$PWD +if [ ! -d "$API_DIR" ]; then + echo "[API_DIR] does not exist. $usage" + return [-1] +fi + #go to directory cd $API_DIR @@ -38,8 +44,22 @@ API_DATE=${API_DATE:2:6} API_DATE=${API_DATE/#/0x} echo "date="$API_DATE + +# API_VAL concatenates branch and date +API_VAL="" +# API branch is defined (3rd argument) +if [ $# -eq 3 ]; then + API_BRANCH=$3 + echo "branch="$API_BRANCH + API_VAL+="\"$API_BRANCH $API_DATE\"" +else + # API branch not defined (default is developer) + echo "branch=developer" + API_VAL+="\"developer $API_DATE\"" +fi + #copy it to versionAPI.h -echo "#define "$API_NAME $API_DATE >> $API_FILE +echo "#define "$API_NAME $API_VAL >> $API_FILE #go back to original directory cd $CURR_DIR diff --git a/updateClientAPI.sh b/updateClientAPI.sh deleted file mode 100755 index c0458574d..000000000 --- a/updateClientAPI.sh +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -API_FILE=$PWD/slsSupportLib/include/sls/versionAPI.h -arraylength=3 - -LIB_DIR=slsDetectorSoftware -RXR_DIR=slsReceiverSoftware -GUI_DIR=slsDetectorGui - -declare -a arraydirs=($LIB_DIR $RXR_DIR $GUI_DIR) -declare -a arraynames=("APILIB" "APIRECEIVER" "APIGUI") - -for (( i=0; i<${arraylength}; ++i )); -do - ./updateAPIVersion.sh ${arraynames[$i]} ${arraydirs[$i]} -done - -#use tag -if [ $# -eq 0 ]; then - declare -a TAG=$(git rev-parse --abbrev-ref HEAD) -#find branch -else - declare -a TAG=${1} -fi -#CURR_BRANCH=$(git rev-parse --abbrev-ref HEAD) - -#update branch -BRANCH=$(cat $API_FILE | grep GITBRANCH | awk '{print $3}' ) -#sed -i s/$BRANCH/\"$CURR_BRANCH\"/g $API_FILE -sed -i s/$BRANCH/\"$TAG\"/g $API_FILE - - - diff --git a/updateClientAPIVersion.sh b/updateClientAPIVersion.sh new file mode 100755 index 000000000..bed281622 --- /dev/null +++ b/updateClientAPIVersion.sh @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2021 Contributors to the SLS Detector Package +branch="" +client_list=("slsDetectorSoftware" "slsReceiverSoftware") +usage="\nUsage: updateClientAPI.sh [all|slsDetectorSoftware|slsReceiverSoftware] [branch]. \n\tNo arguments means all with 'developer' branch. \n\tNo 'branch' input means 'developer branch'" + +# arguments +if [ $# -eq 0 ]; then + declare -a client=${client_list[@]} + echo "API Versioning all" +elif [ $# -eq 1 ] || [ $# -eq 2 ]; then + # 'all' client + if [[ $1 == "all" ]]; then + declare -a client=${client_list[@]} + echo "API Versioning all" + else + # only one server + if [[ $client_list != *$1* ]]; then + echo -e "Invalid argument 1: $1. $usage" + return -1 + fi + declare -a client=("${1}") + #echo "Versioning only $1" + fi + if [ $# -eq 2 ]; then + if [[ $client_list == *$2* ]]; then + echo -e "Invalid argument 2: $2. $usage" + return -1 + fi + branch+=$2 + #echo "with branch $branch" + fi +else + echo -e "Too many arguments.$usage" + return -1 +fi + +#echo "list is: ${client[@]}" + +# versioning each client +for i in ${client[@]} +do + dir=$i + case $dir in + slsDetectorSoftware) + declare -a name=APILIB + ;; + slsReceiverSoftware) + declare -a name=APIRECEIVER + ;; + *) + echo -n "unknown client argument $i" + return -1 + ;; + esac + echo -e "Versioning $dir [$name]" + ./updateAPIVersion.sh $name $dir $branch +done + diff --git a/updateReleaseVersion.sh b/updateReleaseVersion.sh new file mode 100644 index 000000000..8f38ae191 --- /dev/null +++ b/updateReleaseVersion.sh @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2021 Contributors to the SLS Detector Package + +API_FILE=$PWD/slsSupportLib/include/sls/versionAPI.h +CURR_BRANCH=$(cat $API_FILE | grep RELEASE | awk '{print $3}' ) + +# default branch is developer +if [ $# -eq 0 ]; then + declare -a NEW_BRANCH="developer" +else + declare -a NEW_BRANCH=${1} +fi + +# update branch +sed -i s/$CURR_BRANCH/\"$NEW_BRANCH\"/g $API_FILE