Skip to main content

Device

Struct Device 

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

Device struct

Implementations§

Source§

impl Device

Source

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

Open a device

§Errors

This will return an error if the device cannot be opened by librtlsdr (e.g. libusb failure or device is already open)

Examples found in repository?
examples/simple.rs (line 6)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

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

Close device

§Errors

This will return an error if the device cannot be closed by librtlsdr (e.g. libusb failure or device is not open)

Source

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

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

§Errors

This will return an error if the frequencies cannot be retrieved by librtlsdr (e.g. libusb failure or device is not open)

Source

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

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.

§Errors

This will return an error if the frequencies cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Source

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

Get USB device strings.

§Returns

(manufacturer, product, serial) strings

§Panics

This will panic if the retrieved strings from librtlsdr are not valid UTF-8 or if they are not null-terminated.

§Errors

This will return an error if the strings cannot be retrieved by librtlsdr (e

Examples found in repository?
examples/simple.rs (line 9)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

pub fn read_eeprom(&self, offset: u8, len: u16) -> Result<Box<[u8]>>

Read the device EEPROM

§Errors

This will return an error if the EEPROM cannot be read by librtlsdr (e.g. libusb failure or device is not open)

Source

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

Write the device EEPROM

§Errors

This will return an error if the EEPROM cannot be written by librtlsdr (e.g. libusb failure or device is not open)

§Panics

This will panic if the buffer length exceeds the maximum EEPROM size (65535 bytes)

Source

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

Get actual frequency the device is tuned to in Hz

§Errors

This will return an error if the frequency cannot be retrieved by librtlsdr (e.g. libusb failure or device is not open)

Source

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

Set the frequency the device is tuned to in Hz

§Errors

This will return an error if the frequency cannot be retrieved by librtlsdr (e.g. libusb failure or device is not open)

Examples found in repository?
examples/simple.rs (line 13)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

pub fn get_freq_correction(&self) -> i32

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

Source

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

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

§Errors

This will return an error if the frequency cannot be retrieved by librtlsdr (e.g. libusb failure or device is not open)

Source

pub fn get_tuner_type(&self) -> TunerType

Get the tuner type

Source

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

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

§Errors

This will return an error if the frequency cannot be retrieved by librtlsdr (e.g. libusb failure or device is not open)

Source

pub fn get_tuner_gain(&self) -> Result<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.

§Errors

This will return an error if the gain cannot be retrieved by librtlsdr (e.g. libusb failure or device is not open)

Source

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

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

§Errors

This will return an error if the gain cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Source

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

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

§Errors

This will return an error if the bandwidth cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Examples found in repository?
examples/simple.rs (line 15)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

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

Set the intermediate frequency gain for the device.

  • stage intermediate frequency gain stage number (1 to 6 for E4000)
  • gain in tenths of a dB, -30 means -3.0 dB.
§Errors

This will return an error if the IF gain cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Source

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

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

§Errors

This will return an error if the gain mode cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Examples found in repository?
examples/simple.rs (line 17)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

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

Get actual sample rate the device is configured to in Hz

§Errors

This will return an error if the sample rate cannot be retrieved by librtlsdr (e.g. libusb failure or device is not open)

Source

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

Set the sample rate for the device in Hz

§Errors

This will return an error if the sample rate cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Source

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

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

§Errors

This will return an error if the test mode cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Source

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

Enable or disable the internal digital AGC of the RTL2832.

§Errors

This will return an error if the AGC mode cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Examples found in repository?
examples/simple.rs (line 16)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

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

Get state of the direct sampling mode

§Errors

This will return an error if the direct sampling mode cannot be retrieved by librtlsdr (e.g. libusb failure or device is not open)

Source

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

Enable or disable the direct sampling mode. When enabled, the IF mode of the RTL2832 is activated, and Device::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).

§Errors

This will return an error if the direct sampling mode cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Examples found in repository?
examples/simple.rs (line 14)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

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

Get state of the offset tuning mode

§Errors

This will return an error if the offset tuning mode cannot be retrieved by librtlsdr (e.g. libusb failure or device is not open)

Source

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

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.

§Errors

This will return an error if the offset tuning mode cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Source

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

Reset buffer in RTL2832

§Errors

This will return an error if the buffer cannot be reset by librtlsdr (e.g. libusb failure or device is not open)

Examples found in repository?
examples/simple.rs (line 18)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

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

Read data synchronously Returns the number of bytes read.

§Errors

This will return an error if the samples cannot be read by librtlsdr (e.g. libusb failure or device is not open)

§Panics

This will panic if the buffer length exceeds the maximum value of i32 (2^31 - 1) bytes

Examples found in repository?
examples/simple.rs (line 22)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

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

Read samples from the device asynchronously. This will block until the asynchronous reading is canceled.

  • cb: callback function to return received samples, which should return true to cancel further reading or false to continue reading.
  • buf_num optional buffer count, buf_num * buf_len = overall buffer size set to 0 for default buffer count (15)
  • 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)
§Errors

This will return an error if the asynchronous reading cannot be started by librtlsdr (e.g. libusb failure or device is not open)

§Panics

This will panic if canceling the asynchronous reading from the callback fails

Examples found in repository?
examples/simple.rs (lines 28-43)
1fn main() -> rtlsdr::Result<()> {
2    let devices = rtlsdr::get_devices();
3    println!("Found {} device(s)", devices.len());
4
5    let mut device = devices[0];
6    device.open()?;
7
8    // Get and print the device information strings
9    let (manufacturer, product, serial) = device.get_usb_device_strings()?;
10    println!("Device: {manufacturer} {product} {serial}");
11
12    // Configure the device with some common settings
13    device.set_center_freq(101_700_000)?; // 101.7 MHz
14    device.set_direct_sampling(rtlsdr::DirectSampling::Disabled)?;
15    device.set_tuner_bandwidth(0)?;
16    device.set_agc_mode(true)?;
17    device.set_tuner_gain_mode(false)?;
18    device.reset_buffer()?;
19
20    // read some samples synchronously
21    let mut buf = [0u8; 1024];
22    let n_read = device.read(&mut buf)?;
23    println!("Read {} bytes of data", n_read);
24
25    // start asynchronous reading
26    println!("Starting asynchronous reading for 3 seconds...");
27    let start = std::time::Instant::now();
28    device.start_reading(
29        |data| {
30            let avg = data.iter().map(|&b| b as u32).sum::<u32>() as f32 / data.len() as f32;
31
32            println!(
33                "Received {} bytes of data, average value: {:.2}",
34                data.len(),
35                avg
36            );
37
38            // return false to stop reading after 3 seconds
39            start.elapsed().as_secs_f32() >= 3.0
40        },
41        0,
42        0,
43    )?;
44
45    println!("Finished asynchronous reading.");
46
47    Ok(())
48}
Source

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

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

§Errors

This will return an error if the bias tee cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Source

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

Enable or disable (the bias tee on) the given GPIO pin. Note: Device::close() does not clear GPIO lines, so it leaves the (bias tee) lines enabled if a client program doesn’t explictly disable it.

  • gpio_pin 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.
§Errors

This will return an error if the bias tee cannot be set by librtlsdr (e.g. libusb failure or device is not open)

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Device

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Device

Source§

impl Debug for Device

Source§

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

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

impl Eq for Device

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 (const: unstable) · 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 StructuralPartialEq for Device

Auto Trait Implementations§

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.