64 releases (7 breaking)
new 0.8.2 | Jan 16, 2025 |
---|---|
0.7.1 | Jan 7, 2025 |
0.6.1 | Dec 7, 2024 |
0.5.5 | Nov 25, 2024 |
0.4.1 | Nov 14, 2023 |
#228 in Algorithms
927 downloads per month
1MB
6.5K
SLoC
Rust Radio
A library for digital signals processing in the spirit of GNU Radio.
Differences from GNU Radio
Pro
- Written in Rust instead of C++ & Python.
- Easier to get things right than C++.
- More performant than Python (and possibly more performant than C++).
- Easier to ship as a built binary.
- Type safe streams.
Con
- GNU Radio is obviously way more mature.
- GNU Radio has a very nice UI for iterating on graphs.
Missing feature before declaring 1.0
- A clear strategy for optional output streams.
- SymbolSync block at least have the right API.
- Example AX.25 KISS modem written.
- Add cargo-semver-checks to pre-commit or bump-version?
lib.rs
:
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/
Test helper functions.
Dependencies
~7–37MB
~578K SLoC