mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 00:00:02 +02:00
now u can use receiver hostname instead of only ip, got rid of acqtest, separated udpip and port from setudpconnection
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@372 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
ac2c4211e2
commit
9341a2875a
@ -4439,6 +4439,8 @@ int slsDetector::exitServer(){
|
|||||||
|
|
||||||
|
|
||||||
char* slsDetector::setNetworkParameter(networkParameter index, string value) {
|
char* slsDetector::setNetworkParameter(networkParameter index, string value) {
|
||||||
|
char* answer;
|
||||||
|
int i;
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case DETECTOR_MAC:
|
case DETECTOR_MAC:
|
||||||
@ -4446,17 +4448,19 @@ char* slsDetector::setNetworkParameter(networkParameter index, string value) {
|
|||||||
case RECEIVER_HOSTNAME:
|
case RECEIVER_HOSTNAME:
|
||||||
return setReceiver(value);
|
return setReceiver(value);
|
||||||
case RECEIVER_UDP_IP:
|
case RECEIVER_UDP_IP:
|
||||||
setUDPConnection(value,"");
|
return setReceiverUDPIP(value);
|
||||||
return getReceiverUDPIP();
|
|
||||||
case RECEIVER_UDP_PORT:
|
case RECEIVER_UDP_PORT:
|
||||||
setUDPConnection("",value);
|
sscanf(value.c_str(),"%d",&i);
|
||||||
return getReceiverUDPPort();
|
sprintf(answer,"%d",setReceiverUDPPort(i));
|
||||||
|
return answer;
|
||||||
default:
|
default:
|
||||||
return ("unknown network parameter");
|
return ("unknown network parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char* slsDetector::getNetworkParameter(networkParameter index) {
|
char* slsDetector::getNetworkParameter(networkParameter index) {
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
@ -4481,39 +4485,6 @@ char* slsDetector::getNetworkParameter(networkParameter index) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char* slsDetector::setReceiver(string receiverIP){
|
|
||||||
|
|
||||||
|
|
||||||
int wrongFormat=1;
|
|
||||||
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
if(receiverIP.length()<16){
|
|
||||||
int result = inet_pton(AF_INET, receiverIP.c_str(), &(sa.sin_addr));
|
|
||||||
if(result!=0){
|
|
||||||
strcpy(thisDetector->receiver_hostname,receiverIP.c_str());
|
|
||||||
wrongFormat=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(wrongFormat)
|
|
||||||
std::cout<< "IP Address should be VALID and in xxx.xxx.xxx.xxx format" << endl;
|
|
||||||
else{
|
|
||||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
|
||||||
|
|
||||||
setFilePath(fileIO::getFilePath());
|
|
||||||
setFileName(fileIO::getFileName());
|
|
||||||
setFileIndex(fileIO::getFileIndex());
|
|
||||||
setUDPConnection("","");
|
|
||||||
}else
|
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return thisDetector->receiver_hostname;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char* slsDetector::setDetectorMAC(string detectorMAC){
|
char* slsDetector::setDetectorMAC(string detectorMAC){
|
||||||
if(detectorMAC.length()==17){
|
if(detectorMAC.length()==17){
|
||||||
if((detectorMAC[2]==':')&&(detectorMAC[5]==':')&&(detectorMAC[8]==':')&&
|
if((detectorMAC[2]==':')&&(detectorMAC[5]==':')&&(detectorMAC[8]==':')&&
|
||||||
@ -4530,35 +4501,77 @@ char* slsDetector::setDetectorMAC(string detectorMAC){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::setUDPConnection(string udpip, string udpport){
|
|
||||||
|
|
||||||
int ret = FAIL;
|
|
||||||
int fnum = F_SETUP_UDP;
|
char* slsDetector::setReceiver(string receiverIP){
|
||||||
char args[2][MAX_STR_LENGTH];
|
|
||||||
char retval[MAX_STR_LENGTH]="";
|
strcpy(thisDetector->receiver_hostname,receiverIP.c_str());
|
||||||
|
|
||||||
|
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
|
setFilePath(fileIO::getFilePath());
|
||||||
|
setFileName(fileIO::getFileName());
|
||||||
|
setFileIndex(fileIO::getFileIndex());
|
||||||
|
setUDPConnection();
|
||||||
|
}else
|
||||||
|
std::cout << "cannot connect to receiver" << endl;
|
||||||
|
|
||||||
|
|
||||||
|
return thisDetector->receiver_hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char* slsDetector::setReceiverUDPIP(string udpip){
|
||||||
struct sockaddr_in sa;
|
struct sockaddr_in sa;
|
||||||
|
//taking function arguments into consideration
|
||||||
|
|
||||||
|
|
||||||
//if no udp ip given
|
|
||||||
/*convert to IP if its only a hostname**/
|
|
||||||
if(!strcmp(thisDetector->receiverUDPIP,"none"))
|
|
||||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
|
||||||
|
|
||||||
//copy to member if given in argument
|
|
||||||
if(udpip.length()){
|
if(udpip.length()){
|
||||||
if(udpip.length()<16){
|
if(udpip.length()<16){
|
||||||
int result = inet_pton(AF_INET, udpip.c_str(), &(sa.sin_addr));
|
int result = inet_pton(AF_INET, udpip.c_str(), &(sa.sin_addr));
|
||||||
if(result!=0)
|
if(result!=0)
|
||||||
strcpy(thisDetector->receiverUDPIP,udpip.c_str());
|
strcpy(thisDetector->receiverUDPIP,udpip.c_str());
|
||||||
|
else
|
||||||
|
return ("Receiver UDP IP Address should be VALID and in xxx.xxx.xxx.xxx format");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return thisDetector->receiverUDPIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::setReceiverUDPPort(int udpport){
|
||||||
|
thisDetector->receiverUDPPort = udpport;
|
||||||
|
return thisDetector->receiverUDPPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::setUDPConnection(){
|
||||||
|
|
||||||
|
int ret = FAIL;
|
||||||
|
int fnum = F_SETUP_UDP;
|
||||||
|
char args[2][MAX_STR_LENGTH];
|
||||||
|
char retval[MAX_STR_LENGTH]="";
|
||||||
|
|
||||||
|
|
||||||
|
//if no udp ip given, use hostname
|
||||||
|
if(!strcmp(thisDetector->receiverUDPIP,"none")){
|
||||||
|
//hostname is an ip address
|
||||||
|
if(strchr(thisDetector->receiver_hostname,'.')!=NULL)
|
||||||
|
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
||||||
|
//if hostname not ip, convert it to ip
|
||||||
else{
|
else{
|
||||||
std::cout<< "Receiver UDP IP Address should be VALID and in xxx.xxx.xxx.xxx format" << endl;
|
struct hostent *he = gethostbyname(thisDetector->receiver_hostname);
|
||||||
|
if (he == NULL){
|
||||||
|
std::cout << "no rx_udpip given and could not convert receiver hostname to ip" << endl;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}else
|
||||||
|
strcpy(thisDetector->receiverUDPIP,inet_ntoa(*(struct in_addr*)he->h_addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(udpport.length())
|
|
||||||
sscanf(udpport.c_str(),"%d",&thisDetector->receiverUDPPort);
|
|
||||||
|
|
||||||
|
|
||||||
//copy arguments to args[][]
|
//copy arguments to args[][]
|
||||||
@ -4567,7 +4580,6 @@ int slsDetector::setUDPConnection(string udpip, string udpport){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//set up receiver for UDP Connection and get receivermac address
|
//set up receiver for UDP Connection and get receivermac address
|
||||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -4580,9 +4592,6 @@ int slsDetector::setUDPConnection(string udpip, string udpport){
|
|||||||
std::cout << "Receiver mac address: " << retval << std::endl;
|
std::cout << "Receiver mac address: " << retval << std::endl;
|
||||||
#endif
|
#endif
|
||||||
strcpy(thisDetector->receiverUDPMAC,retval);
|
strcpy(thisDetector->receiverUDPMAC,retval);
|
||||||
strcpy(thisDetector->receiverUDPIP,args[0]);
|
|
||||||
sscanf(args[1],"%d",&thisDetector->receiverUDPPort);
|
|
||||||
|
|
||||||
|
|
||||||
//configure detector with udp details
|
//configure detector with udp details
|
||||||
if(configureMAC()!=OK){
|
if(configureMAC()!=OK){
|
||||||
@ -4611,9 +4620,23 @@ int slsDetector::configureMAC(int adc){
|
|||||||
char arg[4][50];
|
char arg[4][50];
|
||||||
char cword[50]="", *pcword;
|
char cword[50]="", *pcword;
|
||||||
string sword;
|
string sword;
|
||||||
|
|
||||||
//if udpip wasnt initialized in config file
|
//if udpip wasnt initialized in config file
|
||||||
if(!(strcmp(thisDetector->receiverUDPIP,"none")))
|
if(!(strcmp(thisDetector->receiverUDPIP,"none"))){
|
||||||
|
//hostname is an ip address
|
||||||
|
if(strchr(thisDetector->receiver_hostname,'.')!=NULL)
|
||||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
||||||
|
//if hostname not ip, convert it to ip
|
||||||
|
else{
|
||||||
|
struct hostent *he = gethostbyname(thisDetector->receiver_hostname);
|
||||||
|
if (he != NULL)
|
||||||
|
strcpy(thisDetector->receiverUDPIP,inet_ntoa(*(struct in_addr*)he->h_addr));
|
||||||
|
else{
|
||||||
|
std::cout << "no rx_udpip given and invalid receiver hostname" << endl;
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
strcpy(arg[0],thisDetector->receiverUDPIP);
|
strcpy(arg[0],thisDetector->receiverUDPIP);
|
||||||
strcpy(arg[1],thisDetector->receiverUDPMAC);
|
strcpy(arg[1],thisDetector->receiverUDPMAC);
|
||||||
strcpy(arg[2],thisDetector->detectorMAC);
|
strcpy(arg[2],thisDetector->detectorMAC);
|
||||||
|
@ -1629,9 +1629,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
char* setDetectorMAC(string serverMAC);
|
char* setDetectorMAC(string serverMAC);
|
||||||
/** validates and sets the receiver IP address/hostname \sa sharedSlsDetector */
|
/** validates and sets the receiver IP address/hostname \sa sharedSlsDetector */
|
||||||
char* setReceiver(string receiver);
|
char* setReceiver(string receiver);
|
||||||
|
/** validates the format of receiver udp ip and sets it \sa sharedSlsDetector */
|
||||||
|
char* setReceiverUDPIP(string udpip);
|
||||||
|
/** sets the receiver udp port \sa sharedSlsDetector */
|
||||||
|
int setReceiverUDPPort(int udpport);
|
||||||
|
|
||||||
/** Gets MAC from receiver and sets up UDP Connection */
|
/** Gets MAC from receiver and sets up UDP Connection */
|
||||||
int setUDPConnection(string udpip, string udpport);
|
int setUDPConnection();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -431,10 +431,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
descrToFuncMap[i].m_pFuncName="acqtest"; //
|
|
||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest;
|
|
||||||
i++;
|
|
||||||
|
|
||||||
descrToFuncMap[i].m_pFuncName="reg"; //
|
descrToFuncMap[i].m_pFuncName="reg"; //
|
||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister;
|
||||||
i++;
|
i++;
|
||||||
@ -2232,10 +2228,10 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
|
|||||||
t=DETECTOR_MAC;
|
t=DETECTOR_MAC;
|
||||||
} else if (cmd=="rx_hostname") {
|
} else if (cmd=="rx_hostname") {
|
||||||
t=RECEIVER_HOSTNAME;
|
t=RECEIVER_HOSTNAME;
|
||||||
} else if (cmd=="rx_udpport") {
|
|
||||||
t=RECEIVER_UDP_PORT;
|
|
||||||
} else if (cmd=="rx_udpip") {
|
} else if (cmd=="rx_udpip") {
|
||||||
t=RECEIVER_UDP_IP;
|
t=RECEIVER_UDP_IP;
|
||||||
|
} else if (cmd=="rx_udpport") {
|
||||||
|
t=RECEIVER_UDP_PORT;
|
||||||
if (!(sscanf(args[1],"%d",&i)))
|
if (!(sscanf(args[1],"%d",&i)))
|
||||||
return ("cannot parse argument") + string(args[1]);
|
return ("cannot parse argument") + string(args[1]);
|
||||||
} else return ("unknown network parameter")+cmd;
|
} else return ("unknown network parameter")+cmd;
|
||||||
@ -2814,20 +2810,6 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) {
|
|||||||
return string("undefined number");
|
return string("undefined number");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd=="acqtest") {
|
|
||||||
if (action==GET_ACTION)
|
|
||||||
return string("cannot get ")+cmd;
|
|
||||||
int ival=-1;
|
|
||||||
if (sscanf(args[1],"%d",&ival)) {
|
|
||||||
if(ival<1)
|
|
||||||
return helpDigiTest(narg, args, action);
|
|
||||||
else {
|
|
||||||
sprintf(answer,"%x",myDet->testFunction(ival));
|
|
||||||
return string(answer);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return string("undefined number");
|
|
||||||
}
|
|
||||||
|
|
||||||
return string("unknown digital test mode ")+cmd;
|
return string("unknown digital test mode ")+cmd;
|
||||||
|
|
||||||
@ -2842,8 +2824,7 @@ string slsDetectorCommand::helpDigiTest(int narg, char *args[], int action) {
|
|||||||
os << "bustest \t performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes."<< std::endl;
|
os << "bustest \t performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes."<< std::endl;
|
||||||
}
|
}
|
||||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
if (action==PUT_ACTION || action==HELP_ACTION) {
|
||||||
os << "digibittest i\t sets a variable in the server to be used in configuremac function. i sets/clears the digital test bit."<< std::endl;
|
os << "digibittest i\t will perform test which will plot the unique channel identifier, instead of data."<< std::endl;
|
||||||
os << "acqtest i\t runs start acquisition i number of times."<< std::endl;
|
|
||||||
}
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
@ -612,11 +612,6 @@ void slsDetectorUtils::incrementProgress(int i) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetectorUtils::testFunction(int times) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetectorUtils::retrieveDetectorSetup(string const fname1, int level){
|
int slsDetectorUtils::retrieveDetectorSetup(string const fname1, int level){
|
||||||
|
@ -443,8 +443,6 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** temporary test fucntion */
|
|
||||||
int testFunction(int times=0);
|
|
||||||
/**
|
/**
|
||||||
write register
|
write register
|
||||||
\param addr address
|
\param addr address
|
||||||
|
@ -398,8 +398,7 @@ int slsReceiverFuncs::setup_udp(){
|
|||||||
strcpy(mess,"Error reading from socket\n");
|
strcpy(mess,"Error reading from socket\n");
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
}
|
}
|
||||||
cout<<"args[0]:"<<args[0]<<endl;
|
|
||||||
cout<<"args[1]:"<<args[1]<<endl;
|
|
||||||
// execute action if the arguments correctly arrived
|
// execute action if the arguments correctly arrived
|
||||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
@ -692,14 +691,14 @@ int slsReceiverFuncs::read_frame(){
|
|||||||
|
|
||||||
|
|
||||||
//1 odd, 1 even
|
//1 odd, 1 even
|
||||||
if((index%2)!=index2%2){
|
/*if((index%2)!=index2%2){
|
||||||
//ideal situation (should be odd, even(index+1))
|
//ideal situation (should be odd, even(index+1))
|
||||||
if(index%2){
|
if(index%2){*/
|
||||||
memcpy(retval,((char*) origVal)+2, onedatasize);
|
memcpy(retval,((char*) origVal)+2, onedatasize);
|
||||||
memcpy((((char*)retval)+onedatasize), ((char*) origVal)+8+onedatasize, onedatasize);
|
memcpy((((char*)retval)+onedatasize), ((char*) origVal)+8+onedatasize, onedatasize);
|
||||||
ret=OK;
|
ret=OK;
|
||||||
break;
|
break;
|
||||||
}
|
/*}
|
||||||
|
|
||||||
//swap to even,odd
|
//swap to even,odd
|
||||||
if(index2%2){
|
if(index2%2){
|
||||||
@ -710,7 +709,7 @@ int slsReceiverFuncs::read_frame(){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}*/
|
||||||
strcpy(mess,"could not read frame due to more than 20 mismatched indices\n");
|
strcpy(mess,"could not read frame due to more than 20 mismatched indices\n");
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
count++;
|
count++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user