Skip to content

Commit

Permalink
EGS51. Freeze driver torque before request
Browse files Browse the repository at this point in the history
  • Loading branch information
rnd-ash committed Aug 16, 2024
1 parent d83399c commit 684f5f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/canbus/can_egs51.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,16 @@ int Egs51Can::get_static_engine_torque(const uint32_t expire_time_ms) {

int Egs51Can::get_driver_engine_torque(const uint32_t expire_time_ms) {
// Don't think EGS51 supports this so just run with static torque for now
return this->get_static_engine_torque(expire_time_ms);
int tmp;
if (this->gs218.TORQUE_REQ_EN) { // Active torque request (Frozen value for now)
tmp = this->torque_before_request;
} else { // No torque request (Unfreeze the torque value)
tmp = this->get_static_engine_torque(expire_time_ms);
this->torque_before_request = tmp;
}


return tmp;
}

int Egs51Can::get_maximum_engine_torque(const uint32_t expire_time_ms) {
Expand Down
1 change: 1 addition & 0 deletions src/canbus/can_egs51.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Egs51Can: public EgsBaseCan {
void tx_frames() override;
void on_rx_frame(uint32_t id, uint8_t dlc, uint64_t data, uint32_t timestamp) override;
private:
int16_t torque_before_request=0;
// CAN Frames to Tx
GS_218_EGS51 gs218 = {0};
ECU_MS51 ms51 = ECU_MS51();
Expand Down

0 comments on commit 684f5f3

Please sign in to comment.