#225 log message fixes and sv addr checks for RTU

This commit is contained in:
Mikayla Fischler 2023-06-07 12:35:17 -04:00
parent f4e7137eb3
commit 5ba06dcdaf
6 changed files with 17 additions and 11 deletions

View File

@ -314,7 +314,7 @@ function pocket.comms(version, modem, pkt_channel, svr_channel, crd_channel, ran
elseif not self.api.linked then
log.debug("discarding coordinator non-link SCADA_MGMT packet before linked")
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
else
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
log.debug("discarding supervisor non-link SCADA_MGMT packet before linked")
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
else
log.debug("illegal packet type " .. protocol .. " from supervisor", true)

View File

@ -17,7 +17,7 @@ local coreio = require("pocket.coreio")
local pocket = require("pocket.pocket")
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_ts = util.println_ts

View File

@ -938,7 +938,7 @@ function plc.comms(id, version, modem, plc_channel, svr_channel, range, reactor,
elseif not self.linked then
log.debug("discarding RPLC packet before linked")
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
elseif protocol == PROTOCOL.SCADA_MGMT then
---@cast packet mgmt_frame
@ -1057,8 +1057,10 @@ function plc.comms(id, version, modem, plc_channel, svr_channel, range, reactor,
else
log.debug("SCADA_MGMT establish packet length mismatch")
end
else
elseif not self.linked then
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
else
-- should be unreachable assuming packet is from parse_packet()

View File

@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
local renderer = require("reactor-plc.renderer")
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_ts = util.println_ts

View File

@ -354,7 +354,7 @@ function rtu.comms(version, modem, rtu_channel, svr_channel, range, conn_watchdo
-- handle packet
if protocol == PROTOCOL.MODBUS_TCP then
---@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 reply ---@type modbus_packet
@ -394,8 +394,10 @@ function rtu.comms(version, modem, rtu_channel, svr_channel, range, conn_watchdo
end
public.send_modbus(reply)
else
elseif not rtu_state.linked then
log.debug("discarding MODBUS packet before linked")
else
log.debug("discarding MODBUS packet from different supervisor (src_addr " .. src_addr .. "" .. self.sv_addr .. ")")
end
elseif protocol == PROTOCOL.SCADA_MGMT then
---@cast packet mgmt_frame
@ -434,7 +436,7 @@ function rtu.comms(version, modem, rtu_channel, svr_channel, range, conn_watchdo
else
log.debug("SCADA_MGMT establish packet length mismatch")
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
-- keep alive request received, echo back
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
log.debug("received unsupported SCADA_MGMT message type " .. packet.type)
end
else
elseif not rtu_state.linked then
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
else
-- should be unreachable assuming packet is from parse_packet()

View File

@ -28,7 +28,7 @@ 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 = "v1.3.3"
local RTU_VERSION = "v1.3.4"
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE