#include "icsneo/communication/packet/genericbinarystatuspacket.h" #include "icsneo/communication/message/genericbinarystatusmessage.h" using namespace icsneo; #pragma pack(push, 2) struct GenericBinaryStatusResponse { ExtendedResponseMessage::ResponseHeader header; size_t size; uint16_t index; uint16_t status; }; #pragma pack(pop) std::shared_ptr GenericBinaryStatusPacket::DecodeToMessage(const std::vector& bytes) { if(bytes.size() < sizeof(GenericBinaryStatusResponse)) { return nullptr; } auto msg = std::make_shared(); const auto& response = *reinterpret_cast(bytes.data()); msg->binarySize = response.size; msg->binaryIndex = response.index; msg->binaryStatus = response.status; return msg; } std::vector GenericBinaryStatusPacket::EncodeArguments(uint16_t binaryIndex) { std::vector bytestream(sizeof(GenericBinaryStatusResponse)); auto& parameters = *reinterpret_cast(bytestream.data()); parameters.index = binaryIndex; return bytestream; }