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

12
src/device/serial_comm.rs Normal file
View file

@ -0,0 +1,12 @@
use super::Result;
#[cfg(any(feature = "serialport_comm", feature = "ftdi_comm"))]
pub const DEFAULT_BAUD_RATE: u32 = 38_400;
/// An API to communicate with a serial device
pub trait SerialComm {
fn write_all(&mut self, data: &[u8]) -> Result<()>;
fn read(&mut self, data: &mut [u8]) -> Result<usize>;
fn set_baud_rate(&mut self, baud_rate: u32) -> Result<()>;
fn purge_buffers(&mut self) -> Result<()>;
}