SoapySDR rust bindings reading samples

I’ve been trying to use the rust soapysdr bindings to control an RTL-SDR usb dongle.

I’ve been running into difficulties with reading samples out of the device, and think it has to do with the way I’m giving my buffer to the function.

let mut samples: [Complex<i8>; 131072] = [Complex::new(1,0); 131072];

let mut buffer: &[&mut [Complex<i8>]] = &[&mut samples];

let read_buffer = soapysdr::RxStream::read(&mut rx_stream, buffer, 1000000);
    

Whenever I compile my code ‘read_buffer’ returns an error with the message “timed out”.

I spent a couple of hours trying to see if the device was timing out because of hardware driver stuff. I was able to use the SoapySDRUtil to probe the device no problem, and could get it to return some samples using rlt-sdr from the same package.

The rest of my code where I create the rx_stream, and instantiate the rtlsdr device seems to be working fine too.

If there is anyone who has experience writing anything with this specific crate advice would be much appreciated.

Diagnosing if this is an issue with my hardware drivers vs code is driving me crazy.

  • Not sure what’s the problem but if read is spposed to fill the buffer then it’s implementation invokes UB. Not the best look for a library..

    – 




  • @cafce25 I’ve read the source code of read and, indeed, it triggers UB by turning a &[...] into ` *mut […]`, then passing it to a function that (presumably) writes to the buffer.

    – 

Leave a Comment