Skip to content

Commit

Permalink
For Ethernet-only, flush receive buffer before sending broadcast read…
Browse files Browse the repository at this point in the history
… request
  • Loading branch information
Peter Kazanzides committed Apr 8, 2024
1 parent f1f26ac commit 00374b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
34 changes: 23 additions & 11 deletions lib/code/EthBasePort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,16 @@ bool EthBasePort::WriteBroadcastOutput(quadlet_t *buffer, unsigned int size)

bool EthBasePort::WriteBroadcastReadRequest(unsigned int seq)
{
if (!useFwBridge) {
// Ethernet-only system automatically sends a response packet in response to
// the broadcast read request, so we first flush any existing packets.
// When using the Ethernet/Firewire bridge, the flush happens in ReadBlockNode,
// which is called by BasePort::ReceiveBroadcastReadResponse.
int numFlushed = PacketFlushAll();
if (numFlushed > 0)
outStr << "WriteBroadcastReadRequest: flushed " << numFlushed << " packets"
<< ", seq = " << seq << std::endl;
}
quadlet_t bcReqData = (seq << 16) | BoardInUseMask_;
return WriteQuadlet(FW_NODE_BROADCAST, 0x1800, bcReqData);
}
Expand Down Expand Up @@ -893,17 +903,19 @@ bool EthBasePort::ReceiveBroadcastReadResponse(quadlet_t *rdata, unsigned int nb
nodeid_t src_node;
// Use FW_NODE_BROADCAST because we do not care which board responds
ret = ReceiveResponseNode(FW_NODE_BROADCAST, rdata, nbytes, fw_tl, &src_node);
unsigned char newHubBoard = Node2Board[src_node];
if (newHubBoard >= BoardIO::MAX_BOARDS) {
// Should not happen
outStr << "ReceiveBroadcastReadResponse: invalid source node " << src_node << std::endl;
}
else if (newHubBoard != HubBoard) {
// Not printing message because current hub board is shown in qladisp
// outStr << "ReceiveBroadcastReadResponse: changing hub board from "
// << static_cast<unsigned int>(HubBoard) << " to "
// << static_cast<unsigned int>(newHubBoard) << std::endl;
HubBoard = newHubBoard;
if (ret) {
unsigned char newHubBoard = Node2Board[src_node];
if (newHubBoard >= BoardIO::MAX_BOARDS) {
// Should not happen
outStr << "ReceiveBroadcastReadResponse: invalid source node " << src_node << std::endl;
}
else if (newHubBoard != HubBoard) {
// Not printing message because current hub board is shown in qladisp
// outStr << "ReceiveBroadcastReadResponse: changing hub board from "
// << static_cast<unsigned int>(HubBoard) << " to "
// << static_cast<unsigned int>(newHubBoard) << std::endl;
HubBoard = newHubBoard;
}
}
}
return ret;
Expand Down
6 changes: 5 additions & 1 deletion tests/qladisp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ int main(int argc, char** argv)
}
}
}
bool allValid = true;
for (unsigned int axisNum = 1; axisNum <= numAxes; axisNum++) {
j = Axis2BoardNum[axisNum];
unsigned int dx = (axisNum-1)*13; // offset between columns
Expand Down Expand Up @@ -817,6 +818,9 @@ int main(int argc, char** argv)
}
}
}
else {
allValid = false;
}
}
unsigned int bdx = 0;
for (j = 0; j < numDisp; j++) {
Expand Down Expand Up @@ -887,7 +891,7 @@ int main(int argc, char** argv)
}
if (showTime) {
console.Print(STATUS_LINE+5, lm+53, "%8.3lf", pcTime);
if (protocol == BasePort::PROTOCOL_BC_QRW) {
if ((protocol == BasePort::PROTOCOL_BC_QRW) && allValid) {
BasePort::BroadcastReadInfo bcReadInfo;
bcReadInfo = Port->GetBroadcastReadInfo();
std::stringstream timingStr;
Expand Down

0 comments on commit 00374b3

Please sign in to comment.