mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Fix a bug where settings were not read properly
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "icsneo/communication/communication.h"
|
||||
#include "icsneo/communication/message/serialnumbermessage.h"
|
||||
#include "icsneo/communication/message/resetstatusmessage.h"
|
||||
#include "icsneo/communication/message/readsettingsmessage.h"
|
||||
#include "icsneo/communication/command.h"
|
||||
#include "icsneo/device/device.h"
|
||||
#include <iostream>
|
||||
@@ -171,6 +172,26 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||
packet->data.resize(length);
|
||||
return decode(result, packet);
|
||||
}
|
||||
case Network::NetID::ReadSettings: {
|
||||
auto msg = std::make_shared<ReadSettingsMessage>();
|
||||
msg->network = packet->network;
|
||||
msg->response = ReadSettingsMessage::Response(packet->data[0]);
|
||||
|
||||
if(msg->response == ReadSettingsMessage::Response::OK) {
|
||||
// The global settings structure is the payload of the message in this case
|
||||
msg->data.insert(msg->data.begin(), packet->data.begin() + 10, packet->data.end());
|
||||
uint16_t resp_len = msg->data[8] | (msg->data[9] << 8);
|
||||
if(msg->data.size() - 1 == resp_len) // There is a padding byte at the end
|
||||
msg->data.pop_back();
|
||||
result = msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
// We did not get a successful response, so the payload is all of the data
|
||||
msg->data.insert(msg->data.begin(), packet->data.begin(), packet->data.end());
|
||||
result = msg;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user