3#include <boost/asio.hpp>
259 const std::chrono::steady_clock::duration expiryTime);
287 uint8_t
getState(
const std::chrono::steady_clock::duration expiryTime =
288 std::chrono::milliseconds(3000))
override;
309 const std::chrono::steady_clock::duration expiryTime =
310 std::chrono::milliseconds(3000))
override;
331 const std::string& filename,
332 const std::chrono::steady_clock::duration expiryTime =
333 std::chrono::milliseconds(5000))
override;
352 const bool stripSizeSuffix =
true,
353 const std::chrono::steady_clock::duration expiryTime =
354 std::chrono::milliseconds(3000));
370 const std::chrono::steady_clock::duration expiryTime =
371 std::chrono::milliseconds(3000));
394 bool writeFile(
const std::string& filename,
const std::vector<uint8_t>& data,
395 const std::chrono::steady_clock::duration expiryTime =
396 std::chrono::milliseconds(5000))
override;
416 expiryTime = std::chrono::milliseconds(2000));
442 bool readValues =
false,
443 const std::chrono::steady_clock::duration expiryTime =
444 std::chrono::milliseconds(1000));
466 uint16_t
index, uint8_t subindex,
467 const std::chrono::steady_clock::duration expiryTime =
468 std::chrono::milliseconds(1000));
491 const std::vector<uint8_t>& data,
492 const std::chrono::steady_clock::duration expiryTime =
493 std::chrono::milliseconds(1000));
508 const std::chrono::steady_clock::duration expiryTime =
509 std::chrono::milliseconds(9000))
override;
516 const uint16_t
index,
const uint8_t subindex,
517 const std::chrono::steady_clock::duration expiryTime =
518 std::chrono::milliseconds(3000))
override;
541 template <
typename T>
543 const std::chrono::steady_clock::duration expiryTime =
544 std::chrono::milliseconds(5000)) {
550 const std::chrono::steady_clock::duration expiryTime =
551 std::chrono::milliseconds(5000))
override;
555 const std::chrono::steady_clock::duration expiryTime =
556 std::chrono::milliseconds(5000))
override;
576 template <
typename T>
578 const std::chrono::steady_clock::duration expiryTime =
579 std::chrono::milliseconds(5000)) {
600 const std::vector<uint8_t>& data,
601 const std::chrono::steady_clock::duration expiryTime =
602 std::chrono::milliseconds(1000));
625 boost::asio::io_context ioContext_;
627 boost::asio::ip::tcp::endpoint
630 boost::asio::ip::tcp::socket
643 std::atomic<uint16_t> seqId_{0};
645 std::unordered_map<common::ParameterKey, common::Parameter>
Handles TCP communication with SOMANET devices over Ethernet.
Definition: ethernet_client.h:170
std::vector< common::Parameter > getParameters(bool readValues=false, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(1000))
Definition: ethernet_client.cc:398
std::vector< uint8_t > sendAndReceiveProcessData(const std::vector< uint8_t > &data, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(1000))
Sends process data to a remote device and receives the response.
Definition: ethernet_client.cc:656
EthernetMessage exchangeWithTimeout(const EthernetMessage &request, const std::chrono::steady_clock::duration expiryTime)
Exchanges a message with a remote server and waits for a response with a timeout.
Definition: ethernet_client.cc:141
uint8_t getState(const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(3000)) override
Sends a request to read the state of the device and returns the state value.
Definition: ethernet_client.cc:208
bool connect()
Establishes a connection to the remote server.
Definition: ethernet_client.cc:112
bool removeFile(const std::string &filename, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(3000))
Removes a file from the device.
Definition: ethernet_client.cc:321
bool writeFile(const std::string &filename, const std::vector< uint8_t > &data, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000)) override
Sends a file in chunks to the remote server via Ethernet.
Definition: ethernet_client.cc:335
std::vector< uint8_t > readFile(const std::string &filename, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000)) override
Reads the contents of a file over Ethernet.
Definition: ethernet_client.cc:244
void download(uint16_t index, uint8_t subindex, const T &value, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))
Sets and downloads a parameter value to the device using the specified type.
Definition: ethernet_client.h:577
bool isConnected()
Checks if the Ethernet socket is currently open.
Definition: ethernet_client.cc:123
common::Parameter & upload(const uint16_t index, const uint8_t subindex, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(3000)) override
Uploads a parameter from the device via SDO and updates the local parameter store.
Definition: ethernet_client.cc:611
uint16_t incrementSeqId()
Increments the sequence ID atomically and wraps it around at the maximum value.
Definition: ethernet_client.cc:107
bool disconnect()
Closes the Ethernet socket connection.
Definition: ethernet_client.cc:125
void exchangeProcessDataAndUpdateParameters() override
Exchanges process data with the remote device and updates local parameters accordingly.
Definition: ethernet_client.cc:680
T upload(uint16_t index, uint8_t subindex, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))
Uploads a parameter from the device and returns its value as the specified type.
Definition: ethernet_client.h:542
std::vector< std::string > readFileList(const bool stripSizeSuffix=true, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(3000))
Reads a list of file names from the device.
Definition: ethernet_client.cc:289
bool setState(uint8_t state, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(3000)) override
Sends a state control command to the Ethernet device and checks the response.
Definition: ethernet_client.cc:228
bool triggerFirmwareUpdate(const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(2000))
Sends a firmware update request to the connected Integro device.
Definition: ethernet_client.cc:382
common::Parameter & findParameter(uint16_t index, uint8_t subindex) override
Finds and returns a reference to a parameter by its index and subindex.
Definition: ethernet_client.cc:599
std::vector< uint8_t > readSdo(uint16_t index, uint8_t subindex, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(1000))
Reads an SDO (Service Data Object) from an Ethernet device.
Definition: ethernet_client.cc:525
bool writeSdo(uint16_t index, uint8_t subindex, const std::vector< uint8_t > &data, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(1000))
Writes an SDO (Service Data Object) to an Ethernet device.
Definition: ethernet_client.cc:553
void loadParameters(bool readValues=false, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(9000)) override
Loads parameters from the device and stores them locally.
Definition: ethernet_client.cc:588
void clearParameters() override
Clears all loaded object dictionary parameters.
Definition: ethernet_client.cc:597
~EthernetDevice()
Destructor for the EthernetDevice class.
Definition: ethernet_client.cc:101
void download(uint16_t index, uint8_t subindex, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000)) override
Downloads a parameter to the device using SDO communication.
Definition: ethernet_client.cc:629
Abstract interface representing a generic device.
Definition: common.h:858
Represents a device parameter identified by index and subindex.
Definition: common.h:472
ParameterValue getValue() const
Retrieves the value of the parameter based on its data type.
Definition: common.cc:31
uint8_t * value
Definition: co_dictionary.h:9
uint16_t index
Definition: co_dictionary.h:0
std::vector< uint8_t > serializeEthernetMessage(const EthernetMessage &message)
Serializes an EthernetMessage object into a byte buffer.
Definition: ethernet_client.cc:37
EthernetMessage parseEthernetMessage(const std::vector< uint8_t > &buffer)
Parses a raw Ethernet message buffer into a structured EthernetMessage.
Definition: ethernet_client.cc:9
EthernetMessageType
Enumeration of Ethernet message types used in the protocol.
Definition: ethernet_client.h:17
@ PARAM_FULL_LIST
Request a full list of parameters.
@ PDO_MAP
Map PDO entries or configurations.
@ SERVER_INFO
Request information about the server or device.
@ STATE_CONTROL
Control the state of the device (e.g., INIT, PREOP).
@ FILE_READ
Read a file from the device.
@ STATE_READ
Read the current state of the device.
@ SDO_WRITE
Write a value to a Service Data Object (SDO).
@ SDO_READ
Read a Service Data Object (SDO) value.
@ FIRMWARE_UPDATE
Perform firmware update operation.
@ FILE_WRITE
Write a file to the device.
@ PDO_CONTROL
Control or configure PDO behavior.
@ PDO_RXTX_FRAME
Transmit or receive a Process Data Object (PDO) frame.
EthernetMessageStatus
Represents the status of an Ethernet message during transmission or processing.
Definition: ethernet_client.h:46
@ FIRST
First segment of a multi-part message.
@ MIDDLE
Middle segment of a multi-part message.
@ ERR
Message contains an error or failed validation.
@ OK
Message is complete and valid.
@ LAST
Last segment of a multi-part message.
EthernetSqiReplyStatus
Enum class representing the status codes for an Ethernet SQI reply.
Definition: ethernet_client.h:60
@ ACK
Acknowledgment received.
@ BSY
Device is busy and cannot process the request.
std::variant< bool, std::int8_t, std::int16_t, std::int32_t, std::int64_t, std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t, float, double, std::string, std::vector< std::uint8_t > > ParameterValue
Definition: common.h:449
Structure representing a parsed Ethernet response message.
Definition: ethernet_client.h:74
std::vector< uint8_t > data
The payload data of the response message.
Definition: ethernet_client.h:123
EthernetSqiReplyStatus sqiStatus
The status of the SQI reply in the response message.
Definition: ethernet_client.h:109
EthernetMessageStatus status
The status of the response message.
Definition: ethernet_client.h:99
static constexpr size_t kBufferSize
Definition: ethernet_client.h:79
EthernetMessageType type
The type of the response message.
Definition: ethernet_client.h:85
uint16_t id
The sequence ID of the response message.
Definition: ethernet_client.h:92
uint16_t size
The size of the buffer in the response message.
Definition: ethernet_client.h:116
static constexpr size_t kHeaderSize
Definition: ethernet_client.h:76
Represents the mapped PDO entries for a slave device.
Definition: common.h:180