JuliaTelecom / SoapySDR.jl

Julia Wrappers for SoapySDR
https://juliatelecom.github.io/SoapySDR.jl/dev/
Other
15 stars 3 forks source link

Error when trying to change a Channel parameter of type Bool #33

Closed TheoBr24 closed 3 years ago

TheoBr24 commented 3 years ago

On Windows 10, Julia 1.6.3, using SoapySDR Hardware: Adalm-Pluto SDR

When I try to configure a parameter of a SoapySDR.Channel of type "Bool", I get this error:

"setfield! immutable struct of type Channel cannot be changed Stacktrace: [1] setproperty!(c::SoapySDR.Channel, s::Symbol, v::Bool) @ SoapySDR C:\Users\Theo.julia\packages\SoapySDR\saW3b\src\highlevel.jl:338 [2] top-level scope @ REPL[5]:1"

Is this a bug or do I have to transform the boolean somehow with Unitful.jl?

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.3 (2021-09-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using SoapySDR, SoapyPlutoSDR_jll

julia> dev = Devices()[1]
SoapySDR ADALM-PLUTO device (driver: PlutoSDR) w/ 1 TX channels and 1 RX channels

julia> rx_chan = dev.rx[1]
RX Channel #1 on ADALM-PLUTO
  Selected Antenna [A_BALANCED]: A_BALANCED
  Bandwidth [ 200..200 kHz, 1..1 MHz, 2..2 MHz, 3..3 MHz, 4..4 MHz, 5..5 MHz, 6..6 MHz, 7..7 MHz, 8..8 MHz, 9..9 MHz, 10..10 MHz ]: 18.0 MHz
  Frequency [ 70 MHz .. 6 GHz ]: 104.3 MHz
    RF [ 70 MHz .. 6 GHz ]: 104.3 MHz
  Gain [0.0 dB .. 73.0 dB]: 73.0 dB
    PGA [0.0 dB .. 73.0 dB]: 73.0 dB
  Sample Rate [ 65.1..65.1 kHz, 1..1 MHz, 2..2 MHz, 3..3 MHz, 4..4 MHz, 5..5 MHz, 6..6 MHz, 7..7 MHz, 8..8 MHz, 9..9 MHz, 10..10 MHz ]: 30.719998999999998 MHz

julia> rx_chan.frequency = 100e6u"Hz"
1.0e8 Hz

julia> rx_chan.gain_mode = true
ERROR: setfield! immutable struct of type Channel cannot be changed
Stacktrace:
 [1] setproperty!(c::SoapySDR.Channel, s::Symbol, v::Bool)
   @ SoapySDR C:\Users\Theo\.julia\packages\SoapySDR\saW3b\src\highlevel.jl:338
 [2] top-level scope
   @ REPL[5]:1
sjkelly commented 3 years ago

This is a bug that should be fixed on the main branch. I will clean up the docs tonight and get a 0.1.1 release out ASAP.

See demonstration below:

julia> using SoapySDR, SoapyPlutoSDR_jll

julia> dev = Devices()[1]
SoapySDR ADALM-PLUTO device
  driver: PlutoSDR
  number of TX channels:1
  number of RX channels:1
  sensors: SoapySDR.SensorComponent[xadc_temp0,xadc_voltage0,xadc_voltage1,xadc_voltage2,xadc_voltage3,xadc_voltage4,xadc_voltage5,xadc_voltage6,xadc_voltage7,xadc_voltage8,adm1177_current0,adm1177_voltage0,ad9361-phy_temp0,ad9361-phy_voltage2,]
  time_source: 
  time_sources:SoapySDR.TimeSource[]
  frontendmapping_rx: 
  frontendmapping_tx: 

julia> rx_chan = dev.rx[1]
RX Channel #1 on ADALM-PLUTO
  antenna: A_BALANCED
  antennas: SoapySDR.Antenna[A_BALANCED,]
  bandwidth [ 200..200 kHz, 1..1 MHz, 2..2 MHz, 3..3 MHz, 4..4 MHz, 5..5 MHz, 6..6 MHz, 7..7 MHz, 8..8 MHz, 9..9 MHz, 10..10 MHz ]: 18.0 MHz
  frequency [ 70 MHz .. 6 GHz ]: 2.399999998 GHz
    RF [ 70 MHz .. 6 GHz ]: 2.399999998 GHz
  gain_mode (AGC=true/false/missing): false
  gain: 71.0 dB
  gain_elements: SoapySDR.GainElement[PGA,]
  fullduplex: true
  stream_formats: DataType[Complex{Int8}, SoapySDR.ComplexInt{12}, Complex{Int16}, ComplexF32]
  native_stream_format: Complex{Int16}
  sample_rate [ 65.1..65.1 kHz, 1..1 MHz, 2..2 MHz, 3..3 MHz, 4..4 MHz, 5..5 MHz, 6..6 MHz, 7..7 MHz, 8..8 MHz, 9..9 MHz, 10..10 MHz ]: 30.72 MHz
  dc_offset_mode (true/false/missing): missing
  dc_offset (if has dc_offset_mode): missing
  iq_balance_mode (true/false/missing): missing
  iq_balance: missing
  frequency_correction: missing ppm

julia> rx_chan.frequency = 100e6u"Hz"
1.0e8 Hz

julia> rx_chan.gain_mode = true
true

julia> rx_chan
RX Channel #1 on ADALM-PLUTO
  antenna: A_BALANCED
  antennas: SoapySDR.Antenna[A_BALANCED,]
  bandwidth [ 200..200 kHz, 1..1 MHz, 2..2 MHz, 3..3 MHz, 4..4 MHz, 5..5 MHz, 6..6 MHz, 7..7 MHz, 8..8 MHz, 9..9 MHz, 10..10 MHz ]: 18.0 MHz
  frequency [ 70 MHz .. 6 GHz ]: 2.399999998 GHz
    RF [ 70 MHz .. 6 GHz ]: 2.399999998 GHz
  gain_mode (AGC=true/false/missing): true
  gain: 71.0 dB
  gain_elements: SoapySDR.GainElement[PGA,]
  fullduplex: true
  stream_formats: DataType[Complex{Int8}, SoapySDR.ComplexInt{12}, Complex{Int16}, ComplexF32]
  native_stream_format: Complex{Int16}
  sample_rate [ 65.1..65.1 kHz, 1..1 MHz, 2..2 MHz, 3..3 MHz, 4..4 MHz, 5..5 MHz, 6..6 MHz, 7..7 MHz, 8..8 MHz, 9..9 MHz, 10..10 MHz ]: 30.72 MHz
  dc_offset_mode (true/false/missing): missing
  dc_offset (if has dc_offset_mode): missing
  iq_balance_mode (true/false/missing): missing
  iq_balance: missing
  frequency_correction: missing ppm
sjkelly commented 3 years ago

Also, thank you for the bug report!

TheoBr24 commented 3 years ago

Thanks for the quick response 👍