Real-Time Workshop | ![]() ![]() |
Running the External Program
The external program must be running before you can use Simulink in external mode. To run the external program, you type a command of the form
where model
is the name of the external program and -opt1
... -
optN
are options. (See Command Line Options for the External Program). In the examples in this section, we assume the name of the external program to be ext_example
.
Running the External Program Under Windows
In the Windows environment, you can run the external programs in either of the following ways:
!
) and followed by an ampersand (&
) , as in the following example.
&
) causes the operating system to spawn another process to run the target executable.
Running the External Program Under UNIX
In the UNIX environment, you can run the external programs in either of the following ways:
Xterm
window. At the command prompt, type the name of the target executable, followed by any options, as in the following example.
!
) and followed by an ampersand (&
) , as in the following example.
Command Line Options for the External Program
External mode target executables generated by Real-Time Workshop support the following command line options:
-tf
option overrides the stop time set for the model in Simulink. The argument n
specifies the number of seconds the program will run. The value inf
directs the model to run indefinitely. In this case, the model code will run until the target program receives a stop message from Simulink.
Note
You may use the -tf option with GRT, GRT malloc, ERT, and Tornado targets. If you are implementing a custom target and want to support the -tf option, you must implement the option yourself. See Creating an External Mode Communication Channel for further information.
|
-w
option instructs the target program to enter a wait state until it receives a message from the host. At this point, the target is running, but not executing the model code. The start message is sent when you select Start real-time code from the Simulation menu or click the Start real-time code button in the External Mode Control Panel.
Use the -w
option if you want to view data from time step 0 of the target program execution, or if you want to modify parameters before the target program begins execution of model code.
-port
option specifies the TCP/IP port number, n
, for the target program. The port number of the target program must match that of the host. The default port number is 17725
. The port number must be a value between 256
and 65535
.
Note
The -w and -port options are supported by the TCP/IP transport layer modules shipped with Real-Time Workshop. By default, these modules are linked into external mode target executables. If you are implementing a custom external mode transport layer and want to support these options, you must implement them in your code. See Creating an External Mode Communication Channel for further information. See matlabroot /rtw/c/src/ext_transport.c for example code.
|
![]() | External Mode Compatible Targets | Error Conditions | ![]() |