mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
fix: detect bias-t support before passing -T to rtl_sdr/rtl_fm
Stock rtl-sdr packages don't support the -T bias-tee flag (only RTL-SDR Blog builds do). Passing -T to stock rtl_sdr causes an immediate exit, breaking meteor scatter and waterfall modes. Now probes the tool's --help output before adding -T, with a regex that avoids false-matching "DVB-T" in the description text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ with existing RTL-SDR installations. No SoapySDR dependency required.
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import re
|
||||
import subprocess
|
||||
from typing import Optional
|
||||
|
||||
@@ -23,6 +24,28 @@ def _rtl_fm_demod_mode(modulation: str) -> str:
|
||||
return 'wbfm' if mod == 'wfm' else mod
|
||||
|
||||
|
||||
def _rtl_tool_supports_bias_t(tool_path: str) -> bool:
|
||||
"""Check if an rtl_* tool (rtl_fm, rtl_sdr) supports the -T bias-tee flag.
|
||||
|
||||
The -T flag is only available in RTL-SDR Blog builds, not in stock
|
||||
rtl-sdr packages shipped by most distros.
|
||||
"""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[tool_path, '--help'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5
|
||||
)
|
||||
help_text = result.stdout + result.stderr
|
||||
# Match "-T" as a CLI flag (e.g. "[-T]" or "-T enable bias"),
|
||||
# not as part of "DVB-T" or similar text.
|
||||
return bool(re.search(r'(?<!\w)-T\b', help_text))
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not detect bias-t support for {tool_path}: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def _get_dump1090_bias_t_flag(dump1090_path: str) -> Optional[str]:
|
||||
"""Detect the correct bias-t flag for the installed dump1090 variant.
|
||||
|
||||
@@ -126,7 +149,10 @@ class RTLSDRCommandBuilder(CommandBuilder):
|
||||
cmd.extend(['-E', 'direct2'])
|
||||
|
||||
if bias_t:
|
||||
cmd.extend(['-T'])
|
||||
if _rtl_tool_supports_bias_t(rtl_fm_path):
|
||||
cmd.append('-T')
|
||||
else:
|
||||
logger.warning("Bias-t requested but rtl_fm does not support -T (RTL-SDR Blog drivers required).")
|
||||
|
||||
# Output to stdout for piping
|
||||
cmd.append('-')
|
||||
@@ -283,7 +309,10 @@ class RTLSDRCommandBuilder(CommandBuilder):
|
||||
cmd.extend(['-p', str(ppm)])
|
||||
|
||||
if bias_t:
|
||||
cmd.append('-T')
|
||||
if _rtl_tool_supports_bias_t(rtl_sdr_path):
|
||||
cmd.append('-T')
|
||||
else:
|
||||
logger.warning("Bias-t requested but rtl_sdr does not support -T (RTL-SDR Blog drivers required).")
|
||||
|
||||
# Output to stdout
|
||||
cmd.append('-')
|
||||
|
||||
Reference in New Issue
Block a user