renamed RawMessage to InternalMessage
parent
dc54bc6868
commit
4901168068
|
|
@ -738,7 +738,7 @@ int icsneo_getDeviceStatus(const neodevice_t* device, void* status, size_t* size
|
||||||
if(!msg) // Did not receive a message
|
if(!msg) // Did not receive a message
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto rawMessage = std::static_pointer_cast<RawMessage>(msg);
|
auto rawMessage = std::static_pointer_cast<InternalMessage>(msg);
|
||||||
if(!rawMessage || (rawMessage->network.getNetID() != Network::NetID::DeviceStatus))
|
if(!rawMessage || (rawMessage->network.getNetID() != Network::NetID::DeviceStatus))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
// They come in as CAN but we will handle them in the device rather than
|
// They come in as CAN but we will handle them in the device rather than
|
||||||
// passing them onto the user.
|
// passing them onto the user.
|
||||||
if(packet->data.size() < 24) {
|
if(packet->data.size() < 24) {
|
||||||
auto rawmsg = std::make_shared<RawMessage>(Network::NetID::Device);
|
auto rawmsg = std::make_shared<InternalMessage>(Network::NetID::Device);
|
||||||
result = rawmsg;
|
result = rawmsg;
|
||||||
rawmsg->data = packet->data;
|
rawmsg->data = packet->data;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -244,7 +244,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
|
|
||||||
// Timestamps are in (resolution) ns increments since 1/1/2007 GMT 00:00:00.0000
|
// Timestamps are in (resolution) ns increments since 1/1/2007 GMT 00:00:00.0000
|
||||||
// The resolution depends on the device
|
// The resolution depends on the device
|
||||||
auto* raw = dynamic_cast<RawMessage*>(result.get());
|
auto* raw = dynamic_cast<InternalMessage*>(result.get());
|
||||||
if(raw == nullptr) {
|
if(raw == nullptr) {
|
||||||
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
||||||
return false; // A nullptr was returned, the packet was malformed
|
return false; // A nullptr was returned, the packet was malformed
|
||||||
|
|
@ -255,7 +255,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
}
|
}
|
||||||
case Network::NetID::DeviceStatus: {
|
case Network::NetID::DeviceStatus: {
|
||||||
// Just pass along the data, the device needs to handle this itself
|
// Just pass along the data, the device needs to handle this itself
|
||||||
result = std::make_shared<RawMessage>(packet->network, packet->data);
|
result = std::make_shared<InternalMessage>(packet->network, packet->data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case Network::NetID::RED_INT_MEMORYREAD: {
|
case Network::NetID::RED_INT_MEMORYREAD: {
|
||||||
|
|
@ -483,6 +483,6 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the moment other types of messages will automatically be decoded as raw messages
|
// For the moment other types of messages will automatically be decoded as raw messages
|
||||||
result = std::make_shared<RawMessage>(packet->network, packet->data);
|
result = std::make_shared<InternalMessage>(packet->network, packet->data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Message::Type::RawMessage: {
|
case Message::Type::RawMessage: {
|
||||||
auto raw = std::dynamic_pointer_cast<RawMessage>(message);
|
auto raw = std::dynamic_pointer_cast<InternalMessage>(message);
|
||||||
|
|
||||||
// Raw message uses raw->data as the buffer unless directed otherwise
|
// Raw message uses raw->data as the buffer unless directed otherwise
|
||||||
buffer = &raw->data;
|
buffer = &raw->data;
|
||||||
|
|
@ -243,7 +243,7 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
|
||||||
* In this case, command 0x06 is SetLEDState.
|
* In this case, command 0x06 is SetLEDState.
|
||||||
* This old command type is not really used anywhere else.
|
* This old command type is not really used anywhere else.
|
||||||
*/
|
*/
|
||||||
auto canmsg = std::make_shared<RawMessage>(Network::NetID::Device);
|
auto canmsg = std::make_shared<InternalMessage>(Network::NetID::Device);
|
||||||
msg = canmsg;
|
msg = canmsg;
|
||||||
if(arguments.empty()) {
|
if(arguments.empty()) {
|
||||||
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
|
|
|
||||||
|
|
@ -472,7 +472,7 @@ int8_t Device::prepareScriptLoad() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto resp = std::static_pointer_cast<RawMessage>(generic);
|
const auto resp = std::static_pointer_cast<InternalMessage>(generic);
|
||||||
retVal = (int8_t)resp->data[0];
|
retVal = (int8_t)resp->data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1719,7 +1719,7 @@ void Device::handleInternalMessage(std::shared_ptr<Message> message) {
|
||||||
latestResetStatus = std::static_pointer_cast<ResetStatusMessage>(message);
|
latestResetStatus = std::static_pointer_cast<ResetStatusMessage>(message);
|
||||||
break;
|
break;
|
||||||
case Message::Type::RawMessage: {
|
case Message::Type::RawMessage: {
|
||||||
auto rawMessage = std::static_pointer_cast<RawMessage>(message);
|
auto rawMessage = std::static_pointer_cast<InternalMessage>(message);
|
||||||
switch(rawMessage->network.getNetID()) {
|
switch(rawMessage->network.getNetID()) {
|
||||||
case Network::NetID::Device: {
|
case Network::NetID::Device: {
|
||||||
// Device is not guaranteed to be a CANMessage, it might be a RawMessage
|
// Device is not guaranteed to be a CANMessage, it might be a RawMessage
|
||||||
|
|
@ -1895,7 +1895,7 @@ std::optional<std::chrono::time_point<std::chrono::system_clock>> Device::getRTC
|
||||||
if(!generic) // Did not receive a message
|
if(!generic) // Did not receive a message
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
auto rawMes = std::dynamic_pointer_cast<RawMessage>(generic);
|
auto rawMes = std::dynamic_pointer_cast<InternalMessage>(generic);
|
||||||
if(!rawMes)
|
if(!rawMes)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,9 @@ enum class AppErrorType : uint16_t {
|
||||||
AppNoError = 255
|
AppNoError = 255
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppErrorMessage : public RawMessage {
|
class AppErrorMessage : public InternalMessage {
|
||||||
public:
|
public:
|
||||||
AppErrorMessage() : RawMessage(Message::Type::AppError, Network::NetID::RED_App_Error) {}
|
AppErrorMessage() : InternalMessage(Message::Type::AppError, Network::NetID::RED_App_Error) {}
|
||||||
uint16_t errorType;
|
uint16_t errorType;
|
||||||
Network::NetID errorNetID;
|
Network::NetID errorNetID;
|
||||||
uint32_t timestamp10us;
|
uint32_t timestamp10us;
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
class DiskDataMessage : public RawMessage {
|
class DiskDataMessage : public InternalMessage {
|
||||||
public:
|
public:
|
||||||
DiskDataMessage(std::vector<uint8_t>&& d) : RawMessage(Network::NetID::DiskData) {
|
DiskDataMessage(std::vector<uint8_t>&& d) : InternalMessage(Network::NetID::DiskData) {
|
||||||
data = std::move(d);
|
data = std::move(d);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public:
|
||||||
|
|
||||||
if(message->type == Message::Type::Frame || message->type == Message::Type::Main51 ||
|
if(message->type == Message::Type::Frame || message->type == Message::Type::Main51 ||
|
||||||
message->type == Message::Type::RawMessage || message->type == Message::Type::ReadSettings) {
|
message->type == Message::Type::RawMessage || message->type == Message::Type::ReadSettings) {
|
||||||
const auto frame = std::static_pointer_cast<RawMessage>(message);
|
const auto frame = std::static_pointer_cast<InternalMessage>(message);
|
||||||
if(!matchNetworkType(frame->network.getType()))
|
if(!matchNetworkType(frame->network.getType()))
|
||||||
return false;
|
return false;
|
||||||
if(!matchNetID(frame->network.getNetID()))
|
if(!matchNetID(frame->network.getNetID()))
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
class FlashMemoryMessage : public RawMessage {
|
class FlashMemoryMessage : public InternalMessage {
|
||||||
public:
|
public:
|
||||||
FlashMemoryMessage() : RawMessage(Message::Type::RawMessage, Network::NetID::RED_INT_MEMORYREAD) {}
|
FlashMemoryMessage() : InternalMessage(Message::Type::RawMessage, Network::NetID::RED_INT_MEMORYREAD) {}
|
||||||
uint16_t startAddress = 0;
|
uint16_t startAddress = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
#include "icsneo/communication/livedata.h"
|
#include "icsneo/communication/livedata.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
class LiveDataMessage : public RawMessage {
|
class LiveDataMessage : public InternalMessage {
|
||||||
public:
|
public:
|
||||||
LiveDataMessage() : RawMessage(Message::Type::LiveData, Network::NetID::ExtendedCommand) {}
|
LiveDataMessage() : InternalMessage(Message::Type::LiveData, Network::NetID::ExtendedCommand) {}
|
||||||
LiveDataHandle handle;
|
LiveDataHandle handle;
|
||||||
LiveDataCommand cmd;
|
LiveDataCommand cmd;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
class Main51Message : public RawMessage {
|
class Main51Message : public InternalMessage {
|
||||||
public:
|
public:
|
||||||
Main51Message() : RawMessage(Message::Type::Main51, Network::NetID::Main51) {}
|
Main51Message() : InternalMessage(Message::Type::Main51, Network::NetID::Main51) {}
|
||||||
Command command = Command(0);
|
Command command = Command(0);
|
||||||
bool forceShortFormat = false; // Necessary for EnableNetworkCom and EnableNetworkComEx
|
bool forceShortFormat = false; // Necessary for EnableNetworkCom and EnableNetworkComEx
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -57,12 +57,12 @@ public:
|
||||||
uint64_t timestamp = 0;
|
uint64_t timestamp = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RawMessage : public Message {
|
class InternalMessage : public Message {
|
||||||
public:
|
public:
|
||||||
RawMessage(Message::Type type = Message::Type::RawMessage) : Message(type) {}
|
InternalMessage(Message::Type type = Message::Type::RawMessage) : Message(type) {}
|
||||||
RawMessage(Message::Type type, Network net) : Message(type), network(net) {}
|
InternalMessage(Message::Type type, Network net) : Message(type), network(net) {}
|
||||||
RawMessage(Network net) : Message(Message::Type::RawMessage), network(net) {}
|
InternalMessage(Network net) : Message(Message::Type::RawMessage), network(net) {}
|
||||||
RawMessage(Network net, std::vector<uint8_t> d) : Message(Message::Type::RawMessage), network(net), data(d) {}
|
InternalMessage(Network net, std::vector<uint8_t> d) : Message(Message::Type::RawMessage), network(net), data(d) {}
|
||||||
|
|
||||||
virtual const icsneo_msg_type_t getMsgType() const { return icsneo_msg_type_internal; }
|
virtual const icsneo_msg_type_t getMsgType() const { return icsneo_msg_type_internal; }
|
||||||
|
|
||||||
|
|
@ -70,9 +70,9 @@ public:
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BusMessage : public RawMessage {
|
class BusMessage : public InternalMessage {
|
||||||
public:
|
public:
|
||||||
BusMessage() : RawMessage(Message::Type::Frame) {}
|
BusMessage() : InternalMessage(Message::Type::Frame) {}
|
||||||
|
|
||||||
const icsneo_msg_type_t getMsgType() const final { return icsneo_msg_type_bus; }
|
const icsneo_msg_type_t getMsgType() const final { return icsneo_msg_type_bus; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
class NeoReadMemorySDMessage : public RawMessage {
|
class NeoReadMemorySDMessage : public InternalMessage {
|
||||||
public:
|
public:
|
||||||
NeoReadMemorySDMessage() : RawMessage(Message::Type::RawMessage, Network::NetID::NeoMemorySDRead) {}
|
NeoReadMemorySDMessage() : InternalMessage(Message::Type::RawMessage, Network::NetID::NeoMemorySDRead) {}
|
||||||
uint32_t startAddress = 0;
|
uint32_t startAddress = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
class ReadSettingsMessage : public RawMessage {
|
class ReadSettingsMessage : public InternalMessage {
|
||||||
public:
|
public:
|
||||||
ReadSettingsMessage() : RawMessage(Message::Type::ReadSettings, Network::NetID::ReadSettings) {}
|
ReadSettingsMessage() : InternalMessage(Message::Type::ReadSettings, Network::NetID::ReadSettings) {}
|
||||||
|
|
||||||
enum class Response : uint8_t {
|
enum class Response : uint8_t {
|
||||||
OK = 0,
|
OK = 0,
|
||||||
|
|
|
||||||
|
|
@ -835,7 +835,7 @@ protected:
|
||||||
|
|
||||||
void handleInternalMessage(std::shared_ptr<Message> message);
|
void handleInternalMessage(std::shared_ptr<Message> message);
|
||||||
|
|
||||||
virtual void handleDeviceStatus(const std::shared_ptr<RawMessage>&) {}
|
virtual void handleDeviceStatus(const std::shared_ptr<InternalMessage>&) {}
|
||||||
|
|
||||||
neodevice_t& getWritableNeoDevice() { return data; }
|
neodevice_t& getWritableNeoDevice() { return data; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ protected:
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
|
||||||
if(message->data.size() < sizeof(neovifire2_status_t))
|
if(message->data.size() < sizeof(neovifire2_status_t))
|
||||||
return;
|
return;
|
||||||
std::lock_guard<std::mutex> lk(ioMutex);
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ protected:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
|
||||||
if(message->data.size() < sizeof(fire2vnet_status_t))
|
if(message->data.size() < sizeof(fire2vnet_status_t))
|
||||||
return;
|
return;
|
||||||
std::lock_guard<std::mutex> lk(ioMutex);
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ protected:
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
|
||||||
if(message->data.size() < sizeof(radgalaxy_status_t))
|
if(message->data.size() < sizeof(radgalaxy_status_t))
|
||||||
return;
|
return;
|
||||||
std::lock_guard<std::mutex> lk(ioMutex);
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ protected:
|
||||||
txNetworks.insert(txNetworks.end(), supportedTxNetworks.begin(), supportedTxNetworks.end());
|
txNetworks.insert(txNetworks.end(), supportedTxNetworks.begin(), supportedTxNetworks.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
|
||||||
if(message->data.size() < sizeof(radgigastar_status_t))
|
if(message->data.size() < sizeof(radgigastar_status_t))
|
||||||
return;
|
return;
|
||||||
std::lock_guard<std::mutex> lk(ioMutex);
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ namespace icsneo
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
void setupSupportedTXNetworks(std::vector<Network> &txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
void setupSupportedTXNetworks(std::vector<Network> &txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
void handleDeviceStatus(const std::shared_ptr<RawMessage> &message) override
|
void handleDeviceStatus(const std::shared_ptr<InternalMessage> &message) override
|
||||||
{
|
{
|
||||||
if (message->data.size() < sizeof(radgigastar2_status_t))
|
if (message->data.size() < sizeof(radgigastar2_status_t))
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ protected:
|
||||||
txNetworks.insert(txNetworks.end(), supportedTxNetworks.begin(), supportedTxNetworks.end());
|
txNetworks.insert(txNetworks.end(), supportedTxNetworks.begin(), supportedTxNetworks.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
|
||||||
if(message->data.size() < sizeof(radmars_status_t))
|
if(message->data.size() < sizeof(radmars_status_t))
|
||||||
return;
|
return;
|
||||||
std::lock_guard<std::mutex> lk(ioMutex);
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ protected:
|
||||||
|
|
||||||
size_t getEthernetActivationLineCount() const override { return 1; }
|
size_t getEthernetActivationLineCount() const override { return 1; }
|
||||||
|
|
||||||
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
|
||||||
if(message->data.size() < sizeof(valuecan4_2el_status_t))
|
if(message->data.size() < sizeof(valuecan4_2el_status_t))
|
||||||
return;
|
return;
|
||||||
std::lock_guard<std::mutex> lk(ioMutex);
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue