Extended Commands: Decode generic responses
parent
103f938d69
commit
2e3b738e76
|
|
@ -5,6 +5,7 @@
|
||||||
#include "icsneo/communication/message/readsettingsmessage.h"
|
#include "icsneo/communication/message/readsettingsmessage.h"
|
||||||
#include "icsneo/communication/message/canerrorcountmessage.h"
|
#include "icsneo/communication/message/canerrorcountmessage.h"
|
||||||
#include "icsneo/communication/message/neoreadmemorysdmessage.h"
|
#include "icsneo/communication/message/neoreadmemorysdmessage.h"
|
||||||
|
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||||
#include "icsneo/communication/message/flexray/control/flexraycontrolmessage.h"
|
#include "icsneo/communication/message/flexray/control/flexraycontrolmessage.h"
|
||||||
#include "icsneo/communication/command.h"
|
#include "icsneo/communication/command.h"
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
|
|
@ -193,6 +194,18 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
msg->data.insert(msg->data.end(), packet->data.begin() + 4, packet->data.end());
|
msg->data.insert(msg->data.end(), packet->data.begin() + 4, packet->data.end());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case Network::NetID::ExtendedCommand: {
|
||||||
|
if(packet->data.size() < sizeof(ExtendedResponseMessage::PackedGenericResponse))
|
||||||
|
break; // Handle as a raw message, might not be a generic response
|
||||||
|
|
||||||
|
const auto& resp = *reinterpret_cast<ExtendedResponseMessage::PackedGenericResponse*>(packet->data.data());
|
||||||
|
if(resp.header.command != ExtendedCommand::GenericReturn)
|
||||||
|
break; // Handle as a raw message
|
||||||
|
|
||||||
|
const auto msg = std::make_shared<ExtendedResponseMessage>(resp.command, resp.returnCode);
|
||||||
|
result = msg;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case Network::NetID::FlexRayControl: {
|
case Network::NetID::FlexRayControl: {
|
||||||
auto frResult = std::make_shared<FlexRayControlMessage>(*packet);
|
auto frResult = std::make_shared<FlexRayControlMessage>(*packet);
|
||||||
if(!frResult->decoded) {
|
if(!frResult->decoded) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ enum class Command : uint8_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ExtendedCommand : uint16_t {
|
enum class ExtendedCommand : uint16_t {
|
||||||
|
GenericReturn = 0x0000,
|
||||||
GetDiskDetails = 0x0010,
|
GetDiskDetails = 0x0010,
|
||||||
DiskFormatStart = 0x0011,
|
DiskFormatStart = 0x0011,
|
||||||
DiskFormatCancel = 0x0012,
|
DiskFormatCancel = 0x0012,
|
||||||
|
|
@ -39,6 +40,16 @@ enum class ExtendedCommand : uint16_t {
|
||||||
Extract = 0x0015,
|
Extract = 0x0015,
|
||||||
StartDHCPServer = 0x0016,
|
StartDHCPServer = 0x0016,
|
||||||
StopDHCPServer = 0x0017,
|
StopDHCPServer = 0x0017,
|
||||||
|
Reboot = 0x001C,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ExtendedResponse : int32_t {
|
||||||
|
OK = 0,
|
||||||
|
InvalidCommand = -1,
|
||||||
|
InvalidState = -2,
|
||||||
|
OperationFailed = -3,
|
||||||
|
OperationPending = -4,
|
||||||
|
InvalidParameter = -5,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef __EXTENDEDRESPONSEMESSAGE_H_
|
||||||
|
#define __EXTENDEDRESPONSEMESSAGE_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/message.h"
|
||||||
|
#include "icsneo/communication/command.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
class ExtendedResponseMessage : public Message {
|
||||||
|
public:
|
||||||
|
ExtendedResponseMessage(ExtendedCommand cmd, ExtendedResponse resp)
|
||||||
|
: Message(Message::Type::ExtendedResponse), command(cmd), response(resp) {}
|
||||||
|
|
||||||
|
const ExtendedCommand command;
|
||||||
|
const ExtendedResponse response;
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct ResponseHeader {
|
||||||
|
ExtendedCommand command;
|
||||||
|
uint16_t length;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PackedGenericResponse {
|
||||||
|
ResponseHeader header;
|
||||||
|
ExtendedCommand command; // `header.command` is ExtendedCommand::GenericReturn, this is the real command
|
||||||
|
ExtendedResponse returnCode;
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -28,6 +28,7 @@ public:
|
||||||
FlexRayControl = 0x8006,
|
FlexRayControl = 0x8006,
|
||||||
EthernetPhyRegister = 0x8007,
|
EthernetPhyRegister = 0x8007,
|
||||||
LogicalDiskInfo = 0x8008,
|
LogicalDiskInfo = 0x8008,
|
||||||
|
ExtendedResponse = 0x8009,
|
||||||
};
|
};
|
||||||
|
|
||||||
Message(Type t) : type(t) {}
|
Message(Type t) : type(t) {}
|
||||||
|
|
@ -71,6 +72,9 @@ public:
|
||||||
#define ICSNEO_MESSAGE_TYPE_DEVICE_VERSION (0x8004)
|
#define ICSNEO_MESSAGE_TYPE_DEVICE_VERSION (0x8004)
|
||||||
#define ICSNEO_MESSAGE_TYPE_MAIN51 (0x8005)
|
#define ICSNEO_MESSAGE_TYPE_MAIN51 (0x8005)
|
||||||
#define ICSNEO_MESSAGE_TYPE_FLEXRAY_CONTROL (0x8006)
|
#define ICSNEO_MESSAGE_TYPE_FLEXRAY_CONTROL (0x8006)
|
||||||
|
#define ICSNEO_MESSAGE_TYPE_ETHERNET_PHY_REGISTER (0x8007)
|
||||||
|
#define ICSNEO_MESSAGE_TYPE_LOGICAL_DISK_INFO (0x8008)
|
||||||
|
#define ICSNEO_MESSAGE_TYPE_EXTENDED_RESPONSE (0x8009)
|
||||||
|
|
||||||
#endif // __ICSNEOC_H_
|
#endif // __ICSNEOC_H_
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ public:
|
||||||
LSFTCAN2 = 99,
|
LSFTCAN2 = 99,
|
||||||
LogicalDiskInfo = 187,
|
LogicalDiskInfo = 187,
|
||||||
EthPHYControl = 239,
|
EthPHYControl = 239,
|
||||||
|
ExtendedCommand = 240,
|
||||||
FlexRayControl = 243,
|
FlexRayControl = 243,
|
||||||
HW_COM_Latency_Test = 512,
|
HW_COM_Latency_Test = 512,
|
||||||
DeviceStatus = 513,
|
DeviceStatus = 513,
|
||||||
|
|
@ -274,6 +275,7 @@ public:
|
||||||
case NetID::ReadSettings:
|
case NetID::ReadSettings:
|
||||||
case NetID::LogicalDiskInfo:
|
case NetID::LogicalDiskInfo:
|
||||||
case NetID::EthPHYControl:
|
case NetID::EthPHYControl:
|
||||||
|
case NetID::ExtendedCommand:
|
||||||
case NetID::NeoMemorySDRead:
|
case NetID::NeoMemorySDRead:
|
||||||
case NetID::NeoMemoryWriteDone:
|
case NetID::NeoMemoryWriteDone:
|
||||||
return Type::Internal;
|
return Type::Internal;
|
||||||
|
|
@ -514,6 +516,8 @@ public:
|
||||||
return "Logical Disk Information";
|
return "Logical Disk Information";
|
||||||
case NetID::EthPHYControl:
|
case NetID::EthPHYControl:
|
||||||
return "Ethernet PHY Register Control";
|
return "Ethernet PHY Register Control";
|
||||||
|
case NetID::ExtendedCommand:
|
||||||
|
return "Extended Command";
|
||||||
case NetID::FlexRayControl:
|
case NetID::FlexRayControl:
|
||||||
return "FlexRay Control";
|
return "FlexRay Control";
|
||||||
case NetID::HW_COM_Latency_Test:
|
case NetID::HW_COM_Latency_Test:
|
||||||
|
|
@ -914,6 +918,7 @@ private:
|
||||||
#define ICSNEO_NETID_LSFTCAN2 99
|
#define ICSNEO_NETID_LSFTCAN2 99
|
||||||
#define ICSNEO_NETID_LOGICAL_DISK_INFO 187
|
#define ICSNEO_NETID_LOGICAL_DISK_INFO 187
|
||||||
#define ICSNEO_NETID_ETH_PHY_CONTROL 239
|
#define ICSNEO_NETID_ETH_PHY_CONTROL 239
|
||||||
|
#define ICSNEO_NETID_EXTENDED_COMMAND 240
|
||||||
#define ICSNEO_NETID_FLEXRAY_CONTROL 243
|
#define ICSNEO_NETID_FLEXRAY_CONTROL 243
|
||||||
#define ICSNEO_NETID_HW_COM_LATENCY_TEST 512
|
#define ICSNEO_NETID_HW_COM_LATENCY_TEST 512
|
||||||
#define ICSNEO_NETID_DEVICE_STATUS 513
|
#define ICSNEO_NETID_DEVICE_STATUS 513
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue