Skip to content

Commit adb309e

Browse files
committed
GateScheduleConfiguratorBase: Added guard conditions to allow unconnected ports.
Previously the port discovery failed for unconnected ports because there was no datarate channel and a connected remote port.
1 parent 09c5c25 commit adb309e

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/inet/linklayer/configurator/gatescheduling/base/GateScheduleConfiguratorBase.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ void GateScheduleConfiguratorBase::addPorts(Input& input) const
106106
port->numGates = subqueue != nullptr ? subqueue->getVectorSize() : -1;
107107
port->module = interface->networkInterface;
108108
port->datarate = bps(interface->networkInterface->getDatarate());
109-
port->propagationTime = check_and_cast<cDatarateChannel *>(interface->networkInterface->getTxTransmissionChannel())->getDelay();
109+
auto channel = dynamic_cast<cDatarateChannel *>(interface->networkInterface->getTxTransmissionChannel());
110+
if (channel != nullptr)
111+
port->propagationTime = channel->getDelay();
110112
port->maxPacketLength = B(interface->networkInterface->getMtu());
111113
port->guardBand = s(port->maxPacketLength / port->datarate).get();
112114
port->maxCycleTime = gateCycleDuration;
@@ -124,15 +126,17 @@ void GateScheduleConfiguratorBase::addPorts(Input& input) const
124126
auto networkInterface = check_and_cast<NetworkInterface *>(port->module);
125127
auto link = findLinkOut(findInterface(node, networkInterface));
126128
auto linkOut = findLinkOut(node, networkInterface->getNodeOutputGateId());
127-
auto remoteNode = check_and_cast<Node *>(linkOut->getLinkOutRemoteNode());
128-
port->endNode = *std::find_if(input.networkNodes.begin(), input.networkNodes.end(), [&] (const auto& networkNode) {
129-
return networkNode->module == remoteNode->module;
130-
});
131-
port->otherPort = *std::find_if(input.ports.begin(), input.ports.end(), [&] (const auto& otherPort) {
132-
return otherPort->module == link->destinationInterface->networkInterface;
133-
});
134-
ASSERT(port->endNode);
135-
ASSERT(port->otherPort);
129+
if (linkOut != nullptr) {
130+
auto remoteNode = check_and_cast<Node *>(linkOut->getLinkOutRemoteNode());
131+
port->endNode = *std::find_if(input.networkNodes.begin(), input.networkNodes.end(), [&] (const auto& networkNode) {
132+
return networkNode->module == remoteNode->module;
133+
});
134+
port->otherPort = *std::find_if(input.ports.begin(), input.ports.end(), [&] (const auto& otherPort) {
135+
return otherPort->module == link->destinationInterface->networkInterface;
136+
});
137+
ASSERT(port->endNode);
138+
ASSERT(port->otherPort);
139+
}
136140
}
137141
}
138142
}

0 commit comments

Comments
 (0)