Skip to main content

HighResolutionVehicleDistanceMessage

Struct HighResolutionVehicleDistanceMessage 

Source
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

Source

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}
Source

pub fn to_pdu(&self) -> [u8; 8]

Trait Implementations§

Source§

impl Display for HighResolutionVehicleDistanceMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.