Main Content

Targets

Configure and manage target objects

Description

A Targets object represents target computers that are defined on the development computer and provides access to methods related to the target computers.

Creation

targets_object = slrealtime.Targets() constructs a Targets object representing target computers that are connected to the development computer.

Example: Create Targets Object, Add Target Computers, Set IP Address

Object Functions

addTargetAdd target computer definition to targets object
removeTargetRemove target computer definition from targets object
getTargetSettingsGet target computer environment settings
getDefaultTargetNameGet default target computer name
setDefaultTargetNameSet default target computer name

Examples

collapse all

To work with multiple target computers, make the computer names available by using a targets object.

Create targets object my_tgs. Add target computers to the targets object. Assign target computers to target objects. Create a target settings object and list the target computer names.

my_tgs = slrealtime.Targets();
% do not need to add default target 'TargetPC1'
addTarget(my_tgs,'TargetPC2');
addTarget(my_tgs,'TargetPC3');

% assign target computers to target objects
tg1 = slrealtime('TargetPC1');
tg2 = slrealtime('TargetPC2');
tg3 = slrealtime('TargetPC3');

% list target computer names
my_tgs_settings = getTargetSettings(my_tgs);
my_tgs_settings.name
ans =

    'TargetPC1'


ans =

    'TargetPC2'

Set Target object tg1 IP address to '192.168.7.5' by using the TargetSettings property.

tg1.TargetSettings.address = '192.168.7.5';
tg1.TargetSettings;

To set the IP address on the target computer, use the setipaddr function.

For security, some installations require changing the default userPassword for the target computer. To customize the password, change both:

— The userPassword in the TargetSettings

— The password for the slrt user on the corresponding target computer

Create targets object my_tgs. Add target computers to the targets object. Assign target computers to target objects. Create a target settings object and list the target computer names.

my_tgs = slrealtime.Targets();
% do not need to add default target 'TargetPC1'
addTarget(my_tgs,'TargetPC2');
addTarget(my_tgs,'TargetPC3');

% assign target computers to target objects
tg1 = slrealtime('TargetPC1');
tg2 = slrealtime('TargetPC2');
tg3 = slrealtime('TargetPC3');

% list target computer names
my_tgs_settings = getTargetSettings(my_tgs);
my_tgs_settings.name
ans =

    'TargetPC1'


ans =

    'TargetPC2'

Set Target object tg1 userPassword to 'H3lloThere!' by using the TargetSettings property.

tg1.TargetSettings.userPassword = 'H3lloThere!';
tg1.TargetSettings;

To set the password on the target computer, open a PuTTY session to the target computer (log in as user root and password root) and use the passwd command to set the password for the slrt. For more information about using PuTTY, see Execute Target Computer RTOS Commands at Target Computer Command Line.

Image of password command in PuTTY session

Introduced in R2020b