Versioning (#568)

- removed getClientServerAPIVersion in server (not used)
- removed rxr side (clientversion compatibility check), removed enum as well as it is now done on the client side.
- versionAPI.h
   - GITBRANCH changed to RELEASE
   - dates for all API changed to "sem_version date". Scripts to compile servers modified for this. Empty "branch" name will end up with developer for sem_version.

- Version class with constructor taking in the long version (APILIB date). Other member functions including concise(to get sem_version for new releases and date for old releases), 
  
- bypassing initial tests, also now bypasses the client-rxr compatibility check (at rx_hostname command)

- previously, compatibility between client-det was ensuring both had the same detector API (eg. same APIJUNGFRAU)
   - Now, compatibility only checks APILIB (client side) and detector API(eg. APIJUNGFRAU) (detector side) have same major version. It only does backward compatibility test. Rest is upto user to ensure. 
   - If server is from an older release, it will compare dates like previous implementation (APIJUNGFRAU from both client and det)
 
- - previously, compatibility between client-rxr was ensuring both had the same APIRECEIVER
   - Now, compatibility only checks APILIB (client side) and APIRECEIVER (rxr side) have same major version. It only does backward compatibility test. Rest is upto user to ensure. 
   - If rxr is from an older release, it will compare dates like previous implementation (APIRECEIVER from both client and rxr)

- removed APIGUI, evalVersionVariables.sh, genVersionHeader.sh (not needed or not used)

- clientVersion, rxrversion and detectorserverversion all return strings and not integers (in hex) anymore. Depending if it has semantic versioning, it will print that or the date if it is too old.

- fixed in python (strings for versions)
- check_version function in detector server changed to "initial checks" as it only checks server-firmware compatibility and initial server checks. Client compatibilities are moved to client side.
- --version gives sem_version and date? Is date needed as well. The clientversion, detserverversion and rxrversion API gives only sem_version (no date)
- - formatting
This commit is contained in:
Dhanya Thattil 2022-11-09 11:13:09 +01:00 committed by GitHub
parent b150db0fb3
commit 05f657c106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 609 additions and 414 deletions

View File

@ -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`

View File

@ -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

View File

@ -225,9 +225,9 @@ class Detector(CppDetectorApi):
Example Example
------- -------
>>> d.detectorserverversion >>> d.detectorserverversion
'0x200910' '7.0.0'
""" """
return ut.lhex(self.getDetectorServerVersion()) return self.getDetectorServerVersion()
@property @property
@element @element
@ -249,15 +249,15 @@ class Detector(CppDetectorApi):
Example Example
------- -------
>>> d.clientversion >>> d.clientversion
'0x200810' '7.0.1'
""" """
return hex(self.getClientVersion()) return self.getClientVersion()
@property @property
@element @element
def rx_version(self): def rx_version(self):
"""Receiver version in format [0xYYMMDD].""" """Receiver version """
return ut.lhex(self.getReceiverVersion()) return self.getReceiverVersion()
@property @property
@element @element

View File

@ -55,16 +55,17 @@ void init_det(py::module &m) {
(int (Detector::*)() const) & Detector::getShmId); (int (Detector::*)() const) & Detector::getShmId);
CppDetectorApi.def("getPackageVersion", (std::string(Detector::*)() const) & CppDetectorApi.def("getPackageVersion", (std::string(Detector::*)() const) &
Detector::getPackageVersion); Detector::getPackageVersion);
CppDetectorApi.def("getClientVersion", (int64_t(Detector::*)() const) & CppDetectorApi.def("getClientVersion", (std::string(Detector::*)() const) &
Detector::getClientVersion); Detector::getClientVersion);
CppDetectorApi.def("getFirmwareVersion", CppDetectorApi.def("getFirmwareVersion",
(Result<int64_t>(Detector::*)(sls::Positions) const) & (Result<int64_t>(Detector::*)(sls::Positions) const) &
Detector::getFirmwareVersion, Detector::getFirmwareVersion,
py::arg() = Positions{}); py::arg() = Positions{});
CppDetectorApi.def("getDetectorServerVersion", CppDetectorApi.def(
(Result<int64_t>(Detector::*)(sls::Positions) const) & "getDetectorServerVersion",
Detector::getDetectorServerVersion, (Result<std::string>(Detector::*)(sls::Positions) const) &
py::arg() = Positions{}); Detector::getDetectorServerVersion,
py::arg() = Positions{});
CppDetectorApi.def( CppDetectorApi.def(
"getKernelVersion", "getKernelVersion",
(Result<std::string>(Detector::*)(sls::Positions) const) & (Result<std::string>(Detector::*)(sls::Positions) const) &
@ -78,10 +79,11 @@ void init_det(py::module &m) {
(Result<int>(Detector::*)(sls::Positions) const) & (Result<int>(Detector::*)(sls::Positions) const) &
Detector::getModuleId, Detector::getModuleId,
py::arg() = Positions{}); py::arg() = Positions{});
CppDetectorApi.def("getReceiverVersion", CppDetectorApi.def(
(Result<int64_t>(Detector::*)(sls::Positions) const) & "getReceiverVersion",
Detector::getReceiverVersion, (Result<std::string>(Detector::*)(sls::Positions) const) &
py::arg() = Positions{}); Detector::getReceiverVersion,
py::arg() = Positions{});
CppDetectorApi.def( CppDetectorApi.def(
"getDetectorType", "getDetectorType",
(Result<defs::detectorType>(Detector::*)(sls::Positions) const) & (Result<defs::detectorType>(Detector::*)(sls::Positions) const) &
@ -202,6 +204,16 @@ void init_det(py::module &m) {
CppDetectorApi.def( CppDetectorApi.def(
"setSynchronization", "setSynchronization",
(void (Detector::*)(bool)) & Detector::setSynchronization, py::arg()); (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", CppDetectorApi.def("isVirtualDetectorServer",
(Result<bool>(Detector::*)(sls::Positions) const) & (Result<bool>(Detector::*)(sls::Positions) const) &
Detector::isVirtualDetectorServer, Detector::isVirtualDetectorServer,
@ -1340,16 +1352,6 @@ void init_det(py::module &m) {
(void (Detector::*)(const int, const int, const int, sls::Positions)) & (void (Detector::*)(const int, const int, const int, sls::Positions)) &
Detector::setADCConfiguration, Detector::setADCConfiguration,
py::arg(), py::arg(), py::arg(), py::arg() = Positions{}); 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", CppDetectorApi.def("getCounterMask",
(Result<uint32_t>(Detector::*)(sls::Positions) const) & (Result<uint32_t>(Detector::*)(sls::Positions) const) &
Detector::getCounterMask, Detector::getCounterMask,
@ -1493,6 +1495,14 @@ void init_det(py::module &m) {
(void (Detector::*)(defs::dacIndex, int, sls::Positions)) & (void (Detector::*)(defs::dacIndex, int, sls::Positions)) &
Detector::setVoltage, Detector::setVoltage,
py::arg(), py::arg(), py::arg() = Positions{}); py::arg(), py::arg(), py::arg() = Positions{});
CppDetectorApi.def("getADCVpp",
(Result<int>(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", CppDetectorApi.def("getADCEnableMask",
(Result<uint32_t>(Detector::*)(sls::Positions) const) & (Result<uint32_t>(Detector::*)(sls::Positions) const) &
Detector::getADCEnableMask, Detector::getADCEnableMask,

View File

@ -21,16 +21,25 @@
#include <QScrollArea> #include <QScrollArea>
#include <QSizePolicy> #include <QSizePolicy>
#include "sls/Version.h"
#include <getopt.h> #include <getopt.h>
#include <string> #include <string>
#include <sys/stat.h> #include <sys/stat.h>
std::string getClientVersion() {
try {
sls::Version v(APILIB);
return v.concise();
} catch (...) {
return std::string("unknown");
}
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
// options // options
std::string fname; std::string fname;
bool isDeveloper = false; bool isDeveloper = false;
int64_t tempval = 0;
int multiId = 0; int multiId = 0;
// parse command line for config // parse command line for config
@ -72,9 +81,7 @@ int main(int argc, char **argv) {
break; break;
case 'v': case 'v':
tempval = APIGUI; LOG(sls::logINFO) << "SLS Detector GUI " << getClientVersion();
LOG(sls::logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
<< std::hex << tempval << ")";
return 0; return 0;
case 'h': case 'h':
@ -463,10 +470,9 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, " LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
"Gotthard, Gotthard2 and Moench detectors"; "Gotthard, Gotthard2 and Moench detectors";
std::string guiVersion = ToStringHex(APIGUI);
std::string clientVersion = "unknown"; std::string clientVersion = "unknown";
try { try {
clientVersion = ToStringHex(det->getClientVersion()); clientVersion = det->getClientVersion();
} }
CATCH_DISPLAY("Could not get client version.", CATCH_DISPLAY("Could not get client version.",
"qDetectorMain::ExecuteHelp") "qDetectorMain::ExecuteHelp")
@ -475,9 +481,8 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
qDefs::INFORMATION, qDefs::INFORMATION,
"<p style=\"font-family:verdana;\">" "<p style=\"font-family:verdana;\">"
"<b>SLS Detector GUI version:&nbsp;&nbsp;&nbsp;" + "<b>SLS Detector Client version: " +
guiVersion + clientVersion +
"<br>SLS Detector Client version: " + clientVersion +
"</b><br><br>" "</b><br><br>"
"Common GUI to control the SLS Detectors: " "Common GUI to control the SLS Detectors: "

View File

@ -184,10 +184,8 @@ void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
std::to_string((unsigned long)det->getFirmwareVersion( std::to_string((unsigned long)det->getFirmwareVersion(
{comboDetector->currentIndex()})[0]); {comboDetector->currentIndex()})[0]);
lblDetectorFirmware->setText(QString(retval.c_str())); lblDetectorFirmware->setText(QString(retval.c_str()));
retval = retval = det->getDetectorServerVersion(
std::string("0x") + {comboDetector->currentIndex()})[0];
std::to_string((unsigned long)det->getDetectorServerVersion(
{comboDetector->currentIndex()})[0]);
lblDetectorSoftware->setText(QString(retval.c_str())); lblDetectorSoftware->setText(QString(retval.c_str()));
} }
CATCH_DISPLAY("Could not get versions.", "qTabDebugging::SetParameters") CATCH_DISPLAY("Could not get versions.", "qTabDebugging::SetParameters")

View File

@ -1,43 +1,84 @@
# SPDX-License-Identifier: LGPL-3.0-or-other # SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package # 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 if [ $# -eq 0 ]; then
declare -a det=("ctbDetectorServer" # no argument, all servers
"gotthardDetectorServer" declare -a det=${det_list[@]}
"gotthard2DetectorServer" echo "Compiling all servers"
"jungfrauDetectorServer" elif [ $# -eq 1 ] || [ $# -eq 2 ]; then
"mythen3DetectorServer" # 'all' servers
"moenchDetectorServer" 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 else
declare -a det=("${1}") echo -e "Too many arguments.$usage"
return -1
fi fi
declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK") 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 do
dir=${det[i]} dir=$i
file="${det[i]}_developer" file="${i}_developer"
echo -e "Compiling $dir [$file]" echo -e "Compiling $dir [$file]"
cd $dir cd $dir
make clean make clean
if make version; then if make version API_BRANCH=$branch; then
deterror[i]="OK" deterror[$idet]="OK"
else else
deterror[i]="FAIL" deterror[$idet]="FAIL"
fi fi
mv bin/$dir bin/$file mv bin/$dir bin/$file
git add -f bin/$file git add -f bin/$file
cp bin/$file /tftpboot/ cp bin/$file /tftpboot/
cd .. cd ..
echo -e "\n\n" echo -e "\n\n"
((++idet))
done done
echo -e "Results:" echo -e "Results:"
for ((i=0;i<${#det[@]};++i)) idet=0
for i in ${det[@]}
do do
printf "%s\t\t= %s\n" "${det[i]}" "${deterror[i]}" printf "%s\t\t= %s\n" "$i" "${deterror[$idet]}"
((++idet))
done done

View File

@ -1,32 +1,32 @@
# SPDX-License-Identifier: LGPL-3.0-or-other # SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package # 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)) echo -e "Compiling $dir [$file]"
do cd $dir
dir=${det[i]} make clean
file="${det[i]}_developer" if make version API_BRANCH=$branch; then
echo -e "Compiling $dir [$file]" deterror="OK"
cd $dir else
make clean deterror="FAIL"
if make version; then fi
deterror[i]="OK"
else mv bin/$dir bin/$file
deterror[i]="FAIL" git add -f bin/$file
fi cp bin/$file /tftpboot/
cd ..
mv bin/$dir bin/$file echo -e "\n\n"
git add -f bin/$file printf "Result:\t\t= %s\n" "${deterror}"
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

View File

@ -25,10 +25,11 @@ version: clean versioning $(PROGS)
boot: $(OBJS) boot: $(OBJS)
version_branch=$(API_BRANCH)
version_name=APICTB version_name=APICTB
version_path=slsDetectorServers/ctbDetectorServer version_path=slsDetectorServers/ctbDetectorServer
versioning: 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) $(PROGS): $(OBJS)

View File

@ -121,9 +121,10 @@ void basictests() {
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion(); 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 sw_fw_apiversion = 0;
int64_t client_sw_apiversion = getClientServerAPIVersion();
if (fwversion >= MIN_REQRD_VRSN_T_RD_API) if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getFirmwareAPIVersion(); sw_fw_apiversion = getFirmwareAPIVersion();
@ -136,15 +137,13 @@ void basictests() {
"Detector MAC Addr:\t\t 0x%llx\n\n" "Detector MAC Addr:\t\t 0x%llx\n\n"
"Firmware Version:\t\t 0x%llx\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" "F/w-S/w API Version:\t\t 0x%llx\n"
"Required Firmware Version:\t 0x%x\n" "Required Firmware Version:\t 0x%x\n"
"Client-Software API Version:\t 0x%llx\n"
"********************************************************\n", "********************************************************\n",
hversion, hsnumber, ipadd, (long long unsigned int)macadd, hversion, hsnumber, ipadd, (long long unsigned int)macadd,
(long long int)fwversion, (long long int)swversion, (long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
(long long int)sw_fw_apiversion, REQRD_FRMWR_VRSN, REQRD_FRMWR_VRSN));
(long long int)client_sw_apiversion));
#ifndef VIRTUAL #ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
@ -325,9 +324,7 @@ int testBus() {
/* Ids */ /* Ids */
uint64_t getServerVersion() { return APICTB; } void getServerVersion(char *version) { strcpy(version, APICTB); }
uint64_t getClientServerAPIVersion() { return APICTB; }
uint64_t getFirmwareVersion() { uint64_t getFirmwareVersion() {
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -25,10 +25,11 @@ version: clean versioning $(PROGS) #hv9m_blackfin_server
boot: $(OBJS) boot: $(OBJS)
version_branch=$(API_BRANCH)
version_name=APIEIGER version_name=APIEIGER
version_path=slsDetectorServers/eigerDetectorServer version_path=slsDetectorServers/eigerDetectorServer
versioning: 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) $(PROGS): $(OBJS)

View File

@ -117,9 +117,10 @@ void basictests() {
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion(); 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 sw_fw_apiversion = getFirmwareAPIVersion();
int64_t client_sw_apiversion = getClientServerAPIVersion();
LOG(logINFOBLUE, LOG(logINFOBLUE,
("**************************************************\n" ("**************************************************\n"
@ -127,16 +128,13 @@ void basictests() {
"Detector MAC Addr:\t\t 0x%llx\n" "Detector MAC Addr:\t\t 0x%llx\n"
"Firmware Version:\t\t %lld\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" "F/w-S/w API Version:\t\t %lld\n"
"Required Firmware Version:\t %d\n" "Required Firmware Version:\t %d\n"
"Client-Software API Version:\t 0x%llx\n"
"\n"
"********************************************************\n", "********************************************************\n",
(unsigned int)ipadd, (long long unsigned int)macadd, (unsigned int)ipadd, (long long unsigned int)macadd,
(long long int)fwversion, (long long int)swversion, (long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
(long long int)sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION, REQUIRED_FIRMWARE_VERSION));
(long long int)client_sw_apiversion));
// update default udpdstip and udpdstmac (1g is hardware ip and hardware // update default udpdstip and udpdstmac (1g is hardware ip and hardware
// mac) // mac)
@ -208,9 +206,7 @@ int getTestImageMode() { return eiger_virtual_test_mode; }
/* Ids */ /* Ids */
uint64_t getServerVersion() { return APIEIGER; } void getServerVersion(char *version) { strcpy(version, APIEIGER); }
uint64_t getClientServerAPIVersion() { return APIEIGER; }
u_int64_t getFirmwareVersion() { u_int64_t getFirmwareVersion() {
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -24,10 +24,11 @@ version: clean versioning $(PROGS)
boot: $(OBJS) boot: $(OBJS)
version_branch=$(API_BRANCH)
version_name=APIGOTTHARD2 version_name=APIGOTTHARD2
version_path=slsDetectorServers/gotthard2DetectorServer version_path=slsDetectorServers/gotthard2DetectorServer
versioning: 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) $(PROGS): $(OBJS)

View File

@ -0,0 +1 @@
1234

View File

@ -117,9 +117,10 @@ void basictests() {
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion(); 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 sw_fw_apiversion = getFirmwareAPIVersion();
int64_t client_sw_apiversion = getClientServerAPIVersion();
uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN; uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN;
LOG(logINFOBLUE, LOG(logINFOBLUE,
@ -130,15 +131,13 @@ void basictests() {
"Detector MAC Addr:\t\t 0x%llx\n\n" "Detector MAC Addr:\t\t 0x%llx\n\n"
"Firmware Version:\t\t 0x%llx\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" "F/w-S/w API Version:\t\t 0x%llx\n"
"Required Firmware Version:\t 0x%x\n" "Required Firmware Version:\t 0x%x\n"
"Client-Software API Version:\t 0x%llx\n"
"********************************************************\n", "********************************************************\n",
hversion, ipadd, (long long unsigned int)macadd, hversion, ipadd, (long long unsigned int)macadd,
(long long int)fwversion, (long long int)swversion, (long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
(long long int)sw_fw_apiversion, requiredFirmwareVersion, requiredFirmwareVersion));
(long long int)client_sw_apiversion));
#ifndef VIRTUAL #ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
@ -251,9 +250,7 @@ int testBus() {
/* Ids */ /* Ids */
uint64_t getServerVersion() { return APIGOTTHARD2; } void getServerVersion(char *version) { strcpy(version, APIGOTTHARD2); }
uint64_t getClientServerAPIVersion() { return APIGOTTHARD2; }
u_int64_t getFirmwareVersion() { u_int64_t getFirmwareVersion() {
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -23,10 +23,11 @@ version: clean versioning $(PROGS)
boot: $(OBJS) boot: $(OBJS)
version_branch=$(API_BRANCH)
version_name=APIGOTTHARD version_name=APIGOTTHARD
version_path=slsDetectorServers/gotthardDetectorServer version_path=slsDetectorServers/gotthardDetectorServer
versioning: 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) $(PROGS): $(OBJS)

View File

@ -107,8 +107,9 @@ void basictests() {
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion(); int64_t fwversion = getFirmwareVersion();
int64_t swversion = getServerVersion(); char swversion[MAX_STR_LENGTH] = {0};
int64_t client_sw_apiversion = getClientServerAPIVersion(); memset(swversion, 0, MAX_STR_LENGTH);
getServerVersion(swversion);
LOG(logINFOBLUE, LOG(logINFOBLUE,
("**************************************************\n" ("**************************************************\n"
@ -118,15 +119,13 @@ void basictests() {
"Detector MAC Addr : 0x%llx\n\n" "Detector MAC Addr : 0x%llx\n\n"
"Firmware Version : 0x%llx\n" "Firmware Version : 0x%llx\n"
"Software Version : 0x%llx\n" "Software Version : %s\n"
"Client-S/w API Version : 0x%llx\n"
"********************************************************\n", "********************************************************\n",
boardrev, boardrev,
ipadd, (long long unsigned int)macadd, ipadd, (long long unsigned int)macadd,
(long long int)fwversion, (long long int)swversion, (long long int)fwversion, swversion));
(long long int)client_sw_apiversion));
#ifndef VIRTUAL #ifndef VIRTUAL
if (!debugflag || updateFlag) { if (!debugflag || updateFlag) {
@ -270,9 +269,7 @@ int getTestImageMode() {
/* Ids */ /* Ids */
uint64_t getServerVersion() { return APIGOTTHARD; } void getServerVersion(char *version) { strcpy(version, APIGOTTHARD); }
uint64_t getClientServerAPIVersion() { return APIGOTTHARD; }
u_int64_t getFirmwareVersion() { u_int64_t getFirmwareVersion() {
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -24,10 +24,11 @@ version: clean versioning $(PROGS)
boot: $(OBJS) boot: $(OBJS)
version_branch=$(API_BRANCH)
version_name=APIJUNGFRAU version_name=APIJUNGFRAU
version_path=slsDetectorServers/jungfrauDetectorServer version_path=slsDetectorServers/jungfrauDetectorServer
versioning: 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) $(PROGS): $(OBJS)

View File

@ -0,0 +1,4 @@
#chip version version (multiplied by 10)
chipversion 11

View File

@ -102,9 +102,10 @@ void basictests() {
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion(); 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 sw_fw_apiversion = 0;
int64_t client_sw_apiversion = getClientServerAPIVersion();
uint32_t requiredFirmwareVersion = uint32_t requiredFirmwareVersion =
(isHardwareVersion2() ? REQRD_FRMWRE_VRSN_BOARD2 : REQRD_FRMWRE_VRSN); (isHardwareVersion2() ? REQRD_FRMWRE_VRSN_BOARD2 : REQRD_FRMWRE_VRSN);
@ -120,15 +121,13 @@ void basictests() {
"Detector MAC Addr:\t\t 0x%llx\n\n" "Detector MAC Addr:\t\t 0x%llx\n\n"
"Firmware Version:\t\t 0x%llx\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" "F/w-S/w API Version:\t\t 0x%llx\n"
"Required Firmware Version:\t 0x%x\n" "Required Firmware Version:\t 0x%x\n"
"Client-Software API Version:\t 0x%llx\n"
"********************************************************\n", "********************************************************\n",
hversion, hsnumber, ipadd, (long long unsigned int)macadd, hversion, hsnumber, ipadd, (long long unsigned int)macadd,
(long long int)fwversion, (long long int)swversion, (long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
(long long int)sw_fw_apiversion, requiredFirmwareVersion, requiredFirmwareVersion));
(long long int)client_sw_apiversion));
#ifndef VIRTUAL #ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
@ -257,9 +256,7 @@ int getTestImageMode() { return virtual_image_test_mode; }
/* Ids */ /* Ids */
uint64_t getServerVersion() { return APIJUNGFRAU; } void getServerVersion(char *version) { strcpy(version, APIJUNGFRAU); }
uint64_t getClientServerAPIVersion() { return APIJUNGFRAU; }
u_int64_t getFirmwareVersion() { u_int64_t getFirmwareVersion() {
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -25,10 +25,11 @@ version: clean versioning $(PROGS)
boot: $(OBJS) boot: $(OBJS)
version_branch=$(API_BRANCH)
version_name=APIMOENCH version_name=APIMOENCH
version_path=slsDetectorServers/moenchDetectorServer version_path=slsDetectorServers/moenchDetectorServer
versioning: 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) $(PROGS): $(OBJS)

View File

@ -125,9 +125,10 @@ void basictests() {
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion(); 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 sw_fw_apiversion = 0;
int64_t client_sw_apiversion = getClientServerAPIVersion();
if (fwversion >= MIN_REQRD_VRSN_T_RD_API) if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getFirmwareAPIVersion(); sw_fw_apiversion = getFirmwareAPIVersion();
@ -140,15 +141,13 @@ void basictests() {
"Detector MAC Addr:\t\t 0x%llx\n\n" "Detector MAC Addr:\t\t 0x%llx\n\n"
"Firmware Version:\t\t 0x%llx\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" "F/w-S/w API Version:\t\t 0x%llx\n"
"Required Firmware Version:\t 0x%x\n" "Required Firmware Version:\t 0x%x\n"
"Client-Software API Version:\t 0x%llx\n"
"********************************************************\n", "********************************************************\n",
hversion, hsnumber, ipadd, (long long unsigned int)macadd, hversion, hsnumber, ipadd, (long long unsigned int)macadd,
(long long int)fwversion, (long long int)swversion, (long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
(long long int)sw_fw_apiversion, REQRD_FRMWR_VRSN, REQRD_FRMWR_VRSN));
(long long int)client_sw_apiversion));
#ifndef VIRTUAL #ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
@ -329,9 +328,7 @@ int testBus() {
/* Ids */ /* Ids */
uint64_t getServerVersion() { return APIMOENCH; } void getServerVersion(char *version) { strcpy(version, APIMOENCH); }
uint64_t getClientServerAPIVersion() { return APIMOENCH; }
uint64_t getFirmwareVersion() { uint64_t getFirmwareVersion() {
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -25,10 +25,11 @@ version: clean versioning $(PROGS)
boot: $(OBJS) boot: $(OBJS)
version_branch=$(API_BRANCH)
version_name=APIMYTHEN3 version_name=APIMYTHEN3
version_path=slsDetectorServers/mythen3DetectorServer version_path=slsDetectorServers/mythen3DetectorServer
versioning: 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) $(PROGS): $(OBJS)

View File

@ -0,0 +1 @@
0

View File

@ -110,10 +110,10 @@ void basictests() {
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion(); 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 sw_fw_apiversion = getFirmwareAPIVersion();
;
int64_t client_sw_apiversion = getClientServerAPIVersion();
uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN; uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN;
LOG(logINFOBLUE, LOG(logINFOBLUE,
@ -124,15 +124,13 @@ void basictests() {
"Detector MAC Addr:\t\t 0x%llx\n\n" "Detector MAC Addr:\t\t 0x%llx\n\n"
"Firmware Version:\t\t 0x%llx\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" "F/w-S/w API Version:\t\t 0x%llx\n"
"Required Firmware Version:\t 0x%x\n" "Required Firmware Version:\t 0x%x\n"
"Client-Software API Version:\t 0x%llx\n"
"********************************************************\n", "********************************************************\n",
hversion, ipadd, (long long unsigned int)macadd, hversion, ipadd, (long long unsigned int)macadd,
(long long int)fwversion, (long long int)swversion, (long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
(long long int)sw_fw_apiversion, requiredFirmwareVersion, requiredFirmwareVersion));
(long long int)client_sw_apiversion));
#ifndef VIRTUAL #ifndef VIRTUAL
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
@ -245,9 +243,7 @@ int testBus() {
/* Ids */ /* Ids */
uint64_t getServerVersion() { return APIMYTHEN3; } void getServerVersion(char *version) { strcpy(version, APIMYTHEN3); }
uint64_t getClientServerAPIVersion() { return APIMYTHEN3; }
u_int64_t getFirmwareVersion() { u_int64_t getFirmwareVersion() {
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -75,8 +75,7 @@ int getTestImageMode();
#endif #endif
// Ids // Ids
u_int64_t getServerVersion(); void getServerVersion(char *version);
u_int64_t getClientServerAPIVersion();
u_int64_t getFirmwareVersion(); u_int64_t getFirmwareVersion();
u_int64_t getFirmwareAPIVersion(); u_int64_t getFirmwareAPIVersion();
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \ #if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \

View File

@ -127,7 +127,7 @@ int temp_control(int);
int temp_event(int); int temp_event(int);
int auto_comp_disable(int); int auto_comp_disable(int);
int storage_cell_start(int); int storage_cell_start(int);
int check_version(int); int initial_checks(int);
int software_trigger(int); int software_trigger(int);
int led(int); int led(int);
int digital_io_delay(int); int digital_io_delay(int);

View File

@ -55,7 +55,8 @@ int main(int argc, char *argv[]) {
debugflag = 0; debugflag = 0;
updateFlag = 0; updateFlag = 0;
checkModuleFlag = 1; checkModuleFlag = 1;
int version = 0; char version[MAX_STR_LENGTH] = {0};
memset(version, 0, MAX_STR_LENGTH);
ignoreConfigFileFlag = 0; ignoreConfigFileFlag = 0;
#if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \ #if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
defined(MYTHEN3D) defined(MYTHEN3D)
@ -142,22 +143,21 @@ int main(int argc, char *argv[]) {
case 'v': case 'v':
#ifdef GOTTHARDD #ifdef GOTTHARDD
version = APIGOTTHARD; strcpy(version, APIGOTTHARD);
#elif EIGERD #elif EIGERD
version = APIEIGER; strcpy(version, APIEIGER);
#elif JUNGFRAUD #elif JUNGFRAUD
version = APIJUNGFRAU; strcpy(version, APIJUNGFRAU);
#elif CHIPTESTBOARDD #elif CHIPTESTBOARDD
version = APICTB; strcpy(version, APICTB);
#elif MOENCHD #elif MOENCHD
version = APIMOENCH; strcpy(version, APIMOENCH);
#elif MYTHEN3D #elif MYTHEN3D
version = APIMYTHEN3; strcpy(version, APIMYTHEN3);
#elif GOTTHARD2D #elif GOTTHARD2D
version = APIGOTTHARD2; strcpy(version, APIGOTTHARD2);
#endif #endif
LOG(logINFO, ("SLS Detector Server Version: %s (0x%x)\n", GITBRANCH, LOG(logINFO, ("SLS Detector Server Version: %s\n", version));
version));
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
case 'p': case 'p':

View File

@ -84,7 +84,7 @@ int updateModeAllowedFunction(int file_des) {
F_EXEC_COMMAND, F_GET_DETECTOR_TYPE, F_GET_FIRMWARE_VERSION, F_EXEC_COMMAND, F_GET_DETECTOR_TYPE, F_GET_FIRMWARE_VERSION,
F_GET_SERVER_VERSION, F_GET_SERIAL_NUMBER, F_WRITE_REGISTER, F_GET_SERVER_VERSION, F_GET_SERIAL_NUMBER, F_WRITE_REGISTER,
F_READ_REGISTER, F_LOCK_SERVER, F_GET_LAST_CLIENT_IP, 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_REBOOT_CONTROLLER, F_GET_KERNEL_VERSION, F_UPDATE_KERNEL,
F_UPDATE_DETECTOR_SERVER, F_GET_UPDATE_MODE, F_SET_UPDATE_MODE, F_UPDATE_DETECTOR_SERVER, F_GET_UPDATE_MODE, F_SET_UPDATE_MODE,
F_GET_NUM_CHANNELS, F_GET_NUM_INTERFACES, F_ACTIVATE}; 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_TEMP_EVENT] = &temp_event;
flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable; flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable;
flist[F_STORAGE_CELL_START] = &storage_cell_start; 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_SOFTWARE_TRIGGER] = &software_trigger;
flist[F_LED] = &led; flist[F_LED] = &led;
flist[F_DIGITAL_IO_DELAY] = &digital_io_delay; 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) { int get_server_version(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int64_t retval = -1; char retvals[MAX_STR_LENGTH];
retval = getServerVersion(); memset(retvals, 0, MAX_STR_LENGTH);
LOG(logDEBUG1, ("server version retval: 0x%llx\n", (long long int)retval)); getServerVersion(retvals);
return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); LOG(logDEBUG1, ("server version retval: %s\n", retvals));
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
} }
int get_serial_number(int file_des) { 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)); return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
} }
int check_version(int file_des) { int initial_checks(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); 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 // check software- firmware compatibility and basic tests
LOG(logDEBUG1, ("Checking software-firmware compatibility and basic " LOG(logDEBUG1, ("Checking software-firmware compatibility and basic "
@ -4107,39 +4104,6 @@ int check_version(int file_des) {
LOG(logERROR, (mess)); 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); return Server_SendResult(file_des, INT32, NULL, 0);
} }

View File

@ -74,11 +74,11 @@ class Detector {
/** package git branch */ /** package git branch */
std::string getPackageVersion() const; std::string getPackageVersion() const;
int64_t getClientVersion() const; std::string getClientVersion() const;
Result<int64_t> getFirmwareVersion(Positions pos = {}) const; Result<int64_t> getFirmwareVersion(Positions pos = {}) const;
Result<int64_t> getDetectorServerVersion(Positions pos = {}) const; Result<std::string> getDetectorServerVersion(Positions pos = {}) const;
Result<std::string> getKernelVersion(Positions pos = {}) const; Result<std::string> getKernelVersion(Positions pos = {}) const;
@ -89,7 +89,7 @@ class Detector {
* streamed out in the UDP header of the detector.*/ * streamed out in the UDP header of the detector.*/
Result<int> getModuleId(Positions pos = {}) const; Result<int> getModuleId(Positions pos = {}) const;
Result<int64_t> getReceiverVersion(Positions pos = {}) const; Result<std::string> getReceiverVersion(Positions pos = {}) const;
/** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2, /** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2,
* CHIPTESTBOARD */ * CHIPTESTBOARD */

View File

@ -37,9 +37,7 @@ int main(int argc, char *argv[]) {
// Check for --version in the arguments // Check for --version in the arguments
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
if (!(strcmp(argv[i], "--version")) || !(strcmp(argv[i], "-v"))) { if (!(strcmp(argv[i], "--version")) || !(strcmp(argv[i], "-v"))) {
int64_t tempval = APILIB; std::cout << argv[0] << " " << APILIB << std::endl;
std::cout << argv[0] << " " << GITBRANCH << " (0x" << std::hex
<< tempval << ")" << std::endl;
return 0; return 0;
} }
} }

View File

@ -277,21 +277,20 @@ std::string CmdProxy::Versions(int action) {
auto t = det->getFirmwareVersion(std::vector<int>{det_id}); auto t = det->getFirmwareVersion(std::vector<int>{det_id});
os << "\nDetector Type: " << OutString(det->getDetectorType()) os << "\nDetector Type: " << OutString(det->getDetectorType())
<< "\nPackage Version: " << det->getPackageVersion() << std::hex << "\nPackage Version: " << det->getPackageVersion() << std::hex
<< "\nClient Version: 0x" << det->getClientVersion(); << "\nClient Version: " << det->getClientVersion();
if (det->getDetectorType().squash() == defs::EIGER) { if (det->getDetectorType().squash() == defs::EIGER) {
os << "\nFirmware Version: " << OutString(t); os << "\nFirmware Version: " << OutString(t);
} else { } else {
os << "\nFirmware Version: " << OutStringHex(t); os << "\nFirmware Version: " << OutStringHex(t);
} }
os << "\nDetector Server Version: " os << "\nDetector Server Version: "
<< OutStringHex( << OutString(
det->getDetectorServerVersion(std::vector<int>{det_id})); det->getDetectorServerVersion(std::vector<int>{det_id}));
os << "\nDetector Server Version: " os << "\nDetector Kernel Version: "
<< OutString(det->getKernelVersion({std::vector<int>{det_id}})); << OutString(det->getKernelVersion({std::vector<int>{det_id}}));
if (det->getUseReceiverFlag().squash(true)) { if (det->getUseReceiverFlag().squash(true)) {
os << "\nReceiver Version: " os << "\nReceiver Version: "
<< OutStringHex( << OutString(det->getReceiverVersion(std::vector<int>{det_id}));
det->getReceiverVersion(std::vector<int>{det_id}));
} }
os << std::dec << '\n'; os << std::dec << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
@ -324,12 +323,12 @@ std::string CmdProxy::ClientVersion(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { 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) { } else if (action == defs::GET_ACTION) {
if (!args.empty()) { if (!args.empty()) {
WrongNumberOfParameters(0); WrongNumberOfParameters(0);
} }
os << ToStringHex(det->getClientVersion()) << '\n'; os << det->getClientVersion() << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
throw RuntimeError("cannot put"); throw RuntimeError("cannot put");
} else { } else {
@ -2563,8 +2562,7 @@ std::string CmdProxy::AdcVpp(int action) {
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of " 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 -> " "ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> "
"2V. " "2V. \n\tAdvanced User function!\n"
"\n\tAdvanced User function!\n"
<< '\n'; << '\n';
return os.str(); return os.str();
} }

View File

@ -1232,16 +1232,14 @@ class CmdProxy {
"[fname]\n\tSets detector measurement parameters to those contained in " "[fname]\n\tSets detector measurement parameters to those contained in "
"fname. Set up per measurement."); "fname. Set up per measurement.");
GET_COMMAND_HEX( GET_COMMAND(detectorserverversion, getDetectorServerVersion,
detectorserverversion, getDetectorServerVersion, "\n\tOn-board detector server software version");
"\n\tOn-board detector server software version in format [0xYYMMDD].");
GET_COMMAND( GET_COMMAND(
kernelversion, getKernelVersion, kernelversion, getKernelVersion,
"\n\tGet kernel version on the detector including time and date."); "\n\tGet kernel version on the detector including time and date.");
GET_COMMAND_HEX(rx_version, getReceiverVersion, GET_COMMAND(rx_version, getReceiverVersion, "\n\tReceiver version");
"\n\tReceiver version in format [0xYYMMDD].");
GET_COMMAND_HEX(serialnumber, getSerialNumber, GET_COMMAND_HEX(serialnumber, getSerialNumber,
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]" "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]"

View File

@ -9,6 +9,7 @@
#include "DetectorImpl.h" #include "DetectorImpl.h"
#include "Module.h" #include "Module.h"
#include "sls/Pattern.h" #include "sls/Pattern.h"
#include "sls/Version.h"
#include "sls/container_utils.h" #include "sls/container_utils.h"
#include "sls/file_utils.h" #include "sls/file_utils.h"
#include "sls/logger.h" #include "sls/logger.h"
@ -112,15 +113,18 @@ void Detector::setVirtualDetectorServers(int numServers, int startingPort) {
int Detector::getShmId() const { return pimpl->getDetectorIndex(); } 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<int64_t> Detector::getFirmwareVersion(Positions pos) const { Result<int64_t> Detector::getFirmwareVersion(Positions pos) const {
return pimpl->Parallel(&Module::getFirmwareVersion, pos); return pimpl->Parallel(&Module::getFirmwareVersion, pos);
} }
Result<int64_t> Detector::getDetectorServerVersion(Positions pos) const { Result<std::string> Detector::getDetectorServerVersion(Positions pos) const {
return pimpl->Parallel(&Module::getDetectorServerVersion, pos); return pimpl->Parallel(&Module::getDetectorServerVersion, pos);
} }
@ -136,7 +140,7 @@ Result<int> Detector::getModuleId(Positions pos) const {
return pimpl->Parallel(&Module::getModuleId, pos); return pimpl->Parallel(&Module::getModuleId, pos);
} }
Result<int64_t> Detector::getReceiverVersion(Positions pos) const { Result<std::string> Detector::getReceiverVersion(Positions pos) const {
return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos); return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos);
} }
@ -1123,14 +1127,16 @@ Result<std::string> Detector::getRxHostname(Positions pos) const {
} }
void Detector::setRxHostname(const std::string &receiver, Positions pos) { void Detector::setRxHostname(const std::string &receiver, Positions pos) {
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver); pimpl->Parallel(&Module::setReceiverHostname, pos, receiver,
pimpl->getInitialChecks());
updateRxRateCorrections(); updateRxRateCorrections();
} }
void Detector::setRxHostname(const std::vector<std::string> &name) { void Detector::setRxHostname(const std::vector<std::string> &name) {
// set all to same rx_hostname // set all to same rx_hostname
if (name.size() == 1) { if (name.size() == 1) {
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]); pimpl->Parallel(&Module::setReceiverHostname, {}, name[0],
pimpl->getInitialChecks());
} else { } else {
if ((int)name.size() != size()) { if ((int)name.size() != size()) {
throw RuntimeError( throw RuntimeError(
@ -1139,7 +1145,8 @@ void Detector::setRxHostname(const std::vector<std::string> &name) {
} }
// set each rx_hostname // set each rx_hostname
for (int idet = 0; idet < size(); ++idet) { for (int idet = 0; idet < size(); ++idet) {
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]); pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet],
pimpl->getInitialChecks());
} }
} }
updateRxRateCorrections(); updateRxRateCorrections();

View File

@ -4,6 +4,7 @@
#include "SharedMemory.h" #include "SharedMemory.h"
#include "sls/ClientSocket.h" #include "sls/ClientSocket.h"
#include "sls/ToString.h" #include "sls/ToString.h"
#include "sls/Version.h"
#include "sls/bit_utils.h" #include "sls/bit_utils.h"
#include "sls/container_utils.h" #include "sls/container_utils.h"
#include "sls/file_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); auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.close(); client.close();
try { try {
initialDetectorServerChecks();
checkDetectorVersionCompatibility(); checkDetectorVersionCompatibility();
LOG(logINFO) << "Module Version Compatibility - Success"; LOG(logINFO) << "Module Version Compatibility - Success";
} catch (const DetectorError &e) { } catch (const DetectorError &e) {
@ -90,8 +92,21 @@ int64_t Module::getFirmwareVersion() const {
return sendToDetector<int64_t>(F_GET_FIRMWARE_VERSION); return sendToDetector<int64_t>(F_GET_FIRMWARE_VERSION);
} }
int64_t Module::getDetectorServerVersion() const { std::string Module::getControlServerLongVersion() const {
return sendToDetector<int64_t>(F_GET_SERVER_VERSION); 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 { std::string Module::getKernelVersion() const {
@ -106,11 +121,15 @@ int64_t Module::getSerialNumber() const {
int Module::getModuleId() const { return sendToDetector<int>(F_GET_MODULE_ID); } int Module::getModuleId() const { return sendToDetector<int>(F_GET_MODULE_ID); }
int64_t Module::getReceiverSoftwareVersion() const { std::string Module::getReceiverLongVersion() const {
if (shm()->useReceiverFlag) { char retval[MAX_STR_LENGTH]{};
return sendToReceiver<int64_t>(F_GET_RECEIVER_VERSION); sendToReceiver(F_GET_RECEIVER_VERSION, nullptr, retval);
} return retval;
return -1; }
std::string Module::getReceiverSoftwareVersion() const {
Version v(getReceiverLongVersion());
return v.concise();
} }
// static function // static function
@ -1279,7 +1298,8 @@ std::string Module::getReceiverHostname() const {
return std::string(shm()->rxHostname); 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; LOG(logDEBUG1) << "Setting up Receiver hostname with " << receiverIP;
if (getRunStatus() == RUNNING) { if (getRunStatus() == RUNNING) {
@ -1303,8 +1323,17 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
} }
strcpy_safe(shm()->rxHostname, host.c_str()); strcpy_safe(shm()->rxHostname, host.c_str());
shm()->useReceiverFlag = true; 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 // populate parameters from detector
rxParameters retval; rxParameters retval;
sendToDetector(F_GET_RECEIVER_PARAMETERS, nullptr, retval); sendToDetector(F_GET_RECEIVER_PARAMETERS, nullptr, retval);
@ -3216,41 +3245,95 @@ void Module::initializeModuleStructure(detectorType type) {
shm()->nDacs = parameters.nDacs; shm()->nDacs = parameters.nDacs;
} }
void Module::initialDetectorServerChecks() {
sendToDetector(F_INITIAL_CHECKS);
sendToDetectorStop(F_INITIAL_CHECKS);
}
void Module::checkDetectorVersionCompatibility() { 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) { switch (shm()->detType) {
case EIGER: case EIGER:
arg = APIEIGER; return APIEIGER;
break;
case JUNGFRAU: case JUNGFRAU:
arg = APIJUNGFRAU; return APIJUNGFRAU;
break;
case GOTTHARD: case GOTTHARD:
arg = APIGOTTHARD; return APIGOTTHARD;
break;
case CHIPTESTBOARD: case CHIPTESTBOARD:
arg = APICTB; return APICTB;
break;
case MOENCH: case MOENCH:
arg = APIMOENCH; return APIMOENCH;
break;
case MYTHEN3: case MYTHEN3:
arg = APIMYTHEN3; return APIMYTHEN3;
break;
case GOTTHARD2: case GOTTHARD2:
arg = APIGOTTHARD2; return APIGOTTHARD2;
break;
default: default:
throw NotImplementedError( 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() { void Module::checkReceiverVersionCompatibility() {
// TODO! Verify that this works as intended when version don't match // rxr and client (sem. versioning)
sendToReceiver(F_RECEIVER_CHECK_VERSION, int64_t(APIRECEIVER), nullptr); 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) { void Module::setModule(sls_detector_module &module, bool trimbits) {

View File

@ -90,11 +90,13 @@ class Module : public virtual slsDetectorDefs {
void setHostname(const std::string &hostname, const bool initialChecks); void setHostname(const std::string &hostname, const bool initialChecks);
int64_t getFirmwareVersion() const; int64_t getFirmwareVersion() const;
int64_t getDetectorServerVersion() const; std::string getControlServerLongVersion() const;
std::string getStopServerLongVersion() const;
std::string getDetectorServerVersion() const;
std::string getKernelVersion() const; std::string getKernelVersion() const;
int64_t getSerialNumber() const; int64_t getSerialNumber() const;
int getModuleId() const; int getModuleId() const;
int64_t getReceiverSoftwareVersion() const; std::string getReceiverSoftwareVersion() const;
static detectorType static detectorType
getTypeFromDetector(const std::string &hostname, getTypeFromDetector(const std::string &hostname,
int cport = DEFAULT_TCP_CNTRL_PORTNO); int cport = DEFAULT_TCP_CNTRL_PORTNO);
@ -276,7 +278,8 @@ class Module : public virtual slsDetectorDefs {
* ************************************************/ * ************************************************/
bool getUseReceiverFlag() const; bool getUseReceiverFlag() const;
std::string getReceiverHostname() const; std::string getReceiverHostname() const;
void setReceiverHostname(const std::string &receiver); void setReceiverHostname(const std::string &receiver,
const bool initialChecks);
int getReceiverPort() const; int getReceiverPort() const;
int setReceiverPort(int port_number); int setReceiverPort(int port_number);
int getReceiverFifoDepth() const; int getReceiverFifoDepth() const;
@ -600,6 +603,8 @@ class Module : public virtual slsDetectorDefs {
int64_t getMeasurementTime() const; int64_t getMeasurementTime() const;
private: private:
std::string getReceiverLongVersion() const;
void checkArgs(const void *args, size_t args_size, void *retval, void checkArgs(const void *args, size_t args_size, void *retval,
size_t retval_size) const; size_t retval_size) const;
@ -737,6 +742,8 @@ class Module : public virtual slsDetectorDefs {
Called when new shared memory is created */ Called when new shared memory is created */
void initializeModuleStructure(detectorType type); void initializeModuleStructure(detectorType type);
void initialDetectorServerChecks();
const std::string getDetectorAPI() const;
void checkDetectorVersionCompatibility(); void checkDetectorVersionCompatibility();
void checkReceiverVersionCompatibility(); void checkReceiverVersionCompatibility();
void setModule(sls_detector_module &module, bool trimbits = true); void setModule(sls_detector_module &module, bool trimbits = true);

View File

@ -36,7 +36,7 @@ class Receiver : private virtual slsDetectorDefs {
* get get Receiver Version * get get Receiver Version
\returns id \returns id
*/ */
int64_t getReceiverVersion(); std::string getReceiverVersion();
/** /**
* Start Acquisition Call back (slsMultiReceiver writes data if file write * Start Acquisition Call back (slsMultiReceiver writes data if file write

View File

@ -51,7 +51,7 @@ ClientInterface::ClientInterface(int portNumber)
make_unique<std::thread>(&ClientInterface::startTCPServer, this); make_unique<std::thread>(&ClientInterface::startTCPServer, this);
} }
int64_t ClientInterface::getReceiverVersion() { return APIRECEIVER; } std::string ClientInterface::getReceiverVersion() { return APIRECEIVER; }
/***callback functions***/ /***callback functions***/
void ClientInterface::registerCallBackStartAcquisition( 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_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_SET_RECEIVER_FRAMES_PER_FILE] = &ClientInterface::set_frames_per_file;
flist[F_GET_RECEIVER_FRAMES_PER_FILE] = &ClientInterface::get_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_SET_RECEIVER_DISCARD_POLICY] = &ClientInterface::set_discard_policy;
flist[F_GET_RECEIVER_DISCARD_POLICY] = &ClientInterface::get_discard_policy; flist[F_GET_RECEIVER_DISCARD_POLICY] = &ClientInterface::get_discard_policy;
flist[F_SET_RECEIVER_PADDING] = &ClientInterface::set_padding_enable; 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) { 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) { int ClientInterface::setup_receiver(Interface &socket) {
@ -1218,33 +1219,6 @@ int ClientInterface::get_frames_per_file(Interface &socket) {
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::check_version_compatibility(Interface &socket) {
auto arg = socket.Receive<int64_t>();
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) { int ClientInterface::set_discard_policy(Interface &socket) {
auto index = socket.Receive<int>(); auto index = socket.Receive<int>();
if (index < 0 || index > NUM_DISCARD_POLICIES) { if (index < 0 || index > NUM_DISCARD_POLICIES) {

View File

@ -30,7 +30,7 @@ class ClientInterface : private virtual slsDetectorDefs {
public: public:
virtual ~ClientInterface(); virtual ~ClientInterface();
ClientInterface(int portNumber = -1); ClientInterface(int portNumber = -1);
int64_t getReceiverVersion(); std::string getReceiverVersion();
//***callback functions*** //***callback functions***
/** params: file path, file name, file index, image size */ /** 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 get_real_udp_socket_buffer_size(ServerInterface &socket);
int set_frames_per_file(ServerInterface &socket); int set_frames_per_file(ServerInterface &socket);
int get_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 set_discard_policy(ServerInterface &socket);
int get_discard_policy(ServerInterface &socket); int get_discard_policy(ServerInterface &socket);
int set_padding_enable(ServerInterface &socket); int set_padding_enable(ServerInterface &socket);

View File

@ -71,8 +71,7 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
break; break;
case 'v': case 'v':
std::cout << "SLS Receiver Version: " << GITBRANCH << " (0x" std::cout << "SLS Receiver Version: " << APIRECEIVER << std::endl;
<< std::hex << APIRECEIVER << ")" << std::endl;
LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]"; LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]";
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
@ -124,7 +123,7 @@ Receiver::Receiver(int tcpip_port_no) {
tcpipInterface = make_unique<ClientInterface>(tcpip_port_no); tcpipInterface = make_unique<ClientInterface>(tcpip_port_no);
} }
int64_t Receiver::getReceiverVersion() { std::string Receiver::getReceiverVersion() {
return tcpipInterface->getReceiverVersion(); return tcpipInterface->getReceiverVersion();
} }

View File

@ -13,6 +13,7 @@ set(SOURCES
src/UdpRxSocket.cpp src/UdpRxSocket.cpp
src/sls_detector_exceptions.cpp src/sls_detector_exceptions.cpp
src/md5_helper.cpp src/md5_helper.cpp
src/Version.cpp
) )
# Header files to install as a part of the library # 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/bit_utils.h
include/sls/md5.h include/sls/md5.h
include/sls/md5_helper.h include/sls/md5_helper.h
include/sls/Version.h
) )
endif() endif()

View File

@ -0,0 +1,33 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include <stdint.h>
#include <string>
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

View File

@ -107,7 +107,7 @@ enum detFuncs {
F_TEMP_EVENT, F_TEMP_EVENT,
F_AUTO_COMP_DISABLE, F_AUTO_COMP_DISABLE,
F_STORAGE_CELL_START, F_STORAGE_CELL_START,
F_CHECK_VERSION, F_INITIAL_CHECKS,
F_SOFTWARE_TRIGGER, F_SOFTWARE_TRIGGER,
F_LED, F_LED,
F_DIGITAL_IO_DELAY, F_DIGITAL_IO_DELAY,
@ -339,7 +339,6 @@ enum detFuncs {
F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE,
F_SET_RECEIVER_FRAMES_PER_FILE, F_SET_RECEIVER_FRAMES_PER_FILE,
F_GET_RECEIVER_FRAMES_PER_FILE, F_GET_RECEIVER_FRAMES_PER_FILE,
F_RECEIVER_CHECK_VERSION,
F_SET_RECEIVER_DISCARD_POLICY, F_SET_RECEIVER_DISCARD_POLICY,
F_GET_RECEIVER_DISCARD_POLICY, F_GET_RECEIVER_DISCARD_POLICY,
F_SET_RECEIVER_PADDING, F_SET_RECEIVER_PADDING,
@ -488,7 +487,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_TEMP_EVENT: return "F_TEMP_EVENT"; case F_TEMP_EVENT: return "F_TEMP_EVENT";
case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE"; case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE";
case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START"; 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_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
case F_LED: return "F_LED"; case F_LED: return "F_LED";
case F_DIGITAL_IO_DELAY: return "F_DIGITAL_IO_DELAY"; 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_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_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_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_SET_RECEIVER_DISCARD_POLICY: return "F_SET_RECEIVER_DISCARD_POLICY";
case F_GET_RECEIVER_DISCARD_POLICY: return "F_GET_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"; case F_SET_RECEIVER_PADDING: return "F_SET_RECEIVER_PADDING";

View File

@ -1,14 +1,13 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */ /** API versions */
#define GITBRANCH "developer" #define RELEASE "developer"
#define APILIB 0x220609 #define APICTB "developer 0x221108"
#define APIRECEIVER 0x220609 #define APIGOTTHARD "developer 0x221108"
#define APIGUI 0x220609 #define APIGOTTHARD2 "developer 0x221108"
#define APICTB 0x221018 #define APIJUNGFRAU "developer 0x221108"
#define APIGOTTHARD 0x221018 #define APIMYTHEN3 "developer 0x221108"
#define APIGOTTHARD2 0x221018 #define APIMOENCH "developer 0x221108"
#define APIJUNGFRAU 0x221018 #define APIEIGER "developer 0x221108"
#define APIMOENCH 0x221018 #define APILIB "developer 0x221108"
#define APIMYTHEN3 0x221107 #define APIRECEIVER "developer 0x221108"
#define APIEIGER 0x221107

View File

@ -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 <sstream>
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

View File

@ -1,8 +1,9 @@
# SPDX-License-Identifier: LGPL-3.0-or-other # SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package # 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 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] return [-1]
fi fi
@ -12,6 +13,11 @@ API_DIR=$PACKAGE_DIR/$2
API_FILE=$PACKAGE_DIR/slsSupportLib/include/sls/versionAPI.h API_FILE=$PACKAGE_DIR/slsSupportLib/include/sls/versionAPI.h
CURR_DIR=$PWD CURR_DIR=$PWD
if [ ! -d "$API_DIR" ]; then
echo "[API_DIR] does not exist. $usage"
return [-1]
fi
#go to directory #go to directory
cd $API_DIR cd $API_DIR
@ -38,8 +44,22 @@ API_DATE=${API_DATE:2:6}
API_DATE=${API_DATE/#/0x} API_DATE=${API_DATE/#/0x}
echo "date="$API_DATE 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 #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 #go back to original directory
cd $CURR_DIR cd $CURR_DIR

View File

@ -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

59
updateClientAPIVersion.sh Executable file
View File

@ -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

15
updateReleaseVersion.sh Normal file
View File

@ -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