From 0497b361efbfcda64575db0f4cdedcfcadbbecd4 Mon Sep 17 00:00:00 2001 From: kjohannes-intrepidcs <90792195+kjohannes-intrepidcs@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:56:18 -0500 Subject: [PATCH] LIN: Settings API (#62) * Settings: add APIs for LIN configuration Add getter/setter for LIN configuration: - baudrate - commander resistor ON/OFF - mode (SLEEP, SLOW, NORMAL, FAST) * Device: add LIN settings getter for devices with LIN * LIN: add setup to LIN example * LIN: settings minor tweaks from PR --------- Co-authored-by: Francesco Valla --- api/icsneocpp/event.cpp | 6 + device/idevicesettings.cpp | 235 ++++++++++++++++++ examples/cpp/lin/src/LINExample.cpp | 33 ++- include/icsneo/api/event.h | 2 + include/icsneo/device/idevicesettings.h | 62 ++++- .../tree/etherbadge/etherbadgesettings.h | 11 + .../device/tree/neovifire/neovifiresettings.h | 17 ++ .../tree/neovifire2/neovifire2settings.h | 22 ++ .../tree/neovifire3/neovifire3settings.h | 26 ++ .../neovifire3flexraysettings.h | 18 ++ .../device/tree/neovired2/neovired2settings.h | 14 ++ .../device/tree/rada2b/rada2bsettings.h | 12 + .../device/tree/radgalaxy/radgalaxysettings.h | 12 + .../tree/radgigastar/radgigastarsettings.h | 12 + .../tree/radjupiter/radjupitersettings.h | 11 + .../device/tree/radmars/radmarssettings.h | 12 + .../device/tree/radpluto/radplutosettings.h | 12 + .../device/tree/radstar2/radstar2settings.h | 12 + .../settings/valuecan4-2elsettings.h | 12 + .../settings/valuecan4-4-2elsettings.h | 12 + .../valuecan4/settings/valuecan4-4settings.h | 12 + 21 files changed, 562 insertions(+), 3 deletions(-) diff --git a/api/icsneocpp/event.cpp b/api/icsneocpp/event.cpp index d9dc245..71aed02 100644 --- a/api/icsneocpp/event.cpp +++ b/api/icsneocpp/event.cpp @@ -116,6 +116,8 @@ static constexpr const char* A2B_MESSAGE_INCOMPLETE_FRAME = "At least one of the static constexpr const char* COREMINI_UPLOAD_VERSION_MISMATCH = "The version of the coremini engine on the device and the script uploaded are not the same."; static constexpr const char* DISK_NOT_CONNECTED = "The program tried to access a disk that is not connected."; static constexpr const char* UNEXPECTED_RESPONSE = "Received an unexpected or invalid response from the device."; +static constexpr const char* LIN_SETTINGS_NOT_AVAILABLE = "LIN settings are not available for this device."; +static constexpr const char* MODE_NOT_FOUND = "The mode was not found."; // Transport Errors static constexpr const char* FAILED_TO_READ = "A read operation failed."; @@ -302,6 +304,10 @@ const char* APIEvent::DescriptionForType(Type type) { return DISK_NOT_CONNECTED; case Type::UnexpectedResponse: return UNEXPECTED_RESPONSE; + case Type::LINSettingsNotAvailable: + return LIN_SETTINGS_NOT_AVAILABLE; + case Type::ModeNotFound: + return MODE_NOT_FOUND; // Transport Errors case Type::FailedToRead: return FAILED_TO_READ; diff --git a/device/idevicesettings.cpp b/device/idevicesettings.cpp index 2a6e6fd..e0bae9a 100644 --- a/device/idevicesettings.cpp +++ b/device/idevicesettings.cpp @@ -128,6 +128,37 @@ int64_t IDeviceSettings::GetBaudrateValueForEnum(CANBaudrate enumValue) { } } +bool IDeviceSettings::ValidateLINBaudrate(int64_t baudrate) { + switch(baudrate) { + case 4800: + // fallthrough + case 9600: + // fallthrough + case 10400: + // fallthrough + case 10417: + // fallthrough + case 10504: + // fallthrough + case 10593: + // fallthrough + case 10684: + // fallthrough + case 10776: + // fallthrough + case 10870: + // fallthrough + case 10965: + // fallthrough + case 11062: + // fallthrough + case 19200: + return true; + default: + return false; + } +} + bool IDeviceSettings::refresh(bool ignoreChecksum) { if(disabled) { report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error); @@ -414,6 +445,15 @@ int64_t IDeviceSettings::getBaudrateFor(Network net) const { } return baudrate; } + case Network::Type::LIN: { + const LIN_SETTINGS* cfg = getLINSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error); + return -1; + } + + return cfg->Baudrate; + } default: report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error); return -1; @@ -493,6 +533,21 @@ bool IDeviceSettings::setBaudrateFor(Network net, int64_t baudrate) { cfg->SetBaudrate = AUTO; // Device will use the baudrate value to set the TQ values return true; } + case Network::Type::LIN: { + LIN_SETTINGS* cfg = getMutableLINSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error); + return false; + } + + bool valid = ValidateLINBaudrate(baudrate); + if(!valid) { + report(APIEvent::Type::BaudrateNotFound, APIEvent::Severity::Error); + return false; + } + cfg->Baudrate = baudrate; + return true; + } default: report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error); return false; @@ -704,6 +759,186 @@ bool IDeviceSettings::setTerminationFor(Network net, bool enabled) { return true; } +std::optional IDeviceSettings::isCommanderResistorEnabledFor(Network net) const { + if(!settingsLoaded) { + report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error); + return std::nullopt; + } + + if(disabled) { + report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error); + return std::nullopt; + } + + switch(net.getType()) { + case Network::Type::LIN: { + const LIN_SETTINGS* cfg = getLINSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error); + return std::nullopt; + } + + return (cfg->CommanderResistor != RESISTOR_OFF); + } + default: + report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error); + return std::nullopt; + } +} + +bool IDeviceSettings::setCommanderResistorFor(Network net, bool resistor_on) { + if(disabled) { + report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error); + return false; + } + + if(!settingsLoaded) { + report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error); + return false; + } + + if(readonly) { + report(APIEvent::Type::SettingsReadOnly, APIEvent::Severity::Error); + return false; + } + + switch(net.getType()) { + case Network::Type::LIN: { + LIN_SETTINGS* cfg = getMutableLINSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error); + return false; + } + + cfg->CommanderResistor = resistor_on ? RESISTOR_ON : RESISTOR_OFF; + return true; + } + default: + report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error); + return false; + } +} + +std::optional IDeviceSettings::getLINModeFor(Network net) const { + if(!settingsLoaded) { + report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error); + return std::nullopt; + } + + if(disabled) { + report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error); + return std::nullopt; + } + + switch(net.getType()) { + case Network::Type::LIN: { + const LIN_SETTINGS* cfg = getLINSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error); + return std::nullopt; + } + + return static_cast(cfg->Mode); + } + default: + report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error); + return std::nullopt; + } +} + +bool IDeviceSettings::setLINModeFor(Network net, LINMode mode) { + if(disabled) { + report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error); + return false; + } + + if(!settingsLoaded) { + report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error); + return false; + } + + if(readonly) { + report(APIEvent::Type::SettingsReadOnly, APIEvent::Severity::Error); + return false; + } + + switch(net.getType()) { + case Network::Type::LIN: { + LIN_SETTINGS* cfg = getMutableLINSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error); + return false; + } + + cfg->Mode = static_cast(mode); + return true; + } + default: + report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error); + return false; + } +} + +std::optional IDeviceSettings::getLINCommanderResponseTimeFor(Network net) const { + if(!settingsLoaded) { + report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error); + return std::nullopt; + } + + if(disabled) { + report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error); + return std::nullopt; + } + + switch(net.getType()) { + case Network::Type::LIN: { + const LIN_SETTINGS* cfg = getLINSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error); + return std::nullopt; + } + + return cfg->numBitsDelay; + } + default: + report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error); + return std::nullopt; + } +} + +bool IDeviceSettings::setLINCommanderResponseTimeFor(Network net, uint8_t bits) { + if(disabled) { + report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error); + return false; + } + + if(!settingsLoaded) { + report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error); + return false; + } + + if(readonly) { + report(APIEvent::Type::SettingsReadOnly, APIEvent::Severity::Error); + return false; + } + + switch(net.getType()) { + case Network::Type::LIN: { + LIN_SETTINGS* cfg = getMutableLINSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error); + return false; + } + + cfg->numBitsDelay = bits; + return true; + } + default: + report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error); + return false; + } +} + template bool IDeviceSettings::applyStructure(const T& newStructure) { if(!settingsLoaded) { report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error); diff --git a/examples/cpp/lin/src/LINExample.cpp b/examples/cpp/lin/src/LINExample.cpp index 0cf332a..5c5a61b 100644 --- a/examples/cpp/lin/src/LINExample.cpp +++ b/examples/cpp/lin/src/LINExample.cpp @@ -77,6 +77,37 @@ int main() { } std::cout << "OK" << std::endl; + std::cout << "\tGetting LIN Baudrate... "; + int64_t baud = device->settings->getBaudrateFor(icsneo::Network::NetID::LIN); + if(baud < 0) + std::cout << "FAIL" << std::endl; + else + std::cout << "OK, " << (baud) << "bit/s" << std::endl; + + std::cout << "Enable LIN commander resistor... "; + ret &= device->settings->setCommanderResistorFor(icsneo::Network::NetID::LIN, true); + std::cout << (ret ? "OK" : "FAIL") << std::endl; + + std::cout << "Setting LIN2 to operate at " << baud << "bit/s... "; + ret = device->settings->setBaudrateFor(icsneo::Network::NetID::LIN2, baud); + std::cout << (ret ? "OK" : "FAIL") << std::endl; + + std::cout << "Setting LIN mode to NORMAL... "; + ret = device->settings->setLINModeFor(icsneo::Network::NetID::LIN, NORMAL_MODE); + std::cout << (ret ? "OK" : "FAIL") << std::endl; + + std::cout << "Setting LIN2 mode to NORMAL... "; + ret = device->settings->setLINModeFor(icsneo::Network::NetID::LIN2, NORMAL_MODE); + std::cout << (ret ? "OK" : "FAIL") << std::endl; + + std::cout << "Disable LIN2 commander resistor... "; + ret &= device->settings->setCommanderResistorFor(icsneo::Network::NetID::LIN2, false); + std::cout << (ret ? "OK" : "FAIL") << std::endl; + + std::cout << "Applying settings... "; + ret = device->settings->apply(true); + std::cout << (ret ? "OK" : "FAIL") << std::endl; + auto handler = device->addMessageCallback(std::make_shared([&](std::shared_ptr message) { if(icsneo::Message::Type::Frame == message->type) { auto frame = std::static_pointer_cast(message); @@ -125,7 +156,7 @@ int main() { // Go offline, stop sending and receiving traffic auto shutdown = [&](){ - device->removeMessageCallback(handler); + device->removeMessageCallback(handler); std::cout << "\tGoing offline... "; ret = device->goOffline(); std::cout << (ret ? "OK" : "FAIL") << std::endl; diff --git a/include/icsneo/api/event.h b/include/icsneo/api/event.h index 416da9c..f06f082 100644 --- a/include/icsneo/api/event.h +++ b/include/icsneo/api/event.h @@ -104,6 +104,8 @@ public: LiveDataEncoderError = 0x2050, LiveDataDecoderError = 0x2051, LiveDataNotSupported = 0x2052, + LINSettingsNotAvailable = 0x2053, + ModeNotFound = 0x2054, // Transport Events FailedToRead = 0x3000, diff --git a/include/icsneo/device/idevicesettings.h b/include/icsneo/device/idevicesettings.h index 81e5ce5..3969068 100644 --- a/include/icsneo/device/idevicesettings.h +++ b/include/icsneo/device/idevicesettings.h @@ -544,7 +544,7 @@ enum }; /* Mode in LIN_SETTINGS */ -enum +enum LINMode { SLEEP_MODE, SLOW_MODE, @@ -558,7 +558,7 @@ typedef struct _LIN_SETTINGS uint16_t spbrg; /* Precompiled to be 40Mhz/Baudrate/16 - 1. Only used in neoVI FIRE/FIREVNET(4dw) */ uint8_t brgh; /* Must be zero */ uint8_t numBitsDelay; - uint8_t MasterResistor; + uint8_t CommanderResistor; uint8_t Mode; } LIN_SETTINGS; #define LIN_SETTINGS_SIZE 10 @@ -643,6 +643,7 @@ public: static std::optional CalculateGSChecksum(const std::vector& settings, std::optional knownSize = std::nullopt); static CANBaudrate GetEnumValueForBaudrate(int64_t baudrate); static int64_t GetBaudrateValueForEnum(CANBaudrate enumValue); + static bool ValidateLINBaudrate(int64_t baudrate); IDeviceSettings(std::shared_ptr com, size_t size) : com(com), report(com->report), structSize(size) {} virtual ~IDeviceSettings() {} @@ -700,6 +701,16 @@ public: return reinterpret_cast((void*)(settings.data() + (offset - settingsInDeviceRAM.data()))); } + virtual const LIN_SETTINGS* getLINSettingsFor(Network net) const { (void)net; return nullptr; } + LIN_SETTINGS* getMutableLINSettingsFor(Network net) { + if(disabled || readonly) + return nullptr; + const uint8_t* offset = (const uint8_t*)getLINSettingsFor(net); + if(offset == nullptr) + return nullptr; + return reinterpret_cast((void*)(settings.data() + (offset - settingsInDeviceRAM.data()))); + } + /** * Some devices have groupings of networks, where software * switchable termination can only be applied to one network @@ -753,6 +764,53 @@ public: */ bool setTerminationFor(Network net, bool enabled); + /** + * Check whether software switchable commander resistor is currently + * enabled for a given network in the currently active device settings. + * + * Returns true if the call was successful, otherwise an error + * will have been reported in icsneo::getLastError(). + */ + std::optional isCommanderResistorEnabledFor(Network net) const; + + /** + * Enable or disable software switchable commander resistor for a given + * network. + * + * Returns true if the call was successful, otherwise an error + * will have been reported in icsneo::getLastError(). + */ + bool setCommanderResistorFor(Network net, bool resistor_on); + + /** + * Get LIN mode for a given network in the currently active device + * settings. + */ + std::optional getLINModeFor(Network net) const; + + /** + * Set LIN mode for a given network. + * + * Returns true if the call was successful, otherwise an error + * will have been reported in icsneo::getLastError(). + */ + bool setLINModeFor(Network net, enum LINMode mode); + + /** + * Get number of bit delays between commander ID and first responder byte for + * a given network in the currently active device settings. + */ + std::optional getLINCommanderResponseTimeFor(Network net) const; + + /** + * Set number of bit delays between commander ID and first responder byte for + * a given network + * + * Returns true if the call was successful, otherwise an error + * will have been reported in icsneo::getLastError(). + */ + bool setLINCommanderResponseTimeFor(Network net, uint8_t bits); + const void* getRawStructurePointer() const { return settingsInDeviceRAM.data(); } void* getMutableRawStructurePointer() { return settings.data(); } template const T* getStructurePointer() const { return reinterpret_cast(getRawStructurePointer()); } diff --git a/include/icsneo/device/tree/etherbadge/etherbadgesettings.h b/include/icsneo/device/tree/etherbadge/etherbadgesettings.h index c270ec2..1a85ab0 100644 --- a/include/icsneo/device/tree/etherbadge/etherbadgesettings.h +++ b/include/icsneo/device/tree/etherbadge/etherbadgesettings.h @@ -88,6 +88,17 @@ public: return nullptr; } } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } }; } diff --git a/include/icsneo/device/tree/neovifire/neovifiresettings.h b/include/icsneo/device/tree/neovifire/neovifiresettings.h index 71658fe..a7892f5 100644 --- a/include/icsneo/device/tree/neovifire/neovifiresettings.h +++ b/include/icsneo/device/tree/neovifire/neovifiresettings.h @@ -131,6 +131,23 @@ public: return nullptr; } } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + case Network::NetID::LIN2: + return &(cfg->lin2); + case Network::NetID::LIN3: + return &(cfg->lin3); + case Network::NetID::LIN4: + return &(cfg->lin4); + default: + return nullptr; + } + } }; } diff --git a/include/icsneo/device/tree/neovifire2/neovifire2settings.h b/include/icsneo/device/tree/neovifire2/neovifire2settings.h index cffa9a0..c1c0222 100644 --- a/include/icsneo/device/tree/neovifire2/neovifire2settings.h +++ b/include/icsneo/device/tree/neovifire2/neovifire2settings.h @@ -209,6 +209,28 @@ public: }; } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + case Network::NetID::LIN2: + return &(cfg->lin2); + case Network::NetID::LIN3: + return &(cfg->lin3); + case Network::NetID::LIN4: + return &(cfg->lin4); + case Network::NetID::LIN5: + return &(cfg->lin5); + case Network::NetID::LIN6: + return &(cfg->lin6); + default: + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { auto cfg = getStructurePointer(); diff --git a/include/icsneo/device/tree/neovifire3/neovifire3settings.h b/include/icsneo/device/tree/neovifire3/neovifire3settings.h index 576419f..5dcbbb4 100644 --- a/include/icsneo/device/tree/neovifire3/neovifire3settings.h +++ b/include/icsneo/device/tree/neovifire3/neovifire3settings.h @@ -229,6 +229,32 @@ public: }; } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + case Network::NetID::LIN2: + return &(cfg->lin2); + case Network::NetID::LIN3: + return &(cfg->lin3); + case Network::NetID::LIN4: + return &(cfg->lin4); + case Network::NetID::LIN5: + return &(cfg->lin5); + case Network::NetID::LIN6: + return &(cfg->lin6); + case Network::NetID::LIN7: + return &(cfg->lin7); + case Network::NetID::LIN8: + return &(cfg->lin8); + default: + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { auto cfg = getStructurePointer(); diff --git a/include/icsneo/device/tree/neovifire3flexray/neovifire3flexraysettings.h b/include/icsneo/device/tree/neovifire3flexray/neovifire3flexraysettings.h index 8be3878..26c7934 100644 --- a/include/icsneo/device/tree/neovifire3flexray/neovifire3flexraysettings.h +++ b/include/icsneo/device/tree/neovifire3flexray/neovifire3flexraysettings.h @@ -212,6 +212,24 @@ public: }; } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + case Network::NetID::LIN2: + return &(cfg->lin2); + case Network::NetID::LIN3: + return &(cfg->lin3); + case Network::NetID::LIN4: + return &(cfg->lin4); + default: + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { auto cfg = getStructurePointer(); diff --git a/include/icsneo/device/tree/neovired2/neovired2settings.h b/include/icsneo/device/tree/neovired2/neovired2settings.h index 0bb0213..aa5180d 100644 --- a/include/icsneo/device/tree/neovired2/neovired2settings.h +++ b/include/icsneo/device/tree/neovired2/neovired2settings.h @@ -170,6 +170,20 @@ public: }; } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + case Network::NetID::LIN2: + return &(cfg->lin2); + default: + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { auto cfg = getStructurePointer(); diff --git a/include/icsneo/device/tree/rada2b/rada2bsettings.h b/include/icsneo/device/tree/rada2b/rada2bsettings.h index 10db525..22b747c 100644 --- a/include/icsneo/device/tree/rada2b/rada2bsettings.h +++ b/include/icsneo/device/tree/rada2b/rada2bsettings.h @@ -121,6 +121,18 @@ public: } } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } + TDMMode getTDMMode(RADA2BDevice device) const { auto cfg = getStructurePointer(); auto &deviceSettings = device == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node; diff --git a/include/icsneo/device/tree/radgalaxy/radgalaxysettings.h b/include/icsneo/device/tree/radgalaxy/radgalaxysettings.h index f91a15c..317f388 100644 --- a/include/icsneo/device/tree/radgalaxy/radgalaxysettings.h +++ b/include/icsneo/device/tree/radgalaxy/radgalaxysettings.h @@ -170,6 +170,18 @@ public: return nullptr; } } + + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } }; } diff --git a/include/icsneo/device/tree/radgigastar/radgigastarsettings.h b/include/icsneo/device/tree/radgigastar/radgigastarsettings.h index 4389098..72edec2 100644 --- a/include/icsneo/device/tree/radgigastar/radgigastarsettings.h +++ b/include/icsneo/device/tree/radgigastar/radgigastarsettings.h @@ -149,6 +149,18 @@ public: }; } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { auto cfg = getStructurePointer(); diff --git a/include/icsneo/device/tree/radjupiter/radjupitersettings.h b/include/icsneo/device/tree/radjupiter/radjupitersettings.h index c531304..6bea9c0 100644 --- a/include/icsneo/device/tree/radjupiter/radjupitersettings.h +++ b/include/icsneo/device/tree/radjupiter/radjupitersettings.h @@ -118,6 +118,17 @@ public: return nullptr; } } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } }; } diff --git a/include/icsneo/device/tree/radmars/radmarssettings.h b/include/icsneo/device/tree/radmars/radmarssettings.h index c4f8d90..1d4a836 100644 --- a/include/icsneo/device/tree/radmars/radmarssettings.h +++ b/include/icsneo/device/tree/radmars/radmarssettings.h @@ -170,6 +170,18 @@ public: }; } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { auto cfg = getStructurePointer(); diff --git a/include/icsneo/device/tree/radpluto/radplutosettings.h b/include/icsneo/device/tree/radpluto/radplutosettings.h index 0cf2e7b..1a81ab2 100644 --- a/include/icsneo/device/tree/radpluto/radplutosettings.h +++ b/include/icsneo/device/tree/radpluto/radplutosettings.h @@ -104,6 +104,18 @@ public: return nullptr; } } + + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } }; } diff --git a/include/icsneo/device/tree/radstar2/radstar2settings.h b/include/icsneo/device/tree/radstar2/radstar2settings.h index bc3379a..5c77be4 100644 --- a/include/icsneo/device/tree/radstar2/radstar2settings.h +++ b/include/icsneo/device/tree/radstar2/radstar2settings.h @@ -99,6 +99,18 @@ public: return nullptr; } } + + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } }; } diff --git a/include/icsneo/device/tree/valuecan4/settings/valuecan4-2elsettings.h b/include/icsneo/device/tree/valuecan4/settings/valuecan4-2elsettings.h index e31ffde..a06b08c 100644 --- a/include/icsneo/device/tree/valuecan4/settings/valuecan4-2elsettings.h +++ b/include/icsneo/device/tree/valuecan4/settings/valuecan4-2elsettings.h @@ -45,6 +45,18 @@ public: }; } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { auto cfg = getStructurePointer(); diff --git a/include/icsneo/device/tree/valuecan4/settings/valuecan4-4-2elsettings.h b/include/icsneo/device/tree/valuecan4/settings/valuecan4-4-2elsettings.h index deeb0a1..2a8ed79 100644 --- a/include/icsneo/device/tree/valuecan4/settings/valuecan4-4-2elsettings.h +++ b/include/icsneo/device/tree/valuecan4/settings/valuecan4-4-2elsettings.h @@ -37,6 +37,18 @@ public: return nullptr; } } + + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } }; } diff --git a/include/icsneo/device/tree/valuecan4/settings/valuecan4-4settings.h b/include/icsneo/device/tree/valuecan4/settings/valuecan4-4settings.h index f7e667f..dabf533 100644 --- a/include/icsneo/device/tree/valuecan4/settings/valuecan4-4settings.h +++ b/include/icsneo/device/tree/valuecan4/settings/valuecan4-4settings.h @@ -59,6 +59,18 @@ public: }; } + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } + protected: ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { auto cfg = getStructurePointer();