diff --git a/DebugVarEdit.exe b/DebugVarEdit.exe index 32fd47c..f0a6f88 100644 Binary files a/DebugVarEdit.exe and b/DebugVarEdit.exe differ diff --git a/Src/generate_debug_vars.py b/Src/generate_debug_vars.py index 47388d2..c7ae7e5 100644 --- a/Src/generate_debug_vars.py +++ b/Src/generate_debug_vars.py @@ -285,15 +285,20 @@ def add_new_vars_to_xml(proj_path, xml_rel_path, output_path): Возвращает True если что-то добавлено и XML перезаписан, иначе False. """ + pattern = re.compile( + r'{\s*\(uint8_t\s*\*\)\s*&([a-zA-Z_][a-zA-Z0-9_]*(?:\[.*?\])?(?:(?:\.|->)[a-zA-Z_][a-zA-Z0-9_]*(?:\[.*?\])?)*)\s*,\s*' + r'(pt_\w+)\s*,\s*' + r'(t?_?iq\w+)\s*,\s*' + r'(t?_?iq\w+)\s*,\s*' + r'"([^"]+)"' + ) # Считываем существующие переменные parsed_vars = {} if os.path.isfile(output_path): with open(output_path, 'r', encoding='utf-8', errors='ignore') as f: for line in f: - # {(uint8_t *)&some.deep.var.name , pt_uint16 , t_iq15 , "ShortName"}, - m = re.match( - r'{\s*\(uint8_t\s*\*\)\s*&([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\s*,\s*(pt_\w+)\s*,\s*(t?iq_\w+)\s*,\s*"([^"]+)"', - line) + # {(uint8_t *)&some.deep.var.name , pt_uint16 , t_iq15 , t_iq10, "ShortName"}, + m = pattern.search(line) if m: full_varname = m.group(1) # e.g., some.deep.var.name pt_type = m.group(2) @@ -556,7 +561,7 @@ def generate_vars_file(proj_path, xml_path, output_dir): out_lines.append(f'int DebugVar_Qnt = {len(all_debug_lines)};') if stm_flag_global == 0: out_lines.append('#pragma DATA_SECTION(dbg_vars,".dbgvar_info")') - out_lines.append('// pointer_type iq_type return_iq_type short_name') + out_lines.append('// pointer_type iq_type return_iq_type short_name') out_lines.append('DebugVar_t dbg_vars[] = {\\') out_lines.extend(all_debug_lines) out_lines.append('};') diff --git a/debug_tools.c b/debug_tools.c index a0ae0c0..e8fac47 100644 --- a/debug_tools.c +++ b/debug_tools.c @@ -197,9 +197,9 @@ static int convertDebugVarToIQx(DebugVar_t *var, int32_t *ret_var) // GLOBAL_Q (64-) if (var->iq_type == t_iq_none) { if (var->ptr_type == pt_float) { - // float_numb 2^GLOBAL_Q (2^24=16777216) + // float_numb 2^GLOBAL_Q // 64 - iq_united64 = (int64_t)(float_numb * 16777216.0f); + iq_united64 = (int64_t)(float_numb * (1 << GLOBAL_Q)); } else { iq_united64 = ((int64_t)iq_numb) << GLOBAL_Q; } diff --git a/debug_tools.h b/debug_tools.h index ac68d83..34c10c9 100644 --- a/debug_tools.h +++ b/debug_tools.h @@ -4,14 +4,8 @@ #include -//#if (LONG_MAX != 2147483647L) -//# error "debug_tools: this code assumes 32-bit long. Please update DebugValue_t typedef." -//#endif - - - -#if defined(uint8_t) && defined(int8_t) // 8 - 8 +#if UINT8_MAX // 8 - 8 #define ALIGN_8BIT 0x0 ///< ( ) #define ALIGN_16BIT 0x1 ///< : 2 (addr & 0x1 == 0) @@ -29,19 +23,13 @@ #endif //STM32/TMS32 - -#if !defined(uint8_t) +#if !UINT8_MAX typedef unsigned char uint8_t; -#endif -#if !defined(int8_t) typedef signed char int8_t; #endif #if !defined(NULL) #define NULL 0 #endif -#if !defined(NULL) -#define NULL 0 -#endif /**