#225 log message fixes and sv addr checks for RTU
This commit is contained in:
@@ -314,7 +314,7 @@ function pocket.comms(version, modem, pkt_channel, svr_channel, crd_channel, ran
|
|||||||
elseif not self.api.linked then
|
elseif not self.api.linked then
|
||||||
log.debug("discarding coordinator non-link SCADA_MGMT packet before linked")
|
log.debug("discarding coordinator non-link SCADA_MGMT packet before linked")
|
||||||
else
|
else
|
||||||
log.debug("discarding SCADA_MGMT from different coordinator (src_addr " .. src_addr .. " ≠ " .. self.api.addr .. ")")
|
log.debug("discarding non-link SCADA_MGMT packet from different coordinator (src_addr " .. src_addr .. " ≠ " .. self.api.addr .. ")")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug("illegal packet type " .. protocol .. " from coordinator", true)
|
log.debug("illegal packet type " .. protocol .. " from coordinator", true)
|
||||||
@@ -405,7 +405,7 @@ function pocket.comms(version, modem, pkt_channel, svr_channel, crd_channel, ran
|
|||||||
elseif not self.sv.linked then
|
elseif not self.sv.linked then
|
||||||
log.debug("discarding supervisor non-link SCADA_MGMT packet before linked")
|
log.debug("discarding supervisor non-link SCADA_MGMT packet before linked")
|
||||||
else
|
else
|
||||||
log.debug("discarding SCADA_MGMT from different supervisor (src_addr " .. src_addr .. " ≠ " .. self.sv.addr .. ")")
|
log.debug("discarding non-link SCADA_MGMT from different supervisor (src_addr " .. src_addr .. " ≠ " .. self.sv.addr .. ")")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug("illegal packet type " .. protocol .. " from supervisor", true)
|
log.debug("illegal packet type " .. protocol .. " from supervisor", true)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ local coreio = require("pocket.coreio")
|
|||||||
local pocket = require("pocket.pocket")
|
local pocket = require("pocket.pocket")
|
||||||
local renderer = require("pocket.renderer")
|
local renderer = require("pocket.renderer")
|
||||||
|
|
||||||
local POCKET_VERSION = "alpha-v0.4.2"
|
local POCKET_VERSION = "alpha-v0.4.3"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
|||||||
@@ -938,7 +938,7 @@ function plc.comms(id, version, modem, plc_channel, svr_channel, range, reactor,
|
|||||||
elseif not self.linked then
|
elseif not self.linked then
|
||||||
log.debug("discarding RPLC packet before linked")
|
log.debug("discarding RPLC packet before linked")
|
||||||
else
|
else
|
||||||
log.debug("discarding RPLC from different supervisor (src_addr " .. src_addr .. " ≠ " .. self.sv_addr .. "sv_addr)")
|
log.debug("discarding RPLC packet from different supervisor (src_addr " .. src_addr .. " ≠ " .. self.sv_addr .. ")")
|
||||||
end
|
end
|
||||||
elseif protocol == PROTOCOL.SCADA_MGMT then
|
elseif protocol == PROTOCOL.SCADA_MGMT then
|
||||||
---@cast packet mgmt_frame
|
---@cast packet mgmt_frame
|
||||||
@@ -1057,8 +1057,10 @@ function plc.comms(id, version, modem, plc_channel, svr_channel, range, reactor,
|
|||||||
else
|
else
|
||||||
log.debug("SCADA_MGMT establish packet length mismatch")
|
log.debug("SCADA_MGMT establish packet length mismatch")
|
||||||
end
|
end
|
||||||
else
|
elseif not self.linked then
|
||||||
log.debug("discarding non-link SCADA_MGMT packet before linked")
|
log.debug("discarding non-link SCADA_MGMT packet before linked")
|
||||||
|
else
|
||||||
|
log.debug("discarding non-link SCADA_MGMT packet from different supervisor (src_addr " .. src_addr .. " ≠ " .. self.sv_addr .. ")")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- should be unreachable assuming packet is from parse_packet()
|
-- should be unreachable assuming packet is from parse_packet()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
|
|||||||
local renderer = require("reactor-plc.renderer")
|
local renderer = require("reactor-plc.renderer")
|
||||||
local threads = require("reactor-plc.threads")
|
local threads = require("reactor-plc.threads")
|
||||||
|
|
||||||
local R_PLC_VERSION = "v1.4.3"
|
local R_PLC_VERSION = "v1.4.4"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
|||||||
12
rtu/rtu.lua
12
rtu/rtu.lua
@@ -354,7 +354,7 @@ function rtu.comms(version, modem, rtu_channel, svr_channel, range, conn_watchdo
|
|||||||
-- handle packet
|
-- handle packet
|
||||||
if protocol == PROTOCOL.MODBUS_TCP then
|
if protocol == PROTOCOL.MODBUS_TCP then
|
||||||
---@cast packet modbus_frame
|
---@cast packet modbus_frame
|
||||||
if rtu_state.linked then
|
if rtu_state.linked and (src_addr == self.sv_addr) then
|
||||||
local return_code ---@type boolean
|
local return_code ---@type boolean
|
||||||
local reply ---@type modbus_packet
|
local reply ---@type modbus_packet
|
||||||
|
|
||||||
@@ -394,8 +394,10 @@ function rtu.comms(version, modem, rtu_channel, svr_channel, range, conn_watchdo
|
|||||||
end
|
end
|
||||||
|
|
||||||
public.send_modbus(reply)
|
public.send_modbus(reply)
|
||||||
else
|
elseif not rtu_state.linked then
|
||||||
log.debug("discarding MODBUS packet before linked")
|
log.debug("discarding MODBUS packet before linked")
|
||||||
|
else
|
||||||
|
log.debug("discarding MODBUS packet from different supervisor (src_addr " .. src_addr .. " ≠ " .. self.sv_addr .. ")")
|
||||||
end
|
end
|
||||||
elseif protocol == PROTOCOL.SCADA_MGMT then
|
elseif protocol == PROTOCOL.SCADA_MGMT then
|
||||||
---@cast packet mgmt_frame
|
---@cast packet mgmt_frame
|
||||||
@@ -434,7 +436,7 @@ function rtu.comms(version, modem, rtu_channel, svr_channel, range, conn_watchdo
|
|||||||
else
|
else
|
||||||
log.debug("SCADA_MGMT establish packet length mismatch")
|
log.debug("SCADA_MGMT establish packet length mismatch")
|
||||||
end
|
end
|
||||||
elseif rtu_state.linked then
|
elseif rtu_state.linked and (src_addr == self.sv_addr) then
|
||||||
if packet.type == SCADA_MGMT_TYPE.KEEP_ALIVE then
|
if packet.type == SCADA_MGMT_TYPE.KEEP_ALIVE then
|
||||||
-- keep alive request received, echo back
|
-- keep alive request received, echo back
|
||||||
if packet.length == 1 and type(packet.data[1]) == "number" then
|
if packet.length == 1 and type(packet.data[1]) == "number" then
|
||||||
@@ -464,8 +466,10 @@ function rtu.comms(version, modem, rtu_channel, svr_channel, range, conn_watchdo
|
|||||||
-- not supported
|
-- not supported
|
||||||
log.debug("received unsupported SCADA_MGMT message type " .. packet.type)
|
log.debug("received unsupported SCADA_MGMT message type " .. packet.type)
|
||||||
end
|
end
|
||||||
else
|
elseif not rtu_state.linked then
|
||||||
log.debug("discarding non-link SCADA_MGMT packet before linked")
|
log.debug("discarding non-link SCADA_MGMT packet before linked")
|
||||||
|
else
|
||||||
|
log.debug("discarding non-link SCADA_MGMT packet from different supervisor (src_addr " .. src_addr .. " ≠ " .. self.sv_addr .. ")")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- should be unreachable assuming packet is from parse_packet()
|
-- should be unreachable assuming packet is from parse_packet()
|
||||||
|
|||||||
@@ -28,7 +28,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.3.3"
|
local RTU_VERSION = "v1.3.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
|
||||||
|
|||||||
Reference in New Issue
Block a user