Bindings: Python: Add EthPhyMessage

Also fixes PhyMessages for RADEpsilon(XL)
This commit is contained in:
Kyle Schwarz
2025-09-29 17:17:26 -04:00
parent f22d666f94
commit 11643e2281
11 changed files with 82 additions and 31 deletions
+9 -9
View File
@@ -8,7 +8,7 @@ bool EthPhyMessage::appendPhyMessage(bool writeEnable, bool clause45, uint8_t ph
msg->Clause45Enable = clause45;
msg->Enabled = enabled;
msg->WriteEnable = writeEnable;
msg->version = 1u;
msg->Version = 1u;
if( (FiveBits < phyAddrOrPort) ||
(clause45 && (FiveBits < pageOrDevice)) ||
(!clause45 && (FiveBits < regAddr)) )
@@ -18,17 +18,17 @@ bool EthPhyMessage::appendPhyMessage(bool writeEnable, bool clause45, uint8_t ph
if(clause45)
{
msg->clause45.port = phyAddrOrPort;
msg->clause45.device = pageOrDevice;
msg->clause45.regAddr = regAddr;
msg->clause45.regVal = regVal;
msg->Clause45.port = phyAddrOrPort;
msg->Clause45.device = pageOrDevice;
msg->Clause45.regAddr = regAddr;
msg->Clause45.regVal = regVal;
}
else
{
msg->clause22.phyAddr = phyAddrOrPort;
msg->clause22.page = pageOrDevice;
msg->clause22.regAddr = regAddr;
msg->clause22.regVal = regVal;
msg->Clause22.phyAddr = phyAddrOrPort;
msg->Clause22.page = pageOrDevice;
msg->Clause22.regAddr = regAddr;
msg->Clause22.regVal = regVal;
}
return appendPhyMessage(msg);
}
+18 -16
View File
@@ -34,11 +34,12 @@ std::shared_ptr<EthPhyMessage> HardwareEthernetPhyRegisterPacket::DecodeToMessag
phyMessage->Enabled = (pEntry->Enabled != 0u);
phyMessage->WriteEnable = (pEntry->WriteEnable != 0u);
phyMessage->Clause45Enable = (pEntry->Clause45Enable != 0u);
phyMessage->version = static_cast<uint8_t>(pEntry->version);
phyMessage->BusIndex = static_cast<uint8_t>(pEntry->BusIndex);
phyMessage->Version = static_cast<uint8_t>(pEntry->version);
if(phyMessage->Clause45Enable)
phyMessage->clause45 = pEntry->clause45;
phyMessage->Clause45 = pEntry->clause45;
else
phyMessage->clause22 = pEntry->clause22;
phyMessage->Clause22 = pEntry->clause22;
msg->messages.push_back(phyMessage);
}
}
@@ -69,34 +70,35 @@ bool HardwareEthernetPhyRegisterPacket::EncodeFromMessage(const EthPhyMessage& m
PhyRegisterPacket_t tempPacket;
tempPacket.Enabled = phyMessage->Enabled ? 0x1u : 0x0u;
tempPacket.WriteEnable = phyMessage->WriteEnable ? 0x1u : 0x0u;
tempPacket.version = (phyMessage->version & 0xF);
tempPacket.BusIndex = (phyMessage->BusIndex & 0xF);
tempPacket.version = (phyMessage->Version & 0xF);
if(phyMessage->Clause45Enable)
{
if( (FiveBits < phyMessage->clause45.port) ||
(FiveBits < phyMessage->clause45.device) )
if( (FiveBits < phyMessage->Clause45.port) ||
(FiveBits < phyMessage->Clause45.device) )
{
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return false;
}
tempPacket.Clause45Enable = 0x1u;
tempPacket.clause45.port = phyMessage->clause45.port;
tempPacket.clause45.device = phyMessage->clause45.device;
tempPacket.clause45.regAddr = phyMessage->clause45.regAddr;
tempPacket.clause45.regVal = phyMessage->clause45.regVal;
tempPacket.clause45.port = phyMessage->Clause45.port;
tempPacket.clause45.device = phyMessage->Clause45.device;
tempPacket.clause45.regAddr = phyMessage->Clause45.regAddr;
tempPacket.clause45.regVal = phyMessage->Clause45.regVal;
}
else
{
if( (FiveBits < phyMessage->clause22.phyAddr) ||
(FiveBits < phyMessage->clause22.regAddr) )
if( (FiveBits < phyMessage->Clause22.phyAddr) ||
(FiveBits < phyMessage->Clause22.regAddr) )
{
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return false;
}
tempPacket.Clause45Enable = 0x0u;
tempPacket.clause22.phyAddr = phyMessage->clause22.phyAddr;
tempPacket.clause22.page = phyMessage->clause22.page;
tempPacket.clause22.regAddr = phyMessage->clause22.regAddr;
tempPacket.clause22.regVal = phyMessage->clause22.regVal;
tempPacket.clause22.phyAddr = phyMessage->Clause22.phyAddr;
tempPacket.clause22.page = phyMessage->Clause22.page;
tempPacket.clause22.regAddr = phyMessage->Clause22.regAddr;
tempPacket.clause22.regVal = phyMessage->Clause22.regVal;
}
uint8_t* pktPtr = reinterpret_cast<uint8_t*>(&tempPacket);
bytestream.insert(bytestream.end(), pktPtr, pktPtr + sizeof(PhyRegisterPacket_t));