Main Content

Register Custom Launcher

Note

The use of a custom launcher to set up connectivity between Simulink® and your target hardware is not recommended. Use the target namespace instead. For more information, see Set Up External Mode Connectivity Between Simulink and Target Hardware

To support the one-click workflow or Deploy step for custom hardware, register your custom launcher for the target application.

  1. Create an rtw.connectivity.Config (Embedded Coder) subclass, which requires myCustomLauncher, a launcher that you provide. myCustomLauncher is a subclass of rtw.connectivity.Launcher (Embedded Coder). In myCustomLauncher, to support one-click functionality, provide an implementation of the getApplicationStatus method. For the communicator and builder subclasses, you can use dummy classes.

    classdef myTargetConnectivityConfig < rtw.connectivity.Config
      methods
        % Constructor
        function this = myTargetConnectivityConfig(componentArgs)
          
          % Launcher with port 0 argument to start TCP/IP server on free port
          modelName = componentArgs.getModelName();
          bDirInfo = RTW.getBuildDir(modelName);
          exeName = fullfile(bDirInfo.CodeGenFolder, modelName);
          if ispc
            exeName = [exeName, '.exe'];
          end
          launcher = myCustomLauncher(componentArgs);
          launcher.setExe(exeName);
    
          % Create dummy communicator and builder
          communicator = rtw.connectivity.RtIOStreamHostCommunicator.empty();
          builder = rtw.connectivity.MakefileBuilder.empty();
    
          % Call super class constructor to register components
          this@rtw.connectivity.Config(componentArgs, builder, launcher, communicator);
        end
      end
    end

  2. To register the implementation in Simulink, create an sl_customization.m file.

    function sl_customization(cm)
      cm.registerTargetInfo(@loc_createConfig);
    end
    % local function
    function config = loc_createConfig
      config = rtw.connectivity.ConfigRegistry;
      config.ConfigClass = 'myTargetConnectivityConfig';
    
      % Specify compatible model configuration. For example,
      % through SystemTargetFile and TargetHWDeviceType properties.
      config.SystemTargetFile = {'ert.tlc'};
      config.TargetHWDeviceType = { 'ARM Compatible->ARM Cortex' };
    end
    See Create sl_customization.m File (Embedded Coder).

  3. Add the folder containing sl_customization.m to the search path and refresh your customizations.

    addpath(sl_customization_path);
    sl_refresh_customizations;

See Also

Topics