client.common — Twisted Async Modbus Client

API Documentation

Modbus Client Common

This is a common client mixin that can be used by both the synchronous and asynchronous clients to simplify the interface.

class pymodbus.client.common.ModbusClientMixin

This is a modbus client mixin that provides additional factory methods for all the current modbus methods. This can be used instead of the normal pattern of:

# instead of this
client = ModbusClient(...)
request = ReadCoilsRequest(1,10)
response = client.execute(request)

# now like this
client = ModbusClient(...)
response = client.read_coils(1, 10)
mask_write_register(*args, **kwargs)
Parameters:
  • address – The address of the register to write
  • and_mask – The and bitmask to apply to the register address
  • or_mask – The or bitmask to apply to the register address
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle

read_coils(address, count=1, **kwargs)
Parameters:
  • address – The starting address to read from
  • count – The number of coils to read
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle

read_discrete_inputs(address, count=1, **kwargs)
Parameters:
  • address – The starting address to read from
  • count – The number of discretes to read
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle

read_holding_registers(address, count=1, **kwargs)
Parameters:
  • address – The starting address to read from
  • count – The number of registers to read
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle

read_input_registers(address, count=1, **kwargs)
Parameters:
  • address – The starting address to read from
  • count – The number of registers to read
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle

readwrite_registers(*args, **kwargs)
Parameters:
  • read_address – The address to start reading from
  • read_count – The number of registers to read from address
  • write_address – The address to start writing to
  • write_registers – The registers to write to the specified address
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle

write_coil(address, value, **kwargs)
Parameters:
  • address – The starting address to write to
  • value – The value to write to the specified address
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle

write_coils(address, values, **kwargs)
Parameters:
  • address – The starting address to write to
  • values – The values to write to the specified address
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle

write_register(address, value, **kwargs)
Parameters:
  • address – The starting address to write to
  • value – The value to write to the specified address
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle

write_registers(address, values, **kwargs)
Parameters:
  • address – The starting address to write to
  • values – The values to write to the specified address
  • unit – The slave unit this request is targeting
Returns:

A deferred response handle