Skip to content

Commit

Permalink
Potential fix for initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jhwang04 committed May 17, 2024
1 parent ba0839b commit 74aca71
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/interfaces/src/AMSInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ void AMSInterface::init(SysTick_s &initial_tick) {

// Initializes the bms_voltages_ member variable to an invalid state. This will
// get overridden once retrieve_voltage_CAN() has been called at least once.
CAN_message_t can_msg;
uint16_t avg = 0x9999U, low = 0xFFFFU, high = 0x1111U, nan = 0x0000U;
memcpy(&can_msg.buf, &avg, sizeof(uint16_t));
memcpy(&can_msg.buf[2], &low, sizeof(uint16_t));
memcpy(&can_msg.buf[4], &high, sizeof(uint16_t));
memcpy(&can_msg.buf[6], &nan, sizeof(uint16_t));
retrieve_voltage_CAN(can_msg);
bms_voltages_.low_voltage_ro = 0xFFFFU;
bms_voltages_.high_voltage_ro = 0x1111U;

}

Expand Down Expand Up @@ -122,7 +117,7 @@ void AMSInterface::tick(const SysTick_s &tick) {
// If AMSInterface has a valid reading in bms_voltages_ and the charge is not
// yet initialized, then call initialize_charge.
if (!has_initialized_charge_) {

bool bms_voltages_is_invalid = bms_voltages_.low_voltage_ro == 0xFFFFU && bms_voltages_.high_voltage_ro == 0x1111U;

if (!bms_voltages_is_invalid) {
Expand Down

0 comments on commit 74aca71

Please sign in to comment.