Skip to content

Commit

Permalink
Cyphal/UDP: show the node-ID of 65535 as anonymous/broadcast instead …
Browse files Browse the repository at this point in the history
…of the numerical value (#16)

Fixes #15
  • Loading branch information
emrainey authored Apr 6, 2024
1 parent 458603c commit 4d4b98a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cyphal_udp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ end
-- Protocol constants
local CYPHAL_UDP_PORT = 9382 -- The port number used by Cyphal/UDP
local CYPHAL_UDP_HEADER_SIZE = 24 -- The sizeof the Cyphal/UDP Header
local ANONYMOUS_UDP_NODE_ID = 65535 -- The Anonymous Node ID in Cyphal/UDP (not the same as in CAN!)
-- Custom protocol dissector
local cyphal_udp = Proto("cyphaludp", "Cyphal/UDP Protocol 1.0 beta")

Expand Down Expand Up @@ -164,7 +165,12 @@ local function dissect_cyphal_udp(buffer, pinfo, tree)
header_tree:add_le(version, buffer(0, 1))
header_tree:add_le(priority, buffer(1, 1))
header_tree:add_le(source_node_id, buffer(2, 2))
header_tree:add_le(destination_node_id, buffer(4, 2))
local dst_node_id = buffer(4, 2):le_uint()
if dst_node_id == ANONYMOUS_UDP_NODE_ID then
header_tree:add_expert_info(PI_PROTOCOL, PI_NOTE, "Anonymous/Broadcast Destintation Node ID")
else
header_tree:add_le(destination_node_id, buffer(4, 2))
end
local ds = buffer(6, 2):le_uint()
local port_id = bit.band(ds, 0x7FFF)
local snm = bit.rshift(bit.band(ds, 0x8000), 15)
Expand Down

0 comments on commit 4d4b98a

Please sign in to comment.