Main Content

UDP String Data and Message Handling

This example shows how to transfer text data by using the UDP communication protocol and shows how to store the incoming messages in a FIFO queue.

The model receives randomly distributed text messages containing textual color description by using the Stream Input block. The model converts the textual color description into corresponding numeric color code. A FIFO queue stores the color codes. The model sequentially displays the received colors at a sample rate that is perceptible to the human eye.

The Message generator subsystem simulates a remote device by randomly sending color text messages to the model. These messages provide input data for the example.

Run Model in Normal Mode

  1. To switch to normal mode if needed, on the Simulation tab, select Normal mode.

  2. To start the real-time execution, on the Simulation tab, click Run.

Run Model in External Mode

To start the real-time execution in external mode, on the Desktop Real-Time tab, click Run in Real Time. The model builds, connects to Simulink in external mode, and starts.

Open the Model

These commands open the model and suppress warning about board not installed.

w = warning('off', 'sldrt:blkgui:boardnotonlist');
open_system(fullfile(matlabroot,'toolbox','sldrt','sldrtexamples','sldrtex_stringmessage'));
warning(w);

Close Open Scopes

close_system(find_system(gcs ,'BlockType', 'Scope'));

Clean Up Model

clear
close all
bdclose all

See Also