AdalmPluto

Public functions and types exported from AdalmPluto

AdalmPluto.PlutoSDRType
PlutoSDR
+-- ctx::Ptr{iio_context}
|
+-- tx::PlutoTx
|   |
|   +-- iio::txWrapper
|   |   |
|   |   +-- tx::Ptr{iio_device};
|   |   +-- tx0_i::Ptr{iio_channel};
|   |   +-- tx0_q::Ptr{iio_channel};
|   |   +-- chn::Ptr{iio_channel};
|   |   +-- chn_lo::Ptr{iio_channel};
|   |
|   +-- cfg::ChannelCfg
|   |   |
|   |   +-- rfport::String;
|   |   +-- bandwidth::Int64;
|   |   +-- samplingRate::Int64;
|   |   +-- carrierFreq::Int64;
|   |
|   +-- buf::IIO_Buffer
|   |   |
|   |   +-- C_ptr::Ptr{iio_buffer};         |< Pointer to the C buffer
|   |   +-- C_size::Csize_t;                |< Size of the C buffer in samples
|   |   +-- C_sample_size::Cssize_t;        |< Size of a sample in the C buffer
|   |   +-- C_first::Ptr{Cuchar};           |< Pointer to the first sample in the C buffer
|   |   +-- C_last::Ptr{Cuchar};            |< Pointer to the last sample in the C buffer
|   |   +-- C_step::Cssize_t;               |< Distance between to sample pointers in the C buffer
|   |   +-- i_raw_samples::Array{UInt8}     |< Temporary buffer to store I bytes
|   |   +-- q_raw_samples::Array{UInt8}     |< Temporary buffer to store Q bytes
|   |   +-- samples::Array{ComplexF32}      |< Samples stored in a Julia array
|   |   +-- nb_samples::Int                 |< Number of samples in the Julia array
|   |
|   +-- effectiveSamplingRate::Float64
|   +-- effectiveCarrierFreq::Float64
|   +-- released::Bool
|
+-- rx::PlutoRx
|   |
|   +-- iio::rxWrapper
|   |   +-- rx::Ptr{iio_device};
|   |   +-- rx0_i::Ptr{iio_channel};
|   |   +-- rx0_q::Ptr{iio_channel};
|   |   +-- chn::Ptr{iio_channel};
|   |   +-- chn_lo::Ptr{iio_channel};
|   |
|   +-- cfg::ChannelCfg
|   |   |
|   |   +-- rfport::String;
|   |   +-- bandwidth::Int64;
|   |   +-- samplingRate::Int64;
|   |   +-- carrierFreq::Int64;
|   |
|   +-- buf::IIO_Buffer
|   |   |
|   |   +-- C_ptr::Ptr{iio_buffer};         |< Pointer to the C buffer
|   |   +-- C_size::Csize_t;                |< Size of the C buffer in samples
|   |   +-- C_sample_size::Cssize_t;        |< Size of a sample in the C buffer
|   |   +-- C_first::Ptr{Cuchar};           |< Pointer to the first sample in the C buffer
|   |   +-- C_last::Ptr{Cuchar};            |< Pointer to the last sample in the C buffer
|   |   +-- C_step::Cssize_t;               |< Distance between to sample pointers in the C buffer
|   |   +-- i_raw_samples::Array{UInt8}     |< Temporary buffer to store I bytes
|   |   +-- q_raw_samples::Array{UInt8}     |< Temporary buffer to store Q bytes
|   |   +-- samples::Array{ComplexF32}      |< Samples decoded and stored in a Julia array
|   |   +-- nb_samples::Int                 |< Number of samples available in the Julia array
|   |
|   +-- effectiveSamplingRate::Float64
|   +-- effectiveCarrierFreq::Float64
|   +-- released::Bool
|
+-- released::Bool
source
AdalmPluto.getBackendsMethod

Returns the list of the available backends in Pluto, as a Vector of Strings str = getBackends() str = ["usb";"ip";"xml"]

source
AdalmPluto.getGainMethod
getGain(pluto)

Returns the gain value

Arguments

  • pluto::PlutoSDR : the radio to monitor

Returns

  • gain :Current radio gain
source
AdalmPluto.openPlutoFunction
openPluto(txCfg, rxCfg[, uri, backend])

Creates a PlutoSDR struct and configures the radio to stream the samples.

Arguments

  • txCfg::ChannelCfg : the port / bandwidth / sampling rate / carrier frequency for the tx channels.
  • rxCfg::ChannelCfg : the port / bandwidth / sampling rate / carrier frequency for the rx channels.
  • bufferSize::UInt=1024*1024 : the buffer size in samples.
  • uri::String="auto" : the radio uri (ex : "usb:1.3.5"). "auto" takes the first uri found for the given backend.
  • backend::Union{nothing,String} : the backend to scan for the auto uri. If not specified, all backend are scanned and the first radio found is used.

Returns

  • radio::PlutoSDR : a fully initialized PlutoSDR structure.
source
AdalmPluto.openPlutoFunction
openPluto(carrierFreq, samplingRate, bandwidth[, uri, backend])

Creates a PlutoSDR struct and configures the radio to stream the samples.

Arguments

  • carrierFreq::Int : the carrier frequency for both tx and rx.
  • samplingRate::Int : the sampling rate for both tx and rx.
  • gain::Int : the analog RX gain.

Keywords

  • addr::String="auto" : the radio address (ex: "usb:1.3.5"). "auto" takes the first uri found for the given backend.
  • backend::Union{nothing,String} : the backend to scan for the auto uri. If not specified, all backend are scanned and the first radio found is used.
  • bufferSize::UInt=1024*1024 : the buffer size in samples.
  • bandwidth::Int : the bandwidth for both tx and rx.

Returns

  • radio::PlutoSDR : a fully initialized PlutoSDR structure.
source
AdalmPluto.recv!Method
recv!(sig, pluto)

Fills the sig input buffer with samples from the Julia buffer. If there are not enough samples in the Julia buffer, it is refilled until sig is full. Returns the number of samples filled or a negative error number.

Arguments

  • sig::Array{ComplexF32} : the buffer to be filled.
  • pluto::PlutoSDR : the radio to read the samples from.
source
AdalmPluto.recvMethod
recv(pluto, nbSamples)

Reads nbSamples from the Julia buffer. If there are less than nbSamples samples in the Julia buffer, the remaining samples are read, the buffer is refilled, and a total of the nbSamples is read. Returns a newly allocated Array{ComplexF32}.

Arguments

  • pluto::PlutoSDR : the radio to get receive the samples from.
  • nbSamples::Int : the number of samples to receive.

Returns

  • buffer::Array{ComplexF32} : an array with nbSamples complex values.
source
AdalmPluto.refillJuliaBufferRXMethod
refillJuliaBufferRX(pluto)

Refills the radio buffer, decode the samples into ComplexF32 values, and store those values in the pluto structure. To access those samples : pluto.rx.buf.samples.

Arguments

  • pluto::PlutoSDR : the radio to receive the samples from, and the structure storing those samples.

Returns

  • nbSamples::Int : the number of samples stored into the Julia buffer.
source
AdalmPluto.sendFunction

send(pluto,buffer;repeat=false) Send the buffer buffer with the Pluto device. If flag is set to true, repeat the transmission indefinively. If useinternalbuffer is set to true, the buffer used is the one already stored in the Pluto device (it saves buffer re-alloc)

source
AdalmPluto.updateBandwidth!Method
updateBandwidth!(pluto, value)

Changes the bandwidth. Prints the new value.

Arguments

  • pluto::PlutoSDR : the radio to modify.
  • value::Int64 : the new sampling rate.

Keywords

  • doLog::Bool : toggles the display of the new carrier frequency

Returns

  • errno::Int : 0 or a negative error code.
source
AdalmPluto.updateCarrierFreq!Method
updateCarrierFreq!(pluto, value; doLog)

Changes the carrier frequency. Prints the new effective frequency.

Arguments

  • pluto::PlutoSDR : the radio to modify.
  • value::Int64 : the new carrier frequency.

Keywords

  • doLog::Bool : toggles the display of the new carrier frequency

Returns

  • errno::Int : 0 or a negative error code.
source
AdalmPluto.updateGain!Method
updateGain!(pluto, value)

Changes the gain control mode to manual et sets the given value. Prints a warning and returns the error code if it doesn't succeed.

Arguments

  • pluto::PlutoSDR : the radio to modify.
  • value::Int64 : the manual gain value.

Returns

  • errno::Int : 0 or a negative error code.
source
AdalmPluto.updateGainMode!Function
updateGainMode!(pluto[, mode])

Modifies the pluto RX channel gain control mode. Returns an error code < 0 if it doesn't succeed.

Arguments

  • pluto::PlutoSDR : the radio to modify.
  • mode::GainMode=DEFAULT : the new gain mode. DEFAULT ≡ FAST_ATTACK.

Returns

  • errno::Int : 0 or a negative error code.
source
AdalmPluto.updateSamplingRate!Method
updateSamplingRate!(pluto, value; doLog)

Changes the sampling rate. Prints the new effective sampling rate.

Arguments

  • pluto::PlutoSDR : the radio to modify.
  • value::Int64 : the new sampling rate.

Keywords

  • doLog::Bool : toggles the display of the new carrier frequency

Returns

  • errno::Int : 0 or a negative error code.
source
Base.closeMethod
close(pluto)

Frees the C allocated memory associated to the PlutoSDR structure.

source

Private functions and types from AdalmPluto

AdalmPluto.cfgChannelsMethod
cfgChannels(txChannel, rxChannel, txLoChannel, rxLoChannel, txCfg, rxCfg)

Configures the RX, RX LO, TX, and TX LO channels from the provided configurations. Returns the configured channels.

Arguments

  • txChannel::Ptr{iio_channel} : the tx channel.
  • rxChannel::Ptr{iio_channel} : the rx channel.
  • txLoChannel::Ptr{iio_channel} : the tx lo channel.
  • rxLoChannel::Ptr{iio_channel} : the rx lo channel.
  • txCfg::ChannelCfg : the tx configuration (port / bandwidth / sampling rate / frequency).
  • rxCfg::ChannelCfg : the rx configuration (port / bandwidth / sampling rate / frequency).

Returns

  • txChannel::Ptr{iio_channel} : a pointer to the configured TX C iio_channel structure.
  • rxChannel::Ptr{iio_channel} : a pointer to the configured RX C iio_channel structure.
  • txLoChannel::Ptr{iio_channel} : a pointer to the configured TX Lo C iio_channel structure.
  • rxLoChannel::Ptr{iio_channel} : a pointer to the configured RX Lo C iio_channel structure.
source
AdalmPluto.cfgChannelsMethod
cfgChannels(context, txCfg, rxCfg)

Configures the RX, RX LO, TX, and TX LO channels from the provided configurations. Returns the configured channels.

Arguments

  • context::Ptr{iio_context} : the context to get the channels from.
  • txCfg::ChannelCfg : the tx configuration (port / bandwidth / sampling rate / frequency).
  • rxCfg::ChannelCfg : the rx configuration (port / bandwidth / sampling rate / frequency).

Returns

  • txChannel::Ptr{iio_channel} : a pointer to the configured TX C iio_channel structure.
  • rxChannel::Ptr{iio_channel} : a pointer to the configured RX C iio_channel structure.
  • txLoChannel::Ptr{iio_channel} : a pointer to the configured TX Lo C iio_channel structure.
  • rxLoChannel::Ptr{iio_channel} : a pointer to the configured RX Lo C iio_channel structure.
source
AdalmPluto.createBufferMethod
createBuffer(device, samplesCount)

Creates a buffer for the provided device. Returns a wrapper around the buffer with basic info (C pointer, sample size, first sample, last sample, steps between samples, Julia complex samples, number of non-queried Julia complex samples).

Arguments

  • device::Ptr{iio_device} : the device for which the buffer is created.
  • samplesCound::UInt : the size of the buffer in samples.

Returns

  • buffer::IIO_Buffer : a buffer for the given channel with space for samplesCount samples.
source
AdalmPluto.createContextMethod
createContext(uri)

Returns the iio_context corresponding the the provided uri. Throws an error if no devices are found in the context.

Arguments

  • uri::String : the radio URI to get the context from.

Returns

  • context::Ptr{iio_context} : the context for the given URI.
source
AdalmPluto.findIQChannelsMethod
findIQChannels(device, iID, qID, isOutput)

Returns IChannel::Ptr{iio_channel}, QChannel::Ptr{iio_channel} from the given device.

Arguments

  • device::Ptr{iio_device} : the device to get the channels from.
  • iID::String : identification string for the I channel (ex : "voltage0").
  • qID::String : identification string for the Q channel (ex : "voltage1").
  • isOutput::Bool : whether the IQ channels are outputs.

Returns

  • IChannel::Ptr{iio_channel} : the I channel.
  • QChannel::Ptr{iio_channel} : the Q channel.
source
AdalmPluto.findLoChannelsFunction
findLoChannels(context[, txLoID, rxLoID])

Returns txLoChannel::Ptr{iio_channel}, rxLoChannel::Ptr{iio_channel} from the given context.

Arguments

  • context::Ptr{iio_context} : the context to get the channels from.
  • txLoID::Integer=1 : the tx lo channel number (ex : 1 for tx lo channel "altvoltage1").
  • rxLoID::Integer=0 : the rx lo channel number (ex : 0 for rx lo channel "altvoltage0").

Returns

  • txLoChannel::Ptr{iio_channel} : a pointer to the TX Lo C iio_channel structure.
  • rxLoChannel::Ptr{iio_channel} : a pointer to the RX Lo C iio_channel structure.
source
AdalmPluto.findTRXChannelsFunction
findTRXChannels(context[, txID, rxID])

Returns txChannel::Ptr{iio_channel}, rxChannel::Ptr{iio_channel} from the given context.

Arguments

  • context::Ptr{iio_context} : the context to get the channels from.
  • txID::Integer=0 : the tx channel number (ex : 0 for tx channel "voltage0").
  • rxID::Integer=0 : the rx channel number (ex : 0 for rx channel "voltage0").

Returns

  • txChannel::Ptr{iio_channel} : a pointer to the TX C iio_channel structure.
  • rxChannel::Ptr{iio_channel} : a pointer to the RX C iio_channel structure.
source
AdalmPluto.findTRXDevicesMethod
findTRXDevices(context)

Returns txDevice::Ptr{iio_device}, rxDevice::Ptr{iio_device} from the given context.

Arguments

  • context::Ptr{iio_context} : the IIO context to get the TX and RX devices from.

Returns

  • txDevice::Ptr{iio_device} : a pointer to the TX C iio_device structure.
  • rxDevice::Ptr{iio_device} : a pointer to the RX C iio_device structure.
source
AdalmPluto.scanFunction
scan(backend[, infoIndex, doPrint])

Returns a device URI.

Arguments

  • backend::String : the backend to scan (local, xml, ip, usb).
  • infoIndex::Integer=1 : the device index.
  • doPrint::Bool=true : toggles console printing of the uri.

Returns

  • uri::Vector{String} : A vector of devices URI.

C equivalent

source
AdalmPluto.updateEffectiveCfg!Method
updateEffectiveCfg!(trx)

Updates the stored values of the effective sampling rate and carrier frequency of either a PlutoTx or PlutoRx. If the values are different than the ones in the ChannelCfg of the structure, a warning is printed. Returns the effective values values.

Arguments

  • trx::Union{PlutoTx, PlutoRx} : the structure containing the channel to read the current configuration from.

Keywords

  • doLog::Bool : toggles the display of the new carrier frequency

Returns

  • effectiveSamplingRate::Int : the current sampling rate.
  • effectiveCarrierFreq::Int : the current carrier frequency.
source
Base.printMethod

print(pluto) Print the current radio configuration

Arguments

  • pluto::PlutoSDR : the radio to receive the samples from, and the structure storing those samples.

Returns

  • A string with the different configuration aspects
source
AdalmPluto.@warnPlutoMacro
@warnPluto TRX str

Prints custom warnings for either Rx or Tx.

Example

  • @warnPluto :RX "msg" to print a warning concerning the Rx part.
  • @warnPluto :TX "msg" to print a warning concerning the Tx part.
source