mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#41 RTU comms closing
This commit is contained in:
parent
5ce3f84dfa
commit
4bc50e4bad
12
rtu/rtu.lua
12
rtu/rtu.lua
@ -249,6 +249,10 @@ function rtu_comms(modem, local_port, server_port)
|
||||
send_modbus(reply)
|
||||
elseif protocol == PROTOCOLS.SCADA_MGMT then
|
||||
-- SCADA management packet
|
||||
if packet.type == SCADA_MGMT_TYPES.CLOSE then
|
||||
-- close connection
|
||||
conn_watchdog.cancel()
|
||||
unlink(rtu_state)
|
||||
if packet.type == SCADA_MGMT_TYPES.REMOTE_LINKED then
|
||||
-- acknowledgement
|
||||
rtu_state.linked = true
|
||||
@ -317,6 +321,11 @@ function rtu_comms(modem, local_port, server_port)
|
||||
self.r_seq_num = nil
|
||||
end
|
||||
|
||||
local close = function (rtu_state)
|
||||
unlink(rtu_state)
|
||||
_send(SCADA_MGMT_TYPES.CLOSE, {})
|
||||
end
|
||||
|
||||
return {
|
||||
send_modbus = send_modbus,
|
||||
reconnect_modem = reconnect_modem,
|
||||
@ -324,6 +333,7 @@ function rtu_comms(modem, local_port, server_port)
|
||||
handle_packet = handle_packet,
|
||||
send_advertisement = send_advertisement,
|
||||
send_heartbeat = send_heartbeat,
|
||||
unlink = unlink
|
||||
unlink = unlink,
|
||||
close = close
|
||||
}
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ os.loadAPI("dev/boiler_rtu.lua")
|
||||
os.loadAPI("dev/imatrix_rtu.lua")
|
||||
os.loadAPI("dev/turbine_rtu.lua")
|
||||
|
||||
local RTU_VERSION = "alpha-v0.4.9"
|
||||
local RTU_VERSION = "alpha-v0.4.10"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
@ -169,6 +169,7 @@ function thread__comms(smem)
|
||||
|
||||
-- check for termination request
|
||||
if rtu_state.shutdown then
|
||||
rtu_comms.close()
|
||||
log._info("comms thread exiting")
|
||||
break
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user