Skip to main content

Crate bacnet_npdu

Crate bacnet_npdu 

Source
Expand description

The BACnet network-layer vocabulary (Clause 6), in one place, for every layer of rusty-bacnet and for firmware.

The crate is no_std, needs no allocator and has no dependencies. It holds what the portable cores, the hosted transports and network layer, and the owned codec of bacnet-encoding all speak, so each concept has one definition:

The other network-layer messages’ payloads, the routing table and the router itself are bacnet-router-core’s.

§Example

use bacnet_npdu::{Address, Npdu, NetworkPriority};

// A confirmed request for station 5 on network 2, at urgent priority.
let mut request = Npdu::apdu(&[0x00, 0x05, 0x01, 0x0C]);
request.destination = Some(Address { network: 2, mac: &[5] });
request.expecting_reply = true;
request.priority = NetworkPriority::Urgent;

let mut frame = [0u8; 32];
let len = request.encode_into(&mut frame)?;
assert_eq!(len, request.encoded_len());
assert_eq!(&frame[..len], &[0x01, 0x25, 0x00, 0x02, 0x01, 0x05, 0xFF, 0x00, 0x05, 0x01, 0x0C]);

let decoded = Npdu::decode(&frame[..len]).expect("an NPDU");
assert_eq!(decoded.destination, request.destination);
assert_eq!(decoded.priority, NetworkPriority::Urgent);
assert_eq!(decoded.payload, request.payload);

Structs§

Address
A network and a MAC on it: a DNET and DADR, or an SNET and SADR.
Mac
A link-layer address of up to MAX_MAC_LEN octets, stored inline, so a route or a pending reply holds one without an allocator.
MacTooLong
A MAC longer than MAX_MAC_LEN octets was offered to Mac.
NetworkMessageType
A network-layer message type: the octet after an NPDU’s addresses that says which message it carries (Clause 6.2.4).
Npdu
An NPDU’s control information, with its payload, borrowed from a frame.
NpduLimits
The longest NPDU a link carries, in octets, to one node and to every node on it (Table 6-1).
PriorityError
A value NetworkPriority::try_from refuses: a network priority is two bits, 0 to 3.
RejectLengthError
A Reject-Message-To-Network’s data isn’t RejectMessageToNetwork::LEN octets: it ends inside the network, or goes on past it.
RejectMessageReason
The reason a Reject-Message-To-Network gives (Clause 6.4.4).
RejectMessageToNetwork
What a Reject-Message-To-Network carries after its type (Clause 6.4.4): one reason octet, then the two-octet network the refused message was for.

Enums§

AddressField
Which address a DecodeError::AddressTooLong concerns.
DecodeError
Why Npdu::decode refused a frame.
EncodeError
Why Npdu::encode_into refused an NPDU. Nothing was written.
Malformed
What made a frame malformed.
NetworkPriority
An NPDU’s network priority (Clause 6.2.2): the control octet’s two low bits, in increasing order of urgency.

Constants§

GLOBAL_NETWORK
The DNET of a global broadcast.
MAX_MAC_LEN
The longest DADR, SADR or link MAC the stack accepts, in octets (#1141).
MAX_NPDU
The longest NPDU, in octets, that B/IP, B/IPv6, Ethernet and MS/TP with extended frames carry (Table 6-1; Clause 9.3 for MS/TP).
VERSION
The protocol version every NPDU starts with.