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

add a script to read out the test system

this script reads out all relevant data from the connected terminals
such that it can be used for offline tests. Also add the retrieved data.
parent 2b501347
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ from argparse import ArgumentParser ...@@ -2,6 +2,7 @@ from argparse import ArgumentParser
import asyncio import asyncio
from functools import wraps from functools import wraps
from hashlib import sha1 from hashlib import sha1
from pprint import PrettyPrinter
from struct import unpack from struct import unpack
import sys import sys
...@@ -138,3 +139,33 @@ async def eeprom(): ...@@ -138,3 +139,33 @@ async def eeprom():
if w is not None: if w is not None:
await t.eeprom_write_one(0xe, w & 0xffff) await t.eeprom_write_one(0xe, w & 0xffff)
await t.eeprom_write_one(0xf, w >> 16) await t.eeprom_write_one(0xf, w >> 16)
@entrypoint
async def create_test():
ec = EtherCat(sys.argv[1])
await ec.connect()
no = await ec.count()
terminals = []
for i in range(no):
t = Terminal()
t.ec = ec
await t.initialize(-i, await ec.find_free_address())
sdo = {}
if t.has_mailbox():
await t.to_operational()
odlist = await t.read_ODlist()
for k, v in odlist.items():
for kk, vv in v.entries.items():
try:
ret = await t.sdo_read(v.index, vv.valueInfo)
except RuntimeError:
pass
sdo[v.index, vv.valueInfo] = ret
terminals.append(dict(eeprom=t.eeprom, sdo=sdo))
pp = PrettyPrinter(indent=4)
pp.pprint(terminals)
This diff is collapsed.
...@@ -7,3 +7,4 @@ dependencies = [] ...@@ -7,3 +7,4 @@ dependencies = []
ec-scanbus = "ebpfcat.scripts:scanbus" ec-scanbus = "ebpfcat.scripts:scanbus"
ec-info = "ebpfcat.scripts:info" ec-info = "ebpfcat.scripts:info"
ec-eeprom = "ebpfcat.scripts:eeprom" ec-eeprom = "ebpfcat.scripts:eeprom"
ec-create-test = "ebpfcat.scripts:create_test"
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