Skip to content

added new mazda with TI2 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master_old
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions can/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ unsigned int chrysler_checksum(uint32_t address, const Signal &sig, const std::v
return ~checksum & 0xFF;
}

unsigned int mazda_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d) {
uint8_t checksum = 0;
if (address == 0x220U) {
checksum = 0x2aU;
}
if (address == 0x249U){
checksum = 0x53U;
}
// Simple XOR over the payload, except for the byte where the checksum lives.
for (int i = 0; i < 7; i++) {
checksum += d[i];
}
return checksum;
}


// Static lookup table for fast computation of CRCs
uint8_t crc8_lut_8h2f[256]; // CRC8 poly 0x2F, aka 8H2F/AUTOSAR
uint16_t crc16_lut_xmodem[256]; // CRC16 poly 0x1021, aka XMODEM
Expand Down
1 change: 1 addition & 0 deletions can/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ unsigned int honda_checksum(uint32_t address, const Signal &sig, const std::vect
unsigned int toyota_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
unsigned int subaru_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
unsigned int chrysler_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
unsigned int mazda_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
unsigned int volkswagen_mqb_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
unsigned int xor_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
unsigned int hkg_can_fd_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
Expand Down
1 change: 1 addition & 0 deletions can/common.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cdef extern from "common_dbc.h":
SUBARU_CHECKSUM,
CHRYSLER_CHECKSUM
HKG_CAN_FD_CHECKSUM,
MAZDA2019_CHECKSUM,

cdef struct Signal:
string name
Expand Down
1 change: 1 addition & 0 deletions can/common_dbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum SignalType {
SUBARU_CHECKSUM,
CHRYSLER_CHECKSUM,
HKG_CAN_FD_CHECKSUM,
MAZDA2019_CHECKSUM,
};

struct Signal {
Expand Down
2 changes: 2 additions & 0 deletions can/dbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ ChecksumState* get_checksum(const std::string& dbc_name) {
s = new ChecksumState({8, -1, 7, -1, false, CHRYSLER_CHECKSUM, &chrysler_checksum});
} else if (startswith(dbc_name, "comma_body")) {
s = new ChecksumState({8, 4, 7, 3, false, PEDAL_CHECKSUM, &pedal_checksum});
} else if (startswith(dbc_name, "mazda_2019")) {
s = new ChecksumState({8, 8, 0, 0, true, MAZDA2019_CHECKSUM, &mazda_checksum});
}
return s;
}
Expand Down
Loading