1919# Last Update: July 11, 2026
2020##--------------------------------------------------------------------\
2121
22+ import atexit
2223import os
2324import shutil
2425import signal
2526import subprocess
2627import sys
2728import threading
29+ import weakref
2830
2931import numpy as np
3032
3133from . import constants as C
3234from .exceptions import (
3335 HackRFValueError , HackRFModeError , HackRFDeviceError , HackRFEnvironmentError ,
3436)
37+ from ._commands .info import InfoMixin
38+ from ._commands .capture import CaptureMixin
39+ from ._commands .transmit import TransmitMixin
40+ from ._commands .sweep import SweepMixin
41+ from ._commands .device import DeviceMixin
3542
3643# ---- platform interrupt plumbing -------------------------------------------
3744# hackrf_* tools flush + close cleanly on SIGINT. On Windows SIGINT can't be
@@ -66,9 +73,6 @@ def _interrupt(proc):
6673# interference problem). RX handles are registered by default but can opt out
6774# (an orphaned receiver only wastes disk, and fire-and-forget is occasionally
6875# wanted).
69- import atexit
70- import weakref
71-
7276_LIVE = weakref .WeakSet ()
7377
7478
@@ -86,13 +90,6 @@ def _stop_all_live():
8690 pass # best-effort on the way down; never raise from atexit
8791
8892
89- from ._commands .info import InfoMixin
90- from ._commands .capture import CaptureMixin
91- from ._commands .transmit import TransmitMixin
92- from ._commands .sweep import SweepMixin
93- from ._commands .device import DeviceMixin
94-
95-
9693# Upper bound on retained drained output per stream (stdout / stderr). The
9794# handle-mode drain and the streaming-mode stderr tail both cap here so a
9895# long-lived RX/TX handle can't grow memory without bound (hackrf_transfer
@@ -683,8 +680,6 @@ def relative_power_db(self, iq_or_dbfs, *, lna=None, vga=None, amp=None,
683680 value -= float (freq_correction (freq_hz ))
684681 return value
685682
686- return load_iq (path , count = count , offset_samples = offset_samples )
687-
688683 def estimate_capture (self , sample_rate , num_samples = None , duration = None ,
689684 path = "." ):
690685 # Bytes/sec = sample_rate * 2 (int8 I + int8 Q). Returns a dict and
@@ -755,4 +750,4 @@ def load_iq(path: str, count: int | None = None,
755750 iq .real = a [0 ::2 ]
756751 iq .imag = a [1 ::2 ]
757752 iq /= 128.0
758- return iq
753+ return iq
0 commit comments