slsReceiver, slsDetector, eiger and jungfrau server: client checks firmware and software an dreceiver compatibility for each time shared memory is cleaned up

This commit is contained in:
maliakal_d 2018-05-28 19:11:34 +02:00
parent 4d4e4a4ce7
commit cf8b0de433
36 changed files with 633 additions and 105 deletions

View File

@ -51,6 +51,7 @@
#define PREPARE_ACQUISITION 0x0000100000000000ULL #define PREPARE_ACQUISITION 0x0000100000000000ULL
#define CLEANUP_ACQUISITION 0x0000080000000000ULL #define CLEANUP_ACQUISITION 0x0000080000000000ULL
#define REGISER_WRITE_READ 0x0000040000000000ULL #define REGISER_WRITE_READ 0x0000040000000000ULL
#define VERSION_COMPATIBILITY 0x0000020000000000ULL
// 0xFFFFFF0000000000ULL // 0xFFFFFF0000000000ULL
// 0x000000FFFFFFFFFFULL // 0x000000FFFFFFFFFFULL
@ -170,6 +171,9 @@ public:
if(slsErrorMask&REGISER_WRITE_READ) if(slsErrorMask&REGISER_WRITE_READ)
retval.append("Could not read/write register in detector\n"); retval.append("Could not read/write register in detector\n");
if(slsErrorMask&VERSION_COMPATIBILITY)
retval.append("Incompatible versions with detector or receiver. Please check log for more details.\n");
if(slsErrorMask&COULD_NOT_CONFIGURE_MAC) if(slsErrorMask&COULD_NOT_CONFIGURE_MAC)

View File

@ -291,7 +291,9 @@ enum idMode{
DETECTOR_SOFTWARE_VERSION, /**<return detector system software version */ DETECTOR_SOFTWARE_VERSION, /**<return detector system software version */
THIS_SOFTWARE_VERSION, /**<return this software version */ THIS_SOFTWARE_VERSION, /**<return this software version */
RECEIVER_VERSION, /**<return receiver software version */ RECEIVER_VERSION, /**<return receiver software version */
SOFTWARE_FIRMWARE_API_VERSION /** return software firmware API version **/ SOFTWARE_FIRMWARE_API_VERSION, /** return software firmware API version **/
CLIENT_SOFTWARE_API_VERSION, /** return detector software and client api version */
CLIENT_RECEIVER_API_VERSION /** return client and receiver api version */
}; };
/** /**
detector digital test modes detector digital test modes

View File

@ -119,6 +119,8 @@ enum detFuncs{
F_AUTO_COMP_DISABLE, /** < auto comp disable mode */ F_AUTO_COMP_DISABLE, /** < auto comp disable mode */
F_STORAGE_CELL_START, /** < storage cell start */ F_STORAGE_CELL_START, /** < storage cell start */
F_CHECK_VERSION, /** < check version compatibility */
/* Always append functions hereafter!!! */ /* Always append functions hereafter!!! */
/* Always append functions before!!! */ /* Always append functions before!!! */

View File

@ -1,5 +1,5 @@
/** API versions */ /** API versions */
#define APIRECEIVER 0x20170101 #define APIRECEIVER 0x180517
#define APIEIGER 0x20170101 #define APIEIGER 0x180523
#define APIJUNGFRAU 0x20170101 #define APIJUNGFRAU 0x180523
#define APIGOTTHARD 0x20170101 #define APIGOTTHARD 0x20170101

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: cb635d800a5e1de6cf3330f03a98ffc382879cf3 Repsitory UUID: 4d4e4a4ce7a91af094251ed0903575ba7e73ef5f
Revision: 339 Revision: 341
Branch: mergevirtual Branch: versioning
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3832 Last Changed Rev: 3847
Last Changed Date: 2018-05-23 11:11:12.000000002 +0200 ./Makefile.virtual Last Changed Date: 2018-05-28 18:02:50.000000002 +0200 ./xparameters.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "cb635d800a5e1de6cf3330f03a98ffc382879cf3" #define GITREPUUID "4d4e4a4ce7a91af094251ed0903575ba7e73ef5f"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3832 #define GITREV 0x3847
#define GITDATE 0x20180523 #define GITDATE 0x20180528
#define GITBRANCH "mergevirtual" #define GITBRANCH "versioning"

View File

@ -14,6 +14,7 @@
#include "gitInfoEiger.h" #include "gitInfoEiger.h"
#include "FebControl.h" #include "FebControl.h"
#include "Beb.h" #include "Beb.h"
#include "versionAPI.h"
#endif #endif
int default_tau_from_file= -1; int default_tau_from_file= -1;
@ -89,18 +90,32 @@ int normal = 0;
uint32_t detid = 0; uint32_t detid = 0;
#endif #endif
/* basic tests */ /* basic tests */
int firmware_compatibility = OK;
int firmware_check_done = 0;
char firmware_message[MAX_STR_LENGTH];
int isFirmwareCheckDone() {
return firmware_check_done;
}
int getFirmwareCheckResult(char** mess) {
*mess = firmware_message;
return firmware_compatibility;
}
void checkFirmwareCompatibility(int flag){ void checkFirmwareCompatibility(int flag){
firmware_compatibility = OK;
firmware_check_done = 0;
memset(firmware_message, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
cprintf(BLUE,"\n\n" cprintf(BLUE,"\n\n"
"********************************************************\n" "********************************************************\n"
"***************** EIGER Virtual Server *****************\n" "***************** EIGER Virtual Server *****************\n"
"********************************************************\n"); "********************************************************\n");
firmware_check_done = 1;
return; return;
#endif #endif
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
@ -108,6 +123,7 @@ void checkFirmwareCompatibility(int flag){
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION); int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION); int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION); int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
int64_t client_sw_apiversion = getDetectorId(CLIENT_SOFTWARE_API_VERSION);
cprintf(BLUE,"\n\n" cprintf(BLUE,"\n\n"
"********************************************************\n" "********************************************************\n"
@ -120,37 +136,61 @@ void checkFirmwareCompatibility(int flag){
"Firmware Version:\t\t %lld\n" "Firmware Version:\t\t %lld\n"
"Software Version:\t\t %llx\n" "Software Version:\t\t %llx\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\n" "Required Firmware Version:\t %d\n"
"Client-Software API Version:\t 0x%llx\n"
"\n"
"********************************************************\n", "********************************************************\n",
(unsigned int)ipadd, (unsigned int)ipadd,
(long long unsigned int)macadd, (long long unsigned int)macadd,
(long long int)fwversion, (long long int)fwversion,
(long long int)swversion, (long long int)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);
// return if flag is not zero, debug mode
if (flag) {
firmware_check_done = 1;
return;
}
//cant read versions //cant read versions
if(!fwversion || !sw_fw_apiversion){ if(!fwversion || !sw_fw_apiversion){
cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n"); strcpy(firmware_message,
cprintf(RED,"Exiting Server. Goodbye!\n\n"); "FATAL ERROR: Cant read versions from FPGA. Please update firmware.\n");
exit(-1); cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
} }
//check for API compatibility - old server //check for API compatibility - old server
if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){ if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){
cprintf(RED,"FATAL ERROR: This software version is incompatible.\n" sprintf(firmware_message,
"Please update it to be compatible with this firmware\n\n"); "FATAL ERROR: This detector software software version (%lld) is incompatible.\n"
cprintf(RED,"Exiting Server. Goodbye!\n\n"); "Please update detector software (min. %lld) to be compatible with this firmware.\n",
exit(-1); (long long int)sw_fw_apiversion,
(long long int)REQUIRED_FIRMWARE_VERSION);
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
} }
//check for firmware compatibility - old firmware //check for firmware compatibility - old firmware
if( REQUIRED_FIRMWARE_VERSION > fwversion){ if( REQUIRED_FIRMWARE_VERSION > fwversion){
cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n" sprintf(firmware_message,
"Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION); "FATAL ERROR: This firmware version (%lld) is incompatible.\n"
cprintf(RED,"Exiting Server. Goodbye!\n\n"); "Please update firmware (min. %lld) to be compatible with this server.\n",
exit(-1); (long long int)fwversion,
(long long int)REQUIRED_FIRMWARE_VERSION);
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
} }
printf("Compatibility - success\n");
firmware_check_done = 1;
} }
@ -175,6 +215,8 @@ int64_t getDetectorId(enum idMode arg){
return (int64_t)Beb_GetFirmwareSoftwareAPIVersion(); return (int64_t)Beb_GetFirmwareSoftwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION: case DETECTOR_SOFTWARE_VERSION:
return (GITDATE & 0xFFFFFF); return (GITDATE & 0xFFFFFF);
case CLIENT_SOFTWARE_API_VERSION:
return APIEIGER;
default: default:
break; break;
} }

View File

@ -1,7 +1,7 @@
SRCFILE=gitInfoEiger.h SRCFILE=gitInfoEiger.h
DSTFILE=../commonFiles/versionAPI.h DSTFILE=versionAPI.h
SRCPATTERN=GITDATE SRCPATTERN=GITDATE
DSTPATTERN=APIEIGER DSTPATTERN=APIEIGER
awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3=x}print > b}' $SRCFILE $DSTFILE awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE

View File

@ -0,0 +1 @@
../commonFiles/versionAPI.h

View File

@ -1,7 +1,7 @@
SRCFILE=gitInfoGotthard.h SRCFILE=gitInfoGotthard.h
DSTFILE=../commonFiles/versionAPI.h DSTFILE=versionAPI.h
SRCPATTERN=GITDATE SRCPATTERN=GITDATE
DSTPATTERN=APIGOTTHARD DSTPATTERN=APIGOTTHARD
awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3=x}print > b}' $SRCFILE $DSTFILE awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE

View File

@ -0,0 +1 @@
../commonFiles/versionAPI.h

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: cb635d800a5e1de6cf3330f03a98ffc382879cf3 Repsitory UUID: 4d4e4a4ce7a91af094251ed0903575ba7e73ef5f
Revision: 151 Revision: 153
Branch: mergevirtual Branch: versioning
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3832 Last Changed Rev: 3847
Last Changed Date: 2018-05-23 14:42:26.000000002 +0200 ./Makefile.virtual Last Changed Date: 2018-05-28 18:02:50.000000002 +0200 ./RegisterDefs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "cb635d800a5e1de6cf3330f03a98ffc382879cf3" #define GITREPUUID "4d4e4a4ce7a91af094251ed0903575ba7e73ef5f"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3832 #define GITREV 0x3847
#define GITDATE 0x20180523 #define GITDATE 0x20180528
#define GITBRANCH "mergevirtual" #define GITBRANCH "versioning"

View File

@ -5,7 +5,7 @@
#include "gitInfoJungfrau.h" #include "gitInfoJungfrau.h"
#include "AD9257.h" // include "commonServerFunctions.h", which in turn includes "blackfin.h" #include "AD9257.h" // include "commonServerFunctions.h", which in turn includes "blackfin.h"
#include "programfpga.h" #include "programfpga.h"
#include "versionAPI.h"
#ifdef VIRTUAL #ifdef VIRTUAL
#include <pthread.h> #include <pthread.h>
@ -33,6 +33,19 @@ int virtual_stop = 0;
/* basic tests */ /* basic tests */
int firmware_compatibility = OK;
int firmware_check_done = 0;
char firmware_message[MAX_STR_LENGTH];
int isFirmwareCheckDone() {
return firmware_check_done;
}
int getFirmwareCheckResult(char** mess) {
*mess = firmware_message;
return firmware_compatibility;
}
void checkFirmwareCompatibility(int flag) { void checkFirmwareCompatibility(int flag) {
#ifdef VIRTUAL #ifdef VIRTUAL
cprintf(BLUE,"\n\n" cprintf(BLUE,"\n\n"
@ -40,23 +53,36 @@ void checkFirmwareCompatibility(int flag) {
"************** Jungfrau Virtual Server *****************\n" "************** Jungfrau Virtual Server *****************\n"
"********************************************************\n\n"); "********************************************************\n\n");
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); strcpy(firmware_message,
exit(EXIT_FAILURE); "FATAL ERROR: Could not map to memory. Dangerous to continue.\n");
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
} }
firmware_check_done = 1;
return; return;
#endif #endif
defineGPIOpins(); defineGPIOpins();
resetFPGA(); resetFPGA();
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); strcpy(firmware_message,
exit(EXIT_FAILURE); "FATAL ERROR: Could not map to memory. Dangerous to continue.\n");
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
} }
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); strcpy(firmware_message,
exit(EXIT_FAILURE); "FATAL ERROR: Could not pass basic tests of FPGA and bus. Dangerous to continue.\n");
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
} }
uint16_t hversion = getHardwareVersionNumber(); uint16_t hversion = getHardwareVersionNumber();
@ -66,6 +92,9 @@ void checkFirmwareCompatibility(int flag) {
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION); int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION); int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
int64_t sw_fw_apiversion = 0; int64_t sw_fw_apiversion = 0;
int64_t client_sw_apiversion = getDetectorId(CLIENT_SOFTWARE_API_VERSION);
if (fwversion >= MIN_REQRD_VRSN_T_RD_API) if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION); sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
cprintf(BLUE,"\n\n" cprintf(BLUE,"\n\n"
@ -82,6 +111,7 @@ void checkFirmwareCompatibility(int flag) {
"Software Version:\t\t 0x%llx\n" "Software Version:\t\t 0x%llx\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"
"********************************************************\n", "********************************************************\n",
hversion, hsnumber, hversion, hsnumber,
@ -90,38 +120,55 @@ void checkFirmwareCompatibility(int flag) {
(long long int)fwversion, (long long int)fwversion,
(long long int)swversion, (long long int)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
); );
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (flag) if (flag) {
firmware_check_done = 1;
return; return;
}
//cant read versions //cant read versions
printf("Testing Firmware-software compatibility ...\n"); printf("Testing Firmware-software compatibility ...\n");
if(!fwversion || !sw_fw_apiversion){ if(!fwversion || !sw_fw_apiversion){
cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n"); strcpy(firmware_message,
cprintf(RED,"Exiting Server. Goodbye!\n\n"); "FATAL ERROR: Cant read versions from FPGA. Please update firmware.\n");
exit(EXIT_FAILURE); cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
} }
//check for API compatibility - old server //check for API compatibility - old server
if(sw_fw_apiversion > REQRD_FRMWR_VRSN){ if(sw_fw_apiversion > REQRD_FRMWR_VRSN){
cprintf(RED,"FATAL ERROR: This software version is incompatible.\n" sprintf(firmware_message,
"Please update it to be compatible with this firmware\n\n"); "FATAL ERROR: This detector software software version (0x%llx) is incompatible.\n"
cprintf(RED,"Exiting Server. Goodbye!\n\n"); "Please update detector software (min. 0x%llx) to be compatible with this firmware.\n",
exit(EXIT_FAILURE); (long long int)sw_fw_apiversion,
(long long int)REQRD_FRMWR_VRSN);
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
} }
//check for firmware compatibility - old firmware //check for firmware compatibility - old firmware
if( REQRD_FRMWR_VRSN > fwversion){ if( REQRD_FRMWR_VRSN > fwversion){
cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n" sprintf(firmware_message,
"Please update it to v%d to be compatible with this server\n\n", REQRD_FRMWR_VRSN); "FATAL ERROR: This firmware version (0x%llx) is incompatible.\n"
cprintf(RED,"Exiting Server. Goodbye!\n\n"); "Please update firmware (min. 0x%llx) to be compatible with this server.\n",
exit(EXIT_FAILURE); (long long int)fwversion,
(long long int)REQRD_FRMWR_VRSN);
cprintf(RED,"%s\n\n", firmware_message);
firmware_compatibility = FAIL;
firmware_check_done = 1;
return;
} }
printf("Compatibility - success\n"); printf("Compatibility - success\n");
firmware_check_done = 1;
} }
@ -222,6 +269,8 @@ int64_t getDetectorId(enum idMode arg){
return getFirmwareAPIVersion(); return getFirmwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION: case DETECTOR_SOFTWARE_VERSION:
return (GITDATE & 0xFFFFFF); return (GITDATE & 0xFFFFFF);
case CLIENT_SOFTWARE_API_VERSION:
return APIJUNGFRAU;
default: default:
return retval; return retval;
} }

View File

@ -10,7 +10,7 @@
#define GOODBYE (-200) #define GOODBYE (-200)
#define PROGRAMMING_MODE (-200) #define PROGRAMMING_MODE (-200)
#define MIN_REQRD_VRSN_T_RD_API 0x171220 #define MIN_REQRD_VRSN_T_RD_API 0x171220
#define REQRD_FRMWR_VRSN 0x180226 #define REQRD_FRMWR_VRSN 0x20180226
/* Struct Definitions */ /* Struct Definitions */

View File

@ -1,7 +1,7 @@
SRCFILE=gitInfoJungfrau.h SRCFILE=gitInfoJungfrau.h
DSTFILE=../commonFiles/versionAPI.h DSTFILE=versionAPI.h
SRCPATTERN=GITDATE SRCPATTERN=GITDATE
DSTPATTERN=APIJUNGFRAU DSTPATTERN=APIJUNGFRAU
awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3=x}print > b}' $SRCFILE $DSTFILE awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE

View File

@ -0,0 +1 @@
../commonFiles/versionAPI.h

View File

@ -7021,3 +7021,42 @@ bool multiSlsDetector::isAcquireReady() {
thisMultiDetector->acquiringFlag = true; thisMultiDetector->acquiringFlag = true;
return OK; return OK;
} }
int multiSlsDetector::checkVersionCompatibility(portType t) {
int ret=-100;
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}else{
//return storage values
int* iret[thisMultiDetector->numberOfDetectors];
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet){
if(detectors[idet]){
iret[idet]= new int(-1);
Task* task = new Task(new func1_t<int,portType>(&slsDetector::checkVersionCompatibility,
detectors[idet],t,iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
}
return ret;
}

View File

@ -1568,6 +1568,14 @@ class multiSlsDetector : public slsDetectorUtils {
*/ */
bool isAcquireReady(); bool isAcquireReady();
/**
* Check version compatibility with detector/receiver software
* (if hostname/rx_hostname has been set/ sockets created)
* \param p port type control port or receiver port
* \returns FAIL for incompatibility, OK for compatibility
*/
int checkVersionCompatibility(portType t);
private: private:

View File

@ -10,6 +10,8 @@
#include <cstdlib> #include <cstdlib>
#include <math.h> #include <math.h>
#include "gitInfoLib.h" #include "gitInfoLib.h"
#include "versionAPI.h"
using namespace std; using namespace std;
int slsDetector::initSharedMemory(detectorType type, int id) { int slsDetector::initSharedMemory(detectorType type, int id) {
@ -806,6 +808,10 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->receiver_read_freq = 0; thisDetector->receiver_read_freq = 0;
thisDetector->receiver_framesPerFile = -1; thisDetector->receiver_framesPerFile = -1;
thisDetector->detectorControlAPIVersion = 0;
thisDetector->detectorStopAPIVersion = 0;
thisDetector->receiverAPIVersion = 0;
for (int ia=0; ia<MAX_ACTIONS; ++ia) { for (int ia=0; ia<MAX_ACTIONS; ++ia) {
strcpy(thisDetector->actionScript[ia],"none"); strcpy(thisDetector->actionScript[ia],"none");
strcpy(thisDetector->actionParameter[ia],"none"); strcpy(thisDetector->actionParameter[ia],"none");
@ -1430,7 +1436,6 @@ int slsDetector::activate(int const enable){
*/ */
int slsDetector::setTCPSocket(string const name, int const control_port, int const stop_port){ int slsDetector::setTCPSocket(string const name, int const control_port, int const stop_port){
char thisName[MAX_STR_LENGTH]; char thisName[MAX_STR_LENGTH];
int thisCP, thisSP; int thisCP, thisSP;
int retval=OK; int retval=OK;
@ -1511,6 +1516,22 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
} }
if (retval!=FAIL) { if (retval!=FAIL) {
checkOnline(); checkOnline();
// check for version compatibility
switch (thisDetector->myDetectorType) {
case EIGER:
case JUNGFRAU:
case GOTTHARD:
if ((thisDetector->detectorControlAPIVersion == 0) ||
(thisDetector->detectorStopAPIVersion == 0)) {
if (checkVersionCompatibility(CONTROL_PORT) == FAIL)
thisDetector->onlineFlag=OFFLINE_FLAG;
}
break;
default:
break;
}
} else { } else {
thisDetector->onlineFlag=OFFLINE_FLAG; thisDetector->onlineFlag=OFFLINE_FLAG;
#ifdef VERBOSE #ifdef VERBOSE
@ -8364,15 +8385,28 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port
} }
//check if it connects //check if it connects
if (retval!=FAIL) { if (retval!=FAIL) {
if(checkReceiverOnline().empty()) checkReceiverOnline();
retval=FAIL; thisReceiver->setSocket(dataSocket);
// check for version compatibility
switch (thisDetector->myDetectorType) {
case EIGER:
case JUNGFRAU:
case GOTTHARD:
if (thisDetector->receiverAPIVersion == 0){
if (checkVersionCompatibility(DATA_PORT) == FAIL)
thisDetector->receiverOnlineFlag=OFFLINE_FLAG;
}
break;
default:
break;
}
} else { } else {
thisDetector->receiverOnlineFlag=OFFLINE_FLAG; thisDetector->receiverOnlineFlag=OFFLINE_FLAG;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "offline!" << std::endl; std::cout<< "offline!" << std::endl;
#endif #endif
} }
thisReceiver->setSocket(dataSocket);
return retval; return retval;
}; };
@ -9821,3 +9855,99 @@ int slsDetector::restreamStopFromReceiver(){
return ret; return ret;
} }
int slsDetector::checkVersionCompatibility(portType t) {
int fnum = F_CHECK_VERSION;
if (t == DATA_PORT)
fnum = F_RECEIVER_CHECK_VERSION;
int ret = FAIL;
char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
int64_t arg = 0;
// detector
if (t == CONTROL_PORT) {
switch (thisDetector->myDetectorType) {
case EIGER: arg = APIEIGER; break;
case JUNGFRAU: arg = APIJUNGFRAU; break;
case GOTTHARD: arg = APIGOTTHARD; break;
default:
std::cout<< "Check version compatibility is not implemented for this detector" << std::endl;
setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY));
return FAIL;
}
#ifdef VERBOSE
std::cout<< std::endl<< "Checking version compatibility with detector with value " << hex << arg << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
// control port
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&arg,sizeof(arg));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret == FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
cprintf(RED, "Detector returned error: (Control Server) %s", mess);
if(strstr(mess,"Unrecognized Function")!=NULL)
std::cout << "The detector server is too old to get API version. Please update detector server!" << std::endl;
setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY));
thisDetector->detectorControlAPIVersion = 0;
} else {
thisDetector->detectorControlAPIVersion = arg;
}
disconnectControl();
}
if (ret!= FAIL) {
ret = FAIL;
// stop port
if (connectStop() == OK){
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
stopSocket->SendDataOnly(&arg,sizeof(arg));
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret == FAIL) {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
cprintf(RED, "Detector returned error: (Stop Server) %s", mess);
if(strstr(mess,"Unrecognized Function")!=NULL)
std::cout << "The detector server is too old to get API version. Please update detector server!" << std::endl;
setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY));
thisDetector->detectorStopAPIVersion = 0;
} else {
thisDetector->detectorStopAPIVersion = arg;
}
disconnectStop();
}
}
}
}
// receiver
else {
arg = APIRECEIVER;
#ifdef VERBOSE
std::cout<< std::endl<< "Checking version compatibility with receiver with value " << hex << arg << std::endl;
#endif
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
// data port
if (connectData() == OK){
// ignoring retval
int64_t retval = -1;
ret=thisReceiver->sendInt(fnum,retval,arg);
if (ret==FAIL){
setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY));
if(strstr(mess,"Unrecognized Function")!=NULL)
std::cout << "The receiver software is too old to get API version. Please update receiver software!" << std::endl;
thisDetector->receiverAPIVersion = 0;
} else {
thisDetector->receiverAPIVersion = arg;
}
disconnectData();
}
}
}
return ret;
}

View File

@ -290,11 +290,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
/** frames per file in receiver */ /** frames per file in receiver */
int receiver_framesPerFile; int receiver_framesPerFile;
/** detector software API version */ /** detector control server software API version */
int detector_software_api_version; int64_t detectorControlAPIVersion;
/** detector stop server software API version */
/** receiver API version */ int64_t detectorStopAPIVersion;
int receiver_api_version; /** receiver server software API version */
int64_t receiverAPIVersion;
} sharedSlsDetector; } sharedSlsDetector;
@ -2059,6 +2060,14 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/ */
int restreamStopFromReceiver(); int restreamStopFromReceiver();
/**
* Check version compatibility with detector/receiver software
* (if hostname/rx_hostname has been set/ sockets created)
* \param p port type control port or receiver port
* \returns FAIL for incompatibility, OK for compatibility
*/
int checkVersionCompatibility(portType t);
protected: protected:

View File

@ -507,6 +507,22 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
Commands to check versions of each subsystem Commands to check versions of each subsystem
*/ */
/*! \page config
- <b>checkdetversion</b> Checks the version compatibility with detector software (if hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
*/
descrToFuncMap[i].m_pFuncName="checkdetversion"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSN;
++i;
/*! \page config
- <b>checkrecversion</b> Checks the version compatibility with receiver software (if rx_hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
*/
descrToFuncMap[i].m_pFuncName="checkrecversion"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSN;
++i;
/*! \page config /*! \page config
- <b>moduleversion:[i]</b> Gets the firmware version of module i. Used for MYTHEN only. Only get! \c Returns \c (long int) in hexadecimal or "undefined module number" - <b>moduleversion:[i]</b> Gets the firmware version of module i. Used for MYTHEN only. Only get! \c Returns \c (long int) in hexadecimal or "undefined module number"
*/ */
@ -4895,6 +4911,24 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
sprintf(answer,"0x%lx", retval); sprintf(answer,"0x%lx", retval);
return string(answer); return string(answer);
} }
if (cmd=="checkdetversion") {
int retval = myDet->checkVersionCompatibility(CONTROL_PORT);
if (retval < 0)
sprintf(answer, "%d", -1);
sprintf(answer,"%s", retval == OK ? "compatible" : "incompatible");
return string(answer);
}
if (cmd=="checkrecversion") {
myDet->setReceiverOnline(ONLINE_FLAG);
int retval = myDet->checkVersionCompatibility(DATA_PORT);
if (retval < 0)
sprintf(answer, "%d", -1);
sprintf(answer,"%s", retval == OK ? "compatible" : "incompatible");
return string(answer);
}
return string("unknown id mode ")+cmd; return string("unknown id mode ")+cmd;
} }
@ -4903,6 +4937,8 @@ string slsDetectorCommand::helpSN(int narg, char *args[], int action) {
ostringstream os; ostringstream os;
if (action==GET_ACTION || action==HELP_ACTION) { if (action==GET_ACTION || action==HELP_ACTION) {
os << "checkdetversion \n gets the version compatibility with detector software (if hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible."<< std::endl;
os << "checkrecversion \n gets the version compatibility with receiver software (if rx_hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible."<< std::endl;
os << "moduleversion:i \n gets the firmwareversion of the module i"<< std::endl; os << "moduleversion:i \n gets the firmwareversion of the module i"<< std::endl;
os << "modulenumber:i \n gets the serial number of the module i"<< std::endl; os << "modulenumber:i \n gets the serial number of the module i"<< std::endl;
os << "detectornumber \n gets the serial number of the detector (MAC)"<< std::endl; os << "detectornumber \n gets the serial number of the detector (MAC)"<< std::endl;

View File

@ -1029,6 +1029,14 @@ virtual int setReceiverSilentMode(int i = -1)=0;
virtual bool isAcquireReady() = 0; virtual bool isAcquireReady() = 0;
/**
* Check version compatibility with detector/receiver software
* (if hostname/rx_hostname has been set/ sockets created)
* \param p port type control port or data (receiver) port
* \returns FAIL for incompatibility, OK for compatibility
*/
virtual int checkVersionCompatibility(portType t) = 0;
protected: protected:

View File

@ -17,6 +17,11 @@ Here are the definitions, but the actual implementation should be done for each
// basic tests // basic tests
#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARD)
int isFirmwareCheckDone();
int getFirmwareCheckResult(char** mess);
#endif
void checkFirmwareCompatibility(int flag); void checkFirmwareCompatibility(int flag);
#if defined(MYTHEN3D) || defined(JUNGFRAUD) #if defined(MYTHEN3D) || defined(JUNGFRAUD)
int checkType(); int checkType();

View File

@ -209,6 +209,7 @@ const char* getFunctionName(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";
default: return "Unknown Function"; default: return "Unknown Function";
} }
@ -293,6 +294,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;
// check // check
if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) { if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) {
@ -5146,9 +5148,10 @@ int program_fpga(int file_des) {
printf("Done with program receiving command\n"); printf("Done with program receiving command\n");
#endif #endif
if (isControlServer) if (isControlServer) {
basictests(debugflag); basictests(debugflag);
init_detector(isControlServer); initControlServer();
}
} }
#endif #endif
if (ret==OK) if (ret==OK)
@ -5760,3 +5763,97 @@ int storage_cell_start(int file_des) {
return ret; return ret;
} }
int check_version(int file_des) {
int ret=OK,ret1=OK;
int n=0;
sprintf(mess,"check version failed\n");
#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(GOTTHARD)
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret=FAIL;
sprintf(mess,"Function (Check Version Compatibility) is not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
#else
// receive arguments
int64_t arg=-1;
n = receiveData(file_des,&arg,sizeof(arg),INT64);
if (n < 0) return printSocketReadError();
// execute action
#ifdef SLS_DETECTOR_FUNCTION_LIST
// check software- firmware compatibility and basic tests
if (isControlServer) {
#ifdef VERBOSE
printf("Checking software-firmware compatibility and basic test result\n");
#endif
// check if firmware check is done
if (!isFirmwareCheckDone()) {
usleep(3 * 1000 * 1000);
if (!isFirmwareCheckDone()) {
ret = FAIL;
strcpy(mess,"Firmware Software Compatibility Check (Server Initialization) "
"still not done done in server. Unexpected.\n");
cprintf(RED, "Warning: %s", mess);
}
}
// check firmware check result
if (ret == OK) {
char* firmware_message = NULL;
if (getFirmwareCheckResult(&firmware_message) == FAIL) {
ret = FAIL;
strcpy(mess, firmware_message);
cprintf(RED, "Warning: %s", mess);
}
}
}
if (ret == OK) {
#ifdef VERBOSE
printf("Checking versioning compatibility with value %d\n",arg);
#endif
int64_t client_requiredVersion = arg;
int64_t det_apiVersion = getDetectorId(CLIENT_SOFTWARE_API_VERSION);
int64_t det_version = getDetectorId(DETECTOR_SOFTWARE_VERSION);
// 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",
client_requiredVersion, det_apiVersion);
cprintf(RED, "Warning: %s", 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",
det_version, client_requiredVersion);
cprintf(RED, "Warning: %s", mess);
}
}
#endif
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret==FAIL) {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}

View File

@ -95,5 +95,6 @@ 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);
#endif #endif

View File

@ -21,7 +21,8 @@ receiverInterface::~receiverInterface(){}
int receiverInterface::sendString(int fnum, char retval[], char arg[]){ int receiverInterface::sendString(int fnum, char retval[], char arg[]){
int ret = slsDetectorDefs::FAIL; int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = ""; char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,MAX_STR_LENGTH); dataSocket->SendDataOnly(arg,MAX_STR_LENGTH);
@ -30,6 +31,7 @@ int receiverInterface::sendString(int fnum, char retval[], char arg[]){
dataSocket->ReceiveDataOnly(mess,sizeof(mess)); dataSocket->ReceiveDataOnly(mess,sizeof(mess));
cprintf(RED, "Receiver returned error: %s", mess); cprintf(RED, "Receiver returned error: %s", mess);
} }
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH); dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
return ret; return ret;
@ -40,7 +42,8 @@ int receiverInterface::sendString(int fnum, char retval[], char arg[]){
int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){ int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){
char args[3][MAX_STR_LENGTH]; char args[3][MAX_STR_LENGTH];
int ret = slsDetectorDefs::FAIL; int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = ""; char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,sizeof(args)); dataSocket->SendDataOnly(arg,sizeof(args));
@ -58,7 +61,8 @@ int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_S
int receiverInterface::sendInt(int fnum, int &retval, int arg){ int receiverInterface::sendInt(int fnum, int &retval, int arg){
int ret = slsDetectorDefs::FAIL; int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = ""; char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(&arg,sizeof(arg)); dataSocket->SendDataOnly(&arg,sizeof(arg));
@ -67,6 +71,7 @@ int receiverInterface::sendInt(int fnum, int &retval, int arg){
dataSocket->ReceiveDataOnly(mess,sizeof(mess)); dataSocket->ReceiveDataOnly(mess,sizeof(mess));
cprintf(RED, "Receiver returned error: %s", mess); cprintf(RED, "Receiver returned error: %s", mess);
} }
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret; return ret;
@ -76,7 +81,8 @@ int receiverInterface::sendInt(int fnum, int &retval, int arg){
int receiverInterface::getInt(int fnum, int &retval){ int receiverInterface::getInt(int fnum, int &retval){
int ret = slsDetectorDefs::FAIL; int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = ""; char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
@ -84,6 +90,7 @@ int receiverInterface::getInt(int fnum, int &retval){
dataSocket->ReceiveDataOnly(mess,sizeof(mess)); dataSocket->ReceiveDataOnly(mess,sizeof(mess));
cprintf(RED, "Receiver returned error: %s", mess); cprintf(RED, "Receiver returned error: %s", mess);
} }
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret; return ret;
@ -93,7 +100,8 @@ int receiverInterface::getInt(int fnum, int &retval){
int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){ int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
int ret = slsDetectorDefs::FAIL; int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = ""; char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(&arg,sizeof(arg)); dataSocket->SendDataOnly(&arg,sizeof(arg));
@ -102,6 +110,7 @@ int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
dataSocket->ReceiveDataOnly(mess,sizeof(mess)); dataSocket->ReceiveDataOnly(mess,sizeof(mess));
cprintf(RED, "Receiver returned error: %s", mess); cprintf(RED, "Receiver returned error: %s", mess);
} }
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret; return ret;
@ -111,15 +120,17 @@ int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], char mess[]){ int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], char mess[]){
int64_t args[2]; int64_t args[2];
char messs[MAX_STR_LENGTH];
int ret = slsDetectorDefs::FAIL; int ret = slsDetectorDefs::FAIL;
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,sizeof(args)); dataSocket->SendDataOnly(arg,sizeof(args));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){ if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(messs)); dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
cprintf(RED, "Receiver returned error: %s", mess); cprintf(RED, "Receiver returned error: %s", mess);
} }
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret; return ret;
@ -130,7 +141,9 @@ int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], c
int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){ int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){
int args[2]; int args[2];
int ret = slsDetectorDefs::FAIL; int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH] = ""; char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,sizeof(args)); dataSocket->SendDataOnly(arg,sizeof(args));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
@ -138,6 +151,7 @@ int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){
dataSocket->ReceiveDataOnly(mess,sizeof(mess)); dataSocket->ReceiveDataOnly(mess,sizeof(mess));
cprintf(RED, "Receiver returned error: %s", mess); cprintf(RED, "Receiver returned error: %s", mess);
} }
if(strstr(mess,"Unrecognized Function")==NULL)
dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
return ret; return ret;
@ -170,6 +184,7 @@ int receiverInterface::getLastClientIP(int fnum, char retval[]){
int receiverInterface::executeFunction(int fnum,char mess[]){ int receiverInterface::executeFunction(int fnum,char mess[]){
int ret = slsDetectorDefs::FAIL; int ret = slsDetectorDefs::FAIL;
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); dataSocket->ReceiveDataOnly(&ret,sizeof(ret));

View File

@ -105,7 +105,7 @@ private:
class SuperTask: public virtual slsDetectorDefs { class SuperTask: public virtual slsDetectorDefs {
public: public:
SuperTask(): SuperTask():
m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0),m17(0),m18(0){}; m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0),m17(0),m18(0),m19(0){};
virtual ~SuperTask(){}; virtual ~SuperTask(){};
protected: protected:
/** Function signature defined /** Function signature defined
@ -129,6 +129,7 @@ protected:
func4_t <int, trimMode,int,int,int>* m16; func4_t <int, trimMode,int,int,int>* m16;
func4_t <int, int,int,detectorSettings,int>* m17; func4_t <int, int,int,detectorSettings,int>* m17;
func4_t <dacs_t, dacs_t,dacIndex,int,int>* m18; func4_t <dacs_t, dacs_t,dacIndex,int,int>* m18;
func1_t <int, portType>* m19;
}; };
class Task: public virtual SuperTask { class Task: public virtual SuperTask {
@ -154,6 +155,7 @@ public:
Task(func4_t <int, trimMode,int,int,int>* t): SuperTask(),fnum(16){m16 = t;}; Task(func4_t <int, trimMode,int,int,int>* t): SuperTask(),fnum(16){m16 = t;};
Task(func4_t <int, int,int,detectorSettings,int>* t): SuperTask(),fnum(17){m17 = t;}; Task(func4_t <int, int,int,detectorSettings,int>* t): SuperTask(),fnum(17){m17 = t;};
Task(func4_t <dacs_t, dacs_t,dacIndex,int,int>* t): SuperTask(),fnum(18){m18 = t;}; Task(func4_t <dacs_t, dacs_t,dacIndex,int,int>* t): SuperTask(),fnum(18){m18 = t;};
Task(func1_t <int, portType>* t): SuperTask(),fnum(19){m19 = t;};
virtual ~Task(){ virtual ~Task(){
switch(fnum) { switch(fnum) {
@ -175,6 +177,7 @@ public:
case 16: delete m16; break; case 16: delete m16; break;
case 17: delete m17; break; case 17: delete m17; break;
case 18: delete m18; break; case 18: delete m18; break;
case 19: delete m19; break;
default: default:
cprintf(RED, "Error: Task not defined. Abort!\n"); cprintf(RED, "Error: Task not defined. Abort!\n");
break; break;
@ -202,6 +205,7 @@ public:
case 16: (*m16)(); break; case 16: (*m16)(); break;
case 17: (*m17)(); break; case 17: (*m17)(); break;
case 18: (*m18)(); break; case 18: (*m18)(); break;
case 19: (*m19)(); break;
default: default:
cprintf(RED, "Error: Task not defined. Abort!\n"); cprintf(RED, "Error: Task not defined. Abort!\n");
break; break;

View File

@ -309,6 +309,10 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
/** set frames per file */ /** set frames per file */
int set_frames_per_file(); int set_frames_per_file();
/** check version compatibility */
int check_version_compatibility();
/** detector type */ /** detector type */
detectorType myDetectorType; detectorType myDetectorType;

View File

@ -67,7 +67,7 @@ enum recFuncs{
F_RECEIVER_UDP_SOCK_BUF_SIZE, /** < UDP socket buffer size */ F_RECEIVER_UDP_SOCK_BUF_SIZE, /** < UDP socket buffer size */
F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, /** < real UDP socket buffer size */ F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, /** < real UDP socket buffer size */
F_SET_RECEIVER_FRAMES_PER_FILE, /** < receiver frames per file */ F_SET_RECEIVER_FRAMES_PER_FILE, /** < receiver frames per file */
F_RECEIVER_CHECK_VERSION, /** < check receiver version compatibility */
/* Always append functions hereafter!!! */ /* Always append functions hereafter!!! */

View File

@ -0,0 +1 @@
../../slsDetectorSoftware/commonFiles/versionAPI.h

View File

@ -674,7 +674,7 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
"[/proc/sys/net/core/netdev_max_backlog] modified to %d\n", "[/proc/sys/net/core/netdev_max_backlog] modified to %d\n",
MAX_SOCKET_INPUT_PACKET_QUEUE); MAX_SOCKET_INPUT_PACKET_QUEUE);
} else { } else {
const char *msg = "Could not change max length of" const char *msg = "Could not change max length of "
"input packet queue [net.core.netdev_max_backlog]. (No Root Privileges?)"; "input packet queue [net.core.netdev_max_backlog]. (No Root Privileges?)";
FILE_LOG(logWARNING) << msg; FILE_LOG(logWARNING) << msg;
} }

View File

@ -8,6 +8,7 @@
#include "gitInfoReceiver.h" #include "gitInfoReceiver.h"
#include "slsReceiverUsers.h" #include "slsReceiverUsers.h"
#include "slsReceiver.h" #include "slsReceiver.h"
#include "versionAPI.h"
#include <stdlib.h> //EXIT #include <stdlib.h> //EXIT
#include <iostream> #include <iostream>
@ -153,7 +154,7 @@ void slsReceiverTCPIPInterface::stop(){
int64_t slsReceiverTCPIPInterface::getReceiverVersion(){ int64_t slsReceiverTCPIPInterface::getReceiverVersion(){
int64_t retval = GITDATE; int64_t retval = GITDATE & 0xFFFFFF;
return retval; return retval;
} }
@ -297,6 +298,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
case F_RECEIVER_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_UDP_SOCK_BUF_SIZE"; case F_RECEIVER_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_UDP_SOCK_BUF_SIZE";
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_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION";
default: return "Unknown Function"; default: return "Unknown Function";
} }
@ -350,6 +352,7 @@ int slsReceiverTCPIPInterface::function_table(){
flist[F_RECEIVER_UDP_SOCK_BUF_SIZE] = &slsReceiverTCPIPInterface::set_udp_socket_buffer_size; flist[F_RECEIVER_UDP_SOCK_BUF_SIZE] = &slsReceiverTCPIPInterface::set_udp_socket_buffer_size;
flist[F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE]= &slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size; flist[F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE]= &slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size;
flist[F_SET_RECEIVER_FRAMES_PER_FILE] = &slsReceiverTCPIPInterface::set_frames_per_file; flist[F_SET_RECEIVER_FRAMES_PER_FILE] = &slsReceiverTCPIPInterface::set_frames_per_file;
flist[F_RECEIVER_CHECK_VERSION] = &slsReceiverTCPIPInterface::check_version_compatibility;
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) { for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) {
@ -367,20 +370,22 @@ int slsReceiverTCPIPInterface::decode_function(){
ret = FAIL; ret = FAIL;
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cprintf(RESET,"\n"); cprintf(RESET,"\n");
FILE_LOG(logDEBUG1) << "waiting to receive data";
#endif #endif
FILE_LOG(logDEBUG1) << "waiting to receive data";
int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum)); int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum));
if (n <= 0) { if (n <= 0) {
#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "ERROR reading from socket. "
FILE_LOG(logDEBUG1) << "ERROR reading from socket. Received " << n << " bytes, fd: " << file_des << " fnum:" << fnum << " (" << getFunctionName((enum recFuncs)fnum) << ")"; "Received " << n << " bytes," <<
#endif "fnum:" << fnum << " "
"(" << getFunctionName((enum recFuncs)fnum) << ")";
return FAIL; return FAIL;
} }
#ifdef VERYVERBOSE
else else
FILE_LOG(logDEBUG1) << "Received " << n << " bytes"; FILE_LOG(logDEBUG1) << "Received " << n << " bytes";
FILE_LOG(logDEBUG1) << "calling function fnum: "<< fnum << " (" << getFunctionName((enum recFuncs)fnum) << ") located at " << flist[fnum];
#endif FILE_LOG(logDEBUG1) << "calling function fnum: "<< fnum << " "
"(" << getFunctionName((enum recFuncs)fnum) << ") "
"located at " << flist[fnum];
if (fnum < REC_FUNC_START_INDEX || fnum >= NUM_REC_FUNCTIONS) { if (fnum < REC_FUNC_START_INDEX || fnum >= NUM_REC_FUNCTIONS) {
FILE_LOG(logERROR) << "Unknown function enum " << fnum; FILE_LOG(logERROR) << "Unknown function enum " << fnum;
@ -429,7 +434,7 @@ void slsReceiverTCPIPInterface::functionNotImplemented() {
} }
int slsReceiverTCPIPInterface::M_nofunc(){ int slsReceiverTCPIPInterface::M_nofunc(){printf("111 \n");
ret = FAIL; ret = FAIL;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int n = 0; int n = 0;
@ -438,7 +443,7 @@ int slsReceiverTCPIPInterface::M_nofunc(){
while (n > 0) while (n > 0)
n = mySock->ReceiveDataOnly(mess,MAX_STR_LENGTH); n = mySock->ReceiveDataOnly(mess,MAX_STR_LENGTH);
sprintf(mess,"Unrecognized Function\n"); strcpy(mess,"Unrecognized Function. Please do not proceed.\n");
FILE_LOG(logERROR) << mess; FILE_LOG(logERROR) << mess;
// send ok / fail // send ok / fail
@ -2758,3 +2763,60 @@ int slsReceiverTCPIPInterface::set_frames_per_file() {
return ret; return ret;
} }
int slsReceiverTCPIPInterface::check_version_compatibility() {
ret = OK;
memset(mess, 0, sizeof(mess));
int64_t arg = -1;
int64_t retval = -1;
// receive arguments
if (mySock->ReceiveDataOnly(&arg,sizeof(arg)) < 0 )
return printSocketReadError();
// execute action
FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value " << arg;
int64_t client_requiredVersion = arg;
int64_t rx_apiVersion = APIRECEIVER;
int64_t rx_version = getReceiverVersion();
// old client
if (rx_apiVersion > client_requiredVersion) {
ret = FAIL;
sprintf(mess,"This client is incompatible.\n"
"Client's receiver API Version: (0x%llx). Receiver API Version: (0x%llx).\n"
"Incompatible, update client!\n",
client_requiredVersion, rx_apiVersion);
FILE_LOG(logERROR) << mess;
}
// old software
else if (client_requiredVersion > rx_version) {
ret = FAIL;
sprintf(mess,"This receiver is incompatible.\n"
"Receiver Version: (0x%llx). Client's receiver API Version: (0x%llx).\n"
"Incompatible, update receiver!\n",
rx_version, client_requiredVersion);
FILE_LOG(logERROR) << mess;
}
else FILE_LOG(logINFO) << "Compatibility with Client: Successful";
if (ret == OK && mySock->differentClients)
ret = FORCE_UPDATE;
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if (ret == FAIL)
mySock->SendDataOnly(mess,sizeof(mess));
mySock->SendDataOnly(&retval,sizeof(retval)); // sending crap (because of thisReceiver interface)
// return ok/fail
return ret;
}

View File

@ -0,0 +1,7 @@
SRCFILE=include/gitInfoReceiver.h
DSTFILE=include/versionAPI.h
SRCPATTERN=GITDATE
DSTPATTERN=APIRECEIVER
awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE