mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 11:20:04 +02:00
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:
parent
4d4e4a4ce7
commit
cf8b0de433
@ -51,6 +51,7 @@
|
||||
#define PREPARE_ACQUISITION 0x0000100000000000ULL
|
||||
#define CLEANUP_ACQUISITION 0x0000080000000000ULL
|
||||
#define REGISER_WRITE_READ 0x0000040000000000ULL
|
||||
#define VERSION_COMPATIBILITY 0x0000020000000000ULL
|
||||
// 0xFFFFFF0000000000ULL
|
||||
|
||||
// 0x000000FFFFFFFFFFULL
|
||||
@ -170,6 +171,9 @@ public:
|
||||
if(slsErrorMask®ISER_WRITE_READ)
|
||||
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)
|
||||
|
@ -291,7 +291,9 @@ enum idMode{
|
||||
DETECTOR_SOFTWARE_VERSION, /**<return detector system software version */
|
||||
THIS_SOFTWARE_VERSION, /**<return this 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
|
||||
|
@ -119,6 +119,8 @@ enum detFuncs{
|
||||
|
||||
F_AUTO_COMP_DISABLE, /** < auto comp disable mode */
|
||||
F_STORAGE_CELL_START, /** < storage cell start */
|
||||
|
||||
F_CHECK_VERSION, /** < check version compatibility */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
/* Always append functions before!!! */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/** API versions */
|
||||
#define APIRECEIVER 0x20170101
|
||||
#define APIEIGER 0x20170101
|
||||
#define APIJUNGFRAU 0x20170101
|
||||
#define APIRECEIVER 0x180517
|
||||
#define APIEIGER 0x180523
|
||||
#define APIJUNGFRAU 0x180523
|
||||
#define APIGOTTHARD 0x20170101
|
||||
|
Binary file not shown.
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: cb635d800a5e1de6cf3330f03a98ffc382879cf3
|
||||
Revision: 339
|
||||
Branch: mergevirtual
|
||||
Repsitory UUID: 4d4e4a4ce7a91af094251ed0903575ba7e73ef5f
|
||||
Revision: 341
|
||||
Branch: versioning
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3832
|
||||
Last Changed Date: 2018-05-23 11:11:12.000000002 +0200 ./Makefile.virtual
|
||||
Last Changed Rev: 3847
|
||||
Last Changed Date: 2018-05-28 18:02:50.000000002 +0200 ./xparameters.h
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "cb635d800a5e1de6cf3330f03a98ffc382879cf3"
|
||||
#define GITREPUUID "4d4e4a4ce7a91af094251ed0903575ba7e73ef5f"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3832
|
||||
#define GITDATE 0x20180523
|
||||
#define GITBRANCH "mergevirtual"
|
||||
#define GITREV 0x3847
|
||||
#define GITDATE 0x20180528
|
||||
#define GITBRANCH "versioning"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "gitInfoEiger.h"
|
||||
#include "FebControl.h"
|
||||
#include "Beb.h"
|
||||
#include "versionAPI.h"
|
||||
#endif
|
||||
|
||||
int default_tau_from_file= -1;
|
||||
@ -89,18 +90,32 @@ int normal = 0;
|
||||
uint32_t detid = 0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* 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){
|
||||
firmware_compatibility = OK;
|
||||
firmware_check_done = 0;
|
||||
memset(firmware_message, 0, MAX_STR_LENGTH);
|
||||
#ifdef VIRTUAL
|
||||
cprintf(BLUE,"\n\n"
|
||||
"********************************************************\n"
|
||||
"***************** EIGER Virtual Server *****************\n"
|
||||
"********************************************************\n");
|
||||
firmware_check_done = 1;
|
||||
return;
|
||||
#endif
|
||||
uint32_t ipadd = getDetectorIP();
|
||||
@ -108,6 +123,7 @@ void checkFirmwareCompatibility(int flag){
|
||||
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
|
||||
int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_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"
|
||||
"********************************************************\n"
|
||||
@ -120,37 +136,61 @@ void checkFirmwareCompatibility(int flag){
|
||||
"Firmware Version:\t\t %lld\n"
|
||||
"Software Version:\t\t %llx\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",
|
||||
(unsigned int)ipadd,
|
||||
(long long unsigned int)macadd,
|
||||
(long long int)fwversion,
|
||||
(long long int)swversion,
|
||||
(long long int)sw_fw_apiversion,
|
||||
REQUIRED_FIRMWARE_VERSION);
|
||||
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
|
||||
if(!fwversion || !sw_fw_apiversion){
|
||||
cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n");
|
||||
cprintf(RED,"Exiting Server. Goodbye!\n\n");
|
||||
exit(-1);
|
||||
strcpy(firmware_message,
|
||||
"FATAL ERROR: Cant read versions from FPGA. Please update firmware.\n");
|
||||
cprintf(RED,"%s\n\n", firmware_message);
|
||||
firmware_compatibility = FAIL;
|
||||
firmware_check_done = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
//check for API compatibility - old server
|
||||
if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){
|
||||
cprintf(RED,"FATAL ERROR: This software version is incompatible.\n"
|
||||
"Please update it to be compatible with this firmware\n\n");
|
||||
cprintf(RED,"Exiting Server. Goodbye!\n\n");
|
||||
exit(-1);
|
||||
sprintf(firmware_message,
|
||||
"FATAL ERROR: This detector software software version (%lld) is incompatible.\n"
|
||||
"Please update detector software (min. %lld) to be compatible with this firmware.\n",
|
||||
(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
|
||||
if( REQUIRED_FIRMWARE_VERSION > fwversion){
|
||||
cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n"
|
||||
"Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION);
|
||||
cprintf(RED,"Exiting Server. Goodbye!\n\n");
|
||||
exit(-1);
|
||||
sprintf(firmware_message,
|
||||
"FATAL ERROR: This firmware version (%lld) is incompatible.\n"
|
||||
"Please update firmware (min. %lld) to be compatible with this server.\n",
|
||||
(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();
|
||||
case DETECTOR_SOFTWARE_VERSION:
|
||||
return (GITDATE & 0xFFFFFF);
|
||||
case CLIENT_SOFTWARE_API_VERSION:
|
||||
return APIEIGER;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
SRCFILE=gitInfoEiger.h
|
||||
DSTFILE=../commonFiles/versionAPI.h
|
||||
DSTFILE=versionAPI.h
|
||||
|
||||
SRCPATTERN=GITDATE
|
||||
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
|
1
slsDetectorSoftware/eigerDetectorServer/versionAPI.h
Symbolic link
1
slsDetectorSoftware/eigerDetectorServer/versionAPI.h
Symbolic link
@ -0,0 +1 @@
|
||||
../commonFiles/versionAPI.h
|
@ -1,7 +1,7 @@
|
||||
SRCFILE=gitInfoGotthard.h
|
||||
DSTFILE=../commonFiles/versionAPI.h
|
||||
DSTFILE=versionAPI.h
|
||||
|
||||
SRCPATTERN=GITDATE
|
||||
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
|
1
slsDetectorSoftware/gotthardDetectorServer/versionAPI.h
Symbolic link
1
slsDetectorSoftware/gotthardDetectorServer/versionAPI.h
Symbolic link
@ -0,0 +1 @@
|
||||
../commonFiles/versionAPI.h
|
Binary file not shown.
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: cb635d800a5e1de6cf3330f03a98ffc382879cf3
|
||||
Revision: 151
|
||||
Branch: mergevirtual
|
||||
Repsitory UUID: 4d4e4a4ce7a91af094251ed0903575ba7e73ef5f
|
||||
Revision: 153
|
||||
Branch: versioning
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3832
|
||||
Last Changed Date: 2018-05-23 14:42:26.000000002 +0200 ./Makefile.virtual
|
||||
Last Changed Rev: 3847
|
||||
Last Changed Date: 2018-05-28 18:02:50.000000002 +0200 ./RegisterDefs.h
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "cb635d800a5e1de6cf3330f03a98ffc382879cf3"
|
||||
#define GITREPUUID "4d4e4a4ce7a91af094251ed0903575ba7e73ef5f"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3832
|
||||
#define GITDATE 0x20180523
|
||||
#define GITBRANCH "mergevirtual"
|
||||
#define GITREV 0x3847
|
||||
#define GITDATE 0x20180528
|
||||
#define GITBRANCH "versioning"
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "gitInfoJungfrau.h"
|
||||
#include "AD9257.h" // include "commonServerFunctions.h", which in turn includes "blackfin.h"
|
||||
#include "programfpga.h"
|
||||
|
||||
#include "versionAPI.h"
|
||||
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
@ -33,6 +33,19 @@ int virtual_stop = 0;
|
||||
|
||||
/* 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) {
|
||||
#ifdef VIRTUAL
|
||||
cprintf(BLUE,"\n\n"
|
||||
@ -40,23 +53,36 @@ void checkFirmwareCompatibility(int flag) {
|
||||
"************** Jungfrau Virtual Server *****************\n"
|
||||
"********************************************************\n\n");
|
||||
if (mapCSP0() == FAIL) {
|
||||
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
strcpy(firmware_message,
|
||||
"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;
|
||||
#endif
|
||||
|
||||
defineGPIOpins();
|
||||
resetFPGA();
|
||||
if (mapCSP0() == FAIL) {
|
||||
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
strcpy(firmware_message,
|
||||
"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
|
||||
if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
|
||||
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
strcpy(firmware_message,
|
||||
"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();
|
||||
@ -66,6 +92,9 @@ void checkFirmwareCompatibility(int flag) {
|
||||
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
|
||||
int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
|
||||
int64_t sw_fw_apiversion = 0;
|
||||
int64_t client_sw_apiversion = getDetectorId(CLIENT_SOFTWARE_API_VERSION);
|
||||
|
||||
|
||||
if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
|
||||
sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
|
||||
cprintf(BLUE,"\n\n"
|
||||
@ -82,6 +111,7 @@ void checkFirmwareCompatibility(int flag) {
|
||||
"Software Version:\t\t 0x%llx\n"
|
||||
"F/w-S/w API Version:\t\t 0x%llx\n"
|
||||
"Required Firmware Version:\t 0x%x\n"
|
||||
"Client-Software API Version:\t 0x%llx\n"
|
||||
"\n"
|
||||
"********************************************************\n",
|
||||
hversion, hsnumber,
|
||||
@ -90,38 +120,55 @@ void checkFirmwareCompatibility(int flag) {
|
||||
(long long int)fwversion,
|
||||
(long long int)swversion,
|
||||
(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
|
||||
if (flag)
|
||||
return;
|
||||
if (flag) {
|
||||
firmware_check_done = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//cant read versions
|
||||
printf("Testing Firmware-software compatibility ...\n");
|
||||
if(!fwversion || !sw_fw_apiversion){
|
||||
cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n");
|
||||
cprintf(RED,"Exiting Server. Goodbye!\n\n");
|
||||
exit(EXIT_FAILURE);
|
||||
strcpy(firmware_message,
|
||||
"FATAL ERROR: Cant read versions from FPGA. Please update firmware.\n");
|
||||
cprintf(RED,"%s\n\n", firmware_message);
|
||||
firmware_compatibility = FAIL;
|
||||
firmware_check_done = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
//check for API compatibility - old server
|
||||
if(sw_fw_apiversion > REQRD_FRMWR_VRSN){
|
||||
cprintf(RED,"FATAL ERROR: This software version is incompatible.\n"
|
||||
"Please update it to be compatible with this firmware\n\n");
|
||||
cprintf(RED,"Exiting Server. Goodbye!\n\n");
|
||||
exit(EXIT_FAILURE);
|
||||
sprintf(firmware_message,
|
||||
"FATAL ERROR: This detector software software version (0x%llx) is incompatible.\n"
|
||||
"Please update detector software (min. 0x%llx) to be compatible with this firmware.\n",
|
||||
(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
|
||||
if( REQRD_FRMWR_VRSN > fwversion){
|
||||
cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n"
|
||||
"Please update it to v%d to be compatible with this server\n\n", REQRD_FRMWR_VRSN);
|
||||
cprintf(RED,"Exiting Server. Goodbye!\n\n");
|
||||
exit(EXIT_FAILURE);
|
||||
sprintf(firmware_message,
|
||||
"FATAL ERROR: This firmware version (0x%llx) is incompatible.\n"
|
||||
"Please update firmware (min. 0x%llx) to be compatible with this server.\n",
|
||||
(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");
|
||||
firmware_check_done = 1;
|
||||
}
|
||||
|
||||
|
||||
@ -222,6 +269,8 @@ int64_t getDetectorId(enum idMode arg){
|
||||
return getFirmwareAPIVersion();
|
||||
case DETECTOR_SOFTWARE_VERSION:
|
||||
return (GITDATE & 0xFFFFFF);
|
||||
case CLIENT_SOFTWARE_API_VERSION:
|
||||
return APIJUNGFRAU;
|
||||
default:
|
||||
return retval;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define GOODBYE (-200)
|
||||
#define PROGRAMMING_MODE (-200)
|
||||
#define MIN_REQRD_VRSN_T_RD_API 0x171220
|
||||
#define REQRD_FRMWR_VRSN 0x180226
|
||||
#define REQRD_FRMWR_VRSN 0x20180226
|
||||
|
||||
|
||||
/* Struct Definitions */
|
||||
|
@ -1,7 +1,7 @@
|
||||
SRCFILE=gitInfoJungfrau.h
|
||||
DSTFILE=../commonFiles/versionAPI.h
|
||||
DSTFILE=versionAPI.h
|
||||
|
||||
SRCPATTERN=GITDATE
|
||||
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
|
1
slsDetectorSoftware/jungfrauDetectorServer/versionAPI.h
Symbolic link
1
slsDetectorSoftware/jungfrauDetectorServer/versionAPI.h
Symbolic link
@ -0,0 +1 @@
|
||||
../commonFiles/versionAPI.h
|
@ -7021,3 +7021,42 @@ bool multiSlsDetector::isAcquireReady() {
|
||||
thisMultiDetector->acquiringFlag = true;
|
||||
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;
|
||||
}
|
||||
|
@ -1568,6 +1568,14 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
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:
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <cstdlib>
|
||||
#include <math.h>
|
||||
#include "gitInfoLib.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
int slsDetector::initSharedMemory(detectorType type, int id) {
|
||||
@ -806,6 +808,10 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
thisDetector->receiver_read_freq = 0;
|
||||
thisDetector->receiver_framesPerFile = -1;
|
||||
|
||||
thisDetector->detectorControlAPIVersion = 0;
|
||||
thisDetector->detectorStopAPIVersion = 0;
|
||||
thisDetector->receiverAPIVersion = 0;
|
||||
|
||||
for (int ia=0; ia<MAX_ACTIONS; ++ia) {
|
||||
strcpy(thisDetector->actionScript[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){
|
||||
|
||||
char thisName[MAX_STR_LENGTH];
|
||||
int thisCP, thisSP;
|
||||
int retval=OK;
|
||||
@ -1511,6 +1516,22 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
}
|
||||
if (retval!=FAIL) {
|
||||
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 {
|
||||
thisDetector->onlineFlag=OFFLINE_FLAG;
|
||||
#ifdef VERBOSE
|
||||
@ -8364,15 +8385,28 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port
|
||||
}
|
||||
//check if it connects
|
||||
if (retval!=FAIL) {
|
||||
if(checkReceiverOnline().empty())
|
||||
retval=FAIL;
|
||||
checkReceiverOnline();
|
||||
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 {
|
||||
thisDetector->receiverOnlineFlag=OFFLINE_FLAG;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "offline!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
thisReceiver->setSocket(dataSocket);
|
||||
return retval;
|
||||
};
|
||||
|
||||
@ -9821,3 +9855,99 @@ int slsDetector::restreamStopFromReceiver(){
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -290,11 +290,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
/** frames per file in receiver */
|
||||
int receiver_framesPerFile;
|
||||
|
||||
/** detector software API version */
|
||||
int detector_software_api_version;
|
||||
|
||||
/** receiver API version */
|
||||
int receiver_api_version;
|
||||
/** detector control server software API version */
|
||||
int64_t detectorControlAPIVersion;
|
||||
/** detector stop server software API version */
|
||||
int64_t detectorStopAPIVersion;
|
||||
/** receiver server software API version */
|
||||
int64_t receiverAPIVersion;
|
||||
|
||||
|
||||
} sharedSlsDetector;
|
||||
@ -2059,6 +2060,14 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
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:
|
||||
|
||||
|
@ -507,6 +507,22 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
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
|
||||
- <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);
|
||||
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;
|
||||
|
||||
}
|
||||
@ -4903,6 +4937,8 @@ string slsDetectorCommand::helpSN(int narg, char *args[], int action) {
|
||||
|
||||
ostringstream os;
|
||||
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 << "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;
|
||||
|
@ -1029,6 +1029,14 @@ virtual int setReceiverSilentMode(int i = -1)=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:
|
||||
|
||||
|
||||
|
@ -17,6 +17,11 @@ Here are the definitions, but the actual implementation should be done for each
|
||||
|
||||
|
||||
// basic tests
|
||||
#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARD)
|
||||
int isFirmwareCheckDone();
|
||||
int getFirmwareCheckResult(char** mess);
|
||||
#endif
|
||||
|
||||
void checkFirmwareCompatibility(int flag);
|
||||
#if defined(MYTHEN3D) || defined(JUNGFRAUD)
|
||||
int checkType();
|
||||
|
@ -209,6 +209,7 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_TEMP_EVENT: return "F_TEMP_EVENT";
|
||||
case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE";
|
||||
case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START";
|
||||
case F_CHECK_VERSION: return "F_CHECK_VERSION";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
@ -293,6 +294,7 @@ void function_table() {
|
||||
flist[F_TEMP_EVENT] = &temp_event;
|
||||
flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable;
|
||||
flist[F_STORAGE_CELL_START] = &storage_cell_start;
|
||||
flist[F_CHECK_VERSION] = &check_version;
|
||||
|
||||
// check
|
||||
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");
|
||||
#endif
|
||||
|
||||
if (isControlServer)
|
||||
if (isControlServer) {
|
||||
basictests(debugflag);
|
||||
init_detector(isControlServer);
|
||||
initControlServer();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ret==OK)
|
||||
@ -5760,3 +5763,97 @@ int storage_cell_start(int file_des) {
|
||||
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;
|
||||
}
|
||||
|
@ -95,5 +95,6 @@ int temp_control(int);
|
||||
int temp_event(int);
|
||||
int auto_comp_disable(int);
|
||||
int storage_cell_start(int);
|
||||
int check_version(int);
|
||||
|
||||
#endif
|
||||
|
@ -21,7 +21,8 @@ receiverInterface::~receiverInterface(){}
|
||||
|
||||
int receiverInterface::sendString(int fnum, char retval[], char arg[]){
|
||||
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(arg,MAX_STR_LENGTH);
|
||||
@ -30,7 +31,8 @@ int receiverInterface::sendString(int fnum, char retval[], char arg[]){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
}
|
||||
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
||||
|
||||
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]){
|
||||
char args[3][MAX_STR_LENGTH];
|
||||
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(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 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(&arg,sizeof(arg));
|
||||
@ -67,7 +71,8 @@ int receiverInterface::sendInt(int fnum, int &retval, int arg){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
}
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -76,7 +81,8 @@ int receiverInterface::sendInt(int fnum, int &retval, int arg){
|
||||
|
||||
int receiverInterface::getInt(int fnum, int &retval){
|
||||
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->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
@ -84,7 +90,8 @@ int receiverInterface::getInt(int fnum, int &retval){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
}
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
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 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(&arg,sizeof(arg));
|
||||
@ -102,7 +110,8 @@ int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
}
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -111,16 +120,18 @@ 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[]){
|
||||
int64_t args[2];
|
||||
char messs[MAX_STR_LENGTH];
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
memset(mess, 0, MAX_STR_LENGTH);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(arg,sizeof(args));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(messs));
|
||||
dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
}
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
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 args[2];
|
||||
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(arg,sizeof(args));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
@ -138,7 +151,8 @@ int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
}
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -170,6 +184,7 @@ int receiverInterface::getLastClientIP(int fnum, char retval[]){
|
||||
|
||||
int receiverInterface::executeFunction(int fnum,char mess[]){
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
memset(mess, 0, MAX_STR_LENGTH);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
|
@ -105,7 +105,7 @@ private:
|
||||
class SuperTask: public virtual slsDetectorDefs {
|
||||
public:
|
||||
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(){};
|
||||
protected:
|
||||
/** Function signature defined
|
||||
@ -129,6 +129,7 @@ protected:
|
||||
func4_t <int, trimMode,int,int,int>* m16;
|
||||
func4_t <int, int,int,detectorSettings,int>* m17;
|
||||
func4_t <dacs_t, dacs_t,dacIndex,int,int>* m18;
|
||||
func1_t <int, portType>* m19;
|
||||
};
|
||||
|
||||
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, 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(func1_t <int, portType>* t): SuperTask(),fnum(19){m19 = t;};
|
||||
|
||||
virtual ~Task(){
|
||||
switch(fnum) {
|
||||
@ -175,6 +177,7 @@ public:
|
||||
case 16: delete m16; break;
|
||||
case 17: delete m17; break;
|
||||
case 18: delete m18; break;
|
||||
case 19: delete m19; break;
|
||||
default:
|
||||
cprintf(RED, "Error: Task not defined. Abort!\n");
|
||||
break;
|
||||
@ -202,6 +205,7 @@ public:
|
||||
case 16: (*m16)(); break;
|
||||
case 17: (*m17)(); break;
|
||||
case 18: (*m18)(); break;
|
||||
case 19: (*m19)(); break;
|
||||
default:
|
||||
cprintf(RED, "Error: Task not defined. Abort!\n");
|
||||
break;
|
||||
|
@ -309,6 +309,10 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/** set frames per file */
|
||||
int set_frames_per_file();
|
||||
|
||||
|
||||
/** check version compatibility */
|
||||
int check_version_compatibility();
|
||||
|
||||
/** detector type */
|
||||
detectorType myDetectorType;
|
||||
|
||||
|
@ -67,7 +67,7 @@ enum recFuncs{
|
||||
F_RECEIVER_UDP_SOCK_BUF_SIZE, /** < 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_RECEIVER_CHECK_VERSION, /** < check receiver version compatibility */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
|
||||
|
1
slsReceiverSoftware/include/versionAPI.h
Symbolic link
1
slsReceiverSoftware/include/versionAPI.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../slsDetectorSoftware/commonFiles/versionAPI.h
|
@ -674,7 +674,7 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
|
||||
"[/proc/sys/net/core/netdev_max_backlog] modified to %d\n",
|
||||
MAX_SOCKET_INPUT_PACKET_QUEUE);
|
||||
} 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?)";
|
||||
FILE_LOG(logWARNING) << msg;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "gitInfoReceiver.h"
|
||||
#include "slsReceiverUsers.h"
|
||||
#include "slsReceiver.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
#include <stdlib.h> //EXIT
|
||||
#include <iostream>
|
||||
@ -153,7 +154,7 @@ void slsReceiverTCPIPInterface::stop(){
|
||||
|
||||
|
||||
int64_t slsReceiverTCPIPInterface::getReceiverVersion(){
|
||||
int64_t retval = GITDATE;
|
||||
int64_t retval = GITDATE & 0xFFFFFF;
|
||||
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_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_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION";
|
||||
|
||||
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_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_RECEIVER_CHECK_VERSION] = &slsReceiverTCPIPInterface::check_version_compatibility;
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
@ -367,20 +370,22 @@ int slsReceiverTCPIPInterface::decode_function(){
|
||||
ret = FAIL;
|
||||
#ifdef VERYVERBOSE
|
||||
cprintf(RESET,"\n");
|
||||
FILE_LOG(logDEBUG1) << "waiting to receive data";
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1) << "waiting to receive data";
|
||||
int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum));
|
||||
if (n <= 0) {
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logDEBUG1) << "ERROR reading from socket. Received " << n << " bytes, fd: " << file_des << " fnum:" << fnum << " (" << getFunctionName((enum recFuncs)fnum) << ")";
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1) << "ERROR reading from socket. "
|
||||
"Received " << n << " bytes," <<
|
||||
"fnum:" << fnum << " "
|
||||
"(" << getFunctionName((enum recFuncs)fnum) << ")";
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
else
|
||||
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) {
|
||||
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;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int n = 0;
|
||||
@ -438,7 +443,7 @@ int slsReceiverTCPIPInterface::M_nofunc(){
|
||||
while (n > 0)
|
||||
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;
|
||||
|
||||
// send ok / fail
|
||||
@ -2758,3 +2763,60 @@ int slsReceiverTCPIPInterface::set_frames_per_file() {
|
||||
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;
|
||||
}
|
||||
|
||||
|
7
slsReceiverSoftware/updateAPIVersion.sh
Executable file
7
slsReceiverSoftware/updateAPIVersion.sh
Executable 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
|
Loading…
x
Reference in New Issue
Block a user