8000 docs/library/esp: Correct the description of esp.osdebug(). · micropython/micropython@a800ed5 · GitHub
[go: up one dir, main page]

Skip to content

Commit a800ed5

Browse files
projectgusdpgeorge
authored andcommitted
docs/library/esp: Correct the description of esp.osdebug().
The behaviour described in the docs was not correct for either port. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent 917b561 commit a800ed5

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

docs/library/esp.rst

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,35 @@ Functions
6262

6363
.. function:: flash_erase(sector_no)
6464

65-
.. function:: osdebug(level)
65+
.. function:: osdebug(uart_no)
6666

67-
Turn esp os debugging messages on or off.
67+
.. note:: This is the ESP8266 form of this function.
6868

69-
The *level* parameter sets the threshold for the log messages for all esp components.
70-
The log levels are defined as constants:
69+
Change the level of OS serial debug log messages. On boot,
70+
OS serial debug log messages are disabled.
71+
72+
``uart_no`` is the number of the UART peripheral which should receive
73+
OS-level output, or ``None`` to disable OS serial debug log messages.
74+
75+
.. function:: osdebug(uart_no, [level])
76+
:no-index:
77+
78+
.. note:: This is the ESP32 form of this function.
79+
80+
Change the level of OS serial debug log messages. On boot, OS
81+
serial debug log messages are limited to Error output only.
82+
83+
The behaviour of this function depends on the arguments passed to it. The
84+
following combinations are supported:
85+
86+
``osdebug(None)`` restores the default OS debug log message level
87+
(``LOG_ERROR``).
88+
89+
``osdebug(0)`` enables all available OS debug log messages (in the
90+
default build configuration this is ``LOG_INFO``).
91+
92+
``osdebug(0, level)`` sets the OS debug log message level to the
93+
specified value. The log levels are defined as constants:
7194

7295
* ``LOG_NONE`` -- No log output
7396
* ``LOG_ERROR`` -- Critical errors, software module can not recover on its own
@@ -77,6 +100,15 @@ Functions
77100
* ``LOG_VERBOSE`` -- Bigger chunks of debugging information, or frequent messages
78101
which can potentially flood the output
79102

103+
.. note:: ``LOG_DEBUG`` and ``LOG_VERBOSE`` are not compiled into the
104+
MicroPython binary by default, to save size. A custom build with a
105+
modified "``sdkconfig``" source file is needed to see any output
106+
at these log levels.
107+
108+
.. note:: Log output on ESP32 is automatically suspended in "Raw REPL" mode,
109+
to prevent communications issues. This means OS level logging is never
110+
seen when using ``mpremote run`` and similar tools.
111+
80112
.. function:: set_native_code_location(start, length)
81113

82114
**Note**: ESP8266 only

ports/esp32/modesp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
#include "py/mphal.h"
3838

3939
STATIC mp_obj_t esp_osdebug(size_t n_args, const mp_obj_t *args) {
40-
esp_log_level_t level = LOG_LOCAL_LEVEL;
40+
esp_log_level_t level = LOG_LOCAL_LEVEL; // Maximum available level
4141
if (n_args == 2) {
4242
level = mp_obj_get_int(args[1]);
4343
}
4444
if (args[0] == mp_const_none) {
45-
// Disable logging
45+
// Set logging back to boot default of ESP_LOG_ERROR
4646
esp_log_level_set("*", ESP_LOG_ERROR);
4747
} else {
4848
// Enable logging at the given level

0 commit comments

Comments
 (0)
0