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.
- Config
Builder - 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.
- Device
Builder - Select and configure a receiver. Standard IDs are
0bda:2832and0bda:2838. - Device
Descriptor - USB identity collected during enumeration and completed during open.
- Device
Info - Immutable identity captured during device initialization.
- F32Iq
- Converted complex
f32samples (the default). - RawIq
- Raw unsigned eight-bit complex samples.
- RxStream
- Owned receive stream for sample mode
M, defaulting toF32Iq. - Sample
Block - Borrowed view of one raw receive block.
- Streaming
Stats - Counters collected during a receive stream.
Enums§
- Direct
Sampling - 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.
- Error
Kind - Stable error category.
- Gain
Config - 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.
- Sample
Format - Representation delivered to the application.
- Tuner
Kind - Detected tuner family. R820T-compatible revisions share the same chip ID.
Constants§
- MAX_
F32_ IQ_ SAMPLES_ PER_ TRANSFER - Maximum number of unpacked complex
F32Iqsamples produced by one USB transfer.
Traits§
- Maybe
Future - IO that may be performed synchronously or asynchronously.
- Sample
Mode - Sealed compile-time sample format used by devices and streams.
Type Aliases§
- Complex32
- Alias for a
Complex<f32> - Result
- Crate result alias using
Error.