# MasterUDP

## `MasterUDP` (FB)

FUNCTION\_BLOCK MasterUDP IMPLEMENTS IKnxConnector

#### Overview

The MasterUDP function block serves as a KNX driver for communication with a KNX Net/IP gateway. It processes telegrams and coordinates communication with slave function blocks.

#### Inputs

| Inputs                   | Initial value                      | Description                         |
| ------------------------ | ---------------------------------- | ----------------------------------- |
| `xEnable`                | *TRUE*                             | Enable/disable the function block   |
| `sIPAddressKNXInterface` | *''*                               | IP address of the KNX interface     |
| `uiPortKNXInterface`     | *gc\_LibPara.gc\_uiPort*           | Port number of the KNX interface    |
| `itfNetworkInterface`    | -                                  | Network interface for communication |
| `uiPortPLC`              | *gc\_LibPara.gc\_uiPortLocal*      | Port number of the PLC              |
| `xResError`              | *FALSE*                            | Error reset flag                    |
| `tResponseTimeout`       | *gc\_LibPara.gc\_tResponseTimeout* | Timeout duration for requests       |

#### Outputs

* `xConnected` (BOOL): Connection status
* `itfKnxConnector` (IKnxConnector): Interface for slave blocks
* `udiConnectedSlaves` (UDINT): Number of connected modules
* `eStatus` (KnxStatus): Current KNX connection status
* `stDeviceInfo` (DeviceInfo): Device information
* `stKnxData` (KnxData): KNX data structure
* `bChannel` (BYTE): Communication channel identifier
* `eError` (ErrorKnx): Current error status
* `eLastError` (ErrorKnx): Last error

#### Usage

1. Configure the KNX interface with `sIPAddressKNXInterface` and `uiPortKNXInterface`.
2. Set `uiPortPLC` according to your PLC configuration.
3. Enable the block with `xEnable = TRUE`.
4. Monitor `xConnected` for the connection status.
5. Use `itfKnxConnector` to interact with slave function blocks.
6. Check `eStatus` and `eError` regularly.
7. Use `xResError` to reset error states.

#### Notes

* Ensure correct network settings (`itfNetworkInterface`) are set.
* Adjust `tResponseTimeout` adjust for network latency if needed.

InOut:

| Scope       | Name                     | Type                               | Initial                          | Comment                      |
| ----------- | ------------------------ | ---------------------------------- | -------------------------------- | ---------------------------- |
| Input       | `xEnable`                | `BOOL`                             | TRUE                             | On/Off                       |
| Input       | `sIPAddressKNXInterface` | `STRING`                           | ‘’                               | IP of the peer e.g. IP/Knx   |
| Input       | `uiPortKNXInterface`     | `UINT`                             | gc\_LibPara.gc\_uiPort           | Port of the peer e.g. KNX GW |
| Input       | `itfNetworkInterface`    | `IIoDrvEthernet.INetworkInterface` |                                  |                              |
| Input       | `uiPortPLC`              | `UINT`                             | gc\_LibPara.gc\_uiPortLocal      | Port of the controller       |
| Input       | `xResError`              | `BOOL`                             | FALSE                            | Error reset                  |
| Input Const | `tResponseTimeout`       | `TIME`                             | gc\_LibPara.gc\_tResponseTimeout | Timeout time for request     |
| Output      | `xConnected`             | `BOOL`                             |                                  |                              |
| Output      | `itfKnxConnector`        | `IKnxConnector`                    | THIS^                            | IF for comm. module FBs      |
| Output      | `udiConnectedSlaves`     | `UDINT`                            |                                  | Number of modules            |
| Output      | `eStatus`                | `KnxStatus`                        |                                  |                              |
| Output      | `stDeviceInfo`           | DeviceInfo                         |                                  |                              |
| Output      | `stKnxData`              | `KnxData`                          |                                  |                              |
| Output      | `bChannel`               | `BYTE`                             |                                  |                              |
| Output      | `eError`                 | ErrorKnx                           |                                  |                              |
| Output      | `eLastError`             | ErrorKnx                           |                                  |                              |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.powerio.com/hub/codesys-hvac/en/hvac-knx-library/functionblocks/masterudp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
