EoE (Ethernet over EtherCAT)
EoE tunnels Ethernet frames through the EtherCAT mailbox. It can send and receive frames, run ICMP Ping and filter by MAC address, and it conforms to ETG.1000.6 and ETG.1020. It is a frame channel inside the mailbox, not an operating-system network adapter: it provides no DHCP, NAT or automatic fragmentation by MTU, and a single frame is limited to 2016 bytes.
Accessed through slave.eoe(). The sub-object is created lazily and always returns an instance (never null); check whether the slave supports EoE with slave.eoe().isSupported(), and treat an unknown capability as unsupported.
Honest boundaries
EoE in this SDK is an Ethernet frame tunnel over the EtherCAT mailbox; it is not an operating-system network adapter.
- No TAP / tun: it creates no Windows TAP or Linux tun/tap device
- No DHCP server / NAT: it assigns no addresses and performs no routing or NAT
- No automatic fragmentation at MTU 1500: frames are split into 32-byte blocks according to the slave mailbox capacity (ETG.1000.6 §5.7); the whole-frame limit is the ETG.1000.6 §5.7 Frame Offset (6 bit × 32 B) = 2016 bytes. Frames larger than 2016 bytes are rejected outright
- Receive buffer:
receiveFramereturns the frame at its actual received length; the maximum is likewise bounded by 2016 bytes, not an arbitrary size
Method overview
| Category | Method | Type | Read/write | Description |
|---|---|---|---|---|
| Capability | isSupported() | boolean | read-only | Whether the slave supports EoE; treat an unknown capability as unsupported |
| Capability | supportState() | Boolean | read-only | Capability tri-state: TRUE=supported, FALSE=confirmed unsupported, null=unknown |
| Capability | isSupportKnown() | boolean | read-only | Whether the capability conclusion is known (supportState() is not null) |
| Network configuration | IP() / IP(String) | String | read/write | IP address (dotted decimal); a failed read returns null, a failed write throws |
| Network configuration | subnet() / subnet(String) | String | read/write | Subnet mask; a failed read returns null, a failed write throws |
| Network configuration | gateway() / gateway(String) | String | read/write | Default gateway; a failed read returns null, a failed write throws |
| Network configuration | MAC() / MAC(String) | String | read/write | MAC address (format "AA:BB:CC:DD:EE:FF"); a failed read returns null, a failed write throws |
| Network configuration | DNS() / DNS(String) | String | read/write | DNS server address; a failed read returns null, a failed write throws |
| Frame send/receive | sendFrame(byte[] frame, int timeoutMs) | boolean | write-only | Sends one Ethernet frame; rejected as soon as the single-frame limit is exceeded |
| Frame send/receive | sendFrameWithTimestamp(byte[] frame, long timestamp, int timeoutMs) | boolean | write-only | Sends a frame and appends a 4-byte timestamp at the end of the frame |
| Frame send/receive | receiveFrame(int timeoutMs) | byte[] | read-only | Receives one frame; returns null on timeout or an empty frame |
| Frame send/receive | sendFrameAsync / receiveFrameAsync | CompletableFuture | read/write | Asynchronous wrappers for the send/receive methods above; a failure completes with EoEProtocolException |
| Connectivity | ping(String targetIp, int timeoutMs, int ttl) | EoEPingResult | read-only | Sends an ICMP Echo to an IP device behind the slave and waits for the reply |
| Connectivity | pingAsync(String targetIp, int timeoutMs, int ttl) | CompletableFuture | read-only | Asynchronous Ping that does not block the calling thread |
| Address filtering | addAddressFilter(byte[] mac, int timeoutMs) | boolean | write-only | Appends one MAC address to the filter (must be 6 bytes, at most 16 entries) |
| Address filtering | removeAddressFilter(byte[] mac, int timeoutMs) | boolean | write-only | Removes one MAC address from the filter |
| Address filtering | getAddressFilters(int timeoutMs) | List<byte[]> | read-only | Reads the MAC address list from the current filter; an empty list is a valid state |
| Address filtering | clearAddressFilters(int timeoutMs) | boolean | write-only | Clears all address filters |
| Frame hook | setReceiveHook(ReceiveHookListener) / clearReceiveHook() | boolean | write-only | Registers a frame-arrival callback; pass null to cancel |
| Protocol identification | getProtocolType() / getProtocolName() | byte / String | read-only | Protocol type constant (EoE=0x02) and protocol name ("EoE") |
| Transaction status | getLastStatus() / getLastErrorCode() | MailboxStatus / long | read-only | Unified status and error code of the most recent mailbox transaction (0=no error) |
| Statistics | getStatistics() / resetStatistics() | MailboxStatistics / void | read-only / write-only | Mailbox statistics snapshot and counter reset |
Interface details
Constants
| Constant | Type | Value | Description |
|---|---|---|---|
DEFAULT_TIMEOUT_MS | int | 500 | Default timeout (milliseconds) used by every overload that omits timeoutMs |
ETG_EOE_MAX_COMPLETE_FRAME_BYTES | int | 2016 | Single-frame limit (ETG.1000.6 §5.7: Frame Offset 6 bit × 32 bytes) |
isSupported() / supportState() / isSupportKnown()
public boolean isSupported()
public Boolean supportState()
public boolean isSupportKnown()
EoE capability detection for the slave: only a confirmed capability is treated as supported; an unknown capability is not treated as supported (the SDK does not overstate the capability).
Returns:
isSupported()—boolean: returnstruewhen support is confirmed; both "confirmed unsupported" and "unknown" returnfalse, and the two cannot be distinguished as a booleansupportState()—Boolean:Boolean.TRUE= supported,Boolean.FALSE= confirmed unsupported,null= capability unknownisSupportKnown()—boolean: returnstruewhen the capability conclusion is known andfalsewhen it is unknown (unknown is not the same as unsupported)
Example:
EoE eoe = slave.eoe();
if (!eoe.isSupported()) {
System.out.println("从站不支持 EoE,或能力未知"); // Slave does not support EoE, or its capability is unknown
return;
}
IP() / IP(String ip)
public String IP()
public void IP(String ip)
Reads and writes the IP address (dotted decimal) of the slave virtual network port. The getter reads the current value in real time on every call; the setter validates the format and writes to the device straight away.
Parameters:
ip(String) — dotted-decimal IPv4 address, for example"192.168.1.100"
Returns:
String— the current IP address; a failed read returnsnull(a read is never faked with0.0.0.0)
Throws:
IllegalArgumentException— the address is empty, is not dotted decimal with 4 segments, or one segment is not a decimal numberEoEProtocolException— reading back the current configuration before the write fails (the write is aborted and nothing is sent out), or the write is not confirmed by the slave
IP, subnet mask and gateway are sent together in a single configuration write. When a single field is written, the other two keep their read-back values; if the read-back fails the write is aborted, which prevents the other two from being written as 0.0.0.0 and dropping the device off the network.
Example:
EoE eoe = slave.eoe();
System.out.println("当前 IP: " + eoe.IP()); // Current IP:
eoe.IP("10.0.0.100");
subnet() / subnet(String subnet)
public String subnet()
public void subnet(String subnet)
Reads and writes the subnet mask (dotted decimal). The write also uses the triple-field write: IP and gateway keep their read-back values.
Parameters:
subnet(String) — dotted-decimal subnet mask, for example"255.255.255.0"
Returns:
String— the current subnet mask; a failed read returnsnull
Throws:
IllegalArgumentException— the mask format is invalid (same criteria as IP)EoEProtocolException— the read-back fails (the write is aborted) or the write is not confirmed by the slave
gateway() / gateway(String gateway)
public String gateway()
public void gateway(String gateway)
Reads and writes the default gateway (dotted decimal). The write also uses the triple-field write: IP and subnet mask keep their read-back values.
Parameters:
gateway(String) — dotted-decimal gateway, for example"192.168.1.1"
Returns:
String— the current gateway; a failed read returnsnull
Throws:
IllegalArgumentException— the gateway format is invalid (same criteria as IP)EoEProtocolException— the read-back fails (the write is aborted) or the write is not confirmed by the slave
MAC() / MAC(String macString)
public String MAC()
public void MAC(String macString)
Reads and writes the MAC address.
Parameters:
macString(String) — formatAA:BB:CC:DD:EE:FF(both:and-are accepted as separators)
Returns:
String— the current MAC address (uppercase hexadecimal,:separated); a failed read returnsnull
Throws:
IllegalArgumentException— after the separators are removed it is not 12 hexadecimal charactersEoEProtocolException— the write is not confirmed by the slave
DNS() / DNS(String dns)
public String DNS()
public void DNS(String dns)
Reads and writes the DNS server address (IPv4).
Parameters:
dns(String) — dotted-decimal IPv4 address, for example"8.8.8.8"
Returns:
String— the current DNS address (dotted decimal); a failed read returnsnull
Throws:
IllegalArgumentException— the address format is invalid (same criteria as IP)EoEProtocolException— the write is not confirmed by the slave
Frame send and receive
sendFrame(byte[] frame, int timeoutMs)
public boolean sendFrame(byte[] frame, int timeoutMs)
public boolean sendFrame(byte[] frame)
Sends one Ethernet frame (including the Ethernet header). Fragmentation follows ETG.1000.6 §5.7: the whole frame may be larger than the slave mailbox, and it is rejected only when it exceeds the Frame Offset limit (2016 bytes). There is no TAP / DHCP / NAT and no automatic fragmentation at MTU 1500.
Parameters:
frame(byte[]) — frame data;nullor an empty array is treated as an invalid argument and does not count as a successful sendtimeoutMs(int) — timeout (milliseconds, default 500, that isDEFAULT_TIMEOUT_MS)
Returns:
boolean—trueon success; an empty frame, more than 2016 bytes, or an unfinished underlying transaction returnsfalse
Throws:
- An exception from the underlying call is propagated as a
RuntimeExceptionand never swallowed intofalse
Use getLastStatus() / getLastErrorCode() to tell the failure causes apart: an empty frame or an over-limit frame records INVALID_ARG, and a transaction that does not finish within the timeout records TIMEOUT.
sendFrameWithTimestamp(byte[] frame, long timestamp, int timeoutMs)
public boolean sendFrameWithTimestamp(byte[] frame, long timestamp, int timeoutMs)
public boolean sendFrameWithTimestamp(byte[] frame, long timestamp)
Sends an Ethernet frame with an appended timestamp (ETG.1000.6 Table 78): a 4-byte timestamp is appended at the end of the frame, taken from the low 32 bits of timestamp (Unsigned32).
Parameters:
frame(byte[]) — frame datatimestamp(long) — DC timestamp (nanoseconds)timeoutMs(int) — timeout (milliseconds, default 500)
Returns:
boolean—trueon success
Throws:
- Unlike
sendFrame, this method folds underlying exceptions intofalseand records a failure status instead of throwing. An empty frame or more than 2016 bytes likewise returnsfalse(recorded asINVALID_ARG)
receiveFrame(int timeoutMs)
public byte[] receiveFrame(int timeoutMs)
public byte[] receiveFrame()
Receives an Ethernet frame. The frame is returned at its actual received length, and the maximum is likewise bounded by 2016 bytes, not an arbitrary size.
Parameters:
timeoutMs(int) — timeout (milliseconds, default 500)
Returns:
byte[]— the received frame data;null= timeout / transaction failure, or an empty frame was received
Throws:
- An exception from the underlying call is propagated as a
RuntimeExceptionand never swallowed intonull
Use getLastStatus() to tell "nothing received" from "an empty frame received": a timeout failure records TIMEOUT, while a successful transaction with an empty frame records SUCCESS.
Example:
EoE eoe = slave.eoe();
boolean sent = eoe.sendFrame(frameData);
byte[] received = eoe.receiveFrame();
if (received != null)
System.out.println("收到 " + received.length + " 字节"); // Received {received.length} bytes
Address filters (ETG.1020)
The filter matches Ethernet frames behind the slave by MAC address. Adding and removing use read-modify-write: read the current filter table first, then write the whole modified table back. If the read-back fails the operation is aborted, and an existing filter table on the slave is never overwritten with an empty one.
addAddressFilter(byte[] mac, int timeoutMs)
public boolean addAddressFilter(byte[] mac, int timeoutMs)
Adds a single MAC address to the filter list. The existing filter is read first, the new address is appended, and the filter is set again.
Parameters:
mac(byte[]) — MAC address (6 bytes)timeoutMs(int) — timeout (milliseconds, default 500)
Returns:
boolean—trueon success
Throws:
IllegalArgumentException—macisnullor not 6 bytesEoEProtocolException— reading back the existing filter fails (aborted, nothing is written out), or the total would exceed 16 entries after adding (aborted, the slave filter table is left untouched)
removeAddressFilter(byte[] mac, int timeoutMs)
public boolean removeAddressFilter(byte[] mac, int timeoutMs)
Removes the given MAC address from the filter list (the whole entry is compared byte by byte). If the list is empty after removal, this is equivalent to clearing the filter.
Parameters:
mac(byte[]) — MAC address (6 bytes)timeoutMs(int) — timeout (milliseconds, default 500)
Returns:
boolean—trueon success
Throws:
IllegalArgumentException—macisnullor not 6 bytesEoEProtocolException— reading back the existing filter fails (aborted, nothing is written out)
getAddressFilters(int timeoutMs)
public List<byte[]> getAddressFilters(int timeoutMs)
public List<byte[]> getAddressFilters()
Gets the current MAC address filter list.
Parameters:
timeoutMs(int) — timeout (milliseconds, optional, default 500)
Returns:
List<byte[]>— MAC address list (6 bytes each). An empty list is a valid state: it means the slave really has no filter entries configured, not that the read failed
Throws:
EoEProtocolException— the read fails, or the count reported by the slave exceeds 16 (a count mismatch is treated as a failure and is not truncated into a list that "looks normal")
clearAddressFilters(int timeoutMs)
public boolean clearAddressFilters(int timeoutMs)
public boolean clearAddressFilters()
Clears all address filters.
Parameters:
timeoutMs(int) — timeout (milliseconds, default 500)
Returns:
boolean—trueon success
Example:
EoE eoe = slave.eoe();
byte[] mac = { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC,
(byte) 0xDD, (byte) 0xEE, (byte) 0xFF };
eoe.addAddressFilter(mac, 500);
List<byte[]> filters = eoe.getAddressFilters();
for (byte[] f : filters) {
System.out.printf("过滤器: %02X:%02X:%02X:%02X:%02X:%02X%n", // Filter: %02X:%02X:%02X:%02X:%02X:%02X%n
f[0] & 0xFF, f[1] & 0xFF, f[2] & 0xFF,
f[3] & 0xFF, f[4] & 0xFF, f[5] & 0xFF);
}
eoe.clearAddressFilters();
ICMP Ping
Sends an ICMP Echo Request through the EoE mailbox tunnel to an IP device behind the slave to verify network-layer connectivity. A failure does not throw; the conclusion is carried in the return value.
ping(String targetIp, int timeoutMs, int ttl)
public EoEPingResult ping(String targetIp, int timeoutMs, int ttl)
public EoEPingResult ping(String targetIp)
Sends an ICMP Echo and waits for the response (synchronous, blocking).
Parameters:
targetIp(String) — target IP (dotted decimal, for example"192.168.1.10")timeoutMs(int) — timeout (milliseconds, default 5000)ttl(int) — IP TTL (default 64)
Returns:
EoEPingResult— Ping result (see "EoEPingResult").Successisfalsewhen the target is unreachable, the request cannot be sent, or no reply arrives before the timeout; the reason is recorded inErrorMessage. This method does not throw
pingAsync(String targetIp, int timeoutMs, int ttl)
public CompletableFuture<EoEPingResult> pingAsync(String targetIp, int timeoutMs, int ttl)
public CompletableFuture<EoEPingResult> pingAsync(String targetIp)
Asynchronous Ping. It returns a CompletableFuture without blocking the calling thread and runs on the SDK common thread pool by default. The parameters and return value are the same as ping.
EoEPingResult
public static class EoEPingResult {
public boolean Success;
public double RoundTripTimeMs;
public String TargetAddress;
public byte TTL;
public String ErrorMessage;
}
| Field | Type | Meaning |
|---|---|---|
Success | boolean | Whether a reply was received |
RoundTripTimeMs | double | Round-trip time (milliseconds); meaningful only when Success is true |
TargetAddress | String | Target IP (identical to the argument) |
TTL | byte | IP TTL used for this request |
ErrorMessage | String | Failure description; states the reason when Success is false |
Example:
EoE eoe = slave.eoe();
// Synchronous Ping
EoEPingResult r = eoe.ping("192.168.1.10");
if (r.Success) {
System.out.printf("Ping 成功: RTT=%.2fms TTL=%d%n", r.RoundTripTimeMs, r.TTL & 0xFF); // Ping succeeded: RTT=%.2fms TTL=%d%n
} else {
System.out.println("Ping 失败: " + r.ErrorMessage); // Ping failed:
}
// Asynchronous Ping
eoe.pingAsync("192.168.1.10").thenAccept(result -> {
System.out.println(result);
});
Asynchronous receive hook
The EoE receive hook turns "poll receiveFrame" into an event-driven model: when a slave pushes a frame the SDK invokes the listener, so the upper layer does not need a while-poll loop. Only one global hook is allowed per master (the last registrant overwrites the previous one).
setReceiveHook(ReceiveHookListener listener) / clearReceiveHook()
public boolean setReceiveHook(ReceiveHookListener listener)
public boolean clearReceiveHook()
public interface ReceiveHookListener {
void onFrame(short slaveIndex, byte[] frameData);
}
Registers the receive hook; passing null is equivalent to clearReceiveHook(). clearReceiveHook() stops the asynchronous push.
Parameters:
listener(ReceiveHookListener) — frame-arrival callback that receivesslaveIndex(1-based) and the frame bytes; passnullto cancel
Returns:
boolean— returnstruewhen the underlying layer supports it and the registration (or clearing) succeeds; returnsfalsewhen unsupported or failed
Example:
EoE eoe = slave.eoe();
eoe.setReceiveHook((slvIdx, data) -> {
System.out.printf("Slave %d 推帧, %d 字节%n", slvIdx, data.length); // Slave %d pushed frame, %d bytes%n
// Recommended: enqueue and let a business thread process it; do not do heavy work on this thread (SDK receive thread context)
});
// Close it when done
eoe.clearReceiveHook();
The hook is invoked on the SDK receive thread. Do not call time-consuming APIs that block the main flow from inside this thread, such as slave.setState(...) (returns boolean, true=switch succeeded) / master.start(). Enqueue into a BlockingQueue and let a business thread consume it. An exception thrown inside the callback does not interrupt frame reception, but log it yourself.
Asynchronous send and receive (CompletableFuture)
sendFrameAsync(byte[] frame, int timeoutMs) / receiveFrameAsync(int timeoutMs)
public CompletableFuture<Boolean> sendFrameAsync(byte[] frame, int timeoutMs)
public CompletableFuture<Boolean> sendFrameAsync(byte[] frame)
public CompletableFuture<byte[]> receiveFrameAsync(int timeoutMs)
public CompletableFuture<byte[]> receiveFrameAsync()
Wraps the synchronous sendFrame / receiveFrame in a CompletableFuture so they can be combined with existing Java asynchronous chains (thenApply / whenComplete and so on). The SDK common thread pool is used by default; a subclass can override defaultExecutor() to use a custom thread pool.
Parameters: the same as the synchronous version (frame / timeoutMs, timeout default 500 milliseconds).
Returns:
sendFrameAsync—CompletableFuture<Boolean>, whose value istrueon successreceiveFrameAsync—CompletableFuture<byte[]>, whose value is the received frame on success
Throws:
- Both methods turn a failure into a completion with
EoEProtocolException(theexreceived inwhenComplete/handle):sendFrameAsyncfails when the underlying call returnsfalse, andreceiveFrameAsyncfails on a timeout or when no frame is received. Note that, unlike the synchronousreceiveFramewhich returnsnull, the asynchronous version never returnsnull
Example:
eoe.sendFrameAsync(frame, 500)
.thenCompose(ok -> eoe.receiveFrameAsync(1000))
.whenComplete((reply, ex) -> {
if (ex != null) ex.printStackTrace();
else System.out.println("收 " + reply.length + " 字节"); // Received {reply.length} bytes
});
Common mailbox protocol interface
EoE shares the same mailbox protocol interface with CoE / FoE / SoE / AoE / VoE / FSoE, so the upper layer can query capabilities, the most recent transaction status and statistics in a consistent way.
getProtocolType() / getProtocolName()
public byte getProtocolType()
public String getProtocolName()
Returns:
getProtocolType()—byte: protocol type constant (EoE=0x02)getProtocolName()—String: protocol name ("EoE")
getLastStatus() / getLastErrorCode()
public MailboxStatus getLastStatus()
public long getLastErrorCode()
Reads the status and error code of the most recent mailbox transaction (frame send/receive, network address read/write, address filter read/write, hook registration); both success and failure update them.
Returns:
getLastStatus()—MailboxStatus: transaction status;PENDINGwhen no transaction has been started yetgetLastErrorCode()—long: protocol-layer error code;0means no error
getStatistics() / resetStatistics()
public MailboxStatistics getStatistics()
public void resetStatistics()
Reads or resets the mailbox statistics of this protocol. resetStatistics() also resets getLastStatus() to PENDING and getLastErrorCode() to 0.
Returns:
getStatistics()—MailboxStatistics: statistics snapshot of the current session (immutable)
MailboxStatus / MailboxStatistics
MailboxStatus | Meaning |
|---|---|
PENDING | Pending (the transaction has not been started or is still in progress) |
SUCCESS | Completed successfully |
TIMEOUT | No response before the timeout |
CANCELLED | Transaction cancelled |
MAILBOX_ERROR | Mailbox error frame |
PROTO_MISMATCH | Response protocol type mismatch |
WKC_FAIL | Working counter did not match the expectation |
NO_MEMORY | Out of memory |
INVALID_ARG | Invalid argument (for example an empty frame or an over-limit frame) |
NOT_IMPLEMENTED | Not supported (for example the underlying layer does not provide the capability) |
LINK_DOWN | Link down (frames fail immediately instead of timing out one by one); check the cable / NIC link status |
NOT_SENT | Request never left the local host (frame never reached the wire: aborted / backoff / pool exhausted / channel closed / held by the kernel); not a slave timeout and not a slave rejection — carries no bus evidence, must not be used for slave-drop or health verdicts; callers treat it as retryable |
MailboxStatistics field | Type | Meaning |
|---|---|---|
totalSent | long | Total transactions sent |
totalReceived | long | Total responses received (including error frames) |
totalTimeout | long | Total timeouts |
totalMailboxError | long | Total mailbox error frames |
totalProtocolError | long | Total protocol errors (protocol type / working counter mismatch) |
totalCancelled | long | Total cancelled transactions |
lastErrorCode | long | Most recent error code (0 means none) |
lastErrorTime | Instant | Time of the most recent error (null when there is no error) |
averageLatencyUs | double | Average transaction latency (microseconds) |
EoEProtocolException
public static class EoEProtocolException extends RuntimeException
Unified exception for EoE protocol-layer failures (a runtime exception, so it need not be declared). It occurs when a network address write is rejected or its read-back fails, when an address filter read/write fails or exceeds the limit, and when an asynchronous send/receive fails.
Full example
Network configuration
EoE eoe = slave.eoe();
// Read the current configuration
System.out.println("当前 IP: " + eoe.IP()); // Current IP:
System.out.println("当前 MAC: " + eoe.MAC()); // Current MAC:
// Set a new configuration
eoe.IP("10.0.0.100");
eoe.subnet("255.255.255.0");
eoe.gateway("10.0.0.1");
eoe.DNS("10.0.0.1");
Frame send and receive
EoE eoe = slave.eoe();
// Send a frame
boolean sent = eoe.sendFrame(frameData);
// Send a frame with a timestamp
eoe.sendFrameWithTimestamp(frameData, System.nanoTime());
// Receive a frame
byte[] received = eoe.receiveFrame(1000);
if (received != null)
System.out.println("收到 " + received.length + " 字节"); // Received {received.length} bytes
Address filtering and receive hook
EoE eoe = slave.eoe();
byte[] mac = { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC,
(byte) 0xDD, (byte) 0xEE, (byte) 0xFF };
try {
eoe.addAddressFilter(mac, 500);
List<byte[]> filters = eoe.getAddressFilters();
for (byte[] f : filters) {
System.out.printf("过滤器: %02X:%02X:%02X:%02X:%02X:%02X%n", // Filter: %02X:%02X:%02X:%02X:%02X:%02X%n
f[0] & 0xFF, f[1] & 0xFF, f[2] & 0xFF,
f[3] & 0xFF, f[4] & 0xFF, f[5] & 0xFF);
}
} catch (EoE.EoEProtocolException ex) {
// Read/write failed: do not overwrite the slave filter table with an empty one
System.out.println("地址过滤器操作失败: " + ex.getMessage()); // Address filter operation failed:
}
eoe.setReceiveHook((slvIdx, data) -> System.out.println("推帧 " + data.length + " 字节")); // Pushed frame {data.length} bytes
// ... run ...
eoe.clearReceiveHook();
Failures and handling
| Symptom | Cause | Handling |
|---|---|---|
| sendFrame returns false | The link is not established, the frame is longer than 2016 bytes, or the transaction does not finish within the timeout | Confirm the slave has reached a communicable state and shorten the frame; use getLastStatus() to tell an invalid argument from a timeout |
| receiveFrame returns null | No frame arrived before the timeout, or an empty frame was received | Increase timeoutMs, or first confirm the peer is already sending frames; getLastStatus() of SUCCESS means an empty frame was received |
| sendFrameWithTimestamp returns false | Empty frame, over the single-frame limit, or the send failed | Same as sendFrame; this method does not throw, and every failure is folded into false |
| ping returns Success=false | The target is unreachable, the slave has no IP configured, or no reply arrived before the timeout | Check ErrorMessage together with the slave IP and gateway configuration |
| getAddressFilters returns an empty list | The slave really has no MAC filter entries configured (an empty table is a valid state, not a failed read) | When filtering is needed, call addAddressFilter first to add the target address |
| getAddressFilters / addAddressFilter / removeAddressFilter throws EoEProtocolException | Reading the existing filter fails, or the count exceeds the limit of 16 | Treat it as a failure and do not overwrite the slave filter table with an empty one; confirm slave communication and retry |
| IP / subnet / gateway / MAC / DNS write throws EoEProtocolException | The write is not confirmed by the slave, or the read-back before the write fails (the write is aborted) | Do not repeat the write when the read-back fails; restore slave communication first, and the device still keeps its original configuration |
| IP / subnet / gateway / MAC / DNS write throws IllegalArgumentException | The address or MAC format is invalid | Fix the string passed by the caller as an invalid-argument problem |
| sendFrameAsync / receiveFrameAsync completes exceptionally | The same-named synchronous method returned a failure | Handle EoEProtocolException in whenComplete / handle; do not treat it as a null return |
| setReceiveHook returns false | The underlying layer does not support asynchronous reception, or registration failed | Fall back to polling receiveFrame |
| isSupported() is false | The slave really does not support EoE, or the capability is unknown | Use supportState() to tell unknown from confirmed unsupported |