Skip to content

Commit

Permalink
moving checksum+counter back to panda/dbc
Browse files Browse the repository at this point in the history
  • Loading branch information
dkiiv committed Jul 22, 2024
1 parent 40a1d39 commit 764d7b6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
20 changes: 15 additions & 5 deletions opendbc/can/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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){

This comment has been minimized.

Copy link
@FLcruising

FLcruising Jul 23, 2024

Revert this

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;
Expand Down
4 changes: 2 additions & 2 deletions opendbc/vw_golf_mk4.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment has been minimized.

Copy link
@FLcruising

FLcruising Jul 23, 2024

Change this to BO_ 980 PLA_1: 4 XXX and test it

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
Expand Down
4 changes: 1 addition & 3 deletions selfdrive/car/volkswagen/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ******************************************** #

Expand Down
4 changes: 1 addition & 3 deletions selfdrive/car/volkswagen/pqcan.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)


Expand Down

0 comments on commit 764d7b6

Please sign in to comment.