mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#164 reporting comms version mismatches
This commit is contained in:
parent
2babd67198
commit
5e65ca636e
@ -204,7 +204,8 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, range
|
|||||||
sv_seq_num = 0,
|
sv_seq_num = 0,
|
||||||
sv_r_seq_num = nil,
|
sv_r_seq_num = nil,
|
||||||
modem = modem,
|
modem = modem,
|
||||||
connected = false
|
connected = false,
|
||||||
|
last_est_ack = ESTABLISH_ACK.ALLOW
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class coord_comms
|
---@class coord_comms
|
||||||
@ -312,6 +313,16 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, range
|
|||||||
|
|
||||||
if terminated then
|
if terminated then
|
||||||
coordinator.log_comms("supervisor connection attempt cancelled by user")
|
coordinator.log_comms("supervisor connection attempt cancelled by user")
|
||||||
|
elseif not self.sv_linked then
|
||||||
|
if self.last_est_ack == ESTABLISH_ACK.DENY then
|
||||||
|
coordinator.log_comms("supervisor connection attempt denied")
|
||||||
|
elseif self.last_est_ack == ESTABLISH_ACK.COLLISION then
|
||||||
|
coordinator.log_comms("supervisor connection failed due to collision")
|
||||||
|
elseif self.last_est_ack == ESTABLISH_ACK.BAD_VERSION then
|
||||||
|
coordinator.log_comms("supervisor connection failed due to version mismatch")
|
||||||
|
else
|
||||||
|
coordinator.log_comms("supervisor connection failed with no valid response")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self.sv_linked
|
return self.sv_linked
|
||||||
@ -538,12 +549,30 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, range
|
|||||||
log.error("invalid supervisor configuration table received, establish failed")
|
log.error("invalid supervisor configuration table received, establish failed")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
log.debug("SCADA_MGMT establish packet reply (len = 2) unsupported")
|
||||||
|
end
|
||||||
|
|
||||||
|
self.last_est_ack = est_ack
|
||||||
|
elseif packet.length == 1 then
|
||||||
|
local est_ack = packet.data[1]
|
||||||
|
|
||||||
|
if est_ack == ESTABLISH_ACK.DENY then
|
||||||
|
if self.last_est_ack ~= est_ack then
|
||||||
log.debug("supervisor connection denied")
|
log.debug("supervisor connection denied")
|
||||||
end
|
end
|
||||||
elseif packet.length == 1 and packet.data[1] == ESTABLISH_ACK.DENY then
|
elseif est_ack == ESTABLISH_ACK.COLLISION then
|
||||||
log.debug("supervisor connection denied")
|
if self.last_est_ack ~= est_ack then
|
||||||
elseif packet.length == 1 and packet.data[1] == ESTABLISH_ACK.COLLISION then
|
|
||||||
log.debug("supervisor connection denied due to collision")
|
log.debug("supervisor connection denied due to collision")
|
||||||
|
end
|
||||||
|
elseif est_ack == ESTABLISH_ACK.BAD_VERSION then
|
||||||
|
if self.last_est_ack ~= est_ack then
|
||||||
|
log.info("supervisor comms version mismatch")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
log.debug("SCADA_MGMT establish packet reply (len = 1) unsupported")
|
||||||
|
end
|
||||||
|
|
||||||
|
self.last_est_ack = est_ack
|
||||||
else
|
else
|
||||||
log.debug("SCADA_MGMT establish packet length mismatch")
|
log.debug("SCADA_MGMT establish packet length mismatch")
|
||||||
end
|
end
|
||||||
|
@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
|
|||||||
local renderer = require("coordinator.renderer")
|
local renderer = require("coordinator.renderer")
|
||||||
local sounder = require("coordinator.sounder")
|
local sounder = require("coordinator.sounder")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "beta-v0.9.13"
|
local COORDINATOR_VERSION = "beta-v0.9.14"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
@ -167,7 +167,7 @@ local function main()
|
|||||||
|
|
||||||
-- attempt to establish a connection with the supervisory computer
|
-- attempt to establish a connection with the supervisory computer
|
||||||
if not coord_comms.sv_connect(60, tick_waiting, task_done) then
|
if not coord_comms.sv_connect(60, tick_waiting, task_done) then
|
||||||
log_comms("supervisor connection failed")
|
log_sys("supervisor connection failed, shutting down...")
|
||||||
log.fatal("failed to connect to supervisor")
|
log.fatal("failed to connect to supervisor")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -421,6 +421,7 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
|
|||||||
reactor = reactor,
|
reactor = reactor,
|
||||||
scrammed = false,
|
scrammed = false,
|
||||||
linked = false,
|
linked = false,
|
||||||
|
last_est_ack = ESTABLISH_ACK.ALLOW,
|
||||||
resend_build = false,
|
resend_build = false,
|
||||||
auto_ack_token = 0,
|
auto_ack_token = 0,
|
||||||
status_cache = nil,
|
status_cache = nil,
|
||||||
@ -917,12 +918,18 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
|
|||||||
elseif est_ack == ESTABLISH_ACK.COLLISION then
|
elseif est_ack == ESTABLISH_ACK.COLLISION then
|
||||||
println_ts("received unsolicited link collision, unlinking")
|
println_ts("received unsolicited link collision, unlinking")
|
||||||
log.warning("unsolicited establish request collision")
|
log.warning("unsolicited establish request collision")
|
||||||
|
elseif est_ack == ESTABLISH_ACK.BAD_VERSION then
|
||||||
|
println_ts("received unsolicited link version mismatch, unlinking")
|
||||||
|
log.warning("unsolicited establish request version mismatch")
|
||||||
else
|
else
|
||||||
println_ts("invalid unsolicited link response")
|
println_ts("invalid unsolicited link response")
|
||||||
log.error("unsolicited unknown establish request response")
|
log.error("unsolicited unknown establish request response")
|
||||||
end
|
end
|
||||||
|
|
||||||
self.linked = est_ack == ESTABLISH_ACK.ALLOW
|
self.linked = est_ack == ESTABLISH_ACK.ALLOW
|
||||||
|
|
||||||
|
-- clear this since this is for something that was unsolicited
|
||||||
|
self.last_est_ack = ESTABLISH_ACK.ALLOW
|
||||||
else
|
else
|
||||||
log.debug("SCADA_MGMT establish packet length mismatch")
|
log.debug("SCADA_MGMT establish packet length mismatch")
|
||||||
end
|
end
|
||||||
@ -968,18 +975,24 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
|
|||||||
public.send_status(plc_state.no_reactor, plc_state.reactor_formed)
|
public.send_status(plc_state.no_reactor, plc_state.reactor_formed)
|
||||||
|
|
||||||
log.debug("sent initial status data")
|
log.debug("sent initial status data")
|
||||||
elseif est_ack == ESTABLISH_ACK.DENY then
|
elseif self.last_est_ack ~= est_ack then
|
||||||
|
if est_ack == ESTABLISH_ACK.DENY then
|
||||||
println_ts("link request denied, retrying...")
|
println_ts("link request denied, retrying...")
|
||||||
log.debug("establish request denied")
|
log.debug("establish request denied")
|
||||||
elseif est_ack == ESTABLISH_ACK.COLLISION then
|
elseif est_ack == ESTABLISH_ACK.COLLISION then
|
||||||
println_ts("reactor PLC ID collision (check config), retrying...")
|
println_ts("reactor PLC ID collision (check config), retrying...")
|
||||||
log.warning("establish request collision")
|
log.warning("establish request collision")
|
||||||
|
elseif est_ack == ESTABLISH_ACK.BAD_VERSION then
|
||||||
|
println_ts("supervisor version mismatch (try updating), retrying...")
|
||||||
|
log.warning("establish request version mismatch")
|
||||||
else
|
else
|
||||||
println_ts("invalid link response, bad channel? retrying...")
|
println_ts("invalid link response, bad channel? retrying...")
|
||||||
log.error("unknown establish request response")
|
log.error("unknown establish request response")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.linked = est_ack == ESTABLISH_ACK.ALLOW
|
self.linked = est_ack == ESTABLISH_ACK.ALLOW
|
||||||
|
self.last_est_ack = est_ack
|
||||||
else
|
else
|
||||||
log.debug("SCADA_MGMT establish packet length mismatch")
|
log.debug("SCADA_MGMT establish packet length mismatch")
|
||||||
end
|
end
|
||||||
|
@ -14,7 +14,7 @@ local config = require("reactor-plc.config")
|
|||||||
local plc = require("reactor-plc.plc")
|
local plc = require("reactor-plc.plc")
|
||||||
local threads = require("reactor-plc.threads")
|
local threads = require("reactor-plc.threads")
|
||||||
|
|
||||||
local R_PLC_VERSION = "beta-v0.10.10"
|
local R_PLC_VERSION = "beta-v0.10.11"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
20
rtu/rtu.lua
20
rtu/rtu.lua
@ -175,7 +175,8 @@ function rtu.comms(version, modem, local_port, server_port, range, conn_watchdog
|
|||||||
modem = modem,
|
modem = modem,
|
||||||
s_port = server_port,
|
s_port = server_port,
|
||||||
l_port = local_port,
|
l_port = local_port,
|
||||||
conn_watchdog = conn_watchdog
|
conn_watchdog = conn_watchdog,
|
||||||
|
last_est_ack = ESTABLISH_ACK.ALLOW
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class rtu_comms
|
---@class rtu_comms
|
||||||
@ -414,10 +415,21 @@ function rtu.comms(version, modem, local_port, server_port, range, conn_watchdog
|
|||||||
log.info("supervisor connection established")
|
log.info("supervisor connection established")
|
||||||
else
|
else
|
||||||
-- establish denied
|
-- establish denied
|
||||||
public.unlink(rtu_state)
|
if est_ack ~= self.last_est_ack then
|
||||||
println_ts("supervisor connection denied")
|
if est_ack == ESTABLISH_ACK.BAD_VERSION then
|
||||||
log.warning("supervisor connection denied by remote host")
|
-- version mismatch
|
||||||
|
println_ts("supervisor comms version mismatch (try updating), retrying...")
|
||||||
|
log.warning("supervisor connection denied due to comms version mismatch")
|
||||||
|
else
|
||||||
|
println_ts("supervisor connection denied, retrying...")
|
||||||
|
log.warning("supervisor connection denied")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
public.unlink(rtu_state)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.last_est_ack = est_ack
|
||||||
else
|
else
|
||||||
log.debug("SCADA_MGMT establish packet length mismatch")
|
log.debug("SCADA_MGMT establish packet length mismatch")
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
|||||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||||
|
|
||||||
local RTU_VERSION = "beta-v0.10.5"
|
local RTU_VERSION = "beta-v0.10.6"
|
||||||
|
|
||||||
local rtu_t = types.rtu_t
|
local rtu_t = types.rtu_t
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ local insert = table.insert
|
|||||||
|
|
||||||
local max_distance = nil
|
local max_distance = nil
|
||||||
|
|
||||||
comms.version = "1.3.2"
|
comms.version = "1.3.3"
|
||||||
|
|
||||||
---@alias PROTOCOLS integer
|
---@alias PROTOCOLS integer
|
||||||
local PROTOCOLS = {
|
local PROTOCOLS = {
|
||||||
@ -68,7 +68,8 @@ local CAPI_TYPES = {
|
|||||||
local ESTABLISH_ACK = {
|
local ESTABLISH_ACK = {
|
||||||
ALLOW = 0, -- link approved
|
ALLOW = 0, -- link approved
|
||||||
DENY = 1, -- link denied
|
DENY = 1, -- link denied
|
||||||
COLLISION = 2 -- link denied due to existing active link
|
COLLISION = 2, -- link denied due to existing active link
|
||||||
|
BAD_VERSION = 3 -- link denied due to comms version mismatch
|
||||||
}
|
}
|
||||||
|
|
||||||
---@alias DEVICE_TYPES integer
|
---@alias DEVICE_TYPES integer
|
||||||
|
@ -14,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions")
|
|||||||
local config = require("supervisor.config")
|
local config = require("supervisor.config")
|
||||||
local supervisor = require("supervisor.supervisor")
|
local supervisor = require("supervisor.supervisor")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "beta-v0.11.8"
|
local SUPERVISOR_VERSION = "beta-v0.11.9"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
@ -170,8 +170,8 @@ function supervisor.comms(version, num_reactors, cooling_conf, modem, dev_listen
|
|||||||
session.in_queue.push_packet(packet)
|
session.in_queue.push_packet(packet)
|
||||||
else
|
else
|
||||||
-- unknown session, force a re-link
|
-- unknown session, force a re-link
|
||||||
log.debug("PLC_EST: no session but not an establish, force relink")
|
log.debug("PLC_ESTABLISH: no session but not an establish, forcing relink")
|
||||||
_send_dev_establish((packet.scada_frame.seq_num() + 1), r_port, { ESTABLISH_ACK.DENY })
|
_send_dev_establish(packet.scada_frame.seq_num() + 1, r_port, { ESTABLISH_ACK.DENY })
|
||||||
end
|
end
|
||||||
elseif protocol == PROTOCOLS.SCADA_MGMT then
|
elseif protocol == PROTOCOLS.SCADA_MGMT then
|
||||||
-- look for an associated session
|
-- look for an associated session
|
||||||
@ -194,7 +194,7 @@ function supervisor.comms(version, num_reactors, cooling_conf, modem, dev_listen
|
|||||||
if comms_v ~= comms.version then
|
if comms_v ~= comms.version then
|
||||||
log.debug(util.c("dropping establish packet with incorrect comms version v", comms_v,
|
log.debug(util.c("dropping establish packet with incorrect comms version v", comms_v,
|
||||||
" (expected v", comms.version, ")"))
|
" (expected v", comms.version, ")"))
|
||||||
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.DENY })
|
_send_dev_establish(next_seq_id, r_port, { ESTABLISH_ACK.BAD_VERSION })
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ function supervisor.comms(version, num_reactors, cooling_conf, modem, dev_listen
|
|||||||
if comms_v ~= comms.version then
|
if comms_v ~= comms.version then
|
||||||
log.debug(util.c("dropping establish packet with incorrect comms version v", comms_v,
|
log.debug(util.c("dropping establish packet with incorrect comms version v", comms_v,
|
||||||
" (expected v", comms.version, ")"))
|
" (expected v", comms.version, ")"))
|
||||||
_send_crdn_establish(next_seq_id, r_port, { ESTABLISH_ACK.DENY })
|
_send_crdn_establish(next_seq_id, r_port, { ESTABLISH_ACK.BAD_VERSION })
|
||||||
return
|
return
|
||||||
elseif dev_type ~= DEVICE_TYPES.CRDN then
|
elseif dev_type ~= DEVICE_TYPES.CRDN then
|
||||||
log.debug(util.c("illegal establish packet for device ", dev_type, " on CRDN listening channel"))
|
log.debug(util.c("illegal establish packet for device ", dev_type, " on CRDN listening channel"))
|
||||||
|
Loading…
Reference in New Issue
Block a user