Allow settings to be marked as readonly
In the case of the FIRE 2 ethernet, we're waiting on a bug fix in firmware before we re-enable writing. In the meantime, setting settings over ethernet crashes the ethernet driver.pull/4/head
parent
5d4cfe4930
commit
ba82c51914
|
|
@ -85,6 +85,9 @@ bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
|||
}
|
||||
|
||||
bool IDeviceSettings::apply(bool temporary) {
|
||||
if(readonly)
|
||||
return false;
|
||||
|
||||
std::vector<uint8_t> 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<Message> msg = com->waitForMessageSync(std::make_shared<Main51MessageFilter>(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<typename T> 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
|
||||
|
||||
|
|
|
|||
|
|
@ -302,6 +302,8 @@ public:
|
|||
template<typename T> bool setStructure(const T& newStructure);
|
||||
|
||||
uint8_t getEnumValueForBaudrate(uint32_t baudrate);
|
||||
|
||||
bool readonly = false;
|
||||
protected:
|
||||
std::shared_ptr<Communication> com;
|
||||
size_t structSize;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public:
|
|||
auto decoder = std::unique_ptr<Decoder>(new Decoder());
|
||||
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
|
||||
settings = std::unique_ptr<IDeviceSettings>(new NeoVIFIRE2Settings(com));
|
||||
settings->readonly = true;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue