pub struct HighResolutionVehicleDistanceMessage {
pub total_vehicle_distance_m: Option<u32>,
pub trip_distance_m: Option<u32>,
}Fields§
§total_vehicle_distance_m: Option<u32>Accumulated distance traveled by the vehicle during its operation (meters).
trip_distance_m: Option<u32>Distance traveled during trip (meters).
Implementations§
Source§impl HighResolutionVehicleDistanceMessage
impl HighResolutionVehicleDistanceMessage
Sourcepub fn from_pdu(pdu: &[u8]) -> Self
pub fn from_pdu(pdu: &[u8]) -> Self
§Panics
Panics if pdu has fewer than 8 bytes.
Examples found in repository?
examples/j1939decode.rs (line 54)
17fn decode_data(pgn: PGN, data: &[u8]) {
18 println!("Data Decoded:");
19 match pgn {
20 PGN::TorqueSpeedControl1 => {
21 println!(" {}", TorqueSpeedControl1Message::from_pdu(data));
22 }
23 PGN::ElectronicEngineController1 => {
24 println!(" {}", ElectronicEngineController1Message::from_pdu(data));
25 }
26 PGN::ElectronicEngineController2 => {
27 println!(" {}", ElectronicEngineController2Message::from_pdu(data));
28 }
29 PGN::ElectronicEngineController3 => {
30 println!(" {}", ElectronicEngineController3Message::from_pdu(data));
31 }
32 PGN::ElectronicBrakeController1 => {
33 println!(" {}", ElectronicBrakeController1Message::from_pdu(data));
34 }
35 PGN::AmbientConditions => {
36 println!(" {}", AmbientConditionsMessage::from_pdu(data));
37 }
38 PGN::VehiclePosition => {
39 println!(" {}", VehiclePositionMessage::from_pdu(data));
40 }
41 PGN::FuelEconomy => {
42 println!(" {}", FuelEconomyMessage::from_pdu(data));
43 }
44 PGN::EngineFluidLevelPressure1 => {
45 println!(" {}", EngineFluidLevelPressure1Message::from_pdu(data));
46 }
47 PGN::FuelConsumption => {
48 println!(" {}", FuelConsumptionMessage::from_pdu(data));
49 }
50 PGN::VehicleDistance => {
51 println!(" {}", VehicleDistanceMessage::from_pdu(data));
52 }
53 PGN::HighResolutionVehicleDistance => {
54 println!(" {}", HighResolutionVehicleDistanceMessage::from_pdu(data));
55 }
56 PGN::FanDrive => {
57 println!(" {}", FanDriveMessage::from_pdu(data));
58 }
59 PGN::Shutdown => {
60 println!(" {}", ShutdownMessage::from_pdu(data));
61 }
62 PGN::EngineTemperature1 => {
63 println!(" {}", EngineTemperature1Message::from_pdu(data));
64 }
65 PGN::InletExhaustConditions1 => {
66 println!(" {}", InletExhaustConditions1Message::from_pdu(data));
67 }
68 PGN::VehicleElectricalPower1 => {
69 println!(" {}", VehicleElectricalPowerMessage::from_pdu(data));
70 }
71 PGN::EngineFluidLevelPressure2 => {
72 println!(" {}", EngineFluidLevelPressure2Message::from_pdu(data));
73 }
74 PGN::AuxiliaryInputOutputStatus => {
75 println!(" {}", CabIlluminationMessage::from_pdu(data));
76 }
77 PGN::ECUHistory => {
78 println!(" {}", ECUHistoryMessage::from_pdu(data));
79 }
80 PGN::TANKInformation1 => {
81 println!(" {}", TankInformation1Message::from_pdu(data));
82 }
83 PGN::Tachograph => {
84 println!(" {}", TachographMessage::from_pdu(data));
85 }
86 PGN::PowerTakeoffInformation => {
87 println!(" {}", PowerTakeoffInformationMessage::from_pdu(data));
88 }
89 PGN::DiagnosticMessage1 => {
90 println!(" {}", diagnostic::Message1::from_pdu(data));
91 }
92 PGN::Request => {
93 println!(" Request PGN: {:?}", protocol::request_from_pdu(data));
94 }
95 PGN::TimeDate => {
96 // TimeDate currently uses Debug formatting for its decoded representation,
97 // unlike other messages in this function that use Display. This is
98 // intentional because TimeDate does not provide a custom Display format.
99 println!(" {:?}", TimeDate::from_pdu(data));
100 }
101 _ => {
102 println!(" Unknown PGN for data decoding.");
103 }
104 }
105}pub fn to_pdu(&self) -> [u8; 8]
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HighResolutionVehicleDistanceMessage
impl RefUnwindSafe for HighResolutionVehicleDistanceMessage
impl Send for HighResolutionVehicleDistanceMessage
impl Sync for HighResolutionVehicleDistanceMessage
impl Unpin for HighResolutionVehicleDistanceMessage
impl UnsafeUnpin for HighResolutionVehicleDistanceMessage
impl UnwindSafe for HighResolutionVehicleDistanceMessage
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