pymodbus.client package¶
Subpackages¶
- pymodbus.client.asynchronous package
- Async Modbus Client implementation based on Twisted, tornado and asyncio
- Subpackages
- Submodules
- pymodbus.client.asynchronous.serial module
- pymodbus.client.asynchronous.tcp module
- pymodbus.client.asynchronous.thread module
- pymodbus.client.asynchronous.udp module
Submodules¶
pymodbus.client.common module¶
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¶ Bases:
objectThis 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)
-
last_frame_end= 0¶
-
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
-
silent_interval= 0¶
-
state= 0¶
-
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
-
pymodbus.client.sync module¶
-
class
pymodbus.client.sync.ModbusTcpClient(host='127.0.0.1', port=502, framer=<class 'pymodbus.framer.socket_framer.ModbusSocketFramer'>, **kwargs)¶ Bases:
pymodbus.client.sync.BaseModbusClientImplementation of a modbus tcp client
-
close()¶ Closes the underlying socket connection
-
connect()¶ Connect to the modbus tcp server
Returns: True if connection succeeded, False otherwise
-
is_socket_open()¶ Check whether the underlying socket/serial is open or not.
Returns: True if socket/serial is open, False otherwise
-
-
class
pymodbus.client.sync.ModbusUdpClient(host='127.0.0.1', port=502, framer=<class 'pymodbus.framer.socket_framer.ModbusSocketFramer'>, **kwargs)¶ Bases:
pymodbus.client.sync.BaseModbusClientImplementation of a modbus udp client
-
close()¶ Closes the underlying socket connection
-
connect()¶ Connect to the modbus tcp server
Returns: True if connection succeeded, False otherwise
-
is_socket_open()¶ Check whether the underlying socket/serial is open or not.
Returns: True if socket/serial is open, False otherwise
-
-
class
pymodbus.client.sync.ModbusSerialClient(method='ascii', **kwargs)¶ Bases:
pymodbus.client.sync.BaseModbusClientImplementation of a modbus serial client
-
close()¶ Closes the underlying socket connection
-
connect()¶ Connect to the modbus serial server
Returns: True if connection succeeded, False otherwise
-
inter_char_timeout= 0¶
-
is_socket_open()¶ Check whether the underlying socket/serial is open or not.
Returns: True if socket/serial is open, False otherwise
-
silent_interval= 0¶
-
state= 0¶
-