https://github.com/yuvadm/rustl-sdr
A pure Rust implementation of the RTL-SDR driver
https://github.com/yuvadm/rustl-sdr
driver libusb rtl-sdr rust
Last synced: 3 months ago
JSON representation
A pure Rust implementation of the RTL-SDR driver
- Host: GitHub
- URL: https://github.com/yuvadm/rustl-sdr
- Owner: yuvadm
- License: gpl-3.0
- Created: 2018-07-23T08:25:01.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-04-28T14:21:16.000Z (about 5 years ago)
- Last Synced: 2025-08-01T21:53:21.127Z (11 months ago)
- Topics: driver, libusb, rtl-sdr, rust
- Language: Rust
- Homepage:
- Size: 92.8 KB
- Stars: 21
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RusTL-SDR
A pure Rust implementation of the RTL-SDR driver, for shits and giggles.
This is mostly an exercise in writing low-level driver code.
Unusable, and highly unlikely to ever become usable. But it's fun.
For real alternatives check out the original [librtlsdr](https://github.com/osmocom/rtl-sdr/) implementation or the high-level [rtlsdr_mt](https://github.com/kchmck/rtlsdr_mt.rs) Rust bindings.
## Usage
Install the crate in your `Cargo.toml`:
```toml
[dependencies]
rustl-sdr = "0.2"
```
Use in your code:
```rust
extern crate rustl_sdr;
fn foo() {
rtlsdr = rustl_sdr::RtlSdr::new(&ctx);
rtlsdr.init();
rtlsdr.do_stuff();
}
```
Or run one of the example binaries:
```bash
$ RUST_LOG=info cargo run --bin rustl_fm
```
## Dev
The usual:
```bash
$ cargo build
$ cargo test -- --nocapture
```
Since there isn't (?) any good USB device mocking setup, for tests to pass an RTL-SDR device must be connected.
## Design
### Overview
RusTL-SDR is very similar to the original rtl-sdr driver. It uses libusb, via the [rusb](https://github.com/a1ien/rusb/) bindings, as the main interface to issue commands to the rtl-sdr USB dongle.
### Lifecycle
Devices generally go through the following lifecycle:
1. Get a libusb context/handle, and find a compatible and supported RTL-SDR device
2. Initialize the device baseband
3. Probe the device for known tuners via the I2C interface
4. Run any special initialization required for the detected tuner
5. Interact with the device, usually this is where samples are read
6. Deinitialize the tuner
7. Deinitialize the baseband
8. Close the USB handle
## License
[GPLv3](LICENSE)