tydy up serial module
This commit is contained in:
parent
98d0a66cf3
commit
31a6228669
1 changed files with 3 additions and 4 deletions
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue