Skip to content

Commit 4d4b98a

Browse files
authored
Cyphal/UDP: show the node-ID of 65535 as anonymous/broadcast instead of the numerical value (#16)
Fixes #15
1 parent 458603c commit 4d4b98a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cyphal_udp.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ end
8181
-- Protocol constants
8282
local CYPHAL_UDP_PORT = 9382 -- The port number used by Cyphal/UDP
8383
local CYPHAL_UDP_HEADER_SIZE = 24 -- The sizeof the Cyphal/UDP Header
84+
local ANONYMOUS_UDP_NODE_ID = 65535 -- The Anonymous Node ID in Cyphal/UDP (not the same as in CAN!)
8485
-- Custom protocol dissector
8586
local cyphal_udp = Proto("cyphaludp", "Cyphal/UDP Protocol 1.0 beta")
8687

@@ -164,7 +165,12 @@ local function dissect_cyphal_udp(buffer, pinfo, tree)
164165
header_tree:add_le(version, buffer(0, 1))
165166
header_tree:add_le(priority, buffer(1, 1))
166167
header_tree:add_le(source_node_id, buffer(2, 2))
167-
header_tree:add_le(destination_node_id, buffer(4, 2))
168+
local dst_node_id = buffer(4, 2):le_uint()
169+
if dst_node_id == ANONYMOUS_UDP_NODE_ID then
170+
header_tree:add_expert_info(PI_PROTOCOL, PI_NOTE, "Anonymous/Broadcast Destintation Node ID")
171+
else
172+
header_tree:add_le(destination_node_id, buffer(4, 2))
173+
end
168174
local ds = buffer(6, 2):le_uint()
169175
local port_id = bit.band(ds, 0x7FFF)
170176
local snm = bit.rshift(bit.band(ds, 0x8000), 15)

0 commit comments

Comments
 (0)