Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mavgen WLUA: Fix incorrect display of negative ints on mac #944

Merged
merged 1 commit into from
May 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion generator/mavgen_wlua.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,37 @@ def generate_field_dissector(outf, msg, field, offset, enums, cmd=None, param=No
else:
field_var = t.substitute("${fmsg}_${fname}${findex}", {'fmsg': msg.name, 'fname': field.name, 'findex': index_text})

t.write(outf,
# If there is an associated enum and the datatype is not uint, we need to extract
# and pass the value to add_le, as the raw and ProtoField types will not match.
# This occurs in the case of using a command field to represent an enum or bitmask
if enum_obj and tvb_func != "le_uint":
value_extracted = True
t.write(outf,
"""
tvbrange = padded(offset + ${foffset}, ${fbytes})
value = tvbrange:${ftvbfunc}()
subtree = tree:add_le(f.${fvar}, tvbrange, value)
""", {'foffset': offset + i * size, 'fbytes': size, 'ftvbfunc': tvb_func, 'fvar': field_var})
else:
value_extracted = False
t.write(outf,
"""
tvbrange = padded(offset + ${foffset}, ${fbytes})
subtree = tree:add_le(f.${fvar}, tvbrange)
""", {'foffset': offset + i * size, 'fbytes': size, 'ftvbfunc': tvb_func, 'fvar': field_var})

unit = field.units.replace("[","").replace("]","")
global unit_decoder_mapping
if unit in unit_decoder_mapping:
if not value_extracted:
t.write(outf," value = tvbrange:${ftvbfunc}()\n", {'ftvbfunc': tvb_func})
value_extracted = True
t.write(outf," subtree:append_text(" + unit_decoder_mapping[unit] + ")\n")

if enum_obj and enum_obj.bitmask:
if not value_extracted:
t.write(outf," value = tvbrange:${ftvbfunc}()\n", {'ftvbfunc': tvb_func})
value_extracted = True
valuemethod = ":tonumber()" if tvb_func == "le_uint64" else ""
t.write(outf,
"""
Expand Down
Loading