diff --git a/CHANGELOG.md b/CHANGELOG.md index cfbb32efb..e627937f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,14 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Development -## [9.2.0.3] +## [9.2.0.4] +### Added +- Function ``AddLog`` to provide logging for up to 128 (LOGSZ) characters to save stack space + +### Changed +- Maximum chars in ``AddLog_P`` logging restored from 128 to 700 (MAX_LOGSZ) to solve broken error messages + +## [9.2.0.3] 20210122 ### Added - Support for time proportioned (``#define USE_TIMEPROP``) and optional PID (``#define USE_PID``) relay control (#10412) - Support rotary encoder on Shelly Dimmer (#10407) @@ -55,7 +62,7 @@ All notable changes to this project will be documented in this file. - Replaced RA8876 GPIO selection from ``SPI CS`` by ``RA8876 CS`` ### Changed -- Maximum chars in AddLog_P logging reduced from 700 to 128 (LOGSZ) to enhance stability +- Maximum chars in ``AddLog_P`` logging reduced from 700 to 128 (LOGSZ) to enhance stability - Disabled ``USE_LIGHT`` light support for ZBBridge saving 17.6kB (#10374) ## [9.2.0.1] 20201229 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 558c87910..baf6f75b9 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -56,7 +56,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota [Complete list](BUILDS.md) of available feature and sensors. -## Changelog v9.2.0.3 +## Changelog v9.2.0.4 ### Added - Command ``CTRange`` to specify the visible CT range the bulb is capable of [#10311](https://github.com/arendst/Tasmota/issues/10311) - Command ``RuleTimer0`` to access all RuleTimers at once [#10352](https://github.com/arendst/Tasmota/issues/10352) diff --git a/tasmota/support.ino b/tasmota/support.ino index aac0aee21..984dc49bf 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -2204,8 +2204,8 @@ void AddLogData(uint32_t loglevel, const char* log_data) { } } -void AddLog_P(uint32_t loglevel, PGM_P formatP, ...) -{ +void AddLog(uint32_t loglevel, PGM_P formatP, ...) { + // To save stack space support logging for max text length of 128 characters char log_data[LOGSZ +4]; va_list arg; @@ -2219,13 +2219,25 @@ void AddLog_P(uint32_t loglevel, PGM_P formatP, ...) static uint32_t max_len = 0; if (len > max_len) { max_len = len; - Serial.printf("PRF: AddLog_P %d\n", max_len); + Serial.printf("PRF: AddLog %d\n", max_len); } #endif AddLogData(loglevel, log_data); } +void AddLog_P(uint32_t loglevel, PGM_P formatP, ...) { + // Use more stack space to support logging for max text length of 700 characters + char log_data[MAX_LOGSZ]; + + va_list arg; + va_start(arg, formatP); + uint32_t len = vsnprintf_P(log_data, sizeof(log_data), formatP, arg); + va_end(arg); + + AddLogData(loglevel, log_data); +} + void AddLog_Debug(PGM_P formatP, ...) { char log_data[MAX_LOGSZ]; @@ -2235,15 +2247,6 @@ void AddLog_Debug(PGM_P formatP, ...) uint32_t len = vsnprintf_P(log_data, sizeof(log_data), formatP, arg); va_end(arg); -#ifdef DEBUG_TASMOTA_CORE - // Profile max_len - static uint32_t max_len = 0; - if (len > max_len) { - max_len = len; - Serial.printf("PRF: AddLog_Debug %d\n", max_len); - } -#endif - AddLogData(LOG_LEVEL_DEBUG, log_data); } diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h index d4b504f4f..f0a110311 100644 --- a/tasmota/tasmota_version.h +++ b/tasmota/tasmota_version.h @@ -20,6 +20,6 @@ #ifndef _TASMOTA_VERSION_H_ #define _TASMOTA_VERSION_H_ -const uint32_t VERSION = 0x09020003; +const uint32_t VERSION = 0x09020004; #endif // _TASMOTA_VERSION_H_ diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index 5589868de..499a29c44 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -184,29 +184,26 @@ bool TimepropCommand() bool serviced = true; uint8_t ua_prefix_len = strlen(D_CMND_TIMEPROP); // to detect prefix of command /* - snprintf_P(log_data, sizeof(log_data), "Command called: " - "index: %d data_len: %d payload: %d topic: %s data: %s\n", + AddLog_P(LOG_LEVEL_INFO, PSTR("Command called: " + "index: %d data_len: %d payload: %d topic: %s data: %s"), XdrvMailbox.index, XdrvMailbox.data_len, XdrvMailbox.payload, (XdrvMailbox.payload >= 0 ? XdrvMailbox.topic : ""), (XdrvMailbox.data_len >= 0 ? XdrvMailbox.data : "")); - - AddLog(LOG_LEVEL_INFO); */ if (0 == strncasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_TIMEPROP), ua_prefix_len)) { // command starts with timeprop_ int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic + ua_prefix_len, kTimepropCommands); if (CMND_TIMEPROP_SETPOWER == command_code) { /* - snprintf_P(log_data, sizeof(log_data), "Timeprop command timeprop_setpower: " - "index: %d data_len: %d payload: %d topic: %s data: %s", + AddLog_P(LOG_LEVEL_INFO, PSTR("Timeprop command timeprop_setpower: " + "index: %d data_len: %d payload: %d topic: %s data: %s"), XdrvMailbox.index, XdrvMailbox.data_len, XdrvMailbox.payload, (XdrvMailbox.payload >= 0 ? XdrvMailbox.topic : ""), (XdrvMailbox.data_len >= 0 ? XdrvMailbox.data : "")); - AddLog(LOG_LEVEL_INFO); */ if (XdrvMailbox.index >=0 && XdrvMailbox.index < TIMEPROP_NUM_OUTPUTS) { timeprops[XdrvMailbox.index].setPower( atof(XdrvMailbox.data), Tprop.current_time_secs );