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:
packets. We implicitly add a datagram in the front which later serves
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
PACKET_HEADER = 16
DATAGRAM_HEADER = 10
......@@ -236,8 +236,15 @@ class Packet:
Depending on the command, one or two more parameters represent the
address, either terminal and offset for position or node 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.size += len(data) + self.DATAGRAM_HEADER + self.DATAGRAM_TAIL
self.size = newsize
def assemble(self, index):
"""Assemble the datagrams into a packet
......@@ -306,17 +313,24 @@ class EtherCat(Protocol):
to be sent from a queue, packs them in a packet and ships them
out. """
try:
packet = Packet()
dgrams = []
packet = Packet()
sent = True
while True:
*dgram, future = await self.send_queue.get()
lastsize = packet.size
packet.append(*dgram)
dgrams.append((lastsize + 10, packet.size - 2, future))
if packet.full() or self.send_queue.empty():
ensure_future(self.process_packet(dgrams, packet))
dgrams = []
packet = Packet()
if sent:
*dgram, future = await self.send_queue.get()
try:
lastsize = packet.size
packet.append(*dgram)
dgrams.append((lastsize + 10, packet.size - 2, future))
sent = True
if not self.send_queue.empty():
continue
except OverflowError:
sent = False
ensure_future(self.process_packet(dgrams, packet))
dgrams = []
packet = Packet()
except CancelledError:
raise
except Exception:
......@@ -805,10 +819,12 @@ class Terminal:
index, subindex, data)
type, data = await self.mbx_recv()
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])
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:
raise EtherCatError(f"expected CoE SDORES, got {coecmd>>12:x}")
else:
......
......@@ -130,7 +130,7 @@ class EK1814(EBPFTerminal):
class EL5042(EBPFTerminal):
compatibility = {(2, 330444882)}
class Channel(Struct):
position = ProcessDesc(0x6000, 0x11)
position = ProcessDesc(0x6000, 0x11, 'q')
warning = ProcessDesc(0x6000, 1)
error = ProcessDesc(0x6000, 2)
status = ProcessDesc(0x6000, 1, "H")
......@@ -199,7 +199,11 @@ class TurboVac(EBPFTerminal):
class Inficon(EBPFTerminal):
compatibility = {(0x644, 0x21)}
valid = ProcessDesc(0xF640, 1)
overrange = ProcessDesc(0xF640, 2)
underrange = ProcessDesc(0xF640, 3)
value = ProcessDesc(0xF640, 0x11, "f")
sensorNo = ProcessDesc(0xF640, 0x12, "f")
class Bronkhorst(EBPFTerminal):
......