diff --git a/lib/libesp32/berry/generate/be_const_strtab.h b/lib/libesp32/berry/generate/be_const_strtab.h index 1150f0797..9dacf5511 100644 --- a/lib/libesp32/berry/generate/be_const_strtab.h +++ b/lib/libesp32/berry/generate/be_const_strtab.h @@ -24,7 +24,7 @@ extern const bcstring be_const_str_BRY_X3A_X20could_X20not_X20save_X20compiled_X extern const bcstring be_const_str_BRY_X3A_X20failed_X20to_X20load_X20_X27_X25s_X27_X20_X28_X25s_X29; extern const bcstring be_const_str_BRY_X3A_X20failed_X20to_X20load_X20_persist_X2Ejson; extern const bcstring be_const_str_BRY_X3A_X20failed_X20to_X20load_X20compiled_X20_X27_X25s_X27_X20_X28_X25s_X29; -extern const bcstring be_const_str_BRY_X3A_X20failed_X20to_X20run_X20compiled_X20code; +extern const bcstring be_const_str_BRY_X3A_X20failed_X20to_X20run_X20compiled_X20code_X20_X27_X25s_X27_X20_X2D_X20_X25s; extern const bcstring be_const_str_BRY_X3A_X20invalid_X20hue_X20payload_X3A_X20; extern const bcstring be_const_str_BRY_X3A_X20method_X20not_X20allowed_X2C_X20use_X20a_X20closure_X20like_X20_X27_X2F_X20args_X20_X2D_X3E_X20obj_X2Efunc_X28args_X29_X27; extern const bcstring be_const_str_BUTTON_CONFIGURATION; diff --git a/lib/libesp32/berry/generate/be_const_strtab_def.h b/lib/libesp32/berry/generate/be_const_strtab_def.h index a6d89b089..0e5b0ccd8 100644 --- a/lib/libesp32/berry/generate/be_const_strtab_def.h +++ b/lib/libesp32/berry/generate/be_const_strtab_def.h @@ -98,7 +98,7 @@ be_define_const_str(BRY_X3A_X20could_X20not_X20save_X20compiled_X20file_X20_X25s be_define_const_str(BRY_X3A_X20failed_X20to_X20load_X20_X27_X25s_X27_X20_X28_X25s_X29, "BRY: failed to load '%s' (%s)", 54995609u, 0, 29, NULL); be_define_const_str(BRY_X3A_X20failed_X20to_X20load_X20_persist_X2Ejson, "BRY: failed to load _persist.json", 2991913445u, 0, 33, &be_const_str__change_buffer); be_define_const_str(BRY_X3A_X20failed_X20to_X20load_X20compiled_X20_X27_X25s_X27_X20_X28_X25s_X29, "BRY: failed to load compiled '%s' (%s)", 3488122666u, 0, 38, &be_const_str_isnan); -be_define_const_str(BRY_X3A_X20failed_X20to_X20run_X20compiled_X20code, "BRY: failed to run compiled code", 4039762049u, 0, 32, &be_const_str_collect); +be_define_const_str(BRY_X3A_X20failed_X20to_X20run_X20compiled_X20code_X20_X27_X25s_X27_X20_X2D_X20_X25s, "BRY: failed to run compiled code '%s' - %s", 380265962u, 0, 42, &be_const_str_obj); be_define_const_str(BRY_X3A_X20invalid_X20hue_X20payload_X3A_X20, "BRY: invalid hue payload: ", 203709367u, 0, 26, &be_const_str_add_handler); be_define_const_str(BRY_X3A_X20method_X20not_X20allowed_X2C_X20use_X20a_X20closure_X20like_X20_X27_X2F_X20args_X20_X2D_X3E_X20obj_X2Efunc_X28args_X29_X27, "BRY: method not allowed, use a closure like '/ args -> obj.func(args)'", 177121572u, 0, 70, &be_const_str_copy); be_define_const_str(BUTTON_CONFIGURATION, "BUTTON_CONFIGURATION", 70820856u, 0, 20, &be_const_str_pc_rel); @@ -1281,14 +1281,14 @@ static const bstring* const m_string_table[] = { NULL, (const bstring *)&be_const_str_manuf, (const bstring *)&be_const_str__X2F_X2Eautoconf, - (const bstring *)&be_const_str_obj, + (const bstring *)&be_const_str_BRY_X3A_X20failed_X20to_X20run_X20compiled_X20code_X20_X27_X25s_X27_X20_X2D_X20_X25s, (const bstring *)&be_const_str_RGBCT, NULL, (const bstring *)&be_const_str_Animate_X20pc_X20is_X20out_X20of_X20range, (const bstring *)&be_const_str__X2F, (const bstring *)&be_const_str_lv_signal_bars, (const bstring *)&be_const_str__X2Eautoconf, - (const bstring *)&be_const_str_BRY_X3A_X20failed_X20to_X20run_X20compiled_X20code, + (const bstring *)&be_const_str_collect, (const bstring *)&be_const_str__X2Ew, (const bstring *)&be_const_str_gamma10, (const bstring *)&be_const_str_add, diff --git a/lib/libesp32/berry_tasmota/src/be_tasmota_lib.c b/lib/libesp32/berry_tasmota/src/be_tasmota_lib.c index 071f116d9..daf62f34a 100644 --- a/lib/libesp32/berry_tasmota/src/be_tasmota_lib.c +++ b/lib/libesp32/berry_tasmota/src/be_tasmota_lib.c @@ -1407,7 +1407,7 @@ be_local_closure(Tasmota_load, /* name */ }) ), be_nested_proto( - 4, /* nstack */ + 10, /* nstack */ 1, /* argc */ 0, /* varg */ 0, /* has upvals */ @@ -1415,15 +1415,17 @@ be_local_closure(Tasmota_load, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 1]) { /* constants */ - /* K0 */ be_nested_str(BRY_X3A_X20failed_X20to_X20run_X20compiled_X20code), + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str(string), + /* K1 */ be_nested_str(format), + /* K2 */ be_nested_str(BRY_X3A_X20failed_X20to_X20run_X20compiled_X20code_X20_X27_X25s_X27_X20_X2D_X20_X25s), }), &be_const_str_try_run_compiled, &be_const_str_solidified, - ( &(const binstruction[20]) { /* code */ + ( &(const binstruction[25]) { /* code */ 0x4C040000, // 0000 LDNIL R1 0x20040001, // 0001 NE R1 R0 R1 - 0x7806000E, // 0002 JMPF R1 #0012 + 0x78060013, // 0002 JMPF R1 #0017 0xA8020006, // 0003 EXBLK 0 #000B 0x5C040000, // 0004 MOVE R1 R0 0x7C040000, // 0005 CALL R1 0 @@ -1431,16 +1433,21 @@ be_local_closure(Tasmota_load, /* name */ 0xA8040001, // 0007 EXBLK 1 1 0x80040200, // 0008 RET 1 R1 0xA8040001, // 0009 EXBLK 1 1 - 0x70020006, // 000A JMP #0012 - 0xAC040001, // 000B CATCH R1 0 1 - 0x70020003, // 000C JMP #0011 - 0x60080001, // 000D GETGBL R2 G1 - 0x580C0000, // 000E LDCONST R3 K0 - 0x7C080200, // 000F CALL R2 1 - 0x70020000, // 0010 JMP #0012 - 0xB0080000, // 0011 RAISE 2 R0 R0 - 0x50040000, // 0012 LDBOOL R1 0 0 - 0x80040200, // 0013 RET 1 R1 + 0x7002000B, // 000A JMP #0017 + 0xAC040002, // 000B CATCH R1 0 2 + 0x70020008, // 000C JMP #0016 + 0xA40E0000, // 000D IMPORT R3 K0 + 0x60100001, // 000E GETGBL R4 G1 + 0x8C140701, // 000F GETMET R5 R3 K1 + 0x581C0002, // 0010 LDCONST R7 K2 + 0x5C200200, // 0011 MOVE R8 R1 + 0x5C240400, // 0012 MOVE R9 R2 + 0x7C140800, // 0013 CALL R5 4 + 0x7C100200, // 0014 CALL R4 1 + 0x70020000, // 0015 JMP #0017 + 0xB0080000, // 0016 RAISE 2 R0 R0 + 0x50040000, // 0017 LDBOOL R1 0 0 + 0x80040200, // 0018 RET 1 R1 }) ), }), diff --git a/lib/libesp32/berry_tasmota/src/embedded/Tasmota.be b/lib/libesp32/berry_tasmota/src/embedded/Tasmota.be index 295f8fa64..60fc6a77f 100644 --- a/lib/libesp32/berry_tasmota/src/embedded/Tasmota.be +++ b/lib/libesp32/berry_tasmota/src/embedded/Tasmota.be @@ -478,8 +478,9 @@ class Tasmota try compiled_code() return true - except .. as e - print('BRY: failed to run compiled code') + except .. as e, m + import string + print(string.format("BRY: failed to run compiled code '%s' - %s", e, m)) end end return false