Device: RADMoon2ZL: Add TC10 commands
parent
77928dc93d
commit
cf1b4778a1
|
|
@ -242,6 +242,7 @@ set(SRC_FILES
|
||||||
communication/message/ethphymessage.cpp
|
communication/message/ethphymessage.cpp
|
||||||
communication/message/linmessage.cpp
|
communication/message/linmessage.cpp
|
||||||
communication/message/livedatamessage.cpp
|
communication/message/livedatamessage.cpp
|
||||||
|
communication/message/tc10statusmessage.cpp
|
||||||
communication/packet/flexraypacket.cpp
|
communication/packet/flexraypacket.cpp
|
||||||
communication/packet/canpacket.cpp
|
communication/packet/canpacket.cpp
|
||||||
communication/packet/a2bpacket.cpp
|
communication/packet/a2bpacket.cpp
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ static constexpr const char* VALUE_NOT_YET_PRESENT = "The value is not yet prese
|
||||||
static constexpr const char* TIMEOUT = "The timeout was reached.";
|
static constexpr const char* TIMEOUT = "The timeout was reached.";
|
||||||
static constexpr const char* WIVI_NOT_SUPPORTED = "Wireless neoVI functions are not supported on this device.";
|
static constexpr const char* WIVI_NOT_SUPPORTED = "Wireless neoVI functions are not supported on this device.";
|
||||||
static constexpr const char* RESTRICTED_ENTRY_FLAG = "Attempted to set a restricted flag in a Root Directory entry.";
|
static constexpr const char* RESTRICTED_ENTRY_FLAG = "Attempted to set a restricted flag in a Root Directory entry.";
|
||||||
|
static constexpr const char* NOT_SUPPORTED = "The requested feature is not supported.";
|
||||||
|
|
||||||
// Device Errors
|
// Device Errors
|
||||||
static constexpr const char* POLLING_MESSAGE_OVERFLOW = "Too many messages have been recieved for the polling message buffer, some have been lost!";
|
static constexpr const char* POLLING_MESSAGE_OVERFLOW = "Too many messages have been recieved for the polling message buffer, some have been lost!";
|
||||||
|
|
@ -221,6 +222,8 @@ const char* APIEvent::DescriptionForType(Type type) {
|
||||||
return WIVI_NOT_SUPPORTED;
|
return WIVI_NOT_SUPPORTED;
|
||||||
case Type::RestrictedEntryFlag:
|
case Type::RestrictedEntryFlag:
|
||||||
return RESTRICTED_ENTRY_FLAG;
|
return RESTRICTED_ENTRY_FLAG;
|
||||||
|
case Type::NotSupported:
|
||||||
|
return NOT_SUPPORTED;
|
||||||
|
|
||||||
// Device Errors
|
// Device Errors
|
||||||
case Type::PollingMessageOverflow:
|
case Type::PollingMessageOverflow:
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#include "icsneo/communication/message/livedatamessage.h"
|
#include "icsneo/communication/message/livedatamessage.h"
|
||||||
#include "icsneo/communication/message/diskdatamessage.h"
|
#include "icsneo/communication/message/diskdatamessage.h"
|
||||||
#include "icsneo/communication/message/hardwareinfo.h"
|
#include "icsneo/communication/message/hardwareinfo.h"
|
||||||
|
#include "icsneo/communication/message/tc10statusmessage.h"
|
||||||
#include "icsneo/communication/command.h"
|
#include "icsneo/communication/command.h"
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/communication/packet/canpacket.h"
|
#include "icsneo/communication/packet/canpacket.h"
|
||||||
|
|
@ -289,6 +290,9 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
case ExtendedCommand::LiveData:
|
case ExtendedCommand::LiveData:
|
||||||
result = HardwareLiveDataPacket::DecodeToMessage(packet->data, report);
|
result = HardwareLiveDataPacket::DecodeToMessage(packet->data, report);
|
||||||
return true;
|
return true;
|
||||||
|
case ExtendedCommand::GetTC10Status:
|
||||||
|
result = TC10StatusMessage::DecodeToMessage(packet->data);
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
// No defined handler, treat this as a RawMessage
|
// No defined handler, treat this as a RawMessage
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
#include "icsneo/communication/message/tc10statusmessage.h"
|
||||||
|
#include "icsneo/communication/command.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
struct Header {
|
||||||
|
ExtendedCommand command;
|
||||||
|
uint16_t length;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Packet {
|
||||||
|
Header header;
|
||||||
|
TC10WakeStatus wakeStatus;
|
||||||
|
TC10SleepStatus sleepStatus;
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
std::shared_ptr<TC10StatusMessage> TC10StatusMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
if(bytestream.size() < sizeof(Packet)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
const Packet* packet = (Packet*)bytestream.data();
|
||||||
|
if (packet->header.command != ExtendedCommand::GetTC10Status) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (packet->header.length < sizeof(Packet) - sizeof(Header)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return std::make_shared<TC10StatusMessage>(packet->wakeStatus, packet->sleepStatus);
|
||||||
|
}
|
||||||
|
|
@ -3180,3 +3180,79 @@ std::optional<uint64_t> Device::getVSADiskSize() {
|
||||||
}
|
}
|
||||||
return diskSize;
|
return diskSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Device::requestTC10Wake(Network::NetID network) {
|
||||||
|
if(!supportsTC10()) {
|
||||||
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::vector<uint8_t> args(sizeof(network));
|
||||||
|
*(Network::NetID*)args.data() = network;
|
||||||
|
auto msg = com->waitForMessageSync([&] {
|
||||||
|
return com->sendCommand(ExtendedCommand::RequestTC10Wake, args);
|
||||||
|
}, std::make_shared<MessageFilter>(Message::Type::ExtendedResponse), std::chrono::milliseconds(1000));
|
||||||
|
|
||||||
|
if(!msg) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto resp = std::static_pointer_cast<ExtendedResponseMessage>(msg);
|
||||||
|
if(!resp) {
|
||||||
|
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp->response == ExtendedResponse::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::requestTC10Sleep(Network::NetID network) {
|
||||||
|
if(!supportsTC10()) {
|
||||||
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::vector<uint8_t> args(sizeof(network));
|
||||||
|
*(Network::NetID*)args.data() = network;
|
||||||
|
auto msg = com->waitForMessageSync([&] {
|
||||||
|
return com->sendCommand(ExtendedCommand::RequestTC10Sleep, args);
|
||||||
|
}, std::make_shared<MessageFilter>(Message::Type::ExtendedResponse), std::chrono::milliseconds(1000));
|
||||||
|
|
||||||
|
if(!msg) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto typed = std::static_pointer_cast<ExtendedResponseMessage>(msg);
|
||||||
|
if(!typed) {
|
||||||
|
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return typed->response == ExtendedResponse::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<TC10StatusMessage> Device::getTC10Status(Network::NetID network) {
|
||||||
|
if(!supportsTC10()) {
|
||||||
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
std::vector<uint8_t> args(sizeof(network));
|
||||||
|
*(Network::NetID*)args.data() = network;
|
||||||
|
auto msg = com->waitForMessageSync([&] {
|
||||||
|
return com->sendCommand(ExtendedCommand::GetTC10Status, args);
|
||||||
|
}, std::make_shared<MessageFilter>(Message::Type::TC10Status), std::chrono::milliseconds(1000));
|
||||||
|
|
||||||
|
if(!msg) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto typed = std::static_pointer_cast<TC10StatusMessage>(msg);
|
||||||
|
|
||||||
|
if(!typed) {
|
||||||
|
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *typed;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ public:
|
||||||
Timeout = 0x1014,
|
Timeout = 0x1014,
|
||||||
WiVINotSupported = 0x1015,
|
WiVINotSupported = 0x1015,
|
||||||
RestrictedEntryFlag = 0x1016,
|
RestrictedEntryFlag = 0x1016,
|
||||||
|
NotSupported = 0x1017,
|
||||||
|
|
||||||
// Device Events
|
// Device Events
|
||||||
PollingMessageOverflow = 0x2000,
|
PollingMessageOverflow = 0x2000,
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,9 @@ enum class ExtendedCommand : uint16_t {
|
||||||
SetRootFSEntryFlags = 0x0027,
|
SetRootFSEntryFlags = 0x0027,
|
||||||
GenericBinaryInfo = 0x0030,
|
GenericBinaryInfo = 0x0030,
|
||||||
LiveData = 0x0035,
|
LiveData = 0x0035,
|
||||||
|
RequestTC10Wake = 0x003D,
|
||||||
|
RequestTC10Sleep = 0x003E,
|
||||||
|
GetTC10Status = 0x003F,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ExtendedResponse : int32_t {
|
enum class ExtendedResponse : int32_t {
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@ public:
|
||||||
SupportedFeatures = 0x800d,
|
SupportedFeatures = 0x800d,
|
||||||
GenericBinaryStatus = 0x800e,
|
GenericBinaryStatus = 0x800e,
|
||||||
LiveData = 0x800f,
|
LiveData = 0x800f,
|
||||||
HardwareInfo = 0x8010
|
HardwareInfo = 0x8010,
|
||||||
|
TC10Status = 0x8011,
|
||||||
};
|
};
|
||||||
|
|
||||||
Message(Type t) : type(t) {}
|
Message(Type t) : type(t) {}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
#ifndef __TC10STATUSMESSAGE_H
|
||||||
|
#define __TC10STATUSMESSAGE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/message.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace icsneo
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class TC10WakeStatus : uint8_t {
|
||||||
|
NoWakeReceived,
|
||||||
|
WakeReceived,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class TC10SleepStatus : uint8_t {
|
||||||
|
NoSleepReceived,
|
||||||
|
SleepReceived,
|
||||||
|
SleepFailed,
|
||||||
|
SleepAborted,
|
||||||
|
};
|
||||||
|
|
||||||
|
class TC10StatusMessage : public Message {
|
||||||
|
public:
|
||||||
|
static std::shared_ptr<TC10StatusMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||||
|
|
||||||
|
TC10StatusMessage(const TC10WakeStatus& wakeStatus, const TC10SleepStatus& sleepStatus) :
|
||||||
|
Message(Type::TC10Status), wakeStatus(wakeStatus), sleepStatus(sleepStatus) {}
|
||||||
|
|
||||||
|
const TC10WakeStatus wakeStatus;
|
||||||
|
const TC10SleepStatus sleepStatus;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
#include "icsneo/communication/message/hardwareinfo.h"
|
#include "icsneo/communication/message/hardwareinfo.h"
|
||||||
#include "icsneo/communication/message/extendeddatamessage.h"
|
#include "icsneo/communication/message/extendeddatamessage.h"
|
||||||
#include "icsneo/communication/message/livedatamessage.h"
|
#include "icsneo/communication/message/livedatamessage.h"
|
||||||
|
#include "icsneo/communication/message/tc10statusmessage.h"
|
||||||
#include "icsneo/communication/packet/genericbinarystatuspacket.h"
|
#include "icsneo/communication/packet/genericbinarystatuspacket.h"
|
||||||
#include "icsneo/communication/packet/livedatapacket.h"
|
#include "icsneo/communication/packet/livedatapacket.h"
|
||||||
#include "icsneo/device/extensions/flexray/controller.h"
|
#include "icsneo/device/extensions/flexray/controller.h"
|
||||||
|
|
@ -722,6 +723,14 @@ public:
|
||||||
|
|
||||||
virtual bool supportsComponentVersions() const { return false; }
|
virtual bool supportsComponentVersions() const { return false; }
|
||||||
|
|
||||||
|
virtual bool supportsTC10() const { return false; }
|
||||||
|
|
||||||
|
bool requestTC10Wake(Network::NetID network);
|
||||||
|
|
||||||
|
bool requestTC10Sleep(Network::NetID network);
|
||||||
|
|
||||||
|
std::optional<TC10StatusMessage> getTC10Status(Network::NetID network);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool online = false;
|
bool online = false;
|
||||||
int messagePollingCallbackID = 0;
|
int messagePollingCallbackID = 0;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ public:
|
||||||
|
|
||||||
bool supportsComponentVersions() const override { return true; }
|
bool supportsComponentVersions() const override { return true; }
|
||||||
|
|
||||||
|
bool supportsTC10() const override { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RADMoon2ZL(neodevice_t neodevice, const driver_factory_t& makeDriver) : RADMoon2Base(neodevice) {
|
RADMoon2ZL(neodevice_t neodevice, const driver_factory_t& makeDriver) : RADMoon2Base(neodevice) {
|
||||||
initialize<RADMoon2Settings>(makeDriver);
|
initialize<RADMoon2Settings>(makeDriver);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue