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 (3)
......@@ -24,7 +24,7 @@ from enum import Enum
import logging
import os
from struct import pack, unpack, calcsize, pack_into, unpack_from
from time import time
from time import monotonic
from .arraymap import ArrayMap, ArrayGlobalVarDesc
from .ethercat import (
ECCmd, EtherCat, MachineState, Packet, Terminal, EtherCatError,
......@@ -502,6 +502,8 @@ class BaseType(Enum):
class SyncGroupBase:
missed_counter = 0
cycletime = 0.01 # cycle time of the PLC loop
task = None
current_data = None
logical_in = logical_out = None
......@@ -543,12 +545,13 @@ class SyncGroupBase:
async with self.map_fmmu():
task = ensure_future(self.to_operational())
try:
lasttime = monotonic()
while True:
self.ec.send_packet(data)
try:
data = await wait_for(
self.ec.receive_index(self.packet_index),
timeout=0.1)
timeout=0.05)
except TimeoutError:
self.missed_counter += 1
logging.warning(
......@@ -556,6 +559,9 @@ class SyncGroupBase:
self.missed_counter)
continue
data = self.update_devices(data)
newtime = monotonic()
await sleep(self.cycletime - (newtime - lasttime))
lasttime = monotonic()
finally:
task.cancel()
try:
......@@ -617,6 +623,7 @@ class SyncGroup(SyncGroupBase):
raise
def start(self):
assert self.task is None or self.task.done()
self.allocate()
self.packet_index = SyncGroup.packet_index
SyncGroup.packet_index += 1
......
......@@ -467,7 +467,6 @@ class EtherCat(Protocol):
def connection_made(self, transport):
"""start the send loop once the connection is made"""
transport.get_extra_info("socket").bind(self.addr)
self.transport = transport
ensure_future(self.sendloop())
......
......@@ -58,7 +58,6 @@ class XDRFD(DatagramProtocol):
def connection_made(self, transport):
sock = transport.get_extra_info("socket")
sock.setsockopt(270, 11, 1)
sock.bind((0, 0))
self.transport = transport
# this was adopted from xdp1_user.c
p = pack("IHHIIBxHiIiHHHHiHHI",
......