mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-11 12:27:14 +02:00
localhost works as a receiver now
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@426 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -755,9 +755,9 @@ int startReceiver(int start) {
|
|||||||
bus_w(CONFIG_REG,reg&(~CPU_OR_RECEIVER_BIT));
|
bus_w(CONFIG_REG,reg&(~CPU_OR_RECEIVER_BIT));
|
||||||
|
|
||||||
reg=bus_r(addr);
|
reg=bus_r(addr);
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("Config Reg %x\n", reg);
|
printf("Config Reg %x\n", reg);
|
||||||
#endif
|
//#endif
|
||||||
int d =reg&CPU_OR_RECEIVER_BIT;
|
int d =reg&CPU_OR_RECEIVER_BIT;
|
||||||
if(d!=0) d=1;
|
if(d!=0) d=1;
|
||||||
if(d!=start)
|
if(d!=start)
|
||||||
|
@ -4610,17 +4610,24 @@ int slsDetector::setUDPConnection(){
|
|||||||
|
|
||||||
//if no udp ip given, use hostname
|
//if no udp ip given, use hostname
|
||||||
if(!strcmp(thisDetector->receiverUDPIP,"none")){
|
if(!strcmp(thisDetector->receiverUDPIP,"none")){
|
||||||
//hostname is an ip address
|
if(!strcmp(thisDetector->receiver_hostname,"localhost")){
|
||||||
if(strchr(thisDetector->receiver_hostname,'.')!=NULL)
|
string temp = genericSocket::ipToName("localhost");
|
||||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
strcpy(thisDetector->receiverUDPIP,temp.c_str());
|
||||||
//if hostname not ip, convert it to ip
|
temp = genericSocket::nameToMac(genericSocket::ipToName(temp));
|
||||||
else{
|
strcpy(thisDetector->receiverUDPMAC,temp.c_str());
|
||||||
struct hostent *he = gethostbyname(thisDetector->receiver_hostname);
|
}else{
|
||||||
if (he == NULL){
|
//hostname is an ip address
|
||||||
std::cout << "no rx_udpip given and could not convert receiver hostname to ip" << endl;
|
if(strchr(thisDetector->receiver_hostname,'.')!=NULL)
|
||||||
return FAIL;
|
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
||||||
}else
|
//if hostname not ip, convert it to ip
|
||||||
strcpy(thisDetector->receiverUDPIP,inet_ntoa(*(struct in_addr*)he->h_addr));
|
else{
|
||||||
|
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;
|
||||||
|
}else
|
||||||
|
strcpy(thisDetector->receiverUDPIP,inet_ntoa(*(struct in_addr*)he->h_addr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4630,29 +4637,37 @@ int slsDetector::setUDPConnection(){
|
|||||||
sprintf(args[1],"%d",thisDetector->receiverUDPPort);
|
sprintf(args[1],"%d",thisDetector->receiverUDPPort);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//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
|
||||||
std::cout << "Setting up UDP Connection for Receiver " << arg[0] << "\t" << arg[1] << std::endl;
|
std::cout << "Setting up UDP Connection for Receiver " << args[0] << "\t" << args[1] << std::endl;
|
||||||
#endif
|
#endif
|
||||||
ret=thisReceiver->sendUDPDetails(fnum,retval,args);
|
|
||||||
|
|
||||||
if(ret!=FAIL){
|
//already have mac address if localhost
|
||||||
|
if(!strcmp(thisDetector->receiver_hostname,"localhost"))
|
||||||
|
ret=OK;
|
||||||
|
|
||||||
|
//get mac address from receiver
|
||||||
|
else{
|
||||||
|
ret=thisReceiver->sendUDPDetails(fnum,retval,args);
|
||||||
|
if(ret!=FAIL){
|
||||||
|
strcpy(thisDetector->receiverUDPMAC,retval);
|
||||||
|
}
|
||||||
|
if(ret==FORCE_UPDATE)
|
||||||
|
updateReceiver();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Receiver mac address: " << retval << std::endl;
|
std::cout << "Receiver mac address: " << thisDetector->receiverUDPMAC << std::endl;
|
||||||
#endif
|
#endif
|
||||||
strcpy(thisDetector->receiverUDPMAC,retval);
|
|
||||||
|
|
||||||
//configure detector with udp details
|
//configure detector with udp details
|
||||||
|
if(ret!=FAIL){
|
||||||
if(configureMAC()!=OK){
|
if(configureMAC()!=OK){
|
||||||
setReceiverOnline(OFFLINE_FLAG);
|
setReceiverOnline(OFFLINE_FLAG);
|
||||||
std::cout << "could not configure mac" << endl;
|
std::cout << "could not configure mac" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret==FORCE_UPDATE)
|
|
||||||
updateReceiver();
|
|
||||||
}else{
|
}else{
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
std::cout << "cannot connect to receiver" << endl;
|
||||||
@ -4674,17 +4689,25 @@ int slsDetector::configureMAC(int adc){
|
|||||||
|
|
||||||
//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 localhost
|
||||||
if(strchr(thisDetector->receiver_hostname,'.')!=NULL)
|
if(!strcmp(thisDetector->receiver_hostname,"localhost")){
|
||||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
string temp = genericSocket::ipToName("localhost");
|
||||||
//if hostname not ip, convert it to ip
|
strcpy(thisDetector->receiverUDPIP,temp.c_str());
|
||||||
else{
|
temp = genericSocket::nameToMac(genericSocket::ipToName(temp));
|
||||||
struct hostent *he = gethostbyname(thisDetector->receiver_hostname);
|
strcpy(thisDetector->receiverUDPMAC,temp.c_str());
|
||||||
if (he != NULL)
|
}else{
|
||||||
strcpy(thisDetector->receiverUDPIP,inet_ntoa(*(struct in_addr*)he->h_addr));
|
//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 << "no rx_udpip given and invalid receiver hostname" << endl;
|
struct hostent *he = gethostbyname(thisDetector->receiver_hostname);
|
||||||
return FAIL;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,10 +233,11 @@ int slsReceiverFunctionList::startListening(){
|
|||||||
do {
|
do {
|
||||||
|
|
||||||
if(!strlen(eth)){
|
if(!strlen(eth)){
|
||||||
cout<<"error:eth is empty:"<<eth<<endl;
|
cout<<"warning:eth is empty.listening to all"<<endl;
|
||||||
break;
|
udpSocket = new genericSocket(server_port,genericSocket::UDP);
|
||||||
}
|
}else
|
||||||
udpSocket = new genericSocket(server_port,genericSocket::UDP,eth);
|
udpSocket = new genericSocket(server_port,genericSocket::UDP,eth);
|
||||||
|
|
||||||
if (udpSocket->getErrorStatus()){
|
if (udpSocket->getErrorStatus()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user