Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • teichman/ebpfcat
1 result
Show changes
Commits on Source (4)
...@@ -215,7 +215,7 @@ class Packet: ...@@ -215,7 +215,7 @@ class Packet:
packets. We implicitly add a datagram in the front which later serves packets. We implicitly add a datagram in the front which later serves
as an identifier for the packet. as an identifier for the packet.
""" """
MAXSIZE = 1000 # maximum size we use for an EtherCAT packet MAXSIZE = 1500 # maximum size we use for an EtherCAT packet
ETHERNET_HEADER = 14 ETHERNET_HEADER = 14
PACKET_HEADER = 16 PACKET_HEADER = 16
DATAGRAM_HEADER = 10 DATAGRAM_HEADER = 10
...@@ -236,8 +236,15 @@ class Packet: ...@@ -236,8 +236,15 @@ class Packet:
Depending on the command, one or two more parameters represent the Depending on the command, one or two more parameters represent the
address, either terminal and offset for position or node addressing, address, either terminal and offset for position or node addressing,
or one value for logical addressing.""" or one value for logical addressing."""
newsize = self.size + len(data) + self.DATAGRAM_HEADER \
+ self.DATAGRAM_TAIL
if newsize > self.MAXSIZE:
raise OverflowError("ethercat packet size too big")
elif len(self.data) > 14:
raise OverflowError("Too many datagrams per packet")
self.data.append((cmd, data, idx) + address) self.data.append((cmd, data, idx) + address)
self.size += len(data) + self.DATAGRAM_HEADER + self.DATAGRAM_TAIL self.size = newsize
def assemble(self, index): def assemble(self, index):
"""Assemble the datagrams into a packet """Assemble the datagrams into a packet
...@@ -306,17 +313,24 @@ class EtherCat(Protocol): ...@@ -306,17 +313,24 @@ class EtherCat(Protocol):
to be sent from a queue, packs them in a packet and ships them to be sent from a queue, packs them in a packet and ships them
out. """ out. """
try: try:
packet = Packet()
dgrams = [] dgrams = []
packet = Packet()
sent = True
while True: while True:
*dgram, future = await self.send_queue.get() if sent:
lastsize = packet.size *dgram, future = await self.send_queue.get()
packet.append(*dgram) try:
dgrams.append((lastsize + 10, packet.size - 2, future)) lastsize = packet.size
if packet.full() or self.send_queue.empty(): packet.append(*dgram)
ensure_future(self.process_packet(dgrams, packet)) dgrams.append((lastsize + 10, packet.size - 2, future))
dgrams = [] sent = True
packet = Packet() if not self.send_queue.empty():
continue
except OverflowError:
sent = False
ensure_future(self.process_packet(dgrams, packet))
dgrams = []
packet = Packet()
except CancelledError: except CancelledError:
raise raise
except Exception: except Exception:
...@@ -805,10 +819,12 @@ class Terminal: ...@@ -805,10 +819,12 @@ class Terminal:
index, subindex, data) index, subindex, data)
type, data = await self.mbx_recv() type, data = await self.mbx_recv()
if type is not MBXType.COE: if type is not MBXType.COE:
raise EtherCatError(f"expected CoE, got {type}, {data} {odata} {index:x} {subindex}") raise EtherCatError(f"expected CoE, got {type}, {data} "
f"{odata} {index:x}:{subindex:x}")
coecmd, sdocmd, idx, subidx = unpack("<HBHB", data[:6]) coecmd, sdocmd, idx, subidx = unpack("<HBHB", data[:6])
if idx != index or subindex != subidx: if idx != index or subindex != subidx:
raise EtherCatError(f"requested index {index}, got {idx}") raise EtherCatError(f"requested index {index:x}:{subindex:x}, "
f"got {idx:x}:{subidx:x}")
if coecmd >> 12 != CoECmd.SDORES.value: if coecmd >> 12 != CoECmd.SDORES.value:
raise EtherCatError(f"expected CoE SDORES, got {coecmd>>12:x}") raise EtherCatError(f"expected CoE SDORES, got {coecmd>>12:x}")
else: else:
......
...@@ -130,7 +130,7 @@ class EK1814(EBPFTerminal): ...@@ -130,7 +130,7 @@ class EK1814(EBPFTerminal):
class EL5042(EBPFTerminal): class EL5042(EBPFTerminal):
compatibility = {(2, 330444882)} compatibility = {(2, 330444882)}
class Channel(Struct): class Channel(Struct):
position = ProcessDesc(0x6000, 0x11) position = ProcessDesc(0x6000, 0x11, 'q')
warning = ProcessDesc(0x6000, 1) warning = ProcessDesc(0x6000, 1)
error = ProcessDesc(0x6000, 2) error = ProcessDesc(0x6000, 2)
status = ProcessDesc(0x6000, 1, "H") status = ProcessDesc(0x6000, 1, "H")
...@@ -199,7 +199,11 @@ class TurboVac(EBPFTerminal): ...@@ -199,7 +199,11 @@ class TurboVac(EBPFTerminal):
class Inficon(EBPFTerminal): class Inficon(EBPFTerminal):
compatibility = {(0x644, 0x21)} compatibility = {(0x644, 0x21)}
valid = ProcessDesc(0xF640, 1)
overrange = ProcessDesc(0xF640, 2)
underrange = ProcessDesc(0xF640, 3)
value = ProcessDesc(0xF640, 0x11, "f") value = ProcessDesc(0xF640, 0x11, "f")
sensorNo = ProcessDesc(0xF640, 0x12, "f")
class Bronkhorst(EBPFTerminal): class Bronkhorst(EBPFTerminal):
......