diff --git a/opendbc/can/common.cc b/opendbc/can/common.cc index 37b48fa6aa860b..662d4edc4ee9e2 100644 --- a/opendbc/can/common.cc +++ b/opendbc/can/common.cc @@ -193,11 +193,21 @@ unsigned int xor_checksum(uint32_t address, const Signal &sig, const std::vector uint8_t checksum = 0; int checksum_byte = sig.start_bit / 8; - // Simple XOR over the payload, except for the byte where the checksum lives. - for (int i = 0; i < d.size(); i++) { - if (i != checksum_byte) { - checksum ^= d[i]; - } + switch(address){ + case 0x3D4: // mPLA_1, TX from OP + for (int i = 0; i < 3; i++) { + if (i != checksum_byte) { + checksum ^= d[i]; + } + } + break; + default: // Simple XOR over the payload, except for the byte where the checksum lives. + for (int i = 0; i < d.size(); i++) { + if (i != checksum_byte) { + checksum ^= d[i]; + } + } + break; } return checksum; diff --git a/opendbc/vw_golf_mk4.dbc b/opendbc/vw_golf_mk4.dbc index cc35617c6234c5..38e9c51f7d3fde 100644 --- a/opendbc/vw_golf_mk4.dbc +++ b/opendbc/vw_golf_mk4.dbc @@ -1152,8 +1152,8 @@ BO_ 978 Lenkhilfe_2: 7 XXX SG_ LH2_PLA_Abbr : 52|4@1+ (1,0) [0|15] "" XXX BO_ 980 PLA_1: 8 XXX - SG_ PL1_Checksumme : 0|8@1+ (1,0) [0|255] "" XXX - SG_ PL1_Zaehler : 8|4@1+ (1,0) [0|15] "" XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX SG_ PL1_Status_EPS : 12|4@1+ (1,0) [0|15] "" XXX SG_ PL1_ArcAngleReq : 16|15@1+ (0.04375,0) [0|1433.55625] "Unit_DegreeOfArc" XXX SG_ PL1_AngleReqSign : 31|1@1+ (1,0) [0|1] "" XXX diff --git a/selfdrive/car/volkswagen/carcontroller.py b/selfdrive/car/volkswagen/carcontroller.py index 1150d1e1720218..0b70a41b9bd1a1 100644 --- a/selfdrive/car/volkswagen/carcontroller.py +++ b/selfdrive/car/volkswagen/carcontroller.py @@ -25,7 +25,6 @@ def __init__(self, dbc_name, CP, VM): self.PLA_status = 0 self.PLA_entryCounter = 0 self.CSsteeringAngleDegLast = 0 - self.PLAidx = 0 def update(self, CC, CS, ext_bus, now_nanos, frogpilot_variables): actuators = CC.actuators @@ -51,8 +50,7 @@ def update(self, CC, CS, ext_bus, now_nanos, frogpilot_variables): self.apply_angle_last = apply_angle self.CSsteeringAngleDegLast = CS.out.steeringAngleDeg - self.PLAidx = (self.frame / self.CCP.STEER_STEP) % 16 - can_sends.append(self.CCS.create_steering_control(self.packer_pt, CANBUS.br, self.PLAidx, apply_angle, self.PLA_status)) + can_sends.append(self.CCS.create_steering_control(self.packer_pt, CANBUS.br, apply_angle, self.PLA_status)) # **** Acceleration Controls ******************************************** # diff --git a/selfdrive/car/volkswagen/pqcan.py b/selfdrive/car/volkswagen/pqcan.py index 87be076067cb06..17c1b50f765edc 100644 --- a/selfdrive/car/volkswagen/pqcan.py +++ b/selfdrive/car/volkswagen/pqcan.py @@ -1,6 +1,5 @@ -def create_steering_control(packer, bus, idx, apply_angle, PLA_status): +def create_steering_control(packer, bus, apply_angle, PLA_status): values = { - "PL1_Zaehler": idx, "PL1_Status_EPS": PLA_status, "PL1_ArcAngleReq": abs(apply_angle), "PL1_AngleReqSign": 1 if apply_angle < 0 else 0, @@ -9,7 +8,6 @@ def create_steering_control(packer, bus, idx, apply_angle, PLA_status): } dat = packer.make_can_msg("PLA_1", bus, values)[2] - values["PL1_Checksumme"] = dat[1] ^ dat[2] ^ dat[3] return packer.make_can_msg("PLA_1", bus, values)