From de3f972aa26eeee733d5510499565a70dc02363e Mon Sep 17 00:00:00 2001 From: Smittix Date: Mon, 2 Mar 2026 21:52:54 +0000 Subject: [PATCH] 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 --- utils/sdr/rtlsdr.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) 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('-')