This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Backup include modbus settings
#1
Hello,

We're using this example: https://openrb.com/e-mail-backup-file-on...h-from-lm/ to make our LM backups, but they don't contain modbus settings. Is it possible to integrate these settings in a backup file, or I have to think of a separate way to do this?

Thank You.
Reply
#2
Heres a function to enable RTU. Change RTU settings as you please.

Call this function in init. You should also set a storage so you know it has been done, so you don't enable RTU each time the device reboots.

Code:
function enableRTU()

-- Function to send request (in this case to enable modbus RTU with settings)
function webrequest(mod, act, vars, data)
require('json')
require('dbenv')
require('uci')
local path
vars = vars or {}
function getvar(v)
    return vars[ v ]
end
json.data = function()
    return data or {}
end
if mod == 'plugin' then
    path = 'plugins/' .. act .. '/web.lua'
else
    path = 'web/' .. mod .. '/' .. act .. '.lua'
end
return dofile('/lib/genohm-scada/' .. path)
end


-- RTU settings (Change these to your liking)
Set_enabled = 1
Set_port = "/dev/RS485"
Set_baudrate  = 19200
Set_parity = 2
Set_duplex = "H"
Set_port1 = ""
Set_baudrate1  = 115200
Set_parity1 = 2
Set_duplex1 = "H"
Set_port2 = ""
Set_baudrate2  = 115200
Set_parity2 = 2
Set_duplex2 = "H"


-- Input settings
requestdata = {
    enabled = "" .. Set_enabled,
    port = "" .. Set_port,
    baudrate = "" .. Set_baudrate,
    parity = "" .. Set_parity,
    duplex = "" .. Set_duplex,
    port_1 = "" .. Set_port1,
    baudrate_1 = "" .. Set_baudrate1,
    parity_1 = "" .. Set_parity1,
    duplex_1 = "" .. Set_duplex1,
    port_2 = "" .. Set_port2,
    baudrate_2 = "" .. Set_baudrate2,
    parity_2 = "" .. Set_parity2,
    duplex_2 = "" .. Set_duplex2,
  }
result = webrequest('plugin', 'modbus', {request = 'config-save'}, requestdata)

  -- Results for log
if result == '{"success":true}' then
    alert('Modbus RTU enabled')
else
    alert('Enable Modbus RTU FAILED!')
end
 
end
Reply


Forum Jump: