mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 11:16:34 +00:00
Allocate ESP8266 log buffer in iram heap space if available
This commit is contained in:
parent
f628a2d4a2
commit
99a8c3d06a
@ -8,11 +8,13 @@ All notable changes to this project will be documented in this file.
|
||||
- Preliminary support for Esp32C3 - RiscV based
|
||||
|
||||
### Changed
|
||||
- NeoPixelBus library from v2.6.1.4 to v2.6.3 stage
|
||||
- Allow longer MQTT response messages by removing fixed memory buffer with size 1040 to heap allocated buffer
|
||||
- Command ``Timers`` layout of JSON message changed to single line
|
||||
- Command ``Gpio`` layout of JSON message changed to single line
|
||||
- Command ``Modules`` layout of JSON message changed to single line
|
||||
- I2C extended MPU6886 to also support MPU9250 (found in Legacy M5Stack Fire)
|
||||
- ESP32 increase log buffer from 4k to 6k to support longer messages
|
||||
|
||||
## [9.4.0.4]
|
||||
### Added
|
||||
|
@ -95,10 +95,12 @@ The binaries can be downloaded from either https://github.com/arendst/Tasmota/tr
|
||||
|
||||
### Changed
|
||||
- IRremoteESP8266 library from v2.7.16 to v2.7.18
|
||||
- NeoPixelBus library from v2.6.1.4 to v2.6.3 stage
|
||||
- Allow longer MQTT response messages by removing fixed memory buffer with size 1040 to heap allocated buffer
|
||||
- Command ``Timers`` layout of JSON message changed to single line
|
||||
- Command ``Gpio`` layout of JSON message changed to single line
|
||||
- Command ``Modules`` layout of JSON message changed to single line
|
||||
- ESP32 increase log buffer from 4k to 6k to support longer messages
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -2261,6 +2261,7 @@ void SyslogAsync(bool refresh) {
|
||||
}
|
||||
|
||||
bool NeedLogRefresh(uint32_t req_loglevel, uint32_t index) {
|
||||
if (!TasmotaGlobal.log_buffer) { return false; } // Leave now if there is no buffer available
|
||||
|
||||
#ifdef ESP32
|
||||
// this takes the mutex, and will be release when the class is destroyed -
|
||||
@ -2278,9 +2279,10 @@ bool NeedLogRefresh(uint32_t req_loglevel, uint32_t index) {
|
||||
}
|
||||
|
||||
bool GetLog(uint32_t req_loglevel, uint32_t* index_p, char** entry_pp, size_t* len_p) {
|
||||
uint32_t index = *index_p;
|
||||
if (!TasmotaGlobal.log_buffer) { return false; } // Leave now if there is no buffer available
|
||||
if (TasmotaGlobal.uptime < 3) { return false; } // Allow time to setup correct log level
|
||||
|
||||
if (TasmotaGlobal.uptime < 3) { return false; } // Allow time to setup correct log level
|
||||
uint32_t index = *index_p;
|
||||
if (!req_loglevel || (index == TasmotaGlobal.log_buffer_pointer)) { return false; }
|
||||
|
||||
#ifdef ESP32
|
||||
@ -2348,6 +2350,8 @@ void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_pa
|
||||
Serial.printf("%s%s%s%s\r\n", mxtime, log_data, log_data_payload, log_data_retained);
|
||||
}
|
||||
|
||||
if (!TasmotaGlobal.log_buffer) { return; } // Leave now if there is no buffer available
|
||||
|
||||
uint32_t highest_loglevel = Settings.weblog_level;
|
||||
if (Settings.mqttlog_level > highest_loglevel) { highest_loglevel = Settings.mqttlog_level; }
|
||||
if (TasmotaGlobal.syslog_level > highest_loglevel) { highest_loglevel = TasmotaGlobal.syslog_level; }
|
||||
@ -2383,7 +2387,7 @@ void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_pa
|
||||
it++; // Skip delimiting "\1"
|
||||
memmove(TasmotaGlobal.log_buffer, it, LOG_BUFFER_SIZE -(it-TasmotaGlobal.log_buffer)); // Move buffer forward to remove oldest log line
|
||||
}
|
||||
snprintf_P(TasmotaGlobal.log_buffer, sizeof(TasmotaGlobal.log_buffer), PSTR("%s%c%c%s%s%s%s\1"),
|
||||
snprintf_P(TasmotaGlobal.log_buffer, LOG_BUFFER_SIZE, PSTR("%s%c%c%s%s%s%s\1"),
|
||||
TasmotaGlobal.log_buffer, TasmotaGlobal.log_buffer_pointer++, '0'+loglevel, mxtime, log_data, log_data_payload, log_data_retained);
|
||||
TasmotaGlobal.log_buffer_pointer &= 0xFF;
|
||||
if (!TasmotaGlobal.log_buffer_pointer) {
|
||||
|
@ -172,9 +172,17 @@ const uint16_t INPUT_BUFFER_SIZE = 520; // Max number of characters in seria
|
||||
const uint16_t FLOATSZ = 16; // Max number of characters in float result from dtostrfd (max 32)
|
||||
const uint16_t CMDSZ = 24; // Max number of characters in command
|
||||
const uint16_t TOPSZ = 151; // Max number of characters in topic string
|
||||
|
||||
#ifdef ESP8266
|
||||
#ifdef PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
|
||||
const uint16_t LOG_BUFFER_SIZE = 6144; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
|
||||
#else
|
||||
const uint16_t LOG_BUFFER_SIZE = 4096; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
|
||||
//const uint16_t LOG_BUFFER_SIZE = 5120; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
|
||||
//const uint16_t LOG_BUFFER_SIZE = 6144; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
|
||||
#endif // PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
|
||||
#else // Not ESP8266
|
||||
const uint16_t LOG_BUFFER_SIZE = 6144; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
|
||||
#endif // ESP8266
|
||||
|
||||
#ifdef MQTT_DATA_STRING
|
||||
const uint16_t MAX_LOGSZ = LOG_BUFFER_SIZE -96; // Max number of characters in log line - may be overruled which will truncate log entry
|
||||
#else
|
||||
|
@ -192,7 +192,16 @@ struct {
|
||||
char serial_in_buffer[INPUT_BUFFER_SIZE]; // Receive buffer
|
||||
char mqtt_client[99]; // Composed MQTT Clientname
|
||||
char mqtt_topic[TOPSZ]; // Composed MQTT topic
|
||||
char log_buffer[LOG_BUFFER_SIZE]; // Web log buffer
|
||||
|
||||
#ifdef ESP8266
|
||||
#ifdef PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
|
||||
char* log_buffer; // Log buffer in IRAM
|
||||
#else
|
||||
char log_buffer[LOG_BUFFER_SIZE]; // Log buffer in DRAM
|
||||
#endif // PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
|
||||
#else // Not ESP8266
|
||||
char log_buffer[LOG_BUFFER_SIZE]; // Log buffer in DRAM
|
||||
#endif // ESP8266
|
||||
} TasmotaGlobal;
|
||||
|
||||
#ifdef SUPPORT_IF_STATEMENT
|
||||
@ -251,6 +260,20 @@ void setup(void) {
|
||||
// Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars
|
||||
TasmotaGlobal.seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
|
||||
|
||||
#ifdef ESP8266
|
||||
#ifdef PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
|
||||
ESP.setIramHeap();
|
||||
TasmotaGlobal.log_buffer = (char*)malloc(LOG_BUFFER_SIZE); // Allocate in "new" 16k heap space
|
||||
ESP.resetHeap();
|
||||
if (TasmotaGlobal.log_buffer == nullptr) {
|
||||
TasmotaGlobal.log_buffer = (char*)malloc(LOG_BUFFER_SIZE); // Allocate in "old" heap space as fallback
|
||||
}
|
||||
if (TasmotaGlobal.log_buffer != nullptr) {
|
||||
TasmotaGlobal.log_buffer[0] = '\0';
|
||||
}
|
||||
#endif // PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
|
||||
#endif // ESP8266
|
||||
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("HDW: %s"), GetDeviceHardware().c_str());
|
||||
|
||||
#ifdef USE_UFILESYS
|
||||
|
Loading…
x
Reference in New Issue
Block a user