# Read Data

The Read Data block reads the data of the remote Modbus Server device to which the selected Modbus Client device is connected.

By default, the block has two input pins and one output pin:

Input Pin Name | Type | Description
StartingAddress | int32 | The 0-based address of the first IO unit to read.
Count | int32 | The number of IO units to read.
Output Pin Name | Type | Description
Values | bool[] / short[] / byte[] (depending on the Data Format). | The result data read from the remote Modbus Server device.

Note: You can also configure the StartingAddress and Count input values as block properties instead of input pins by right-clicking on the block and selecting the Configure I/O option from the context menu. Note that the Read Data block does not handle double-clicking and has no Edit context menu item.

The Read Data block has the following properties:

Property | Type | Description
Selected Device | IModbusClient | The name of the associated Modbus Client device.
IO Type | ModbusIOType | The type of the IO units to read.
Data Format | ModbusDataFormatType | The data format of the data to read (short array, byte array or Boolean array).

This block is executed successfully if the following conditions are met:

- The sum of the StartingAddress and Count values are less than or equal to 65535.
- The value of Count is larger than 0.
- The Selected Device property is configured.
- The IO Type and Data Format properties are configured in one of the below combinations:
  - The IO Type property is set to 16-bit size IO while the Data Format property is set to Short array or Byte array.
  - The IO Type property is set to 1-bit size IO while the Data Format property is set to Boolean array.
- The IO Type property and the Count input value are present in one of the below combinations:
  - The IO Type property is set to 16-bit size IO while the value of the Count input is less than or equal to 2000.
  - The IO Type property is set to 1-bit size IO while the value of the Count input is less than or equal to 125.
- The Modbus Server device responds in time and no network-related errors occur.

If any of the above conditions is not met, the Read Data block generates one of the below exceptions, depending on the type of the error:

Exception | Error
ArgumentOutOfRangeException | The StartingAddress and/or the Count inputs are configured incorrectly.
InvalidOperationException | The SelectedDevice property is not set. The IO Type and Data Format properties are configured inconsistently (see the above list for the allowed combinations). A server timeout or other network-related error occured.