#8 base class for RTU unit sessions, handle MODBUS error responses

This commit is contained in:
Mikayla Fischler
2022-05-17 17:16:04 -04:00
parent 31ede51c42
commit 9c034c366b
7 changed files with 349 additions and 304 deletions

View File

@@ -6,7 +6,7 @@ local util = require("scada-common.util")
local txnctrl = {}
local TIMEOUT = 3000 -- 3000ms max wait
local TIMEOUT = 2000 -- 2000ms max wait
-- create a new transaction controller
txnctrl.new = function ()
@@ -63,6 +63,17 @@ txnctrl.new = function ()
return txn_type
end
-- renew a transaction by re-inserting it with its ID and type
---@param txn_id integer
---@param txn_type integer
public.renew = function (txn_id, txn_type)
insert(self.list, {
txn_id = txn_id,
txn_type = txn_type,
expiry = util.time() + TIMEOUT
})
end
-- close timed-out transactions
public.cleanup = function ()
local now = util.time()