> For the complete documentation index, see [llms.txt](https://support.powerio.com/hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.powerio.com/hub/codesys-hvac/en/hvac-modbus-library/functionblocks/generic/modbusclient_tcp.md).

# ModbusClient\_TCP

## `ModbusClient_TCP` (FB)

`FUNCTION_BLOCK` ModbusClient\_TCP EXTENDS ModbusClientBase

### **Representation**

<figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2F72CenA7gPXPeRZfCt1jc%2FModbusClient_TCP.png?alt=media&amp;token=810edf05-4d03-4a53-9962-b9727aa16d34" alt=""><figcaption></figcaption></figure>

### Functional description

This function block provides the client functionalities in a Modbus TCP communication. The remote station must provide the server functionalities. Ideally (= complete reception of the Modbus response telegram within one task cycle time), a new transmission is started cyclically after T = 5 \* task cycle time (T = 50 ms with a task cycle time of 10 ms). For Modbus telegrams with a lot of data and/or low transmission rates on the serial side (`RS` 485) can this duration increase accordingly.

InOut:

| Scope       | Name                    | Type                             | Initial                                    | Comment                                                                                                                                                      | Inherited from   |
| ----------- | ----------------------- | -------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------- |
| Output      | `xConnected`            | `BOOL`                           |                                            | TRUE if connection has been established                                                                                                                      | ModbusClientBase |
| Output      | `xLicenceValid`         | `BOOL`                           |                                            | TRUE if a valid licence was found                                                                                                                            | ModbusClientBase |
| Input       | `xEn`                   | `BOOL`                           | TRUE                                       | Input to enable / disable the function block                                                                                                                 |                  |
| Input       | `sHostAddress`          | `STRING`                         | ‘’                                         | <p>Hostname (FQDN, e.g. <code>[www.focus.de](http://www.focus.de)</code>) or IP address of the<br>Server (e.g. <code>192.168.178.210</code>)(Modbus-TCP)</p> |                  |
| Input       | `wPort`                 | `WORD`                           | 502                                        | <p>Port number of the Server (Modbus-TCP)(502 is the default<br>port)</p>                                                                                    |                  |
| Input       | `xResetLastErrors`      | `BOOL`                           | FALSE                                      | Input to reset the error outputs (rising edge)                                                                                                               |                  |
| Output      | `byLastRequestUnitID`   | `BYTE`                           | 0                                          | Last Request telegram: Unit ID (0 = No Unit)                                                                                                                 |                  |
| Output      | `eState`                | Client\_TCP\_StateCode           | Client\_TCP\_StateCode.IDLE                | Current state of the state machine as `ENUM`                                                                                                                 |                  |
| Output      | `eResponseState`        | Client\_TCP\_Response\_StateCode | Client\_TCP\_Response\_StateCode.NO\_ERROR | Last Response telegram: Description of the state as `ENUM`                                                                                                   |                  |
| Output      | `byLastErrorUnitID`     | `BYTE`                           | 0                                          | Last error: Unit ID (0 = No Unit)                                                                                                                            |                  |
| Output      | `xError`                | `BOOL`                           | FALSE                                      | Current Error State (FALSE = No Error, TRUE = Error)                                                                                                         |                  |
| Output      | `eLastErrorCode`        | Client\_TCP\_ErrorCode           | Client\_TCP\_ErrorCode.NO\_ERROR           | Last Error: Description of the communication error as `ENUM`                                                                                                 |                  |
| Output      | `xReady`                | `BOOL`                           | FALSE                                      | <p>Current Standby state (FALSE = Not ready, TRUE = Ready to<br>send / receive Modbus data)</p>                                                              |                  |
| Input Const | `tKeepAliveTimeout`     | `TIME`                           | TIME#1m20s0ms                              | Time between the last package sent and the first probe (Idle-Mode)                                                                                           |                  |
| Input Const | `tTimeoutDeviceReceive` | `TIME`                           | TIME#2s0ms                                 | Timeout for the Device communication (Read)                                                                                                                  |                  |
| Input Const | `tTimeoutDeviceSend`    | `TIME`                           | TIME#2s0ms                                 | Timeout for the Device communication (Send)                                                                                                                  |                  |
| Input Const | `tTimeoutConnect`       | `TIME`                           | TIME#3s0ms                                 | <p>Timeout for the Client-Server communication (Resolve = name<br>resolution & Connection time)</p>                                                          |                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://support.powerio.com/hub/codesys-hvac/en/hvac-modbus-library/functionblocks/generic/modbusclient_tcp.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
