mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 00:50:24 +08:00
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>
This commit is contained in:
parent
917b56137f
commit
a800ed5ae3
@ -62,12 +62,35 @@ Functions
|
|||||||
|
|
||||||
.. function:: flash_erase(sector_no)
|
.. function:: flash_erase(sector_no)
|
||||||
|
|
||||||
.. function:: osdebug(level)
|
.. function:: osdebug(uart_no)
|
||||||
|
|
||||||
Turn esp os debugging messages on or off.
|
.. note:: This is the ESP8266 form of this function.
|
||||||
|
|
||||||
The *level* parameter sets the threshold for the log messages for all esp components.
|
Change the level of OS serial debug log messages. On boot,
|
||||||
The log levels are defined as constants:
|
OS serial debug log messages are disabled.
|
||||||
|
|
||||||
|
``uart_no`` is the number of the UART peripheral which should receive
|
||||||
|
OS-level output, or ``None`` to disable OS serial debug log messages.
|
||||||
|
|
||||||
|
.. function:: osdebug(uart_no, [level])
|
||||||
|
:no-index:
|
||||||
|
|
||||||
|
.. note:: This is the ESP32 form of this function.
|
||||||
|
|
||||||
|
Change the level of OS serial debug log messages. On boot, OS
|
||||||
|
serial debug log messages are limited to Error output only.
|
||||||
|
|
||||||
|
The behaviour of this function depends on the arguments passed to it. The
|
||||||
|
following combinations are supported:
|
||||||
|
|
||||||
|
``osdebug(None)`` restores the default OS debug log message level
|
||||||
|
(``LOG_ERROR``).
|
||||||
|
|
||||||
|
``osdebug(0)`` enables all available OS debug log messages (in the
|
||||||
|
default build configuration this is ``LOG_INFO``).
|
||||||
|
|
||||||
|
``osdebug(0, level)`` sets the OS debug log message level to the
|
||||||
|
specified value. The log levels are defined as constants:
|
||||||
|
|
||||||
* ``LOG_NONE`` -- No log output
|
* ``LOG_NONE`` -- No log output
|
||||||
* ``LOG_ERROR`` -- Critical errors, software module can not recover on its own
|
* ``LOG_ERROR`` -- Critical errors, software module can not recover on its own
|
||||||
@ -77,6 +100,15 @@ Functions
|
|||||||
* ``LOG_VERBOSE`` -- Bigger chunks of debugging information, or frequent messages
|
* ``LOG_VERBOSE`` -- Bigger chunks of debugging information, or frequent messages
|
||||||
which can potentially flood the output
|
which can potentially flood the output
|
||||||
|
|
||||||
|
.. note:: ``LOG_DEBUG`` and ``LOG_VERBOSE`` are not compiled into the
|
||||||
|
MicroPython binary by default, to save size. A custom build with a
|
||||||
|
modified "``sdkconfig``" source file is needed to see any output
|
||||||
|
at these log levels.
|
||||||
|
|
||||||
|
.. note:: Log output on ESP32 is automatically suspended in "Raw REPL" mode,
|
||||||
|
to prevent communications issues. This means OS level logging is never
|
||||||
|
seen when using ``mpremote run`` and similar tools.
|
||||||
|
|
||||||
.. function:: set_native_code_location(start, length)
|
.. function:: set_native_code_location(start, length)
|
||||||
|
|
||||||
**Note**: ESP8266 only
|
**Note**: ESP8266 only
|
||||||
|
@ -37,12 +37,12 @@
|
|||||||
#include "py/mphal.h"
|
#include "py/mphal.h"
|
||||||
|
|
||||||
STATIC mp_obj_t esp_osdebug(size_t n_args, const mp_obj_t *args) {
|
STATIC mp_obj_t esp_osdebug(size_t n_args, const mp_obj_t *args) {
|
||||||
esp_log_level_t level = LOG_LOCAL_LEVEL;
|
esp_log_level_t level = LOG_LOCAL_LEVEL; // Maximum available level
|
||||||
if (n_args == 2) {
|
if (n_args == 2) {
|
||||||
level = mp_obj_get_int(args[1]);
|
level = mp_obj_get_int(args[1]);
|
||||||
}
|
}
|
||||||
if (args[0] == mp_const_none) {
|
if (args[0] == mp_const_none) {
|
||||||
// Disable logging
|
// Set logging back to boot default of ESP_LOG_ERROR
|
||||||
esp_log_level_set("*", ESP_LOG_ERROR);
|
esp_log_level_set("*", ESP_LOG_ERROR);
|
||||||
} else {
|
} else {
|
||||||
// Enable logging at the given level
|
// Enable logging at the given level
|
||||||
|
Loading…
Reference in New Issue
Block a user