pub struct Pluto {
pub context: Context,
pub phy: Device,
pub rxadc: Device,
pub txdac: Device,
}Expand description
This represents you Pluto device. This library provides a lot of different functions to send and receive data, to change the Pluto’s settings and more!
A small example that receives samples with minimal effort
use pluto_sdr::pluto::{Pluto, RX};
let my_pluto = Pluto::connect("ip:192.168.2.2").unwrap();
//setup rf settings of receiver
let _ = my_pluto.set_sampling_freq( 5_000_000 ); // 5 Mhz
let _ = my_pluto.set_lo_rx( 2_400_000_000 ); // 2.4 GHz
let _ = my_pluto.set_rf_bandwidth( 2_500_000 , RX); // 2.5 MHz
let _ = my_pluto.set_hwgain(10.0, RX);
// get the receive channels
let (rx_i, rx_q) = my_pluto.rx_ch0();
// before creating a buffer and receiving samples,
// enable the channels you need
rx_i.enable();
let mut buf = my_pluto.create_buffer_rx(32).unwrap();
for _ in 0..100 {
buf.refill().unwrap();
let rx_i_samples = rx_i.read::<i16>(&buf).unwrap();
// print or analyze chuncks of samples here:
println!("{:?}", rx_i_samples);
}Fields§
§context: ContextReference to the Pluto IIO Context
phy: DevicePluto’s PHY: It controls most settings
rxadc: DevicePluto’s 12-bit ADC
txdac: DevicePluto’s DAC: A 12-bit DDS Signal Generator
Implementations§
Source§impl Pluto
impl Pluto
Sourcepub fn connect(uri: &str) -> Option<Self>
pub fn connect(uri: &str) -> Option<Self>
Connect to your ADALM-Pluto SDR using an IP address or USB / serial port.
Resolving the hostname pluto.local can be quite slow (multiple seconds).
Timeouts are even slower!
use pluto_sdr::pluto::Pluto;
let my_pluto = Pluto::connect("ip:pluto3.local");
let my_pluto = Pluto::connect("ip:192.168.2.2");
let my_pluto = Pluto::connect("usb:1.7.5");
println!("{:?}", my_pluto);Sourcepub fn set_lo_rx(&self, f_lo: i64) -> Result<(), ()>
pub fn set_lo_rx(&self, f_lo: i64) -> Result<(), ()>
Set the RF Local Oscillator frequency for the receiver.
Mapping: Pluto -> Device: phy/ad9361-phy -> Channel: altvoltage0 (RX_LO) -> Attribute: frequency (i64)
Sourcepub fn set_lo_tx(&self, f_lo: i64) -> Result<(), ()>
pub fn set_lo_tx(&self, f_lo: i64) -> Result<(), ()>
Set the RF Local Oscillator frequency for Transmission.
Mapping: Pluto -> Device: phy/ad9361-phy -> Channel: altvoltage1 (TX_LO) -> Attribute: frequency (i64)
Sourcepub fn set_rf_bandwidth(&self, f_b: i64, rxtx: bool) -> Result<(), ()>
pub fn set_rf_bandwidth(&self, f_b: i64, rxtx: bool) -> Result<(), ()>
Set the RF bandwidth for RX or TX (specified by argument rxtx).
Mapping: Pluto -> Device: phy/ad9361-phy -> Channel: voltage0 -> Attribute: rf_bandwidth (i64)
Sourcepub fn set_hwgain(&self, g: f64, rxtx: bool) -> Result<(), ()>
pub fn set_hwgain(&self, g: f64, rxtx: bool) -> Result<(), ()>
Set the RX/TX hardware gain (RX or TX specified by argument rxtx).
When setting gain for RX, it defaults to “manual” gain mode (manual/autogain).
Mapping: Pluto -> Device: phy/ad9361-phy -> Channel: voltage0 -> Attribute: hardwaregain (i64)
Sourcepub fn set_sampling_freq(&self, fs: i64) -> Result<(), ()>
pub fn set_sampling_freq(&self, fs: i64) -> Result<(), ()>
Sets the sample rate of both RX and TX.
Mapping: Pluto -> Device: phy/ad9361-phy -> Channel: voltage0 -> Attribute: sampling_frequency (i64)
Sourcepub fn rx_ch0(&self) -> (Channel, Channel)
pub fn rx_ch0(&self) -> (Channel, Channel)
Get the RX channel 0 data stream.
use pluto_sdr::pluto::Pluto;
let my_pluto = Pluto::connect("ip:192.168.2.2").unwrap();
let (rx_i, rx_q) = my_pluto.rx_ch0();
// before creating a buffer and receiving samples,
// enable the channels you need
rx_i.enable();
let mut buf = my_pluto.create_buffer_rx(32).unwrap();
for _ in 0..100 {
buf.refill().unwrap();
let rx_i_samples = rx_i.read::<i16>(&buf).unwrap();
println!("{:?}", rx_i_samples);
}Mapping: Pluto -> Device: rxadc/cf-ad9361-lpc -> Channel: voltage0/1
Sourcepub fn tx_ch0(&self) -> (Channel, Channel)
pub fn tx_ch0(&self) -> (Channel, Channel)
Get the TX channel 0 data sink. Similar to rx_ch0(), but we can write samples to the Channel.
use pluto_sdr::pluto::Pluto;
let my_pluto = Pluto::connect("ip:192.168.2.2").unwrap();
let (tx_i, tx_q) = my_pluto.tx_ch0();
// the signal we want to send
let signal = vec![1,0,-1,0];
// before creating a buffer and transmitting samples,
// enable the channels you need
tx_i.enable();
let mut buf = my_pluto.create_buffer_tx(signal.len(), true).unwrap();
let _ = tx_i.write::<i16>(&buf, signal.as_slice()).unwrap();
buf.push().unwrap();Mapping: Pluto -> Device: txdac/cf-ad9361-dds-core-lpc -> Channel: voltage0/1