mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#338 resolved diagnostic warnings
This commit is contained in:
parent
b9073153b3
commit
5585088e3a
@ -54,9 +54,9 @@ end
|
|||||||
function coordinator.configure_monitors(num_units, disable_flow_view)
|
function coordinator.configure_monitors(num_units, disable_flow_view)
|
||||||
---@class monitors_struct
|
---@class monitors_struct
|
||||||
local monitors = {
|
local monitors = {
|
||||||
primary = nil,
|
primary = nil, ---@type table|nil
|
||||||
primary_name = "",
|
primary_name = "",
|
||||||
flow = nil,
|
flow = nil, ---@type table|nil
|
||||||
flow_name = "",
|
flow_name = "",
|
||||||
unit_displays = {},
|
unit_displays = {},
|
||||||
unit_name_map = {}
|
unit_name_map = {}
|
||||||
|
@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder")
|
|||||||
|
|
||||||
local apisessions = require("coordinator.session.apisessions")
|
local apisessions = require("coordinator.session.apisessions")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "v1.0.10"
|
local COORDINATOR_VERSION = "v1.0.11"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
require("lockbox").insecure();
|
|
||||||
|
|
||||||
local Bit = require("lockbox.util.bit");
|
local Bit = require("lockbox.util.bit");
|
||||||
local String = require("string");
|
local String = require("string");
|
||||||
local Math = require("math");
|
local Math = require("math");
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
require("lockbox").insecure();
|
|
||||||
|
|
||||||
local Bit = require("lockbox.util.bit");
|
local Bit = require("lockbox.util.bit");
|
||||||
local String = require("string");
|
local String = require("string");
|
||||||
local Math = require("math");
|
local Math = require("math");
|
||||||
|
@ -1,25 +1,6 @@
|
|||||||
local Lockbox = {};
|
local Lockbox = {}
|
||||||
|
|
||||||
-- cc-mek-scada lockbox version
|
-- cc-mek-scada lockbox version
|
||||||
Lockbox.version = "1.0"
|
Lockbox.version = "1.1"
|
||||||
|
|
||||||
--[[
|
return Lockbox
|
||||||
package.path = "./?.lua;"
|
|
||||||
.. "./cipher/?.lua;"
|
|
||||||
.. "./digest/?.lua;"
|
|
||||||
.. "./kdf/?.lua;"
|
|
||||||
.. "./mac/?.lua;"
|
|
||||||
.. "./padding/?.lua;"
|
|
||||||
.. "./test/?.lua;"
|
|
||||||
.. "./util/?.lua;"
|
|
||||||
.. package.path;
|
|
||||||
--]]
|
|
||||||
Lockbox.ALLOW_INSECURE = true;
|
|
||||||
|
|
||||||
Lockbox.insecure = function()
|
|
||||||
assert(Lockbox.ALLOW_INSECURE,
|
|
||||||
"This module is insecure! It should not be used in production." ..
|
|
||||||
"If you really want to use it, set Lockbox.ALLOW_INSECURE to true before importing it");
|
|
||||||
end
|
|
||||||
|
|
||||||
return Lockbox;
|
|
||||||
|
@ -8,7 +8,7 @@ local HMAC = function()
|
|||||||
|
|
||||||
local public = {};
|
local public = {};
|
||||||
local blockSize = 64;
|
local blockSize = 64;
|
||||||
local Digest = nil;
|
local Digest;
|
||||||
local outerPadding = {};
|
local outerPadding = {};
|
||||||
local innerPadding = {}
|
local innerPadding = {}
|
||||||
local digest;
|
local digest;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
local String = require("string");
|
local String = require("string");
|
||||||
local Bit = require("lockbox.util.bit");
|
local Bit = require("lockbox.util.bit");
|
||||||
local Queue = require("lockbox.util.queue");
|
local Queue = require("lockbox.util.queue");
|
||||||
|
@ -215,7 +215,7 @@ function modbus.new(rtu_dev, use_parallel_read)
|
|||||||
---@param value any
|
---@param value any
|
||||||
---@return boolean ok, MODBUS_EXCODE
|
---@return boolean ok, MODBUS_EXCODE
|
||||||
local function _5_write_single_coil(c_addr, value)
|
local function _5_write_single_coil(c_addr, value)
|
||||||
local response = nil
|
local response = MODBUS_EXCODE.OK
|
||||||
local _, coils, _, _ = rtu_dev.io_count()
|
local _, coils, _, _ = rtu_dev.io_count()
|
||||||
local return_ok = c_addr <= coils
|
local return_ok = c_addr <= coils
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ function modbus.new(rtu_dev, use_parallel_read)
|
|||||||
---@param value any
|
---@param value any
|
||||||
---@return boolean ok, MODBUS_EXCODE
|
---@return boolean ok, MODBUS_EXCODE
|
||||||
local function _6_write_single_holding_register(hr_addr, value)
|
local function _6_write_single_holding_register(hr_addr, value)
|
||||||
local response = nil
|
local response = MODBUS_EXCODE.OK
|
||||||
local _, _, _, hold_regs = rtu_dev.io_count()
|
local _, _, _, hold_regs = rtu_dev.io_count()
|
||||||
local return_ok = hr_addr <= hold_regs
|
local return_ok = hr_addr <= hold_regs
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ function modbus.new(rtu_dev, use_parallel_read)
|
|||||||
---@param values any
|
---@param values any
|
||||||
---@return boolean ok, MODBUS_EXCODE
|
---@return boolean ok, MODBUS_EXCODE
|
||||||
local function _15_write_multiple_coils(c_addr_start, values)
|
local function _15_write_multiple_coils(c_addr_start, values)
|
||||||
local response = nil
|
local response = MODBUS_EXCODE.OK
|
||||||
local _, coils, _, _ = rtu_dev.io_count()
|
local _, coils, _, _ = rtu_dev.io_count()
|
||||||
local count = #values
|
local count = #values
|
||||||
local return_ok = ((c_addr_start + count) <= (coils + 1)) and (count > 0)
|
local return_ok = ((c_addr_start + count) <= (coils + 1)) and (count > 0)
|
||||||
@ -292,7 +292,7 @@ function modbus.new(rtu_dev, use_parallel_read)
|
|||||||
---@param values any
|
---@param values any
|
||||||
---@return boolean ok, MODBUS_EXCODE
|
---@return boolean ok, MODBUS_EXCODE
|
||||||
local function _16_write_multiple_holding_registers(hr_addr_start, values)
|
local function _16_write_multiple_holding_registers(hr_addr_start, values)
|
||||||
local response = nil
|
local response = MODBUS_EXCODE.OK
|
||||||
local _, _, _, hold_regs = rtu_dev.io_count()
|
local _, _, _, hold_regs = rtu_dev.io_count()
|
||||||
local count = #values
|
local count = #values
|
||||||
local return_ok = ((hr_addr_start + count) <= (hold_regs + 1)) and (count > 0)
|
local return_ok = ((hr_addr_start + count) <= (hold_regs + 1)) and (count > 0)
|
||||||
@ -403,7 +403,7 @@ function modbus.new(rtu_dev, use_parallel_read)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if type(response) == "table" then
|
if type(response) == "table" then
|
||||||
elseif type(response) == "nil" then
|
elseif response == MODBUS_EXCODE.OK then
|
||||||
response = {}
|
response = {}
|
||||||
else
|
else
|
||||||
response = { response }
|
response = { response }
|
||||||
|
@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
|||||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||||
|
|
||||||
local RTU_VERSION = "v1.6.3"
|
local RTU_VERSION = "v1.6.4"
|
||||||
|
|
||||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||||
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
||||||
|
@ -16,7 +16,7 @@ local logger = {
|
|||||||
path = "/log.txt",
|
path = "/log.txt",
|
||||||
mode = MODE.APPEND,
|
mode = MODE.APPEND,
|
||||||
debug = false,
|
debug = false,
|
||||||
file = nil,
|
file = nil, ---@type table|nil
|
||||||
dmesg_out = nil,
|
dmesg_out = nil,
|
||||||
dmesg_restore_coord = { 1, 1 },
|
dmesg_restore_coord = { 1, 1 },
|
||||||
dmesg_scroll_count = 0
|
dmesg_scroll_count = 0
|
||||||
|
@ -375,6 +375,7 @@ types.MODBUS_FCODE = {
|
|||||||
-- MODBUS exception codes
|
-- MODBUS exception codes
|
||||||
---@enum MODBUS_EXCODE
|
---@enum MODBUS_EXCODE
|
||||||
types.MODBUS_EXCODE = {
|
types.MODBUS_EXCODE = {
|
||||||
|
OK = 0x00,
|
||||||
ILLEGAL_FUNCTION = 0x01,
|
ILLEGAL_FUNCTION = 0x01,
|
||||||
ILLEGAL_DATA_ADDR = 0x02,
|
ILLEGAL_DATA_ADDR = 0x02,
|
||||||
ILLEGAL_DATA_VALUE = 0x03,
|
ILLEGAL_DATA_VALUE = 0x03,
|
||||||
|
@ -8,7 +8,7 @@ local cc_strings = require("cc.strings")
|
|||||||
local util = {}
|
local util = {}
|
||||||
|
|
||||||
-- scada-common version
|
-- scada-common version
|
||||||
util.version = "1.1.0"
|
util.version = "1.1.1"
|
||||||
|
|
||||||
-- ENVIRONMENT CONSTANTS --
|
-- ENVIRONMENT CONSTANTS --
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ function txnctrl.new()
|
|||||||
-- mark a transaction as resolved to get its transaction type
|
-- mark a transaction as resolved to get its transaction type
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---@param txn_id integer
|
---@param txn_id integer
|
||||||
---@return integer txn_type
|
---@return integer|nil txn_type
|
||||||
function public.resolve(txn_id)
|
function public.resolve(txn_id)
|
||||||
local txn_type = nil
|
local txn_type = nil
|
||||||
|
|
||||||
|
@ -73,7 +73,13 @@ function unit_session.new(session_id, unit_id, advert, out_queue, log_tag, txn_t
|
|||||||
if m_pkt.scada_frame.protocol() == PROTOCOL.MODBUS_TCP then
|
if m_pkt.scada_frame.protocol() == PROTOCOL.MODBUS_TCP then
|
||||||
if m_pkt.unit_id == unit_id then
|
if m_pkt.unit_id == unit_id then
|
||||||
local txn_type = self.transaction_controller.resolve(m_pkt.txn_id)
|
local txn_type = self.transaction_controller.resolve(m_pkt.txn_id)
|
||||||
local txn_tag = " (" .. util.strval(txn_tags[txn_type]) .. ")"
|
local txn_tag = util.c(" (", txn_tags[txn_type], ")")
|
||||||
|
|
||||||
|
if txn_type == nil then
|
||||||
|
-- couldn't find this transaction
|
||||||
|
log.debug(log_tag .. "MODBUS: expired or spurious transaction reply (txn_id " .. m_pkt.txn_id .. ")")
|
||||||
|
return false, m_pkt.txn_id
|
||||||
|
end
|
||||||
|
|
||||||
if bit.band(m_pkt.func_code, MODBUS_FCODE.ERROR_FLAG) ~= 0 then
|
if bit.band(m_pkt.func_code, MODBUS_FCODE.ERROR_FLAG) ~= 0 then
|
||||||
-- transaction incomplete or failed
|
-- transaction incomplete or failed
|
||||||
|
@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor")
|
|||||||
|
|
||||||
local svsessions = require("supervisor.session.svsessions")
|
local svsessions = require("supervisor.session.svsessions")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "v1.0.3"
|
local SUPERVISOR_VERSION = "v1.0.4"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
Loading…
Reference in New Issue
Block a user