server.async
— Twisted Asynchronous Modbus Server¶
API Documentation¶
Implementation of a Twisted Modbus Server¶
-
class
pymodbus.server.async.
ModbusTcpProtocol
[source]¶ Implements a modbus server in twisted
-
connectionMade
()[source]¶ Callback for when a client connects
- ..note:: since the protocol factory cannot be accessed from the
- protocol __init__, the client connection made is essentially our __init__ method.
-
connectionLost
(reason)[source]¶ Callback for when a client disconnects
Parameters: reason – The client’s reason for disconnecting
-
dataReceived
(data)[source]¶ Callback when we receive any data
Parameters: data – The data sent by the client
-
-
class
pymodbus.server.async.
ModbusUdpProtocol
(store, framer=None, identity=None, **kwargs)[source]¶ Implements a modbus udp server in twisted
-
__init__
(store, framer=None, identity=None, **kwargs)[source]¶ Overloaded initializer for the modbus factory
If the identify structure is not passed in, the ModbusControlBlock uses its own empty structure.
Parameters: - store – The ModbusServerContext datastore
- framer – The framer strategy to use
- identity – An optional identify structure
- ignore_missing_slaves – True to not send errors on a request to a missing slave
-
datagramReceived
(data, addr)[source]¶ Callback when we receive any data
Parameters: data – The data sent by the client
-
-
class
pymodbus.server.async.
ModbusServerFactory
(store, framer=None, identity=None, **kwargs)[source]¶ Builder class for a modbus server
This also holds the server datastore so that it is persisted between connections
-
protocol
¶ alias of
ModbusTcpProtocol
-
__init__
(store, framer=None, identity=None, **kwargs)[source]¶ Overloaded initializer for the modbus factory
If the identify structure is not passed in, the ModbusControlBlock uses its own empty structure.
Parameters: - store – The ModbusServerContext datastore
- framer – The framer strategy to use
- identity – An optional identify structure
- ignore_missing_slaves – True to not send errors on a request to a missing slave
-
-
pymodbus.server.async.
StartTcpServer
(context, identity=None, address=None, console=False, **kwargs)[source]¶ Helper method to start the Modbus Async TCP server
Parameters: - context – The server data context
- identify – The server identity to use (default empty)
- address – An optional (interface, port) to bind to.
- console – A flag indicating if you want the debug console
- ignore_missing_slaves – True to not send errors on a request to a missing slave
-
pymodbus.server.async.
StartUdpServer
(context, identity=None, address=None, **kwargs)[source]¶ Helper method to start the Modbus Async Udp server
Parameters: - context – The server data context
- identify – The server identity to use (default empty)
- address – An optional (interface, port) to bind to.
- ignore_missing_slaves – True to not send errors on a request to a missing slave
-
pymodbus.server.async.
StartSerialServer
(context, identity=None, framer=<class 'pymodbus.transaction.ModbusAsciiFramer'>, **kwargs)[source]¶ Helper method to start the Modbus Async Serial server
Parameters: - context – The server data context
- identify – The server identity to use (default empty)
- framer – The framer to use (default ModbusAsciiFramer)
- port – The serial port to attach to
- baudrate – The baud rate to use for the serial device
- console – A flag indicating if you want the debug console
- ignore_missing_slaves – True to not send errors on a request to a missing slave