From 38e06102e82e14200ee4b4c89b5c6f709a2f8c33 Mon Sep 17 00:00:00 2001 From: Martin Teichmann <martin.teichmann@gmail.com> Date: Sat, 11 Feb 2023 07:51:38 +0000 Subject: [PATCH] pre-operational is good enough to read terminals --- ebpfcat/ethercat.py | 4 +++- ebpfcat/scripts.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ebpfcat/ethercat.py b/ebpfcat/ethercat.py index 95c5187..61838bf 100644 --- a/ebpfcat/ethercat.py +++ b/ebpfcat/ethercat.py @@ -531,7 +531,7 @@ class Terminal: ret, = await self.ec.roundtrip(ECCmd.FPRD, self.position, 0x0130, "H") return ret - async def to_operational(self): + async def to_operational(self, target=8): """try to bring the terminal to operational state this tries to push the terminal through its state machine to the @@ -556,6 +556,8 @@ class Terminal: 0x0130, "H2xH") if error != 0: raise EtherCatError(f"AL register {error}") + if state == target: + return async def get_error(self): """read the error register""" diff --git a/ebpfcat/scripts.py b/ebpfcat/scripts.py index b88ce1b..01bf319 100644 --- a/ebpfcat/scripts.py +++ b/ebpfcat/scripts.py @@ -69,7 +69,7 @@ async def info(): i += infos[i] + 1 if args.sdo: - await t.to_operational() + await t.to_operational(4) ret = await t.read_ODlist() for k, v in ret.items(): print(f"{k:X}:") @@ -86,7 +86,7 @@ async def info(): else: print(f" {r}") if args.pdo: - await t.to_operational() + await t.to_operational(4) await t.parse_pdos() for (idx, subidx), (sm, pos, fmt) in t.pdos.items(): print(f"{idx:4X}:{subidx:02X} {sm} {pos} {fmt}") @@ -159,7 +159,7 @@ async def create_test(): await t.initialize(-i, await ec.find_free_address()) sdo = {} if t.has_mailbox(): - await t.to_operational() + await t.to_operational(4) odlist = await t.read_ODlist() for k, v in odlist.items(): -- GitLab