ade-ma / LibRedio

DSP abstractions
GNU General Public License v3.0
24 stars 2 forks source link

rtlsdr read_async doesn't seem to be working #30

Closed awelkie closed 9 years ago

awelkie commented 9 years ago

After a call to read_async, the callback doesn't seem to be getting called. Here's my main function:

fn main() {
    let dev = open_device();
    set_frequency(dev, 101_000_000);
    set_sample_rate(dev, 1_000_000);
    set_gain_auto(dev);
    let source = read_async(dev, 1024);
    loop {
        let data = source.recv();
        println!("got data");
    }
}

I'm not getting any of the "got data" printouts. I know my rtlsdr is working, because the rtl_fm utility is working. This is on arch linux x86_64, with rustc version rustc 0.13.0-nightly (99d6956c3 2014-12-18 20:32:07 +0000), with the Rafael Micro R820T tuner. Any idea what's wrong?

awelkie commented 9 years ago

Ah, I figured it out. It was a missing call to clear_buffer:


fn main() {
    let dev = open_device();
    set_frequency(dev, 101_000_000);
    set_sample_rate(dev, 1_000_000);
    set_gain_auto(dev);
    clear_buffer(dev);
    let source = read_async(dev, 1024);
    loop {
        let data = source.recv();
        println!("got data");
    }
}
itdaniher commented 9 years ago

Thanks! I welcome any additional bug reports / questions / comments. I'll be sure to add sample code showing the correct use of read_async.