added time functions to util, also task_wait

This commit is contained in:
Mikayla Fischler
2022-04-25 10:36:47 -04:00
parent 1744527a41
commit c46a7b2486
4 changed files with 33 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
-- #REQUIRES comms.lua
-- #REQUIRES ppm.lua
-- #REQUIRES util.lua
local PROTOCOLS = comms.PROTOCOLS
local RPLC_TYPES = comms.RPLC_TYPES
@@ -272,7 +273,7 @@ function comms_init(id, modem, local_port, server_port, reactor, iss)
-- keep alive ack
local _send_keep_alive_ack = function (srv_time)
_send(RPLC_TYPES.KEEP_ALIVE, { srv_time, os.epoch() })
_send(RPLC_TYPES.KEEP_ALIVE, { srv_time, util.time() })
end
-- general ack
@@ -369,7 +370,7 @@ function comms_init(id, modem, local_port, server_port, reactor, iss)
if packet.type == RPLC_TYPES.KEEP_ALIVE then
-- keep alive request received, echo back
local timestamp = packet.data[1]
local trip_time = os.epoch() - timestamp
local trip_time = util.time() - timestamp
if trip_time < 0 then
log._warning("PLC KEEP_ALIVE trip time less than 0 (" .. trip_time .. ")")
@@ -494,7 +495,7 @@ function comms_init(id, modem, local_port, server_port, reactor, iss)
end
local sys_status = {
os.epoch(),
util.time(),
(not self.scrammed),
overridden,
degraded,