Skip to content

Commit f071408

Browse files
committed
feat: add new base MAVlink dissector port association for TCP
1 parent 2e01c34 commit f071408

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

generator/mavgen_wlua.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def get_field_info(field):
5555

5656
def generate_preamble(outf):
5757
print("Generating preamble")
58-
t.write(outf,
58+
t.write(outf,
5959
"""
6060
-- Wireshark dissector for the MAVLink protocol (please see https://mavlink.io/en for details)
6161
@@ -102,10 +102,10 @@ def generate_preamble(outf):
102102
}
103103
104104
""" )
105-
106-
105+
106+
107107
def generate_body_fields(outf):
108-
t.write(outf,
108+
t.write(outf,
109109
"""
110110
f.magic = ProtoField.uint8("mavlink_proto.magic", "Magic value / version", base.HEX, protocolVersions)
111111
f.length = ProtoField.uint8("mavlink_proto.length", "Payload length")
@@ -234,7 +234,7 @@ def generate_msg_fields(outf, msg, enums):
234234
mavlink_type, field_type, _, _, count = get_field_info(f)
235235

236236
for i in range(0,count):
237-
if count>1:
237+
if count>1:
238238
array_text = '[' + str(i) + ']'
239239
index_text = '_' + str(i)
240240
else:
@@ -420,20 +420,20 @@ def generate_payload_dissector(outf, msg, cmds, enums, cmd=None):
420420

421421
# function header
422422
if cmd is not None:
423-
t.write(outf,
423+
t.write(outf,
424424
"""
425425
-- dissect payload of message type ${msgname} with command ${cmdname}
426426
function payload_fns.payload_${msgid}_cmd${cmdid}(buffer, tree, msgid, offset, limit, pinfo)
427427
""", {'msgid': msg.id, 'msgname': msg.name, 'cmdid': cmd.value, 'cmdname': cmd.name})
428428
else:
429-
t.write(outf,
429+
t.write(outf,
430430
"""
431431
-- dissect payload of message type ${msgname}
432432
function payload_fns.payload_${msgid}(buffer, tree, msgid, offset, limit, pinfo)
433433
""", {'msgid': msg.id, 'msgname': msg.name})
434434

435435
# validate and pad payload if necessary
436-
t.write(outf,
436+
t.write(outf,
437437
"""
438438
local padded, field_offset, value, subtree, tvbrange
439439
if (offset + ${msgbytes} > limit) then
@@ -466,7 +466,7 @@ def generate_payload_dissector(outf, msg, cmds, enums, cmd=None):
466466
return
467467
end
468468
""", {'msgid': msg.id})
469-
469+
470470
for field in msg.fields:
471471
# detect command params
472472
param = None
@@ -482,14 +482,14 @@ def generate_payload_dissector(outf, msg, cmds, enums, cmd=None):
482482

483483
generate_field_dissector(outf, msg, field, msg.field_offsets[field.name], enums, cmd, param)
484484

485-
t.write(outf,
485+
t.write(outf,
486486
"""
487487
end
488488
""")
489-
489+
490490

491491
def generate_packet_dis(outf):
492-
t.write(outf,
492+
t.write(outf,
493493
"""
494494
-- dissector function
495495
function mavlink_proto.dissector(buffer,pinfo,tree)
@@ -696,12 +696,12 @@ def generate_packet_dis(outf):
696696
697697
698698
""")
699-
699+
700700

701701

702702
def generate_epilog(outf):
703703
print("Generating epilog")
704-
t.write(outf,
704+
t.write(outf,
705705
"""
706706
-- bind protocol dissector to USER0 linktype
707707
@@ -718,6 +718,7 @@ def generate_epilog(outf):
718718
-- register common Mavlink TCP ports
719719
720720
DissectorTable.get("tcp.port"):add("5760-5763", mavlink_proto)
721+
DissectorTable.get("tcp.port"):add("5790", mavlink_proto)
721722
722723
""")
723724

@@ -753,17 +754,17 @@ def generate(basename, xml):
753754

754755
for c in cmds:
755756
generate_cmd_params(outf, c, enums)
756-
757+
757758
for m in msgs:
758759
generate_msg_fields(outf, m, enums)
759760

760761
for e in enums:
761762
if e.bitmask:
762763
generate_flag_enum_dissector(outf, e)
763-
764+
764765
for m in msgs:
765766
generate_payload_dissector(outf, m, cmds, enums)
766-
767+
767768
generate_packet_dis(outf)
768769
# generate_enums(outf, enums)
769770
# generate_message_ids(outf, msgs)

0 commit comments

Comments
 (0)