Skip to content

Commit 23df972

Browse files
committed
bug fixes
1 parent 8d1c5ba commit 23df972

19 files changed

Lines changed: 133 additions & 55 deletions

File tree

.github/workflows/auto-bump-minor.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ jobs:
4444
# exits 0 without committing when the PR didn't touch any board or
4545
# common/ path — in that case there's nothing new on HEAD to push.
4646
if [ "$(git rev-list --count origin/main..HEAD)" -gt 0 ]; then
47-
git push origin main
48-
git push origin --tags
47+
# --atomic makes the branch update and tag push a single transaction:
48+
# if the server rejects either, neither is applied, so we never end
49+
# up with a bump commit on main without its matching tag.
50+
git push --atomic origin main --tags
4951
else
5052
echo "No version bump commit produced; nothing to push."
5153
fi

BMS/Core/User/Src/FEB_ADBMS6830B.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "FEB_ADBMS6830B_Driver.h"
1414

1515
#include <float.h>
16+
#include <math.h>
1617
#include <stdbool.h>
1718
#include <stdio.h>
1819
#include "stm32f4xx_hal.h"
@@ -362,6 +363,13 @@ static void compute_pack_temp_stats(void)
362363
}
363364
else
364365
{
366+
// All sensor readings were invalid. Publish NaN so consumers can detect
367+
// the condition (NaN propagates through comparisons as false), and raise
368+
// the same diagnostic that validate_temps() uses for chronically-low reads.
369+
FEB_ACC.pack_min_temp = NAN;
370+
FEB_ACC.pack_max_temp = NAN;
371+
FEB_ACC.average_pack_temp = NAN;
372+
FEB_ADBMS_Update_Error_Type(ERROR_TYPE_LOW_TEMP_READS);
365373
DEBUG_TEMP_PRINT("Pack stats: no valid readings");
366374
}
367375
}
@@ -737,6 +745,19 @@ void FEB_Cell_Balance_Process()
737745

738746
bool FEB_Cell_Balancing_Status(void)
739747
{
748+
// The per-cell loop used to index temp_sensor_readings by cell index, which
749+
// only covered FEB_NUM_CELLS_PER_BANK (14) of the FEB_NUM_TEMP_SENSORS (42)
750+
// sensors. Use the pack-wide max computed by compute_pack_temp_stats() so
751+
// every MUX output is considered. NaN (all-invalid readings) fails the
752+
// comparison and stops balancing — the safe default when we have no thermal
753+
// telemetry.
754+
const float max_temp_dC = FEB_ADBMS_GET_ACC_MAX_Temp() * 10.0f;
755+
if (!(max_temp_dC < FEB_CONFIG_CELL_SOFT_MAX_TEMP_dC))
756+
{
757+
LOG_W(TAG_BALANCE, "Temp limit: pack max=%.1fC, stopping", max_temp_dC / 10.0f);
758+
return false;
759+
}
760+
740761
float min_v = FLT_MAX;
741762
float max_v = FLT_MIN;
742763

@@ -745,13 +766,6 @@ bool FEB_Cell_Balancing_Status(void)
745766
for (size_t j = 0; j < FEB_NUM_CELLS_PER_BANK; ++j)
746767
{
747768
const float voltage = FEB_ADBMS_GET_Cell_Voltage(i, j) * 1000.0f;
748-
const float temp = FEB_ADBMS_GET_Cell_Temperature(i, j) * 10.0f;
749-
750-
if (temp >= FEB_CONFIG_CELL_SOFT_MAX_TEMP_dC)
751-
{
752-
LOG_W(TAG_BALANCE, "Temp limit: Bank%zu Cell%zu = %.1fC, stopping", i, j, temp / 10.0f);
753-
return false;
754-
}
755769

756770
if (voltage < 0)
757771
{

BMS/Core/User/Src/FEB_ADBMS6830B_Driver.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,18 +637,41 @@ uint8_t ADBMS6830B_rdaux(uint8_t total_ic, // The number of ICs in the system
637637
return 1;
638638
}
639639

640+
// Match rdcv/rdsv/rdsid: ensure the daisy chain is awake before the first
641+
// command or the leading frames can be dropped on a sleeping chain.
642+
wakeup_sleep(total_ic);
643+
640644
// RDAUXA: GPIO1-3 -> a_codes[0..2]
641645
transmitCMDR(RDAUXA, cell_data, NUM_RX_BYT * total_ic);
642646
for (int i = 0; i < total_ic; i++)
643647
{
644-
memcpy(&ic[i].aux.a_codes[0], cell_data + i * NUM_RX_BYT, 6);
648+
uint8_t *ic_data = cell_data + i * NUM_RX_BYT;
649+
memcpy(&ic[i].aux.a_codes[0], ic_data, 6);
650+
651+
// PEC is big-endian: ic_data[6] is MSB, ic_data[7] is LSB (same layout
652+
// as rdcfga/rdcfgb/rdsid). Record per-IC match so downstream consumers
653+
// like check_and_report_pec_errors() can drive redundancy failover.
654+
uint16_t calc_pec = Pec10_calc(false, 6, ic_data);
655+
uint16_t rx_pec = ((uint16_t)ic_data[6] << 8) | ic_data[7];
656+
bool mismatch = (calc_pec != rx_pec);
657+
ic[i].aux.pec_match[0] = mismatch ? 1 : 0;
658+
if (mismatch)
659+
pec_error++;
645660
}
646661

647662
// RDAUXB: GPIO4-6 -> a_codes[3..5]
648663
transmitCMDR(RDAUXB, cell_data, NUM_RX_BYT * total_ic);
649664
for (int i = 0; i < total_ic; i++)
650665
{
651-
memcpy(&ic[i].aux.a_codes[3], cell_data + i * NUM_RX_BYT, 6);
666+
uint8_t *ic_data = cell_data + i * NUM_RX_BYT;
667+
memcpy(&ic[i].aux.a_codes[3], ic_data, 6);
668+
669+
uint16_t calc_pec = Pec10_calc(false, 6, ic_data);
670+
uint16_t rx_pec = ((uint16_t)ic_data[6] << 8) | ic_data[7];
671+
bool mismatch = (calc_pec != rx_pec);
672+
ic[i].aux.pec_match[1] = mismatch ? 1 : 0;
673+
if (mismatch)
674+
pec_error++;
652675
}
653676

654677
vPortFree(cell_data);

BMS/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1
1+
1.0.2

DART/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.3
1+
1.0.4

DASH/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1
1+
1.0.2

DCU/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1
1+
1.0.2

LVPDB/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1
1+
1.0.2

PCU/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1
1+
1.0.2

Sensor_Nodes/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1
1+
1.0.2

0 commit comments

Comments
 (0)