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 20:40:30 -04:00
parent 83ce026d23
commit c1cea1e488
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
11 changed files with 194 additions and 58 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<()>;
}