Skip to content
Snippets Groups Projects
Commit e321e5d3 authored by Dorababu A's avatar Dorababu A
Browse files

read and serial print runtime stats

- using a freeRTOS function `vTaskGetRunTimeStats()`
parent 0e8ec6f1
No related branches found
No related tags found
No related merge requests found
......@@ -4,11 +4,11 @@
#include "esp_flash.h"
#include "esp_flash_encrypt.h"
#include "esp_freertos_hooks.h"
#include "esp_wifi.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
#include <inttypes.h>
#include "esp_wifi.h"
// Shepehrd task to print metrics
static void shepherd_task(void *args) {
......@@ -39,12 +39,19 @@ static void shepherd_task(void *args) {
mode == ESP_FLASH_ENC_MODE_DEVELOPMENT ? "DEVELOPMENT"
: "RELEASE");
}
// wifi connection status
// wifi connection status
wifi_mode_t wifi_mode;
if(esp_wifi_get_mode(&wifi_mode) == ESP_ERR_WIFI_NOT_INIT){
printf("WiFI Status : disabled \n");
} else
printf("WiFi Status : Enabled");
if (esp_wifi_get_mode(&wifi_mode) == ESP_ERR_WIFI_NOT_INIT) {
printf("WiFI Status : disabled \n");
} else
printf("WiFi Status : Enabled \n");
// Runtime Stats
/*
char pbuf[100];
vTaskGetRunTimeStats(pbuf);
printf("Run Time stats \n%s/r/n", pbuf);
*/
printf("-----------------------------------------\n");
vTaskDelay(15000 / portTICK_PERIOD_MS);
}
vTaskDelete(NULL);
......@@ -52,6 +59,6 @@ static void shepherd_task(void *args) {
esp_err_t shepherd_sniff() {
// TODO calculate optimal stack size
xTaskCreate(shepherd_task, "shepherd_task", 2048, NULL, 1, NULL);
xTaskCreate(shepherd_task, "shepherd_task", 2048, NULL, 4, NULL);
return ESP_OK;
}
......@@ -41,9 +41,23 @@ void blinky(void *pvParameter) {
}
}
void run_time_stats(void *pvParameter) {
while (1) {
// Runtime Stats
printf("--------Run time stats ---------------\n");
char pbuf[100];
vTaskGetRunTimeStats(pbuf);
printf("%s\r\n", pbuf);
printf("---------------------------------------\n");
vTaskDelay(15000 / portTICK_PERIOD_MS);
}
}
extern "C" {
void app_main() {
shepherd_sniff();
xTaskCreate(&blinky, "blinky", 4098, NULL, 5, NULL);
xTaskCreate(&blinky, "blinky", 4098, NULL, 1, NULL);
xTaskCreate(&run_time_stats, "run_time_stats", 2096, NULL, 2, NULL);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment