1 unstable release
Uses old Rust 2015
0.1.0 | Jan 17, 2018 |
---|
#6 in #rtl-sdr
6MB
131K
SLoC
rtlsdr_iq – I/Q complex sample lookup table for RTL-SDR
This crate provides a lookup table to map I/Q byte pairs from the RTL-SDR to complex, floating-point samples.
Example
use rtlsdr_iq::IQ;
// This is assuming little endian, where the Q byte is in the upper half of the word
// and the I byte is in the lower half.
let a = IQ[0x01_00u16];
let b = IQ[0x01_02u16];
let c = IQ[0x00_02u16];
assert!(a.re != b.re);
assert!(a.im == b.im);
assert!(b.re == c.re);
assert!(b.im != c.im);
Usage
This crate can be used through cargo by adding it
as a dependency in Cargo.toml
:
[dependencies]
rtlsdr_iq = "1.1.0"
and importing it in the crate root:
extern crate rtlsdr_iq;
lib.rs
:
This crate provides a lookup table to map I/Q byte pairs from the RTL-SDR to complex, floating-point samples.
The raw byte pairs should first be transmuted to a sequence of u16
indexes (for
example, with slice-cast
), which can then be
used with the lookup table. Each lookup compiles to an unchecked array access, which
can be safely done due to the size limit of the index falling within the guaranteed
length of the table.
The I sample is always the first sample sent by the RTL-SDR and is always lower in memory than the corresponding Q sample. As such, the resulting 16-bit word will differ between little-endian and big-endian targets. To resolve this issue, the crate compiles a lookup table specific to the endianness of the target platform.
Example
use rtlsdr_iq::IQ;
// This is assuming little endian, where the Q byte is in the upper half of the word
// and the I byte is in the lower half.
let a = IQ[0x01_00u16];
let b = IQ[0x01_02u16];
let c = IQ[0x00_02u16];
assert!(a.re != b.re);
assert!(a.im == b.im);
assert!(b.re == c.re);
assert!(b.im != c.im);