From 4e32a90c5a3b562500f0cbb7c923c2f08b06251e Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 28 Mar 2024 16:40:31 -0700 Subject: [PATCH] juggle.py: migrate platform name (#32042) * fix formatting! * migrate plotjuggler platform for dbc * test with can * temp * Revert "temp" This reverts commit 9d740bf3bddc8a7833ca8c293a6fb4b692a30bb8. Revert "test with can" This reverts commit d6cf2304895d00f83e737f3f749089ce9c5f836e. * fix test old-commit-hash: 903cc225ebac1742517068b787f7dff91f7f7823 --- .github/workflows/tools_tests.yaml | 4 ++-- tools/plotjuggler/juggle.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index a051cb1241..ff0e29e9e2 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -31,7 +31,7 @@ jobs: - uses: ./.github/workflows/setup-with-retry - name: Build openpilot timeout-minutes: 5 - run: ${{ env.RUN }} "scons -j$(nproc) cereal/ common/ --minimal" + run: ${{ env.RUN }} "scons -j$(nproc) cereal/ common/ opendbc/ --minimal" - name: Test PlotJuggler timeout-minutes: 2 run: | @@ -99,4 +99,4 @@ jobs: - name: Test notebooks timeout-minutes: 3 run: | - ${{ env.RUN }} "pip install nbmake && pytest --nbmake tools/car_porting/examples/" \ No newline at end of file + ${{ env.RUN }} "pip install nbmake && pytest --nbmake tools/car_porting/examples/" diff --git a/tools/plotjuggler/juggle.py b/tools/plotjuggler/juggle.py index 0caf5a18ff..1d1612a1cd 100755 --- a/tools/plotjuggler/juggle.py +++ b/tools/plotjuggler/juggle.py @@ -11,19 +11,20 @@ import argparse from functools import partial from openpilot.common.basedir import BASEDIR +from openpilot.selfdrive.car.fingerprints import MIGRATION from openpilot.tools.lib.helpers import save_log - from openpilot.tools.lib.logreader import LogReader, ReadMode juggle_dir = os.path.dirname(os.path.realpath(__file__)) DEMO_ROUTE = "a2a0ccea32023010|2023-07-27--13-01-19" -RELEASES_URL="https://github.com/commaai/PlotJuggler/releases/download/latest" +RELEASES_URL = "https://github.com/commaai/PlotJuggler/releases/download/latest" INSTALL_DIR = os.path.join(juggle_dir, "bin") PLOTJUGGLER_BIN = os.path.join(juggle_dir, "bin/plotjuggler") MINIMUM_PLOTJUGGLER_VERSION = (3, 5, 2) MAX_STREAMING_BUFFER_SIZE = 1000 + def install(): m = f"{platform.system()}-{platform.machine()}" supported = ("Linux-x86_64", "Linux-aarch64", "Darwin-arm64", "Darwin-x86_64") @@ -38,7 +39,7 @@ def install(): with requests.get(url, stream=True, timeout=10) as r, tempfile.NamedTemporaryFile() as tmp: r.raise_for_status() with open(tmp.name, 'wb') as tmpf: - for chunk in r.iter_content(chunk_size=1024*1024): + for chunk in r.iter_content(chunk_size=1024 * 1024): tmpf.write(chunk) with tarfile.open(tmp.name) as tar: @@ -69,9 +70,11 @@ def start_juggler(fn=None, dbc=None, layout=None, route_or_segment_name=None): cmd = f'{PLOTJUGGLER_BIN} --buffer_size {MAX_STREAMING_BUFFER_SIZE} --plugin_folders {INSTALL_DIR}{extra_args}' subprocess.call(cmd, shell=True, env=env, cwd=juggle_dir) + def process(can, lr): return [d for d in lr if can or d.which() not in ['can', 'sendcan']] + def juggle_route(route_or_segment_name, can, layout, dbc=None): sr = LogReader(route_or_segment_name, default_mode=ReadMode.AUTO_INTERACTIVE) @@ -82,7 +85,8 @@ def juggle_route(route_or_segment_name, can, layout, dbc=None): for cp in [m for m in all_data if m.which() == 'carParams']: try: DBC = __import__(f"openpilot.selfdrive.car.{cp.carParams.carName}.values", fromlist=['DBC']).DBC - dbc = DBC[cp.carParams.carFingerprint]['pt'] + fingerprint = cp.carParams.carFingerprint + dbc = DBC[MIGRATION.get(fingerprint, fingerprint)]['pt'] except Exception: pass break