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 Connected IO Mode

  1. To switch to Connected IO mode if needed, on the Desktop Real-Time tab, select Mode > Connected IO.

  2. To start the real-time execution, click Run in Real-Time.

Run Model in Run in Kernel Mode

  1. To switch to Run in Kernel mode if needed, on the Desktop Real-Time tab, select Mode > Run in Kernel.

  2. To start the real-time execution, click Run in Real-Time.

The model builds, connects to Simulink® in Run in Kernel 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('sldrtex_stringmessage');
warning(w);

Close Open Scopes

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

Clean Up Model

clear
close all
bdclose all

See Also