From e7a5d19f9c919c1bc5c49f53f93b6ac8bec03b2b Mon Sep 17 00:00:00 2001 From: Skorpionm <85568270+Skorpionm@users.noreply.github.com> Date: Tue, 30 Aug 2022 19:22:24 +0400 Subject: [PATCH] [FL-2778] SubGhz: fix CLI "subghz tx" (#1681) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * SubGhz: fix CLI "subghz tx" * Fix qoutes in amap workflow * Github: fix step naming * fix quotes in PR name again Co-authored-by: あく Co-authored-by: DrunkBatya --- .github/workflows/amap_analyse.yml | 16 +++++++++++++--- applications/subghz/subghz_cli.c | 20 ++++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/amap_analyse.yml b/.github/workflows/amap_analyse.yml index 11dac543..5efdb09e 100644 --- a/.github/workflows/amap_analyse.yml +++ b/.github/workflows/amap_analyse.yml @@ -45,6 +45,19 @@ jobs: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} + - name: 'Escape pull request title' + if: github.event_name == 'pull_request' + run: | + import json + import os + import shlex + with open('${{ github.event_path }}') as fh: + event = json.load(fh) + escaped = shlex.quote(event['pull_request']['title']) + with open(os.environ['GITHUB_ENV'], 'a') as fh: + print(f'PULL_NAME={escaped}', file=fh) + shell: python3 {0} + - name: 'Generate prefixes by commit' id: names run: | @@ -58,7 +71,6 @@ jobs: SHA="$(cut -c -8 <<< "$COMMIT_HASH")" COMMIT_MSG="$(git log -1 --pretty=format:"%s")" PULL_ID="${{github.event.pull_request.number}}" - PULL_NAME="${{github.event.pull_request.title}}" fi BRANCH_NAME=${REF#refs/*/} SUFFIX=${BRANCH_NAME//\//_}-$(date +'%d%m%Y')-${SHA} @@ -78,7 +90,6 @@ jobs: mkdir artifacts - name: 'Download build artifacts' - if: ${{ !github.event.pull_request.head.repo.fork }} run: | echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key; chmod 600 ./deploy_key; @@ -112,7 +123,6 @@ jobs: export FREE_FLASH_SIZE="$(get_size ".free_flash")" if [[ ${{ github.event_name }} == 'pull_request' ]]; then export PULL_ID="${{steps.names.outputs.pull-id}}" - export PULL_NAME="${{steps.names.outputs.pull-name}}" fi python3 -m pip install mariadb python3 scripts/amap_mariadb_insert.py \ diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c index 09dae048..cda50c79 100644 --- a/applications/subghz/subghz_cli.c +++ b/applications/subghz/subghz_cli.c @@ -114,19 +114,21 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) { uint32_t frequency = 433920000; uint32_t key = 0x0074BADE; uint32_t repeat = 10; + uint32_t te = 403; if(string_size(args)) { - int ret = sscanf(string_get_cstr(args), "%lx %lu %lu", &key, &frequency, &repeat); - if(ret != 3) { + int ret = sscanf(string_get_cstr(args), "%lx %lu %lu %lu", &key, &frequency, &te, &repeat); + if(ret != 4) { printf( - "sscanf returned %d, key: %lx, frequency: %lu, repeat: %lu\r\n", + "sscanf returned %d, key: %lx, frequency: %lu, te:%lu, repeat: %lu\r\n", ret, key, frequency, + te, repeat); cli_print_usage( "subghz tx", - "<3 Byte Key: in hex> ", + "<3 Byte Key: in hex> ", string_get_cstr(args)); return; } @@ -139,9 +141,10 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) { } printf( - "Transmitting at %lu, key %lx, repeat %lu. Press CTRL+C to stop\r\n", + "Transmitting at %lu, key %lx, te %lu, repeat %lu. Press CTRL+C to stop\r\n", frequency, key, + te, repeat); string_t flipper_format_string; @@ -149,12 +152,13 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) { flipper_format_string, "Protocol: Princeton\n" "Bit: 24\n" - "Key: 00 00 00 00 00 %X %X %X\n" - "TE: 403\n" + "Key: 00 00 00 00 00 %02X %02X %02X\n" + "TE: %d\n" "Repeat: %d\n", (uint8_t)((key >> 16) & 0xFF), (uint8_t)((key >> 8) & 0xFF), (uint8_t)(key & 0xFF), + te, repeat); FlipperFormat* flipper_format = flipper_format_string_alloc(); Stream* stream = flipper_format_get_raw_stream(flipper_format); @@ -425,7 +429,7 @@ static void subghz_cli_command_print_usage() { printf("\tchat \t - Chat with other Flippers\r\n"); printf( - "\ttx <3 byte Key: in hex> \t - Transmitting key\r\n"); + "\ttx <3 byte Key: in hex> \t - Transmitting key\r\n"); printf("\trx \t - Reception key\r\n"); printf("\tdecode_raw \t - Testing\r\n");