Main Content

创建公益诉讼目标连接配置万博1manbetx

Target Connectivity Configurations for PIL

Use target connectivity configurations and the target connectivity API to customize processor-in-the-loop (PIL) simulation for your target environments.

通过目标连接配置,您指定:

  • A configuration name for a target connectivity API implementation.

  • Settings that define the set of compatible Simulink®models. For example, the set of models that have a particular system target file, template makefile, and hardware implementation.

A PIL simulation requires a target connectivity API implementation that integrates third-party tools for:

  • 交叉编译生成的代码,创建在目标硬件上运行的PIL应用程序。

  • Downloading, starting, and stopping the application on the target.

  • 在Simulink和目标之间进行交流。万博1manbetx

您可以具有许多不同的目标连接配置来拟合PIL模拟。通过创建一个万博1manbetxsl_customization.mfile and placing it on the MATLAB®search path.

When you run a PIL simulation, the software determines which of the available connectivity configurations to use. The software looks for a connectivity configuration that is compatible with the model under test. If the software finds multiple or no compatible connectivity configurations, the software generates an error message with information about resolving the problem.

Create a Target Connectivity API Implementation

该图显示了PIL目标连接API的组件。

You must provide implementations of the three API components:

  • Build API — Specify theSimulink Coder™用于构建生成代码的工具链或模板makefile方法。

  • 启动器API - 控制Simulink如何启动并停止万博1manbetxPIL可执行文件。

  • 通信API - 自定义Simulink和PIL目标之间的连接。万博1manbetx嵌入式编码器®提供对TCP/IP和串行通信的主机端支万博1manbetx持,您可以适应其他协议。

这些步骤概述了如何创建目标连接API实现。步骤中显示的示例代码是从ConnectivityConfig.minConfigure Processor-In-The-Loop (PIL) for a Custom Target

  1. 创建一个子类rtw.connectivity.config

    ConnectivityConfig < rtw.connectivity.Config

  2. 在子类中:

    • 实例化rtw.connectivity.makefilebuilder,配置构建过程。

      builder = rtw.connectivity.MakefileBuilder(componentArgs, ... targetApplicationFramework, ... exeExtension);

    • 创建一个子类rtw.connectivity.Launcher, which downloads and executes the application using a third-party tool.

      启动器= mypil.launcher(componentargs,builder);

  3. 配置您的rtiostreamAPI实施主机 - 目标通信渠道。

    • For the target side, you must provide the driver code for communications, for example, TCP/IP or serial communications. To integrate this code into the build process, create a subclass ofrtw.pil.rtiostreamapplicationframework

    • 对于主机端,您可以将提供的库用于TCP/IP或串行通信。实例化rtw.connectivity.rtiostreamhostCommunicator, which loads and initializes the library that you specify.

      hostCommunicator = rtw.connectivity.rtiostreamHostCommunicator(ComponentArgs,...启动器,... rtiostreamlib);

  4. 如果您需要生成代码的执行时间分析,请创建一个计时器对象,该计时器对特定于硬件的计时器和关联的源文件的详细信息。看指定硬件计时器

笔记

Each time you modify a connectivity implementation, close and reopen the models to refresh them.

注册连接API实施

To register a target connectivity API implementation as a target connectivity configuration in Simulink:

  1. 创建或更新sl_customization.mfile. In this file:

    • Create a target connectivity configuration object that specifies, for example, the configuration name for a target connectivity API implementation and compatible models.

    • 调用registerTargetInfo

  2. 添加包含的文件夹sl_customization.mto the search path and refresh your customizations.

    addpath(sl_customization_path);sl_refresh_customizations;

For more information, seertw.connectivity.configregistry

验证目标连接配置

To verify your target connectivity configuration early on and independently of your model development and code generation, use the supplied皮尔特功能。使用该功能,您可以运行一套测试。在测试中,该函数运行各种正常,SIL和PIL模拟。该函数比较结果并产生错误,如果它检测到模拟模式之间的差异。

Target Connectivity API Examples

For step-by-step examples, see:

  • Configure Processor-In-The-Loop (PIL) for a Custom Target

    此示例向您展示了如何使用目标连接API创建自定义PIL实现。您可以检查配置构建过程以支持PIL的代码,下载和执行工具以及主机和目标之间的通信渠道。万博1manbetx要激活基于主机的完整PIL配置,请按照示例中的步骤操作。

  • Create a Target Communication Channel for Processor-In-The-Loop (PIL) Simulation

    This example shows you how to implement a communication channel for use with the Embedded Coder product and your embedded target. This communication channel enables exchange of data between different processes. PIL simulation requires exchange of data between the Simulink software running on your development computer and deployed code executing on target hardware.

    rtiostream接口提供了一个通用的通信通道,您可以以目标连接驱动程序的形式为一系列连接类型实现。该示例显示了如何为TCP/IP配置自己的目标端驱动程序,以使用默认的主机端TCP/IP驱动程序进行操作。默认的TCP/IP通信允许主机和目标之间的高带宽通信,您可以将其用于传输视频等数据。

    笔记

    如果您自定义rtiostream用于PIL模拟的TCP/IP实现,必须关闭连接服务器端的Nagle的算法。如果Nagle的算法未关闭,则您的PIL模拟可以以明显较慢的速度运行。这matlabroot/toolbox/coder/rtiostream/src/rtiostreamtcpip/rtiostream_tcpip.cfile shows how you can turn off Nagle's algorithm:

    /* Disable Nagle's Algorithm*/ option = 1; sockStatus = setsockopt(lFd,IPPROTO_TCP,TCP_NODELAY,(char*)&option,sizeof(option));
    这code for your custom TCP/IP implementation can require modification.

    这example also shows how to implement custom target connectivity drivers, for example, using serial, CAN, or USB for both host and target sides of the communication channel.

也可以看看

||||||

Related Topics