diff --git a/device/idevicesettings.cpp b/device/idevicesettings.cpp index 7080c4b..cb74082 100644 --- a/device/idevicesettings.cpp +++ b/device/idevicesettings.cpp @@ -85,6 +85,9 @@ bool IDeviceSettings::refresh(bool ignoreChecksum) { } bool IDeviceSettings::apply(bool temporary) { + if(readonly) + return false; + std::vector bytestream; bytestream.resize(7 + structSize); bytestream[0] = 0x00; @@ -131,6 +134,9 @@ bool IDeviceSettings::apply(bool temporary) { } bool IDeviceSettings::applyDefaults(bool temporary) { + if(readonly) + return false; + com->sendCommand(Command::SetDefaultSettings); std::shared_ptr msg = com->waitForMessageSync(std::make_shared(Command::SetDefaultSettings), std::chrono::milliseconds(1000)); if(!msg || msg->data[0] != 1) { @@ -171,6 +177,9 @@ bool IDeviceSettings::applyDefaults(bool temporary) { } bool IDeviceSettings::setBaudrateFor(Network net, uint32_t baudrate) { + if(readonly) + return false; + switch(net.getType()) { case Network::Type::CAN: { CAN_SETTINGS* cfg = getCANSettingsFor(net); @@ -191,6 +200,9 @@ bool IDeviceSettings::setBaudrateFor(Network net, uint32_t baudrate) { } template bool IDeviceSettings::setStructure(const T& newStructure) { + if(readonly) + return false; + if(sizeof(T) != structSize) return false; // The wrong structure was passed in for the current device diff --git a/device/include/idevicesettings.h b/device/include/idevicesettings.h index fb17e6a..270d4d6 100644 --- a/device/include/idevicesettings.h +++ b/device/include/idevicesettings.h @@ -302,6 +302,8 @@ public: template bool setStructure(const T& newStructure); uint8_t getEnumValueForBaudrate(uint32_t baudrate); + + bool readonly = false; protected: std::shared_ptr com; size_t structSize; diff --git a/device/neovifire2/include/neovifire2eth.h b/device/neovifire2/include/neovifire2eth.h index e755da4..7fbf918 100644 --- a/device/neovifire2/include/neovifire2eth.h +++ b/device/neovifire2/include/neovifire2eth.h @@ -18,6 +18,7 @@ public: auto decoder = std::unique_ptr(new Decoder()); com = std::make_shared(std::move(transport), packetizer, std::move(encoder), std::move(decoder)); settings = std::unique_ptr(new NeoVIFIRE2Settings(com)); + settings->readonly = true; productId = PRODUCT_ID; }