subitem retrieve fix, new loglev 9 for mbus trace

This commit is contained in:
2023-11-15 11:02:53 +03:00
parent fd65c1a3a1
commit 9683e51c18
4 changed files with 15 additions and 13 deletions

View File

@@ -106,7 +106,7 @@ int subitem2cmd(char *payload) {
int txt2subItem(char *payload) {
if (!payload || !strlen(payload)) return S_NOTFOUND;
for(uint8_t i=1; i<suffixNum ;i++)
if (strncmp_P(payload, suffix_P[i], strlen_P(suffix_P[i])) == 0)
if (strcmp_P(payload, suffix_P[i]) == 0)
{
return i;
}
@@ -495,7 +495,7 @@ void Item::setExt(long int par) // Only store if VAL is int (autogenerated or c
if(itemExt->type == aJson_NULL) itemExt->type=aJson_Int;
else if(itemExt->type != aJson_Int ) return;
itemExt->valueint = par;
debugSerial<<F("Stored EXT:")<<par<<endl;
//debugSerial<<F("Stored EXT:")<<par<<endl;
}
@@ -1472,7 +1472,7 @@ if ((!driver || driver->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<<F(" T:")<<tStore.tempX100<<F(" TS:")<<tStore.timestamp16<<endl;
//debugSerial<<F(" T:")<<tStore.tempX100<<F(" TS:")<<tStore.timestamp16<<endl;
setExt(tStore.asint);
res=1;
}

View File

@@ -327,7 +327,7 @@ itemCmd out_Modbus::findRegister(uint16_t registerNum, uint16_t posInBuffer, uin
mappedParam.Int((uint32_t)param);
}
debugSerial << F("MBUSD: got ")<<mappedParam.toString(buf,sizeof(buf))<< F(" from type ")<<parType<<F(":")<<paramObj->name<<endl;
traceSerial << F("MBUSD: got ")<<mappedParam.toString(buf,sizeof(buf))<< F(" from type ")<<parType<<F(":")<<paramObj->name<<endl;
if (mapObj && (mapObj->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:")<<mappedParam.toString(buf,sizeof(buf))<<endl;
traceSerial << F("MBUSD: NestedMapped:")<<mappedParam.toString(buf,sizeof(buf))<<endl;
if (!(lastMeasured->subtype & MB_VALUE_OUTDATED))
{
@@ -449,7 +449,7 @@ itemCmd out_Modbus::findRegister(uint16_t registerNum, uint16_t posInBuffer, uin
*/
}
else
debugSerial << F("MBUSD: Mapped:")<<mappedParam.toString(buf,sizeof(buf))<<endl;
traceSerial << F("MBUSD: Mapped:")<<mappedParam.toString(buf,sizeof(buf))<<endl;
} //mapping
if (doExecution && idObj && idObj->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<<F("MBUSD: Ignored - equal with setted val")<<endl;
traceSerial<<F("MBUSD: Ignored - equal with setted val")<<endl;
*submitParam=false;
}
else
@@ -719,7 +719,7 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object)
// if some polling configured
if (store->pollingRegisters || store->pollingIrs || store->pollingCoils || store->poolingDiscreteIns)
{
debugSerial<<F("MBUSD: Poll ")<< item->itemArr->name << endl;
traceSerial<<F("MBUSD: Poll ")<< item->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<<F("MBUSD: endPoll ")<< item->itemArr->name << endl;
traceSerial<<F("MBUSD: endPoll ")<< item->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<<F("MBUSD: suffix:")<<suffixStr<< F(" Val: ")<<Value<<endl;
traceSerial<<F("MBUSD: suffix:")<<suffixStr<< F(" Val: ")<<Value<<endl;
aJsonObject * itemParametersObj = aJson.getArrayItem(item->itemArg, 2);
if (itemParametersObj && itemParametersObj->type ==aJson_Object)
{

View File

@@ -226,11 +226,11 @@ int sensors_loop(void) {
case DS2482_ERROR_CONFIG:
errorSerial<<F("1WT: DS2482_ERROR_CONFIG")<<endl;
oneWire->wireReset();
return INTERVAL_1W;
i2cReset();
break;
case DS2482_ERROR_TIMEOUT:
errorSerial<<F("1WT: 1-wire shorted")<<endl;
errorSerial<<F("1WT: timeout")<<endl;
oneWire->wireReset();
return INTERVAL_1W;

View File

@@ -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: