client.async — Twisted Async Modbus Client

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

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

API Documentation

Implementation of a Modbus Client Using Twisted

Example Run:

from pymodbus.client.async import ModbusClientFactory
from pymodbus.bit_read_message import ReadCoilsRequest

def clientTest():
    requests = [ ReadCoilsRequest(0,99) ]
    p = reactor.connectTCP("localhost", 502, ModbusClientFactory(requests))

if __name__ == "__main__":
   reactor.callLater(1, clientTest)
   reactor.run()
class pymodbus.client.async.ModbusClientProtocol(framer=None)

This represents the base modbus client protocol. All the application layer code is deferred to a higher level wrapper.

connectionLost()

Called upon a client disconnect

connectionMade()

Called upon a successful client connection.

dataReceived(data)

Get response, check for valid message, decode result

Parameters:data – The data returned from the server
execute(request)

Starts the producer to send the next request to consumer.write(Frame(request))

class pymodbus.client.async.ModbusClientFactory

Simple client protocol factory

protocol

alias of ModbusClientProtocol