mirror of
https://github.com/esphome/esphome.git
synced 2025-07-31 23:47:47 +00:00
wip
This commit is contained in:
parent
4c1111a395
commit
fcdf209ac3
@ -41,22 +41,65 @@ extern "C" void dump_task_heap_info() {
|
|||||||
ESP_LOGI("HEAP", "Total blocks: %u", info.total_blocks);
|
ESP_LOGI("HEAP", "Total blocks: %u", info.total_blocks);
|
||||||
ESP_LOGI("HEAP", "-------------------------------------");
|
ESP_LOGI("HEAP", "-------------------------------------");
|
||||||
|
|
||||||
// Get information about running tasks
|
// Get information about running tasks with a much larger buffer to prevent overflow
|
||||||
char buffer[128];
|
// The FreeRTOS functions don't provide a way to check buffer size requirements in advance
|
||||||
|
static char buffer[2048];
|
||||||
|
|
||||||
|
// Zero out the buffer for safety
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
|
||||||
|
// Get task list
|
||||||
vTaskList(buffer);
|
vTaskList(buffer);
|
||||||
|
|
||||||
ESP_LOGI("HEAP", "Task Information:");
|
// Check if buffer has valid content
|
||||||
ESP_LOGI("HEAP", "Name State Priority Stack Num");
|
if (buffer[0] != '\0') {
|
||||||
ESP_LOGI("HEAP", "-------------------------------------");
|
ESP_LOGI("HEAP", "Task Information:");
|
||||||
ESP_LOGI("HEAP", "%s", buffer);
|
ESP_LOGI("HEAP", "Name State Priority Stack Num");
|
||||||
|
ESP_LOGI("HEAP", "-------------------------------------");
|
||||||
|
|
||||||
|
// Process the buffer line by line to add the log prefix to each line
|
||||||
|
char *line = strtok(buffer, "\n\r");
|
||||||
|
int count = 0;
|
||||||
|
while (line != nullptr && strlen(line) > 0 && count < 20) {
|
||||||
|
ESP_LOGI("HEAP", "%s", line);
|
||||||
|
line = strtok(nullptr, "\n\r");
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ESP_LOGE("HEAP", "Could not get task information");
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOGI("HEAP", "-------------------------------------");
|
ESP_LOGI("HEAP", "-------------------------------------");
|
||||||
|
|
||||||
// Additional runtime statistics about tasks
|
// Runtime statistics - use a separate section with a different buffer to avoid corruption
|
||||||
vTaskGetRunTimeStats(buffer);
|
static char stats_buffer[2048];
|
||||||
ESP_LOGI("HEAP", "Task Runtime Statistics:");
|
memset(stats_buffer, 0, sizeof(stats_buffer));
|
||||||
ESP_LOGI("HEAP", "Name Time Percentage");
|
|
||||||
ESP_LOGI("HEAP", "-------------------------------------");
|
// Get runtime stats
|
||||||
ESP_LOGI("HEAP", "%s", buffer);
|
vTaskGetRunTimeStats(stats_buffer);
|
||||||
|
|
||||||
|
// Check if buffer has valid content
|
||||||
|
if (stats_buffer[0] != '\0') {
|
||||||
|
ESP_LOGI("HEAP", "Task Runtime Statistics:");
|
||||||
|
ESP_LOGI("HEAP", "Name Time Percentage");
|
||||||
|
ESP_LOGI("HEAP", "-------------------------------------");
|
||||||
|
|
||||||
|
// Process the runtime stats buffer line by line safely
|
||||||
|
char *line = strtok(stats_buffer, "\n\r");
|
||||||
|
int count = 0;
|
||||||
|
// Limit to 20 lines to prevent buffer overruns
|
||||||
|
while (line != nullptr && count < 20) {
|
||||||
|
// Skip empty lines
|
||||||
|
if (strlen(line) > 0) {
|
||||||
|
ESP_LOGI("HEAP", "%s", line);
|
||||||
|
}
|
||||||
|
line = strtok(nullptr, "\n\r");
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ESP_LOGE("HEAP", "Could not get task runtime statistics");
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOGI("HEAP", "-------------------------------------");
|
ESP_LOGI("HEAP", "-------------------------------------");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,6 +19,8 @@ api:
|
|||||||
standalone: true
|
standalone: true
|
||||||
# Number of trace records to keep (more records = more memory usage)
|
# Number of trace records to keep (more records = more memory usage)
|
||||||
num_records: 100
|
num_records: 100
|
||||||
|
# Enable task statistics tracking (shows task names, stack usage, etc.)
|
||||||
|
task_tracking: true
|
||||||
|
|
||||||
# Enable OTA updates
|
# Enable OTA updates
|
||||||
ota:
|
ota:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user