mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#65 safe concat where appropriate
This commit is contained in:
parent
5068e47590
commit
f0c97e8b70
@ -738,7 +738,7 @@ function plc.comms(id, version, modem, local_port, server_port, reactor, rps, co
|
||||
log.warning("PLC KEEP_ALIVE trip time > 500ms (" .. trip_time .. "ms)")
|
||||
end
|
||||
|
||||
-- log.debug("RPLC RTT = ".. trip_time .. "ms")
|
||||
-- log.debug("RPLC RTT = " .. trip_time .. "ms")
|
||||
|
||||
_send_keep_alive_ack(timestamp)
|
||||
else
|
||||
|
@ -383,7 +383,7 @@ function rtu.comms(version, modem, local_port, server_port, conn_watchdog)
|
||||
log.warning("RTU KEEP_ALIVE trip time > 500ms (" .. trip_time .. "ms)")
|
||||
end
|
||||
|
||||
-- log.debug("RTU RTT = ".. trip_time .. "ms")
|
||||
-- log.debug("RTU RTT = " .. trip_time .. "ms")
|
||||
|
||||
_send_keep_alive_ack(timestamp)
|
||||
else
|
||||
|
@ -102,7 +102,7 @@ for entry_idx = 1, #rtu_redstone do
|
||||
|
||||
local capabilities = {}
|
||||
|
||||
log.debug("init> starting redstone RTU I/O linking for reactor " .. io_reactor .. "...")
|
||||
log.debug(util.c("init> starting redstone RTU I/O linking for reactor ", io_reactor, "..."))
|
||||
|
||||
local continue = true
|
||||
|
||||
@ -110,7 +110,7 @@ for entry_idx = 1, #rtu_redstone do
|
||||
local unit = units[i] ---@type rtu_unit_registry_entry
|
||||
if unit.reactor == io_reactor and unit.type == rtu_t.redstone then
|
||||
-- duplicate entry
|
||||
log.warning("init> skipping definition block #" .. entry_idx .. " for reactor " .. io_reactor .. " with already defined redstone I/O")
|
||||
log.warning(util.c("init> skipping definition block #", entry_idx, " for reactor ", io_reactor, " with already defined redstone I/O"))
|
||||
continue = false
|
||||
break
|
||||
end
|
||||
@ -131,8 +131,8 @@ for entry_idx = 1, #rtu_redstone do
|
||||
end
|
||||
|
||||
if not valid then
|
||||
local message = "init> invalid redstone definition at index " .. i .. " in definition block #" .. entry_idx ..
|
||||
" (for reactor " .. io_reactor .. ")"
|
||||
local message = util.c("init> invalid redstone definition at index ", i, " in definition block #", entry_idx,
|
||||
" (for reactor ", io_reactor, ")")
|
||||
println_ts(message)
|
||||
log.warning(message)
|
||||
else
|
||||
@ -141,7 +141,7 @@ for entry_idx = 1, #rtu_redstone do
|
||||
if mode == rsio.IO_MODE.DIGITAL_IN then
|
||||
-- can't have duplicate inputs
|
||||
if util.table_contains(capabilities, conf.channel) then
|
||||
log.warning("init> skipping duplicate input for channel " .. rsio.to_string(conf.channel) .. " on side " .. conf.side)
|
||||
log.warning(util.c("init> skipping duplicate input for channel ", rsio.to_string(conf.channel), " on side ", conf.side))
|
||||
else
|
||||
rs_rtu.link_di(conf.side, conf.bundled_color)
|
||||
end
|
||||
@ -150,7 +150,7 @@ for entry_idx = 1, #rtu_redstone do
|
||||
elseif mode == rsio.IO_MODE.ANALOG_IN then
|
||||
-- can't have duplicate inputs
|
||||
if util.table_contains(capabilities, conf.channel) then
|
||||
log.warning("init> skipping duplicate input for channel " .. rsio.to_string(conf.channel) .. " on side " .. conf.side)
|
||||
log.warning(util.c("init> skipping duplicate input for channel ", rsio.to_string(conf.channel), " on side ", conf.side))
|
||||
else
|
||||
rs_rtu.link_ai(conf.side)
|
||||
end
|
||||
@ -164,8 +164,8 @@ for entry_idx = 1, #rtu_redstone do
|
||||
|
||||
table.insert(capabilities, conf.channel)
|
||||
|
||||
log.debug("init> linked redstone " .. #capabilities .. ": " .. rsio.to_string(conf.channel) .. " (" .. conf.side ..
|
||||
") for reactor " .. io_reactor)
|
||||
log.debug(util.c("init> linked redstone ", #capabilities, ": ", rsio.to_string(conf.channel), " (", conf.side, ") for reactor ",
|
||||
io_reactor))
|
||||
end
|
||||
end
|
||||
|
||||
@ -184,7 +184,7 @@ for entry_idx = 1, #rtu_redstone do
|
||||
|
||||
table.insert(units, unit)
|
||||
|
||||
log.debug("init> initialized RTU unit #" .. #units .. ": redstone_io (redstone) [1] for reactor " .. io_reactor)
|
||||
log.debug(util.c("init> initialized RTU unit #", #units, ": redstone_io (redstone) [1] for reactor ", io_reactor))
|
||||
end
|
||||
end
|
||||
|
||||
@ -193,7 +193,7 @@ for i = 1, #rtu_devices do
|
||||
local device = ppm.get_periph(rtu_devices[i].name)
|
||||
|
||||
if device == nil then
|
||||
local message = "init> '" .. rtu_devices[i].name .. "' not found"
|
||||
local message = util.c("init> '", rtu_devices[i].name, "' not found")
|
||||
println_ts(message)
|
||||
log.warning(message)
|
||||
else
|
||||
@ -231,7 +231,7 @@ for i = 1, #rtu_devices do
|
||||
rtu_type = rtu_t.env_detector
|
||||
rtu_iface = envd_rtu.new(device)
|
||||
else
|
||||
local message = "init> device '" .. rtu_devices[i].name .. "' is not a known type (" .. type .. ")"
|
||||
local message = util.c("init> device '", rtu_devices[i].name, "' is not a known type (", type, ")")
|
||||
println_ts(message)
|
||||
log.warning(message)
|
||||
end
|
||||
@ -254,8 +254,8 @@ for i = 1, #rtu_devices do
|
||||
|
||||
table.insert(units, rtu_unit)
|
||||
|
||||
log.debug("init> initialized RTU unit #" .. #units .. ": " .. rtu_devices[i].name .. " (" .. rtu_type .. ") [" ..
|
||||
rtu_devices[i].index .. "] for reactor " .. rtu_devices[i].for_reactor)
|
||||
log.debug(util.c("init> initialized RTU unit #", #units, ": ", rtu_devices[i].name, " (", rtu_type, ") [",
|
||||
rtu_devices[i].index, "] for reactor ", rtu_devices[i].for_reactor))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -307,7 +307,7 @@ function threads.thread__unit_comms(smem, unit)
|
||||
end
|
||||
|
||||
if not rtu_state.shutdown then
|
||||
log.info("rtu unit thread " .. unit.name .. "(" .. unit.type .. ") restarting in 5 seconds...")
|
||||
log.info(util.c("rtu unit thread ", unit.name, "(", unit.type, ") restarting in 5 seconds..."))
|
||||
util.psleep(5)
|
||||
end
|
||||
end
|
||||
|
@ -107,7 +107,7 @@ function crypto.encrypt(plaintext)
|
||||
local ciphertext = c_eng.cipher.asHex() ---@type hex
|
||||
|
||||
log.debug("crypto.encrypt: aes128-ctr-mode took " .. (util.time() - start) .. "ms")
|
||||
log.debug("ciphertext: " .. ciphertext)
|
||||
log.debug("ciphertext: " .. util.strval(ciphertext))
|
||||
|
||||
return iv, ciphertext
|
||||
end
|
||||
@ -129,7 +129,7 @@ function crypto.decrypt(iv, ciphertext)
|
||||
local plaintext = stream.toString(stream.fromHex(plaintext_hex))
|
||||
|
||||
log.debug("crypto.decrypt: aes128-ctr-mode took " .. (util.time() - start) .. "ms")
|
||||
log.debug("plaintext: " .. plaintext)
|
||||
log.debug("plaintext: " .. util.strval(plaintext))
|
||||
|
||||
return plaintext
|
||||
end
|
||||
@ -146,7 +146,7 @@ function crypto.hmac(message_hex)
|
||||
local hash = c_eng.hmac.asHex() ---@type hex
|
||||
|
||||
log.debug("crypto.hmac: hmac-sha1 took " .. (util.time() - start) .. "ms")
|
||||
log.debug("hmac: " .. hash)
|
||||
log.debug("hmac: " .. util.strval(hash))
|
||||
|
||||
return hash
|
||||
end
|
||||
|
@ -177,7 +177,7 @@ function log.dmesg(msg, tag, tag_color)
|
||||
out.write(lines[i])
|
||||
end
|
||||
|
||||
_log("[" .. t_stamp .. "] " .. tag .. " " .. msg)
|
||||
_log(util.c("[", t_stamp, "] ", tag, " ", msg))
|
||||
end
|
||||
|
||||
-- log debug messages
|
||||
|
@ -2,7 +2,8 @@
|
||||
-- Protected Peripheral Manager
|
||||
--
|
||||
|
||||
local log = require("scada-common.log")
|
||||
local log = require("scada-common.log")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
---@class ppm
|
||||
local ppm = {}
|
||||
@ -76,7 +77,7 @@ local function peri_init(iface)
|
||||
count_str = " [" .. self.fault_counts[key] .. " total faults]"
|
||||
end
|
||||
|
||||
log.error("PPM: protected " .. key .. "() -> " .. result .. count_str)
|
||||
log.error(util.c("PPM: protected ", key, "() -> ", result, count_str))
|
||||
end
|
||||
|
||||
self.fault_counts[key] = self.fault_counts[key] + 1
|
||||
@ -176,7 +177,7 @@ function ppm.mount_all()
|
||||
for i = 1, #ifaces do
|
||||
_ppm_sys.mounts[ifaces[i]] = peri_init(ifaces[i])
|
||||
|
||||
log.info("PPM: found a " .. _ppm_sys.mounts[ifaces[i]].type .. " (" .. ifaces[i] .. ")")
|
||||
log.info(util.c("PPM: found a ", _ppm_sys.mounts[ifaces[i]].type, " (", ifaces[i], ")"))
|
||||
end
|
||||
|
||||
if #ifaces == 0 then
|
||||
@ -199,7 +200,7 @@ function ppm.mount(iface)
|
||||
pm_type = _ppm_sys.mounts[iface].type
|
||||
pm_dev = _ppm_sys.mounts[iface].dev
|
||||
|
||||
log.info("PPM: mount(" .. iface .. ") -> found a " .. pm_type)
|
||||
log.info(util.c("PPM: mount(", iface, ") -> found a ", pm_type))
|
||||
break
|
||||
end
|
||||
end
|
||||
@ -221,9 +222,9 @@ function ppm.handle_unmount(iface)
|
||||
pm_type = lost_dev.type
|
||||
pm_dev = lost_dev.dev
|
||||
|
||||
log.warning("PPM: lost device " .. pm_type .. " mounted to " .. iface)
|
||||
log.warning(util.c("PPM: lost device ", pm_type, " mounted to ", iface))
|
||||
else
|
||||
log.error("PPM: lost device unknown to the PPM mounted to " .. iface)
|
||||
log.error(util.c("PPM: lost device unknown to the PPM mounted to ", iface))
|
||||
end
|
||||
|
||||
return pm_type, pm_dev
|
||||
|
@ -391,8 +391,8 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
|
||||
log.warning(log_header .. "PLC KEEP_ALIVE round trip time > 500ms (" .. self.last_rtt .. "ms)")
|
||||
end
|
||||
|
||||
-- log.debug(log_header .. "PLC RTT = ".. self.last_rtt .. "ms")
|
||||
-- log.debug(log_header .. "PLC TT = ".. (srv_now - plc_send) .. "ms")
|
||||
-- log.debug(log_header .. "PLC RTT = " .. self.last_rtt .. "ms")
|
||||
-- log.debug(log_header .. "PLC TT = " .. (srv_now - plc_send) .. "ms")
|
||||
else
|
||||
log.debug(log_header .. "SCADA keep alive packet length mismatch")
|
||||
end
|
||||
|
@ -235,8 +235,8 @@ function rtu.new_session(id, in_queue, out_queue, advertisement)
|
||||
log.warning(log_header .. "RTU KEEP_ALIVE round trip time > 500ms (" .. self.last_rtt .. "ms)")
|
||||
end
|
||||
|
||||
-- log.debug(log_header .. "RTU RTT = ".. self.last_rtt .. "ms")
|
||||
-- log.debug(log_header .. "RTU TT = ".. (srv_now - rtu_send) .. "ms")
|
||||
-- log.debug(log_header .. "RTU RTT = " .. self.last_rtt .. "ms")
|
||||
-- log.debug(log_header .. "RTU TT = " .. (srv_now - rtu_send) .. "ms")
|
||||
else
|
||||
log.debug(log_header .. "SCADA keep alive packet length mismatch")
|
||||
end
|
||||
|
@ -104,7 +104,7 @@ function redstone.new(session_id, unit_id, advert, out_queue)
|
||||
table.insert(self.io_list.analog_out, channel)
|
||||
else
|
||||
-- should be unreachable code, we already validated channels
|
||||
log.error(log_tag .. "failed to identify advertisement channel IO mode (" .. channel .. ")", true)
|
||||
log.error(util.c(log_tag, "failed to identify advertisement channel IO mode (", channel, ")"), true)
|
||||
return nil
|
||||
end
|
||||
|
||||
@ -212,8 +212,8 @@ function redstone.new(session_id, unit_id, advert, out_queue)
|
||||
break
|
||||
end
|
||||
end
|
||||
elseif mode ~= nil then
|
||||
log.debug(log_tag .. "attemted write to non D/O or A/O mode " .. mode)
|
||||
else
|
||||
log.debug(util.c(log_tag, "attemted write to non D/O or A/O mode ", mode))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -237,7 +237,7 @@ function turbinev.new(session_id, unit_id, advert, out_queue)
|
||||
elseif cmd == TBV_RTU_S_CMDS.DEC_DUMP_MODE then
|
||||
_dec_dump_mode()
|
||||
else
|
||||
log.debug(log_tag .. "unrecognized in_q command " .. util.strval(cmd))
|
||||
log.debug(util.c(log_tag, "unrecognized in_q command ", cmd))
|
||||
end
|
||||
elseif msg.qtype == mqueue.TYPE.DATA then
|
||||
-- instruction with body
|
||||
@ -245,7 +245,7 @@ function turbinev.new(session_id, unit_id, advert, out_queue)
|
||||
if cmd.key == TBV_RTU_S_DATA.SET_DUMP_MODE then
|
||||
_set_dump_mode(cmd.val)
|
||||
else
|
||||
log.debug(log_tag .. "unrecognized in_q data " .. util.strval(cmd.key))
|
||||
log.debug(util.c(log_tag, "unrecognized in_q data ", cmd.key))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -187,11 +187,11 @@ function supervisor.comms(version, num_reactors, modem, dev_listen, coord_listen
|
||||
local plc_id = svsessions.establish_plc_session(l_port, r_port, packet.data[1], packet.data[2])
|
||||
if plc_id == false then
|
||||
-- reactor already has a PLC assigned
|
||||
log.debug("PLC_LNK: assignment collision with reactor " .. packet.data[1])
|
||||
log.debug(util.c("PLC_LNK: assignment collision with reactor ", packet.data[1]))
|
||||
_send_plc_linking(next_seq_id, r_port, { RPLC_LINKING.COLLISION })
|
||||
else
|
||||
-- got an ID; assigned to a reactor successfully
|
||||
println("connected to reactor " .. packet.data[1] .. " PLC (" .. packet.data[2] .. ") [:" .. r_port .. "]")
|
||||
println(util.c("connected to reactor ", packet.data[1], " PLC (", packet.data[2], ") [:", r_port, "]"))
|
||||
log.debug("PLC_LNK: allowed for device at " .. r_port)
|
||||
_send_plc_linking(next_seq_id, r_port, { RPLC_LINKING.ALLOW })
|
||||
end
|
||||
@ -215,7 +215,7 @@ function supervisor.comms(version, num_reactors, modem, dev_listen, coord_listen
|
||||
elseif packet.type == SCADA_MGMT_TYPES.RTU_ADVERT then
|
||||
if packet.length >= 1 then
|
||||
-- this is an RTU advertisement for a new session
|
||||
println("connected to RTU (" .. packet.data[1] .. ") [:" .. r_port .. "]")
|
||||
println(util.c("connected to RTU (", packet.data[1], ") [:", r_port, "]"))
|
||||
|
||||
svsessions.establish_rtu_session(l_port, r_port, packet.data)
|
||||
|
||||
@ -244,7 +244,7 @@ function supervisor.comms(version, num_reactors, modem, dev_listen, coord_listen
|
||||
log.debug("illegal packet type " .. protocol .. " on coordinator listening channel")
|
||||
end
|
||||
else
|
||||
log.error("received packet on unused channel " .. l_port, true)
|
||||
log.warning("received packet on unused channel " .. l_port)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user