Skip to content

SNS - LP BMS - #99

Open
H-Allen wants to merge 60 commits into
mainfrom
hype-105-implement-lp-bms
Open

SNS - LP BMS#99
H-Allen wants to merge 60 commits into
mainfrom
hype-105-implement-lp-bms

Conversation

@H-Allen

@H-Allen H-Allen commented Jun 11, 2025

Copy link
Copy Markdown
Contributor

No description provided.

miksquared and others added 30 commits October 14, 2024 18:41
@H-Allen
H-Allen requested a review from davidbeechey as a code owner June 11, 2025 14:14
@linear

linear Bot commented Jun 11, 2025

Copy link
Copy Markdown

@davidbeechey davidbeechey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! A few things to look at, plus making clippy and the formatter happy. Also could you merge main back into this branch, you seem to have included a lot of accel code? Thanks!

.send(CanMessage::MeasurementReading(MeasurementReading::new(
CanData::F32(battery_data.voltage),
board,
measurement_id,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The measurement ID should be unique for each "thing" we're measuring, so all of these will need their own. You can add them to /config/pods.yaml and hard-code them in here using the MeasurementId. Otherwise it'll be hellish to pass into this task (and we'll probs only have one LP BMS so don't need to worry about that)

Comment thread lib/sensors/src/lp_bms.rs
Comment on lines +1 to +2
/// Driver for the TinyBMS s516 30A Battery Management System using CAN.
/// Used to monitor battery status and health.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy is complaining about these comments, so either put them somewhere else in the file or change them to // instead of /// (probably the former)

Comment thread lib/sensors/src/lp_bms.rs
Comment on lines +95 to +117
impl<'a, T: HypedCanTx + HypedCanRx> Bms<'a, T> {
pub fn new(can: &'a mut T) -> Self {
Bms { can }
}

pub fn read_battery_data(&mut self) -> Result<BatteryData, CanError> {
let voltage = self.read_voltage()?;
let current = self.read_current()?;
let max_cell_mv = self.read_max_cell_voltage()?;
let min_cell_mv = self.read_min_cell_voltage()?;
let temperatures_c = self.read_temperatures()?;
let cell_voltages_mv = self.read_cell_voltages()?;

Ok(BatteryData {
voltage,
current,
max_cell_mv,
min_cell_mv,
temperatures_c,
cell_voltages_mv,
})
}
} No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this is in a separate impl block to the block above? Looks like they're the same

Comment thread lib/sensors/src/lp_bms.rs

impl<'a, T: HypedCanTx + HypedCanRx> Bms<'a, T> {
const NODE_ID: u8 = 0x01;
const REQUEST_ID: u32 = 0x400 | Self::NODE_ID as u32;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is Self::NODE_ID?

Comment thread lib/sensors/src/lp_bms.rs
const RESPONSE_ID: u32 = 0x500 | Self::NODE_ID as u32;

fn send_simple_request(&mut self, cmd: u8) -> Result<(), CanError> {
let frame = HypedCanFrame::new(Self::REQUEST_ID, [cmd, 0, 0, 0, 0, 0, 0, 0]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise what is Self::REQUEST_ID?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants