configure mac

This commit is contained in:
maliakal_d 2020-08-04 16:55:31 +02:00
parent a70d4e1e5d
commit 380b062216
8 changed files with 81 additions and 5 deletions

View File

@ -236,4 +236,6 @@ int set_filter(int);
int get_adc_config(int);
int set_adc_config(int);
int get_bad_channels(int);
int set_bad_channels(int);
int set_bad_channels(int);
int reconfigure_udp(int);
int validate_udp_configuration(int);

View File

@ -354,6 +354,8 @@ void function_table() {
flist[F_SET_ADC_CONFIGURATION] = &set_adc_config;
flist[F_GET_BAD_CHANNELS] = &get_bad_channels;
flist[F_SET_BAD_CHANNELS] = &set_bad_channels;
flist[F_RECONFIGURE_UDP] = &reconfigure_udp;
flist[F_VALIDATE_UDP_CONFIG] = &validate_udp_configuration;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -4865,13 +4867,13 @@ int check_detector_idle() {
}
int is_configurable() {
if (udpDetails.srcip == 0) {
strcpy(configureMessage, "udp source ip not configured\n");
if (udpDetails.dstip == 0) {
strcpy(configureMessage, "udp destination ip not configured\n");
LOG(logWARNING, ("%s", configureMessage));
return FAIL;
}
if (udpDetails.dstip == 0) {
strcpy(configureMessage, "udp destination ip not configured\n");
if (udpDetails.srcip == 0) {
strcpy(configureMessage, "udp source ip not configured\n");
LOG(logWARNING, ("%s", configureMessage));
return FAIL;
}
@ -7976,3 +7978,37 @@ int set_bad_channels(int file_des) {
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int reconfigure_udp(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
if (Server_VerifyLock() == OK) {
LOG(logINFO, ("Reconfiguring UDP\n"));
if (check_detector_idle() == OK) {
configure_mac();
if (configured == FAIL) {
ret = FAIL;
strcpy(mess, "Invalid UDP Configuration because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
}
}
}
return Server_SendResult(file_des, INT32, NULL, 0);
}
int validate_udp_configuration(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
LOG(logINFO, ("Validating UDP Configuration\n"));
if (configured == FAIL) {
ret = FAIL;
strcpy(mess, "Invalid UDP Configuration because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
}
return Server_SendResult(file_des, INT32, NULL, 0);
}

View File

@ -509,6 +509,10 @@ class Detector {
*/
void setDestinationUDPPort2(int port, int module_id = -1);
void reconfigureUDPDestination(Positions pos = {});
void validateUDPConfiguration(Positions pos = {});
Result<std::string> printRxConfiguration(Positions pos = {}) const;
/** [Eiger][CTB][Moench][Mythen3] */

View File

@ -776,6 +776,8 @@ class CmdProxy {
{"udp_dstmac2", &CmdProxy::udp_dstmac2},
{"udp_dstport", &CmdProxy::udp_dstport},
{"udp_dstport2", &CmdProxy::udp_dstport2},
{"udp_reconfigure", &CmdProxy::udp_reconfigure},
{"udp_validate", &CmdProxy::udp_validate},
{"rx_printconfig", &CmdProxy::rx_printconfig},
{"tengiga", &CmdProxy::tengiga},
{"flowcontrol10g", &CmdProxy::flowcontrol10g},
@ -1645,6 +1647,18 @@ class CmdProxy {
"sent to. \n[Eiger] Port number of the reciever (desintation) udp "
"interface where the right half of the detector data is sent to.");
EXECUTE_SET_COMMAND(
udp_reconfigure, reconfigureUDPDestination,
"\n\tReconfigures Detector with UDP destination. More for debugging as "
"the configuration is done automatically when the detector has "
"sufficient UDP details.");
EXECUTE_SET_COMMAND(
udp_validate, validateUDPConfiguration,
"\n\tValidates that UDP configuration in the detector is "
"valid. If not configured, it will throw with error message "
"requesting missing udp information.");
GET_COMMAND(rx_printconfig, printRxConfiguration,
"\n\tPrints the receiver configuration.");

View File

@ -716,6 +716,14 @@ void Detector::setDestinationUDPPort2(int port, int module_id) {
}
}
void Detector::reconfigureUDPDestination(Positions pos) {
pimpl->Parallel(&Module::reconfigureUDPDestination, pos);
}
void Detector::validateUDPConfiguration(Positions pos) {
pimpl->Parallel(&Module::validateUDPConfiguration, pos);
}
Result<std::string> Detector::printRxConfiguration(Positions pos) const {
return pimpl->Parallel(&Module::printReceiverConfiguration, pos);
}

View File

@ -638,6 +638,12 @@ void Module::setDestinationUDPPort2(const int port) {
}
}
void Module::reconfigureUDPDestination() { sendToDetector(F_RECONFIGURE_UDP); }
void Module::validateUDPConfiguration() {
sendToDetector(F_VALIDATE_UDP_CONFIG);
}
std::string Module::printReceiverConfiguration() {
std::ostringstream os;
os << "\n\nDetector " << moduleId << "\nReceiver Hostname:\t"

View File

@ -202,6 +202,8 @@ class Module : public virtual slsDetectorDefs {
void setDestinationUDPPort(int udpport);
int getDestinationUDPPort2() const;
void setDestinationUDPPort2(int udpport);
void reconfigureUDPDestination();
void validateUDPConfiguration();
std::string printReceiverConfiguration();
bool getTenGiga() const;
void setTenGiga(bool value);

View File

@ -211,6 +211,8 @@ enum detFuncs {
F_SET_ADC_CONFIGURATION,
F_GET_BAD_CHANNELS,
F_SET_BAD_CHANNELS,
F_RECONFIGURE_UDP,
F_VALIDATE_UDP_CONFIG,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
@ -523,6 +525,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_GET_ADC_CONFIGURATION: return "F_GET_ADC_CONFIGURATION";
case F_GET_BAD_CHANNELS: return "F_GET_BAD_CHANNELS";
case F_SET_BAD_CHANNELS: return "F_SET_BAD_CHANNELS";
case F_RECONFIGURE_UDP: return "F_RECONFIGURE_UDP";
case F_VALIDATE_UDP_CONFIG: return "F_VALIDATE_UDP_CONFIG";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";