How do I use External Mode from the command line?

8 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2021 年 7 月 14 日
編集済み: MathWorks Support Team 2025 年 2 月 4 日 6:15
I am familiar with running External Mode simulations using the user interface available in the Hardware and Run on Custom Hardware apps. How can I do the same thing from the command line?

採用された回答

MathWorks Support Team
MathWorks Support Team 2025 年 2 月 3 日 0:00
編集済み: MathWorks Support Team 2025 年 2 月 4 日 6:15
It depends on how you are going to deploy your Simulink model onto the target. There are three options outlined below.

Using a Hardware Support Package

If you are using a Hardware Support Package, consult the documentation for the support package to learn how to set up the model and run External Mode from the command line. Once you set up the model according to the support package documentation, you will likely be able to run External mode with the following:
>> set_param(mdl,'SimulationMode','external') >> set_param(mdl,'SimulationCommand','start')

Custom hardware and using 3rd party software to deploy the code

If you have custom hardware and would like to only generate code from Simulink, and use a 3rd party software for building and deploying the code, then all you need to do from Simulink is connect to the target application. You can do that by following the steps in this documentation page: External Mode from Command line
Note that the documentation page above assumes the target application is deployed and running on the target. At a high level, the workflow looks something like this:
  1. Generate code from Simulink, with the ExtMode Configuration Parameter turned on. This will generate the files necessary to implement External Mode
  2. Package the generated code and relocate it to your 3rd party environment
  3. Modify the code according to the instructions here: Create a Transport Layer for TCP/IP or Serial External Mode Communication
  4. Build the code and deploy the application to your hardware using the 3rd party software
  5. Connect to the application running on the target from Simulink, using the commands from External Mode from Command line

Custom hardware and using Simulink to deploy the code

If you have custom hardware and would like to build, deploy, and start the external mode simulation from Simulink, you will need to set it up manually. See the following documentation links for how to set up your target with External Mode:
For MATLAB R2020b and earlier, you need to register a custom launcher. To access the release-specific documentation, execute the following command in the MATLAB R2020b command window:
>> web(fullfile(docroot, 'rtw/ug/external-mode-simulation-with-xcp-communication.html'))
For MATLAB R2021a and later, you can use the target package: target Package
Once you set that up, you will be able to run the following to start External Mode simulation from the command line:
>> set_param(mdl,'SimulationMode','external') >> set_param(mdl,'SimulationCommand','start')
The 'start' command will then build, deploy, and run the application on the target.
For additional information regarding the current release, please follow the link below:

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDeployment, Integration, and Supported Hardware についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by