Device: Add device binary export support

This commit is contained in:
Yasser Yassine
2023-05-30 21:22:53 +00:00
parent f907d6759f
commit d9c12bffe7
11 changed files with 242 additions and 3 deletions
+7 -1
View File
@@ -31,7 +31,8 @@ enum class Command : uint8_t {
GetVBattReq = 0xDF, // Previously known as RED_CMD_VBATT_REQUEST
ScriptStatus = 0xE0, // Previously known as RED_CMD_SCRIPT_STATUS
MiscControl = 0xE7,
Extended = 0xF0,
Extended = 0xF0, // Previously known as RED_CMD_EXT_COMM
ExtendedData = 0xF2, // Previously known as RED_CMD_EXTENDED_DATA
FlexRayControl = 0xF3,
CoreMiniPreload = 0xF4, // Previously known as RED_CMD_COREMINI_PRELOAD
PHYControlRegisters = 0xEF
@@ -51,6 +52,7 @@ enum class ExtendedCommand : uint16_t {
GetComponentVersions = 0x001A,
Reboot = 0x001C,
SetUploadedFlag = 0x0027,
GenericBinaryInfo = 0x0030,
};
enum class ExtendedResponse : int32_t {
@@ -62,6 +64,10 @@ enum class ExtendedResponse : int32_t {
InvalidParameter = -5,
};
enum class ExtendedDataSubCommand : uint32_t {
GenericBinaryRead = 13,
};
}
#endif // __cplusplus
@@ -0,0 +1,34 @@
#ifndef __EXTENDEDDATAMESSAGE_H_
#define __EXTENDEDDATAMESSAGE_H_
#ifdef __cplusplus
#include "icsneo/communication/message/message.h"
#include "icsneo/communication/command.h"
namespace icsneo {
class ExtendedDataMessage : public RawMessage {
public:
#pragma pack(push, 2)
struct ExtendedDataHeader {
ExtendedDataSubCommand subCommand;
uint32_t userValue;
uint32_t offset;
uint32_t length;
};
#pragma pack(pop)
static constexpr size_t MaxExtendedDataBufferSize = 2048;
const ExtendedDataHeader header;
ExtendedDataMessage(ExtendedDataHeader params) : RawMessage(Message::Type::RawMessage, Network::NetID::ExtendedData), header{params} {}
};
}
#endif // __cplusplus
#endif
@@ -0,0 +1,22 @@
#ifndef _EXTENDED_GENERIC_BINARY_STATUS_MESSAGE_H_
#define _EXTENDED_GENERIC_BINARY_STATUS_MESSAGE_H_
#ifdef __cplusplus
#include "icsneo/communication/message/extendedresponsemessage.h"
namespace icsneo {
class GenericBinaryStatusMessage : public Message {
public:
GenericBinaryStatusMessage() : Message(Message::Type::GenericBinaryStatus) {}
size_t binarySize;
uint16_t binaryIndex;
uint16_t binaryStatus;
};
}
#endif // __cplusplus
#endif // _EXTENDED_GENERIC_BINARY_STATUS_RESPONSE_MESSAGE_H_
@@ -36,6 +36,7 @@ public:
ScriptStatus = 0x800b,
ComponentVersions = 0x800c,
SupportedFeatures = 0x800d,
GenericBinaryStatus = 0x800e,
};
Message(Type t) : type(t) {}
+2
View File
@@ -123,6 +123,7 @@ public:
ScriptStatus = 224,
EthPHYControl = 239,
ExtendedCommand = 240,
ExtendedData = 242,
FlexRayControl = 243,
CoreMiniPreLoad = 244,
HW_COM_Latency_Test = 512,
@@ -349,6 +350,7 @@ public:
case NetID::EthPHYControl:
case NetID::CoreMiniPreLoad:
case NetID::ExtendedCommand:
case NetID::ExtendedData:
case NetID::NeoMemorySDRead:
case NetID::NeoMemoryWriteDone:
case NetID::RED_GET_RTC:
@@ -0,0 +1,23 @@
#ifndef __GENERICBINARYSTATUSPACKET_H__
#define __GENERICBINARYSTATUSPACKET_H__
#ifdef __cplusplus
#include <cstdint>
#include <memory>
#include <vector>
namespace icsneo {
class GenericBinaryStatusMessage;
struct GenericBinaryStatusPacket {
static std::shared_ptr<GenericBinaryStatusMessage> DecodeToMessage(const std::vector<uint8_t>& bytes);
static std::vector<uint8_t> EncodeArguments(uint16_t binaryIndex);
};
}
#endif // __cplusplus
#endif // __GENERICBINARYSTATUSPACKET_H__
+8
View File
@@ -33,6 +33,9 @@
#include "icsneo/communication/message/wiviresponsemessage.h"
#include "icsneo/communication/message/scriptstatusmessage.h"
#include "icsneo/communication/message/supportedfeaturesmessage.h"
#include "icsneo/communication/message/genericbinarystatusmessage.h"
#include "icsneo/communication/message/extendeddatamessage.h"
#include "icsneo/communication/packet/genericbinarystatuspacket.h"
#include "icsneo/device/extensions/flexray/controller.h"
#include "icsneo/communication/message/flexray/control/flexraycontrolmessage.h"
#include "icsneo/communication/message/ethphymessage.h"
@@ -565,6 +568,9 @@ public:
std::shared_ptr<Communication> com;
std::unique_ptr<IDeviceSettings> settings;
std::optional<size_t> getGenericBinarySize(uint16_t binaryIndex);
bool readBinaryFile(std::ostream& stream, uint16_t binaryIndex);
protected:
bool online = false;
int messagePollingCallbackID = 0;
@@ -670,6 +676,8 @@ protected:
neodevice_t& getWritableNeoDevice() { return data; }
private:
neodevice_t data;
std::shared_ptr<ResetStatusMessage> latestResetStatus;