From a6b43dd714e290080c112a3001037187bdb3a5f5 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Fri, 5 Apr 2024 14:52:41 +0200 Subject: [PATCH] Speed up no data detection. (#2150) --- pymodbus/framer/old_framer_base.py | 2 ++ pymodbus/framer/old_framer_socket.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pymodbus/framer/old_framer_base.py b/pymodbus/framer/old_framer_base.py index b35da6d53..4922be1c4 100644 --- a/pymodbus/framer/old_framer_base.py +++ b/pymodbus/framer/old_framer_base.py @@ -138,6 +138,8 @@ def processIncomingPacket(self, data, callback, slave, **kwargs): """ Log.debug("Processing: {}", data, ":hex") self._buffer += data + if self._buffer == b'': + return if not isinstance(slave, (list, tuple)): slave = [slave] single = kwargs.pop("single", False) diff --git a/pymodbus/framer/old_framer_socket.py b/pymodbus/framer/old_framer_socket.py index 4bd36f3f7..bc515ab2a 100644 --- a/pymodbus/framer/old_framer_socket.py +++ b/pymodbus/framer/old_framer_socket.py @@ -72,6 +72,8 @@ def frameProcessIncomingPacket(self, single, callback, slave, tid=None, **kwargs function to process and send. """ while True: + if self._buffer == b'': + return used_len, use_tid, dev_id, data = self.message_handler.decode(self._buffer) if not data: return