tydy up serial module

This commit is contained in:
Vladan Popovic 2022-12-23 13:00:10 +01:00
parent 98d0a66cf3
commit 31a6228669

View file

@ -5,11 +5,13 @@ use std::time::Duration;
use embedded_hal::serial::{Read, Write};
use esp_idf_hal::serial::{self, Rx, Tx};
const READ_MAX_RETRIES: usize = 5;
const READ_WAIT_TIME: u64 = 10;
#[derive(Debug)]
pub enum SerialError {
ReadError(String),
WriteError(String),
TimeoutError,
}
impl Error for SerialError {}
@ -85,9 +87,6 @@ impl<UART: serial::Uart> SerialIO<UART> {
}
}
const READ_MAX_RETRIES: usize = 5;
const READ_WAIT_TIME: u64 = 50;
impl<UART: serial::Uart> io::Read for SerialIO<UART> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let count = nb::block!(self.read_bytes(buf))