From 5cff346cb55085909d239cfce2c2c7ff47f5b542 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Thu, 10 Mar 2022 14:21:03 -0500 Subject: [PATCH] ppm function renames, edited log messages, and changed protected calls to return true if function has no return --- scada-common/ppm.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scada-common/ppm.lua b/scada-common/ppm.lua index 2eaa9ab..4b9e2f1 100644 --- a/scada-common/ppm.lua +++ b/scada-common/ppm.lua @@ -16,10 +16,15 @@ local peri_init = function (device) local status, result = pcall(func, ...) if status then - return result + -- assume nil is only for functions with no return, so return status + if result == nil then + return true + else + return result + end else -- function failed - log._error("protected " .. key .. "() -> " .. result) + log._error("PPM: protected " .. key .. "() -> " .. result) return nil end end @@ -37,6 +42,10 @@ function mount_all() peri_init(pm_dev) self.mounts[ifaces[i]] = { peripheral.getType(ifaces[i]), pm_dev } end + + if #ifaces == 0 then + log._warning("PPM: mount_all() -> no devices found") + end end -- mount a particular device @@ -61,12 +70,12 @@ function mount(name) end -- handle peripheral_detach event -function unmount_handler(iface) +function handle_unmount(iface) -- what got disconnected? local lost_dev = self.mounts[iface] local type = lost_dev.type - log._warning("PMGR: lost device " .. type .. " mounted to " .. iface) + log._warning("PPM: lost device " .. type .. " mounted to " .. iface) return self.mounts[iface] end