Main Content

target.TargetConnection Class

Namespace: target

Provide details about connecting MATLAB computer to target hardware

Since R2020b

Description

Use the target.TargetConnection class, which inherits functionality from target.Connection, to provide details about connecting your MATLAB® computer to target hardware. For example, the communication channel and connection properties that are required for communication with your target hardware.

To create a target.TargetConnection object, use the target.create function. Create the object and then use separate steps to specify properties. Or, using name-value arguments, create the object and specify properties in a single step.

Properties

expand all

Name of connection object.

Attributes:

GetAccess
public
SetAccess
public

Associate a target.CommunicationChannel object with your connection, which describes the type of channel that is used. For example, to specify serial or TCP channel properties, use target.RS232Channel or target.TCPChannel respectively.

If you use name-value arguments to create a target.TargetConnection object, for the CommunicationChannel property, specify these arguments.

NameDescription
'CommunicationType'

Required. Type of predefined communication channel. Specifies one of these values:

  • 'RS232Channel'

  • 'TCPChannel'

  • 'UDPChannel'

'IPAddress'

Optional. If predefined communication channel is 'TCPChannel' or 'UDPChannel', specifies IPAddress property of target.TCPChannel or target.UDPChannel object.

'Port'

Optional. If predefined communication channel is 'TCPChannel' or 'UDPChannel', specifies Port property of target.TCPChannel or target.UDPChannel object.

'BaudRate'

Optional. If predefined communication channel is 'RS232Channel', specifies BaudRate property of target.RS232Channel object.

'Parity'

Optional. If predefined communication channel is 'RS232Channel', specifies Parity property of target.RS232Channel object.

Attributes:

GetAccess
public
SetAccess
public

Associate a target.Board object with your connection, which describes the target hardware that is connected to the MATLAB computer.

Attributes:

GetAccess
public
SetAccess
public

Associate a target.ConnectionProperties object with your connection that describes the MATLAB computer connection properties that are used to connect to the target hardware. For example, to specify the serial port, use a target.Port object.

If you use name-value arguments to create a target.TargetConnection object and the predefined communication channel type is 'RS232Channel', specifying the argument 'Port' sets the ConnectionProperties property to target.Port.

Attributes:

GetAccess
public
SetAccess
public

Associate a target.ConnectionProperties object with your connection that describes the target hardware connection properties that are used to connect to the MATLAB computer. For example, to specify the serial port, use a target.Port object.

If you use name-value arguments to create a target.TargetConnection object and the predefined communication channel type is 'RS232Channel', specifying the argument 'Port' sets the TargetConnectionProperties property to target.Port.

Attributes:

GetAccess
public
SetAccess
public

Examples

collapse all

This code from Set Up PIL Connectivity by Using Target Framework (Embedded Coder) shows how to specify the connection between your development computer and target hardware. In the example, the target application runs on your development computer as a separate process and uses a TCP communication channel through localhost.

connection = target.create('TargetConnection');
connection.Name = 'Host Process Connection';
connection.Target = hostTarget;
connection.CommunicationChannel = target.create('TCPChannel');
connection.CommunicationChannel.Name = ...
                   'External Process TCPCommunicationChannel';
connection.CommunicationChannel.IPAddress = 'localhost';
connection.CommunicationChannel.Port = '0';

Note

Using name-value arguments, you can create the connection object with this command:

connection = target.create('TargetConnection', ...
                      'Name', 'Host Process Connection', ...
                      'Target', hostTarget, ...
                      'CommunicationType', 'TCPChannel', ...
                      'IPAddress', 'localhost', ... 
                      'Port', '0')

Version History

Introduced in R2020b