mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#270 validate reactor PLC status packet types
This commit is contained in:
parent
ab193db153
commit
59eac62c33
File diff suppressed because one or more lines are too long
@ -313,17 +313,19 @@ function plc.new_session(id, s_addr, reactor_id, in_queue, out_queue, timeout, f
|
|||||||
if pkt.type == RPLC_TYPE.STATUS then
|
if pkt.type == RPLC_TYPE.STATUS then
|
||||||
-- status packet received, update data
|
-- status packet received, update data
|
||||||
if pkt.length >= 5 then
|
if pkt.length >= 5 then
|
||||||
|
if (type(pkt.data[1]) == "number") and (type(pkt.data[2]) == "boolean") and (type(pkt.data[3]) == "boolean") and
|
||||||
|
(type(pkt.data[4]) == "boolean") and (type(pkt.data[5]) == "number") then
|
||||||
self.sDB.last_status_update = pkt.data[1]
|
self.sDB.last_status_update = pkt.data[1]
|
||||||
self.sDB.control_state = pkt.data[2]
|
self.sDB.control_state = pkt.data[2]
|
||||||
self.sDB.no_reactor = pkt.data[3]
|
self.sDB.no_reactor = pkt.data[3]
|
||||||
self.sDB.formed = pkt.data[4]
|
self.sDB.formed = pkt.data[4]
|
||||||
self.sDB.auto_ack_token = pkt.data[5]
|
self.sDB.auto_ack_token = pkt.data[5]
|
||||||
|
|
||||||
if not self.sDB.no_reactor and self.sDB.formed then
|
if (not self.sDB.no_reactor) and self.sDB.formed and (type(pkt.data[6]) == "number") then
|
||||||
self.sDB.mek_status.heating_rate = pkt.data[6] or 0.0
|
self.sDB.mek_status.heating_rate = pkt.data[6] or 0.0
|
||||||
|
|
||||||
-- attempt to read mek_data table
|
-- attempt to read mek_data table
|
||||||
if pkt.data[7] ~= nil then
|
if type(pkt.data[7]) == "table" then
|
||||||
local status = pcall(_copy_status, pkt.data[7])
|
local status = pcall(_copy_status, pkt.data[7])
|
||||||
if status then
|
if status then
|
||||||
-- copied in status data OK
|
-- copied in status data OK
|
||||||
@ -334,6 +336,9 @@ function plc.new_session(id, s_addr, reactor_id, in_queue, out_queue, timeout, f
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
log.debug(log_header .. "RPLC status packet invalid")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
log.debug(log_header .. "RPLC status packet length mismatch")
|
log.debug(log_header .. "RPLC status packet length mismatch")
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor")
|
|||||||
|
|
||||||
local svsessions = require("supervisor.session.svsessions")
|
local svsessions = require("supervisor.session.svsessions")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "v0.19.0"
|
local SUPERVISOR_VERSION = "v0.19.1"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user