check if interface exists before trying to get its device or type
This commit is contained in:
@@ -10,7 +10,7 @@ os.loadAPI("scada-common/comms.lua")
|
|||||||
os.loadAPI("config.lua")
|
os.loadAPI("config.lua")
|
||||||
os.loadAPI("plc.lua")
|
os.loadAPI("plc.lua")
|
||||||
|
|
||||||
local R_PLC_VERSION = "alpha-v0.2.2"
|
local R_PLC_VERSION = "alpha-v0.2.3"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ os.loadAPI("dev/boiler_rtu.lua")
|
|||||||
os.loadAPI("dev/imatrix_rtu.lua")
|
os.loadAPI("dev/imatrix_rtu.lua")
|
||||||
os.loadAPI("dev/turbine_rtu.lua")
|
os.loadAPI("dev/turbine_rtu.lua")
|
||||||
|
|
||||||
local RTU_VERSION = "alpha-v0.2.1"
|
local RTU_VERSION = "alpha-v0.2.2"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
|||||||
@@ -174,12 +174,16 @@ end
|
|||||||
|
|
||||||
-- get a mounted peripheral by side/interface
|
-- get a mounted peripheral by side/interface
|
||||||
function get_periph(iface)
|
function get_periph(iface)
|
||||||
return self.mounts[iface].dev
|
if self.mounts[iface] then
|
||||||
|
return self.mounts[iface].dev
|
||||||
|
else return nil end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get a mounted peripheral type by side/interface
|
-- get a mounted peripheral type by side/interface
|
||||||
function get_type(iface)
|
function get_type(iface)
|
||||||
return self.mounts[iface].type
|
if self.mounts[iface] then
|
||||||
|
return self.mounts[iface].type
|
||||||
|
else return nil end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get all mounted peripherals by type
|
-- get all mounted peripherals by type
|
||||||
|
|||||||
Reference in New Issue
Block a user