added Luacheck GitHub action (#210)
* added shields.io elements * #209 luacheck action * #209 cleanup to pass luacheck * added check statuses to readme
This commit is contained in:
@@ -34,7 +34,7 @@ function redstone_rtu.new()
|
||||
---@param side string
|
||||
---@param color integer
|
||||
function public.link_di(side, color)
|
||||
local f_read = nil
|
||||
local f_read ---@type function
|
||||
|
||||
if color then
|
||||
f_read = function ()
|
||||
@@ -53,8 +53,8 @@ function redstone_rtu.new()
|
||||
---@param side string
|
||||
---@param color integer
|
||||
function public.link_do(side, color)
|
||||
local f_read = nil
|
||||
local f_write = nil
|
||||
local f_read ---@type function
|
||||
local f_write ---@type function
|
||||
|
||||
if color then
|
||||
f_read = function ()
|
||||
|
||||
@@ -347,11 +347,9 @@ function modbus.new(rtu_dev, use_parallel_read)
|
||||
response = { MODBUS_EXCODE.NEG_ACKNOWLEDGE }
|
||||
end
|
||||
|
||||
-- default is to echo back
|
||||
local func_code = packet.func_code
|
||||
|
||||
-- echo back with error flag, on success the "error" will be acknowledgement
|
||||
func_code = bit.bor(packet.func_code, MODBUS_FCODE.ERROR_FLAG)
|
||||
-- default is to echo back<br>
|
||||
-- but here we echo back with error flag, on success the "error" will be acknowledgement
|
||||
local func_code = bit.bor(packet.func_code, MODBUS_FCODE.ERROR_FLAG)
|
||||
|
||||
-- create reply
|
||||
local reply = comms.modbus_packet()
|
||||
@@ -365,8 +363,8 @@ function modbus.new(rtu_dev, use_parallel_read)
|
||||
---@param packet modbus_frame
|
||||
---@return boolean return_code, modbus_packet reply
|
||||
function public.handle_packet(packet)
|
||||
local return_code = true
|
||||
local response = nil
|
||||
local return_code ---@type boolean
|
||||
local response ---@type table|MODBUS_EXCODE
|
||||
|
||||
if packet.length >= 2 then
|
||||
-- handle by function code
|
||||
|
||||
@@ -14,9 +14,6 @@ local ESTABLISH_ACK = comms.ESTABLISH_ACK
|
||||
local SCADA_MGMT_TYPE = comms.SCADA_MGMT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
local print_ts = util.print_ts
|
||||
local println_ts = util.println_ts
|
||||
|
||||
-- create a new RTU unit
|
||||
@@ -347,8 +344,8 @@ function rtu.comms(version, modem, local_port, server_port, range, conn_watchdog
|
||||
if protocol == PROTOCOL.MODBUS_TCP then
|
||||
---@cast packet modbus_frame
|
||||
if rtu_state.linked then
|
||||
local return_code = false
|
||||
local reply = modbus.reply__neg_ack(packet)
|
||||
local return_code ---@type boolean
|
||||
local reply ---@type modbus_packet
|
||||
|
||||
-- handle MODBUS instruction
|
||||
if packet.unit_id <= #units then
|
||||
|
||||
@@ -25,13 +25,11 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||
|
||||
local RTU_VERSION = "v0.13.2"
|
||||
local RTU_VERSION = "v0.13.3"
|
||||
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
local print_ts = util.print_ts
|
||||
local println_ts = util.println_ts
|
||||
|
||||
----------------------------------------
|
||||
@@ -287,9 +285,9 @@ local function main()
|
||||
|
||||
local device = ppm.get_periph(name)
|
||||
|
||||
local type = nil ---@type string|nil
|
||||
local rtu_iface = nil ---@type rtu_device
|
||||
local rtu_type = nil ---@type RTU_UNIT_TYPE
|
||||
local type ---@type string|nil
|
||||
local rtu_iface ---@type rtu_device
|
||||
local rtu_type ---@type RTU_UNIT_TYPE
|
||||
local is_multiblock = false ---@type boolean
|
||||
local formed = nil ---@type boolean|nil
|
||||
local faulted = nil ---@type boolean|nil
|
||||
@@ -356,11 +354,11 @@ local function main()
|
||||
elseif type == "solarNeutronActivator" then
|
||||
-- SNA
|
||||
rtu_type = RTU_UNIT_TYPE.SNA
|
||||
rtu_iface, _ = sna_rtu.new(device)
|
||||
rtu_iface, faulted = sna_rtu.new(device)
|
||||
elseif type == "environmentDetector" then
|
||||
-- advanced peripherals environment detector
|
||||
rtu_type = RTU_UNIT_TYPE.ENV_DETECTOR
|
||||
rtu_iface, _ = envd_rtu.new(device)
|
||||
rtu_iface, faulted = envd_rtu.new(device)
|
||||
elseif type == ppm.VIRTUAL_DEVICE_TYPE then
|
||||
-- placeholder device
|
||||
rtu_type = RTU_UNIT_TYPE.VIRTUAL
|
||||
|
||||
@@ -17,9 +17,6 @@ local threads = {}
|
||||
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
local print_ts = util.print_ts
|
||||
local println_ts = util.println_ts
|
||||
|
||||
local MAIN_CLOCK = 2 -- (2Hz, 40 ticks)
|
||||
|
||||
Reference in New Issue
Block a user