Main Content

WiFi TCP Receive

Receive TCP/IP packets from another TCP/IP host on internet network

Since R2021a

Add-On Required: This feature requires the Embedded Coder Support Package for STMicroelectronics STM32 Processors add-on.

  • WiFi TCP Receive block

Libraries:
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32L475VG-Discovery (B-L475E-IOT01A)

Description

The WiFi TCP Receive block receives data from a remote host or other hardware over a wireless network.

At each time step, the Data port outputs data as a vector of the size specified in the Data size (N) parameter. The Status port outputs 0 or a nonzero value indicating whether new data is received. 0 at the Status port indicates that a valid data is received.

Note

Your antivirus software or firewall might block TCP traffic. Configure the software to allow traffic from a specific IP port number.

Limitations

  • The sample time of the WiFi TCP Send and WiFi TCP Receive blocks should be more than 0.1 s, as the WiFi module on the board does not support sending data at a faster rate.

  • The maximum number of times a server can be started or restarted on the board is three. So:

    • The maximum number of blocks supported in the server mode is three.

    • When the model has a block in the server mode, and the client connected to that block/port gets disconnected for some reason, the server is restarted on the board for that block/port.

  • When you configure the block in the client mode, the remote server must be up and running before deploying the model that contains the WiFi TCP Send block to the target. If server is not running, there will be some fixed waiting time (while trying to connect to the server) at every execution. This might lead to overruns until the server is up again.

  • When using the WiFi TCP Send, WiFi TCP Receive, ThingSpeak Read, and ThingSpeak Write blocks in a model, the blocks must have the same sample time as the driver code is nonreentrant.

Ports

Output

expand all

At each time step, the port outputs data as a vector of the size specified in the Data size (N) parameter.

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

The port outputs 0 if the data is received at given time step. At other times the port outputs a nonzero value, indicating that no new data is available.

Dependencies

To enable this port, select the Output Status parameter.

Data Types: uint8

Parameters

expand all

Set the block as a TCP server or client.

When you set this parameter to Server, you must provide a Local IP port. The local port acts as the listening port on the TCP server.

When you set this parameter to Client, you must provide a Remote IP address and the Remote IP port on the TCP server from which you want to receive the data. Before you deploy a model that includes a client WiFi TCP Receive block, ensure that the server is up and running.

This local port number acts as a listening port on the TCP server. Match the local port number with the remote port number of the sending host.

Dependencies

To enable this parameter, set Connection mode parameter to Server.

Specify the IP address of the sending server from which the data is received.

Dependencies

To enable this parameter, set Connection mode parameter to Server.

Specify the port number of the sending server from which data is received.

Dependencies

To enable this parameter, set Connection mode parameter to Server.

Select the data type of the elements in the TCP data received by the block. The size of each element depends on its data type.

Specify the number of data bytes to receive at each time step.

Specify how often the block should read the port buffer. Enter a value greater than 0 or -1 (for inherited sample time).

This value defaults to a sample time of 0.5 seconds. Smaller values require the processor to complete the same number of instructions in less time and this can cause task overruns.

Specify the maximum amount of time that the block should wait for the data during each time step. If a timeout occurs, the read operation is aborted.

Note

When simulating a model in external mode, specify a value less than 3 seconds.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2021a