mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
included serverMAC function for gotthard
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@100 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
e5ab585ab0
commit
e8e1157c1a
@ -506,6 +506,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
strcpy(thisDetector->clientIP,"none");
|
strcpy(thisDetector->clientIP,"none");
|
||||||
/** set client mac address */
|
/** set client mac address */
|
||||||
strcpy(thisDetector->clientMAC,"none");
|
strcpy(thisDetector->clientMAC,"none");
|
||||||
|
/** set server mac address */
|
||||||
|
strcpy(thisDetector->serverMAC,"00:aa:bb:cc:dd:ee");
|
||||||
|
|
||||||
/** sets onlineFlag to OFFLINE_FLAG */
|
/** sets onlineFlag to OFFLINE_FLAG */
|
||||||
thisDetector->onlineFlag=OFFLINE_FLAG;
|
thisDetector->onlineFlag=OFFLINE_FLAG;
|
||||||
@ -5105,27 +5107,43 @@ char* slsDetector::setClientMAC(string clientMAC){
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
char* slsDetector::setServerMAC(string serverMAC){
|
||||||
|
if(serverMAC.length()==17){
|
||||||
|
if((serverMAC[2]==':')&&(serverMAC[5]==':')&&(serverMAC[8]==':')&&
|
||||||
|
(serverMAC[11]==':')&&(serverMAC[14]==':'))
|
||||||
|
sprintf(thisDetector->serverMAC,serverMAC.c_str());
|
||||||
|
else
|
||||||
|
return("server MAC Address should be in xx:xx:xx:xx:xx:xx format");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return("server MAC Address should be in xx:xx:xx:xx:xx:xx format");
|
||||||
|
|
||||||
|
return thisDetector->serverMAC;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::configureMAC(){
|
int slsDetector::configureMAC(int ival){
|
||||||
int retval;
|
int retval,i;
|
||||||
int ret=FAIL;
|
int ret=FAIL;
|
||||||
int fnum=F_CONFIGURE_MAC;
|
int fnum=F_CONFIGURE_MAC;
|
||||||
char mess[100];
|
char mess[100];
|
||||||
char arg[2][50];
|
char arg[3][50];
|
||||||
char cword[50]="", *pcword;
|
char cword[50]="", *pcword;
|
||||||
string sword;
|
string sword;
|
||||||
strcpy(arg[0],getClientIP());
|
strcpy(arg[0],getClientIP());
|
||||||
strcpy(arg[1],getClientMAC());
|
strcpy(arg[1],getClientMAC());
|
||||||
|
strcpy(arg[2],getServerMAC());
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "slsDetector configureMAC "<< std::endl;
|
std::cout<< "slsDetector configureMAC "<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
if(!strcmp(arg[0],"none"))
|
|
||||||
return -1;
|
for(i=0;i<3;i++){
|
||||||
else if(!strcmp(arg[1],"none"))
|
if(!strcmp(arg[i],"none"))
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "IP/MAC Addresses in valid format "<< std::endl;
|
std::cout<< "IP/MAC Addresses in valid format "<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -5148,12 +5166,21 @@ int slsDetector::configureMAC(){
|
|||||||
strcat(arg[1],sword.c_str());
|
strcat(arg[1],sword.c_str());
|
||||||
std::cout<<"arg1:"<<arg[1]<<"."<<std::endl;
|
std::cout<<"arg1:"<<arg[1]<<"."<<std::endl;
|
||||||
|
|
||||||
|
//converting server MACaddress to hex.
|
||||||
|
sword.assign(arg[2]);
|
||||||
|
strcpy(arg[2],"");
|
||||||
|
stringstream ssstr(sword);
|
||||||
|
while(getline(ssstr,sword,':'))
|
||||||
|
strcat(arg[2],sword.c_str());
|
||||||
|
std::cout<<"arg2:"<<arg[2]<<"."<<std::endl;
|
||||||
|
|
||||||
//send to server
|
//send to server
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (controlSocket) {
|
if (controlSocket) {
|
||||||
if (controlSocket->Connect()>=0) {
|
if (controlSocket->Connect()>=0) {
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
controlSocket->SendDataOnly(arg,sizeof(arg));
|
controlSocket->SendDataOnly(arg,sizeof(arg));
|
||||||
|
controlSocket->SendDataOnly(&ival,sizeof(ival));
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=FAIL)
|
if (ret!=FAIL)
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
@ -5729,6 +5756,12 @@ string slsDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
return string(setClientMAC(sval));
|
return string(setClientMAC(sval));
|
||||||
} else
|
} else
|
||||||
return getClientMAC();
|
return getClientMAC();
|
||||||
|
} else if (var=="servermac") {
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
sval=string(args[1]);
|
||||||
|
return string(setServerMAC(sval));
|
||||||
|
} else
|
||||||
|
return getServerMAC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -6436,10 +6469,17 @@ string slsDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
return string(answer);
|
return string(answer);
|
||||||
//gotthard
|
//gotthard
|
||||||
}else if (var=="configuremac") {
|
}else if (var=="configuremac") {
|
||||||
if(configureMAC()==-1)
|
if (action==GET_ACTION) {
|
||||||
|
return string("cannot use GET for this function");
|
||||||
|
} else if (action==PUT_ACTION) {
|
||||||
|
sscanf(args[1],"%d",&ival);
|
||||||
|
if((ival<0)||(ival>1))
|
||||||
|
return string("use only 0/1 to reset/set digital_test_bit");
|
||||||
|
if(configureMAC(ival)==-1)
|
||||||
return string("client ip address/client mac address not valid");
|
return string("client ip address/client mac address not valid");
|
||||||
return string("mac configuration completed");
|
return string("mac configuration completed");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ("Unknown command");
|
return ("Unknown command");
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -7935,7 +7975,8 @@ int slsDetector::writeConfigurationFile(string const fname){
|
|||||||
names[3]="outdir";
|
names[3]="outdir";
|
||||||
names[4]="clientip";
|
names[4]="clientip";
|
||||||
names[5]="clientmac";
|
names[5]="clientmac";
|
||||||
nvar=6;
|
names[6]="servermac";
|
||||||
|
nvar=7;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
nvar=19;
|
nvar=19;
|
||||||
|
@ -315,6 +315,8 @@ typedef struct sharedSlsDetector {
|
|||||||
char clientIP[MAX_STR_LENGTH];
|
char clientIP[MAX_STR_LENGTH];
|
||||||
/** is the mac address of the client for gotthard; read from configuration file **/
|
/** is the mac address of the client for gotthard; read from configuration file **/
|
||||||
char clientMAC[MAX_STR_LENGTH];
|
char clientMAC[MAX_STR_LENGTH];
|
||||||
|
/** is the mac address of the server for gotthard; read from configuration file **/
|
||||||
|
char serverMAC[MAX_STR_LENGTH];
|
||||||
|
|
||||||
} sharedSlsDetector;
|
} sharedSlsDetector;
|
||||||
|
|
||||||
@ -362,8 +364,9 @@ typedef struct sharedSlsDetector {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
configures mac for gotthard readout
|
configures mac for gotthard readout
|
||||||
|
\param ival temporarily used to set/reset the digital test bit
|
||||||
*/
|
*/
|
||||||
int configureMAC();
|
int configureMAC(int ival);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Purely virtual function
|
Purely virtual function
|
||||||
@ -459,11 +462,14 @@ typedef struct sharedSlsDetector {
|
|||||||
char* getClientIP() {return thisDetector->clientIP;};
|
char* getClientIP() {return thisDetector->clientIP;};
|
||||||
/** returns the client MAC address for gotthard \sa sharedSlsDetector */
|
/** returns the client MAC address for gotthard \sa sharedSlsDetector */
|
||||||
char* getClientMAC() {return thisDetector->clientMAC;};
|
char* getClientMAC() {return thisDetector->clientMAC;};
|
||||||
|
/** returns the server MAC address for gotthard \sa sharedSlsDetector */
|
||||||
|
char* getServerMAC() {return thisDetector->serverMAC;};
|
||||||
/** validates and sets the client IP address for gotthard \sa sharedSlsDetector */
|
/** validates and sets the client IP address for gotthard \sa sharedSlsDetector */
|
||||||
char* setClientIP(string clientIP);
|
char* setClientIP(string clientIP);
|
||||||
/** validates the format of client MAC address and sets it for gotthard \sa sharedSlsDetector */
|
/** validates the format of client MAC address and sets it for gotthard \sa sharedSlsDetector */
|
||||||
char* setClientMAC(string clientMAC);
|
char* setClientMAC(string clientMAC);
|
||||||
|
/** validates the format of server MAC address and sets it for gotthard \sa sharedSlsDetector */
|
||||||
|
char* setServerMAC(string serverMAC);
|
||||||
|
|
||||||
/* I/O */
|
/* I/O */
|
||||||
/** returns the detector trimbit/settings directory \sa sharedSlsDetector */
|
/** returns the detector trimbit/settings directory \sa sharedSlsDetector */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user