ethercat_soem/
al_status.rs

1use num_derive::FromPrimitive;
2use num_traits::cast::FromPrimitive as _;
3
4// TODO: auto generate from `ethercatprint.c`
5
6/// AL status code
7#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive)]
8#[repr(u16)]
9pub enum AlStatus {
10    /// No error
11    NoError = 0x0000,
12
13    /// Unspecified error
14    UnspecifiedError = 0x0001,
15
16    /// No memory,
17    NoMemory = 0x0002,
18
19    /// Invalid requested state change" },
20    InvalidRequestedStateChange = 0x0011,
21
22    /// Unknown requested state,
23    UnknownRequestedState = 0x0012,
24
25    /// Bootstrap not supported
26    BootstrapNotSupported = 0x0013,
27
28    /// No Valid Firmware
29    NoValidFirmware = 0x0014,
30
31    /// Invalid mailbox configuration
32    ///
33    /// First value as defined in `ethercatprint.c`.
34    InvalidMailboxConfig = 0x0015,
35
36    /// Invalid mailbox configuration
37    ///
38    /// Second value as defined in `ethercatprint.c`.
39    InvalidMailboxConfig2 = 0x0016,
40
41    /// Invalid sync manager configuration
42    InvalidSyncManagerConfiguration = 0x0017,
43
44    /// No valid inputs available
45    NoValidInputsAvailable = 0x0018,
46
47    /// No valid outputs
48    NoValidOutputs = 0x0019,
49
50    /// Synchronization error
51    SynchronizationError = 0x001A,
52
53    /// Sync manager watchdog
54    SyncManagerWatchdog = 0x001B,
55
56    /// Invalid sync Manager types,
57    InvalidSyncManagerTypes = 0x001C,
58
59    /// Invalid output configuration
60    InvalidOutputConfiguration = 0x001D,
61
62    /// Invalid input configuration
63    InvalidInputConfiguration = 0x001E,
64
65    /// Invalid watchdog configuration
66    InvalidWatchdogConfiguration = 0x001F,
67
68    /// Slave needs cold start
69    SlaveNeedsColdStart = 0x0020,
70
71    /// Slave needs INIT
72    SlaveNeedsInit = 0x0021,
73
74    /// Slave needs PREOP
75    SlaveNeedsPreOp = 0x0022,
76
77    /// Slave needs SAFEOP
78    SlaveNeedsSafeOp = 0x0023,
79
80    /// Invalid input mapping
81    InvalidInputMapping = 0x0024,
82
83    /// Invalid output mapping
84    InvalidOutputMapping = 0x0025,
85
86    /// Inconsistent settings
87    InconsistentSettings = 0x0026,
88
89    /// Freerun not supported
90    FreerunNotSupported = 0x0027,
91
92    /// Synchronisation not supported
93    SynchronisationNotSupported = 0x0028,
94
95    /// Freerun needs 3buffer mode
96    FreerunNeeds3BufferMode = 0x0029,
97
98    /// Background watchdog
99    BackgroundWatchdog = 0x002A,
100
101    /// No valid Inputs and Outputs
102    NovalidInputsAndOutputs = 0x002B,
103
104    /// Fatal sync error
105    FatalSyncError = 0x002C,
106
107    /// No sync error
108    NoSyncError = 0x002D,
109
110    /// Invalid input FMMU configuration
111    InvalidInputFmmuConfiguration = 0x002E,
112
113    /// Invalid DC SYNC configuration
114    InvalidDcSyncConfiguration = 0x0030,
115
116    /// Invalid DC latch configuration
117    InvalidDcLatchConfiguration = 0x0031,
118
119    /// PLL error
120    PllError = 0x0032,
121
122    /// DC sync IO error
123    DcSyncIoError = 0x0033,
124
125    /// DC sync timeout error
126    DcSyncTimeoutError = 0x0034,
127
128    /// DC invalid sync cycle time
129    DcInvalidSyncCycleTime = 0x0035,
130
131    /// DC invalid sync0 cycle time
132    DcInvalidSync0CycleTime = 0x0036,
133
134    /// DC invalid sync1 cycle time
135    DcInvalidSync1CycleTime = 0x0037,
136
137    /// MBX_AOE
138    MbxAoe = 0x0041,
139
140    /// MBX_EOE
141    MbxEoe = 0x0042,
142
143    /// MBX_COE
144    MbxCoe = 0x0043,
145
146    /// MBX_FOE
147    MbxFoe = 0x0044,
148
149    /// MBX_SOE
150    MbxSoe = 0x0045,
151
152    /// MBX_VOE
153    MbcVoe = 0x004F,
154
155    /// EEPROM no access
156    EepromNoAccess = 0x0050,
157
158    /// EEPROM error
159    EeepromError = 0x0051,
160
161    /// Slave restarted locally
162    SlaveRestartedLocally = 0x0060,
163
164    /// Device identification value updated
165    DeviceIdValueUpdated = 0x0061,
166
167    /// Application controller available
168    ApplicationControllerAvailable = 0x00f0,
169
170    /// Unknown
171    Unknown = 0xffff,
172}
173
174impl From<u16> for AlStatus {
175    fn from(code: u16) -> Self {
176        AlStatus::from_u16(code).unwrap_or(AlStatus::Unknown)
177    }
178}