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

bla

parent 9b012c20
No related branches found
No related tags found
No related merge requests found
...@@ -118,8 +118,15 @@ class Terminal: ...@@ -118,8 +118,15 @@ class Terminal:
async def to_operational(self): async def to_operational(self):
"""try to bring the terminal to operational state""" """try to bring the terminal to operational state"""
order = [0x11, 1, 2, 4, 8] order = [1, 2, 4, 8]
ret, = await self.ec.roundtrip(4, self.position, 0x0130, "H") ret, error = await self.ec.roundtrip(4, self.position,
0x0130, "H2xH")
print(ret, error)
if ret & 0x10:
await self.ec.roundtrip(5, self.position, 0x0120, "H", 0x11)
ret, error = await self.ec.roundtrip(4, self.position,
0x0130, "H2xH")
print("B", ret, error)
pos = order.index(ret) pos = order.index(ret)
s = 0x11 s = 0x11
for state in order[pos:]: for state in order[pos:]:
...@@ -133,18 +140,33 @@ class Terminal: ...@@ -133,18 +140,33 @@ class Terminal:
async def get_error(self): async def get_error(self):
return (await self.ec.roundtrip(4, self.position, 0x0134, "H"))[0] return (await self.ec.roundtrip(4, self.position, 0x0134, "H"))[0]
async def read(self, start, fmt):
return (await self.ec.roundtrip(4, self.position, start, fmt))
async def write(self, start, fmt, *args):
return (await self.ec.roundtrip(5, self.position, start, fmt, *args))
async def main(): async def main():
ec = await EtherCat("eth0") ec = await EtherCat("eth0")
tin = Terminal(ec) tin = Terminal(ec)
tout = Terminal(ec) tout = Terminal(ec)
tdigi = Terminal(ec) tdigi = Terminal(ec)
await tin.initialize(-1, 5) await gather(
await tout.initialize(-2, 6) tin.initialize(-1, 5),
await tdigi.initialize(0, 22) tout.initialize(-2, 6),
await tin.to_operational() tdigi.initialize(0, 22),
await tout.to_operational() )
await tdigi.to_operational() print("tin")
await tin.to_operational(),
print("tout")
await tout.to_operational(),
print("tdigi")
await tdigi.to_operational(),
print(tout.eeprom[10])
print(await tout.write(0x1100, "HHHH", 10000, 20000, 30000, 40000))
print(await tin.read(0x1180, "HHHHHHHH"))
if __name__ == "__main__": if __name__ == "__main__":
loop = get_event_loop() loop = get_event_loop()
......
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