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

ethercat object doesn't need to know its terminals

especially if we want to assign terminals dynamically, we cannot assing
terminals to loops at creation time.
parent 15f78085
No related branches found
No related tags found
No related merge requests found
......@@ -342,15 +342,15 @@ class EtherCatBase:
for (i, t) in enumerate(self.terminals)])
class SimpleEtherCat(EtherCatBase, EtherCat):
class SimpleEtherCat(EtherCat):
pass
class FastEtherCat(SimpleEtherCat):
MAX_PROGS = 64
def __init__(self, network, terminals):
super().__init__(network, terminals)
def __init__(self, network):
super().__init__(network)
self.programs = create_map(MapType.PROG_ARRAY, 4, 4, self.MAX_PROGS)
self.sync_groups = {}
......
......@@ -413,6 +413,8 @@ class EtherCat(Protocol):
class Terminal:
"""Represent one terminal ("slave") in the loop"""
def __init__(self, ethercat):
self.ec = ethercat
async def initialize(self, relative, absolute):
"""Initialize the terminal
......
......@@ -52,8 +52,7 @@ async def info():
for i, t in zip(terminals, terms)))
else:
free = await ec.find_free_address()
term = Terminal()
term.ec = ec
term = Terminal(ec)
await term.initialize(-args.terminal, free)
terms = [term]
......@@ -128,8 +127,7 @@ async def eeprom():
await ec.roundtrip(ECCmd.FPRW, 7, 0x10, "H", 0)
terminals = [args.terminal]
t = Terminal()
t.ec = ec
t = Terminal(ec)
await t.initialize(-args.terminal, 7)
if args.read or args.check is not None:
......
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