From 518da075de6342b753bee2e32cb633e0e053bab8 Mon Sep 17 00:00:00 2001 From: cemaxecuter Date: Tue, 27 Jan 2026 09:55:57 -0500 Subject: [PATCH] Support f00b4r0 acarsdec fork (DragonOS) Add detection for f00b4r0/acarsdec which uses --output json:file:- syntax instead of TLeconte's -j flag. Auto-detects fork by checking for --output in help output. Supports three acarsdec variants: - TLeconte v4+: -j - TLeconte v3.x: -o 4 - f00b4r0 (DragonOS): --output json:file:- --- routes/acars.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/routes/acars.py b/routes/acars.py index 6d1c74e..b5f3827 100644 --- a/routes/acars.py +++ b/routes/acars.py @@ -52,11 +52,13 @@ def find_acarsdec(): def get_acarsdec_json_flag(acarsdec_path: str) -> str: """Detect which JSON output flag acarsdec supports. - Version 4.0+ uses -j for JSON stdout. - Version 3.x uses -o 4 for JSON stdout. + Different forks use different flags: + - TLeconte v4.0+: uses -j for JSON stdout + - TLeconte v3.x: uses -o 4 for JSON stdout + - f00b4r0 fork (DragonOS): uses --output json:file:- for JSON stdout """ try: - # Get version by running acarsdec with no args (shows usage with version) + # Get help/version by running acarsdec with no args (shows usage) result = subprocess.run( [acarsdec_path], capture_output=True, @@ -65,8 +67,15 @@ def get_acarsdec_json_flag(acarsdec_path: str) -> str: ) output = result.stdout + result.stderr - # Parse version from output like "Acarsdec v4.3.1" or "Acarsdec/acarsserv 3.7" import re + + # Check for f00b4r0 fork signature: uses --output instead of -j/-o + # f00b4r0's help shows "--output" for output configuration + if '--output' in output or 'json:file:' in output.lower(): + logger.debug("Detected f00b4r0 acarsdec fork (--output syntax)") + return '--output' + + # Parse version from output like "Acarsdec v4.3.1" or "Acarsdec/acarsserv 3.7" version_match = re.search(r'acarsdec[^\d]*v?(\d+)\.(\d+)', output, re.IGNORECASE) if version_match: major = int(version_match.group(1)) @@ -79,7 +88,7 @@ def get_acarsdec_json_flag(acarsdec_path: str) -> str: except Exception as e: logger.debug(f"Could not detect acarsdec version: {e}") - # Default to -j (modern standard for current builds from source) + # Default to -j (TLeconte modern standard) return '-j' @@ -210,15 +219,20 @@ def start_acars() -> Response: acars_last_message_time = None # Build acarsdec command - # acarsdec -j -g -p -r ... - # Note: -j is JSON stdout (newer forks), -o 4 was the old syntax - # gain/ppm must come BEFORE -r + # Different forks have different syntax: + # - TLeconte v4+: acarsdec -j -g -p -r ... + # - TLeconte v3: acarsdec -o 4 -g -p -r ... + # - f00b4r0 (DragonOS): acarsdec --output json:file:- -g -p -r ... + # Note: gain/ppm must come BEFORE -r json_flag = get_acarsdec_json_flag(acarsdec_path) cmd = [acarsdec_path] - if json_flag == '-j': - cmd.append('-j') # JSON output (newer TLeconte fork) + if json_flag == '--output': + # f00b4r0 fork: --output json:file:- sends JSON to stdout + cmd.extend(['--output', 'json:file:-']) + elif json_flag == '-j': + cmd.append('-j') # JSON output (TLeconte v4+) else: - cmd.extend(['-o', '4']) # JSON output (older versions) + cmd.extend(['-o', '4']) # JSON output (TLeconte v3.x) # Add gain if not auto (must be before -r) if gain and str(gain) != '0':