Motion Master
|
#include "ethernet_client.h"
#include <boost/system/error_code.hpp>
#include <iostream>
#include <vector>
#include "loguru.h"
Functions | |
EthernetMessage | parseEthernetMessage (const std::vector< uint8_t > &buffer) |
Parses a raw Ethernet message buffer into a structured EthernetMessage. More... | |
std::vector< uint8_t > | serializeEthernetMessage (const EthernetMessage &message) |
Serializes an EthernetMessage object into a byte buffer. More... | |
EthernetMessage parseEthernetMessage | ( | const std::vector< uint8_t > & | buffer | ) |
Parses a raw Ethernet message buffer into a structured EthernetMessage.
This function interprets the first 7 bytes of the buffer as the message header, extracting the type, sequence ID, status, and payload size. If the size field is greater than zero, it also extracts the payload data.
buffer | The raw byte buffer containing the Ethernet message. Must be at least 7 bytes long to contain the header. |
std::runtime_error | If the buffer is smaller than the required header size. |
std::vector< uint8_t > serializeEthernetMessage | ( | const EthernetMessage & | message | ) |
Serializes an EthernetMessage object into a byte buffer.
This function converts the provided EthernetMessage into a byte array, which can be sent over a network. The EthernetMessage type, ID, status, size, and any associated data are serialized into the buffer in a specific format expected by the receiving device.
message | The EthernetMessage object to serialize. |