Real-Time Workshop    

External Mode Communications Overview

This section gives a high-level overview of how a Real-Time Workshop generated program communicates with Simulink in external mode. This description is based on the TCP/IP version of external mode that ships with Real-Time Workshop.

For communication to take place:

The client and server communicate via two sockets. Each socket supports a distinct channel. The message channel is bidirectional; it carries commands, responses, and parameter downloads. The unidirectional upload channel is for uploading signal data to the client. The message channel is given higher priority.

If the target program was invoked with the -w command line option, the program enters a wait state until it receives a message from the host. Otherwise, the program begins execution of the model. While the target program is in a wait state, Simulink can download parameters to the target and configure data uploading.

When the user chooses the Connect to target option from the Simulation menu, the host initiates a handshake by sending an EXT_CONNECT message. The server responds with information about itself. This information includes:

At this point, host and server are connected. The server is either executing the model or in the wait state. (In the latter case, the user can begin model execution by selecting Start real-time code from the Simulation menu.)

During model execution, the message server runs as a background task. This task receives and processes messages such as parameter downloads.

Data uploading comprises both foreground execution and background servicing of the upload channel. As the target computes model outputs, it also copies signal values into data upload buffers. This occurs as part of the task associated with each task identifier (tid). Therefore, data collection occurs in the foreground. Transmission of the collected data, however, occurs as a background task. The background task sends the data in the collection buffers to Simulink via the upload channel.

The host initiates most exchanges on the message channel. The target usually sends a response confirming that it has received and processed the message. Examples of messages and commands are:

Model execution terminates when the model reaches its final time, when the host sends a terminate command, or when a Stop Simulation block terminates execution. On termination, the server informs the host that model execution has stopped, and shuts down both sockets. The host also shuts down its sockets, and exits external mode.


  The Design of External Mode External Mode Source Files