diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 59698838a..8daf5a725 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -4610,24 +4610,17 @@ int slsDetector::setUDPConnection(){ //if no udp ip given, use hostname if(!strcmp(thisDetector->receiverUDPIP,"none")){ - if(!strcmp(thisDetector->receiver_hostname,"localhost")){ - string temp = genericSocket::ipToName("localhost"); - strcpy(thisDetector->receiverUDPIP,temp.c_str()); - temp = genericSocket::nameToMac(genericSocket::ipToName(temp)); - strcpy(thisDetector->receiverUDPMAC,temp.c_str()); - }else{ - //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{ - 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)); - } + //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{ + 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)); } } @@ -4635,39 +4628,32 @@ int slsDetector::setUDPConnection(){ //copy arguments to args[][] strcpy(args[0],thisDetector->receiverUDPIP); sprintf(args[1],"%d",thisDetector->receiverUDPPort); - +#ifdef VERBOSE + std::cout << "Receiver ip address: " << thisDetector->receiverUDPIP << std::endl; +#endif //set up receiver for UDP Connection and get receivermac address if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ #ifdef VERBOSE - std::cout << "Setting up UDP Connection for Receiver " << args[0] << "\t" << args[1] << std::endl; + std::cout << "Setting up UDP Connection for Receiver " << args[0] << "\t" << args[1] << std::endl; #endif - //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(); - } + ret=thisReceiver->sendUDPDetails(fnum,retval,args); + if(ret!=FAIL){ + strcpy(thisDetector->receiverUDPMAC,retval); #ifdef VERBOSE - std::cout << "Receiver mac address: " << thisDetector->receiverUDPMAC << std::endl; + std::cout << "Receiver mac address: " << thisDetector->receiverUDPMAC << std::endl; #endif + if(ret==FORCE_UPDATE) + updateReceiver(); //configure detector with udp details - if(ret!=FAIL){ - if(configureMAC()!=OK){ - setReceiverOnline(OFFLINE_FLAG); - std::cout << "could not configure mac" << endl; - } + if(configureMAC()!=OK){ + setReceiverOnline(OFFLINE_FLAG); + std::cout << "could not configure mac" << endl; } + } }else{ ret=FAIL; std::cout << "cannot connect to receiver" << endl; @@ -4689,27 +4675,19 @@ int slsDetector::configureMAC(int adc){ //if udpip wasnt initialized in config file if(!(strcmp(thisDetector->receiverUDPIP,"none"))){ - //if localhost - if(!strcmp(thisDetector->receiver_hostname,"localhost")){ - string temp = genericSocket::ipToName("localhost"); - strcpy(thisDetector->receiverUDPIP,temp.c_str()); - temp = genericSocket::nameToMac(genericSocket::ipToName(temp)); - strcpy(thisDetector->receiverUDPMAC,temp.c_str()); - }else{ - //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{ - 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; - } - } - } + //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{ + 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[1],thisDetector->receiverUDPMAC);