pub struct J1939Id { /* private fields */ }Expand description
The fields a J1939 message packs into its 29-bit identifier.
§Examples
use pamoja_can::{CanId, J1939Id};
// The standard engine-speed broadcast, identifier 0x0CF00400.
let message = J1939Id::from_id(CanId::extended(0x0CF0_0400)).unwrap();
assert_eq!(message.priority(), 3);
assert_eq!(message.pgn(), 61_444);
assert_eq!(message.source(), 0x00);
assert!(message.is_broadcast());
assert_eq!(message.destination(), None);Implementations§
Source§impl J1939Id
impl J1939Id
Sourcepub fn broadcast(priority: u8, pgn: u32, source: u8) -> J1939Id
pub fn broadcast(priority: u8, pgn: u32, source: u8) -> J1939Id
Builds the identifier for a message addressed to every node.
A broadcast parameter group has no destination, so this fills in
BROADCAST_ADDRESS rather than making a caller remember it.
§Arguments
priority- the three-bit priority;prioritynames the usual ones.pgn- the parameter group number the message belongs to.source- the address of the node sending it.
§Returns
The identifier fields.
Sourcepub fn from_parts(
priority: u8,
pgn: u32,
source: u8,
destination: u8,
) -> J1939Id
pub fn from_parts( priority: u8, pgn: u32, source: u8, destination: u8, ) -> J1939Id
Composes a J1939 identifier from its fields.
§Arguments
priority- the message priority, masked to its low three bits.pgn- the parameter group number.source- the source address.destination- the destination address, used only for an addressed (PDU1) parameter group and ignored for a broadcast (PDU2) one.
§Returns
The identifier fields.
Sourcepub fn pdu_format(&self) -> u8
pub fn pdu_format(&self) -> u8
Sourcepub fn destination(&self) -> Option<u8>
pub fn destination(&self) -> Option<u8>
Sourcepub fn is_broadcast(&self) -> bool
pub fn is_broadcast(&self) -> bool
Reports whether the message is a broadcast.
§Returns
true for a broadcast (PDU2) message, false for an addressed (PDU1) one.
Trait Implementations§
impl Copy for J1939Id
impl Eq for J1939Id
impl StructuralPartialEq for J1939Id
Auto Trait Implementations§
impl Freeze for J1939Id
impl RefUnwindSafe for J1939Id
impl Send for J1939Id
impl Sync for J1939Id
impl Unpin for J1939Id
impl UnsafeUnpin for J1939Id
impl UnwindSafe for J1939Id
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more