From 6b6f20d1bcda30f2ad686f870581fba3731fc38c Mon Sep 17 00:00:00 2001
From: Martin Teichmann <martin.teichmann@xfel.eu>
Date: Thu, 19 Jan 2023 16:13:32 +0100
Subject: [PATCH] fix weird terminals

bus couplers seem to be incomplete
---
 ebpfcat/ebpfcat.py  | 2 +-
 ebpfcat/ethercat.py | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/ebpfcat/ebpfcat.py b/ebpfcat/ebpfcat.py
index 941a6a7..1754604 100644
--- a/ebpfcat/ebpfcat.py
+++ b/ebpfcat/ebpfcat.py
@@ -222,7 +222,7 @@ class EBPFTerminal(Terminal):
         await super().initialize(relative, absolute)
         if (self.compatibility is not None and
                 (self.vendorId, self.productCode) not in self.compatibility):
-            raise RuntimeError(f"Incompatible Terminal: {self.vendorId}:{self.productCode}")
+            raise RuntimeError(f"Incompatible Terminal: {self.vendorId}:{self.productCode} ({relative}, {absolute})")
 
     def allocate(self, packet, readonly):
         if self.pdo_in_sz:
diff --git a/ebpfcat/ethercat.py b/ebpfcat/ethercat.py
index 261ee20..3c69e86 100644
--- a/ebpfcat/ethercat.py
+++ b/ebpfcat/ethercat.py
@@ -379,6 +379,9 @@ class Terminal:
         self.mbx_lock = Lock()
 
         self.eeprom = await self.read_eeprom()
+        if 41 not in self.eeprom:
+            print('no 41 in eeprom')
+            return
         await self.write(0x800, data=0x80)  # empty out sync manager
         await self.write(0x800, data=self.eeprom[41])
         self.mbx_out_off = self.mbx_out_sz = None
-- 
GitLab