mirror of
https://github.com/smittix/intercept.git
synced 2026-06-08 22:21:55 -07:00
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:-
This commit is contained in:
+25
-11
@@ -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 <gain> -p <ppm> -r <device> <freq1> <freq2> ...
|
||||
# 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 <gain> -p <ppm> -r <device> <freq1> <freq2> ...
|
||||
# - TLeconte v3: acarsdec -o 4 -g <gain> -p <ppm> -r <device> <freq1> <freq2> ...
|
||||
# - f00b4r0 (DragonOS): acarsdec --output json:file:- -g <gain> -p <ppm> -r <device> <freq1> ...
|
||||
# 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':
|
||||
|
||||
Reference in New Issue
Block a user