Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44dd99f

Browse filesBrowse files
authored
Merge branch 'master' into docs/wemos_boards
2 parents a7ea737 + b580bb2 commit 44dd99f
Copy full SHA for 44dd99f

File tree

Expand file treeCollapse file tree

2 files changed

+53
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+53
-0
lines changed

‎cores/esp32/esp32-hal-log.h

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-log.h
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,24 @@ extern "C"
6666
#define ARDUHAL_LOG_COLOR_I ARDUHAL_LOG_COLOR(ARDUHAL_LOG_COLOR_GREEN)
6767
#define ARDUHAL_LOG_COLOR_D ARDUHAL_LOG_COLOR(ARDUHAL_LOG_COLOR_CYAN)
6868
#define ARDUHAL_LOG_COLOR_V ARDUHAL_LOG_COLOR(ARDUHAL_LOG_COLOR_GRAY)
69+
#define ARDUHAL_LOG_COLOR_PRINT(letter) log_printf(ARDUHAL_LOG_COLOR_ ## letter)
70+
#define ARDUHAL_LOG_COLOR_PRINT_END log_printf(ARDUHAL_LOG_RESET_COLOR)
6971
#else
7072
#define ARDUHAL_LOG_COLOR_E
7173
#define ARDUHAL_LOG_COLOR_W
7274
#define ARDUHAL_LOG_COLOR_I
7375
#define ARDUHAL_LOG_COLOR_D
7476
#define ARDUHAL_LOG_COLOR_V
7577
#define ARDUHAL_LOG_RESET_COLOR
78+
#define ARDUHAL_LOG_COLOR_PRINT(letter)
79+
#define ARDUHAL_LOG_COLOR_PRINT_END
7680
#endif
7781

7882

7983

8084
const char * pathToFileName(const char * path);
8185
int log_printf(const char *fmt, ...);
86+
void log_print_buf(const uint8_t *b, size_t len);
8287

8388
#define ARDUHAL_SHORT_LOG_FORMAT(letter, format) ARDUHAL_LOG_COLOR_ ## letter format ARDUHAL_LOG_RESET_COLOR "\r\n"
8489
#define ARDUHAL_LOG_FORMAT(letter, format) ARDUHAL_LOG_COLOR_ ## letter "[%6u][" #letter "][%s:%u] %s(): " format ARDUHAL_LOG_RESET_COLOR "\r\n", (unsigned long) (esp_timer_get_time() / 1000ULL), pathToFileName(__FILE__), __LINE__, __FUNCTION__
@@ -87,78 +92,96 @@ int log_printf(const char *fmt, ...);
8792
#ifndef USE_ESP_IDF_LOG
8893
#define log_v(format, ...) log_printf(ARDUHAL_LOG_FORMAT(V, format), ##__VA_ARGS__)
8994
#define isr_log_v(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(V, format), ##__VA_ARGS__)
95+
#define log_buf_v(b,l) do{ARDUHAL_LOG_COLOR_PRINT(V);log_print_buf(b,l);ARDUHAL_LOG_COLOR_PRINT_END;}while(0)
9096
#else
9197
#define log_v(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_VERBOSE, TAG, format, ##__VA_ARGS__);}while(0)
9298
#define isr_log_v(format, ...) do {ets_printf(LOG_FORMAT(V, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
99+
#define log_buf_v(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_VERBOSE);}while(0)
93100
#endif
94101
#else
95102
#define log_v(format, ...)
96103
#define isr_log_v(format, ...)
104+
#define log_buf_v(b,l)
97105
#endif
98106

99107
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
100108
#ifndef USE_ESP_IDF_LOG
101109
#define log_d(format, ...) log_printf(ARDUHAL_LOG_FORMAT(D, format), ##__VA_ARGS__)
102110
#define isr_log_d(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(D, format), ##__VA_ARGS__)
111+
#define log_buf_d(b,l) do{ARDUHAL_LOG_COLOR_PRINT(D);log_print_buf(b,l);ARDUHAL_LOG_COLOR_PRINT_END;}while(0)
103112
#else
104113
#define log_d(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_DEBUG, TAG, format, ##__VA_ARGS__);}while(0)
105114
#define isr_log_d(format, ...) do {ets_printf(LOG_FORMAT(D, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
115+
#define log_buf_d(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_DEBUG);}while(0)
106116
#endif
107117
#else
108118
#define log_d(format, ...)
109119
#define isr_log_d(format, ...)
120+
#define log_buf_d(b,l)
110121
#endif
111122

112123
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
113124
#ifndef USE_ESP_IDF_LOG
114125
#define log_i(format, ...) log_printf(ARDUHAL_LOG_FORMAT(I, format), ##__VA_ARGS__)
115126
#define isr_log_i(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(I, format), ##__VA_ARGS__)
127+
#define log_buf_i(b,l) do{ARDUHAL_LOG_COLOR_PRINT(I);log_print_buf(b,l);ARDUHAL_LOG_COLOR_PRINT_END;}while(0)
116128
#else
117129
#define log_i(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, TAG, format, ##__VA_ARGS__);}while(0)
118130
#define isr_log_i(format, ...) do {ets_printf(LOG_FORMAT(I, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
131+
#define log_buf_i(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_INFO);}while(0)
119132
#endif
120133
#else
121134
#define log_i(format, ...)
122135
#define isr_log_i(format, ...)
136+
#define log_buf_i(b,l)
123137
#endif
124138

125139
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_WARN
126140
#ifndef USE_ESP_IDF_LOG
127141
#define log_w(format, ...) log_printf(ARDUHAL_LOG_FORMAT(W, format), ##__VA_ARGS__)
128142
#define isr_log_w(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(W, format), ##__VA_ARGS__)
143+
#define log_buf_w(b,l) do{ARDUHAL_LOG_COLOR_PRINT(W);log_print_buf(b,l);ARDUHAL_LOG_COLOR_PRINT_END;}while(0)
129144
#else
130145
#define log_w(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_WARN, TAG, format, ##__VA_ARGS__);}while(0)
131146
#define isr_log_w(format, ...) do {ets_printf(LOG_FORMAT(W, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
147+
#define log_buf_w(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_WARN);}while(0)
132148
#endif
133149
#else
134150
#define log_w(format, ...)
135151
#define isr_log_w(format, ...)
152+
#define log_buf_w(b,l)
136153
#endif
137154

138155
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_ERROR
139156
#ifndef USE_ESP_IDF_LOG
140157
#define log_e(format, ...) log_printf(ARDUHAL_LOG_FORMAT(E, format), ##__VA_ARGS__)
141158
#define isr_log_e(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(E, format), ##__VA_ARGS__)
159+
#define log_buf_e(b,l) do{ARDUHAL_LOG_COLOR_PRINT(E);log_print_buf(b,l);ARDUHAL_LOG_COLOR_PRINT_END;}while(0)
142160
#else
143161
#define log_e(format, ...) do {log_to_esp(TAG, ESP_LOG_ERROR, format, ##__VA_ARGS__);}while(0)
144162
#define isr_log_e(format, ...) do {ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
163+
#define log_buf_e(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_ERROR);}while(0)
145164
#endif
146165
#else
147166
#define log_e(format, ...)
148167
#define isr_log_e(format, ...)
168+
#define log_buf_e(b,l)
149169
#endif
150170

151171
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_NONE
152172
#ifndef USE_ESP_IDF_LOG
153173
#define log_n(format, ...) log_printf(ARDUHAL_LOG_FORMAT(E, format), ##__VA_ARGS__)
154174
#define isr_log_n(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(E, format), ##__VA_ARGS__)
175+
#define log_buf_n(b,l) do{ARDUHAL_LOG_COLOR_PRINT(E);log_print_buf(b,l);ARDUHAL_LOG_COLOR_PRINT_END;}while(0)
155176
#else
156177
#define log_n(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, TAG, format, ##__VA_ARGS__);}while(0)
157178
#define isr_log_n(format, ...) do {ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
179+
#define log_buf_n(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_ERROR);}while(0)
158180
#endif
159181
#else
160182
#define log_n(format, ...)
161183
#define isr_log_n(format, ...)
184+
#define log_buf_n(b,l)
162185
#endif
163186

164187
#include "esp_log.h"

‎cores/esp32/esp32-hal-uart.c

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-uart.c
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,36 @@ int log_printf(const char *format, ...)
669669
return len;
670670
}
671671

672+
static void log_print_buf_line(const uint8_t *b, size_t len, size_t total_len){
673+
for(size_t i = 0; i<len; i++){
674+
log_printf("%s0x%02x,",i?" ":"", b[i]);
675+
}
676+
if(total_len > 16){
677+
for(size_t i = len; i<16; i++){
678+
log_printf(" ");
679+
}
680+
log_printf(" // ");
681+
} else {
682+
log_printf(" // ");
683+
}
684+
for(size_t i = 0; i<len; i++){
685+
log_printf("%c",((b[i] >= 0x20) && (b[i] < 0x80))?b[i]:'.');
686+
}
687+
log_printf("\n");
688+
}
689+
690+
void log_print_buf(const uint8_t *b, size_t len){
691+
if(!len || !b){
692+
return;
693+
}
694+
for(size_t i = 0; i<len; i+=16){
695+
if(len > 16){
696+
log_printf("/* 0x%04X */ ", i);
697+
}
698+
log_print_buf_line(b+i, ((len-i)<16)?(len - i):16, len);
699+
}
700+
}
701+
672702
/*
673703
* if enough pulses are detected return the minimum high pulse duration + minimum low pulse duration divided by two.
674704
* This equals one bit period. If flag is true the function return inmediately, otherwise it waits for enough pulses.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.