It is possible to configure the AD9361 chip directly from sysfs. The interesting files are located in /sys/bus/iio/devices/iio:deviceX where X is the number of the device whose name is ad9361-phy:
root@linaro-ubuntu-desktop:~# cat /sys/bus/iio/devices/iio:device1/name ad9361-phy
This directory contains several files, some of which can be used to read raw values from the hardware, while others are used to configure the ad9361 chip.
root@linaro-ubuntu-desktop:~# ls /sys/bus/iio/devices/iio:device1 calib_mode in_voltage_rf_dc_offset_tracking_en calib_mode_available in_voltage_rf_port_select_available dcxo_tune_coarse in_voltage_sampling_frequency dcxo_tune_fine name dev out_altvoltage0_RX_LO_frequency ensm_mode out_altvoltage1_TX_LO_frequency ensm_mode_available out_voltage0_hardwaregain filter_fir_config out_voltage0_rf_port_select in_out_voltage_filter_fir_en out_voltage1_hardwaregain in_temp0_input out_voltage1_rf_port_select in_voltage0_gain_control_mode out_voltage2_raw in_voltage0_hardwaregain out_voltage2_scale in_voltage0_rf_port_select out_voltage3_raw in_voltage0_rssi out_voltage3_scale in_voltage1_gain_control_mode out_voltage_filter_fir_en in_voltage1_hardwaregain out_voltage_rf_bandwidth in_voltage1_rf_port_select out_voltage_rf_port_select_available in_voltage1_rssi out_voltage_sampling_frequency in_voltage2_offset power in_voltage2_raw rx_path_rates in_voltage2_scale subsystem in_voltage_bb_dc_offset_tracking_en trx_rate_governor in_voltage_filter_fir_en trx_rate_governor_available in_voltage_gain_control_mode_available tx_path_rates in_voltage_quadrature_tracking_en uevent in_voltage_rf_bandwidth
The program we will use, IIO Oscilloscope, use the sysfs interface to configure the ad9361, and use the special character device /dev/iio:device1 to read the raw values.
This test has been realized with a Zed board, coupled with a AD-FMCOMMS3-EBZ module.
We will monitor the most used FM band, from 87.5 MHz to 107.9 MHz. The IIO Oscilloscope can be configured like this:
Lanch a capture, and you will be able to see peaks in the frequency domain:
In this screenshot, it is clearly possible to identify several channels: at 95.5 MHz, 96.3 MHz, 97.5 MHz, 98.4 MHz among other frequencies.
To verify if those frequencies actually correspond to something, we can use the iio_fm_radio tool. But first, it is necessary to change the gain control:
echo fast_attack > /sys/bus/iio/devices/iio:device1/in_voltage1_gain_control_mode
Then, the iio_fm_radio_play tool will playback the desired channel on the speaker of the HDMI monitor:
To directly get access to the audio waveform data the iio_fm_radio tool can be used. This tool outputs the audio data (in 16-bit mono at 48kHz) on standard output from where it can be taken and further processed. E.g. the following command plays back the stream on the headphone jack of the ZED board.
iio_fm_radio 95.5 | aplay -D default:CARD=ADAU1761 -r 48000 -f S16