Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Target Computer Commands

You can interact with the real-time application after it has been loaded to the target computer by using a limited set of target computer commands.

  • Function commands — Interact directly with the scope or target.

  • Property commands — Work with target and scope properties.

  • Variable commands — Alias target computer command-line interface commands with names of your choice.

Refer to Control Real-Time Application at Target Computer Command Line for a description of how to use these functions and commands.

To read the target computer console log, call SimulinkRealTime.utils.getConsoleLog.

Target Object Function Commands

When you are using the target computer command-line interface, target object functions are limited to starting and stopping the real-time application.

The following table lists the syntax for the target commands that you can use on the target computer. The equivalent MATLAB® syntax is shown in the right column. The target object name tg is used as an example for the MATLAB functions. These functions assume that you have already loaded the real-time application onto the target computer.

Target Computer Command

Description

MATLAB Equivalent

start

Start the real-time application currently loaded on the target computer.

start(tg)

stop

Stop the real-time application currently running on the target computer.

stop(tg)

reboot

Restart the target computer.

reboot(tg)

Target Object Property Commands

When you are using the target computer command-line interface, target object properties are limited to parameters, signals, stop time, and sample time.

The following table lists the syntax for the target commands that you can use to manipulate target object properties. The MATLAB equivalent syntax is shown in the right column, and the target object name tg is used as an example for the MATLAB functions.

To read signal and parameter and signal values, use signal and parameter names (for example, S1, P1). To both read and write parameter values, use parameter indexes (for example, 0, 1).

Target Computer Command

Description

MATLAB Equivalent

getpar param_index

Display the value of a block parameter using the parameter index.

getparam(tg, param_index)

setpar param_index = number

Change the value of a block parameter using the parameter index.

setparam(tg, param_index, number)

stoptime = number

stoptime = Inf

With the value number, run for the specified number of seconds.

With the value Inf, run the real-time application until you manually stop it or reset the target computer.

tg.StopTime = number

tg.StopTime = Inf

sampletime = number

Enter a new sample time.

tg.SampleTime = number

P#

Display the value of the block parameter with index #.

For example, P2 displays the value of block parameter 2.

getparam(tg, param_index)

S#

Display the value of the signal with index #.

For example, S2 displays the value of signal 2.

getsignal(tg, sig_index)

Scope and Video Object Function Commands

When using the target computer command-line interface, you use scope object functions to start a scope and add signal traces. You can also collapse scopes and video displays into icons and expand them again. The functions addscope and remscope are target object functions that also run on the development computer.

The following table lists the syntax for the target commands that you can use on the target computer. The MATLAB equivalent syntax is shown in the right column. The target object name tg and the scope object name sc are used as an example for the MATLAB functions.

To add and remove scopes, use scope numbers (for example, 0, 1) and not scope names (for example, Scope 1, Scope 2). To add and remove signals from scopes, use signal indexes (for example, 0, 1) and not signal names (for example, S0, S1).

Target Computer Command

Description

MATLAB Equivalent

addscope

addscope scope_index

Without an argument, add a target scope and assign it the next available index.

With argument scope_index, add a target scope and assign it index scope_index.

addscope(tg, 'target')

addscope(tg, 'target', scope_index)

remscope scope_index

remscope all

With value scope_index, remove scope scope_index.

With value all, remove all scopes.

remscope(tg, scope_index)

remscope(tg)

startscope scope_index

startscope all

With value scope_index, start the scope with index scope_index.

With value all, start all scopes.

start(sc)

start(getscope(tg))

stopscope scope_index

stopscope all

With value scope_index, stop the scope with index scope_index.

With value all, stop all scopes.

stop(sc)

stop(getscope(tg))

addsignal scope_index = sig_index1, sig_index2, ...

With values sig_index1, sig_index2, ..., add the signals with these signal indexes to the scope with index scope_index.

addsignal(sc, sig_index_vector)

remsignal scope_index = sig_index1, sig_index2, ...

remsignal scope_index

With values sig_index1, sig_index2, ..., remove the signals with these signal indexes from the scope with index scope_index.

Without a sig_index value, remove all the signals from the scope with index scope_index.

remsignal(sc, sig_index_vector)

remsignal(sc)

show Scope scope_index

With value scope_index, expand scope scope_index from an icon.

 

hide Scope scope_index

With value scope_index, collapse scope scope_index into an icon.

 

show Video video_index

With value video_index, expand video display video_index from an icon.

 

hide Video video_index

With value video_index, collapse video display video_index into an icon.

 

Scope Object Property Commands

When you use the target computer command-line interface, scope object properties are limited to the properties shown in the following table.

The following table lists the syntax for the target properties that you can set on the target computer. The equivalent MATLAB syntax is shown in the right column. The scope object name sc is used as an example for the MATLAB functions.

To change scope properties, use scope indexes (for example, 0, 1) and not scope names (for example, Scope 1, Scope 2).

If a scope is running, stop the scope before you change a scope property.

Target Computer Command

Description

MATLAB Equivalent

numsamples scope_index = number

Set the number of contiguous samples captured by scope scope_index to number.

sc.NumSamples = number

decimation scope_index = 1

decimation scope_index = number

With value 1, the scope returns all sample points.

With value n, the scope returns every nth sample point.

sc.Decimation = 1

sc.Decimation = number

grid scope_index on

grid scope_index off

With value on, the scope grid display is visible.

With value off, the scope grid display is not visible.

sc.Grid = 'on'

sc.Grid = 'off'

scopemode scope_index = 0

scopemode scope_index = numerical

scopemode scope_index = 1

scopemode scope_index = redraw

scopemode scope_index = 3

scopemode scope_index = rolling

With value 0 or numerical, scope scope_index displays signal values as text.

With value 1 or redraw, scope scope_index plots signal values when numsamples samples have been acquired.

With value 3 or rolling, scope scope_index plots signal values at every sample time.

Value 2, sliding, will be removed in a future release. It behaves like value 3, rolling.

sc.DisplayMode = 'numerical'

sc.DisplayMode = 'redraw'

sc.DisplayMode = 'rolling'

triggermode scope_index = 0

triggermode scope_index = freerun

triggermode scope_index = 1

triggermode scope_index = software

triggermode scope_index = 2

triggermode scope_index = signal

triggermode scope_index = 3

triggermode scope_index = scope

With value 0 or freerun, scope scope_index triggers on every sample time.

With value 1 or software, scope scope_index triggers from Command Window.

With value 2 or signal, scope scope_index triggers when a designated signal changes state.

With value 3 or scope, scope scope_index triggers when a designated scope triggers.

sc.TriggerMode = 'freerun'

sc.TriggerMode = 'software'

sc.TriggerMode = 'signal'

sc.TriggerMode = 'scope'

numprepostsamples scope_index = number

Number of samples collected before or after a trigger event.

sc.NumPrePostSamples = number

triggersignal scope_index = sig_index

If triggermode is signal, triggersignal identifies the block output signal to use for triggering the scope.

sc.TriggerSignal = sig_index

triggersample scope_index = number

If triggermode is scope, triggersample specifies which sample of the triggering scope the current scope triggers on.

sc.TriggerSample = number

triggerlevel scope_index = number

If triggermode is signal, triggerlevel indicates the value the signal has to cross to trigger the scope to start acquiring data.

sc.TriggerLevel = number

triggerslope scope_index = 0

triggerslope scope_index = either

triggerslope scope_index = 1

triggerslope scope_index = rising

triggerslope scope_index = 2

triggerslope scope_index = falling

If triggermode is signal:

With value 0 or either, the signal triggers the scope when it crosses triggerlevel in either the rising or falling directions.

With value 1 or rising, the signal triggers the scope when it crosses triggerlevel in the rising direction.

With value 2 or falling, the signal triggers the scope when it crosses triggerlevel in the falling direction.

sc.TriggerSlope = 'Either'

sc.TriggerSlope = 'Rising'

sc.TriggerSlope = 'Falling'

triggerscope scope_index = scope_index2

If triggermode is scope, triggerscope identifies the scope to use for a trigger.

sc.TriggerScope = scope_index2

triggerscopesample scope_index= integer

If triggermode is scope, triggerscopesample specifies which sample of the triggering scope to trigger on.

sc.TriggerScopeSample = integer

ylimit scope_index = min_y, max_y

ylimit scope_index = auto

With value min_y, max_y, change the lower and upper y-axis values to min_y and max_y.

With value auto, the values being displayed determine the lower and upper y-axis values.

sc.YLimit = [min_y, max_y]

sc.YLimit = 'auto'

Aliasing with Variable Commands

You can set a variable to a command character vector, and later use that variable to execute that command. For example, type the following on the target computer command line:

setvar aa = startscope 2
setvar bb = stopscope 2

Later, to start and stop scope 2, you can type the following:

aa
bb

The following table lists the syntax for the aliasing variable commands that you can use only on the target computer. There is no MATLAB equivalent syntax. For a usage example, see Alias Commands at Target Computer Command Line.

Target Computer Command

Description

setvar variable_name = command

Set a variable to a target computer command-line character vector.

getvar variable_name

Display the value of a variable.

delvar variable_name

Delete a variable.

delallvar

Delete all variables.

showvar

Display a list of variables.

See Also

Was this topic helpful?