This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
resources:eval:user-guides:matlab_bsp_extend [02 May 2019 01:24] – created Travis Collins | resources:eval:user-guides:matlab_bsp_extend [02 May 2019 01:37] (current) – add headings Travis Collins | ||
---|---|---|---|
Line 5: | Line 5: | ||
The MATLAB and Simulink interfaces can be extended in two ways. | The MATLAB and Simulink interfaces can be extended in two ways. | ||
- | 1. Directly address properties through the underlying libIIO API calls. For example, the RSSI measurement is not provided as part of the AD9361 transceiver interfaces. To read this attribute directly we could do the following with the [[https:// | + | ==== Directly Addressing Attributes ==== |
+ | 1. Directly address properties through the underlying libIIO API calls. By default the AD9361 receiver interfaces only provide or control the following properties: | ||
+ | < | ||
+ | rx = | ||
+ | |||
+ | adi.AD9361.Rx with properties: | ||
+ | |||
+ | | ||
+ | SamplingRate: | ||
+ | | ||
+ | | ||
+ | EnableQuadratureTracking: | ||
+ | EnableRFDCTracking: | ||
+ | EnableBasebandDCTracking: | ||
+ | | ||
+ | channelCount: | ||
+ | EnableCustomFilter: | ||
+ | uri: ' | ||
+ | </ | ||
+ | This does not provide status attributes or other more obscure control attributes. For example, the RSSI measurement is not provided as part of the AD9361 transceiver interfaces. To read this attribute directly we could do the following with the [[https:// | ||
< | < | ||
rx = adi.AD9361.Rx(' | rx = adi.AD9361.Rx(' | ||
rssiValue = rx.getAttributeLongLong(' | rssiValue = rx.getAttributeLongLong(' | ||
</ | </ | ||
+ | |||
+ | ==== Adding MATLAB Properties For Attributes ==== | ||
+ | 2. If additional APIs are needed for a device, and that code will be used by others, then it is recommended to add an actual property to the class. This can provide additional documentation as well as range checking. Below the [[https:// | ||
+ | < | ||
+ | properties | ||
+ | %RFPort RF Port | ||
+ | % | ||
+ | % ' | ||
+ | % ' | ||
+ | % ' | ||
+ | % ' | ||
+ | RFPort = ' | ||
+ | end | ||
+ | </ | ||
+ | Now under the standard methods scope the following set method is added | ||
+ | < | ||
+ | % Check RFPort | ||
+ | function set.RFPort (obj, value) | ||
+ | obj.RFPort = value; | ||
+ | if obj.ConnectedToDevice | ||
+ | id = ' | ||
+ | obj.setAttributeRAW(id,' | ||
+ | end | ||
+ | end | ||
+ | </ | ||
+ | Now when the class is expanded the new property is populated: | ||
+ | < | ||
+ | rx = | ||
+ | |||
+ | adi.AD9361.Rx with properties: | ||
+ | |||
+ | | ||
+ | SamplingRate: | ||
+ | | ||
+ | RFPort: ' | ||
+ | | ||
+ | EnableQuadratureTracking: | ||
+ | EnableRFDCTracking: | ||
+ | EnableBasebandDCTracking: | ||
+ | | ||
+ | channelCount: | ||
+ | EnableCustomFilter: | ||
+ | uri: ' | ||
+ | </ | ||
+ | |||
+ |