ESP32日志报文打印API测试,掌握Debug,Info,Warn以及Error四种日志报文输出,获取ESP32芯片相关信息并打印输出
1.日志打印API介绍
函数名 | 描述 | 案例 |
---|---|---|
esp_chip_info(esp_chip_info_t* info) |
info:芯片信息结构体指针 | esp_chip_info(&info) |
ESP_LOGI(const char* tag,char* format_msg) |
打印信息: [tag:format_msg] | ESP_LOGI("Info","This is a Information"); ESP_LOGI("Info","ESP32 Chip Cores Count: %d",chip_info.cores); ESP_LOGI("Info","ESP32 Chip, WiFi%s%s,",(chip_info.features & CHIP_FEATURE_BT)?"/BT":"",(chip_info.features&CHIP_FEATURE_BLE) ? "/BLE":""); ESP_LOGI("Info","SPI Flash Chip Size: %dMByte %s flash",spi_flash_get_chip_size()/(1024*1024),(chip_info.features & CHIP_FEATURE_EMB_FLASH)?"Embedded" : "External"); |
esp_base_mac_addr_get(uint8_t MAC[6]) |
WiFi的MAC地址 | esp_base_mac_addr_get(MAC) ESP_LOGI("Info", "Base MAC Addr : %02X.%02X.%02X.%02X.%02X.%02X",MAC[0],MAC[1],MAC[2],MAC[3],MAC[4],MAC[5]); |
ESP_LOGW(const char* tag,char* msg) | 打印报警:[tag,msg] | ESP_LOGW(“Warn”, “This is a Warn”) |
ESP_LOGE(const char* tag,char* msg) | 打印错误:[tag,msg] | ESP_LOGE(“Error”, “This is a Error”) |
ESP_LOGD (const char* tag,char* msg) | 打印调试:[tag,msg] | ESP_LOGD(“Debug”, “This is a Debug”) |
ESP_LOGV(const char* tag,char* msg) | 详细:[tag,msg] | ESP_LOGV(“Detial”, “This is a Detail”) |
esp_restart() | 软件复位 | esp_restart(); |
2.功能设计
Info:CPU基本信息 如Flash Size,Core Num,RAM Size等
打印输出: Warn,Error信息
代码
1 |
|
Post not found: ESP32-LED输出结果