diff --git a/utils/sdr/rtlsdr.py b/utils/sdr/rtlsdr.py index 3cede61..645d709 100644 --- a/utils/sdr/rtlsdr.py +++ b/utils/sdr/rtlsdr.py @@ -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'(? 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('-')