server.async — Twisted Asynchronous Modbus Server

Module author: Galen Collins <bashwork@gmail.com>

Section author: Galen Collins <bashwork@gmail.com>

API Documentation

Implementation of a Twisted Modbus Server

class pymodbus.server.async.ModbusTcpProtocol

Implements a modbus server in twisted

connectionLost(reason)

Callback for when a client disconnects

Parameters:reason – The client’s reason for disconnecting
connectionMade()

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.

dataReceived(data)

Callback when we receive any data

Parameters:data – The data sent by the client
class pymodbus.server.async.ModbusUdpProtocol(store, framer=None, identity=None)

Implements a modbus udp server in twisted

datagramReceived(data, addr)

Callback when we receive any data

Parameters:data – The data sent by the client
class pymodbus.server.async.ModbusServerFactory(store, framer=None, identity=None)

Builder class for a modbus server

This also holds the server datastore so that it is persisted between connections

protocol

alias of ModbusTcpProtocol

pymodbus.server.async.StartTcpServer(context, identity=None)

Helper method to start the Modbus Async TCP server

Parameters:
  • context – The server data context
  • identify – The server identity to use (default empty)
pymodbus.server.async.StartUdpServer(context, identity=None)

Helper method to start the Modbus Async Udp server

Parameters:
  • context – The server data context
  • identify – The server identity to use (default empty)
pymodbus.server.async.StartSerialServer(context, identity=None, framer=<class 'pymodbus.transaction.ModbusAsciiFramer'>, **kwargs)

Helper method to start the Modbus Async Serial server :param context: The server data context :param identify: The server identity to use (default empty) :param framer: The framer to use (default ModbusAsciiFramer)