Main Content

Target

Represent real-time application and target computer status

Description

A Target object represents a target computer and provides access to methods and properties related to the target computer.

The object provides access to methods and properties that:

  • Start and stop the real-time application.

  • Read and set parameters.

  • Monitor signals.

  • Retrieve status information about the target computer.

  • Restart the target computer.

  • Load the real-time application.

  • Start, stop, and retrieve information from the profiler.

Function names are case-sensitive. Type the entire name. Property names are not case-sensitive. You do not need to type the entire name if the characters you type are unique for the property.

You can invoke some of the object properties and functions from the target computer command line when the real-time application has been loaded. For more information, see Target Computer Command-Line Interface.

Creation

target_object = slrealtime constructs a target object representing the default target computer.

target_object = slrealtime(target_name) constructs a target object representing the target computer designated by target_name.

The slrealtime function accepts these arguments:

  • target_name — Name assigned to target computer (character vector or string scalar). For example, 'TargetPC1'.

  • target_object — Object representing target computer. For example, tg.

Example: Create Target Object for Default Target Computer

Example: Build and Run Real-Time Application

Properties

expand all

The TargetSettings property holds a TargetSettings structure that includes fields name, address, sshPort, xcpPort, username, userPassword, and rootPassword. To view the targetSettings, in the MATLAB Command Window, type:

tg.TargetSettings
ans = 

  TargetSettings with properties:

            name: 'TargetPC1'
         address: '192.168.7.5'
         sshPort: 22
         xcpPort: 5555
        username: 'slrt'
    userPassword: 'slrt'
    rootPassword: 'root'

The ProfilerStatus property holds the execution profiler status. To view the ProfilerStatus, in the MATLAB Command Window, type:

tg.ProfilerStatus
ans =

    'Ready'

The SDIRunId property holds the Simulation Data Inspector run identifier for the current simulation run. To view the SDIRunId, in the MATLAB Command Window, type:

tg.SDIRunId
ans =

  int32

   22110

The ptpd property holds a PTPControl structure that includes fields Command and AutoStart. For more information, see the Target.ptpd object. To view the targetSettings, in the MATLAB Command Window, type:

tg.ptpd
ans = 

  PTPControl with properties:

      Command: 'ptpd -L -K -g'
    AutoStart: 1

The FileLog property holds a FileLogger structure that includes fields Importing, ImportProgress, LoggingService, and DataAvailable. For more information, see the Target.FileLog object. To view the targetSettings, in the MATLAB Command Window, type:

tg.FileLog
ans = 

  FileLogger with properties:

         Importing: 0
    ImportProgress: 100
    LoggingService: STOPPED
     DataAvailable: 0

The Stimulation property provides access to the Target.Stimulation object. To view the Stimulation, in the MATLAB Command Window, type:

tg.Stimulation
ans = 

  StimulationControl with no properties.

The TargetStatus property provides access to target computer status information. The status values are enums. To view the TargetStatus, in the MATLAB Command Window, type:

tg.TargetStatus
ans = 

  struct with fields:

    State: BUSY
    Error: ''

The ModelStatus property provides access to information about the loaded real-time application and related model. The status values are enums. To view the ModelStatus, in the MATLAB Command Window, type:

tg.ModelStatus
ans = 

  struct with fields:

                     State: LOADED
               Application: 'slrt_ex_osc_outport'
                 ModelName: 'slrt_ex_osc_outport'
                     Error: ''
                  LogLevel: "info"
          PollingThreshold: 1.0000e-04
            FileLogMaxRuns: 1
    OverrideBaseRatePeriod: 0
                  StopTime: 10
                  ExecTime: 0
                   TETInfo: [1×1 struct]

Events

A number of the Target object functions produce event status. You can use the MATLAB listener function to monitor event states.

  • Connecting, ConnectFailed, Connected – Events related to connecting a target computer by using the Real-Time tab in the Simulink Editor, Simulink Real-Time Explorer, or the connect function.

  • Disconnecting, Disconnected – Events related to disconnecting a target computer by using the Real-Time tab in the Simulink Editor, Simulink Real-Time Explorer, or the disconnect function.

  • Installing, InstallFailed, Installed – Events related to installing a real-time application on a target computer by using the install function.

  • Loading, LoadFailed, Loaded – Events related to loading a real-time application on a target computer by using the Real-Time tab in the Simulink Editor, Simulink Real-Time Explorer, or the load function.

  • Starting, StartFailed, Started – Events related to starting a real-time application on a target computer by using the Real-Time tab in the Simulink Editor, Simulink Real-Time Explorer, or the start function.

  • Stopping, StopFailed, Stopped – Events related to stopping a real-time application on a target computer by using the Real-Time tab in the Simulink Editor, Simulink Real-Time Explorer, or the stop function.

  • Rebooting, RebootFailed, RebootIssued – Events related to rebooting a target computer by using the Simulink Real-Time Explorer or the reboot function.

  • UpdateBegin, UpdateMessage, UpdateFailed, UpdateCompleted – Events related to updating target computer RTOS software by using the Simulink Real-Time Explorer or the update function.

  • SetIPAddressBegin, SetIPAddressFailed, SetIPAddressCompleted – Events related to changing a target computer IP address by using the Simulink Real-Time Explorer or the setipaddr function.

  • StartupAppChanged – Event related to changing a target computer startup application by using the Simulink Real-Time Explorer or the setStartupApp or clearStartupApp functions.

  • StopTimeChanged – Event related to changing a real-time application stop time by using the Simulink Real-Time Explorer or the setStopTime function.

Object Functions

addInstrumentAdd instrument object to target object
clearStartupAppClear startup application selection on target computer
connectConnect MATLAB to target computer
deleteProfilerDataDelete execution profiler data from target computer
disconnectDisconnect MATLAB from target computer
exportParamSetWrite ParameterSet object data to parameter set file
getAvailableProfileGet information about available execution profiler data
getProfilerDataRetrieve profile data object
getStartupAppGet information about startup application configuration on target computer
getparamRead value of observable parameter in real-time application
importParamSetCreate ParameterSet object
installInstall real-time application on target computer
listParamSetList available parameter set files for application
loadDeploy to target and load real-time application to target computer
loadParamSetRestore parameter values saved in specified file
rebootRestart target computer
removeAllInstrumentsRemove instrument objects from target object
removeInstrumentRemove selected instrument object from target object
resetProfilerReset profiling service state to Ready
saveParamSetSave real-time application parameter values
setipaddrSet IP address and netmask on the target computer
setStartupAppConfigure startup real-time application for target computer
setStopTimeConfigure stop time for real-time application
setparamChange value of tunable parameter in real-time application
startStart execution of real-time application on target computer
startProfilerStart profiling service on target computer
statusGet status of real-time application on target computer
stopStop execution of real-time application on target computer
stopProfilerStop profiling service on target computer
updateUpdate RTOS version on target computer

Examples

collapse all

Create a target object that represents the default target computer.

Create target object tg for the default target computer. You can select the default target computer by using Simulink Real-Time Explorer.

tg = slrealtime

Create a target object that represents target computer TargetPC1.

Create target object tg for a target computer by using an explicit name.

tg = slrealtime('TargetPC1')

Build and download slrt_ex_osc and execute the real-time application.

Open, build, and download the real-time application:

model = 'slrt_ex_osc';
open_system(model);
slbuild(model);
tg = slrealtime('TargetPC1');
load(tg,model);
start(tg);
Introduced in R2020b