The SDRu receiver block and System object™ components have a length output that can be used to trigger conditional execution of components downstream from them.
The SDRu Receiver block has a static
length port that
outputs either 0 or the frame length specified in the block mask. When the output is 0,
Simulink® is running faster than the USRP™ hardware, and the hardware did not have any new data to send to Simulink at that instant of sample time. When the output is the specified frame length,
then the hardware sent valid data.
Any processing downstream of the SDRu Receiver block needs to run only
when there is valid data to process, so control it with an enabled subsystem. The
length output serves as a convenient control signal for such an enabled
To get more information on sample time, see What Is Sample Time? (Simulink).
The SDRu Receiver block has a
length port for validating the
presence of data.
System object uses a data length output when the object is called as a function to indicate
the length of data packets streaming to MATLAB® from the USRP hardware. If the length is 0, then the hardware has not sent any valid data.
If the length equals the specified
FrameLength, then it has sent valid
data. Any downstream processing must be conditioned on the presence of valid data.
Set up your USRP hardware and make sure that the host PC is communicating with the radio before you run this example.
radio = comm.SDRuReceiver('Platform','N200/N210/USRP2', ... 'IPAddress','192.168.10.2','CenterFrequency',102.5e6, ... 'Gain',30,'DecimationFactor',500, ... 'SamplesPerFrame',4000,'OutputDataType','single'); % USRP N200/N210/USRP2 master clock rate is 100 MHz sampleRate = 100e6/500; frameTime = 4000/sampleRate; radioList = findsdru('192.168.10.2'); if strcmp(radioList.Status,'Success') % Loop until the example reaches 10 seconds timeCounter = 0; while timeCounter < 10 [data, len] = radio(); if len > 0 % Received valid data, so run downstream algorithm % <insert you algorithm and code to process> % Update counter timeCounter = timeCounter + frameTime; end end end