Skip to content

Commit

Permalink
Subaru: cruise_rpm and cruise_throttle are 13 bits (commaai#1786)
Browse files Browse the repository at this point in the history
* fix cruise throttle

* and es_status

* bump opendbc
  • Loading branch information
jnewb1 authored Dec 30, 2023
1 parent 0bcaa73 commit 20722a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"

ENV PANDA_PATH=/tmp/openpilot/panda
ENV OPENPILOT_REF="5690386d8d731c9bebda536a5c71c890f6dfe98c"
ENV OPENDBC_REF="5b0c73977f1428700d0344d52874a90a4c5168fb"
ENV OPENDBC_REF="40d9c723d48496229fecc436046538a53af19c11"

COPY requirements.txt /tmp/
RUN pyenv install 3.11.4 && \
Expand Down
4 changes: 2 additions & 2 deletions board/safety/safety_subaru.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static bool subaru_tx_hook(CANPacket_t *to_send) {

// check es_distance cruise_throttle limits
if (addr == MSG_SUBARU_ES_Distance) {
int cruise_throttle = (GET_BYTES(to_send, 2, 2) & 0xFFFU);
int cruise_throttle = (GET_BYTES(to_send, 2, 2) & 0x1FFFU);
bool cruise_cancel = GET_BIT(to_send, 56U) != 0U;

if (subaru_longitudinal) {
Expand All @@ -218,7 +218,7 @@ static bool subaru_tx_hook(CANPacket_t *to_send) {

// check es_status transmission_rpm limits
if (addr == MSG_SUBARU_ES_Status) {
int transmission_rpm = (GET_BYTES(to_send, 2, 2) & 0xFFFU);
int transmission_rpm = (GET_BYTES(to_send, 2, 2) & 0x1FFFU);
violation |= longitudinal_transmission_rpm_checks(transmission_rpm, SUBARU_LONG_LIMITS);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/safety/test_subaru.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ class TestSubaruLongitudinalSafetyBase(TestSubaruSafetyBase, common.Longitudinal
MIN_GAS = 808
MAX_GAS = 3400
INACTIVE_GAS = 1818
MAX_POSSIBLE_GAS = 2**12
MAX_POSSIBLE_GAS = 2**13

MIN_BRAKE = 0
MAX_BRAKE = 600
MAX_POSSIBLE_BRAKE = 2**16

MIN_RPM = 0
MAX_RPM = 2400
MAX_POSSIBLE_RPM = 2**12
MAX_POSSIBLE_RPM = 2**13

FWD_BLACKLISTED_ADDRS = {2: [SubaruMsg.ES_LKAS, SubaruMsg.ES_Brake, SubaruMsg.ES_Distance,
SubaruMsg.ES_Status, SubaruMsg.ES_DashStatus,
Expand Down

0 comments on commit 20722a5

Please sign in to comment.