46
46
#include "usb_serial_jtag.h"
47
47
#include "uart.h"
48
48
49
+ #include "py/mpprint.h"
50
+ //#define DBG(...)
51
+ #define DBG (...) mp_printf(MP_PYTHON_PRINTER, __VA_ARGS__); mp_printf(&mp_plat_print, "\n");
52
+
49
53
TaskHandle_t mp_main_task_handle ;
50
54
51
55
STATIC uint8_t stdin_ringbuf_array [260 ];
52
56
ringbuf_t stdin_ringbuf = {stdin_ringbuf_array , sizeof (stdin_ringbuf_array ), 0 , 0 };
53
57
54
58
// Check the ESP-IDF error code and raise an OSError if it's not ESP_OK.
55
- void check_esp_err (esp_err_t code ) {
59
+ void check_esp_err_ (esp_err_t code , const char * func , const int line , const char * file ) {
56
60
if (code != ESP_OK ) {
57
61
// map esp-idf error code to posix error code
58
62
uint32_t pcode = - code ;
@@ -78,8 +82,14 @@ void check_esp_err(esp_err_t code) {
78
82
o_str -> len = strlen ((char * )o_str -> data );
79
83
o_str -> hash = qstr_compute_hash (o_str -> data , o_str -> len );
80
84
// raise
81
- mp_obj_t args [2 ] = { MP_OBJ_NEW_SMALL_INT (pcode ), MP_OBJ_FROM_PTR (o_str )};
85
+ #if 0
86
+ mp_obj_t args [2 ] = { MP_OBJ_NEW_SMALL_INT (pcode ), MP_OBJ_FROM_PTR (o_str ) };
82
87
nlr_raise (mp_obj_exception_make_new (& mp_type_OSError , 2 , 0 , args ));
88
+ #else
89
+ DBG ("Exception from function '%s' at line %d in file '%s'" , func , line , file )
90
+ mp_obj_t args [5 ] = { MP_OBJ_NEW_SMALL_INT (pcode ), MP_OBJ_FROM_PTR (o_str ), mp_obj_new_str (func , strlen (func )), mp_obj_new_int (line ), mp_obj_new_str (file , strlen (file )) };
91
+ nlr_raise (mp_obj_exception_make_new (& mp_type_OSError , 5 , 0 , args ));
92
+ #endif
83
93
}
84
94
}
85
95
0 commit comments