diff --git a/ebpfcat/ethercat.py b/ebpfcat/ethercat.py index 5742ecd23bb82a41529fbc7d6b4c0cab31174a11..0b6efae084f010614194ae2fc9ca7059c647246a 100644 --- a/ebpfcat/ethercat.py +++ b/ebpfcat/ethercat.py @@ -529,7 +529,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 @@ -554,6 +554,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 b88ce1b5f46e71f67287e4951334a56b94a48b75..01bf319478b0a13dbdfbb66d7d2659fc1e6227b5 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():