From 97be15f30ae3e62a75900424d95575b45094e9ff Mon Sep 17 00:00:00 2001 From: Martin Teichmann <martin.teichmann@xfel.eu> Date: Sat, 11 Feb 2023 15:03:45 +0100 Subject: [PATCH] ignore Ethernet-over-Ethercat somehow the anybus thing wants to return a EoE frame when asked for a CoE frame. We can just ignore it, then it works fine. --- ebpfcat/ethercat.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ebpfcat/ethercat.py b/ebpfcat/ethercat.py index 61838bf..b37b0a5 100644 --- a/ebpfcat/ethercat.py +++ b/ebpfcat/ethercat.py @@ -666,9 +666,11 @@ class Terminal: offset = 8 # skip header in first packet while fragments: - type, data = await self.mbx_recv() - if type is not MBXType.COE: - raise EtherCatError(f"expected CoE package, got {type}") + type = None + while type is not MBXType.COE: + type, data = await self.mbx_recv() + if type is not MBXType.COE: + print(f"expected CoE package, got {type}") coecmd, rodcmd, fragments = unpack("<HBxH", data[:6]) if rodcmd & 0x7f != odcmd.value + 1: raise EtherCatError(f"expected {odcmd.value}, got {odcmd}") @@ -683,9 +685,11 @@ class Terminal: ODCmd.UP_REQ_CA.value if subindex is None else ODCmd.UP_REQ.value, index, 1 if subindex is None else subindex) - type, data = await self.mbx_recv() - if type is not MBXType.COE: - raise EtherCatError(f"expected CoE, got {type}") + type = None + while type is not MBXType.COE: + type, data = await self.mbx_recv() + if type is not MBXType.COE: + print(f"got {type}") coecmd, sdocmd, idx, subidx, size = unpack("<HBHBI", data[:10]) if coecmd >> 12 != CoECmd.SDORES.value: if subindex is None and coecmd >> 12 == CoECmd.SDOREQ.value: -- GitLab