Ofer Posted April 30, 2019 Report Share Posted April 30, 2019 Im just a nube so it took me a while to figure it out. on the unitronix side assign a slave to one of the ports like this on the python side read data with something like this import modbus_tk import modbus_tk.defines as cst import modbus_tk.modbus as modbus import modbus_tk.modbus_tcp as modbus_tcp import logging logger = modbus_tk.utils.create_logger("console", level=logging.DEBUG) master = modbus_tcp.TcpMaster(host='172.21.2.183', port=20257, timeout_in_sec=5.0) master.open actual_bits = master.execute(slave=1, function_code=cst.READ_COILS, starting_address=1, quantity_of_x=2) print("actual_bits =", actual_bits) master.close remember the slave number! Hope this helps someone Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.