2018-02-01 12:14:47 +00:00
|
|
|
@COMMENT@
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#if __has_include("soc/soc.h")
|
|
|
|
#include "soc/soc.h"
|
|
|
|
#endif
|
|
|
|
@HEADERS@
|
|
|
|
|
2018-02-22 12:46:55 +00:00
|
|
|
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
2018-02-01 12:14:47 +00:00
|
|
|
#define ERR_TBL_IT(err) {err, #err}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
esp_err_t code;
|
|
|
|
const char *msg;
|
|
|
|
} esp_err_msg_t;
|
|
|
|
|
|
|
|
static const esp_err_msg_t esp_err_msg_table[] = {
|
|
|
|
@ERROR_ITEMS@
|
|
|
|
};
|
2018-02-22 12:46:55 +00:00
|
|
|
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
2018-02-01 12:14:47 +00:00
|
|
|
|
2018-02-22 12:46:55 +00:00
|
|
|
static const char esp_unknown_msg[] =
|
|
|
|
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
|
|
|
"ERROR";
|
|
|
|
#else
|
|
|
|
"UNKNOWN ERROR";
|
|
|
|
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
2018-02-01 12:14:47 +00:00
|
|
|
|
|
|
|
const char *esp_err_to_name(esp_err_t code)
|
|
|
|
{
|
2018-02-22 12:46:55 +00:00
|
|
|
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
2018-02-01 12:14:47 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(esp_err_msg_table)/sizeof(esp_err_msg_table[0]); ++i) {
|
|
|
|
if (esp_err_msg_table[i].code == code) {
|
|
|
|
return esp_err_msg_table[i].msg;
|
|
|
|
}
|
|
|
|
}
|
2018-02-22 12:46:55 +00:00
|
|
|
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
2018-02-01 12:14:47 +00:00
|
|
|
|
|
|
|
return esp_unknown_msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *esp_err_to_name_r(esp_err_t code, char *buf, size_t buflen)
|
|
|
|
{
|
2018-02-22 12:46:55 +00:00
|
|
|
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
2018-02-01 12:14:47 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(esp_err_msg_table)/sizeof(esp_err_msg_table[0]); ++i) {
|
|
|
|
if (esp_err_msg_table[i].code == code) {
|
|
|
|
strlcpy(buf, esp_err_msg_table[i].msg, buflen);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
}
|
2018-02-22 12:46:55 +00:00
|
|
|
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
2018-02-01 12:14:47 +00:00
|
|
|
|
|
|
|
if (strerror_r(code, buf, buflen) == 0) {
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2018-06-11 12:52:30 +00:00
|
|
|
snprintf(buf, buflen, "%s 0x%x(%d)", esp_unknown_msg, code, code);
|
2018-02-01 12:14:47 +00:00
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|