#[derive(Debug)]
pub enum Error {
StartTimeout,
ReadTimeout,
WriteTimeout,
DMA,
Noise,
Frame,
Parity,
Others,
}
#[derive(Default)]
pub enum StopBits {
#[default]
Stop1 = 0,
Stop2 = 1,
}
#[derive(Default)]
pub enum WordLen {
#[default]
WordLen8 = 0,
WordLen9 = 1,
}
#[derive(Default, PartialEq)]
pub enum Parity {
#[default]
None = 0,
Even = 1,
Odd = 2,
}
#[derive(Default)]
pub enum BaudRate {
Bps300 = 300,
Bps1200 = 1200,
Bps2400 = 2400,
Bps4800 = 4800,
Bps9600 = 9600,
Bps1440 = 1440,
Bps19200 = 19200,
Bps28800 = 28800,
Bps38400 = 38400,
Bps57600 = 57600,
Bps74880 = 74880,
#[default]
Bps115200 = 115200,
Bps230400 = 230400,
}
#[derive(Default, Clone, Copy, PartialEq)]
pub enum OverSampling {
#[default]
OverSampling16 = 0,
OverSampling8 = 1,
}
impl OverSampling {
pub(crate) fn div(&self) -> u32 {
if *self == Self::OverSampling16 {
16
} else {
8
}
}
}
impl From<OverSampling> for bool {
fn from(value: OverSampling) -> Self {
value == OverSampling::OverSampling8
}
}
#[derive(Default, PartialEq)]
pub enum DataBits {
#[default]
DataBits8 = 0,
DataBits9 = 1,
}
impl From<DataBits> for bool {
fn from(value: DataBits) -> Self {
value == DataBits::DataBits9
}
}