You must use StartTcpServer
and not ModbusTcpClient
.
See the server example that use here :
#!/usr/bin/env python
from pymodbus.server.async import StartTcpServer
from pymodbus.datastore import ModbusSequentialDataBlock
from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext
#---------------------------------------------------------------------------#
# initialize your data store
#---------------------------------------------------------------------------#
store = ModbusSlaveContext(
di = ModbusSequentialDataBlock(0, [17]*100),
co = ModbusSequentialDataBlock(0, [17]*100),
hr = ModbusSequentialDataBlock(0, [17]*100),
ir = ModbusSequentialDataBlock(0, [17]*100))
context = ModbusServerContext(slaves=store, single=True)
#---------------------------------------------------------------------------#
# run the server
#---------------------------------------------------------------------------#
StartTcpServer(context)
Links to resources that may be of interest to you:
The simulator uses the output of the scraper to create a server with the data of a real server that has been scraping.