Pluto

Struct Pluto 

Source
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: Context

Reference to the Pluto IIO Context

§phy: Device

Pluto’s PHY: It controls most settings

§rxadc: Device

Pluto’s 12-bit ADC

§txdac: Device

Pluto’s DAC: A 12-bit DDS Signal Generator

Implementations§

Source§

impl Pluto

Source

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);
Source

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)

Source

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)

Source

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)

Source

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)

Source

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)

Source

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

Source

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

Source

pub fn rx_i_ch0(&self) -> Channel

Source

pub fn rx_q_ch0(&self) -> Channel

Source

pub fn tx_i_ch0(&self) -> Channel

Source

pub fn tx_q_ch0(&self) -> Channel

Source

pub fn create_buffer_rx(&self, size: usize) -> Result<Buffer>

Source

pub fn create_buffer_tx(&self, size: usize, cyclic: bool) -> Result<Buffer>

Source

pub fn toggle_dds(&self, enable: bool)

Source

pub fn list_dds(&self)

Trait Implementations§

Source§

impl Debug for Pluto

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Pluto

§

impl RefUnwindSafe for Pluto

§

impl Send for Pluto

§

impl !Sync for Pluto

§

impl Unpin for Pluto

§

impl UnwindSafe for Pluto

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> 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, 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.