Does RevolutionPI already come with a server that listens to say port 502 that will reply to modbus TCP protocol?
For instance, using the webinterface, I have enabled "Enable/Disable Modbus Slave".
But after this enable and reboot, the PC still does not accept incoming connections on 502.
Specifically, I would like to read DigitalIn and DigitalOut of the RevolutionPi via ModbusTCP.
Thank you
Modbus TCP Slave
Hello asherjackson ,
The RevolutionPi does come with the ability to act as a Modbus TCP slave, but it doesn't automatically start a Modbus TCP server on port 502 just by enabling the "Modbus Slave" option in the web interface.
Verify that the port 502 is open and not blocked by any firewall or security settings on the RevolutionPi. You can check this by running:
If needed, you can open the port with:
The Modbus server should be running after the configuration. You can check if the service is listening on port 502 using
If there’s no output, it means the server isn’t running. You might need to restart the Modbus service or the entire device.
Once the server is running, you should be able to read DigitalIn and DigitalOut using Modbus TCP. Make sure to do the mapping for these inputs and outputs. You can a python script with the library revpimodio
see the following code as example:
Best Regards
Ulrich Kouatang Biakoup | field application engineer
The RevolutionPi does come with the ability to act as a Modbus TCP slave, but it doesn't automatically start a Modbus TCP server on port 502 just by enabling the "Modbus Slave" option in the web interface.
Verify that the port 502 is open and not blocked by any firewall or security settings on the RevolutionPi. You can check this by running:
Code: Select all
sudo iptables -L
Code: Select all
sudo iptables -A INPUT -p tcp --dport 502 -j ACCEPT
Code: Select all
sudo netstat -tuln | grep 502
Once the server is running, you should be able to read DigitalIn and DigitalOut using Modbus TCP. Make sure to do the mapping for these inputs and outputs. You can a python script with the library revpimodio
see the following code as example:
Code: Select all
import revpimodio2
import time
# Initialisierung des RevPiModIO Objekts
rpi = revpimodio2.RevPiModIO(autorefresh=True)
while True:
rpi.io.ModbusOutput_1.value = int(rpi.io.I_1.value)
rpi.io.O_1.value = int(rpi.io.ModbusInput_1.value)
print(rpi.io.ModbusOutput_1.value, rpi.io.O_1.value)
time.sleep(0.02)
Best Regards
Ulrich Kouatang Biakoup | field application engineer