pub struct HackRf { /* private fields */ }
Expand description
HackRF One software defined radio.
NOTE: The Hackrf may continue transmitting the latest samples it received if never dropped. Be sure to include a
Implementations§
Source§impl HackRf
impl HackRf
Sourcepub fn open(info: DeviceInfo) -> Result<Self>
pub fn open(info: DeviceInfo) -> Result<Self>
Opens info
based on the result of a nusb
scan.
Sourcepub fn from_fd(fd: OwnedFd) -> Result<Self>
Available on Android or Linux only.
pub fn from_fd(fd: OwnedFd) -> Result<Self>
Wraps a HackRf One exposed through an existing file descriptor.
Useful on platforms like Android where UsbManager
permits access to an fd.
Sourcepub fn open_first() -> Result<HackRf>
pub fn open_first() -> Result<HackRf>
Opens the first Hackrf One found via USB.
Sourcepub fn scan() -> Result<Vec<(u8, u8)>>
pub fn scan() -> Result<Vec<(u8, u8)>>
Scans the usb bus for hackrf devices, returning the pair of (bus_num, bus_addr) for each device.
Sourcepub fn open_bus(bus_number: u8, address: u8) -> Result<HackRf>
pub fn open_bus(bus_number: u8, address: u8) -> Result<HackRf>
Opens a hackrf with usb address <bus_number>:<address>
Sourcepub fn device_version(&self) -> UsbVersion
pub fn device_version(&self) -> UsbVersion
Returns the USB version of the device.
Sourcepub fn start_tx(&self, config: &Config) -> Result<()>
pub fn start_tx(&self, config: &Config) -> Result<()>
Transitions the radio into transmit mode.
Call this function before calling Self::write
.
Previous state set via set_xxx
functions will be overridden with the parameters set in config
.
§Errors
This function will return an error if a tx or rx operation is already in progress or if an I/O error occurs
Sourcepub fn start_rx(&self, config: &Config) -> Result<()>
pub fn start_rx(&self, config: &Config) -> Result<()>
Transitions the radio into receive mode.
Call this function before calling Self::read
.
Previous state set via set_xxx
functions will be overridden with the parameters set in config
.
§Errors
This function will return an error if a tx or rx operation is already in progress or if an I/O error occurs
Sourcepub fn start_rx_stream(
self: &Arc<Self>,
transfer_size: usize,
) -> Result<RxStream>
pub fn start_rx_stream( self: &Arc<Self>, transfer_size: usize, ) -> Result<RxStream>
Setup the device to stream samples.
When the stream is dropped, the device will be reset to the Off
state,
meaning Self::start_rx
will be required before using the device again.
Sourcepub fn start_tx_stream(self: &Arc<Self>) -> Result<TxStream>
pub fn start_tx_stream(self: &Arc<Self>) -> Result<TxStream>
Setup the device to stream samples.
When the stream is dropped, the device will be reset to the Off
state,
meaning Self::start_tx
will be required before using the device again.
Source§impl HackRf
impl HackRf
Sourcepub fn set_amp_enable(&self, enable: bool) -> Result<()>
pub fn set_amp_enable(&self, enable: bool) -> Result<()>
Enable the RX/TX RF amplifier.
In GNU radio this is used as the RF gain, where a value of 0 dB is off, and a value of 14 dB is on.
Sourcepub fn set_baseband_filter_bandwidth(&self, hz: u32) -> Result<()>
pub fn set_baseband_filter_bandwidth(&self, hz: u32) -> Result<()>
Set the baseband filter bandwidth.
This is automatically set when the sample rate is changed with
Self::set_sample_rate
.
Sourcepub fn set_sample_rate(&self, hz: u32, div: u32) -> Result<()>
pub fn set_sample_rate(&self, hz: u32, div: u32) -> Result<()>
Set the sample rate.
For anti-aliasing, the baseband filter bandwidth is automatically set to the widest available setting that is no more than 75% of the sample rate. This happens every time the sample rate is set. If you want to override the baseband filter selection, you must do so after setting the sample rate.
Limits are 8MHz - 20MHz. Preferred rates are 8, 10, 12.5, 16, 20MHz due to less jitter.
Sourcepub fn set_lna_gain(&self, gain: u16) -> Result<()>
pub fn set_lna_gain(&self, gain: u16) -> Result<()>
Set the LNA (low noise amplifier) gain.
Range 0 to 40dB in 8dB steps.
This is also known as the IF gain.
Sourcepub fn set_vga_gain(&self, gain: u16) -> Result<()>
pub fn set_vga_gain(&self, gain: u16) -> Result<()>
Set the VGA (variable gain amplifier) gain.
Range 0 to 62dB in 2dB steps.
This is also known as the baseband (BB) gain.
Sourcepub fn set_txvga_gain(&self, gain: u16) -> Result<()>
pub fn set_txvga_gain(&self, gain: u16) -> Result<()>
Set the transmit VGA gain.
Range 0 to 47dB in 1db steps.
Sourcepub fn set_antenna_enable(&self, value: bool) -> Result<()>
pub fn set_antenna_enable(&self, value: bool) -> Result<()>
Antenna power port control. Dhruv’s guess: is this DC bias?
The source docs are a little lacking in terms of explanations here.