BMS class for managing the Accumulator (Kclear BMS) via CAN bus. More...
#include <BMS.hpp>
Public Member Functions | |
| BMS (MCP2515 &bms_can_, CarState &car_) | |
| Construct a new BMS object, initing car.pedal.status.bits.hv_ready to false. | |
| bool | hvReady () const |
| Returns true if HV has been started. | |
| void | initFilter () |
| Initializes the CAN filters for reading BMS data. Call after constructing the BMS object and the MCP2515 object it references to ensure BMS data is being read correctly. This function will block until the filter is set correctly on the MCP2515. If it never succeed, the program will be stuck here. Consider that in the case that we can't even set the filter on the MCP2515, we probably can't communicate with the BMS at all, so being stuck here is acceptable since the car won't start without BMS communication anyway. | |
| void | checkHv () |
| Attempts to start HV. First check BMS is in standby(3) state, then send the HV start command. Keep sending the command until the BMS state changes to precharge(4). Sets car.pedal.status.bits.hv_ready to true when BMS state changes to run(5). | |
Private Attributes | |
| MCP2515 & | bms_can |
| can_frame | rx_bms_msg |
| CarState & | car |
| BMS::BMS | ( | MCP2515 & | bms_can_, |
| CarState & | car_ | ||
| ) |
Construct a new BMS object, initing car.pedal.status.bits.hv_ready to false.
| bms_can_ | Reference to MCP2515 for BMS CAN bus |
| car_ | Reference to CarState, for the status flags and setting BMS data |
Definition at line 32 of file BMS.cpp.
References TelemetryFramePedal::StateByteStatus::bits, car, TelemetryFramePedal::StateByteStatus::Bits::hv_ready, CarState::pedal, and TelemetryFramePedal::status.
| void BMS::checkHv | ( | ) |
Attempts to start HV. First check BMS is in standby(3) state, then send the HV start command. Keep sending the command until the BMS state changes to precharge(4). Sets car.pedal.status.bits.hv_ready to true when BMS state changes to run(5).
Definition at line 62 of file BMS.cpp.
References TelemetryFramePedal::StateByteStatus::bits, bms_can, TelemetryFramePedal::StateByteStatus::Bits::bms_no_msg, car, DBGLN_GENERAL(), TelemetryFramePedal::StateByteStatus::Bits::hv_ready, CarState::pedal, rx_bms_msg, start_hv_msg, and TelemetryFramePedal::status.
Referenced by scheduler_bms().
|
inline |
Returns true if HV has been started.
Definition at line 54 of file BMS.hpp.
References TelemetryFramePedal::StateByteStatus::bits, car, TelemetryFramePedal::StateByteStatus::Bits::hv_ready, CarState::pedal, and TelemetryFramePedal::status.
| void BMS::initFilter | ( | ) |
Initializes the CAN filters for reading BMS data. Call after constructing the BMS object and the MCP2515 object it references to ensure BMS data is being read correctly. This function will block until the filter is set correctly on the MCP2515. If it never succeed, the program will be stuck here. Consider that in the case that we can't even set the filter on the MCP2515, we probably can't communicate with the BMS at all, so being stuck here is acceptable since the car won't start without BMS communication anyway.
Definition at line 45 of file BMS.cpp.
References bms_can, and BMS_INFO_EXT.
Referenced by setup().
|
private |
Reference to MCP2515 for BMS CAN bus
Definition at line 59 of file BMS.hpp.
Referenced by checkHv(), and initFilter().
|
private |
|
private |