From ebcb16a572ebdd6cb5ffbc14bb44c96a10efcec1 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Sun, 6 Feb 2022 19:24:36 +1100 Subject: [PATCH 01/10] Update DebugMenu.md --- Documentation/DebugMenu.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/DebugMenu.md b/Documentation/DebugMenu.md index b0a1be7a..bca579a4 100644 --- a/Documentation/DebugMenu.md +++ b/Documentation/DebugMenu.md @@ -71,7 +71,8 @@ This may change during power up as the sources are negotiated in turn. - **DC** input (dumb) - **QC** input (We used QC2/3 negotiation for current supply) -- **PD** input (We used the PD subsystem to negotiate for the current supply) +- **PD W. VBus** input (We used the PD subsystem to negotiate for the current supply); and VBus is connected to your input power source +- **PD No VBus** input (We used the PD subsystem to negotiate for the current supply); and VBus is **NOT** connected to your input power source ### Max From 3967525190daa3114bc281807f6e9161aa661613 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Sun, 6 Feb 2022 19:26:33 +1100 Subject: [PATCH 02/10] Update DebugMenu.md --- Documentation/DebugMenu.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/DebugMenu.md b/Documentation/DebugMenu.md index bca579a4..91ac0a9a 100644 --- a/Documentation/DebugMenu.md +++ b/Documentation/DebugMenu.md @@ -78,3 +78,9 @@ This may change during power up as the sources are negotiated in turn. This indicates the max temp in C that the system estimates it can measure the tip reliably to. This is dependant on a few factors including the handle temperature so it can move around during use. + + +### Hall + +This will appear if your device is capable of having a magnetic hall effect sensor fitted. +This will show the current field strength reading from the sensor, this can be used to check the sensor is operational and measure how strong the magnetic field is for diagnostics. From 42609ad9fca9fa0bd7256d94c64f7dd996f9907a Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Sun, 6 Feb 2022 19:49:27 +1100 Subject: [PATCH 03/10] Delete setup.sh --- setup.sh | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 setup.sh diff --git a/setup.sh b/setup.sh deleted file mode 100644 index 00c460da..00000000 --- a/setup.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -set -e -# Setup shell file to setup the environment on an ubuntu machine -sudo apt-get update && sudo apt-get install -y make bzip2 git python3 python3-pip wget dfu-util -python3 -m pip install bdflib black flake8 -sudo mkdir -p /build -cd /build - -# Download source files to cache folder -# Remember if these are updated, you need to update the md5 file respectively -# Github checks out under $GITHUB_WORKSPACE -MDPATH=${GITHUB_WORKSPACE:-/build/source/} -sudo mkdir -p /build/cache -cd /build/cache/ -if md5sum -c "$MDPATH"/ci/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2.md5; then - echo "Good MD5 ARM" -else - echo "ARM MD5 Mismatch, downloading fresh" - rm -rf /build/cache/gcc-arm*.bz2 || true - sudo wget -q "https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2" -O gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -fi - -if md5sum -c "$MDPATH"/ci/nuclei_riscv_newlibc_prebuilt_linux64_2020.08.tar.bz2.md5; then - echo "Good MD5 RISCV" -else - echo "RISCV MD5 Mismatch, downloading fresh" - rm -rf /build/cache/nuclei*.bz2 || true - sudo wget -q "https://github.com/Ralim/nuclei-compiler/releases/download/2020.08/nuclei_riscv_newlibc_prebuilt_linux64_2020.08.tar.bz2" -O nuclei_riscv_newlibc_prebuilt_linux64_2020.08.tar.bz2 -fi - -echo "Extracting compilers" -sudo tar -xj -f gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /build/ -sudo tar -xj -f nuclei_riscv_newlibc_prebuilt_linux64_2020.08.tar.bz2 -C /build/ - -echo "Link into PATH" - -sudo ln -s /build/gcc-arm-none-eabi-10-2020-q4-major/bin/* /usr/local/bin -sudo ln -s /build/gcc/bin/* /usr/local/bin From 91c9c73d4ac1f2a9b683cd8ee3f84a311f3ea980 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 7 Feb 2022 21:22:13 +1100 Subject: [PATCH 04/10] First pass of metadata generator --- source/metadata.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 source/metadata.py diff --git a/source/metadata.py b/source/metadata.py new file mode 100755 index 00000000..94d3bfc9 --- /dev/null +++ b/source/metadata.py @@ -0,0 +1,80 @@ +#! python3 + +import json +from pathlib import Path +import os +import re +import subprocess + +# Creates an index metadata json file of the hexfiles folder +# This is used by automation like the Pinecil updater + +HERE = Path(__file__).resolve().parent + +HexFileFolder = os.path.join(HERE, "Hexfile") +OutputJSONPath = os.path.join(HexFileFolder, "index.json") +TranslationsFilesPath = os.path.join(HERE.parent, "Translations") + + +def load_json(filename: str, skip_first_line: bool): + with open(filename) as f: + if skip_first_line: + f.readline() + return json.loads(f.read()) + + +def read_git_tag(): + return f"{subprocess.check_output(['git', 'rev-parse', '--short=7', 'HEAD']).strip().decode('ascii').upper()}" + + +def read_version(): + with open(HERE / "version.h") as version_file: + for line in version_file: + if re.findall(r"^.*(?<=(#define)).*(?<=(BUILD_VERSION))", line): + matches = re.findall(r"\"(.+?)\"", line) + if matches: + return matches[0] + raise Exception("Could not parse version") + + +# Fetch our file listings +translation_files = [os.path.join(TranslationsFilesPath, f) for f in os.listdir(TranslationsFilesPath) if os.path.isfile(os.path.join(TranslationsFilesPath, f)) and f.endswith(".json")] +output_files = [os.path.join(HexFileFolder, f) for f in os.listdir(HexFileFolder) if os.path.isfile(os.path.join(HexFileFolder, f))] + +parsed_languages = {} +for path in translation_files: + lang: dict = load_json(path, skip_first_line=False) + code = lang.get("languageCode", None) + if code is not None: + parsed_languages[code] = lang + +# Now that we have the languages, we can generate our index of info on each file + +output_json = {"git_tag": read_git_tag(), "release": read_version(), "contents": {}} + +device_model_name = None +for file_path in output_files: + if file_path.endswith(".hex") or file_path.endswith(".dfu"): + # Find out what language this file is + name: str = os.path.basename(file_path) + matches = re.findall(r"^([a-zA-Z]+)_(.+)\.(.+)$", name) + if matches: + matches = matches[0] + if len(matches) == 3: + if device_model_name is None: + device_model_name = matches[0] + lang_code = matches[1] + lang_file = parsed_languages.get(lang_code, None) + if lang_file is None: + raise Exception(f"Could not match language code {lang_code}") + file_record = {"language_code": lang_code, "language_name": lang_file.get("languageLocalName", None)} + output_json["contents"][name] = file_record + else: + print(f"failed to parse {matches}") + +if device_model_name is None: + raise Exception("No files parsed") + +output_json["model"] = device_model_name +with open(OutputJSONPath, "w", encoding="utf8") as json_file: + json.dump(output_json, json_file, ensure_ascii=False) From 5e777a97d26638b78c905c8ac896981fa67d1b07 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 7 Feb 2022 21:31:33 +1100 Subject: [PATCH 05/10] Draft ci --- .github/workflows/push.yml | 9 +++++++++ source/metadata.py | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 6c1e45b1..4f0b3b9a 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -42,6 +42,15 @@ jobs: source/Hexfile/LICENSE_RELEASE.md if-no-files-found: error + - name: Generate json index file + run: cd source && python3 metadata.py ${{ matrix.model }}.json + + - name: Archive ${{ matrix.model }} index file + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.model }}.json + path: source/Hexfile/${{ matrix.model }}.json + build_multi-lang: runs-on: ubuntu-20.04 container: diff --git a/source/metadata.py b/source/metadata.py index 94d3bfc9..cd672bfc 100755 --- a/source/metadata.py +++ b/source/metadata.py @@ -5,14 +5,20 @@ from pathlib import Path import os import re import subprocess +import sys # Creates an index metadata json file of the hexfiles folder # This is used by automation like the Pinecil updater + +if len(sys.argv) != 2: + print("Requires the output json name as an arg") + exit(1) + HERE = Path(__file__).resolve().parent HexFileFolder = os.path.join(HERE, "Hexfile") -OutputJSONPath = os.path.join(HexFileFolder, "index.json") +OutputJSONPath = os.path.join(HexFileFolder, sys.argv[1]) TranslationsFilesPath = os.path.join(HERE.parent, "Translations") From 8c5c166109ff52644fe2ce67fc7a841d9b96088d Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 7 Feb 2022 21:34:01 +1100 Subject: [PATCH 06/10] Update metadata.py --- source/metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/metadata.py b/source/metadata.py index cd672bfc..09458a18 100755 --- a/source/metadata.py +++ b/source/metadata.py @@ -63,7 +63,7 @@ for file_path in output_files: if file_path.endswith(".hex") or file_path.endswith(".dfu"): # Find out what language this file is name: str = os.path.basename(file_path) - matches = re.findall(r"^([a-zA-Z]+)_(.+)\.(.+)$", name) + matches = re.findall(r"^([a-zA-Z0-9]+)_(.+)\.(.+)$", name) if matches: matches = matches[0] if len(matches) == 3: From ee0eeec08f3168396be51a6ccc07404b9f13f60f Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 7 Feb 2022 21:37:59 +1100 Subject: [PATCH 07/10] Update push.yml --- .github/workflows/push.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4f0b3b9a..bcfabc33 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -89,6 +89,15 @@ jobs: source/Hexfile/LICENSE_RELEASE.md if-no-files-found: error + - name: Generate json index file + run: cd source && python3 metadata.py ${{ matrix.model }}.json + + - name: Archive ${{ matrix.model }} index file + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.model }}_multi-lang.json + path: source/Hexfile/${{ matrix.model }}.json + tests: runs-on: ubuntu-20.04 container: From d8e0d860846ac7c97c61c8022280a6489059bc05 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 7 Feb 2022 21:48:57 +1100 Subject: [PATCH 08/10] Update metadata.py --- source/metadata.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/metadata.py b/source/metadata.py index 09458a18..9349bef8 100755 --- a/source/metadata.py +++ b/source/metadata.py @@ -69,8 +69,11 @@ for file_path in output_files: if len(matches) == 3: if device_model_name is None: device_model_name = matches[0] - lang_code = matches[1] + lang_code: str = matches[1] lang_file = parsed_languages.get(lang_code, None) + if lang_file is None and lang_code.startswith("multi_"): + # Multi files wont match, but we fake this by just taking the filename to it + lang_file = {"languageLocalName": lang_code.replace("multi_", "").replace("compressed_", "")} if lang_file is None: raise Exception(f"Could not match language code {lang_code}") file_record = {"language_code": lang_code, "language_name": lang_file.get("languageLocalName", None)} From 0b894ffaf39a5019ca22c00459891638255055df Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 9 Feb 2022 21:09:18 +1100 Subject: [PATCH 09/10] merged metadata? --- .github/workflows/push.yml | 17 +++++++++++++++-- .github/workflows/shellcheck.yml | 15 --------------- 2 files changed, 15 insertions(+), 17 deletions(-) delete mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index bcfabc33..ea6b0ac9 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -48,7 +48,7 @@ jobs: - name: Archive ${{ matrix.model }} index file uses: actions/upload-artifact@v2 with: - name: ${{ matrix.model }}.json + name: metadata.zip path: source/Hexfile/${{ matrix.model }}.json build_multi-lang: @@ -95,7 +95,7 @@ jobs: - name: Archive ${{ matrix.model }} index file uses: actions/upload-artifact@v2 with: - name: ${{ matrix.model }}_multi-lang.json + name: metadata.zip path: source/Hexfile/${{ matrix.model }}.json tests: @@ -149,3 +149,16 @@ jobs: - name: Check python with flake8 run: flake8 Translations + + shellcheck: + name: runner / shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: shellcheck + uses: reviewdog/action-shellcheck@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review # Change reporter. + exclude: "./.git/*" # Optional. + check_all_files_with_shebangs: "false" # Optional. diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml deleted file mode 100644 index 8def392d..00000000 --- a/.github/workflows/shellcheck.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Shell Check -on: [pull_request] -jobs: - shellcheck: - name: runner / shellcheck - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: shellcheck - uses: reviewdog/action-shellcheck@v1 - with: - github_token: ${{ secrets.github_token }} - reporter: github-pr-review # Change reporter. - exclude: "./.git/*" # Optional. - check_all_files_with_shebangs: "false" # Optional. From 6c058f93d57267bf058a9fba7a3de3635b68ed3e Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 9 Feb 2022 21:11:47 +1100 Subject: [PATCH 10/10] Update push.yml --- .github/workflows/push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ea6b0ac9..738ecfcc 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -48,7 +48,7 @@ jobs: - name: Archive ${{ matrix.model }} index file uses: actions/upload-artifact@v2 with: - name: metadata.zip + name: metadata path: source/Hexfile/${{ matrix.model }}.json build_multi-lang: @@ -95,7 +95,7 @@ jobs: - name: Archive ${{ matrix.model }} index file uses: actions/upload-artifact@v2 with: - name: metadata.zip + name: metadata path: source/Hexfile/${{ matrix.model }}.json tests: