From d2c35dc60140cf4e6f81c5108df25f7c8ffc7413 Mon Sep 17 00:00:00 2001 From: ju6ge Date: Mon, 5 Jan 2026 17:23:09 +0100 Subject: [PATCH] use thiserror for protocol error type --- Cargo.lock | 1 + lib-bms-protocol/Cargo.toml | 1 + lib-bms-protocol/src/lib.rs | 3 +++ 3 files changed, 5 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 7b380ac..388af15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -537,6 +537,7 @@ name = "lib-bms-protocol" version = "0.1.0" dependencies = [ "embedded-hal 1.0.0", + "thiserror", ] [[package]] diff --git a/lib-bms-protocol/Cargo.toml b/lib-bms-protocol/Cargo.toml index 2964329..b374162 100644 --- a/lib-bms-protocol/Cargo.toml +++ b/lib-bms-protocol/Cargo.toml @@ -5,6 +5,7 @@ edition = "2024" [dependencies] embedded-hal = "1.0.0" +thiserror = { version = "2.0.17", default-features = false } [profile.dev] diff --git a/lib-bms-protocol/src/lib.rs b/lib-bms-protocol/src/lib.rs index 64a3401..ca92124 100644 --- a/lib-bms-protocol/src/lib.rs +++ b/lib-bms-protocol/src/lib.rs @@ -1,6 +1,7 @@ #![no_std] use embedded_hal::i2c::{I2c, Operation, SevenBitAddress}; +use thiserror::Error; pub const BMS_I2C_ADDRESS: u8 = 0x55; @@ -17,7 +18,9 @@ pub trait BmsWriteable { I: I2c; } +#[derive(Debug, Error)] pub enum BmsProtocolError { + #[error("i2c communication failed")] I2cCommunicationError, }