From 84035f0f78b7584961fb7092612194f093188071 Mon Sep 17 00:00:00 2001 From: Alex King Date: Wed, 14 Jun 2017 21:03:42 -0500 Subject: [PATCH 1/3] esp32/modesp: Add osdebug() function to disable or change IDF logging. Code lineage: osdebug() is based loosely on the version in esp8266, but there didn't seem to be an obvious way of choosing a particular UART. The basic behavior is the same, though: provide None, and logging is disabled; provide an integer and logging is restored to the default level. To build on that, and because the IDF provides more functionality, a second parameter has now been implemented which allows the active log level to be set: esp.osdebug(uart[, level]) The module has a corresponding set of LOG_ values to set this accordingly. --- ports/esp32/modesp.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ports/esp32/modesp.c b/ports/esp32/modesp.c index caa055164..e614f77a6 100644 --- a/ports/esp32/modesp.c +++ b/ports/esp32/modesp.c @@ -30,6 +30,7 @@ #include #include "rom/gpio.h" +#include "esp_log.h" #include "esp_spi_flash.h" #include "py/runtime.h" @@ -38,6 +39,23 @@ #include "drivers/dht/dht.h" #include "modesp.h" +STATIC mp_obj_t esp_osdebug(size_t n_args, const mp_obj_t *args) { + esp_log_level_t level = LOG_LOCAL_LEVEL; + if (n_args == 2) { + level = mp_obj_get_int(args[1]); + } + if (args[0] == mp_const_none) { + // Disable logging + esp_log_level_set("*", ESP_LOG_ERROR); + } else { + // Enable logging at the given level + // TODO args[0] should set the UART to which debug is sent + esp_log_level_set("*", level); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_osdebug_obj, 1, 2, esp_osdebug); + STATIC mp_obj_t esp_flash_read(mp_obj_t offset_in, mp_obj_t buf_in) { mp_int_t offset = mp_obj_get_int(offset_in); mp_buffer_info_t bufinfo; @@ -107,6 +125,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(esp_neopixel_write_obj, esp_neopixel_write_); STATIC const mp_rom_map_elem_t esp_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_esp) }, + { MP_ROM_QSTR(MP_QSTR_osdebug), MP_ROM_PTR(&esp_osdebug_obj) }, + { MP_ROM_QSTR(MP_QSTR_flash_read), MP_ROM_PTR(&esp_flash_read_obj) }, { MP_ROM_QSTR(MP_QSTR_flash_write), MP_ROM_PTR(&esp_flash_write_obj) }, { MP_ROM_QSTR(MP_QSTR_flash_erase), MP_ROM_PTR(&esp_flash_erase_obj) }, @@ -118,6 +138,14 @@ STATIC const mp_rom_map_elem_t esp_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_neopixel_write), MP_ROM_PTR(&esp_neopixel_write_obj) }, { MP_ROM_QSTR(MP_QSTR_dht_readinto), MP_ROM_PTR(&dht_readinto_obj) }, + + // Constants for second arg of osdebug() + { MP_ROM_QSTR(MP_QSTR_LOG_NONE), MP_ROM_INT((mp_uint_t)ESP_LOG_NONE)}, + { MP_ROM_QSTR(MP_QSTR_LOG_ERROR), MP_ROM_INT((mp_uint_t)ESP_LOG_ERROR)}, + { MP_ROM_QSTR(MP_QSTR_LOG_WARNING), MP_ROM_INT((mp_uint_t)ESP_LOG_WARN)}, + { MP_ROM_QSTR(MP_QSTR_LOG_INFO), MP_ROM_INT((mp_uint_t)ESP_LOG_INFO)}, + { MP_ROM_QSTR(MP_QSTR_LOG_DEBUG), MP_ROM_INT((mp_uint_t)ESP_LOG_DEBUG)}, + { MP_ROM_QSTR(MP_QSTR_LOG_VERBOSE), MP_ROM_INT((mp_uint_t)ESP_LOG_VERBOSE)}, }; STATIC MP_DEFINE_CONST_DICT(esp_module_globals, esp_module_globals_table); From aabbbf7fcc689414ff4e09f8d61e25b13ff4ef75 Mon Sep 17 00:00:00 2001 From: Nick Moore Date: Mon, 12 Feb 2018 10:29:32 +1100 Subject: [PATCH 2/3] README.md: update to indicate port merged back --- README.md | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 19c27e296..725316203 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![Build Status](https://travis-ci.org/micropython/micropython.png?branch=master)](https://travis-ci.org/micropython/micropython) [![Coverage Status](https://coveralls.io/repos/micropython/micropython/badge.png?branch=master)](https://coveralls.io/r/micropython/micropython?branch=master) - The MicroPython project =======================

@@ -13,24 +11,12 @@ You can find the official website at [micropython.org](http://www.micropython.or A note about this ESP32 repository ---------------------------------- -This repository is a clone of the main, upstream repository found at -https://github.com/micropython/micropython. This repository adds a new -branch called `esp32` which contains a port of MicroPython to the ESP32 -microcontroller, under the MIT license. Please see the `README.md` file -in the `ports/esp32/` subdirectory for details of this port. - -This `esp32` branch is the default branch and all pull requests should be -made to this branch, and any issues should discuss only the code developed -in the `ports/esp32/` subdirectory. - -The `esp32` branch will not be rebased so it is safe to clone/fork it and -base your work on it. New commits from the upstream repository will -occasionally be merged in the `esp32` branch. Any additional branches in -this repository (apart from `master`) may be rebased or deleted at any time. +**The ESP32 port has now been merged back into the +[main MicroPython repository](https://github.com/micropython/micropython/) +and this repository is maintained for historical purposes.** -If there is enough interest in the port to the ESP32 then this code can -eventually be merged into the upstream repository. So please do let your -interest be known! +**This repository is now getting out of date and new pull requests should +be made against the master branch of the main repository!** About MicroPython ----------------- From 2f4dac5f121a59fc187c1d9c1f9eade365b3aba1 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 27 Feb 2018 15:06:10 +1100 Subject: [PATCH 3/3] Add ISSUE_TEMPLATE.md and PULL_REQUEST_TEMPLATE.md. To direct users to the main MicroPython repository. --- ISSUE_TEMPLATE.md | 6 ++++++ PULL_REQUEST_TEMPLATE.md | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 ISSUE_TEMPLATE.md create mode 100644 PULL_REQUEST_TEMPLATE.md diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..aaf16861f --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,6 @@ +**The ESP32 port has now been merged back into the +[main MicroPython repository](https://github.com/micropython/micropython/) +and this repository is maintained for historical purposes.** + +**Please make new issues and pull requests against the master branch of the +main repository, linked above.** diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..aaf16861f --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,6 @@ +**The ESP32 port has now been merged back into the +[main MicroPython repository](https://github.com/micropython/micropython/) +and this repository is maintained for historical purposes.** + +**Please make new issues and pull requests against the master branch of the +main repository, linked above.**