From 9683e51c18a0bb742163c467e460f05868c6440a Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 15 Nov 2023 11:02:53 +0300 Subject: [PATCH] subitem retrieve fix, new loglev 9 for mbus trace --- lighthub/item.cpp | 6 +++--- lighthub/modules/out_modbus.cpp | 14 +++++++------- lighthub/owTerm.cpp | 6 +++--- lighthub/streamlog.h | 2 ++ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 903582e..cce2f8f 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -106,7 +106,7 @@ int subitem2cmd(char *payload) { int txt2subItem(char *payload) { if (!payload || !strlen(payload)) return S_NOTFOUND; for(uint8_t i=1; itype == aJson_NULL) itemExt->type=aJson_Int; else if(itemExt->type != aJson_Int ) return; itemExt->valueint = par; - debugSerial<isAllowed(cmd)) && (!getFlag(FLAG_FREEZED))) if (!tStore.timestamp16) mqttClient.publish("/alarmoff/snsr", itemArr->name); tStore.tempX100=cmd.getFloat()*100.; //Save measurement tStore.timestamp16=millisNZ(8) & 0xFFFF; //And timestamp - debugSerial<name<name<type==aJson_Array || mapObj->type==aJson_Object)) { @@ -401,7 +401,7 @@ itemCmd out_Modbus::findRegister(uint16_t registerNum, uint16_t posInBuffer, uin aJsonObject * nestedMapObj = aJson.getObjectItem(templateParObj, "map"); if (nestedMapObj && (nestedMapObj->type==aJson_Array || nestedMapObj->type==aJson_Object)) mappedParam=mappedParam.doReverseMapping(nestedMapObj); - debugSerial << F("MBUSD: NestedMapped:")<subtype & MB_VALUE_OUTDATED)) { @@ -449,7 +449,7 @@ itemCmd out_Modbus::findRegister(uint16_t registerNum, uint16_t posInBuffer, uin */ } else - debugSerial << F("MBUSD: Mapped:")<type==aJson_Int) @@ -505,7 +505,7 @@ itemCmd out_Modbus::findRegister(uint16_t registerNum, uint16_t posInBuffer, uin aJsonObject *settedValue = aJson.getObjectItem(markObj,"@V"); if (settedValue && settedValue->type==aJson_Int && (settedValue->valueint == param)) { - debugSerial<type ==aJson_Object) // if some polling configured if (store->pollingRegisters || store->pollingIrs || store->pollingCoils || store->poolingDiscreteIns) { - debugSerial<itemArr->name << endl; + traceSerial<itemArr->name << endl; modbusBusy=1; if (!lineInitialized) @@ -732,7 +732,7 @@ if (store->pollingRegisters || store->pollingIrs || store->pollingCoils || store pollModbus(store->pollingIrs,MODBUS_INPUT_REG_TYPE); pollModbus(store->pollingCoils,MODBUS_COIL_REG_TYPE); pollModbus(store->poolingDiscreteIns ,MODBUS_DISCRETE_REG_TYPE); - debugSerial<itemArr->name << endl; + traceSerial<itemArr->name << endl; //Non blocking waiting to release line uint32_t time = millis(); @@ -794,7 +794,7 @@ aJsonObject * mapObj = aJson.getObjectItem(templateParamObj, "map"); Value=cmdValue.getTens_raw()*(100/TENS_BASE); } -debugSerial<itemArg, 2); if (itemParametersObj && itemParametersObj->type ==aJson_Object) { diff --git a/lighthub/owTerm.cpp b/lighthub/owTerm.cpp index 9845d06..982a7cd 100644 --- a/lighthub/owTerm.cpp +++ b/lighthub/owTerm.cpp @@ -226,11 +226,11 @@ int sensors_loop(void) { case DS2482_ERROR_CONFIG: errorSerial<wireReset(); - return INTERVAL_1W; + i2cReset(); + break; case DS2482_ERROR_TIMEOUT: - errorSerial<wireReset(); return INTERVAL_1W; diff --git a/lighthub/streamlog.h b/lighthub/streamlog.h index 9556b54..4077b71 100644 --- a/lighthub/streamlog.h +++ b/lighthub/streamlog.h @@ -24,10 +24,12 @@ extern uint8_t udpDebugLevel; #define SerialPortType HardwareSerial #endif +#define LOG_TRACE 9 #define LOG_DEBUG 7 #define LOG_INFO 6 #define LOG_ERROR 3 +#define traceSerial if (serialDebugLevel>=LOG_TRACE || udpDebugLevel>=LOG_TRACE) debugSerial class Streamlog : public Print { public: