From c78891a423e302fe084a92fe8920b9f99494425b Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Sun, 14 Jul 2019 01:44:06 +0300 Subject: [PATCH] modbus pooling/tomeout fix --- lighthub/item.cpp | 20 +++++++++++--------- platformio.ini | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 4660b4e..0be0482 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -1137,19 +1137,21 @@ int Item::checkModbusDimmer() { data = node.getResponseBuffer(0); debugSerial << F("MB: ") << itemArr->name << F(" Val: ") << _HEX(data) << endl; checkModbusDimmer(data); + + // Looking 1 step ahead for modbus item, which uses same register + Item nextItem(pollingItem->next); + if (pollingItem && nextItem.isValid() && nextItem.itemType == CH_MODBUS && nextItem.getArg(0) == addr && + nextItem.getArg(1) == reg) { + nextItem.checkModbusDimmer(data); + pollingItem = pollingItem->next; + if (!pollingItem) + pollingItem = items->child; + } } else debugSerial << F("Modbus polling error=") << _HEX(result) << endl; modbusBusy = 0; -// Looking 1 step ahead for modbus item, which uses same register - Item nextItem(pollingItem->next); - if (pollingItem && nextItem.isValid() && nextItem.itemType == CH_MODBUS && nextItem.getArg(0) == addr && - nextItem.getArg(1) == reg) { - nextItem.checkModbusDimmer(data); - pollingItem = pollingItem->next; - if (!pollingItem) - pollingItem = items->child; - } + } diff --git a/platformio.ini b/platformio.ini index 2b3e318..7f7ad35 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,7 +20,7 @@ env_default = ; mega2560-5100 ; Arduino Mega + Ethernet shield Wiznet 5500 - mega2560-5500 +; mega2560-5500 ; LightHub controller HW revision 2.1 and above (Wiznet 5500 CS on pin 53) ; lighthub21 @@ -29,7 +29,7 @@ env_default = ; due-5100 ; Arduino DUE + Ethernet shield Wiznet 5500 -; due-5500 + due-5500 ; ESP 8266 ; esp8266-wifi