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: Support 64-bit flag fields #886

Merged
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions generator/mavgen_wlua.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,11 @@ def generate_field_dissector(outf, msg, field, offset, enums, cmd=None, param=No
""", {'foffset': offset + i * size, 'fbytes': size, 'ftvbfunc': tvb_func, 'fvar': field_var})

if enum_obj and enum_obj.bitmask:
valuemethod = ":tonumber()" if tvb_func == "le_uint64" else ""
t.write(outf,
"""
dissect_flags_${enumname}(subtree, "${fvar}", tvbrange, value)
""", {'enumname': enum_name, 'fvar': field_var})
dissect_flags_${enumname}(subtree, "${fvar}", tvbrange, value${vmeth})
""", {'enumname': enum_name, 'fvar': field_var, 'vmeth': valuemethod})


def generate_payload_dissector(outf, msg, cmds, enums, cmd=None):
Expand Down
76 changes: 76 additions & 0 deletions tests/snapshottests/__snapshots__/test_wlua.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,82 @@
Message CRC: 0xf478


''',
})
# ---
# name: test_wlua[common.xml-autopilot_version.pcapng]
dict({
'returncode': 0,
'stderr': '',
'stdout': '''
Frame 1: 131 bytes on wire (1048 bits), 131 bytes captured (1048 bits) o
Ethernet II, Src: 00:00:00:00:00:00, Dst: 00:00:00:00:00:00
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
User Datagram Protocol, Src Port: 34942, Dst Port: 18570
MAVLink Protocol (89)
Header
Magic value / version: MAVLink 2.0 (0xfd)
Payload length: 77
Incompatibility flag: 0
Compatibility flag: 0
Packet sequence: 219
System id: 0x01
Component id: 0x01
Message id: AUTOPILOT_VERSION (148)
Payload: AUTOPILOT_VERSION (148)
capabilities (MAV_PROTOCOL_CAPABILITY): 62319
.... .... .... .... .1 = MAV_PROTOCOL_CAPABILITY_MISSION_FLO
.... .... .... .... 1. = MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT
.... .... .... ...1 .. = MAV_PROTOCOL_CAPABILITY_MISSION_INT
.... .... .... ..1. .. = MAV_PROTOCOL_CAPABILITY_COMMAND_INT
.... .... .... .0.. .. = MAV_PROTOCOL_CAPABILITY_PARAM_ENCOD
.... .... .... 1... .. = MAV_PROTOCOL_CAPABILITY_FTP: True
.... .... ...1 .... .. = MAV_PROTOCOL_CAPABILITY_SET_ATTITUD
.... .... ..0. .... .. = MAV_PROTOCOL_CAPABILITY_SET_POSITIO
.... .... .1.. .... .. = MAV_PROTOCOL_CAPABILITY_SET_POSITIO
.... .... 1... .... .. = MAV_PROTOCOL_CAPABILITY_TERRAIN: Tr
.... ...0 .... .... .. = MAV_PROTOCOL_CAPABILITY_SET_ACTUATO
.... ..0. .... .... .. = MAV_PROTOCOL_CAPABILITY_FLIGHT_TERM
.... .1.. .... .... .. = MAV_PROTOCOL_CAPABILITY_COMPASS_CAL
.... 1... .... .... .. = MAV_PROTOCOL_CAPABILITY_MAVLINK2: T
...1 .... .... .... .. = MAV_PROTOCOL_CAPABILITY_MISSION_FEN
..1. .... .... .... .. = MAV_PROTOCOL_CAPABILITY_MISSION_RAL
.0.. .... .... .... .. = MAV_PROTOCOL_CAPABILITY_RESERVED2:
0... .... .... .... .. = MAV_PROTOCOL_CAPABILITY_PARAM_ENCOD
flight_sw_version (uint32_t): 67307007
middleware_sw_version (uint32_t): 0
os_sw_version (uint32_t): 0
board_version (uint32_t): 0
flight_custom_version[0] (uint8_t): 51
flight_custom_version[1] (uint8_t): 98
flight_custom_version[2] (uint8_t): 102
flight_custom_version[3] (uint8_t): 54
flight_custom_version[4] (uint8_t): 100
flight_custom_version[5] (uint8_t): 55
flight_custom_version[6] (uint8_t): 97
flight_custom_version[7] (uint8_t): 99
middleware_custom_version[0] (uint8_t): 0
middleware_custom_version[1] (uint8_t): 0
middleware_custom_version[2] (uint8_t): 0
middleware_custom_version[3] (uint8_t): 0
middleware_custom_version[4] (uint8_t): 0
middleware_custom_version[5] (uint8_t): 0
middleware_custom_version[6] (uint8_t): 0
middleware_custom_version[7] (uint8_t): 0
os_custom_version[0] (uint8_t): 0
os_custom_version[1] (uint8_t): 0
os_custom_version[2] (uint8_t): 0
os_custom_version[3] (uint8_t): 0
os_custom_version[4] (uint8_t): 0
os_custom_version[5] (uint8_t): 0
os_custom_version[6] (uint8_t): 0
os_custom_version[7] (uint8_t): 0
vendor_id (uint16_t): 0
product_id (uint16_t): 0
uid (uint64_t): 0
Message CRC: 0xfcfc


''',
})
# ---
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/snapshottests/test_wlua.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def snapshot(*args, **kwargs):
("common.xml", "command_long_over_tcp.pcapng"),
# test that output is okay when we encounter messages not defined in the xml
("minimal.xml", "common.pcapng"),
# test that 64-bit bitfield in AUTOPILOT_VERSION is correctly handled
("common.xml", "autopilot_version.pcapng"),
],
)
def test_wlua(request, tmp_path, snapshot, mdef, pcap):
Expand Down
Loading