pub struct Session<A: Adapter> { /* private fields */ }Expand description
The primary entry point for all OBD-II operations.
A Session wraps an Adapter and provides high-level methods for reading PIDs, DTCs, identifying vehicles, and more.
§Example
use obd2_core::adapter::mock::MockAdapter;
use obd2_core::session::Session;
use obd2_core::protocol::pid::Pid;
let adapter = MockAdapter::new();
let mut session = Session::new(adapter);
let profile = session.identify_vehicle().await?;
let rpm = session.read_pid(Pid::ENGINE_RPM).await?;Implementations§
Source§impl<A: Adapter> Session<A>
impl<A: Adapter> Session<A>
Sourcepub fn load_spec(&mut self, path: &Path) -> Result<(), Obd2Error>
pub fn load_spec(&mut self, path: &Path) -> Result<(), Obd2Error>
Load a vehicle spec from a YAML file.
Sourcepub fn load_spec_dir(&mut self, dir: &Path) -> Result<usize, Obd2Error>
pub fn load_spec_dir(&mut self, dir: &Path) -> Result<usize, Obd2Error>
Load all specs from a directory.
Sourcepub fn specs(&self) -> &SpecRegistry
pub fn specs(&self) -> &SpecRegistry
Access the spec registry.
Sourcepub async fn read_pid(&mut self, pid: Pid) -> Result<Reading, Obd2Error>
pub async fn read_pid(&mut self, pid: Pid) -> Result<Reading, Obd2Error>
Read a single standard PID.
Sourcepub async fn read_pids(
&mut self,
pids: &[Pid],
) -> Result<Vec<(Pid, Reading)>, Obd2Error>
pub async fn read_pids( &mut self, pids: &[Pid], ) -> Result<Vec<(Pid, Reading)>, Obd2Error>
Read multiple standard PIDs in sequence.
Sourcepub async fn supported_pids(&mut self) -> Result<HashSet<Pid>, Obd2Error>
pub async fn supported_pids(&mut self) -> Result<HashSet<Pid>, Obd2Error>
Query which standard PIDs this vehicle supports.
Sourcepub async fn read_dtcs(&mut self) -> Result<Vec<Dtc>, Obd2Error>
pub async fn read_dtcs(&mut self) -> Result<Vec<Dtc>, Obd2Error>
Read stored (confirmed) DTCs via broadcast.
Sourcepub async fn read_pending_dtcs(&mut self) -> Result<Vec<Dtc>, Obd2Error>
pub async fn read_pending_dtcs(&mut self) -> Result<Vec<Dtc>, Obd2Error>
Read pending DTCs (Mode 07).
Sourcepub async fn read_permanent_dtcs(&mut self) -> Result<Vec<Dtc>, Obd2Error>
pub async fn read_permanent_dtcs(&mut self) -> Result<Vec<Dtc>, Obd2Error>
Read permanent DTCs (Mode 0A).
Sourcepub async fn clear_dtcs(&mut self) -> Result<(), Obd2Error>
pub async fn clear_dtcs(&mut self) -> Result<(), Obd2Error>
Clear all DTCs and reset monitors (broadcast).
Sourcepub async fn identify_vehicle(&mut self) -> Result<VehicleProfile, Obd2Error>
pub async fn identify_vehicle(&mut self) -> Result<VehicleProfile, Obd2Error>
Identify vehicle: read VIN, decode offline, match spec.
Sourcepub async fn read_enhanced(
&mut self,
did: u16,
module: ModuleId,
) -> Result<Reading, Obd2Error>
pub async fn read_enhanced( &mut self, did: u16, module: ModuleId, ) -> Result<Reading, Obd2Error>
Read an enhanced PID from a specific module.
Sourcepub fn module_pids(&self, module: ModuleId) -> Vec<&EnhancedPid>
pub fn module_pids(&self, module: ModuleId) -> Vec<&EnhancedPid>
List enhanced PIDs available for a module (from matched spec).
Sourcepub async fn read_o2_monitoring(
&mut self,
test_id: u8,
) -> Result<Vec<O2TestResult>, Obd2Error>
pub async fn read_o2_monitoring( &mut self, test_id: u8, ) -> Result<Vec<O2TestResult>, Obd2Error>
Read O2 sensor monitoring test results for a specific TID.
Sourcepub async fn read_all_o2_monitoring(
&mut self,
) -> Result<Vec<O2TestResult>, Obd2Error>
pub async fn read_all_o2_monitoring( &mut self, ) -> Result<Vec<O2TestResult>, Obd2Error>
Read all O2 sensor monitoring tests (TIDs 0x01-0x09).
Sourcepub fn vehicle(&self) -> Option<&VehicleProfile>
pub fn vehicle(&self) -> Option<&VehicleProfile>
Current vehicle profile (after identify_vehicle()).
Sourcepub fn spec(&self) -> Option<&VehicleSpec>
pub fn spec(&self) -> Option<&VehicleSpec>
Matched spec (shorthand).
Sourcepub fn adapter_info(&self) -> &AdapterInfo
pub fn adapter_info(&self) -> &AdapterInfo
Adapter info.