libSDRForge
Loading...
Searching...
No Matches
sdrforge.adapters.rtl_sdr.RtlSdrSource Class Reference

Acquire unsigned 8-bit interleaved IQ through librtlsdr. More...

Inheritance diagram for sdrforge.adapters.rtl_sdr.RtlSdrSource:
sdrforge.interfaces.sdr_source_if.SdrSourceIf

Public Member Functions

None __init__ (self, int device_index=0, int block_bytes=DEFAULT_BLOCK_BYTES, Any|None library=None, str acquisition_mode="auto", int queue_blocks=32, int|None usb_fd=None)
 Initialize the instance.
None open (self)
 Load librtlsdr and open the selected RTL-SDR device.
None close (self)
 Release the device even if asynchronous acquisition already failed.
bool is_connected (self)
 Return whether the connected.
SdrCapabilities get_capabilities (self)
 Return the capabilities.
None set_center_frequency (self, int frequency_hz)
 Set the center frequency.
int get_center_frequency (self)
 Return the center frequency.
None set_sample_rate (self, int sample_rate_hz)
 Set the sample rate.
int get_sample_rate (self)
 Return the sample rate.
None set_gain (self, float|None gain_db)
 Set the gain.
dict[str, int|float|None] get_hardware_configuration (self)
 Read librtlsdr's reported settings, independently of Python caches.
None set_rtl_agc (self, bool enabled)
 Configure RTL2832 digital AGC independently of tuner gain.
None set_ppm_correction (self, int ppm)
 Set RTL-SDR oscillator correction before acquisition.
None start (self)
 Start the component.
None stop (self)
 Stop the async worker; tolerate cancel failure after USB disconnect.
dict[str, int|float] get_acquisition_stats (self)
 Return the acquisition stats.
IqBlock read_iq (self)
 Read iq.

Static Public Attributes

int DEFAULT_SAMPLE_RATE_HZ = 2_400_000
int DEFAULT_BLOCK_BYTES = 262_144
int MIN_FREQUENCY_HZ = 24_000_000
int MAX_FREQUENCY_HZ = 1_766_000_000

Protected Member Functions

bool _use_async (self, Any library)
None _on_iq (self, Any buffer, int length, ctypes.c_void_p _context)
None _run_async (self)
tuple[ctypes.c_void_p, Any] _require_device (self)

Static Protected Member Functions

None _check (int result, str operation)
ctypes.CDLL _load_library ()
None _configure_library (Any library)

Protected Attributes

str _acquisition_mode = acquisition_mode
queue.Queue[IqBlock] _queue = queue.Queue(maxsize=queue_blocks)
threading.Thread|None _worker = None
Any _callback = None
str|None _worker_error = None
int _dropped_blocks = 0
int _received_blocks = 0
int|None _first_callback_ns = None
int|None _previous_callback_ns = None
int _callback_gap_max_ns = 0
int _callback_gap_over_2x = 0
int _callback_gap_over_4x = 0
int _queue_high_water = 0
int _startup_gap_max_ns = 0
int _startup_gap_over_2x = 0
 _usb_fd = usb_fd
 _device_index = device_index
 _block_bytes = block_bytes
 _library = library
 _device = ctypes.c_void_p()
int _center_frequency_hz = 0
int _sample_rate_hz = self.DEFAULT_SAMPLE_RATE_HZ
float|None _gain_db = None
bool _rtl_agc_enabled = False
int _ppm_correction = 0
bool _running = False

Detailed Description

Acquire unsigned 8-bit interleaved IQ through librtlsdr.

Constructor & Destructor Documentation

◆ __init__()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.__init__ ( self,
int device_index = 0,
int block_bytes = DEFAULT_BLOCK_BYTES,
Any | None library = None,
str acquisition_mode = "auto",
int queue_blocks = 32,
int | None usb_fd = None )

Initialize the instance.

Parameters
selfThe current instance.
device_indexThe device_index value.
block_bytesThe block_bytes value.
libraryThe library value.
acquisition_modeThe acquisition_mode value.
queue_blocksThe queue_blocks value.
usb_fdThe usb_fd value.

Member Function Documentation

◆ _check()

None sdrforge.adapters.rtl_sdr.RtlSdrSource._check ( int result,
str operation )
staticprotected

◆ _configure_library()

None sdrforge.adapters.rtl_sdr.RtlSdrSource._configure_library ( Any library)
staticprotected
Declare the librtlsdr ABI when using a real ctypes library.

◆ _load_library()

ctypes.CDLL sdrforge.adapters.rtl_sdr.RtlSdrSource._load_library ( )
staticprotected

◆ _on_iq()

None sdrforge.adapters.rtl_sdr.RtlSdrSource._on_iq ( self,
Any buffer,
int length,
ctypes.c_void_p _context )
protected

◆ _require_device()

tuple[ctypes.c_void_p, Any] sdrforge.adapters.rtl_sdr.RtlSdrSource._require_device ( self)
protected

◆ _run_async()

None sdrforge.adapters.rtl_sdr.RtlSdrSource._run_async ( self)
protected

◆ _use_async()

bool sdrforge.adapters.rtl_sdr.RtlSdrSource._use_async ( self,
Any library )
protected

◆ close()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.close ( self)

Release the device even if asynchronous acquisition already failed.

Parameters
selfThe current instance.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ get_acquisition_stats()

dict[str, int | float] sdrforge.adapters.rtl_sdr.RtlSdrSource.get_acquisition_stats ( self)

Return the acquisition stats.

Parameters
selfThe current instance.
Returns
The operation result.

◆ get_capabilities()

SdrCapabilities sdrforge.adapters.rtl_sdr.RtlSdrSource.get_capabilities ( self)

Return the capabilities.

Parameters
selfThe current instance.
Returns
The operation result.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ get_center_frequency()

int sdrforge.adapters.rtl_sdr.RtlSdrSource.get_center_frequency ( self)

Return the center frequency.

Parameters
selfThe current instance.
Returns
The operation result.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ get_hardware_configuration()

dict[str, int | float | None] sdrforge.adapters.rtl_sdr.RtlSdrSource.get_hardware_configuration ( self)

Read librtlsdr's reported settings, independently of Python caches.

A successful readback confirms driver state, not physical tuner PLL lock. Missing optional librtlsdr symbols are reported as null.

Parameters
selfThe current instance.
Returns
The operation result.

◆ get_sample_rate()

int sdrforge.adapters.rtl_sdr.RtlSdrSource.get_sample_rate ( self)

Return the sample rate.

Parameters
selfThe current instance.
Returns
The operation result.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ is_connected()

bool sdrforge.adapters.rtl_sdr.RtlSdrSource.is_connected ( self)

Return whether the connected.

Parameters
selfThe current instance.
Returns
The operation result.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ open()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.open ( self)

Load librtlsdr and open the selected RTL-SDR device.

Parameters
selfThe current instance.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ read_iq()

IqBlock sdrforge.adapters.rtl_sdr.RtlSdrSource.read_iq ( self)

Read iq.

Parameters
selfThe current instance.
Returns
The operation result.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ set_center_frequency()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.set_center_frequency ( self,
int frequency_hz )

Set the center frequency.

Parameters
selfThe current instance.
frequency_hzThe frequency in hertz.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ set_gain()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.set_gain ( self,
float | None gain_db )

Set the gain.

Parameters
selfThe current instance.
gain_dbThe tuner gain in decibels, or None for automatic gain.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ set_ppm_correction()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.set_ppm_correction ( self,
int ppm )

Set RTL-SDR oscillator correction before acquisition.

Parameters
selfThe current instance.
ppmThe ppm value.

◆ set_rtl_agc()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.set_rtl_agc ( self,
bool enabled )

Configure RTL2832 digital AGC independently of tuner gain.

Parameters
selfThe current instance.
enabledThe enabled value.

◆ set_sample_rate()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.set_sample_rate ( self,
int sample_rate_hz )

Set the sample rate.

Parameters
selfThe current instance.
sample_rate_hzThe sample rate in hertz.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ start()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.start ( self)

Start the component.

Parameters
selfThe current instance.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

◆ stop()

None sdrforge.adapters.rtl_sdr.RtlSdrSource.stop ( self)

Stop the async worker; tolerate cancel failure after USB disconnect.

Parameters
selfThe current instance.

Reimplemented from sdrforge.interfaces.sdr_source_if.SdrSourceIf.

Member Data Documentation

◆ _acquisition_mode

str sdrforge.adapters.rtl_sdr.RtlSdrSource._acquisition_mode = acquisition_mode
protected

◆ _block_bytes

sdrforge.adapters.rtl_sdr.RtlSdrSource._block_bytes = block_bytes
protected

◆ _callback

Any sdrforge.adapters.rtl_sdr.RtlSdrSource._callback = None
protected

◆ _callback_gap_max_ns

int sdrforge.adapters.rtl_sdr.RtlSdrSource._callback_gap_max_ns = 0
protected

◆ _callback_gap_over_2x

sdrforge.adapters.rtl_sdr.RtlSdrSource._callback_gap_over_2x = 0
protected

◆ _callback_gap_over_4x

sdrforge.adapters.rtl_sdr.RtlSdrSource._callback_gap_over_4x = 0
protected

◆ _center_frequency_hz

sdrforge.adapters.rtl_sdr.RtlSdrSource._center_frequency_hz = 0
protected

◆ _device

sdrforge.adapters.rtl_sdr.RtlSdrSource._device = ctypes.c_void_p()
protected

◆ _device_index

sdrforge.adapters.rtl_sdr.RtlSdrSource._device_index = device_index
protected

◆ _dropped_blocks

sdrforge.adapters.rtl_sdr.RtlSdrSource._dropped_blocks = 0
protected

◆ _first_callback_ns

int | None sdrforge.adapters.rtl_sdr.RtlSdrSource._first_callback_ns = None
protected

◆ _gain_db

sdrforge.adapters.rtl_sdr.RtlSdrSource._gain_db = None
protected

◆ _library

sdrforge.adapters.rtl_sdr.RtlSdrSource._library = library
protected

◆ _ppm_correction

sdrforge.adapters.rtl_sdr.RtlSdrSource._ppm_correction = 0
protected

◆ _previous_callback_ns

int | None sdrforge.adapters.rtl_sdr.RtlSdrSource._previous_callback_ns = None
protected

◆ _queue

queue.Queue[IqBlock] sdrforge.adapters.rtl_sdr.RtlSdrSource._queue = queue.Queue(maxsize=queue_blocks)
protected

◆ _queue_high_water

sdrforge.adapters.rtl_sdr.RtlSdrSource._queue_high_water = 0
protected

◆ _received_blocks

sdrforge.adapters.rtl_sdr.RtlSdrSource._received_blocks = 0
protected

◆ _rtl_agc_enabled

sdrforge.adapters.rtl_sdr.RtlSdrSource._rtl_agc_enabled = False
protected

◆ _running

bool sdrforge.adapters.rtl_sdr.RtlSdrSource._running = False
protected

◆ _sample_rate_hz

sdrforge.adapters.rtl_sdr.RtlSdrSource._sample_rate_hz = self.DEFAULT_SAMPLE_RATE_HZ
protected

◆ _startup_gap_max_ns

int sdrforge.adapters.rtl_sdr.RtlSdrSource._startup_gap_max_ns = 0
protected

◆ _startup_gap_over_2x

sdrforge.adapters.rtl_sdr.RtlSdrSource._startup_gap_over_2x = 0
protected

◆ _usb_fd

sdrforge.adapters.rtl_sdr.RtlSdrSource._usb_fd = usb_fd
protected

◆ _worker

threading.Thread | None sdrforge.adapters.rtl_sdr.RtlSdrSource._worker = None
protected

◆ _worker_error

str | None sdrforge.adapters.rtl_sdr.RtlSdrSource._worker_error = None
protected

◆ DEFAULT_BLOCK_BYTES

int sdrforge.adapters.rtl_sdr.RtlSdrSource.DEFAULT_BLOCK_BYTES = 262_144
static

◆ DEFAULT_SAMPLE_RATE_HZ

int sdrforge.adapters.rtl_sdr.RtlSdrSource.DEFAULT_SAMPLE_RATE_HZ = 2_400_000
static

◆ MAX_FREQUENCY_HZ

int sdrforge.adapters.rtl_sdr.RtlSdrSource.MAX_FREQUENCY_HZ = 1_766_000_000
static

◆ MIN_FREQUENCY_HZ

int sdrforge.adapters.rtl_sdr.RtlSdrSource.MIN_FREQUENCY_HZ = 24_000_000
static

The documentation for this class was generated from the following file: