I'm trying to add low-pass filter and read or set hardware gain and rssi in my own program, but I get some problems when I do these. The first question is about filter, I did it as follows:
static int load_fir_filter(const char *filter_file_name)
int ret = -1;
FILE *filter_file = fopen(filter_file_name, "r");
fseek(filter_file, 0, SEEK_END);
filter_len = ftell(filter_file);
filter_buf = malloc(filter_len);
fseek(filter_file, 0, SEEK_SET);
filter_len = fread(filter_buf, 1, filter_len, filter_file);
ret = iio_device_attr_write_raw(tx,
"filter_fir_config", filter_buf, filter_len);
if (ret < 0)
printf("FIR filter config failed\n");
In the main() function, I did this: filter_ret = load_fir_filter(filter_file_name); But the iio_device_attr_write_raw() function got a less then zero return, it means write failure, I'm sure the filter_buf and filter_len are right. Could you tell me why? Thank you.
The second question is about rssi, the programs are as follows:
int rssi_ret = 0;
uint32_t address = 0x1A7;
rssi_ret = iio_device_reg_read(rx, address, &rssi_value);
printf("rssi value = %d dB\n", rssi_value);
The iio_device_reg_read() function's return is right, but the rssi_value is always the same (101), it means there must be some problems in my program, do some steps lose? Thank you.
The last question is about hardware gain.
AGC_ret = iio_device_reg_write(rx, 0x132, 90);
printf("AGC write success\n");
AGC_ret = iio_device_reg_read(rx, 0x132, &AGC);
printf("set AGC = %d dB\n", AGC);
I found I change the AGC successfully, but the transmite distance of TX and RX is not changed, the transmite distance is very close. I used two zynq706 boards and two ad9361 boards, one for TX, one for RX.