Real-Time Workshop    

The Design of External Mode

External mode communication between Simulink and a target system is based on a client/server architecture. The client (Simulink) transmits messages requesting the server (target) to accept parameter changes or to upload signal data. The server responds by executing the request.

A low-level transport layer handles physical transmission of messages. Both Simulink and the model code are independent of this layer. Both the transport layer and code directly interfacing to the transport layer are isolated in separate modules that format, transmit and receive messages and data packets.

This design makes it possible for different targets to use different transport layers. For example, the GRT, GRT malloc, ERT, and Tornado targets support host/target communication via TCP/IP, whereas the xPC Target supports both RS232 (serial) and TCP/IP communication.

Real-Time Workshop provides full source code for both the client and server-side external mode modules, as used by the GRT, GRT malloc, ERT, rapid simulation, real-time Windows, xPC, and Tornado targets. The main client-side module is ext_comm.c. The main server-side module is ext_svr.c.

These two modules call the TCP/IP transport layer. ext_transport.c implements the client-side transport functions. ext_svr_transport.c contains the corresponding server-side functions. You can modify these files to support external mode via your own low-level communications layer.

You need only modify those parts of the code that implement low-level communications. You need not be concerned with issues such as data conversions between host and target, or with the formatting of messages. Code provided by Real-Time Workshop handles these functions.

On the client (Simulink) side, communications are handled by ext_comm, a C MEX-file. This component is implemented as a DLL on Windows, or as a shared library on UNIX.

On the server (target) side, external mode modules are linked into the target executable. This takes place automatically if the External mode code generation option is selected at code generation time. These modules, called from the main program and the model execution engine, are independent of the generated model code.

To implement your own low-level protocol:


  Creating an External Mode Communication Channel External Mode Communications Overview