diff --git a/.clangd b/.clangd new file mode 100644 index 000000000..3e0024e8c --- /dev/null +++ b/.clangd @@ -0,0 +1,13 @@ +CompileFlags: + Add: + - -Wno-unknown-warning-option + - -Wno-format + Remove: + - -mword-relocations + +--- + +If: + PathMatch: .*\.h +Diagnostics: + UnusedIncludes: None diff --git a/.gitignore b/.gitignore index fb6d6b704..59c526d2d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,9 @@ compile_commands.json # JetBrains IDEs .idea/ +# Sublime Text +.sublime-project.sublime-workspace + # Python VirtEnvironments .env .venv diff --git a/.sublime-project b/.sublime-project new file mode 100644 index 000000000..4912c9974 --- /dev/null +++ b/.sublime-project @@ -0,0 +1,21 @@ +{ + "folders": + [ + { + "path": ".", + } + ], + "settings": { + "LSP": { + "clangd": { + "initializationOptions": { + "clangd.compile-commands-dir": "build/latest", + "clangd.header-insertion": null, + "clangd.query-driver": "**", + "clangd.clang-tidy": true, + }, + "enabled": true, + }, + }, + }, +} diff --git a/.vscode/example/settings.json b/.vscode/example/settings.json index a59194901..9afabf926 100644 --- a/.vscode/example/settings.json +++ b/.vscode/example/settings.json @@ -19,6 +19,8 @@ "clangd.arguments": [ // We might be able to tighten this a bit more to only include the correct toolchain. "--query-driver=**", - "--compile-commands-dir=${workspaceFolder}/build/latest" + "--compile-commands-dir=${workspaceFolder}/build/latest", + "--clang-tidy", + "--header-insertion=never" ] } \ No newline at end of file diff --git a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c index 040aff46c..5304a32e2 100644 --- a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c +++ b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c @@ -81,6 +81,14 @@ bool subghz_txrx_gen_data_protocol_and_te( ret = true; } } + if(ret == SubGhzProtocolStatusOk) { + uint32_t guard_time = 30; + if(!flipper_format_update_uint32( + instance->fff_data, "Guard_time", (uint32_t*)&guard_time, 1)) { + ret = SubGhzProtocolStatusErrorParserOthers; + FURI_LOG_E(TAG, "Unable to update Guard_time"); + } + } return ret; } diff --git a/firmware.scons b/firmware.scons index bf3f46a9b..62b1184eb 100644 --- a/firmware.scons +++ b/firmware.scons @@ -20,6 +20,7 @@ env = ENV.Clone( "fbt_resources", ], COMPILATIONDB_USE_ABSPATH=False, + COMPILATIONDB_USE_BINARY_ABSPATH=True, BUILD_DIR=fw_build_meta["build_dir"], IS_BASE_FIRMWARE=fw_build_meta["type"] == "firmware", FW_FLAVOR=fw_build_meta["flavor"], diff --git a/lib/subghz/protocols/princeton.c b/lib/subghz/protocols/princeton.c index 1a7fe53ed..038a3a8e8 100644 --- a/lib/subghz/protocols/princeton.c +++ b/lib/subghz/protocols/princeton.c @@ -13,6 +13,7 @@ */ #define TAG "SubGhzProtocolPrinceton" +#define PRINCETON_GUARD_TIME_DEFALUT 30 //GUARD_TIME = PRINCETON_GUARD_TIME_DEFALUT * TE static const SubGhzBlockConst subghz_protocol_princeton_const = { .te_short = 390, @@ -29,6 +30,7 @@ struct SubGhzProtocolDecoderPrinceton { uint32_t te; uint32_t last_data; + uint32_t guard_time; }; struct SubGhzProtocolEncoderPrinceton { @@ -38,6 +40,7 @@ struct SubGhzProtocolEncoderPrinceton { SubGhzBlockGeneric generic; uint32_t te; + uint32_t guard_time; }; typedef enum { @@ -135,8 +138,9 @@ static bool //Send Stop bit instance->encoder.upload[index++] = level_duration_make(true, (uint32_t)instance->te); - //Send PT_GUARD - instance->encoder.upload[index++] = level_duration_make(false, (uint32_t)instance->te * 30); + //Send PT_GUARD_TIME + instance->encoder.upload[index++] = + level_duration_make(false, (uint32_t)instance->te * instance->guard_time); return true; } @@ -165,6 +169,11 @@ SubGhzProtocolStatus break; } //optional parameter parameter + if(!flipper_format_read_uint32( + flipper_format, "Guard_time", (uint32_t*)&instance->guard_time, 1)) { + instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT; + } + flipper_format_read_uint32( flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); @@ -235,6 +244,7 @@ void subghz_protocol_decoder_princeton_feed(void* context, bool level, uint32_t instance->decoder.decode_data = 0; instance->decoder.decode_count_bit = 0; instance->te = 0; + instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT; } break; case PrincetonDecoderStepSaveDuration: @@ -257,6 +267,7 @@ void subghz_protocol_decoder_princeton_feed(void* context, bool level, uint32_t instance->generic.data = instance->decoder.decode_data; instance->generic.data_count_bit = instance->decoder.decode_count_bit; + instance->guard_time = round((float)duration / instance->te); if(instance->base.callback) instance->base.callback(&instance->base, instance->base.context); @@ -323,6 +334,12 @@ SubGhzProtocolStatus subghz_protocol_decoder_princeton_serialize( FURI_LOG_E(TAG, "Unable to add TE"); ret = SubGhzProtocolStatusErrorParserTe; } + if((ret == SubGhzProtocolStatusOk) && + !flipper_format_write_uint32(flipper_format, "Guard_time", &instance->guard_time, 1)) { + FURI_LOG_E(TAG, "Unable to add Guard_time"); + ret = SubGhzProtocolStatusErrorParserOthers; + } + return ret; } @@ -349,6 +366,10 @@ SubGhzProtocolStatus ret = SubGhzProtocolStatusErrorParserTe; break; } + if(!flipper_format_read_uint32( + flipper_format, "Guard_time", (uint32_t*)&instance->guard_time, 1)) { + instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT; + } } while(false); return ret; diff --git a/scripts/fbt_tools/ccache.py b/scripts/fbt_tools/ccache.py index 63577ab78..a7e546422 100644 --- a/scripts/fbt_tools/ccache.py +++ b/scripts/fbt_tools/ccache.py @@ -12,3 +12,4 @@ def generate(env): env["LINK"] = env["CXX"] env["CXX_NOCACHE"] = env["CXX"] env["CXX"] = "$CCACHE $CXX_NOCACHE" + env.AppendUnique(COMPILATIONDB_OMIT_BINARIES=["ccache"]) diff --git a/scripts/fbt_tools/compilation_db.py b/scripts/fbt_tools/compilation_db.py index 3d5e469f4..6bad96b2d 100644 --- a/scripts/fbt_tools/compilation_db.py +++ b/scripts/fbt_tools/compilation_db.py @@ -32,7 +32,7 @@ which is the name that most clang tools search for by default. import fnmatch import itertools import json -from shlex import quote +from shlex import join, split import SCons from SCons.Tool.asm import ASPPSuffixes, ASSuffixes @@ -108,6 +108,10 @@ def make_emit_compilation_DB_entry(comstr): return emit_compilation_db_entry +def __is_value_true(value): + return value in [True, 1, "True", "true"] + + def compilation_db_entry_action(target, source, env, **kw): """ Create a dictionary with evaluated command line, target, source @@ -126,16 +130,19 @@ def compilation_db_entry_action(target, source, env, **kw): env=env["__COMPILATIONDB_ENV"], ) - # We assume first non-space character is the executable - executable = command.split(" ", 1)[0] - if not (tool_path := _TOOL_PATH_CACHE.get(executable, None)): - tool_path = env.WhereIs(executable) or executable - _TOOL_PATH_CACHE[executable] = tool_path - # If there are spaces in the executable path, we need to quote it - if " " in tool_path: - tool_path = quote(tool_path) - # Replacing the executable with the full path - command = tool_path + command[len(executable) :] + cmdline = split(command) + binaries_to_omit = env["COMPILATIONDB_OMIT_BINARIES"] + while (executable := cmdline[0]) in binaries_to_omit: + cmdline.pop(0) + + if __is_value_true(env["COMPILATIONDB_USE_BINARY_ABSPATH"]): + if not (tool_path := _TOOL_PATH_CACHE.get(executable, None)): + tool_path = env.WhereIs(executable) or executable + _TOOL_PATH_CACHE[executable] = tool_path + # Replacing the executable with the full path + executable = tool_path + + command = join((executable, *cmdline[1:])) entry = { "directory": env.Dir("#").abspath, @@ -150,7 +157,7 @@ def compilation_db_entry_action(target, source, env, **kw): def write_compilation_db(target, source, env): entries = [] - use_abspath = env["COMPILATIONDB_USE_ABSPATH"] in [True, 1, "True", "true"] + use_abspath = __is_value_true(env["COMPILATIONDB_USE_ABSPATH"]) use_path_filter = env.subst("$COMPILATIONDB_PATH_FILTER") use_srcpath_filter = env.subst("$COMPILATIONDB_SRCPATH_FILTER") @@ -225,6 +232,8 @@ def generate(env, **kwargs): COMPILATIONDB_USE_ABSPATH=False, COMPILATIONDB_PATH_FILTER="", COMPILATIONDB_SRCPATH_FILTER="", + COMPILATIONDB_OMIT_BINARIES=[], + COMPILATIONDB_USE_BINARY_ABSPATH=False, ) components_by_suffix = itertools.chain( diff --git a/scripts/ufbt/SConstruct b/scripts/ufbt/SConstruct index 784d66161..26b1046ee 100644 --- a/scripts/ufbt/SConstruct +++ b/scripts/ufbt/SConstruct @@ -102,6 +102,7 @@ env = core_env.Clone( core_env.subst("$SDK_DEFINITION"), load_version_only=True ).version, APPCHECK_COMSTR="\tAPPCHK\t${SOURCE}\n\t\tTarget: ${TARGET_HW}, API: ${UFBT_API_VERSION}", + COMPILATIONDB_USE_BINARY_ABSPATH=True, ) wrap_tempfile(env, "LINKCOM")