Skip to content

Commit

Permalink
Updated ethswitch to print list of board numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
pkazanzides committed Apr 1, 2024
1 parent 98430d9 commit 05dc9c5
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/ethswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,28 @@ bool GetBit(uint16_t value, uint16_t inPort, uint16_t outPort)
return value & (1 << offset);
}

// Convert bitmask to list of board numbers
const char *PrintFpgaList(uint16_t fpgaList)
{
static char buffer[128];
char *p = buffer;
for (size_t i = 0; i < 16; i++) {
if (fpgaList & (1<<i)) {
if (p != buffer)
*p++ = ' ';
if (i < 10) {
*p++ = '0'+i;
}
else {
*p++ = '1';
*p++ = '0'+(i-10);
}
}
}
*p = 0;
return buffer;
}

void PrintDebugStream(std::stringstream &debugStream)
{
std::cerr << debugStream.str() << std::endl;
Expand Down Expand Up @@ -311,8 +333,8 @@ int main(int argc, char** argv)
UdpMulticastFpga = data->UdpMulticastFpga;
console.Print(36, lm+64, EthUdpPort::IP_String(bswap_32(UdpMulticastFpga)).c_str());
}
console.Print(37, lm+16, "%6x", data->PortForwardFpga[0]);
console.Print(37, lm+32, "%6x", data->PortForwardFpga[1]);
console.Print(37, lm+16, PrintFpgaList(data->PortForwardFpga[0]));
console.Print(37, lm+32, PrintFpgaList(data->PortForwardFpga[1]));
}
}

Expand Down

0 comments on commit 05dc9c5

Please sign in to comment.