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 communicationnamespace (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 beforetimeoutMs
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
readrequest (ReadRequest) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- Return type
- ReadDiscreteInputs(readrequest, deviceId=0, options=RouterClientSendOptions())¶
- The
READ_ONLY
permission is necessary to call this RPC.MODBUS function code 2A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.- Parameters
readrequest (ReadRequest) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- Return type
- ReadHoldingRegisters(readrequest, deviceId=0, options=RouterClientSendOptions())¶
- The
READ_ONLY
permission is necessary to call this RPC.MODBUS function code 3A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.- Parameters
readrequest (ReadRequest) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- Return type
- ReadInputRegisters(readrequest, deviceId=0, options=RouterClientSendOptions())¶
- The
READ_ONLY
permission is necessary to call this RPC.MODBUS function code 4A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.- Parameters
readrequest (ReadRequest) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- Return type
- WriteSingleCoil(singlecoilwriterequest, deviceId=0, options=RouterClientSendOptions())¶
- The
CONFIGURE
permission is necessary to call this RPC.MODBUS function code 5A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.- Parameters
singlecoilwriterequest (SingleCoilWriteRequest) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- WriteSingleHoldRegister(singleregisterwriterequest, deviceId=0, options=RouterClientSendOptions())¶
- The
CONFIGURE
permission is necessary to call this RPC.MODBUS function code 6A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.- Parameters
singleregisterwriterequest (SingleRegisterWriteRequest) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- WriteMultipleCoils(multiplecoilswriterequest, deviceId=0, options=RouterClientSendOptions())¶
- The
CONFIGURE
permission is necessary to call this RPC.MODBUS function code 15A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.- Parameters
multiplecoilswriterequest (MultipleCoilsWriteRequest) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- WriteMultipleHoldRegisters(multipleregisterswriterequest, deviceId=0, options=RouterClientSendOptions())¶
- The
CONFIGURE
permission is necessary to call this RPC.MODBUS function code 16A DEVICE_READY error will be thrown if no connection has been initialized with InitConnection.- Parameters
multipleregisterswriterequest (MultipleRegistersWriteRequest) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- 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
connectionparameters (ConnectionParameters) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- Return type
- 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
devicehandle (DeviceHandle) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message
- 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
devicehandle (DeviceHandle) –
deviceId (int) – Device’s Id called by rpc (optional)
options (RouterClientSendOptions) – Router options for sending the message