- allow communication to elm327 device via a serialport

- allow creation of elm327 device without requiring unwrap()
- added some extra documentation
- add fuel_level obd-ii command
- expose reset() functionality of device
This commit is contained in:
Nicholas Orlowsky 2025-03-18 22:03:13 -04:00
parent db4b4d990d
commit 642d2255ef
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
10 changed files with 189 additions and 63 deletions

View file

@ -3,6 +3,9 @@
mod elm327;
pub use elm327::Elm327;
mod serial_comm;
pub use serial_comm::{FTDIDevice, SerialPort};
type Result<T> = std::result::Result<T, Error>;
/// A lower-level API for using an OBD-II device
@ -54,6 +57,10 @@ pub enum Error {
#[error("FTDI error: `{0:?}`")]
Ftdi(ftdi::Error),
/// An error with the underlying [serialport device](serialport::SerialPort)
#[error("Serialport error: `{0:?}`")]
Serialport(serialport::Error),
/// An I/O error in a low-level [std::io] stream operation
#[error("IO error: `{0:?}`")]
IO(std::io::Error),
@ -69,6 +76,12 @@ impl From<ftdi::Error> for Error {
}
}
impl From<serialport::Error> for Error {
fn from(e: serialport::Error) -> Self {
Error::Serialport(e)
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::IO(e)