modbus_object.ReadDiscreteInputs Method

Reads one or more inputs from a MODBUS slave and returns the values in a Boolean array.

modbus_object.ReadDiscreteInputs(start, number, value_array)

Prerequisites

None

Parameters

start

A required Integer expression that specifies the number of the first input to be read.

number

A required Integer expression that defines the number of inputs to be read.

value_array

A required Boolean array that receives the input values. The length of the array is changed to reflect the number of values read.

Remarks

This method issues a MODBUS/TCP Read Discrete Inputs request (function 2).

A new connection to the MODBUS slave is made if none currently exists.

If any network errors occur, this method throws an exception.

Examples

Dim ep As New IPEndPoint("192.168.0.150")
Dim mb As New Modbus(ep)
Dim bool() As Boolean
mb.ReadDiscreteInputs(1, 16, bool) ' Read 16 inputs

See Also

Modbus Class |modbus_object.ReadInputRegisters