Trait ecu_diagnostics::hardware::Hardware
source · [−]pub trait Hardware {
fn create_iso_tp_channel(
this: Arc<Mutex<Self>>
) -> HardwareResult<Box<dyn IsoTPChannel>>;
fn create_can_channel(
this: Arc<Mutex<Self>>
) -> HardwareResult<Box<dyn CanChannel>>;
fn is_iso_tp_channel_open(&self) -> bool;
fn is_can_channel_open(&self) -> bool;
fn read_battery_voltage(&mut self) -> Option<f32>;
fn read_ignition_voltage(&mut self) -> Option<f32>;
fn get_info(&self) -> &HardwareInfo;
}
Expand description
The hardware trait defines functions supported by all adapter types, as well as functions that can create abstracted communication channels that can be used in diagnostic servers
Required Methods
fn create_iso_tp_channel(
this: Arc<Mutex<Self>>
) -> HardwareResult<Box<dyn IsoTPChannel>>
fn create_iso_tp_channel(
this: Arc<Mutex<Self>>
) -> HardwareResult<Box<dyn IsoTPChannel>>
Creates an ISO-TP channel on the devices. This channel will live for as long as the hardware trait. Upon being dropped, the channel will automatically be closed, if it has been opened.
fn create_can_channel(
this: Arc<Mutex<Self>>
) -> HardwareResult<Box<dyn CanChannel>>
fn create_can_channel(
this: Arc<Mutex<Self>>
) -> HardwareResult<Box<dyn CanChannel>>
Creates a CAN Channel on the devices. This channel will live for as long as the hardware trait. Upon being dropped, the channel will automatically be closed, if it has been opened.
fn is_iso_tp_channel_open(&self) -> bool
fn is_iso_tp_channel_open(&self) -> bool
Returns true if the ISO-TP channel is current open and in use
fn is_can_channel_open(&self) -> bool
fn is_can_channel_open(&self) -> bool
Returns true if the CAN channel is currently open and in use
fn read_battery_voltage(&mut self) -> Option<f32>
fn read_battery_voltage(&mut self) -> Option<f32>
Tries to read battery voltage from Pin 16 of an OBD port (+12V). This is mainly used by diagnostic adapters, and is purely optional Should the adapter not support this feature, std::option::Option::None is returned
fn read_ignition_voltage(&mut self) -> Option<f32>
fn read_ignition_voltage(&mut self) -> Option<f32>
Tries to read battery voltage from the igntion pin on the OBD2 port. A reading would indicate ignition is on in the vehicle. This is mainly used by diagnostic adapters, and is purely optional Should the adapter not support this feature, std::option::Option::None is returned
fn get_info(&self) -> &HardwareInfo
fn get_info(&self) -> &HardwareInfo
Returns the information of the hardware