Skip to content

Commit

Permalink
Merge branch 'wlua-show-date-time' into simon-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
shancock884 committed Sep 26, 2023
2 parents b86a76f + 2b32263 commit 6c4c9c3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions generator/mavgen_wlua.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,18 @@ def generate_preamble(outf):
end
local signature_time_ref = get_timezone() + os.time{year=2015, month=1, day=1, hour=0}
time_usec_threshold = UInt64.new(0,4096)
-- threshold to decide if time is absolute or relative (roughly 13.5 months from epoch)
time_usec_threshold = UInt64.new(0,8192)
-- function to append human-readable time onto unix_time_us fields
local function append_time(subtree,value)
if value > time_usec_threshold then
d = os.date("%Y-%m-%d %H:%M:%S",value:tonumber() / 1000000.0)
us = value % 1000000
us = string.format("%06d",us:tonumber())
tz = os.date(" %Z",value:tonumber() / 1000000.0)
subtree:append_text(" [" .. d .. "." .. us .. tz .. "]")
end
end
payload_fns = {}
Expand Down Expand Up @@ -276,9 +287,7 @@ def generate_field_dissector(outf, msg, field, offset, enums, cmd=None, param=No
if tvb_func == "le_uint64" and field.name in ["time_usec","time_unix_usec"]:
t.write(outf,
"""
if value > time_usec_threshold then
subtree:append_text(" [" .. format_date(value:tonumber() / 1000000.0) .. "]")
end
append_time(subtree,value)
""")

if enum_obj and enum_obj.bitmask:
Expand Down

0 comments on commit 6c4c9c3

Please sign in to comment.