tcp_master.py 268 B

123456789101112
  1. import modbus_rt
  2. import modbus_rt_defines as cst
  3. ip_addr = "192.168.28.150"
  4. tm = modbus_rt.tcp(cst.MASTER)
  5. tm.set_net(ip_addr, 0, cst.SOCK_STREAM)
  6. tm.set_server(ip_addr, 502)
  7. tm.open()
  8. # tm.excuse(1,3,0,5)
  9. # tm.excuse(1,16,0,5,[21,23,24,25,65])
  10. # tm.excuse(1,3,0,5)