8000 ESP32: Check the ESP-IDF error code · Issue #6573 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

ESP32: Check the ESP-IDF error code #6573

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

Closed
IhorNehrutsa opened this issue Oct 27, 2020 · 5 comments
Closed

ESP32: Check the ESP-IDF error code #6573

IhorNehrutsa opened this issue Oct 27, 2020 · 5 comments

Comments

@IhorNehrutsa
Copy link
Contributor

1) Is it correct to represent the ESP-IDF error code as OSError code?
For example, for the code

from esp32 import RMT  
from machine import Pin  
rmt = RMT(1000, pin=Pin(10)) # 1000 is wrong  

we get an output

OSError: (-258, 'ESP_ERR_INVALID_ARG')

But I expect to see

EspError: (258, '0x102 ESP_ERR_INVALID_ARG')

(or something similar) according to errors

#define ESP_ERR_INVALID_ARG         0x102   /*!< Invalid argument */

from the
esp_err.h#L31

2) Is this line of code correct? Do you need a '-' here?

uint32_t pcode = -code;

from the
mphalport.c#61

3) Is it possible to develop a C module with esp_err.py functionality?
esp_err.zip

I try but it doesn't work completely.
mod_esp_err.zip
I get TypeError when executing esp_err_test.py

  File "<stdin>", line 9, in <module>
TypeError: can't create 'EspError' instances
@jimmo
Copy link
Member
jimmo commented Oct 29, 2020
  1. Is it correct to represent the ESP-IDF error code as OSError code?

This is the way it's done, but whether it's the best thing to do... not sure.

  1. Is this line of code correct? Do you need a '-' here?

The idea here is that positive values indicate a "real" error code (i.e. MP_Exxx), and negative values are custom error code (i.e. ESP-IDF codes).

  1. Is it possible to develop a C module with esp_err.py functionality?

Your mod_esp_err_EspError_type instance doesn't have a .make_new entry and therefore cannot be constructed from Python. Here's roughly what that would look like.

STATIC mp_obj_t mod_esp_err_EspError_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
    ...allocate and return an instance of _mp_obj_EspError_t
}

STATIC const mp_obj_type_t mod_esp_err_EspError_type = {
    { &mp_type_type },
    .name = MP_QSTR_EspError,
    .locals_dict = (void*)&mod_esp_err_EspError_locals_dict,
    .make_new = mod_esp_err_EspError_make_new,
};

@IhorNehrutsa
Copy link
Contributor Author

Thanks, Jim.
I have developed an external C-module for ESP errors.
mod_esp_err.zip
When executed
esp_err_test.zip
EspError raised as expected

Traceback (most recent call last):
  File "<stdin>", line 9, in <module>
EspError: (258, '0x102 - ESP_ERR_INVALID_ARG')

WIP

@IhorNehrutsa
Copy link
Contributor Author
IhorNehrutsa commented Nov 16, 2020

This issue solved in PR #6638

@dpgeorge
Copy link
Member

I'll close this issue because points (2) and (3) are answered above. And point (1) is covered by #6638.

@QGB
Copy link
QGB commented Apr 23, 2023

idf.py fullclean

make BOARD=GENERIC_C3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0