diff --git a/lib-bms-protocol/src/lib.rs b/lib-bms-protocol/src/lib.rs index 006b1dd..8e13811 100644 --- a/lib-bms-protocol/src/lib.rs +++ b/lib-bms-protocol/src/lib.rs @@ -29,6 +29,8 @@ pub trait BmsWriteable { pub enum BmsProtocolError { #[error("i2c communication failed")] I2cCommunicationError, + #[error("checksum error in received data")] + ChecksumError, } impl From for BmsProtocolError @@ -41,8 +43,11 @@ where } impl From for BmsProtocolError { - fn from(_error: crate::types::U26Error) -> Self { - Self::I2cCommunicationError + fn from(error: crate::types::U26Error) -> Self { + match error { + crate::types::U26Error::ChecksumError => Self::ChecksumError, + _ => Self::I2cCommunicationError, + } } }