Main Content

TCP/IP Receive

Receive data over TCP/IP network from remote host

Since R2020b

Add-On Required: This feature requires the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms add-on.

  • NVIDIA TCP/IP Receive block

Libraries:
NVIDIA Jetson and NVIDIA DRIVE / Network

Description

Receive data from a remote host/another target hardware over a network. When you set the connection mode as server, you must provide the local port. The local port acts as the listening port of the TCP/IP server. When you set the block as a client, you must provide the remote address and the remote port of the TCP/IP server to receive data. The block accepts data either in blocking mode or in non-blocking mode. The Data port output contains the requested data at each time step. The Status port contains 0 or 1 to indicate whether the new data at the specified time step is received. The Status port value 1 indicates that the data from Data port is valid.

In blocking mode, the model blocks the execution while it waits for the requested data to be available.

blocking mode

At time step 1, the block requests four data values, and the TCP/IP receive buffer gets four data values. The execution runs.

At time step 2, the block requests for data again, but the TCP/IP receive buffer gets only three data values. The execution pauses until the buffer receives the fourth data value or the time-out value elapses. Then, the execution resumes.

At time step 3, the block requests for data, and the buffer receives five data values. The block returns the first four data values, and the remaining data value is used in the next receipt cycle.

In non-blocking mode, the model runs continuously.

non blocking mode

At time step 1, the block requests data, and the buffer gets four data values. The block changes the Status port value to 0, indicating that new requested data is available. The Data port, at this point, contains the newly received data values. The block resets the Data port value to 0.

At time step 2, the block requests data again, but the buffer gets only three values. The block cannot return a value of 3 because the data size is specified as 4. Therefore, the block sets the Status port value to 1, indicating that there is no new data. All values on the Data port become 0. The buffer, at this point, has three data values. However, during this phase, the execution does not stop unlike in the blocking mode.

At time step 3, the buffer has five data values, and the block returns the first four data values in the order received and changes the Status port value to 0. The remaining data value is used in the next receipt cycle.

Ports

Output

expand all

The block outputs data as an [Nx1] array.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

This port shows the data received status. The status value 1 means successful receipt of data.

Data Types: int8

Parameters

expand all

Main Tab

Select the option to connect the block as TCP/IP server or TCP/IP client.

Programmatic Use

Block Parameter: Mode_
Type: character vector
Values: 'Server'|'Client'
Default: 'Server'

Enter the local port number which acts as the listening port of the TCP/IP server. This parameter appears only when you set the Connection mode to Server

Programmatic Use

Block Parameter: LocalServerPort_
Type: character vector
Values: '25000'|scalar
Default: '25000'

Enter the remote server address from which to receive the data. This parameter appears only when you set the Connection mode to Client.

Programmatic Use

Block Parameter: RemoteAddr_
Type: character vector
Values: '127.0.0.1'|scalar
Default: '127.0.0.1'

Enter the remote server port. This parameter appears only when you set the Connection mode to Client.

Programmatic Use

Block Parameter: RemoteServerPort_
Type: character vector
Values: '25000'|scalar
Default: '25000'

Select the data type that is to be received from the remote host.

Programmatic Use

Block Parameter: DataType_
Type: character vector
Values: 'uint8'|'uint16''uint32''double''single''int8''int16''int32''boolean'
Default: 'uint8'

Enter the data size to be received from the remote host.

Programmatic Use

Block Parameter: DataSize_
Type: character vector
Values: '1'|scalar
Default: '1'

Enter the time frequency at which to receive data.

Programmatic Use

Block Parameter: SampleTime_
Type: character vector
Values: scalar | vector
Default: '0.1'
Advanced Tab

Allow manual specification of local IP port at which to receive data. This parameter appears only when you set the Connection mode to Client.

Programmatic Use

Block Parameter: ClientPortBindingSelection_
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Enter the local port of the client to receive data. This parameter appears only when you set the Connection mode to Client and select the check box Manually specify local IP port.

Programmatic Use

Block Parameter: ClientPortToBind_
Type: character vector
Values: '35000'|scalar
Default: '35000'

Select this option to specify if the block waits for the data to be received. Selecting this check box enables the blocking mode.

Programmatic Use

Block Parameter: BlockingMode_
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Specify the time the block waits for the data to be received during each simulation time step. This field is unavailable, if you have not selected Wait until data received parameter. Enter ‘inf’ value in this parameter, if you want the block to wait indefinitely until it receives the data.

Programmatic Use

Block Parameter: BlockTimeout_
Type: character vector
Values: '0.1'|scalar
Default: '0.1'

Version History

Introduced in R2020b