Motion Master
Loading...
Searching...
No Matches
Functions
ethernet_client.cc File Reference
#include "ethernet_client.h"
#include <boost/system/error_code.hpp>
#include <iostream>
#include <vector>
#include "loguru.h"
Include dependency graph for ethernet_client.cc:

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...
 

Function Documentation

◆ parseEthernetMessage()

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.

Parameters
bufferThe raw byte buffer containing the Ethernet message. Must be at least 7 bytes long to contain the header.
Returns
A structured representation of the parsed Ethernet message.
Exceptions
std::runtime_errorIf the buffer is smaller than the required header size.
See also
EthernetMessage, EthernetMessageType

◆ serializeEthernetMessage()

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.

Parameters
messageThe EthernetMessage object to serialize.
Returns
A std::vector<uint8_t> containing the serialized byte buffer.
See also
EthernetMessage, EthernetMessageType