fredlcore / BSB-LAN

LAN/WiFi interface for Boiler-System-Bus (BSB) and Local Process Bus (LPB) and Punkt-zu-Punkt Schnittstelle (PPS) with a Siemens® controller used by Elco®, Brötje® and similar heating systems
222 stars 84 forks source link

[BUG] logging unknown parameter crashes system #507

Closed DE-cr closed 1 year ago

DE-cr commented 1 year ago

BSB-LAN Version Current (30Oct2022) GitHub master sources

Architecture ESP32 NodeMCU

Bus system BSB

Describe the bug Trying to log unknown parameters resets the system (and does not log values).

To Reproduce I re-enabled "SD card" logging of parameters I had logged before. When the time came to log their values, the system went through a reset. The problem seems to be that I'm now running BSB-LAN with a tailored BSB_LAN_custom_defs.h, which does not contain parameter 8760 anymore (which did work before the custom_defs). Including this parameter in logging leads to the reset on my system.

fredlcore commented 1 year ago

Thanks for reporting this, I had this problem elsewhere and fixed it there, but I'm currently away from home, so I can't test this: Could you please make these changes at around line 6646 in BSB_LAN.ino: Instead of

          query(log_parameters[i]);
          outBufLen = 0;

if should be

          query(log_parameters[i]);
          if (decodedTelegram.prognr < 0) continue;
          outBufLen = 0;

This should skip non-existing parameters.

DE-cr commented 1 year ago

Thanks for the quick fix proposal!

It worked almost as expected: The system didn't crash anymore ... but the log contained incomplete lines, like this (parameter 8760):

Milliseconds;Date;Parameter;Description;Value;Unit
241919;31.10.2022 20:50:44;20050.0;24h Durchschnittswert. Aussentemperatur;12.7;°C
241920;31.10.2022 20:50:44;20051.0;24h Durchschnittswert. Zustand Trinkwasserpumpe (Q3);255.0;
241921;31.10.2022 20:50:44;20052.0;24h Durchschnittswert. Vorlauftemperatur Istwert Heizkreis 2;34.6;°C
241921;31.10.2022 20:50:44;8773.0;Vorlauftemperatur Istwert Heizkreis 2;34.6;°C
242272;31.10.2022 20:50:44;8760.0;362612;31.10.2022 20:52:44;20050.0;24h Durchschnittswert. Aussentemperatur;12.7;°C
362613;31.10.2022 20:52:44;20051.0;24h Durchschnittswert. Zustand Trinkwasserpumpe (Q3);255.0;
362614;31.10.2022 20:52:44;20052.0;24h Durchschnittswert. Vorlauftemperatur Istwert Heizkreis 2;34.5;°C
362614;31.10.2022 20:52:44;8773.0;Vorlauftemperatur Istwert Heizkreis 2;34.3;°C
362810;31.10.2022 20:52:44;8760.0;

This led to curious legends in /DG plots: an entry for parameter 8760.0 without a name and an entry for "8760.0 - 36261" (i.e. parameter name "36261").

A better fix seems to be https://github.com/DE-cr/BSB-LAN/commit/297dc5ad3d91c2731d1761f4b7dea34f701cd302 which avoids logging unknown parameters completely.

fredlcore commented 1 year ago

Thanks, I've taken up your fix as I still haven't decided about your SD card PR, so the others don't have to live with this error until I've had time to deal with this.