Real-Time Workshop User's Guide | ![]() ![]() |
Host (ext_comm) Source Files
The source files for the ext_comm
component are located in the directory matlabroot
/rtw/ext_mode
:
ext_comm.c
This file is the core of external mode communication. It acts as a relay station between the target and Simulink. ext_comm.c
communicates to Simulink via a shared data structure, ExternalSim
. It communicates to the target via calls to the transport layer.
Tasks carried out by ext_comm
include establishment of a connection with the target, downloading of parameters, and termination of the connection with the target.
ext_transport.c
This file implements required transport layer functions. (Note that ext_transport.c
includes ext_transport_share.h
, which contains functions common to client and server sides.) The version of ext_transport.c
shipped with the Real-Time Workshop uses TCP/IP functions including recv()
, send()
, and socket()
.
ext_main.c
This file is a MEX-file wrapper for external mode. ext_main
interfaces to Simulink via the standard mexFunction
call. (See External Interfaces in the MATLAB online documentation for information on mexFunction.) ext_main
contains a function dispatcher, esGetAction
, that sends requests from Simulink to ext_comm
.
xt_convert.c
This file contains functions used for converting data from host to target formats (and vice versa). Functions include byte-swapping (big to little- endian), conversion from non-IEEE floats to IEEE doubles, and other conversions. These functions are called both by ext_comm.c
and directly by Simulink (via function pointers).
extsim.h
This file defines the ExternalSim
data structure and access macros. This structure is used for communication between Simulink and ext_comm.c
.
extutil.h
This file contains only conditionals for compilation of the assert
macro.
Target (Server) Source Files
These files are part of the run-time interface and are linked into the model
.exe
executable. They are located in the directory matlabroot
/rtw/c/src
.
ext_svr.c
ext_svr.c
is analogous to ext_comm.c
on the host, but generally is responsible for more tasks. It acts as a relay station between the host and the generated code. Like ext_comm.c
, ext_svr.c
carries out tasks such as establishing and terminating connection with the host. ext_svr.c
also contains the background task functions that either write downloaded parameters to the target model, or extract data from the target data buffers and send it back to the host.
The version of ext_svr.c
shipped with the Real-Time Workshop uses TCP/IP functions including recv()
, send()
, and socket()
.
ext_svr_transport.c
This file implements required transport layer functions. (Note that ext_svr_transport.c
includes ext_transport_share.h
, which contains functions common to client and server sides.) The version of ext_svr_transport.c
shipped with the Real-Time Workshop uses TCP/IP functions including recv()
, send()
, and socket()
.
updown.c
updown.c
handles the details of interacting with the target model. During parameter downloads, updown.c
does the work of installing the new parameters into the model's parameter vector. For data uploading, updown.c
contains the functions that extract data from the model's blockio
vector and write the data to the upload buffers. updown.c
provides services both to ext_svr.c
and to the model code (e.g., grt_main.c
). It contains code that is called via the background tasks of ext_svr.c
as well as code that is called as part of the higher priority model execution.
t_info.h
and model
.dt
These files contain data type transition information that allows access to multi-data type structures across different computer architectures. This information is used in data conversions between host and target formats.
updown_util.h
This file contains only conditionals for compilation of the assert
macro.
Other Files
xt_share.h
Contains message code definitions and other definitions required by both the host and target modules.
ext_transport_share.h
Contains functions and data structures required by both the host and target modules of the transport layer. The version of ext_transport_share.h
shipped with the Real-time Workshop is specific to TCP/IP communications.
![]() | Overview of External Mode Communications | Guidelines for Implementing the Transport Layer | ![]() |