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, GraphRunner};
use rustradio::blocks::{AddConst, VectorSource, DebugSink};
use rustradio::Complex;
let (src, prev) = VectorSource::new(
vec![
Complex::new(10.0, 0.0),
Complex::new(-20.0, 0.0),
Complex::new(100.0, -100.0),
],
);
let (add, prev) = AddConst::new(prev, Complex::new(1.1, 2.0));
let sink = DebugSink::new(prev);
let mut g = Graph::new();
g.add(Box::new(src));
g.add(Box::new(add));
g.add(Box::new(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/
Re-exports§
pub use rustradio_macros;
Modules§
- add
- Add two streams.
- add_
const - Add a constant value to every sample.
- au
- Blocks for the Au file format.
- binary_
slicer - Turn positive Float values into binary
1u8
, and negative into0u8
. - block
- RustRadio Block implementation
- blocks
- Convenient mod collecting all standard library blocks for import.
- burst_
tagger - Burst tagger.
- circular_
buffer - Test implementation of circular buffers. Full of unsafe. Full of ugly code.
- cma
- WIP. Completely untested.
- complex_
to_ mag2 - Convert Complex numbers to square of their magnitude.
- constant_
source - Generate the same value, forever.
- convert
- Blocks for converting from one type to another.
- correlate_
access_ code - Correlate Access Code blocks.
- debug_
sink - Print values to stdout, for debugging.
- delay
- Delay stream. Good for syncing up streams.
- descrambler
- LFSR based Descrambler.
- fft_
filter - FFT filter. Like a FIR filter, but more efficient when there are many taps.
- fft_
stream - FFT stream.
- file_
sink - Send stream to raw file.
- file_
source - Read stream from raw file.
- fir
- Finite impulse response filter.
- graph
- Graphs contain blocks connected by streams, and run them.
- hdlc_
deframer - HDLC Deframer.
- hilbert
- Hilbert transform.
- iir_
filter - Infinite impulse response filter
- il2p_
deframer - IL2P Deframer
- mtgraph
- Multithreaded version of Graph, otherwise the same as graph.rs.
- multiply_
const - Multiply stream by a constant value.
- nrzi
- NRZI — Non return to zero
- null_
sink - Discard anything written to this block.
- pdu_
writer - PDU Writer
- quadrature_
demod - Quadrature demod, the core of an FM demodulator.
- rational_
resampler - Resample by a fractional amount.
- rtlsdr_
decode - Decode RTL-SDR’s byte based format into Complex I/Q.
- sigmf
- SigMF implementation.
- signal_
source - Generate a pure signal.
- single_
pole_ iir_ filter - Infinite Impulse Response (IIR) filter.
- skip
- Skip samples, then stream at full speed.
- stream
- Streams connecting blocks.
- stream_
to_ pdu - Stream to PDU.
- symbol_
sync - Clock recovery implementations
- tcp_
source - TCP source.
- tee
- Tee a stream
- to_text
- Turn samples into text.
- vec_
to_ stream - Vector to stream block.
- vector_
sink - Sink values into a vector.
- vector_
source - Generate values from a fixed vector.
- window
- Window functions
- wpcr
- Whole packet clock recovery block.
- xor
- Xor two streams.
- xor_
const - Xor a constant value with every sample.
- zero_
crossing - Very simple clock recovery.