Motion Master 6.0.0-alpha.50
Next-generation motion control software
Loading...
Searching...
No Matches
al_status_codes.h
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <array>
5#include <cstdint>
6#include <nlohmann/json_fwd.hpp>
7#include <string_view>
8
9namespace mm::comm {
10
13 uint16_t code = 0;
14 std::string_view name;
15 std::string_view description;
16 bool terminal = false;
21};
22
30void to_json(nlohmann::json& j, const AlStatusCode& c);
31
40inline constexpr auto kAlStatusCodes = std::to_array<AlStatusCode>({
41 {0x0000, "No error", "No error"},
42 {0x0001, "Unspecified error", "Unspecified error"},
43 {0x0002, "No Memory", "Slave has insufficient memory to complete the requested operation",
44 true},
45 {0x0003, "Invalid Device Setup", "The device setup is invalid", true},
46 {0x0005, "Reserved", "Reserved due to compatibility reasons"},
47 {0x0011, "Invalid requested state change", "The requested state transition is not allowed",
48 true},
49 {0x0012, "Unknown requested state", "The requested state is not a valid EtherCAT AL state",
50 true},
51 {0x0013, "Bootstrap not supported", "The slave does not support the Bootstrap state", true},
52 {0x0014, "No valid firmware", "No valid firmware is present — the slave needs firmware flashed",
53 true},
54 {0x0015, "Invalid mailbox config (BOOT)", "Mailbox configuration is invalid for BOOT state",
55 true},
56 {0x0016, "Invalid mailbox config (PRE-OP)", "Mailbox configuration is invalid for PRE-OP state",
57 true},
58 {0x0017, "Invalid sync manager config", "Sync manager configuration is invalid", true},
59 {0x0018, "No valid inputs", "No valid input data is available"},
60 {0x0019, "No valid outputs", "No valid output data is available"},
61 {0x001A, "Synchronization error", "A synchronization error has occurred"},
62 {0x001B, "Sync manager watchdog", "The sync manager watchdog has expired"},
63 {0x001C, "Invalid SM types", "Invalid sync manager types", true},
64 {0x001D, "Invalid output config", "Invalid output configuration", true},
65 {0x001E, "Invalid input config", "Invalid input configuration", true},
66 {0x001F, "Invalid watchdog config", "Invalid watchdog configuration", true},
67 {0x0020, "Needs cold start", "The slave requires a cold start (power cycle)", true},
68 {0x0021, "Needs INIT", "The slave must be in INIT state before this transition", true},
69 {0x0022, "Needs PRE-OP", "The slave must be in PRE-OP state before this transition", true},
70 {0x0023, "Needs SAFE-OP", "The slave must be in SAFE-OP state before this transition", true},
71 {0x0024, "Invalid input mapping", "The FMMU input mapping is invalid", true},
72 {0x0025, "Invalid output mapping", "The FMMU output mapping is invalid", true},
73 {0x0026, "Inconsistent settings", "Application and mailbox settings are inconsistent", true},
74 {0x0027, "FreeRun not supported", "FreeRun mode is not supported by this slave", true},
75 {0x0028, "SyncMode not supported", "Synchronous mode is not supported by this slave", true},
76 {0x0029, "FreeRun needs 3buffer mode", "FreeRun mode requires 3-buffer SyncManager mode", true},
77 {0x002A, "Background watchdog", "Background watchdog has expired"},
78 {0x002B, "No valid I/O data", "No valid input and output data are available"},
79 {0x002C, "Fatal sync error", "A fatal synchronization error has occurred"},
80 {0x002D, "No Sync Error", "No synchronization error"},
81 {0x0030, "Invalid DC SYNC config", "Invalid Distributed Clocks SYNC configuration", true},
82 {0x0031, "Invalid DC latch config", "Invalid Distributed Clocks latch configuration", true},
83 {0x0032, "PLL error", "Distributed Clocks PLL error"},
84 {0x0033, "DC sync IO error", "Distributed Clocks sync IO error"},
85 {0x0034, "DC sync timeout", "Distributed Clocks sync timeout error"},
86 {0x0035, "Invalid DC sync cycle time", "Invalid Distributed Clocks sync cycle time", true},
87 {0x0036, "DC sync0 cycle time", "Invalid SYNC0 cycle time", true},
88 {0x0037, "DC sync1 cycle time", "Invalid SYNC1 cycle time", true},
89 {0x0041, "MBX_AoE error", "ADS over EtherCAT mailbox error"},
90 {0x0042, "MBX_EoE error", "Ethernet over EtherCAT mailbox error"},
91 {0x0043, "MBX_CoE error", "CANopen over EtherCAT mailbox error"},
92 {0x0044, "MBX_FoE error", "File access over EtherCAT mailbox error"},
93 {0x0045, "MBX_SoE error", "Servo Drive Profile over EtherCAT mailbox error"},
94 {0x004F, "MBX_VoE error", "Vendor specific over EtherCAT mailbox error"},
95 {0x0050, "EEPROM no access", "The EEPROM cannot be accessed", true},
96 {0x0051, "EEPROM Error", "An EEPROM error has occurred", true},
97 {0x0060, "Slave restarted locally", "The slave has restarted locally"},
98 {0x0061, "Device Identification value updated", "Device identification value has been updated"},
99 {0x00F0, "Application controller available", "An application controller is available"},
100
101 // --- Beyond ETG.1000.6 V1.0.4 Table 11: vendor/de-facto codes (mirrors SOEM's table) ---
102 // Observed from real slaves; not part of the released spec. Kept here so terminal
103 // classification and name decoding cover the firmware/config failures that actually occur.
104 {0x0004, "Invalid revision", "The slave revision does not match the one expected by the master",
105 true},
106 {0x0006, "SII/EEPROM mismatch", "SII/EEPROM information does not match the firmware", true},
107 {0x0007, "Firmware update failed",
108 "Firmware update was not successful — the old firmware is still running", true},
109 {0x000E, "License error", "The slave firmware license is invalid or missing", true},
110 {0x002E, "Invalid input FMMU config", "The FMMU input configuration is invalid", true},
111 {0x0052, "External hardware not ready", "External hardware is not ready"},
112 {0x0070, "Module ident mismatch",
113 "The detected module ident list does not match the configured one", true},
114 {0x0080, "Supply voltage too low", "The slave supply voltage is too low"},
115 {0x0081, "Supply voltage too high", "The slave supply voltage is too high"},
116 {0x0082, "Temperature too low", "The slave temperature is too low"},
117 {0x0083, "Temperature too high", "The slave temperature is too high"},
118});
119
121constexpr const AlStatusCode* findAlStatusCode(uint16_t code) {
122 const auto it = std::find_if(kAlStatusCodes.begin(), kAlStatusCodes.end(),
123 [code](const AlStatusCode& entry) { return entry.code == code; });
124 return it != kAlStatusCodes.end() ? &*it : nullptr;
125}
126
134constexpr bool isAlStatusCodeTerminal(uint16_t code) {
135 const AlStatusCode* entry = findAlStatusCode(code);
136 return entry != nullptr && entry->terminal;
137}
138
145constexpr std::string_view alStatusCodeName(uint16_t code) {
146 const AlStatusCode* entry = findAlStatusCode(code);
147 return entry != nullptr ? entry->name : std::string_view{};
148}
149
150} // namespace mm::comm
Definition al_status_codes.cc:5
void to_json(nlohmann::json &j, const AlStatusCode &c)
Serialises an AlStatusCode to JSON.
Definition al_status_codes.cc:7
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.
Definition al_status_codes.h:145
constexpr const AlStatusCode * findAlStatusCode(uint16_t code)
Looks up code in kAlStatusCodes, or returns nullptr if it is not catalogued.
Definition al_status_codes.h:121
constexpr auto kAlStatusCodes
Catalogue of AL Status Codes.
Definition al_status_codes.h:40
constexpr bool isAlStatusCodeTerminal(uint16_t code)
Returns true if code indicates a state-transition failure that cannot be resolved by retrying the sam...
Definition al_status_codes.h:134
Metadata for a single AL Status Code entry.
Definition al_status_codes.h:12
bool terminal
Definition al_status_codes.h:16
std::string_view name
Short human-readable name.
Definition al_status_codes.h:14
std::string_view description
Full description of the error condition.
Definition al_status_codes.h:15
uint16_t code
AL Status Code value (ETG.1000.6 Table 11).
Definition al_status_codes.h:13