Skip to content
Snippets Groups Projects
Commit e46f9331 authored by Martin Teichmann's avatar Martin Teichmann
Browse files

put terminal into operational later

the Leybold TurboVac does not like to be put into operational unless
it is already getting PDO data. This actually seems like a good idea.
parent 93d605ff
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""The high-level API for EtherCAT loops"""
from asyncio import ensure_future, gather, wait_for, TimeoutError
from asyncio import ensure_future, gather, sleep, wait_for, TimeoutError
from contextlib import asynccontextmanager, contextmanager
import os
from struct import pack, unpack, calcsize, pack_into, unpack_from
......@@ -222,7 +222,7 @@ class EBPFTerminal(Terminal):
raise RuntimeError(
f"Incompatible Terminal: {self.vendorId}:{self.productCode} "
f"({relative}, {absolute})")
await self.to_operational()
await self.to_operational(4)
self.pdos = {}
if self.has_mailbox():
await self.parse_pdos()
......@@ -388,12 +388,27 @@ class SyncGroup(SyncGroupBase):
dev.update()
return self.current_data
async def to_operational(self):
try:
r = await gather(*[t.to_operational() for t in self.terminals])
while True:
for t in self.terminals:
print("stat", await t.get_state())
await sleep(1)
except Exception:
import traceback
traceback.print_exc()
raise
def start(self):
self.allocate()
self.packet_index = SyncGroup.packet_index
SyncGroup.packet_index += 1
self.asm_packet = self.packet.assemble(self.packet_index)
return ensure_future(self.run())
ret = ensure_future(self.run())
ensure_future(self.to_operational())
return ret
def allocate(self):
self.packet = Packet()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment