Modbus RTU

From Electrical Age
Jump to: navigation, search

The Modbus RTU is an entity that allows your real life electrical monitoring equipment to communicate with your in game circuits via the Modbus protocol.

It is necessary to enable it in the config before you can use it. The game will warn you if it is not enabled in the configuration file.

some references to other modbus software

example server side Python code

Note that you need to install the pymodbus pip package:

pip install --user pymodbus

Code listing

import time

from pymodbus.client.sync import ModbusTcpClient

client = ModbusTcpClient('127.0.0.1', 1502)

while True:
    read = client.read_input_registers(10, 4).registers
    print(read)
    client.write_coil(15, read[3] > 1024*32)
    time.sleep(0.1)

client.close()

You will also need to enable the Modbus RTU in the game config file. It only interacts with wireless signals at the time of writing, examples will be eventually provided.