pymodbus.client.asynchronous.asyncio package¶
Asynchronous framework adapter for asyncio.
-
class
pymodbus.client.asynchronous.asyncio.
AsyncioModbusSerialClient
(port, protocol_class=None, framer=None, loop=None, baudrate=9600, bytesize=8, parity='N', stopbits=1)¶ Bases:
object
Client to connect to modbus device over serial.
-
connect
()¶ Connect Async client :return:
-
framer
= None¶
-
loop
= None¶ Event loop to use.
-
protocol
= None¶ Current protocol instance.
-
protocol_class
= None¶ Protocol used to talk to modbus device.
-
protocol_lost_connection
(protocol)¶ Protocol notification of lost connection.
-
protocol_made_connection
(protocol)¶ Protocol notification of successful connection.
-
stop
()¶ Stops connection :return:
-
transport
= None¶
-
-
class
pymodbus.client.asynchronous.asyncio.
AsyncioModbusTcpClient
(host=None, port=502, protocol_class=None, loop=None)¶ Bases:
object
Client to connect to modbus device over TCP/IP.
-
connect
()¶ Connect and start Async client :return:
-
loop
= None¶ Event loop to use.
-
protocol
= None¶ Current protocol instance.
-
protocol_class
= None¶ Protocol used to talk to modbus device.
-
protocol_lost_connection
(protocol)¶ Protocol notification of lost connection.
-
protocol_made_connection
(protocol)¶ Protocol notification of successful connection.
-
stop
()¶ Stops the client :return:
-
-
class
pymodbus.client.asynchronous.asyncio.
AsyncioModbusUdpClient
(host=None, port=502, protocol_class=None, loop=None)¶ Bases:
object
Client to connect to modbus device over UDP.
-
connect
()¶
-
loop
= None¶ Event loop to use.
-
protocol
= None¶ Current protocol instance.
-
protocol_class
= None¶ Protocol used to talk to modbus device.
-
protocol_lost_connection
(protocol)¶ Protocol notification of lost connection.
-
protocol_made_connection
(protocol)¶ Protocol notification of successful connection.
-
stop
()¶ Stops connection :return:
-
-
class
pymodbus.client.asynchronous.asyncio.
BaseModbusAsyncClientProtocol
(host='127.0.0.1', port=502, framer=None, source_address=None, timeout=None, **kwargs)¶ Bases:
pymodbus.client.asynchronous.mixins.AsyncModbusClientMixin
Asyncio specific implementation of asynchronous modbus client protocol.
-
close
()¶ Closes the underlying socket connection
-
connected
¶ Return connection status.
-
connection_lost
(reason)¶ Called when the connection is lost or closed.
The argument is either an exception object or None :param reason: :return:
-
connection_made
(transport)¶ Called when a connection is made.
The transport argument is the transport representing the connection. :param transport: :return:
-
create_future
()¶ Helper function to create asyncio Future object :return:
-
data_received
(data)¶ Called when some data is received. data is a non-empty bytes object containing the incoming data. :param data: :return:
-
execute
(request, **kwargs)¶ Starts the producer to send the next request to consumer.write(Frame(request))
-
factory
= None¶ Factory that created this instance.
-
raise_future
(f, exc)¶ Sets exception of a future if not done :param f: :param exc: :return:
-
resolve_future
(f, result)¶ Resolves the completed future and sets the result :param f: :param result: :return:
-
transport
= None¶
-
-
class
pymodbus.client.asynchronous.asyncio.
ModbusClientProtocol
(host='127.0.0.1', port=502, framer=None, source_address=None, timeout=None, **kwargs)¶ Bases:
pymodbus.client.asynchronous.asyncio.BaseModbusAsyncClientProtocol
,asyncio.protocols.Protocol
Asyncio specific implementation of asynchronous modbus client protocol.
-
data_received
(data)¶ Called when some data is received. data is a non-empty bytes object containing the incoming data. :param data: :return:
-
factory
= None¶ Factory that created this instance.
-
transport
= None¶
-
-
class
pymodbus.client.asynchronous.asyncio.
ModbusUdpClientProtocol
(host=None, port=0, **kwargs)¶ Bases:
pymodbus.client.asynchronous.asyncio.BaseModbusAsyncClientProtocol
,asyncio.protocols.DatagramProtocol
Asyncio specific implementation of asynchronous modbus udp client protocol.
-
datagram_received
(data, addr)¶ Called when some datagram is received.
-
factory
= None¶ Factory that created this instance.
-
-
class
pymodbus.client.asynchronous.asyncio.
ReconnectingAsyncioModbusTcpClient
(protocol_class=None, loop=None)¶ Bases:
object
Client to connect to modbus device repeatedly over TCP/IP.”
-
DELAY_MAX_MS
= 300000¶ Maximum delay in milli seconds before reconnect is attempted.
-
DELAY_MIN_MS
= 100¶ Minimum delay in milli seconds before reconnect is attempted.
-
delay_ms
= None¶ Reconnect delay in milli seconds.
-
loop
= None¶ Event loop to use.
-
protocol
= None¶ Current protocol instance.
-
protocol_class
= None¶ Protocol used to talk to modbus device.
-
protocol_lost_connection
(protocol)¶ Protocol notification of lost connection.
-
protocol_made_connection
(protocol)¶ Protocol notification of successful connection.
-
reset_delay
()¶ Resets wait before next reconnect to minimal period.
-
start
(host, port=502)¶ Initiates connection to start client :param host: :param port: :return:
-
stop
()¶ Stops client :return:
-
-
class
pymodbus.client.asynchronous.asyncio.
ReconnectingAsyncioModbusUdpClient
(protocol_class=None, loop=None)¶ Bases:
object
Client to connect to modbus device repeatedly over UDP.
-
DELAY_MAX_MS
= 300000¶ Maximum delay in milli seconds before reconnect is attempted.
-
delay_ms
= 0¶ Reconnect delay in milli seconds.
-
loop
= None¶ Event loop to use.
-
protocol
= None¶ Current protocol instance.
-
protocol_class
= None¶ Protocol used to talk to modbus device.
-
protocol_lost_connection
(protocol)¶ Protocol notification of lost connection.
-
protocol_made_connection
(protocol)¶ Protocol notification of successful connection.
-
reset_delay
()¶ Resets wait before next reconnect to minimal period.
-
start
(host, port=502)¶ Start reconnecting asynchronous udp client :param host: Host IP to connect :param port: Host port to connect :return:
-
stop
()¶ Stops connection and prevents reconnect :return:
-
-
pymodbus.client.asynchronous.asyncio.
init_tcp_client
(proto_cls, loop, host, port, **kwargs)¶ Helper function to initialize tcp client :param proto_cls: :param loop: :param host: :param port: :param kwargs: :return:
-
pymodbus.client.asynchronous.asyncio.
init_udp_client
(proto_cls, loop, host, port, **kwargs)¶ Helper function to initialize UDP client :param proto_cls: :param loop: :param host: :param port: :param kwargs: :return: