Main Content

Target

Represent real-time application and target computer status

Since R2020b

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, 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
copyPageCopy one calibration page to another in the real-time application
deleteParamSetDelete selected parameter set file from an application
deleteProfilerDataDelete execution profiler data from target computer
disconnectDisconnect MATLAB from target computer
exportParamSetWrite ParameterSet object data to parameter set file
getAllInstrumentsGet information on instruments added to target object
getApplicationFileGet name of real-time application file
getAvailableProfileGet information about available execution profiler data
getECUPageGet current page number used by ECU on real-time application
getInstalledApplicationsGet list of installed real-time application files
getLastApplicationGet name of real-time application most recently run on target computer
getNumPagesGet number of pages in memory for real-time application
getPersistentVariablesGet persistent variables from the Simulink Real-Time target computer to MATLAB
getProfilerDataRetrieve profile data object
getStartupAppGet information about startup application configuration on target computer
getXCPPageGet current page number used by XCP on real-time application
getparamRead value of observable parameter in real-time application
getsignalRead a signal value from a real-time application
getVersionGet MATLAB, support package, and Speedgoat I/O Blockset version information
importParamSetCreate ParameterSet object
installInstall real-time application on target computer
isConnectedGet target computer connected status
isLoadedGet real-time application loaded status
isRunningGet real-time application running status
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
removeAllApplicationsRemoves all Simulink Real-Time applications from target computer
removeApplicationRemoves Simulink Real-Time application from target computer
removeInstrumentRemove selected instrument object from target object
resetReset target object
resetProfilerReset profiling service state to Ready
saveParamSetSave real-time application parameter values
setECUAndXCPPageSet memory pages used by XCP and ECU to selected memory page on real-time application
setECUPageSet memory page used by ECU to selected memory page on real-time application
setStartupAppConfigure startup real-time application for target computer
setStopTimeConfigure stop time for real-time application
setXCPPageSet memory page used by XCP to selected memory page on real-time application
setipaddrSet IP address and netmask on the target computer
setparamChange value of tunable parameter in real-time application
setPersistentVariablesSet persistent variables from MATLAB to the Simulink Real-Time target computer
startStart execution of real-time application on target computer
startProfilerStart profiling service on target computer
startRecordingStarts signal data live streaming and File Log logging
statusGet status of real-time application on target computer
stopStop execution of real-time application on target computer
stopProfilerStop profiling service on target computer
stopRecordingStops signal data live streaming and File Log logging
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';
openExample(model);
slbuild(model);
tg = slrealtime('TargetPC1');
load(tg,model);
start(tg);

Version History

Introduced in R2020b

expand all