Modbus TCP Server vía UCI command - RUT200

Hello everyone,

I’m having issues using UCI commands to configure the Modbus TCP server on the RUT200. I successfully completed this process once without errors, but now I can’t replicate it.

These are the UCI commands I’ve used so far:

"opkg update",
"opkg install modbus_server",
"uci set modbus_server.modbus.enabled='1'",
"uci set modbus_server.modbus.timeout='5'",
"uci commit modbus_server"

Then, I reboot the device. I’m not sure if the last command (commit) is required, but it shouldn’t be a problem either.

The issue is that I also need to enable remote access. According to this forum post, I should use the following command:

uci set firewall.20.enabled='1'

However, I get an error because that rule doesn’t exist, even though it should. Also, when listing the UCI configuration, I get:

~ uci show modbus_server                                                                  
modbus_server.modbus=modbus                                                                            
modbus_server.modbus.keepconn='1'                                                                      
modbus_server.modbus.enabled='1'                                                                       
modbus_server.modbus.timeout='5'                                                                       

Previously, I used to get:

So, I suspect something is not being configured correctly, but I’m not sure what.

If I access the WebUI, go to Services > Modbus > Modbus TCP Server, and click Save and Apply, all the missing UCI commands appear. However, I need a solution using only UCI commands (if possible).

Thanks in advance!

Hello,

The rule you have used to enable remote access is device specific the value 20 is probably wrong in your case.
Try instead:

uci set firewall.$(uci show firewall | grep Enable_MODBUSD_WAN|cut -d '.' -f 2).enabled='1'

if you need to do it via a script or just set “Allow remote access” in the UI at Services->Modbus->Modbus TCP server.

Regards,

Hello,

Yes, I noticed that the number is not important (I used 21 before). The issue is that the rule doesn’t exist, and some configurations of modbus_server are also missing from the uci command list.

Doing it on the WebUI doesn’t solve the problem for me since the devices connected to the router don’t have a GUI.

Regards,