Device: Implement Ethernet PHY MDIO Communication

The following fixups were added during the squash/merge:

Fix formatting in EthPhyMessage and EthPhyRegPacket
Device: Use std::make_shared when creating the EthPHYControl filter
Network: Create NetID String for EthPHYControl
EthPhyRegPacket: Constants in PascalCase
This commit is contained in:
Kyle Johannes
2021-12-08 19:07:07 -05:00
committed by Paul Hollinsky
parent 890eb1e1bc
commit 2d1bb381f6
21 changed files with 421 additions and 1 deletions
+9
View File
@@ -24,6 +24,7 @@
#include "icsneo/communication/message/resetstatusmessage.h"
#include "icsneo/device/extensions/flexray/controller.h"
#include "icsneo/communication/message/flexray/control/flexraycontrolmessage.h"
#include "icsneo/communication/message/ethphymessage.h"
#include "icsneo/third-party/concurrentqueue/concurrentqueue.h"
#include "icsneo/platform/optional.h"
#include "icsneo/platform/nodiscard.h"
@@ -224,6 +225,14 @@ public:
const device_eventhandler_t& getEventHandler() const { return report; }
/**
* Tell whether the current device supports reading and writing
* Ethernet PHY registers through MDIO.
*/
virtual bool getEthPhyRegControlSupported() const { return false; }
optional<EthPhyMessage> sendEthPhyMsg(const EthPhyMessage& message, std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
std::shared_ptr<Communication> com;
std::unique_ptr<IDeviceSettings> settings;
@@ -16,6 +16,8 @@ public:
size_t getEthernetActivationLineCount() const override { return 1; }
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADGigastar(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
@@ -35,6 +37,7 @@ protected:
void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
encoder.supportEthPhy = true;
}
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
@@ -67,6 +67,8 @@ public:
return false;
}
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADMoon2(neodevice_t neodevice) : Device(neodevice) {
initialize<FTDI3, RADMoon2Settings>();
@@ -80,6 +82,11 @@ protected:
packetizer.align16bit = false;
}
virtual void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportEthPhy = true;
}
void setupDecoder(Decoder& decoder) override {
Device::setupDecoder(decoder);
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
@@ -33,6 +33,8 @@ public:
return supportedNetworks;
}
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADMoonDuo(neodevice_t neodevice) : Device(neodevice) {
initialize<CDCACM, RADMoonDuoSettings>();
@@ -40,6 +42,11 @@ protected:
getWritableNeoDevice().type = DEVICE_TYPE;
}
virtual void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportEthPhy = true;
}
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
for(auto& netid : GetSupportedNetworks())
rxNetworks.emplace_back(netid);
@@ -49,6 +56,7 @@ protected:
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
bool requiresVehiclePower() const override { return false; }
};
}
@@ -40,10 +40,13 @@ public:
productId = PRODUCT_ID;
}
bool getEthPhyRegControlSupported() const override { return true; }
protected:
virtual void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
encoder.supportEthPhy = true;
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
@@ -57,6 +57,8 @@ public:
return Device::getProductName();
}
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADSupermoon(neodevice_t neodevice) : Device(neodevice) {
initialize<FTDI3, RADSupermoonSettings>();
@@ -70,6 +72,11 @@ protected:
packetizer.align16bit = false;
}
virtual void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportEthPhy = true;
}
void setupDecoder(Decoder& decoder) override {
Device::setupDecoder(decoder);
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns