pub struct Device { /* private fields */ }Expand description
Device struct
Implementations§
Source§impl Device
impl Device
Sourcepub fn open(&mut self) -> Result<(), RtlsdrError>
pub fn open(&mut self) -> Result<(), RtlsdrError>
Open device This may fail due to a libusb error or some other unspecified error
pub fn close(&mut self) -> Result<(), String>
Sourcepub fn get_xtal_freq(&self) -> Result<(u32, u32), String>
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.
Sourcepub fn set_xtal_freq(
&mut self,
rtl_freq: u32,
tuner_freq: u32,
) -> Result<(), String>
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.
Sourcepub fn get_usb_device_strings(&self) -> Result<(String, String, String), String>
pub fn get_usb_device_strings(&self) -> Result<(String, String, String), String>
Get USB device strings. @return (manufacturer, product, serial) strings
Sourcepub fn read_eeprom(&self, offset: u8, len: u16) -> Result<Vec<u8>, String>
pub fn read_eeprom(&self, offset: u8, len: u16) -> Result<Vec<u8>, String>
Read the device EEPROM
Sourcepub fn write_eeprom(&mut self, offset: u8, buf: &mut [u8]) -> Result<(), String>
pub fn write_eeprom(&mut self, offset: u8, buf: &mut [u8]) -> Result<(), String>
Write the device EEPROM
Sourcepub fn get_center_freq(&self) -> Result<u32, String>
pub fn get_center_freq(&self) -> Result<u32, String>
Get actual frequency the device is tuned to in Hz
Sourcepub fn set_center_freq(&mut self, freq: u32) -> Result<(), String>
pub fn set_center_freq(&mut self, freq: u32) -> Result<(), String>
Set the frequency the device is tuned to in Hz
Sourcepub fn get_freq_correction(&self) -> i32
pub fn get_freq_correction(&self) -> i32
Get actual frequency correction value of the device. @return correction value in parts per million (ppm)
Sourcepub fn set_freq_correction(&mut self, ppm: i32) -> Result<(), String>
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)
Sourcepub fn get_tuner_type(&self) -> TunerType
pub fn get_tuner_type(&self) -> TunerType
Get the tuner type
Sourcepub fn get_tuner_gains(&self) -> Vec<i32>
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
Sourcepub fn get_tuner_gain(&self) -> i32
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
Sourcepub fn set_tuner_gain(&mut self, gain: i32) -> Result<(), String>
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
Sourcepub fn set_tuner_bandwidth(&mut self, bw: u32) -> Result<(), String>
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.
Sourcepub fn set_tuner_if_gain(&mut self, stage: i32, gain: i32) -> Result<(), String>
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.
Sourcepub fn set_tuner_gain_mode(&mut self, manual: bool) -> Result<(), String>
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.
Sourcepub fn get_sample_rate(&self) -> Result<u32, String>
pub fn get_sample_rate(&self) -> Result<u32, String>
Get actual sample rate the device is configured to. @return sample rate in Hz
Sourcepub fn set_sample_rate(&mut self, rate: u32) -> Result<(), String>
pub fn set_sample_rate(&mut self, rate: u32) -> Result<(), String>
Set the sample rate for the device. @param rate sample rate in Hz
Sourcepub fn set_test_mode(&mut self, test_mode: bool) -> Result<(), String>
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.
Sourcepub fn set_agc_mode(&mut self, enabled: bool) -> Result<(), String>
pub fn set_agc_mode(&mut self, enabled: bool) -> Result<(), String>
Enable or disable the internal digital AGC of the RTL2832.
Sourcepub fn get_direct_sampling(&self) -> Result<DirectSampling, String>
pub fn get_direct_sampling(&self) -> Result<DirectSampling, String>
Get state of the direct sampling mode
Sourcepub fn set_direct_sampling(
&mut self,
mode: DirectSampling,
) -> Result<(), String>
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).
Sourcepub fn get_offset_tuning(&self) -> Result<bool, String>
pub fn get_offset_tuning(&self) -> Result<bool, String>
Get state of the offset tuning mode
Sourcepub fn set_offset_tuning(&mut self, enabled: bool) -> Result<(), String>
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.
Sourcepub fn reset_buffer(&mut self) -> Result<(), String>
pub fn reset_buffer(&mut self) -> Result<(), String>
Reset buffer in RTL2832
Sourcepub fn wait_async<F>(&self, cb: F) -> Result<(), String>
👎Deprecated
pub fn wait_async<F>(&self, cb: F) -> Result<(), String>
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
Sourcepub fn read_async<F>(
&self,
cb: F,
buf_num: u32,
buf_len: u32,
) -> Result<(), String>
pub fn read_async<F>( &self, cb: F, buf_num: u32, buf_len: u32, ) -> Result<(), String>
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)
Sourcepub fn cancel_async(&self) -> Result<(), String>
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.
Sourcepub fn set_bias_tee(&mut self, on: bool) -> Result<(), String>
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.
Sourcepub fn set_bias_tee_gpio(&mut self, gpio: i32, on: bool) -> Result<(), String>
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.