From 17d0213d58bbb1cadf1fce67ca4f81df1c82d595 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Fri, 22 Apr 2022 10:58:18 -0400 Subject: [PATCH] RTU/PPM bugfixes --- reactor-plc/plc.lua | 10 ---------- reactor-plc/startup.lua | 2 +- rtu/startup.lua | 4 ++-- scada-common/ppm.lua | 14 +++++++++----- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/reactor-plc/plc.lua b/reactor-plc/plc.lua index 5c50065..c7a6346 100644 --- a/reactor-plc/plc.lua +++ b/reactor-plc/plc.lua @@ -326,16 +326,6 @@ function comms_init(id, modem, local_port, server_port, reactor, iss) end end - local _send_iss_status = function () - local iss_status = { - id = self.id, - type = RPLC_TYPES.ISS_STATUS, - status = iss.status() - } - - _send(iss_status) - end - -- PUBLIC FUNCTIONS -- -- reconnect a newly connected modem diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index b57845c..d413684 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -10,7 +10,7 @@ os.loadAPI("scada-common/comms.lua") os.loadAPI("config.lua") os.loadAPI("plc.lua") -local R_PLC_VERSION = "alpha-v0.2.3" +local R_PLC_VERSION = "alpha-v0.2.4" local print = util.print local println = util.println diff --git a/rtu/startup.lua b/rtu/startup.lua index 0074625..42779c6 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -17,7 +17,7 @@ os.loadAPI("dev/boiler_rtu.lua") os.loadAPI("dev/imatrix_rtu.lua") os.loadAPI("dev/turbine_rtu.lua") -local RTU_VERSION = "alpha-v0.2.2" +local RTU_VERSION = "alpha-v0.2.3" local print = util.print local println = util.println @@ -185,7 +185,7 @@ while true do for i = 1, #units do -- find disconnected device - if units[i].device == device then + if units[i].device == device.dev then -- we are going to let the PPM prevent crashes -- return fault flags/codes to MODBUS queries local unit = units[i] diff --git a/scada-common/ppm.lua b/scada-common/ppm.lua index f751342..66f26a7 100644 --- a/scada-common/ppm.lua +++ b/scada-common/ppm.lua @@ -116,7 +116,7 @@ function mount_all() dev = pm_dev } - log._debug("PPM: found a " .. self.mounts[ifaces[i]].type .. " (" .. ifaces[i] .. ")") + log._info("PPM: found a " .. self.mounts[ifaces[i]].type .. " (" .. ifaces[i] .. ")") end if #ifaces == 0 then @@ -132,7 +132,7 @@ function mount(iface) for i = 1, #ifaces do if iface == ifaces[i] then - log._debug("PPM: mount(" .. iface .. ") -> found a " .. peripheral.getType(iface)) + log._info("PPM: mount(" .. iface .. ") -> found a " .. peripheral.getType(iface)) type = peripheral.getType(iface) pm_dev = peripheral.wrap(iface) @@ -153,9 +153,13 @@ end function handle_unmount(iface) -- what got disconnected? local lost_dev = self.mounts[iface] - local type = lost_dev.type - - log._warning("PPM: lost device " .. type .. " mounted to " .. iface) + + if lost_dev then + local type = lost_dev.type + log._warning("PPM: lost device " .. type .. " mounted to " .. iface) + else + log._error("PPM: lost device unknown to the PPM mounted to " .. iface) + end return lost_dev end