Skip to main content

Module node_id

Module node_id 

Source
Expand description

48-bit OpenLCB Node IDs.

Every OpenLCB node carries a globally unique 48-bit Node ID, assigned from blocks handed out by the OpenLCB group (see the Unique Identifiers Standard). It is conventionally written as six dot-separated hex bytes, most significant first: 05.01.01.01.22.00. The 05.01.01.01.xx.xx range is the one OpenLCB reserves for individual hobbyists.

On CAN the full Node ID is too large to fit into every frame header, so nodes also reserve a short 12-bit alias (see crate::can and crate::node). The Node ID still travels in the data bytes of Initialization Complete, Verified Node ID and the AMD control frame, which is how other nodes learn the alias → Node ID mapping.

use rolcb::NodeId;

let id: NodeId = "05.01.01.01.22.0F".parse()?;
assert_eq!(id.as_u64(), 0x0501_0101_220F);
assert_eq!(id.to_string(), "05.01.01.01.22.0F");
assert_eq!(id.to_bytes(), [0x05, 0x01, 0x01, 0x01, 0x22, 0x0F]);

// Separators are optional and may be '.', ':', '-' or ' '; hex is case-insensitive.
assert_eq!("05:01:01:01:22:0f".parse::<NodeId>()?, id);
assert_eq!("05010101220F".parse::<NodeId>()?, id);

Structs§

NodeId
A unique 48-bit OpenLCB node identifier, e.g. 05.01.01.01.22.00.