Apply Conditional Execution
You can apply conditional execution to determine whether the receiver blocks or System objects available in theCommunications Toolbox™ Support Package for USRP™ Embedded Series Radioreceive valid data from the radio hardware.
Conditional Execution with Receiver Blocks
TheE3xx Receiverblock hasa staticdata validoutput port returning a logical value.
1
indicates that the block has received data from the radio hardware.0
indicates that the block has not received data from the radio hardware. Either Simulink®runs faster than the radio hardware during simulation or the radio hardware has no new data to send to Simulink when the sampling occurs.
Any processing that occurs downstream of the receiver block must run only on valid data. To ensure that data is valid, control the data with an enabled subsystem. Thedata validoutput serves as a convenient control signal for such an enabled subsystem.
Example
To enable thedata validport of theE3xx Receiverblock, on theAdvancedtab of the block mask, updateData timeout (sec)to a value other thanInf
. When this value is set toInf
, the block indefinitely waits for valid data and this port is not required.
When used in a model, the output from this port can help determine data validity.
Conditional Execution with Receiver System Objects
When you call thecomm.SDRRxE3xx
System object™, the second output arguments is a logical value that indicates validity of the data packets streaming to MATLAB®from the radio hardware.
true
indicates that the System object has received data from the radio hardware.false
indicates that the System object has not received data from the radio hardware.
Any processing that occurs downstream of the System object must have conditions to accept only valid data. Note that if theDataTimeout
property is set toInf
, the object indefinitely waits for valid data. In this case, the second output argument of the object indicating data validity is alwaystrue
and can be ignored.
Example
Create a receiver System object.
rx = sdrrx('E3xx');% Use second output argument for validationrx.DataTimeout = 0;
Receive data using the object. Validate data, then save valid data using a log.
Log = dsp.SignalSink;forcounter = 1:20 [data,validData,overflow] = rx();ifvalidData == 1ifoverflow ~=1%的连续数据Log(data);endelsedisp('Not valid data.');endend