diff --git a/ebpfcat/ebpfcat.py b/ebpfcat/ebpfcat.py index c2ddfb86d3a5a76dc2f6d331b8064de04bb89c91..f5d38df84b9471dcd3290c773dbc8ffd0a356c1e 100644 --- a/ebpfcat/ebpfcat.py +++ b/ebpfcat/ebpfcat.py @@ -92,7 +92,7 @@ class ProcessDesc: def __get__(self, instance, owner): if instance is None: return self - index = self.index + instance.position_offset[SyncManager.IN] + index = self.index + instance.position_offset[None] if isinstance(instance, Struct): terminal = instance.terminal device = instance.device @@ -276,7 +276,7 @@ class EBPFTerminal(Terminal): product id of all supported terminal types. """ compatibility = None - position_offset = {SyncManager.OUT: 0, SyncManager.IN: 0} + position_offset = {SyncManager.OUT: 0, SyncManager.IN: 0, None: 0} use_fmmu = True out_pdos = None in_pdos = None diff --git a/ebpfcat/ethercat.py b/ebpfcat/ethercat.py index cc6fffc489983c1314273784e5c5b240300cbcbe..8e1c838ad5260b6cc34f379069b16b61031677f7 100644 --- a/ebpfcat/ethercat.py +++ b/ebpfcat/ethercat.py @@ -497,16 +497,19 @@ class Struct: """ device = None - def __new__(cls, *args): - return StructDesc(cls, *args) + def __new__(cls, *args, **kwargs): + return StructDesc(cls, *args, **kwargs) class StructDesc: - def __init__(self, struct, sm3=0, sm2=None): + def __init__(self, struct, sm3=0, sm2=None, coe=None): self.struct = struct if sm2 is None: sm2 = sm3 - self.position_offset = {SyncManager.OUT: sm2, SyncManager.IN: sm3} + if coe is None: + coe = sm3 + self.position_offset = {SyncManager.OUT: sm2, SyncManager.IN: sm3, + None: coe} def __get__(self, instance, owner): if instance is None: @@ -680,7 +683,7 @@ class Terminal: await self.read_object_entry(v.index, v.subidx)) elif isinstance(v, StructDesc): struct = getattr(self, k) - offset = struct.position_offset[SyncManager.IN] + offset = struct.position_offset[None] for kk, vv in struct.__class__.__dict__.items(): if isinstance(vv, ServiceDesc): setattr(struct, kk, diff --git a/ebpfcat/terminals.py b/ebpfcat/terminals.py index 6221a68b914ce9c328618d572ff6560993ed0184..333d937089d4c62ddaec35bef92783f6f23fb4fe 100644 --- a/ebpfcat/terminals.py +++ b/ebpfcat/terminals.py @@ -45,7 +45,7 @@ class EL2212(EBPFTerminal): compatibility = {(2, 0x8A43052)} class Channel(Struct): - output = ProcessDesc(0x7000, 2) + value = ProcessDesc(0x7000, 2) boost_current = ServiceDesc(0x8000, 1) hold_current = ServiceDesc(0x8000, 2) @@ -169,8 +169,8 @@ class EL5042(EBPFTerminal): channel2 = Channel(0x10) -class EL6022(EBPFTerminal): - compatibility = {(2, 0x17863052)} +class EL6002(EBPFTerminal): + compatibility = {(2, 393359442)} class Channel(Struct): transmit_accept = PacketDesc(SyncManager.IN, 0, 0) @@ -193,8 +193,20 @@ class EL6022(EBPFTerminal): baudRate = ServiceDesc(0x8000, 0x11) dataFrame = ServiceDesc(0x8000, 0x15) - channel1 = Channel(0) - channel2 = Channel(0x10) + channel1 = Channel(0, 0, 0) + channel2 = Channel(24, 24, 0x10) + + + +class EL6022(EBPFTerminal): + compatibility = {(2, 0x17863052)} + + class Channel(EL6002.Channel): + enableHalfDuplex = ServiceDesc(0x8000, 6) + enablePointToPoint = ServiceDesc(0x8000, 7) + + channel1 = Channel(0, 0, 0) + channel2 = Channel(24, 24, 0x10) class EL7041(EBPFTerminal):