Skip to content

Suppress placeholder BMS faults during startup grace#92

Open
mjc wants to merge 1 commit into
lukash:mainfrom
mjc:mjc/refloat-bms-startup-grace-fix
Open

Suppress placeholder BMS faults during startup grace#92
mjc wants to merge 1 commit into
lukash:mainfrom
mjc:mjc/refloat-bms-startup-grace-fix

Conversation

@mjc

@mjc mjc commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Prevent the startup BMS message-age sentinel from falling through to telemetry threshold checks during the existing grace period.

While BMS data is stale, bms_update() now returns without reporting telemetry faults until the grace period expires. Afterward it reports the existing connection fault; fresh telemetry continues through the existing threshold checks unchanged.

Copilot AI review requested due to automatic review settings July 15, 2026 17:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refines BMS startup behavior so placeholder telemetry values aren’t interpreted as real BMS data, by explicitly tracking when BMS status has been requested and when the first real sample has been received.

Changes:

  • Add status_requested / status_received state to BMS telemetry handling, and gate fault evaluation until a request is made and a sample arrives (or a request timeout occurs).
  • Route Lisp bridge BMS writes through bms_request_status / bms_store_status helpers instead of directly mutating the BMS struct.
  • Update the Lisp BMS loop to call ext-bms early to register a status request.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/main.c Updates ext_bms to either record a status request (no args) or store a received sample (with args).
src/bms.h Extends BMS state to track request/receipt and adds new helper APIs.
src/bms.c Implements request/receive tracking and gates connection-fault logic until after a request.
lisp/bms.lisp Adjusts the BMS loop to call ext-bms up front to mark a request before reading and forwarding values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/bms.c Outdated
Comment thread lisp/bms.lisp Outdated
@mjc
mjc force-pushed the mjc/refloat-bms-startup-grace-fix branch from e77b09a to ca54db3 Compare July 15, 2026 17:34
@mjc
mjc marked this pull request as draft July 16, 2026 01:49
@mjc

mjc commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

code review made me unsure about this and then I thought about it. minimal fix posted instead. sorry about the wild ride lmao.

@mjc
mjc marked this pull request as ready for review July 16, 2026 01:59
@mjc
mjc force-pushed the mjc/refloat-bms-startup-grace-fix branch from ede6bdc to 62d78af Compare July 16, 2026 02:00
@mjc mjc changed the title Fix BMS startup grace fault handling Suppress placeholder BMS faults during startup grace Jul 16, 2026
@lukash

lukash commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Which case is your code fixing? Seems to me they result in identical behavior because at startup bms->fault_mask = BMSF_NONE;.

@mjc

mjc commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

before:

bms->fault_mask = BMSF_NONE; // during init

// First bms_update():
fault_mask = BMSF_NONE;
if (42 > 5 && false) { ... } // does not return
if (0.0f < 2.7f) {
    set_fault(&fault_mask, BMSF_CELL_UNDER_VOLTAGE);
}
bms->fault_mask = fault_mask; // now contains false undervoltage

17d3c61 was supposed to fix this but didn't exactly do it right.

To clarify the scope: with a healthy BMS this is likely only present until the BMS Lisp thread makes its first ext-bms call, which normally happens almost immediately. It persists through the startup grace period only when no BMS snapshot is forwarded. So this is primarily a correctness fix for the intended grace period.

@mjc mjc closed this Jul 20, 2026
@mjc mjc reopened this Jul 20, 2026
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