Post Go back to editing

rf_port_select does not work

Category: Software
Product Number: iiolib

Good morning

for this

ret = iio_channel_attr_write(phy_chn_rx, "rf_port_select", rxcfg.rfport);

I get a -22

Other settings for the rx channel work

The 

 phy_chn_rx = iio_device_find_channel(phydev, "voltage0", false );

gives the channel for rx. This one works.

Additionally is of value to assign settings to altvoltage0 or altvoltage1 for the PLUTO?
It seems they are not available ...

Thank You

Pietro

  • Is this the outcome?

    This example is working for streaming it does the initialization without any problem. I just add the lines of code for reading what is already written. 

    Can You modify the example for streaming and show this  API work?

    Thank You

    Pietro

  • So Michael was referring to the IIO devices that you reference for pulling back information. You can use iio_info and iio_attr to examine what is available. First I would start with iio_attr to list the devices as so:

    iio_attr -u ip:pluto.local -d
    IIO context has 5 devices:
    	iio:device0, adm1177: found 0 device attributes
    	iio:device1, ad9361-phy: found 18 device attributes
    	iio:device2, xadc: found 1 device attributes
    	iio:device3, cf-ad9361-dds-core-lpc: found 0 device attributes
    	iio:device4, cf-ad9361-lpc: found 0 device attributes

    The devices cf-ad9361-dds-core-lpc and cf-ad9361-lpc are the controls for data streaming and DDS control. You can tell since they have scan elements (that's an IIO concept for buffer management):

    iio_attr -u ip:pluto.local -s -c cf-ad9361-lpc
    dev 'cf-ad9361-lpc', channel 'voltage0' (input, index: 0, format: le:S12/16>>0)
    found 6 channel-specific attributes
    dev 'cf-ad9361-lpc', channel 'voltage1' (input, index: 1, format: le:S12/16>>0)
    found 6 channel-specific attributes
    
    iio_attr -u ip:pluto.local -s -c cf-ad9361-dds-core-lpc
    dev 'cf-ad9361-dds-core-lpc', channel 'voltage0' (output, index: 0, format: le:S16/16>>0)
    found 4 channel-specific attributes
    dev 'cf-ad9361-dds-core-lpc', channel 'voltage1' (output, index: 1, format: le:S16/16>>0)
    found 4 channel-specific attributes

    The ad9361-phy is where all the main control attributes for the transceiver live:

    iio_attr -u ip:pluto.local -c ad9361-phy .
    dev 'ad9361-phy', channel 'altvoltage1' (output), id 'TX_LO', attr 'external', value '0'
    dev 'ad9361-phy', channel 'altvoltage1' (output), id 'TX_LO', attr 'fastlock_load', value '0'
    dev 'ad9361-phy', channel 'altvoltage1' (output), id 'TX_LO', attr 'fastlock_recall', ERROR: Invalid argument (22)
    dev 'ad9361-phy', channel 'altvoltage1' (output), id 'TX_LO', attr 'fastlock_save', value '0 183,183,183,183,183,183,183,183,183,183,183,183,183,183,183,183'
    dev 'ad9361-phy', channel 'altvoltage1' (output), id 'TX_LO', attr 'fastlock_store', value '0'
    dev 'ad9361-phy', channel 'altvoltage1' (output), id 'TX_LO', attr 'frequency', value '2450000000'
    dev 'ad9361-phy', channel 'altvoltage1' (output), id 'TX_LO', attr 'frequency_available', value '[325000000 1 3800000000]'
    dev 'ad9361-phy', channel 'altvoltage1' (output), id 'TX_LO', attr 'powerdown', value '0'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'bb_dc_offset_tracking_en', value '1'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'filter_fir_en', value '0'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'gain_control_mode', value 'slow_attack'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'gain_control_mode_available', value 'manual fast_attack slow_attack hybrid'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'hardwaregain', value '71.000000 dB'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'hardwaregain_available', value '[-3 1 71]'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'quadrature_tracking_en', value '1'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'rf_bandwidth', value '18000000'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'rf_bandwidth_available', value '[200000 1 56000000]'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'rf_dc_offset_tracking_en', value '1'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'rf_port_select', value 'A_BALANCED'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'rf_port_select_available', value 'A_BALANCED B_BALANCED C_BALANCED A_N A_P B_N B_P C_N C_P TX_MONITOR1 TX_MONITOR2 TX_MONITOR1_2'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'rssi', value '114.25 dB'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'sampling_frequency', value '30720000'
    dev 'ad9361-phy', channel 'voltage0' (input), attr 'sampling_frequency_available', value '[2083333 1 61440000]'
    dev 'ad9361-phy', channel 'voltage3' (output), attr 'filter_fir_en', value '0'
    dev 'ad9361-phy', channel 'voltage3' (output), attr 'raw', value '306'
    dev 'ad9361-phy', channel 'voltage3' (output), attr 'rf_bandwidth', value '18000000'
    dev 'ad9361-phy', channel 'voltage3' (output), attr 'rf_bandwidth_available', value '[200000 1 40000000]'
    dev 'ad9361-phy', channel 'voltage3' (output), attr 'rf_port_select_available', value 'A B'
    dev 'ad9361-phy', channel 'voltage3' (output), attr 'sampling_frequency', value '30720000'
    dev 'ad9361-phy', channel 'voltage3' (output), attr 'sampling_frequency_available', value '[2083333 1 61440000]'
    dev 'ad9361-phy', channel 'voltage3' (output), attr 'scale', value '1.000000'
    dev 'ad9361-phy', channel 'altvoltage0' (output), id 'RX_LO', attr 'external', value '0'
    dev 'ad9361-phy', channel 'altvoltage0' (output), id 'RX_LO', attr 'fastlock_load', value '0'
    dev 'ad9361-phy', channel 'altvoltage0' (output), id 'RX_LO', attr 'fastlock_recall', ERROR: Invalid argument (22)
    dev 'ad9361-phy', channel 'altvoltage0' (output), id 'RX_LO', attr 'fastlock_save', value '0 230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230'
    dev 'ad9361-phy', channel 'altvoltage0' (output), id 'RX_LO', attr 'fastlock_store', value '0'
    dev 'ad9361-phy', channel 'altvoltage0' (output), id 'RX_LO', attr 'frequency', value '2400000000'
    dev 'ad9361-phy', channel 'altvoltage0' (output), id 'RX_LO', attr 'frequency_available', value '[325000000 1 3800000000]'
    dev 'ad9361-phy', channel 'altvoltage0' (output), id 'RX_LO', attr 'powerdown', value '0'
    dev 'ad9361-phy', channel 'voltage2' (output), attr 'filter_fir_en', value '0'
    dev 'ad9361-phy', channel 'voltage2' (output), attr 'raw', value '306'
    dev 'ad9361-phy', channel 'voltage2' (output), attr 'rf_bandwidth', value '18000000'
    dev 'ad9361-phy', channel 'voltage2' (output), attr 'rf_bandwidth_available', value '[200000 1 40000000]'
    dev 'ad9361-phy', channel 'voltage2' (output), attr 'rf_port_select_available', value 'A B'
    dev 'ad9361-phy', channel 'voltage2' (output), attr 'sampling_frequency', value '30720000'
    dev 'ad9361-phy', channel 'voltage2' (output), attr 'sampling_frequency_available', value '[2083333 1 61440000]'
    dev 'ad9361-phy', channel 'voltage2' (output), attr 'scale', value '1.000000'
    dev 'ad9361-phy', channel 'temp0' (input), attr 'input', value '30702'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'filter_fir_en', value '0'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'hardwaregain', value '-10.000000 dB'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'hardwaregain_available', value '[-89.750000 0.250000 0.000000]'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'rf_bandwidth', value '18000000'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'rf_bandwidth_available', value '[200000 1 40000000]'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'rf_port_select', value 'A'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'rf_port_select_available', value 'A B'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'rssi', value '0.00 dB'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'sampling_frequency', value '30720000'
    dev 'ad9361-phy', channel 'voltage0' (output), attr 'sampling_frequency_available', value '[2083333 1 61440000]'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'bb_dc_offset_tracking_en', value '1'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'filter_fir_en', value '0'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'gain_control_mode_available', value 'manual fast_attack slow_attack hybrid'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'offset', value '57'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'quadrature_tracking_en', value '1'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'raw', value '1255'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'rf_bandwidth', value '18000000'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'rf_bandwidth_available', value '[200000 1 56000000]'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'rf_dc_offset_tracking_en', value '1'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'rf_port_select_available', value 'A_BALANCED B_BALANCED C_BALANCED A_N A_P B_N B_P C_N C_P TX_MONITOR1 TX_MONITOR2 TX_MONITOR1_2'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'sampling_frequency', value '30720000'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'sampling_frequency_available', value '[2083333 1 61440000]'
    dev 'ad9361-phy', channel 'voltage2' (input), attr 'scale', value '0.305250'
    dev 'ad9361-phy', channel 'out' (input), attr 'voltage_filter_fir_en', value '0'

    Since you don't specify in your code how "tx" is created, our guess is that its not from ad9361-phy.

    -Travis

  • Hi Travis

    I changed the call to the read this way

    err2 = iio_channel_attr_read_bool( iio_device_find_channel(phydev, "voltage0", true), "rf_bandwidth", &pluto_ad9361_phy_attrib.voltage0_out.filter_fir_en ); // wrong
    iio_strerror(err2, buf2, 200);
    err2 = iio_channel_attr_read(iio_device_find_channel(phydev, "voltage0", true), "rf_port_select", pluto_ad9361_phy_attrib.voltage0_out.rf_port_select, 20 ); // wrong
    iio_strerror(err2, buf2, 200);

    Now all of the readings are working. But the difference is the channel is inlined every time rather than recycled from a variable. It should not make any difference but ... That's it.

    Thank You

    Pietro

  • Reusing a channel pointer or re-creating it does not matter.

    -Travis

  • Thank You for this support. I am trying to learn  just doing.

    I have a different behaviour or the command 

    iio_attr -u ip:pluto.local -c ad9361-phy

    I get 

    dev 'ad9361-phy', channel 'altvoltage1', id 'TX_LO' (output), found 8 channel-specific attributes
    dev 'ad9361-phy', channel 'voltage0' (input), found 15 channel-specific attributes
    dev 'ad9361-phy', channel 'voltage3' (output), found 8 channel-specific attributes
    dev 'ad9361-phy', channel 'altvoltage0', id 'RX_LO' (output), found 8 channel-specific attributes
    dev 'ad9361-phy', channel 'voltage2' (output), found 8 channel-specific attributes
    dev 'ad9361-phy', channel 'temp0' (input), found 1 channel-specific attributes
    dev 'ad9361-phy', channel 'voltage0' (output), found 10 channel-specific attributes
    dev 'ad9361-phy', channel 'voltage2' (input), found 13 channel-specific attributes
    dev 'ad9361-phy', channel 'out' (input), found 1 channel-specific attributes

    I do not access the attributes of the channels. How to get the same result You have?

    Thank  You'

    Pietro

  • I am trying to get the channel attributes but I do not get.
    Is there a different version?

    Thank You

    Pietro

  • You are missing the dot "." at the end of the command. Needs to be:

    iio_attr -u ip:pluto.local -c ad9361-phy .

    -Travis