right now i'm just trying example codes, and it's still not working.
i'm using synchronous client and asynchronous slave, connected by RS485 ports
exactly using the example code
#!/usr/bin/python2.4
#from pymodbus.client.sync import ModbusTcpClient as ModbusClient
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)
#client = ModbusClient('localhost', port=502)
client = ModbusClient(method='rtu', port='/dev/ttyS2', timeout=10)
client.connect()
rr = client.read_holding_registers(1,3)
print rr.registers
client.close()
And for the slave:
#!/usr/bin/python2.4
from pymodbus.server.async import StartTcpServer
from pymodbus.server.async import StartUdpServer
from pymodbus.server.async import StartSerialServer
from pymodbus.device import ModbusDeviceIdentification
from pymodbus.datastore import ModbusSequentialDataBlock
from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext
from pymodbus.transaction import ModbusRtuFramer, ModbusAsciiFramer
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)
store = ModbusSlaveContext(
di = ModbusSequentialDataBlock(1, [15,16,21,23]))
context = ModbusServerContext(slaves=store, single=True)
identity = ModbusDeviceIdentification()
#StartTcpServer(context, identity=identity, address=("localhost", 502))
StartSerialServer(context, identity=identity, port='/dev/ttyS2', framer=ModbusR\
tuFramer)
the arduino slave i'm using is this one
https://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slavethank you for looking into this and helping me.