From 456f6b8ad463e20cc1f5bfa24390fa2fff9fced1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BB=D0=B8=D0=BC=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9=20=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B5?= =?UTF-8?q?=D0=B2=D0=B8=D1=87?= Date: Mon, 30 Oct 2023 20:12:16 +0300 Subject: [PATCH] modbus v1 retry optimisation --- lighthub/item.cpp | 36 +++++++++++++++++++++++++++--------- lighthub/item.h | 4 ++-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index ac08b4a..11f0dbb 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -67,7 +67,7 @@ e-mail anklimov@gmail.com #endif short modbusBusy = 0; -bool isPendedModbusWrites = false; +//bool isPendedModbusWrites = false; extern aJsonObject *pollingItem; extern PubSubClient mqttClient; @@ -1615,7 +1615,8 @@ int Item::isActive() { int Item::Poll(int cause) { -if (isPendedModbusWrites) resumeModbus(); +//if (isPendedModbusWrites) resumeModbus(); +checkRetry(); aJsonObject *timestampObj = aJson.getArrayItem(itemArr, I_TIMESTAMP); if (timestampObj) @@ -1937,7 +1938,7 @@ return itemType; void Item::mb_fail(int result) { debugSerial<Ctrl(val); + + if (driver) + { + clearFlag(FLAG_SEND_RETRY); // Clean retry flag + debugSerial<Ctrl(val); + } #ifndef MODBUS_DISABLE else switch (itemType) { case CH_MODBUS: + if (modbusBusy) return M_BUSY; + clearFlag(FLAG_SEND_RETRY); // Clean retry flag + debugSerial<