client.sync — Twisted Synchronous Modbus Client

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

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

API Documentation

Implementation of a Modbus Client Using Sockets

Example Run:

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.sync.ModbusTransactionManager(client)

This is a simply pull producer that feeds requests to the modbus client

execute(request)

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

class pymodbus.client.sync.BaseModbusClient(framer)

Inteface for a modbus synchronous client. Defined here are all the methods for performing the related request methods. Derived classes simply need to implement the transport methods and set the correct framer.

close()

Closes the underlying socket connection

connect()

Connect to the modbus remote host

Returns:True if connection succeeded, False otherwise
execute(request=None)
Parameters:request – The request to process
Returns:The result of the request execution
class pymodbus.client.sync.ModbusTcpClient(host='127.0.0.1', port=502)

Implementation 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
class pymodbus.client.sync.ModbusUdpClient(host='127.0.0.1', port=502)

Implementation 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
class pymodbus.client.sync.ModbusSerialClient(method='ascii', **kwargs)

Implementation 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