Motion Master
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
ethernet_client.h File Reference
#include <boost/asio.hpp>
#include <chrono>
#include <string>
#include "common.h"
Include dependency graph for ethernet_client.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EthernetMessage
 Structure representing a parsed Ethernet response message. More...
 
class  EthernetDevice
 Handles TCP communication with SOMANET devices over Ethernet. More...
 

Enumerations

enum class  EthernetMessageType : uint8_t {
  SDO_READ = 0x01 , SDO_WRITE = 0x02 , PDO_RXTX_FRAME , PDO_CONTROL = 0x04 ,
  PDO_MAP = 0x05 , FIRMWARE_UPDATE = 0x0B , FILE_READ = 0x0C , FILE_WRITE = 0x0D ,
  STATE_CONTROL , STATE_READ = 0x0F , PARAM_FULL_LIST = 0x13 , SERVER_INFO = 0x20
}
 Enumeration of Ethernet message types used in the protocol. More...
 
enum class  EthernetMessageStatus : uint8_t {
  OK = 0x00 , FIRST = 0x80 , MIDDLE = 0xC0 , LAST = 0x40 ,
  ERR = 0x28
}
 Represents the status of an Ethernet message during transmission or processing. More...
 
enum class  EthernetSqiReplyStatus : uint8_t { BSY = 0x28 , ACK = 0x58 , ERR = 0x63 }
 Enum class representing the status codes for an Ethernet SQI reply. More...
 

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

Enumeration Type Documentation

◆ EthernetMessageStatus

enum class EthernetMessageStatus : uint8_t
strong

Represents the status of an Ethernet message during transmission or processing.

This enum is used to indicate whether a message is complete, part of a segmented sequence, or contains an error. The values are bit flags that may be interpreted by the protocol handler.

Enumerator
OK 

Message is complete and valid.

FIRST 

First segment of a multi-part message.

MIDDLE 

Middle segment of a multi-part message.

LAST 

Last segment of a multi-part message.

ERR 

Message contains an error or failed validation.

◆ EthernetMessageType

enum class EthernetMessageType : uint8_t
strong

Enumeration of Ethernet message types used in the protocol.

Each message type corresponds to a specific operation or request within the Ethernet communication protocol.

Note
This is specified in the "Ethernet interface definition" document.
Enumerator
SDO_READ 

Read a Service Data Object (SDO) value.

SDO_WRITE 

Write a value to a Service Data Object (SDO).

PDO_RXTX_FRAME 

Transmit or receive a Process Data Object (PDO) frame.

PDO_CONTROL 

Control or configure PDO behavior.

PDO_MAP 

Map PDO entries or configurations.

FIRMWARE_UPDATE 

Perform firmware update operation.

FILE_READ 

Read a file from the device.

FILE_WRITE 

Write a file to the device.

STATE_CONTROL 

Control the state of the device (e.g., INIT, PREOP).

STATE_READ 

Read the current state of the device.

PARAM_FULL_LIST 

Request a full list of parameters.

SERVER_INFO 

Request information about the server or device.

◆ EthernetSqiReplyStatus

enum class EthernetSqiReplyStatus : uint8_t
strong

Enum class representing the status codes for an Ethernet SQI reply.

This enum class defines the possible reply statuses returned in response to an SQI (Serial Quality Indicator) communication with a System on Chip (SoC).

Enumerator
BSY 

Device is busy and cannot process the request.

ACK 

Acknowledgment received.

ERR 

Error occurred during processing.

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