From 6cc0f08e2b0b18d519a46f0373cf04eca7f2f9ce Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Thu, 24 Feb 2022 15:29:12 -0500 Subject: [PATCH] Settings: The device can report when defaults were applied --- api/icsneocpp/event.cpp | 3 +++ communication/communication.cpp | 6 ++++-- include/icsneo/api/event.h | 1 + include/icsneo/communication/message/readsettingsmessage.h | 3 ++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api/icsneocpp/event.cpp b/api/icsneocpp/event.cpp index c63abc7..64f7ec9 100644 --- a/api/icsneocpp/event.cpp +++ b/api/icsneocpp/event.cpp @@ -103,6 +103,7 @@ static constexpr const char* TERMINATION_NOT_SUPPORTED_DEVICE = "This device doe static constexpr const char* TERMINATION_NOT_SUPPORTED_NETWORK = "This network does not support software selectable termination on this device."; static constexpr const char* ANOTHER_IN_TERMINATION_GROUP_ENABLED = "A mutually exclusive network already has termination enabled."; static constexpr const char* ETH_PHY_REGISTER_CONTROL_NOT_AVAILABLE = "Ethernet PHY register control is not available for this device."; +static constexpr const char* SETTINGS_DEFAULTS_USED = "The device settings could not be loaded, the default settings have been applied."; // Transport Errors static constexpr const char* FAILED_TO_READ = "A read operation failed."; @@ -214,6 +215,8 @@ const char* APIEvent::DescriptionForType(Type type) { return NO_SERIAL_NUMBER_FW_12V; case Type::EthPhyRegisterControlNotAvailable: return ETH_PHY_REGISTER_CONTROL_NOT_AVAILABLE; + case Type::SettingsDefaultsUsed: + return SETTINGS_DEFAULTS_USED; // Transport Errors case Type::FailedToRead: diff --git a/communication/communication.cpp b/communication/communication.cpp index f5f53e2..d2fd93a 100644 --- a/communication/communication.cpp +++ b/communication/communication.cpp @@ -125,8 +125,10 @@ bool Communication::getSettingsSync(std::vector& data, std::chrono::mil return false; } - if(gsmsg->response != ReadSettingsMessage::Response::OK) { - report(APIEvent::Type::Unknown, APIEvent::Severity::Error); + if(gsmsg->response == ReadSettingsMessage::Response::OKDefaultsUsed) { + report(APIEvent::Type::SettingsDefaultsUsed, APIEvent::Severity::EventInfo); + } else if(gsmsg->response != ReadSettingsMessage::Response::OK) { + report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error); return false; } diff --git a/include/icsneo/api/event.h b/include/icsneo/api/event.h index 652ce39..2407807 100644 --- a/include/icsneo/api/event.h +++ b/include/icsneo/api/event.h @@ -80,6 +80,7 @@ public: NoSerialNumber12V = 0x2028, // The device must be powered with 12V for communication to be established NoSerialNumberFW12V = 0x2029, // The device must be powered with 12V for communication to be established, a firmware update was already attempted EthPhyRegisterControlNotAvailable = 0x2030, //The device doesn't support Ethernet PHY MDIO access + SettingsDefaultsUsed = 0x2033, // Transport Events FailedToRead = 0x3000, diff --git a/include/icsneo/communication/message/readsettingsmessage.h b/include/icsneo/communication/message/readsettingsmessage.h index 3be1054..7c05ecf 100644 --- a/include/icsneo/communication/message/readsettingsmessage.h +++ b/include/icsneo/communication/message/readsettingsmessage.h @@ -19,7 +19,8 @@ public: InvalidSubversion = 3, NotEnoughMemory = 4, APIFailure = 5, - APIUnsupported = 6 + APIUnsupported = 6, + OKDefaultsUsed = 7, // Got the settings okay, but the defaults were used (after firmware upgrade or a checksum error) }; Response response;