airspy

Crates.ioairspy
lib.rsairspy
version0.4.0
sourcesrc
created_at2015-08-28 17:56:08.975775
updated_at2015-12-11 23:57:25.953017
descriptionRust bindings for libairspy
homepagehttps://github.com/adamgreig/airspy-rs
repositoryhttps://github.com/adamgreig/airspy-rs.git
max_upload_size
id2943
size32,686
Adam Greig (adamgreig)

documentation

README

Rust bindings for libairspy

Requires libairspy at least 1.0.6 already built and installed on your system. Tests require an attached Airspy (otherwise there is not much to test!) and must be run with RUST_TEST_THREADS=1 or the threads may stomp on each other.

Simple usage example:

extern crate airspy;
use airspy::{Airspy,IQ};
use std::sync::mpsc;

// Open first available Airspy and configure for floating IQ samples,
// 10Msps, 434MHz (can also set gains, AGC, RF bias etc).
let mut dev = Airspy::new().unwrap();
dev.set_sample_rate(0).unwrap();
dev.set_freq(434000000).unwrap();

// Samples are sent back to us from the C thread by an MPSC channel
let (tx, rx) = mpsc::channel();

// Begin receiving data. Need the type hint either here or when creating the
// channel, which must match with the sample type selected earlier.
dev.start_rx::<IQ<f32>>(tx).unwrap();

// Blocking receive samples, stop after 10M. When the `rx` object goes out of
// scope and is destroyed, the `tx` detects the hangup and tells libairspy to
// stop data reception.
let mut n_samples = 0usize;
while dev.is_streaming() {
    let samples = rx.recv().unwrap();
    n_samples += samples.len() / 2;
    println!("Got {} samples so far", n_samples);
    if n_samples > 10_000_000 {
        break;
    }
}

See src/bin/rx.rs for a complete example of usage.

Commit count: 16

cargo fmt