Serialport Support

- allow communication to elm327 device via a serialport
- allow creation of elm327 device without requiring unwrap()
- added some extra documentation
- expose reset() functionality of device
- serial_comm and ftdi_comm abstractions added
This commit is contained in:
Nicholas Orlowsky 2025-05-23 18:41:49 -04:00
parent db4b4d990d
commit 821e80aaaf
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
14 changed files with 213 additions and 60 deletions

View file

@ -1,3 +1,6 @@
//! Error types for OBD-II related errors
/// Result type defaulted with this library's error type
pub type Result<T> = std::result::Result<T, Error>;
/// An error with OBD-II communication
@ -16,8 +19,9 @@ pub enum Error {
Other(String),
}
/// An error with the ELM327 device
#[derive(Debug)]
pub struct DeviceError(crate::device::Error);
pub struct DeviceError(pub crate::device::Error);
impl From<super::device::Error> for Error {
fn from(e: super::device::Error) -> Self {
@ -27,12 +31,12 @@ impl From<super::device::Error> for Error {
impl From<std::num::ParseIntError> for Error {
fn from(e: std::num::ParseIntError) -> Self {
Error::Other(format!("invalid data recieved: {:?}", e))
Error::Other(format!("invalid data received: {:?}", e))
}
}
impl From<std::string::FromUtf8Error> for Error {
fn from(e: std::string::FromUtf8Error) -> Self {
Error::Other(format!("invalid string recieved: {:?}", e))
Error::Other(format!("invalid string received: {:?}", e))
}
}