Modbus

class ModbusClient
Canonical

kortex_api.autogen.client_stubs.ModbusClientRpc

__init__(router, namespace=None)

Constructs a ModbusClient with an initialized RouterClient and an optional namespace.

Parameters
  • router (RouterClient) – RouterClient used for the communication

  • namespace (string) – Optional namespace on which to initialize the ModbusClient (defaults to None)

IsAlive(timeoutMs: int = 1000)

Returns True if the Service Server is detected online before timeoutMs is expired, False otherwise.

Parameters

timeoutMs (unsigned int) – The maximum time to wait for an answer from the server

Return type

bool

ReadCoils(readrequest, deviceId=0, options=RouterClientSendOptions())
The READ_ONLY permission is necessary to call this RPC.

MODBUS function code 1.
A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.

Parameters
Return type

ReadCoilResponse

ReadDiscreteInputs(readrequest, deviceId=0, options=RouterClientSendOptions())
The READ_ONLY permission is necessary to call this RPC.

MODBUS function code 2
A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.

Parameters
Return type

ReadCoilResponse

ReadHoldingRegisters(readrequest, deviceId=0, options=RouterClientSendOptions())
The READ_ONLY permission is necessary to call this RPC.

MODBUS function code 3
A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.

Parameters
Return type

ReadRegisterResponse

ReadInputRegisters(readrequest, deviceId=0, options=RouterClientSendOptions())
The READ_ONLY permission is necessary to call this RPC.

MODBUS function code 4
A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.

Parameters
Return type

ReadRegisterResponse

WriteSingleCoil(singlecoilwriterequest, deviceId=0, options=RouterClientSendOptions())
The CONFIGURE permission is necessary to call this RPC.

MODBUS function code 5
A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.

Parameters
WriteSingleHoldRegister(singleregisterwriterequest, deviceId=0, options=RouterClientSendOptions())
The CONFIGURE permission is necessary to call this RPC.

MODBUS function code 6
A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.

Parameters
WriteMultipleCoils(multiplecoilswriterequest, deviceId=0, options=RouterClientSendOptions())
The CONFIGURE permission is necessary to call this RPC.

MODBUS function code 15
A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.

Parameters
WriteMultipleHoldRegisters(multipleregisterswriterequest, deviceId=0, options=RouterClientSendOptions())
The CONFIGURE permission is necessary to call this RPC.

MODBUS function code 16
A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.

Parameters
InitConnection(connectionparameters, deviceId=0, options=RouterClientSendOptions())
The CONFIGURE permission is necessary to call this RPC.

Initialize a connection with a MODBUS server (slave). Returns a device handle for the created connection.
To connect with the Wrist, the ip_address should be “10.10.0.16” and the port should be 502.
An INVALID_DEVICE error will be thrown if the device ID is invalid or if the connection to the given device ID fails to be established.

Parameters
Return type

DeviceHandle

SetTargetSlave(devicehandle, deviceId=0, options=RouterClientSendOptions())
The CONFIGURE permission is necessary to call this RPC.

Sets the slave target. It will receive the next MODBUS commands.
The device_identifier field shall be filled with a valid slave ID.
An INVALID_DEVICE error will be thrown if the slave ID is invalid.

Parameters
CloseConnection(devicehandle, deviceId=0, options=RouterClientSendOptions())
The CONFIGURE permission is necessary to call this RPC.

Close the currently active connection with a MODBUS server (slave).
The input parameter is unused.

Parameters