From 9f05d0ad714725a8a7ac5ce017f5a58a4b2ea102 Mon Sep 17 00:00:00 2001 From: Martin Teichmann <martin.teichmann@xfel.eu> Date: Fri, 11 Dec 2020 12:22:29 +0000 Subject: [PATCH] make MAXSIZE a named constant --- ethercat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethercat.py b/ethercat.py index a0b474f..12a7cd9 100644 --- a/ethercat.py +++ b/ethercat.py @@ -2,6 +2,8 @@ from asyncio import ensure_future, Event, Future, gather, get_event_loop, Protoc from socket import socket, AF_PACKET, SOCK_DGRAM from struct import pack, unpack, calcsize +MAXSIZE = 1000 # maximum size we use for an EtherCAT packet + class AsyncBase: async def __new__(cls, *args, **kwargs): @@ -23,7 +25,7 @@ class EtherCat(Protocol, AsyncBase): size = 2 while True: *dgram, data, future = await self.send_queue.get() - done = size > 1000 or self.send_queue.empty() + done = size > MAXSIZE or self.send_queue.empty() ret.append(pack("<BBhHHH", *dgram, len(data) | ((not done) << 15), 0)) ret.append(data) -- GitLab