Skip to content

Commit 6c35a14

Browse files
committed
esp8266/ets_printf: Introduce __ets_vprintf_disable
A quick solution to serial port pollution bug. The culprit is libnet80211.a, which uses ets_printf() long after the system bootup. Set the flag from within the application to nonzero value in order to completely suppress this output. Signed-off-by: Pavel Fedin <pavel_fedin@mail.ru>
1 parent caee162 commit 6c35a14

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

components/esp8266/include/esp_libc.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ int ets_putc(int c);
6161
*/
6262
int ets_vprintf(const char *fmt, va_list ap);
6363

64+
/**
65+
* libnet80211.a produces some debug output using ets_printf(), and continues
66+
* to use this function well after bootup. If the serial port is used for other
67+
* purposes than logging, it disrupts serial communication at arbitraty moments.
68+
* The output looks like:
69+
* I (5504) wifi:state: 0 -> 2 (b0)
70+
* I (5545) wifi:state: 2 -> 3 (0)
71+
* I (5551) wifi:state: 3 -> 5 (10)
72+
* This flag is a quick stopgap solution. If set by the app, ets_vprintf() output
73+
* is completely supressed.
74+
* See https://github.com/espressif/ESP8266_RTOS_SDK/issues/1082
75+
*/
76+
extern int __ets_vprintf_disable;
77+
6478
#ifndef os_printf
6579
#define os_printf printf
6680
#endif

components/esp8266/source/ets_printf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,13 @@ static int ets_printf_int(val_attr_t * const attr, uint8_t hex)
176176
return 0;
177177
}
178178

179+
int __ets_vprintf_disable = 0;
180+
179181
int ets_vprintf(const char *fmt, va_list va)
180182
{
183+
if (__ets_vprintf_disable)
184+
return 0;
185+
181186
for (; ;) {
182187
const char *ps = fmt;
183188
val_attr_t attr;

0 commit comments

Comments
 (0)