Device

Struct Device 

Source
pub struct Device { /* private fields */ }
Expand description

Device struct

Implementations§

Source§

impl Device

Source

pub fn open(&mut self) -> Result<(), RtlsdrError>

Open device This may fail due to a libusb error or some other unspecified error

Source

pub fn close(&mut self) -> Result<(), String>

Source

pub fn get_xtal_freq(&self) -> Result<(u32, u32), String>

Get crystal oscillator frequencies used for the RTL2832 and the tuner IC Usually both ICs use the same clock.

Source

pub fn set_xtal_freq( &mut self, rtl_freq: u32, tuner_freq: u32, ) -> Result<(), String>

Set crystal oscillator frequencies used for the RTL2832 and the tuner IC. Usually both ICs use the same clock. Changing the clock may make sense if you are applying an external clock to the tuner or to compensate the frequency (and samplerate) error caused by the original (cheap) crystal. NOTE: Call this function only if you fully understand the implications.

Source

pub fn get_usb_device_strings(&self) -> Result<(String, String, String), String>

Get USB device strings. @return (manufacturer, product, serial) strings

Source

pub fn read_eeprom(&self, offset: u8, len: u16) -> Result<Vec<u8>, String>

Read the device EEPROM

Source

pub fn write_eeprom(&mut self, offset: u8, buf: &mut [u8]) -> Result<(), String>

Write the device EEPROM

Source

pub fn get_center_freq(&self) -> Result<u32, String>

Get actual frequency the device is tuned to in Hz

Source

pub fn set_center_freq(&mut self, freq: u32) -> Result<(), String>

Set the frequency the device is tuned to in Hz

Source

pub fn get_freq_correction(&self) -> i32

Get actual frequency correction value of the device. @return correction value in parts per million (ppm)

Source

pub fn set_freq_correction(&mut self, ppm: i32) -> Result<(), String>

Set frequency correction value for the device. @param ppm correction value in parts per million (ppm)

Source

pub fn get_tuner_type(&self) -> TunerType

Get the tuner type

Source

pub fn get_tuner_gains(&self) -> Vec<i32>

Get a list of gains supported by the tuner. Gain values in tenths of a dB, 115 means 11.5 dB

Source

pub fn get_tuner_gain(&self) -> i32

Get actual (RF / HF) gain the device is configured to - excluding the IF gain. Gain in tenths of a dB, 115 means 11.5 dB. unfortunately it’s impossible to distinguish error against 0 dB

Source

pub fn set_tuner_gain(&mut self, gain: i32) -> Result<(), String>

Set the gain for the device. Manual gain mode must be enabled for this to work. Valid gain values may be queried with rtlsdr_get_tuner_gains function. Gain in tenths of a dB, 115 means 11.5 dB

Source

pub fn set_tuner_bandwidth(&mut self, bw: u32) -> Result<(), String>

Set the bandwidth for the device. @param bw bandwidth in Hz. Zero means automatic BW selection.

Source

pub fn set_tuner_if_gain(&mut self, stage: i32, gain: i32) -> Result<(), String>

Set the intermediate frequency gain for the device. @param stage intermediate frequency gain stage number (1 to 6 for E4000) @param gain in tenths of a dB, -30 means -3.0 dB.

Source

pub fn set_tuner_gain_mode(&mut self, manual: bool) -> Result<(), String>

Set the gain mode (automatic/manual) for the device. Manual gain mode must be enabled for the gain setter function to work.

Source

pub fn get_sample_rate(&self) -> Result<u32, String>

Get actual sample rate the device is configured to. @return sample rate in Hz

Source

pub fn set_sample_rate(&mut self, rate: u32) -> Result<(), String>

Set the sample rate for the device. @param rate sample rate in Hz

Source

pub fn set_test_mode(&mut self, test_mode: bool) -> Result<(), String>

Enable test mode that returns an 8 bit counter instead of the samples. The counter is generated inside the RTL2832.

Source

pub fn set_agc_mode(&mut self, enabled: bool) -> Result<(), String>

Enable or disable the internal digital AGC of the RTL2832.

Source

pub fn get_direct_sampling(&self) -> Result<DirectSampling, String>

Get state of the direct sampling mode

Source

pub fn set_direct_sampling( &mut self, mode: DirectSampling, ) -> Result<(), String>

Enable or disable the direct sampling mode. When enabled, the IF mode of the RTL2832 is activated, and set_center_freq() will control the IF-frequency of the DDC, which can be used to tune from 0 to 28.8 MHz (xtal frequency of the RTL2832).

Source

pub fn get_offset_tuning(&self) -> Result<bool, String>

Get state of the offset tuning mode

Source

pub fn set_offset_tuning(&mut self, enabled: bool) -> Result<(), String>

Enable or disable offset tuning for zero-IF tuners, which allows to avoid problems caused by the DC offset of the ADCs and 1/f noise.

Source

pub fn reset_buffer(&mut self) -> Result<(), String>

Reset buffer in RTL2832

Source

pub fn read_sync(&self, buf: &mut [u8]) -> Result<i32, RtlsdrError>

Read data synchronously

Source

pub fn wait_async<F>(&self, cb: F) -> Result<(), String>
where F: FnMut(Vec<u8>),

👎Deprecated

Read samples from the device asynchronously. This function will block until it is being canceled using rtlsdr_cancel_async() NOTE: This function is deprecated and is subject for removal. @param cb callback function to return received samples @param ctx user specific context to pass via the callback function

Source

pub fn read_async<F>( &self, cb: F, buf_num: u32, buf_len: u32, ) -> Result<(), String>
where F: FnMut(Vec<u8>),

Read samples from the device asynchronously. This function will block until it is being canceled using rtlsdr_cancel_async() @param cb callback function to return received samples @param buf_num optional buffer count, buf_num * buf_len = overall buffer size set to 0 for default buffer count (15) @param buf_len optional buffer length, must be multiple of 512, should be a multiple of 16384 (URB size), set to 0 for default buffer length (16 * 32 * 512)

Source

pub fn cancel_async(&self) -> Result<(), String>

Cancel all pending asynchronous operations on the device. Due to incomplete concurrency implementation, this should only be called from within the callback function, so it is in the correct thread.

Source

pub fn set_bias_tee(&mut self, on: bool) -> Result<(), String>

Enable or disable (the bias tee on) GPIO PIN 0 - if not reconfigured. See rtlsdr_set_opt_string() option ‘T’. This works for rtl-sdr.com v3 dongles, see http://www.rtl-sdr.com/rtl-sdr-blog-v-3-dongles-user-guide/ Note: rtlsdr_close() does not clear GPIO lines, so it leaves the (bias tee) line enabled if a client program doesn’t explictly disable it.

Source

pub fn set_bias_tee_gpio(&mut self, gpio: i32, on: bool) -> Result<(), String>

Enable or disable (the bias tee on) the given GPIO pin. Note: rtlsdr_close() does not clear GPIO lines, so it leaves the (bias tee) lines enabled if a client program doesn’t explictly disable it. @param gpio the gpio pin – assuming this line is connected to Bias T. gpio needs to be in 0 .. 7. BUT pin 4 is connected to Tuner RESET. and for FC0012 is already connected/reserved pin 6 for switching V/U-HF. @param on: 1 for Bias T on. 0 for Bias T off.

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Device

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Device

Source§

fn eq(&self, other: &Device) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Device

Source§

impl Eq for Device

Source§

impl StructuralPartialEq for Device

Auto Trait Implementations§

§

impl Freeze for Device

§

impl RefUnwindSafe for Device

§

impl !Send for Device

§

impl !Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.