Class: ModbusClient

ModbusClient

Provides methods and properties for using Modbus as a client

Members


<readonly> connected :bool

Returns true when successfully connected.

Type:
  • bool
Since:
  • 0.1 (WAT 2.4)

Methods


close()

Close the connection to Modbus.

Since:
  • 0.1 (WAT 2.4)
Example
client.close();

createDevice(serverAddress)

Creates an object for accessing a Modbus device at a specific Modbus server address (1 to 247).

Parameters:
Name Type Description
serverAddress int

Modbus server address (1 to 247)

Since:
  • 0.1 (WAT 2.4)
Returns:
Type
modbus.ModbusDevice
Example
var address = 1;
var device = client.createDevice(address);

open()

Attempts to open a connection to Modbus.

Since:
  • 0.1 (WAT 2.4)
Returns:

Indicates if the open was successfully started.

Type
bool
Example
client.open();

reset()

Resets properties to the default value. Useful for resetting to a known state when re-configuring.

Since:
  • 0.1 (WAT 2.4)
Example
client.reset();

Events


closed

Emitted when the connection to Modbus has been closed.

Since:
  • 0.1 (WAT 2.4)

connectedChanged

Emitted when the connected state of the Modbus client changes. See connected for more details.

Parameters:
Name Type Description
connected bool

Whether the client is currently connected to Modbus

Since:
  • 0.1 (WAT 2.4)

error

Emitted when the connection to Modbus detects an error condition.

Parameters:
Name Type Description
err string

Description of the error

Since:
  • 0.1 (WAT 2.4)

opened

Emitted when a connection to Modbus has been established.

Since:
  • 0.1 (WAT 2.4)