update examples
This commit is contained in:
parent
1b3f6a2f6b
commit
6426fc7afc
|
@ -2,15 +2,19 @@ use obd2::commands::Obd2DataRetrieval;
|
||||||
|
|
||||||
use std::time;
|
use std::time;
|
||||||
|
|
||||||
fn main() {
|
fn main() -> Result<(), obd2::Error> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let mut device: obd2::Obd2<obd2::device::Elm327> = obd2::Obd2::default();
|
let mut device: obd2::Obd2<obd2::device::Elm327<obd2::device::FTDIDevice>> = obd2::Obd2::new(
|
||||||
|
obd2::device::Elm327::new(
|
||||||
|
obd2::device::FTDIDevice::new()?
|
||||||
|
)?
|
||||||
|
)?;
|
||||||
|
|
||||||
println!("VIN: {:?}", device.get_vin());
|
println!("VIN: {:?}", device.get_vin());
|
||||||
for s in device.get_service_1_pid_support_1().unwrap().iter() {
|
for s in device.get_service_1_pid_support_1()?.iter() {
|
||||||
println!("PID support ($01-$20): {:08X}", s);
|
println!("PID support ($01-$20): {:08X}", s);
|
||||||
}
|
}
|
||||||
for s in device.get_service_1_pid_support_2().unwrap().iter() {
|
for s in device.get_service_1_pid_support_2()?.iter() {
|
||||||
println!("PID support ($21-$40): {:08X}", s);
|
println!("PID support ($21-$40): {:08X}", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,4 +51,6 @@ fn main() {
|
||||||
device.get_throttle_position()
|
device.get_throttle_position()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -6,14 +6,20 @@
|
||||||
//!
|
//!
|
||||||
//! # Usage
|
//! # Usage
|
||||||
//! ```
|
//! ```
|
||||||
//! use obd2::{commands::Obd2DataRetrieval, device::Elm327, Obd2};
|
//! use obd2::{commands::Obd2DataRetrieval, device::{Elm327, FTDIDevice}, Obd2};
|
||||||
//!
|
//!
|
||||||
//! fn main() -> Result<(), obd2::Error> {
|
//! fn main() -> Result<(), obd2::Error> {
|
||||||
//! let mut device = Obd2::<Elm327>::default();
|
//! let mut device = Obd2::<Elm327::<FTDIDevice>>::new(Elm327::new(FTDIDevice::new()?)?)?;
|
||||||
//! println!("VIN: {}", device.get_vin()?);
|
//! println!("VIN: {}", device.get_vin()?);
|
||||||
//! Ok(())
|
//! Ok(())
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
//!
|
||||||
|
//! alternatively, you could use a serial port provided by your operating system such as
|
||||||
|
//! /dev/ttyUSB0 on unix-like systems
|
||||||
|
//! ```
|
||||||
|
//! let mut device = Obd2::<Elm327::<SerialPort>>::new(Elm327::new(SerialPort::new("/dev/ttyUSB0")?)?)?;
|
||||||
|
//! ```
|
||||||
|
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
Loading…
Reference in a new issue