Device: Add GetComponentVersions and GetSupportedFeatures commands

Driver: Fix re-open and failed open cases for TCP

Also enforces even length packets for the RED2, FIRE3, and FIRE3 FlexRay devices.
This commit is contained in:
Jonathan Schwartz
2023-05-08 21:07:43 +00:00
parent b6d9ef4c7e
commit 32900ae263
22 changed files with 303 additions and 23 deletions
+2
View File
@@ -47,6 +47,8 @@ enum class ExtendedCommand : uint16_t {
Extract = 0x0015,
StartDHCPServer = 0x0016,
StopDHCPServer = 0x0017,
GetSupportedFeatures = 0x0018,
GetComponentVersions = 0x001A,
Reboot = 0x001C,
SetUploadedFlag = 0x0027,
};
@@ -10,6 +10,8 @@
#include "icsneo/communication/message/callback/messagecallback.h"
#include "icsneo/communication/message/serialnumbermessage.h"
#include "icsneo/communication/message/logicaldiskinfomessage.h"
#include "icsneo/communication/message/componentversionsmessage.h"
#include "icsneo/communication/message/extendedresponsemessage.h"
#include "icsneo/device/deviceversion.h"
#include "icsneo/api/eventmanager.h"
#include "icsneo/communication/packetizer.h"
@@ -58,6 +60,7 @@ public:
std::shared_ptr<SerialNumberMessage> getSerialNumberSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
std::optional< std::vector< std::optional<DeviceAppVersion> > > getVersionsSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
std::shared_ptr<LogicalDiskInfoMessage> getLogicalDiskInfoSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
std::optional< std::vector<ComponentVersion> > getComponentVersionsSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
int addMessageCallback(const std::shared_ptr<MessageCallback>& cb);
bool removeMessageCallback(int id);
@@ -0,0 +1,29 @@
#ifndef _EXTENDED_COMPONENT_VERSIONS_RESPONSE_MESSAGE_H_
#define _EXTENDED_COMPONENT_VERSIONS_RESPONSE_MESSAGE_H_
#ifdef __cplusplus
#include "icsneo/communication/message/extendedresponsemessage.h"
namespace icsneo {
class ComponentVersion {
public:
ComponentVersion(uint8_t valid, uint8_t componentInfo, uint32_t identifier, uint32_t dotVersion, uint32_t commitHash) :
valid(valid), componentInfo(componentInfo), identifier(identifier), dotVersion(dotVersion), commitHash(commitHash) {}
const bool valid;
const uint8_t componentInfo;
const uint32_t identifier;
const uint32_t dotVersion;
const uint32_t commitHash;
};
class ComponentVersionsMessage : public Message {
public:
ComponentVersionsMessage() : Message(Message::Type::ComponentVersions) {}
std::vector<ComponentVersion> versions;
};
}
#endif // __cplusplus
#endif // _EXTENDED_COMPONENT_VERSIONS_RESPONSE_MESSAGE_H_
@@ -34,6 +34,8 @@ public:
ExtendedResponse = 0x8009,
WiVICommandResponse = 0x800a,
ScriptStatus = 0x800b,
ComponentVersions = 0x800c,
SupportedFeatures = 0x800d,
};
Message(Type t) : type(t) {}
@@ -0,0 +1,44 @@
#ifndef _SUPPORTED_FEATURES_RESPONSE_MESSAGE_H_
#define _SUPPORTED_FEATURES_RESPONSE_MESSAGE_H_
#ifdef __cplusplus
#include "icsneo/communication/message/extendedresponsemessage.h"
#include <cstdint>
#include <set>
namespace icsneo {
enum class SupportedFeature : uint16_t {
networkDWCAN01 = 0,
networkDWCAN02 = 1,
networkDWCAN03 = 2,
networkDWCAN04 = 3,
networkDWCAN05 = 4,
networkDWCAN06 = 5,
networkDWCAN07 = 6,
networkDWCAN08 = 7,
networkTerminationDWCAN01 = 8,
networkTerminationDWCAN02 = 9,
networkTerminationDWCAN03 = 10,
networkTerminationDWCAN04 = 11,
networkTerminationDWCAN05 = 12,
networkTerminationDWCAN06 = 13,
networkTerminationDWCAN07 = 14,
networkTerminationDWCAN08 = 15,
enhancedFlashDriver = 16,
rtcCalibration = 17,
rtcClosedLoopCalibration = 18,
numSupportedFeatures,
};
class SupportedFeaturesMessage : public Message {
public:
SupportedFeaturesMessage() : Message(Message::Type::SupportedFeatures) {}
std::set<SupportedFeature> features;
};
}
#endif // __cplusplus
#endif // _SUPPORTED_FEATURES_RESPONSE_MESSAGE_H_
@@ -0,0 +1,22 @@
#ifndef __COMPONENTVERSIONPACKET_H__
#define __COMPONENTVERSIONPACKET_H__
#ifdef __cplusplus
#include <cstdint>
#include <memory>
#include <vector>
namespace icsneo {
class ComponentVersionsMessage;
struct ComponentVersionPacket {
static std::shared_ptr<ComponentVersionsMessage> DecodeToMessage(const std::vector<uint8_t>& bytes);
};
}
#endif // __cplusplus
#endif // __DEVICECOMPONENTVERSIONPACKET_H__
@@ -0,0 +1,22 @@
#ifndef __SUPPORTEDFEATURESPACKET_H_
#define __SUPPORTEDFEATURESPACKET_H_
#ifdef __cplusplus
#include <cstdint>
#include <memory>
#include <vector>
namespace icsneo {
class SupportedFeaturesMessage;
struct SupportedFeaturesPacket {
static std::shared_ptr<SupportedFeaturesMessage> DecodeToMessage(const std::vector<uint8_t>& bytes);
};
}
#endif // __cplusplus
#endif // __SUPPORTEDFEATURESPACKET_H_