From: He Yin Ling <heyinling@espressif.com>
Date: Fri, 9 Mar 2018 09:42:08 +0000 (+0800)
Subject: iperf example: add cmd to trace max heap usage
X-Git-Tag: v3.1-beta1~145^2~3
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f7bb5c8f42721ea963d02634080447c0cae24581;p=esp-idf

iperf example: add cmd to trace max heap usage
---

diff --git a/examples/wifi/iperf/main/cmd_wifi.c b/examples/wifi/iperf/main/cmd_wifi.c
index e26900dfb7..3407e99e98 100644
--- a/examples/wifi/iperf/main/cmd_wifi.c
+++ b/examples/wifi/iperf/main/cmd_wifi.c
@@ -314,6 +314,13 @@ static int restart(int argc, char** argv)
     ESP_LOGI(TAG, "Restarting");
     esp_restart();
 }
+
+static int heap_size(int argc, char** argv)
+{
+    uint32_t heap_size = heap_caps_get_minimum_free_size(MALLOC_CAP_DEFAULT);
+    ESP_LOGI(TAG, "min heap size: %u", heap_size);
+    return 0;
+}
  
 void register_wifi()
 {
@@ -378,4 +385,12 @@ void register_wifi()
     };
 
     ESP_ERROR_CHECK( esp_console_cmd_register(&iperf_cmd) );
+
+    const esp_console_cmd_t heap_cmd = {
+        .command = "heap",
+        .help = "get min free heap size druing test",
+        .hint = NULL,
+        .func = &heap_size,
+    };
+    ESP_ERROR_CHECK( esp_console_cmd_register(&heap_cmd) );
 }