Stream Input/Output

This example shows how to transfer data through TCP communication protocol by using ASCII encoding. The model sends data within one computer, from one TCP port to another. You can modify the model to communicate between two computers by splitting this model into its send and receive parts and running the models on two computers. The yellow blocks are used to send the data, the blue blocks are used to receive the data. Then, please enter the host names or IP addresses of the two computers into the appropriate fields in the Board Setup dialog.

Run Model in Normal Mode

  1. To switch to normal mode if needed, double-click the orange button in the model.

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

Run Model in External Mode

  1. To switch to external mode if needed, double-click the orange button in the model.

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

Open the Model

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

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

Close Open Scopes

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

Clean Up Model

clear
close all
bdclose all

See Also