|
Motion Master 6.0.0-alpha.111
Next-generation motion control software
|
Namespaces | |
| namespace | soem |
| namespace | spoe |
Classes | |
| struct | AlStatusCode |
| Metadata for a single AL Status Code entry. More... | |
| struct | BusIoLock |
| The bus lock held shared, and a frame slot. The slot goes first. More... | |
| class | BusLock |
| A reader/writer lock that lets no new reader in while a writer waits. More... | |
| class | ControlPlaneLocks |
| The control-plane locks of one fieldbus driver: one for the bus, one per drive. More... | |
| struct | DcConfig |
| Distributed-clock configuration for a slave. More... | |
| struct | DcSyncDiagnostics |
| Live distributed-clock synchronisation status for one slave, read from its ESC. More... | |
| struct | DriveLock |
| The bus lock held shared, the lock of one drive, and a frame slot. More... | |
| struct | EscRegister |
| Metadata for a single ESC register entry. More... | |
| class | FieldbusDriver |
| Abstract interface for an EtherCAT fieldbus driver. More... | |
| struct | FmmuConfig |
| One FMMU's configuration as programmed on a slave's ESC. More... | |
| struct | FoeError |
A structured FoE failure. String-like where a caller only forwards it (operator<<, .message, what()); branchable where a caller must react (kind, retry). More... | |
| struct | FoeErrorCode |
| Metadata for a single FoE error code entry. More... | |
| class | FrameSlot |
| One of a fixed number of slots for a frame on the wire. Released when destroyed. More... | |
| struct | MailboxConfig |
| Mailbox configuration for a slave (the CoE/FoE/EoE/SoE transport windows). More... | |
| struct | MailboxErrorCode |
| Metadata for a single CoE mailbox error code entry. More... | |
| struct | NetworkAdapter |
| struct | ObjectDataTypeInfo |
| Metadata for a single object dictionary data type. More... | |
| struct | OdEntry |
| Schema of a single object dictionary entry uploaded from a slave. More... | |
| struct | OdRead |
| One device's object dictionary as read from the bus, and what the read did not get. More... | |
| struct | PdoLayout |
Layout of the process-data images, produced by configureProcessData. More... | |
| struct | PortDiagnostics |
| Per-port link state and error counters decoded from a slave's ESC. More... | |
| struct | ProcessDataWatchdogConfig |
| Process-data (sync-manager) watchdog configuration of one slave. More... | |
| class | ScopedQuietSdoLog |
| RAII guard that suppresses per-transfer SDO debug logging for its scope (and restores the previous state on exit, so it nests correctly). More... | |
| struct | SdoAbortCode |
| Metadata for a single CoE SDO abort code entry. More... | |
| struct | SiiCategoryDistributedClockElement |
| One distributed-clock setting from SII category 60 (0x3C). More... | |
| struct | SiiCategoryGeneral |
| General device information (SII category 30 / 0x1E). More... | |
| struct | SiiCategoryPdoElement |
| One default PDO (RxPDO category 51 / 0x33, or TxPDO category 50 / 0x32). More... | |
| struct | SiiCategoryPdoEntryElement |
| One mapped object within a default PDO (SII categories 50/51). More... | |
| struct | SiiCategorySection |
| The decoded category section of an SII image. More... | |
| struct | SiiCategorySyncManagerElement |
| One Sync-Manager default from SII category 41 (0x29). More... | |
| struct | SiiInfo |
| SII (Slave Information Interface) — the structured EEPROM image of an EtherCAT slave. More... | |
| struct | SlaveConfig |
Static ESC configuration snapshot for one slave, captured by configureProcessData. More... | |
| struct | SlaveDiagnostics |
| Decoded health diagnostics for one slave, read live from its ESC registers. More... | |
| struct | SlaveInfo |
| Immutable identity fields read from a slave's EEPROM during configuration. More... | |
| struct | SlaveInformationInterface |
| A fully parsed SII image: fixed header plus decoded categories. More... | |
| struct | SlaveIo |
| One slave's input and output windows within the process-data images. More... | |
| struct | SyncManagerConfig |
| One Sync Manager's configuration as programmed on a slave's ESC. More... | |
Enumerations | |
| enum class | EtherCatState : uint16_t { Init = 0x01 , PreOp = 0x02 , Boot = 0x03 , SafeOp = 0x04 , Op = 0x08 } |
| EtherCAT Application Layer state values. More... | |
| enum class | Reachability : uint8_t { Answering , AddressLost , NotAnswering } |
| Whether a slave answers at the station address the master gave it. More... | |
| enum class | Retry { Transient , Permanent } |
Retry disposition of a failed operation: whether re-issuing the identical call could plausibly succeed. This is the one axis callers branch on uniformly — a firmware flasher retries Transient failures and aborts on Permanent ones — so it rides alongside the FoE-specific kind rather than being folded into it. More... | |
| enum class | FoeErrorKind { NoResponse , FileNotFound , BufferTooSmall , PacketMismatch , Protocol } |
Specific File-over-EtherCAT failure kind. Transport-agnostic: the SOEM driver decodes it from the error code of the slave's FoE Error packet, or from a negated ec_err_type when the slave sent none. The SPoE driver decodes it from its own protocol codes. More... | |
| enum class | ObjectDataType : uint16_t { UNSPECIFIED = 0x0000 , BOOLEAN = 0x0001 , BYTE = 0x001E , WORD = 0x001F , DWORD = 0x0020 , BIT1 = 0x0030 , BIT2 = 0x0031 , BIT3 = 0x0032 , BIT4 = 0x0033 , BIT5 = 0x0034 , BIT6 = 0x0035 , BIT7 = 0x0036 , BIT8 = 0x0037 , BIT9 = 0x0038 , BIT10 = 0x0039 , BIT11 = 0x003A , BIT12 = 0x003B , BIT13 = 0x003C , BIT14 = 0x003D , BIT15 = 0x003E , BIT16 = 0x003F , BITARR8 = 0x002D , BITARR16 = 0x002E , BITARR32 = 0x002F , INTEGER8 = 0x0002 , INTEGER16 = 0x0003 , INTEGER24 = 0x0010 , INTEGER32 = 0x0004 , INTEGER40 = 0x0012 , INTEGER48 = 0x0013 , INTEGER56 = 0x0014 , INTEGER64 = 0x0015 , UNSIGNED8 = 0x0005 , UNSIGNED16 = 0x0006 , UNSIGNED24 = 0x0016 , UNSIGNED32 = 0x0007 , UNSIGNED40 = 0x0018 , UNSIGNED48 = 0x0019 , UNSIGNED56 = 0x001A , UNSIGNED64 = 0x001B , REAL32 = 0x0008 , REAL64 = 0x0011 , GUID = 0x001D , VISIBLE_STRING = 0x0009 , OCTET_STRING = 0x000A , UNICODE_STRING = 0x000B , WSTRING = 0x0268 , TIME_OF_DAY = 0x000C , TIME_DIFFERENCE = 0x000D , DOMAIN = 0x000F , ARRAY_OF_INT = 0x0260 , ARRAY_OF_SINT = 0x0261 , ARRAY_OF_DINT = 0x0262 , ARRAY_OF_UDINT = 0x0263 , ARRAY_OF_BITARR8 = 0x0264 , ARRAY_OF_BITARR16 = 0x0265 , ARRAY_OF_BITARR32 = 0x0266 , ARRAY_OF_USINT = 0x0267 , ARRAY_OF_REAL = 0x0269 , ARRAY_OF_LREAL = 0x026A , PDO_MAPPING = 0x0021 , IDENTITY = 0x0023 , COMMAND_PAR = 0x0025 , PDO_PARAMETER = 0x0027 , ENUM = 0x0028 , SM_SYNCHRONISATION = 0x0029 , RECORD = 0x002A , BACKUP_PARAMETER = 0x002B , MODULAR_DEVICE_PROFILE = 0x002C , ERROR_SETTING = 0x0281 , DIAGNOSIS_HISTORY = 0x0282 , EXTERNAL_SYNC_STATUS = 0x0283 , EXTERNAL_SYNC_SETTINGS = 0x0284 , DEFTYPE_FSOEFRAME = 0x0285 , DEFTYPE_FSOECOMMPAR = 0x0286 , UTYPE_START = 0x0800 , UTYPE_END = 0x0FFF } |
| CoE object dictionary data type codes. More... | |
| enum class | SiiCategoryType : uint16_t { Nop = 0 , DeviceSpecific = 1 , Strings = 10 , DataTypes = 20 , General = 30 , Fmmu = 40 , SyncM = 41 , FmmuX = 42 , SyncUnit = 43 , TxPdo = 50 , RxPdo = 51 , Dc = 60 , Timeouts = 70 , Dictionary = 80 , Hardware = 90 , VendorInformation = 100 , Images = 110 , VendorSpecific = 0x0800 , ApplicationSpecific = 0x2000 , End = 0xFFFF } |
| Recognised SII category type identifiers (ETG.2010 Table 5). More... | |
Functions | |
| void | to_json (nlohmann::json &j, const AlStatusCode &c) |
| Serialises an AlStatusCode to JSON. | |
| constexpr const AlStatusCode * | findAlStatusCode (uint16_t code) |
Looks up code in kAlStatusCodes, or returns nullptr if it is not catalogued. | |
| constexpr bool | isAlStatusCodeTerminal (uint16_t code) |
Returns true if code indicates a state-transition failure that cannot be resolved by retrying the same writestate. | |
| constexpr std::string_view | alStatusCodeName (uint16_t code) |
Returns the short name for code, or an empty view if code is not a known AL Status Code. | |
| void | to_json (nlohmann::json &j, const NetworkAdapter &a) |
| Serialises a NetworkAdapter to JSON. | |
| bool | isMacAddress (const std::string &s) |
Returns true if s is a MAC address in either Linux (:) or Windows (-) separator format. | |
| std::string | normalizeMac (const std::string &raw, char sep) |
| Normalises a MAC address string to uppercase with the given separator. | |
| std::optional< std::array< uint8_t, 6 > > | parseMac (const std::string &s) |
| Decodes a MAC address string into its six bytes, in wire order. | |
| std::vector< NetworkAdapter > | enumerateNetworkAdapters () |
| Enumerates all network adapters visible to the OS. | |
| std::expected< NetworkAdapter, std::string > | resolveNetworkAdapter (const std::string &input) |
Resolves a network adapter specifier to a fully populated NetworkAdapter. | |
| void | to_json (nlohmann::json &j, const EscRegister &r) |
| Serialises an EscRegister to JSON. | |
| std::array< uint8_t, kSyncManagerRegisterBytes > | encodeSyncManager (const SyncManagerConfig &config) |
| Encodes a Sync Manager as the eight bytes an FPWR to its register block carries. | |
| std::optional< SyncManagerConfig > | decodeSyncManager (uint8_t index, std::span< const uint8_t > bytes) |
Decodes a Sync Manager register block — the inverse of encodeSyncManager. | |
| std::array< uint8_t, kFmmuRegisterBytes > | encodeFmmu (const FmmuConfig &config) |
| Encodes an FMMU as the sixteen bytes an FPWR to its register block carries. | |
| std::optional< FmmuConfig > | decodeFmmu (uint8_t index, std::span< const uint8_t > bytes) |
Decodes an FMMU register block — the inverse of encodeFmmu. | |
| EtherCatState | alState (uint16_t alStatus) |
| Extracts the AL state (bits 3:0) from a raw AL Status register value (0x0130). | |
| bool | alHasError (uint16_t alStatus) |
| Returns whether the AL Status error indicator (bit 4 of register 0x0130) is set. | |
| std::string_view | toString (EtherCatState state) |
| Human-readable name of an AL state, for log and error messages. | |
| std::string_view | toString (Reachability reachability) |
| API name of a reachability, as the HTTP API and the client spell it. | |
| int | workingCounterContribution (uint16_t alStatus, bool hasOutputs, bool hasInputs) |
| Working-counter contribution of one slave for a given AL status and PDO presence. | |
| bool | exchangesProcessData (uint16_t alStatus) |
| Returns whether a slave with this AL status exchanges process data: SAFE-OP or OP, with the error flag clear. | |
| FoeError | makeFoeRefusal (uint32_t code, std::string_view text, std::string_view op, uint16_t slave, std::string_view filename) |
| Builds the FoeError for a transfer the slave refused with an FoE Error packet, naming the code as an SDO failure names its abort code: "(FoE error 0x8001: Not found)". | |
| std::string_view | foeReason (FoeErrorKind kind) |
| Short human-readable reason for a FoE kind (no surrounding punctuation). | |
| Retry | foeRetry (FoeErrorKind kind) |
| Retry disposition implied by a FoE kind. A missing file or an undersized buffer is a fixed condition that will recur identically; a desync or a not-yet-ready slave (the BOOT bootloader warm-up path) is worth another attempt. | |
| std::ostream & | operator<< (std::ostream &os, const FoeError &e) |
Streams the message, so ASSERT_TRUE(r) << r.error() and spdlog {} work unchanged. | |
| FoeError | makeFoeError (FoeErrorKind kind, std::string_view op, uint16_t slave, std::string_view filename) |
Builds a fully-formed FoeError from a decoded kind plus call context. Keeps the message wording identical to the pre-promotion string ("<op> slave N '<file>' failed
(<reason>)") so nothing downstream that logs or displays it changes shape. | |
| void | to_json (nlohmann::json &j, const FoeErrorCode &e) |
| Serialises a FoeErrorCode to JSON. | |
| constexpr std::string_view | foeErrorCodeName (uint32_t code) |
Returns the name of code, or an empty view if code is not a known FoE error code (vendor-specific, or a slave that put something else in the field). | |
| void | to_json (nlohmann::json &j, const MailboxErrorCode &e) |
| Serialises a MailboxErrorCode to JSON. | |
| constexpr std::string_view | mailboxErrorCodeDescription (uint16_t code) |
Returns the description of code, or an empty view if code is not a known mailbox error code (vendor-specific, or a stale/garbage read). | |
| void | to_json (nlohmann::json &j, const ObjectDataTypeInfo &info) |
| Serialises an ObjectDataTypeInfo to JSON. | |
| constexpr std::string_view | objectDataTypeName (uint16_t code) |
Returns the symbolic name of code, or "UNKNOWN" if it is not in the table. | |
| constexpr uint16_t | objectDataTypeBitSize (uint16_t code) |
Returns the declared bit width of code, or 0 if unknown / variable-length. | |
| void | to_json (nlohmann::json &j, const SdoAbortCode &e) |
| Serialises an SdoAbortCode to JSON. | |
| constexpr std::string_view | sdoAbortCodeDescription (uint32_t code) |
Returns the description of code, or an empty view if code is not a known SDO abort code (vendor-specific, or a stale/garbage read). | |
| std::optional< SiiCategoryType > | resolveSiiCategoryType (uint16_t value) |
Normalises a raw 16-bit category-type word into a SiiCategoryType. | |
| std::expected< SlaveInformationInterface, std::string > | parseSii (std::span< const uint8_t > buffer) |
Parses a raw SII EEPROM image into a SlaveInformationInterface. | |
| std::expected< void, std::string > | validateSiiImage (std::span< const uint8_t > buffer) |
| Checks that a raw SII image is structurally sound enough to be written to an EEPROM. | |
| void | to_json (nlohmann::json &j, const SiiInfo &v) |
| void | to_json (nlohmann::json &j, const SiiCategoryGeneral &v) |
| void | to_json (nlohmann::json &j, const SiiCategorySyncManagerElement &v) |
| void | to_json (nlohmann::json &j, const SiiCategoryPdoEntryElement &v) |
| void | to_json (nlohmann::json &j, const SiiCategoryPdoElement &v) |
| void | to_json (nlohmann::json &j, const SiiCategoryDistributedClockElement &v) |
| void | to_json (nlohmann::json &j, const SiiCategorySection &v) |
| void | to_json (nlohmann::json &j, const SlaveInformationInterface &v) |
| constexpr bool | isSomanetDevice (uint32_t vendorId) |
| Whether a device with this vendor ID is a SOMANET device. | |
Variables | |
| constexpr auto | kAlStatusCodes |
| Catalogue of AL Status Codes. | |
| constexpr auto | kEscRegisters |
| Catalogue of well-known ESC registers. | |
| constexpr std::size_t | kMaxProcessImageBytes = 32768 |
| Maximum size in bytes of the combined process-data image (all outputs + all inputs). | |
| constexpr std::chrono::milliseconds | kFoeReadTimeout {6000} |
| How long a file read waits for the slave's answer, unless the caller asks for longer. | |
| constexpr uint16_t | kSyncManagerRegisterBase = 0x0800 |
| Register block addresses and widths for the two configurations above (ETG.1000.4 §6). | |
| constexpr uint16_t | kSyncManagerRegisterBytes = 8 |
| Width of one channel (Table 58). | |
| constexpr uint16_t | kFmmuRegisterBase = 0x0600 |
| FMMU entity 0 (Table 57). | |
| constexpr uint16_t | kFmmuRegisterBytes = 16 |
| Width of one entity (Table 56). | |
| constexpr auto | kFoeErrorCodes |
| Catalogue of FoE error codes defined in ETG.1000.6 §5.8.5, Table 93. | |
| constexpr auto | kMailboxErrorCodes |
| Catalogue of CoE mailbox error codes. | |
| constexpr auto | kObjectDataTypes |
| Catalogue of ETG.1020 object dictionary data types. | |
| constexpr auto | kSdoAbortCodes |
| Catalogue of CoE SDO abort codes. | |
| thread_local bool | sdoLogQuiet = false |
When true on the calling thread, a driver demotes its per-transfer SDO debug logs to trace. Set it via ScopedQuietSdoLog around background polling so a periodic poller does not flood the log, while direct (user-initiated) reads keep their debug trace. | |
| constexpr uint32_t | kSynapticonVendorId = 0x000022D2 |
| Synapticon's EtherCAT Vendor ID (SII and object 0x1018:01). | |
| constexpr uint32_t | kSensodriveVendorId = 0x0000063A |
| Sensodrive's EtherCAT Vendor ID (SII and object 0x1018:01). | |
|
strong |
EtherCAT Application Layer state values.
Numeric values match the EtherCAT standard AL control/status register encoding (ETG.1000.6 §6.4.1).
|
strong |
Specific File-over-EtherCAT failure kind. Transport-agnostic: the SOEM driver decodes it from the error code of the slave's FoE Error packet, or from a negated ec_err_type when the slave sent none. The SPoE driver decodes it from its own protocol codes.
|
strong |
CoE object dictionary data type codes.
Maps the 16-bit DataType field returned by ecx_readOE to its symbolic name. Base numbering follows SOEM (ec_type.h) / CiA 301 — what the wire actually reports — extended with the record/array/DEFTYPE codes from ETG.1020 v1.6.0 (§26 Base Data Types, Tables 119-121) plus ETG.5001 / ETG.5120 cross-references. Where SOEM and ETG.1020 disagree (notably 0x000B, see below) SOEM's numbering wins.
|
strong |
Whether a slave answers at the station address the master gave it.
A reset sets the Configured Station Address register (0x0010) back to 0, and only the master can write it again. From then on every configured-address read and write misses the slave, so its AL state is unknown although it is still on the wire.
The wire position is checked by position only. When devices were added to or removed from the chain, the device at that position can be a different one, and a device near the end can find nothing at its position. Both outcomes need a scan.
|
strong |
Retry disposition of a failed operation: whether re-issuing the identical call could plausibly succeed. This is the one axis callers branch on uniformly — a firmware flasher retries Transient failures and aborts on Permanent ones — so it rides alongside the FoE-specific kind rather than being folded into it.
| Enumerator | |
|---|---|
| Transient | A fresh attempt may succeed (protocol desync, slave not yet ready after BOOT). |
| Permanent | The identical call will fail the same way (no such file, undersized buffer). |
|
strong |
Recognised SII category type identifiers (ETG.2010 Table 5).
ETG.2010 is the authoritative SII spec; its Table 5 supersedes ETG.1000.6 Table 19. The base IDs up to Dc (60) are common to both; the extended IDs (FmmuX, SyncUnit, Timeouts, Dictionary, Hardware, VendorInformation, Images, ApplicationSpecific) and the wider vendor/application ranges (see resolveSiiCategoryType) are ETG.2010's. Several spec ranges collapse to a single representative (e.g. all vendor-specific values map to VendorSpecific); the category-type word is a full Unsigned16 (no vendor-specific flag bit).
| Enumerator | |
|---|---|
| Nop | |
| DeviceSpecific | |
| Strings | |
| DataTypes | |
| General | |
| Fmmu | |
| SyncM | |
| FmmuX | |
| SyncUnit | |
| TxPdo | |
| RxPdo | |
| Dc | |
| Timeouts | |
| Dictionary | |
| Hardware | |
| VendorInformation | |
| Images | |
| VendorSpecific | |
| ApplicationSpecific | |
| End | |
|
inline |
Returns whether the AL Status error indicator (bit 4 of register 0x0130) is set.
|
inline |
Extracts the AL state (bits 3:0) from a raw AL Status register value (0x0130).
The single place the AL Status register layout is decoded: the low nibble is the current state, bit 4 is the error indicator (see alHasError). Callers compare the result against EtherCatState rather than re-masking the raw register.
|
constexpr |
Returns the short name for code, or an empty view if code is not a known AL Status Code.
An empty result is the signal that a slave reported a code outside the catalogue — vendor-specific, or a stale/garbage read — which a caller should flag rather than present as a decoded error.
| std::optional< FmmuConfig > mm::comm::decodeFmmu | ( | uint8_t | index, |
| std::span< const uint8_t > | bytes | ||
| ) |
Decodes an FMMU register block — the inverse of encodeFmmu.
Every field survives the round trip, because the register carries all of them.
| index | FMMU number, which the block itself does not carry. |
| bytes | The register block; at least kFmmuRegisterBytes. |
nullopt when bytes is short. | std::optional< SyncManagerConfig > mm::comm::decodeSyncManager | ( | uint8_t | index, |
| std::span< const uint8_t > | bytes | ||
| ) |
Decodes a Sync Manager register block — the inverse of encodeSyncManager.
type is not recoverable and comes back zero. What a Sync Manager carries — a mailbox or process data, and in which direction — is not in the register. It is the master's own classification, read from the slave's SII, so a caller that needs it must supply it.
| index | Sync Manager number, which the block itself does not carry. |
| bytes | The register block; at least kSyncManagerRegisterBytes. |
nullopt when bytes is short. | std::array< uint8_t, kFmmuRegisterBytes > mm::comm::encodeFmmu | ( | const FmmuConfig & | config | ) |
Encodes an FMMU as the sixteen bytes an FPWR to its register block carries.
| std::array< uint8_t, kSyncManagerRegisterBytes > mm::comm::encodeSyncManager | ( | const SyncManagerConfig & | config | ) |
Encodes a Sync Manager as the eight bytes an FPWR to its register block carries.
The two bytes the master may not set — status at offset 5 and PDI control at offset 7 — are written as zero. SyncManagerConfig::flags is the 32-bit read of offsets 4 to 7, so its low byte is the control byte and its third the activate byte.
| std::vector< NetworkAdapter > mm::comm::enumerateNetworkAdapters | ( | ) |
Enumerates all network adapters visible to the OS.
Scans every network adapter and returns a fully populated NetworkAdapter per NIC, so callers can select a specific one by its hardware address rather than by its OS-assigned name, which can change across reboots or driver updates. All three representations are populated at enumeration time.
Platform behaviour
ec_find_adapters() and queries each interface with SIOCGIFHWADDR via a temporary SOCK_DGRAM socket. Adapters for which the ioctl call fails are silently skipped.AF_LINK) addresses from getifaddrs().GetAdaptersAddresses() (IPHLPAPI) to enumerate adapters. Interface names are formatted as WinPcap/Npcap NPF paths: "\\Device\\NPF_<AdapterName>".MAC address format — macLinux is uppercase colon-separated hex octets, e.g. "AA:BB:CC:DD:EE:FF"; macWindows is the dash-separated equivalent. Both are consistent across platforms.
Returns an empty vector if adapter enumeration fails (e.g. insufficient privileges or no adapters present).
|
inline |
Returns whether a slave with this AL status exchanges process data: SAFE-OP or OP, with the error flag clear.
Below SAFE-OP a slave writes nothing into the frame, so its input region holds bytes it never sent. The control plane uses this rule to choose between the process image and an SDO upload, and the RT decode uses it to leave such a slave's cells alone. The two must agree, so the rule has one definition.
| alStatus | AL status of the slave: the state in the low four bits, and the error flag. |
|
constexpr |
Looks up code in kAlStatusCodes, or returns nullptr if it is not catalogued.
|
constexpr |
Returns the name of code, or an empty view if code is not a known FoE error code (vendor-specific, or a slave that put something else in the field).
|
inline |
Short human-readable reason for a FoE kind (no surrounding punctuation).
|
inline |
Retry disposition implied by a FoE kind. A missing file or an undersized buffer is a fixed condition that will recur identically; a desync or a not-yet-ready slave (the BOOT bootloader warm-up path) is worth another attempt.
|
constexpr |
Returns true if code indicates a state-transition failure that cannot be resolved by retrying the same writestate.
A terminal code means the polling loop in FieldbusDriver::transitionToState should abandon the slave immediately rather than waiting for the timeout — the master must change something (re-init, reflash, power cycle) before another transition attempt can succeed. Unknown codes are treated as non-terminal.
| bool mm::comm::isMacAddress | ( | const std::string & | s | ) |
Returns true if s is a MAC address in either Linux (:) or Windows (-) separator format.
Accepts exactly 17 characters: six pairs of hex digits separated by consistent colon or dash delimiters, e.g. "AA:BB:CC:DD:EE:FF" or "aa-bb-cc-dd-ee-ff". Mixed separators are rejected.
| s | String to test. |
true when s matches the pattern; false otherwise.
|
constexpr |
Whether a device with this vendor ID is a SOMANET device.
A SOMANET device runs SOMANET firmware. The vendor ID is the evidence for that, and it comes from the SII, so it is known as soon as the device is. Sensodrive devices run SOMANET firmware unmodified under their own vendor ID.
|
constexpr |
Returns the description of code, or an empty view if code is not a known mailbox error code (vendor-specific, or a stale/garbage read).
|
inline |
Builds a fully-formed FoeError from a decoded kind plus call context. Keeps the message wording identical to the pre-promotion string ("<op> slave N '<file>' failed
(<reason>)") so nothing downstream that logs or displays it changes shape.
| FoeError mm::comm::makeFoeRefusal | ( | uint32_t | code, |
| std::string_view | text, | ||
| std::string_view | op, | ||
| uint16_t | slave, | ||
| std::string_view | filename | ||
| ) |
Builds the FoeError for a transfer the slave refused with an FoE Error packet, naming the code as an SDO failure names its abort code: "(FoE error 0x8001: Not found)".
Only 0x8001 Not found has a kind of its own, because a caller branches on it: removing a file that is not there is a success. The slave's text often repeats the code's name, so it is added only when it says more.
| code | ETG.1000.6 error code from the Error packet. |
| text | The packet's error text, empty when it carried none. |
| std::string mm::comm::normalizeMac | ( | const std::string & | raw, |
| char | sep | ||
| ) |
Normalises a MAC address string to uppercase with the given separator.
Extracts the six hex-octet pairs from raw (which must pass isMacAddress()) and rebuilds the string in uppercase with sep as the field delimiter.
| raw | Source MAC string (colon- or dash-separated, any case). |
| sep | Output separator character, typically ':' or '-'. |
"XX<sep>XX<sep>…<sep>XX". isMacAddress(raw) == true
|
constexpr |
Returns the declared bit width of code, or 0 if unknown / variable-length.
|
constexpr |
Returns the symbolic name of code, or "UNKNOWN" if it is not in the table.
|
inline |
Streams the message, so ASSERT_TRUE(r) << r.error() and spdlog {} work unchanged.
| std::optional< std::array< uint8_t, 6 > > mm::comm::parseMac | ( | const std::string & | s | ) |
Decodes a MAC address string into its six bytes, in wire order.
The string form is what an adapter carries and what a human types; a protocol that puts a MAC on the wire — an ENI Source, an EoE frame — needs the bytes. isMacAddress decides what is acceptable, so both separators and either case are.
| s | Source MAC string. |
std::nullopt when s is not a MAC address. | std::expected< SlaveInformationInterface, std::string > mm::comm::parseSii | ( | std::span< const uint8_t > | buffer | ) |
Parses a raw SII EEPROM image into a SlaveInformationInterface.
Decodes the fixed 128-byte header, then walks the category section starting at offset 128 (each category is a 16-bit type, a 16-bit word-size, then wordSize × 2 payload bytes), dispatching recognised categories to their decoders and stopping at the End (0xFFFF) or Nop marker. Unrecognised categories are skipped; multiple PDO categories accumulate. The walk is bounds-checked: a category claiming more bytes than remain is clamped, never read past the end.
| buffer | Raw SII bytes (at least 128 for a valid header). |
buffer is shorter than the fixed header. | std::expected< NetworkAdapter, std::string > mm::comm::resolveNetworkAdapter | ( | const std::string & | input | ) |
Resolves a network adapter specifier to a fully populated NetworkAdapter.
input may be any of the three accepted forms:
"AA:BB:CC:DD:EE:FF" "AA-BB-CC-DD-EE-FF" "eth0", "\\Device\\NPF_{GUID}" Calls enumerateNetworkAdapters() once to resolve the form that was not supplied.
| input | User-supplied adapter specifier string. |
NetworkAdapter, or an error string if the adapter cannot be found in the OS adapter map. | std::optional< SiiCategoryType > mm::comm::resolveSiiCategoryType | ( | uint16_t | value | ) |
Normalises a raw 16-bit category-type word into a SiiCategoryType.
Range-based values are folded to a single representative (DeviceSpecific for 0x0001–0x0009, VendorSpecific for 0x0800–0x1FFF and 0x3000–0xFFFE, ApplicationSpecific for 0x2000–0x2FFF); the original numeric value is not preserved. Fixed IDs (Strings, General, …) and the End marker resolve directly. Returns std::nullopt for unrecognised values, which the caller skips.
|
constexpr |
Returns the description of code, or an empty view if code is not a known SDO abort code (vendor-specific, or a stale/garbage read).
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const AlStatusCode & | c | ||
| ) |
Serialises an AlStatusCode to JSON.
Produces an object with keys code, name, description, terminal. Participates in nlohmann ADL so that nlohmann::json(kAlStatusCodes) works automatically.
| j | Output JSON value. |
| c | AL Status Code entry to serialise. |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const EscRegister & | r | ||
| ) |
Serialises an EscRegister to JSON.
Produces an object with keys address, length, name, description. Participates in nlohmann ADL so that nlohmann::json(kEscRegisters) works automatically.
| j | Output JSON value. |
| r | Register entry to serialise. |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const FoeErrorCode & | e | ||
| ) |
Serialises a FoeErrorCode to JSON.
Produces an object with keys code, name, description. Participates in nlohmann ADL so that nlohmann::json(kFoeErrorCodes) works automatically.
| j | Output JSON value. |
| e | FoE error code entry to serialise. |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const MailboxErrorCode & | e | ||
| ) |
Serialises a MailboxErrorCode to JSON.
Produces an object with keys code, name, description. Participates in nlohmann ADL so that nlohmann::json(kMailboxErrorCodes) works automatically.
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const NetworkAdapter & | a | ||
| ) |
Serialises a NetworkAdapter to JSON.
Produces an object with keys macLinux, macWindows, name, description. Participates in nlohmann ADL so that nlohmann::json(adapters) serialises a std::vector<NetworkAdapter> automatically.
| j | Output JSON value. |
| a | Adapter to serialise. |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const ObjectDataTypeInfo & | info | ||
| ) |
Serialises an ObjectDataTypeInfo to JSON.
Produces an object with keys code, name, bitSize. Participates in nlohmann ADL so that nlohmann::json(kObjectDataTypes) works automatically.
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const SdoAbortCode & | e | ||
| ) |
Serialises an SdoAbortCode to JSON.
Produces an object with keys code and description. Participates in nlohmann ADL so that nlohmann::json(kSdoAbortCodes) works automatically.
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const SiiCategoryDistributedClockElement & | v | ||
| ) |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const SiiCategoryGeneral & | v | ||
| ) |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const SiiCategoryPdoElement & | v | ||
| ) |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const SiiCategoryPdoEntryElement & | v | ||
| ) |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const SiiCategorySection & | v | ||
| ) |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const SiiCategorySyncManagerElement & | v | ||
| ) |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const SiiInfo & | v | ||
| ) |
| void mm::comm::to_json | ( | nlohmann::json & | j, |
| const SlaveInformationInterface & | v | ||
| ) |
|
inline |
Human-readable name of an AL state, for log and error messages.
|
inline |
API name of a reachability, as the HTTP API and the client spell it.
| std::expected< void, std::string > mm::comm::validateSiiImage | ( | std::span< const uint8_t > | buffer | ) |
Checks that a raw SII image is structurally sound enough to be written to an EEPROM.
This is the guard in front of FieldbusDriver::writeSii, and it exists because that write is the most destructive operation in the stack: a malformed image leaves the slave unidentifiable until it is re-flashed, and the ESC only reloads the EEPROM on a power cycle, so the damage is discovered after the point where it could still be undone. Validation is therefore not a nicety — it is the difference between rejecting a bad file and bricking a drive.
Deliberately structural rather than semantic: it does not judge whether the vendor ID or the PDO defaults are right for the device, only that the bytes are a well-formed SII image.
Four checks, in the order a corrupt file usually fails them:
| buffer | Raw SII image. |
|
inline |
Working-counter contribution of one slave for a given AL status and PDO presence.
A slave increments the working counter of an LRW by 2 when it takes the outputs and by 1 when it delivers the inputs (ETG.1000.4, section 5.4.3.5). SAFE-OP and OP contribute the same. The PRE-OP to SAFE-OP transition enables the output Sync Manager as well as the input one, and leaving OP only sets the outputs to their safe values (ETG.1000.6, Tables 99 and 103). The slave must also receive outputs in SAFE-OP, or it refuses the step to OP with AL status code 0x0019. Below SAFE-OP a slave does not contribute.
A slave with the error flag set contributes 0. One that enters SAFE-OP with the flag set disables Sync Manager 2 and may still deliver its inputs, so 0 is lower than what it answers. The expected value is a lower limit, so that is safe, and the error itself is reported in the AL status.
Summed across the bus, this is the working counter a partially operational bus is expected to produce, and a health check compares the live working counter against it. The protocol rule lives here, with the other AL vocabulary, and not in the node layer, which knows no transport.
| alStatus | AL status of the slave: the state in the low four bits, and the error flag. |
| hasOutputs | Whether the slave has any mapped output (RxPDO) bits. |
| hasInputs | Whether the slave has any mapped input (TxPDO) bits. |
|
inlineconstexpr |
Catalogue of AL Status Codes.
The first block is a faithful transcription of ETG.1000.6 V1.0.4 Table 11 (the latest released revision). The second block adds codes that are not in that table but are reported by real slaves and carried by SOEM's own ec_ALstatuscodelist — most relevantly the firmware/EEPROM/FMMU failures raised during BOOT/FoE flashing and re-mapping. They earn their place here because isAlStatusCodeTerminal must classify them so FieldbusDriver::transitionToState fails fast instead of spinning to timeout.
|
inlineconstexpr |
Catalogue of well-known ESC registers.
Addresses and sizes follow the Beckhoff EtherCAT ESC datasheet (Section II) and ETG.1000.4. FMMU and SyncManager entries list the full block for the first instance; subsequent instances follow at fixed strides (FMMU: 16 bytes, SM: 8 bytes).
|
constexpr |
FMMU entity 0 (Table 57).
|
constexpr |
Width of one entity (Table 56).
|
inlineconstexpr |
Catalogue of FoE error codes defined in ETG.1000.6 §5.8.5, Table 93.
Codes in the 0x8000 range are the standard EtherCAT FoE error codes. The 0x00000000 entry is a catch-all for unspecified or vendor-specific errors, which otherwise fall outside this range.
|
inlineconstexpr |
How long a file read waits for the slave's answer, unless the caller asks for longer.
A SOMANET bootloader can take seconds to answer a read, and it sends nothing until it answers. A read given up too early fails on every attempt, because each attempt starts the read again. 6 s is the timeout known to work on such drives in the field: Motion Master v5 waits the same 6 s, and it reads files from SOMANET bootloaders reliably. The wait is spent only when the slave does not answer.
|
inlineconstexpr |
Catalogue of CoE mailbox error codes.
A faithful transcription of ETG.1000.4 Table 30 ("Error Reply Service Data"). A slave returns one of these in a mailbox error reply when the mailbox layer (below any specific protocol like CoE/FoE) rejects a transfer. SOEM carries the same set in its ec_mbxerrorlist but stops at 0x0008 — this table also lists the spec's 0x0009. The FieldbusDriver surfaces mailbox errors as text embedding the raw 0x... code, so this table lets a caller decode it to a reason.
|
inlineconstexpr |
Maximum size in bytes of the combined process-data image (all outputs + all inputs).
The whole bus is exchanged as one IOmap laid out as [all outputs | all inputs]; on SOEM that is a single buffer of this size, so it is the combined image (outputs + inputs) that both buildProcessImage and configureProcessData() bound against this cap. Each per-direction RT ProcessBuffer scratch is also this size — one direction alone may use the whole budget when the other is empty. A SOMANET drive maps ~100 bytes across both directions, so 50 drives total ~5 KB — under 15% of this cap. This is not a practical limit: on 100 Mbit EtherCAT an image approaching 32 KB already forces a many-millisecond cycle, so the cap sits well clear of any realistic configuration.
|
inlineconstexpr |
Catalogue of ETG.1020 object dictionary data types.
|
inlineconstexpr |
Catalogue of CoE SDO abort codes.
A faithful transcription of ETG.1000.6 §5.6.2.7.2, Table 41 (which reproduces the CANopen CiA 301 SDO abort transfer codes). A slave returns one of these in the Abort SDO Transfer request when a mailbox SDO read/write fails. SOEM carries the identical set in its ec_sdoerrorlist; the FieldbusDriver surfaces SDO failures only as text, embedding the raw 0x... code, so this table lets a caller decode that code to a reason.
|
inlineconstexpr |
Sensodrive's EtherCAT Vendor ID (SII and object 0x1018:01).
Sensodrive devices run SOMANET firmware, so isSomanetDevice is true for them.
|
inlineconstexpr |
Synapticon's EtherCAT Vendor ID (SII and object 0x1018:01).
In mm::comm because the fieldbus driver must know the vendor, and comm cannot depend on node. mm::node::kSynapticonVendorId names this same constant.
|
constexpr |
Register block addresses and widths for the two configurations above (ETG.1000.4 §6).
A master programs a Sync Manager or an FMMU by writing its whole block to the slave's ESC, and an ENI init command carries exactly those bytes. The constants sit here so the encode, the decode and any caller working out a stride all read them from one place. Sync Manager channel 0 (Table 59).
|
constexpr |
Width of one channel (Table 58).
|
inline |
When true on the calling thread, a driver demotes its per-transfer SDO debug logs to trace. Set it via ScopedQuietSdoLog around background polling so a periodic poller does not flood the log, while direct (user-initiated) reads keep their debug trace.
Thread-local (the comment, not the name, carries that): the flag is read on the same thread that issues the transfer — SDO reads run synchronously on the caller's thread — so a scope set by the caller reliably covers the driver's logging. Inline so the one instance is shared across translation units.