Refer to various great god code is very easy the following
The import modbus_tk
The import modbus_tk. Defines as MTK
The import modbus_tk. Modbus
The from modbus_tk import modbus_tcp
The from modbus_tk import modbus_rtu
The import of logging
Server=modbus_tcp. TcpServer (502, "0.0.0.0")
Print (" running...
")
Server. The start ()
Slave_1=server. Add_slave (1)
Slave_1. Add_block (' 0 ', MTK HOLDING_REGISTERS, 0, 20)
Slave_1. Set_values (' 0 ', 14, [x4000 0 x8000, 0, 0 x2000])
Test the problem comes when
Using modbus POLL tools as master reading and writing are no problem
Measured devices, but received no response
Wireshark caught found in syn three-way handshake
Python code tracking gradually found in modbus_tcp select socket links this step
Docking is under test equipment, don't get the socket link
Docking is the modbus POLL, socket to receive normal
The select is the underlying function without further code
So the question of what a great god know what reason be?