1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

ips/switch: add more sanity checks for making connections

This commit is contained in:
Daniel Krebs 2018-06-04 17:08:36 +02:00
parent e9add5d602
commit 00fb0363dd

View file

@ -73,9 +73,26 @@ bool
AxiStreamSwitch::connectInternal(const std::string& portSlave,
const std::string& portMaster)
{
// check if slave port exists
try {
getSlavePort(portSlave);
} catch(const std::out_of_range&) {
logger->error("Switch doesn't have a slave port named '{}'", portSlave);
return false;
}
// check if master port exists
try {
getMasterPort(portMaster);
} catch(const std::out_of_range&) {
logger->error("Switch doesn't have a master port named '{}'", portMaster);
return false;
}
if(portSlave.substr(0, 1) != "S" or
portMaster.substr(0, 1) != "M") {
logger->error("sanity check failed");
logger->error("sanity check failed: master {} slave {}",
portMaster, portSlave);
return false;
}