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<u64, String>
pub fn get_center_freq(&self) -> Result<u64, String>
Get actual frequency the device is tuned to in Hz
sourcepub fn set_center_freq(&mut self, freq: u64) -> Result<(), String>
pub fn set_center_freq(&mut self, freq: u64) -> Result<(), String>
Set the frequency the device is tuned to in Hz
sourcepub fn set_harmonic_rx(&mut self, harmonic: i32) -> Result<(), String>
pub fn set_harmonic_rx(&mut self, harmonic: i32) -> Result<(), String>
Set harmonic reception - for R820T/2 tuner @param harmonic - receive n’th harmonic. 0 = default for disabling this
sourcepub fn is_tuner_pll_locked(&self) -> Result<bool, String>
pub fn is_tuner_pll_locked(&self) -> Result<bool, String>
Check, if tuner PLL (frequency) is still locked. Tuner/PLL might loose lock (at high frequencies), e.g. for temperature reasons
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 get_bandwidth(&self) -> Result<u32, String>
pub fn get_bandwidth(&self) -> Result<u32, String>
Get the bandwidth for the device. Zero means automatic BW selection.
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_band_center(&mut self, center: i32) -> Result<(), String>
pub fn set_tuner_band_center(&mut self, center: i32) -> Result<(), String>
Sets the center of the filtered tuner band(width) @param center in Hz. Zero means, that band center shall be at zero (=default). set if_band_center_freq = +samplerate/4 to have the filtered band centered at output’s right half.
sourcepub fn set_tuner_sideband(&mut self, sideband: Sideband) -> Result<(), String>
pub fn set_tuner_sideband(&mut self, sideband: Sideband) -> Result<(), String>
Set the mixer sideband for the device.
sourcepub fn set_tuner_gain_ext(
&self,
lna_gain: i32,
mixer_gain: i32,
vga_gain: i32
) -> Result<(), String>
pub fn set_tuner_gain_ext( &self, lna_gain: i32, mixer_gain: i32, vga_gain: i32 ) -> Result<(), String>
Set LNA / Mixer / VGA Device Gain for R820T/2 device is configured to. @param lna_gain index in 0 .. 15: 0 == min; see tuner_r82xx.c table r82xx_lna_gain_steps[] @param mixer_gain index in 0 .. 15: 0 == min; see tuner_r82xx.c table r82xx_mixer_gain_steps[] @param vga_gain index in 0 .. 15: 0 == -12 dB; 15 == 40.5 dB; => 3.5 dB/step; vga_gain index 16 activates AGC for VGA controlled from RTL2832 see tuner_r82xx.c table r82xx_vga_gain_steps[]
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 set_tuner_if_mode(&mut self, agc_mode: i32) -> Result<(), String>
pub fn set_tuner_if_mode(&mut self, agc_mode: i32) -> Result<(), String>
Set the agc_variant for automatic gain mode for the device (only R820T/2). Automatic gain mode must be enabled for the gain setter function to work. @param if_mode 0: set automatic VGA, which is controlled from RTL2832 -2500 .. +2500: set fixed IF gain in tenths of a dB, 115 means 11.5 dB. use -1 or +1 in case you neither want attenuation nor gain. this equals the VGA gain for R820T/2 tuner. exact values (R820T/2) are in range -47 .. 408 in tenth of a dB, giving -4.7 .. +40.8 dB. these exact values may slightly change with better measurements. 10000 .. 10015: IF gain == VGA index from parameter if_mode set if_mode by index: index := VGA_idx +10000 10016 .. 10031: same as 10000 .. 10015, but additionally set automatic VGA 10011: for fixed VGA (=default) of -12 dB + 11 * 3.5 dB = 26.5 dB
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 set_ds_mode(
&mut self,
mode: DirectSamplingThreshold,
freq_threshold: u32
) -> Result<(), String>
pub fn set_ds_mode( &mut self, mode: DirectSamplingThreshold, freq_threshold: u32 ) -> Result<(), String>
Set direct sampling mode with threshold @param mode static modes 0 .. 2 as in rtlsdr_set_direct_sampling(). other modes do automatic switching @param freq_threshold direct sampling is used below this frequency, else quadrature mode through tuner set 0 for using default setting per tuner - not fully implemented yet!
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 set_dithering(&mut self, enabled: bool) -> Result<(), String>
pub fn set_dithering(&mut self, enabled: bool) -> Result<(), String>
Enable or disable frequency dithering for r820t tuners. Must be performed before freq_set(). Fails for other tuners.
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 ir_query(&self, buf: &mut [u8]) -> Result<i32, String>
pub fn ir_query(&self, buf: &mut [u8]) -> Result<i32, String>
Read from the remote control (RC) infrared (IR) sensor @param buf buffer to write IR signal (MSB=pulse/space, 7LSB=duration*20usec), recommended 128-bytes @param buf_len size of buf @return 0 if no signal, >0 number of bytes written into buf
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.
sourcepub fn set_gpio_bit(&mut self, gpio: u8, bit: i32) -> Result<(), String>
pub fn set_gpio_bit(&mut self, gpio: u8, bit: i32) -> Result<(), String>
Write a bit to a GPIO pin.
sourcepub fn get_gpio_byte(&self) -> Result<i32, String>
pub fn get_gpio_byte(&self) -> Result<i32, String>
Read GPIO byte.
sourcepub fn set_opt_string(
&mut self,
opts: String,
verbose: bool
) -> Result<(), String>
pub fn set_opt_string( &mut self, opts: String, verbose: bool ) -> Result<(), String>
Sets multiple options from a string encoded like “bw=300:agc=0:gain=27.3:dagc=0:T=1”. this is a helper function, that programs don’t need to implement every single option at the command line interface. Options are seperated by colon ‘:’. There mustn’t be extra spaces between option name and ‘=’. option ‘f’ set center frequency as in rtlsdr_set_center_freq() option ‘bw’ sets tuner bandwidth as in rtlsdr_set_tuner_bandwidth() - but value is in kHz. option ‘agc’ sets tuner gain mode as with rtlsdr_set_tuner_gain_mode(): ‘1’ means manual gain mode shall be enabled. option ‘gain’ sets tuner gain as with rtlsdr_set_tuner_gain(): values in tenth dB. option ‘dagc’ or ‘dgc’ de/activates digital agc as with rtlsdr_set_agc_mode(). 1 to enable. 0 to disable. option ‘ds’ set direct sampling as with rtlsdr_set_direct_sampling(): ‘0’ to deactivate, ‘1’ or ‘i’ for I-ADC input, ‘2’ or ‘q’ for Q-ADC input option ‘t’ or ‘T’ for enabling bias tee on GPIO PIN 0 as with rtlsdr_set_bias_tee(): ‘1’ for Bias T on. ‘0’ for Bias T off. @param opts described option string @param verbose print parsed options to stderr
sourcepub fn get_opt_help(long_info: bool) -> String
pub fn get_opt_help(long_info: bool) -> String
Get opt help
sourcepub fn get_tuner_i2c_register(&self, data: &mut [u8]) -> Result<(), String>
pub fn get_tuner_i2c_register(&self, data: &mut [u8]) -> Result<(), String>
Get tuner i2c register
sourcepub fn set_tuner_i2c_register(
&mut self,
i2c_register: u32,
mask: u8,
data: u8
) -> Result<(), String>
pub fn set_tuner_i2c_register( &mut self, i2c_register: u32, mask: u8, data: u8 ) -> Result<(), String>
Exposes/permits hacking of Tuner-specific I2C registers: set register once @param i2c_register register address @param mask 8-bit bitmask, indicating which bits shall be set @param data 8-bit data, which shall be set
sourcepub fn set_tuner_i2c_override(
&mut self,
i2c_register: u32,
mask: u8,
data: u8
) -> Result<(), String>
pub fn set_tuner_i2c_override( &mut self, i2c_register: u32, mask: u8, data: u8 ) -> Result<(), String>
Exposes/permits hacking of Tuner-specific I2C registers: set and keep register for future @param i2c_register register address @param mask 8-bit bitmask, indicating which bits shall be set @param data 8-bit data, which shall be set; data in 0 .. 255 sets override; data > 255 clears override
sourcepub fn get_version_id() -> &'static str
pub fn get_version_id() -> &'static str
Request version id string to identify source and date of library
sourcepub fn get_version() -> (u16, u16)
pub fn get_version() -> (u16, u16)
Request version numbers of library @return (major, minor)