analogdevicesinc / TransceiverToolbox

MATLAB toolbox for ADI transceiver products

Home Page:https://analogdevicesinc.github.io/TransceiverToolbox/master

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TransceiverToolbox/+adi/+AD9371/ORx.m crashes MATLAB R2020b in Windows 10

Shaun-Cummins opened this issue · comments

https://github.com/analogdevicesinc/TransceiverToolbox/blob/master/%2Badi/%2BAD9371/ORx.m
When adjusting manual mode ORx gain after initialisation, function set.Gain(obj, value) calls obj.setAttributeLongLong('voltage2','hardwaregain',value,false);

However, when Attribute.m's function call to setAttributeLongLong(obj,id,attr,value,isOutput,tol,phydev) to checks the value back after it has been written using: [status, rValue] = iio_channel_attr_read_longlong(obj,chanPtr,attr);, the following cstatus(obj,status,['Attribute ' attr ' return value ' num2str(rValue) ', expected ' num2str(value)]); is thrown.

The next time the observation receive object is called, MATLAB does a complete crash with dump.

However, within ORx.m, it appears that the call to obj.setAttributeRAW('voltage2','rf_port_select','OFF',false); within immediately before obj.setAttributeLongLong('voltage2','hardwaregain',value,false); causes the ZC706 to ignore the write and return -229 dB.
This was confirmed using the iio_info command via the terminal where the voltage2/hardwaregain does change from the default of 18.0 dB to -220 dB when the RF Port is changed to OFF.

By removing the call to obj.setAttributeRAW('voltage2','rf_port_select' before and after the gain setting does appear to alleviate throwing the cstatus and avoiding the subsequent MATLAB crashing.

Another workaround is to detect if ConnectedToDevice for the ORx object just prior to calling another observation.

I don't think that MATLAB should not crash if a cstatus is legitimately thrown from time to time.

I pushed a fix here for the state: #96

However, I could not make MATLAB crash