Add the remaining service $00 PIDs up to $20

Also restructure the code to implement get_dtcs and get_dtc_info by
implementing GetObd2Values on the data types they return. This brings
them in line with every other getter function besides get_vin.
This commit is contained in:
Robert Sammelson 2023-05-21 01:38:30 -04:00
parent 5b20ac0ab9
commit 13b9041511
No known key found for this signature in database
GPG key ID: 92F1F04EDB06B9E9
5 changed files with 344 additions and 84 deletions

View file

@ -34,6 +34,19 @@ pub enum Dtc {
Network(u16),
}
impl From<u16> for Dtc {
fn from(val: u16) -> Self {
let n = val & 0x3f;
match val >> 14 {
0 => Dtc::Powertrain(n),
1 => Dtc::Chassis(n),
2 => Dtc::Body(n),
3 => Dtc::Network(n),
_ => unreachable!(),
}
}
}
impl fmt::Display for Dtc {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (c, n) = match self {
@ -46,6 +59,18 @@ impl fmt::Display for Dtc {
}
}
/// Data retreived when reading an oxygen sensor
pub struct OxygenSensorData {
/// The current voltage reading (V)
pub voltage: f32,
/// The current associated short term fuel trim (%)
///
/// The range of this value is approximately -1 to 1. This will be `127./128.` if not
/// applicable for the sensor.
pub shrft: f32,
}
pub(super) mod private {
pub trait Sealed {}
impl<T: crate::Obd2Device> Sealed for T {}