Expand description
This create provides a framework for running SDR (software defined radio) applications.
It’s heavily inspired by GNURadio, except of course written in Rust.
It currently has very few blocks, and is missing tags, and PDU messages.
In addition to the example applications in this crate, there’s also a sparslog project using this framework, that decodes IKEA Sparsnäs electricity meter RF signals.
§Architecture overview
A RustRadio application consists of blocks that are connected by unidirectional streams. Each block has zero or more input streams, and zero or more output streams.
The signal flows through the blocks from “sources” (blocks without any input streams) to “sinks” (blocks without any output streams.
These blocks and streams are called a “graph”, like the mathematical concept of graphs that have nodes and edges.
A block does something to its input(s), and passes the result to its output(s).
A typical graph will be something like:
[ Raw radio source ]
↓
[ Filtering ]
↓
[ Resampling ]
↓
[ Demodulation ]
↓
[ Symbol Sync ]
↓
[ Packet assembly and save ]
Or concretely, for sparslog:
[ RtlSdrSource ]
↓
[ RtlSdrDecode to convert from ]
[ own format to complex I/Q ]
↓
[ FftFilter ]
↓
[ RationalResampler ]
↓
[ QuadratureDemod ]
↓
[ AddConst for frequency offset ]
↓
[ ZeroCrossing symbol sync ]
↓
[ Custom Sparsnäs decoder ]
[ block in the binary, ]
[ not in the framework ]
§Examples
Here’s a simple example that creates a couple of blocks, connects them with streams, and runs the graph.
use rustradio::graph::Graph;
use rustradio::blocks::{AddConst, VectorSource, DebugSink};
use rustradio::Complex;
let src = Box::new(VectorSource::new(
vec![
Complex::new(10.0, 0.0),
Complex::new(-20.0, 0.0),
Complex::new(100.0, -100.0),
],
));
let add = Box::new(AddConst::new(src.out(), Complex::new(1.1, 2.0)));
let sink = Box::new(DebugSink::new(add.out()));
let mut g = Graph::new();
g.add(src);
g.add(add);
g.add(sink);
g.run()?;
§Links
- Main repo: https://github.com/ThomasHabets/rustradio
- crates.io: https://crates.io/crates/rustradio
- This documentation: https://docs.rs/rustradio/latest/rustradio/
Modules§
- Add two streams.
- Add a constant value to every sample.
- Blocks for the Au file format.
- Turn positive Float values into binary
1u8
, and negative into0u8
. - RustRadio Block implementation
- Convenient mod collecting all standard library blocks for import.
- Burst tagger.
- Test implementation of circular buffers. Full of unsafe. Full of ugly code.
- Convert Complex numbers to square of their magnitude.
- Generate the same value, forever.
- Blocks for converting from one type to another.
- Correlate Access Code blocks.
- Print values to stdout, for debugging.
- Delay stream. Good for syncing up streams.
- LFSR based Descrambler.
- FFT filter. Like a FIR filter, but more efficient when there are many taps.
- Send stream to raw file.
- Read stream from raw file.
- Finite impulse response filter.
- Graphs contain blocks connected by streams, and run them.
- HDLC Deframer.
- Hilbert transform.
- Infinite impulse response filter
- IL2P Deframer
- Multithreaded version of Graph, otherwise the same as graph.rs.
- Multiply stream by a constant value.
- NRZI — Non return to zero
- Discard anything written to this block.
- PDU Writer
- Quadrature demod, the core of an FM demodulator.
- Resample by a fractional amount.
- Decode RTL-SDR’s byte based format into Complex I/Q.
- SigMF implementation.
- Generate a pure signal.
- Infinite Impulse Response (IIR) filter.
- Skip samples, then stream at full speed.
- Streams connecting blocks.
- Stream to PDU.
- Clock recovery implementations
- TCP source.
- Tee a stream
- Turn samples into text.
- Vector to stream block.
- Generate values from a fixed vector.
- Window functions
- Whole packet clock recovery block.
- Xor two streams.
- Xor a constant value with every sample.
- Very simple clock recovery.
Macros§
- Macro to make it easier to write converting blocks.
- Version of map_block_convert_macro that supports adding tags.
- Macro to make it easier to write one-for-one blocks.
Structs§
- RustRadio error.
Traits§
- Trivial trait for types that have .len().
- A trait all sample types must implement.
Type Aliases§
- Complex (I/Q) data.
- Float type used. Usually f32, but not guaranteed.