diff --git a/ebpfcat/ebpfcat.py b/ebpfcat/ebpfcat.py index 6f8f20eea6c51975eebda95448101b5ebcb75662..30291c4ae00c08fd41d8a29d622efe25ac9a89cc 100644 --- a/ebpfcat/ebpfcat.py +++ b/ebpfcat/ebpfcat.py @@ -255,6 +255,8 @@ class EBPFTerminal(Terminal): compatibility = None position_offset = {SyncManager.OUT: 0, SyncManager.IN: 0} use_fmmu = True + out_pdos = None + in_pdos = None async def apply_eeprom(self): await super().apply_eeprom() @@ -263,6 +265,10 @@ class EBPFTerminal(Terminal): raise EtherCatError( f"Incompatible Terminal: {self.vendorId}:{self.productCode}") await self.to_operational(MachineState.PRE_OPERATIONAL) + if self.out_pdos is not None: + await self.write_pdos(0x1c12, self.out_pdos) + if self.in_pdos is not None: + await self.write_pdos(0x1c13, self.in_pdos) self.pdos = {} outbits, inbits = await self.parse_pdos() self.pdo_out_sz = int((outbits + 7) // 8) @@ -271,6 +277,13 @@ class EBPFTerminal(Terminal): assert not self.pdo_in_sz or self.pdo_in_off await self.write_pdo_sm() + async def write_pdos(self, index, values): + await self.sdo_write(pack('B', 0), index, 0) + for i, v in enumerate(values, 1): + await self.sdo_write(pack('<H', v), index, i) + await self.sdo_write(pack('<H', 0), index, i + 1) + await self.sdo_write(pack('B', len(values)), index, 0) + def allocate(self, packet, readwrite): """allocate space in packet for the pdos of this terminal diff --git a/ebpfcat/terminals.py b/ebpfcat/terminals.py index 35a80466c4439c193353b04129d5e4c91227587f..a4db46562fe426b545cfea21ff3fb1c9642a143b 100644 --- a/ebpfcat/terminals.py +++ b/ebpfcat/terminals.py @@ -159,13 +159,17 @@ class EL6022(EBPFTerminal): class EL7041(EBPFTerminal): compatibility = {(2, 461451346), (2, 461455442), (2, 460795986)} + out_pdos = [0x1600, 0x1602, 0x1604] + in_pdos = [0x1A00, 0x1A03, 0x1A07] velocity = ProcessDesc(0x7010, 0x21, "h") enable = ProcessDesc(0x7010, 1) + reset = ProcessDesc(0x7010, 2) reduced_current = ProcessDesc(0x7010, 3) status = ProcessDesc(0x6010, 1, "H") + error = ProcessDesc(0x6010, 4) low_switch = ProcessDesc(0x6010, 0xc) high_switch = ProcessDesc(0x6010, 0xd) - + stepcounter = ProcessDesc(0x6010, 0x14) class EL7332(EBPFTerminal):