pub struct Id(/* private fields */);
Implementations§
source§impl Id
impl Id
Frame ID
sourcepub const fn new(id: u32) -> Self
pub const fn new(id: u32) -> Self
Construct new Frame ID from raw integer.
The ID is masked to 29 bits to ensure that the ID is within the valid range.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub const fn as_raw(&self) -> u32
pub const fn as_raw(&self) -> u32
Return ID as raw integer.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub fn priority(&self) -> u8
pub fn priority(&self) -> u8
Frame priority
The priority ranges from 0 to 7, where 0 is the highest priority and 7 the lowest priority.
Default priority for informational, proprietary, request and acknowledgement frames is 6. Default priority for control frames (e.g., speeding up or slowing down the vehicle) is 3.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub fn data_page(&self) -> u8
pub fn data_page(&self) -> u8
Data page (DP)
Returns the data page bit of the frame ID.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub fn pgn(&self) -> PGN
pub fn pgn(&self) -> PGN
Parameter Group Number (PGN)
Returns the parameter group number of the frame ID.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub fn pgn_raw(&self) -> u32
pub fn pgn_raw(&self) -> u32
Parameter Group Number
Returns the raw parameter group number of the frame ID.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub fn pdu_format(&self) -> PDUFormat
pub fn pdu_format(&self) -> PDUFormat
PDU Format (PF)
Returns the PDU format of the frame ID.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub fn is_broadcast(&self) -> bool
pub fn is_broadcast(&self) -> bool
Test if the frame is a broadcast frame
Returns true if the frame is a broadcast frame, false otherwise.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub fn destination_address(&self) -> Option<u8>
pub fn destination_address(&self) -> Option<u8>
Frame Destination Address (DA)
Returns the destination address of the frame ID.
The destination address is only available on PDU1 frames.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub fn group_extension(&self) -> Option<u8>
pub fn group_extension(&self) -> Option<u8>
Frame Group Extension (GE)
Returns the group extension of the frame ID.
The group extension is only available on PDU2 frames.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}
sourcepub fn pdu_specific(&self) -> u8
pub fn pdu_specific(&self) -> u8
PDU Specific (PS)
Returns the PDU specific value of the frame ID.
sourcepub fn source_address(&self) -> u8
pub fn source_address(&self) -> u8
Device Source Address (SA)
Returns the source address of the frame ID.
Examples found in repository?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let input = env::args().nth(1);
if input.is_none() {
usage();
return;
}
let id_str = input.unwrap();
if !id_str.starts_with("0x") {
usage();
return;
}
let id_raw = u32::from_str_radix(id_str.trim_start_matches("0x"), 16).expect("Invalid ID");
let id = Id::new(id_raw);
println!("ID");
println!(" Hex: 0x{:X?}", id.as_raw());
println!(" Dec: {}", id.as_raw());
println!(" Bin: {:029b}", id.as_raw());
println!("Priority");
println!(" Hex: 0x{:X?}", id.priority());
println!(" Dec: {}", id.priority());
println!(" Bin: {:03b}", id.priority());
println!("Data Page (DP): {}", id.data_page());
println!("Parameter Group Number (PGN): {:?}", id.pgn());
println!(" Hex: 0x{:X?}", id.pgn_raw());
println!(" Dec: {}", id.pgn_raw());
println!(" Bin: {:024b}", id.pgn_raw());
println!("PDU Format: {:?}", id.pdu_format());
println!("Broadcast: {}", id.is_broadcast());
if let Some(ge) = id.group_extension() {
println!("Group Extension (GE)/PDU Specific (PS)");
println!(" Hex: 0x{:X?}", ge);
println!(" Dec: {}", ge);
println!(" Bin: {:08b}", ge);
}
if let Some(da) = id.destination_address() {
println!("Destination Address (DA)");
println!(" Hex: 0x{:X?}", da);
println!(" Dec: {}", da);
println!(" Bin: {:08b}", da);
}
println!("Source Address (SA)");
println!(" Hex: 0x{:X?}", id.source_address());
println!(" Dec: {}", id.source_address());
println!(" Bin: {:08b}", id.source_address());
}