Skip to main content

Crate rtlsdr_nusb

Crate rtlsdr_nusb 

Source
Expand description

Native RTL2832U / R820T / R828D driver built on nusb.

Device and stream operations can be awaited, or synchronously executed with MaybeFuture::wait on native targets. Enable smol or tokio when awaiting native discovery, opening, and endpoint setup; no runtime is required by the blocking API. WebUSB supports awaiting only and requires --cfg=web_sys_unstable_apis in the application’s Rust flags.

An independently owned RxStream keeps the hardware alive. Stop preserves its exclusive claim; consuming close releases it. Device::shutdown is terminal and returns Error::Busy until the stream has been closed/dropped.

use rtlsdr_nusb::{Complex32, Device, MaybeFuture};
use std::time::Duration;

let mut device = Device::builder()
    .frequency_hz(100_000_000)
    .sample_rate_hz(2_048_000)
    .open().wait()?;
let mut rx = device.rx_stream()?;
rx.start().wait()?;
let mut samples = [Complex32::default(); 4096];
let count = rx.read(&mut samples, Some(Duration::from_secs(1))).wait()?;
println!("received {count} samples");
rx.close().wait()?;
device.shutdown().wait()?;

Structs§

Config
Complete, statically validated receiver configuration.
ConfigBuilder
Builder for reusable receiver configurations.
Device
Owned device handle with a separately owned receive stream. Dropping the handle does not interrupt an outstanding stream, even if stopped.
DeviceBuilder
Select and configure a receiver. Standard IDs are 0bda:2832 and 0bda:2838.
DeviceDescriptor
USB identity collected during enumeration and completed during open.
DeviceInfo
Immutable identity captured during device initialization.
F32Iq
Converted complex f32 samples (the default).
RawIq
Raw unsigned eight-bit complex samples.
RxStream
Owned receive stream for sample mode M, defaulting to F32Iq.
SampleBlock
Borrowed view of one raw receive block.
StreamingStats
Counters collected during a receive stream.

Enums§

DirectSampling
Direct ADC input for frequencies below 28.8 MHz on non-V4 dongles. Requires appropriate board wiring. Blog V4 uses its own upconverter instead.
Error
Error returned by a RTL-SDR operation.
ErrorKind
Stable error category.
GainConfig
Tuner gain policy. Manual gain is approximate, using the reference driver’s measured 2.3 dB LNA and 1.2 dB mixer steps with a fixed VGA setting.
SampleFormat
Representation delivered to the application.
TunerKind
Detected tuner family. R820T-compatible revisions share the same chip ID.

Constants§

MAX_F32_IQ_SAMPLES_PER_TRANSFER
Maximum number of unpacked complex F32Iq samples produced by one USB transfer.

Traits§

MaybeFuture
IO that may be performed synchronously or asynchronously.
SampleMode
Sealed compile-time sample format used by devices and streams.

Type Aliases§

Complex32
Alias for a Complex<f32>
Result
Crate result alias using Error.