Skip to content

fix DEBUG macros #5728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cores/esp8266/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include <stdint.h>

#ifdef DEBUG_ESP_CORE
#define DEBUGV(...) ets_printf(__VA_ARGS__)
#define DEBUGV(fmt, ...) ::printf_P( (PGM_P)PSTR(fmt), ## __VA_ARGS__)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be the same as others (i.e. DEBUG_ESP_PORT.printf(...)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ets_printf is safe to call in any context (such as system), but DEBUG_ESP_PORT.printf could yield, which would not work in sys context?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to ::printf_P so we can use fmt arguments from flash.
I assume ::printf_P uses putchar installed by ets_install_putc1/putc2 in debug mode like, ets_printf does.
(should the others use ::printf_P instead of Serial.printf_P ?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@igrr Were you suggesting to remove (legacy) DEBUG_ESP_PORT.printf and use DEBUGV instead ?
About sys context, I believe new newlib's ::vsnprintf() and fw's ets_putc() are safe (no yield).

#endif

#ifndef DEBUGV
#define DEBUGV(...)
#define DEBUGV(...) do { (void)0; } while (0)
#endif

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#endif

#ifndef DEBUG_HTTPCLIENT
#define DEBUG_HTTPCLIENT(...)
#define DEBUG_HTTPCLIENT(...) do { (void)0; } while (0)
#endif

#define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (5000)
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern "C" {
#endif

#ifndef DEBUG_WIFI
#define DEBUG_WIFI(...)
#define DEBUG_WIFI(...) do { (void)0; } while (0)
#endif


Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

#ifdef DEBUG_ESP_WIFI
#ifdef DEBUG_ESP_PORT
#define DEBUG_WIFI_GENERIC(fmt, ...) DEBUG_ESP_PORT.printf( (PGM_P)PSTR(fmt), ##__VA_ARGS__ )
#define DEBUG_WIFI_GENERIC(fmt, ...) DEBUG_ESP_PORT.printf_P( (PGM_P)PSTR(fmt), ##__VA_ARGS__ )
#endif
#endif

#ifndef DEBUG_WIFI_GENERIC
#define DEBUG_WIFI_GENERIC(...)
#define DEBUG_WIFI_GENERIC(...) do { (void)0; } while (0)
#endif

struct WiFiEventHandlerOpaque;
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFi/src/ESP8266WiFiMulti.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

#ifdef DEBUG_ESP_WIFI
#ifdef DEBUG_ESP_PORT
#define DEBUG_WIFI_MULTI(fmt, ...) DEBUG_ESP_PORT.printf( (PGM_P)PSTR(fmt), ##__VA_ARGS__ )
#define DEBUG_WIFI_MULTI(fmt, ...) DEBUG_ESP_PORT.printf_P( (PGM_P)PSTR(fmt), ##__VA_ARGS__ )
#endif
#endif

#ifndef DEBUG_WIFI_MULTI
#define DEBUG_WIFI_MULTI(...)
#define DEBUG_WIFI_MULTI(...) do { (void)0; } while (0)
#endif

struct WifiAPEntry {
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@

#ifdef DEBUG_ESP_HTTP_UPDATE
#ifdef DEBUG_ESP_PORT
#define DEBUG_HTTP_UPDATE(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )
#define DEBUG_HTTP_UPDATE(fmt, ...) DEBUG_ESP_PORT.printf_P( (PGM_P)PSTR(fmt), ## __VA_ARGS__ )
#endif
#endif

#ifndef DEBUG_HTTP_UPDATE
#define DEBUG_HTTP_UPDATE(...)
#define DEBUG_HTTP_UPDATE(...) do { (void)0; } while(0)
#endif

/// note we use HTTP client errors too so we start at 100
Expand Down