Motion Master 6.0.0-alpha.111
Next-generation motion control software
Loading...
Searching...
No Matches
ethercat_frame.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <optional>
5#include <span>
6#include <vector>
7
10
11namespace mm::capture {
12
14inline constexpr uint16_t kEtherCatEtherType = 0x88A4;
15
17struct Datagram {
18 uint8_t command = 0;
19 uint8_t index = 0;
20 uint16_t adp = 0;
21 uint16_t ado = 0;
22 uint16_t length = 0;
23 bool more = false;
24 uint16_t wkc = 0;
25};
26
33 bool fromMaster = false;
34 std::vector<Datagram> datagrams;
35};
36
41bool isLogicalCommand(uint8_t command);
42
47bool isPositionCountedUp(uint8_t command);
48
54std::optional<EtherCatFrame> parseEtherCatFrame(std::span<const uint8_t> bytes);
55
56} // namespace mm::capture
Definition capture.h:14
bool isPositionCountedUp(uint8_t command)
Whether every slave counts command's position up as the frame passes.
Definition ethercat_frame.cc:26
bool isLogicalCommand(uint8_t command)
Whether command addresses the process image: LRD, LWR or LRW.
Definition ethercat_frame.cc:21
constexpr uint16_t kEtherCatEtherType
The Ethernet type of an EtherCAT frame.
Definition ethercat_frame.h:14
std::optional< EtherCatFrame > parseEtherCatFrame(std::span< const uint8_t > bytes)
Reads one Ethernet frame that carries EtherCAT datagrams.
Definition ethercat_frame.cc:43
std::size_t bytes
Definition spoe_connection.cc:24
The header of one datagram in a frame, without its data.
Definition ethercat_frame.h:17
uint8_t command
ETG.1000.4 command: 1 APRD, 4 FPRD, 10 LRD, 12 LRW, and so on.
Definition ethercat_frame.h:18
uint16_t ado
Address offset, or the low half of a logical address.
Definition ethercat_frame.h:21
uint16_t length
Bytes of data in the datagram.
Definition ethercat_frame.h:22
bool more
Another datagram follows in the same frame.
Definition ethercat_frame.h:23
uint16_t adp
Address position, or the high half of a logical address.
Definition ethercat_frame.h:20
uint8_t index
The master's index, which is how it pairs a return with a send.
Definition ethercat_frame.h:19
uint16_t wkc
The working counter after the data.
Definition ethercat_frame.h:24
One EtherCAT frame.
Definition ethercat_frame.h:28
std::vector< Datagram > datagrams
In wire order. Never empty.
Definition ethercat_frame.h:34
bool fromMaster
Definition ethercat_frame.h:33