Skip to content

Commit

Permalink
DBC parser: add back checksum start bit and length checks (#636)
Browse files Browse the repository at this point in the history
* Revert "remove checksum and counter alignment checks (#634)"

This reverts commit f3232cc.

* add logic to ignore checksum check if -1

* think we need size too
  • Loading branch information
sshane authored Jun 13, 2022
1 parent 05d53c4 commit 567601d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion can/dbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ ChecksumState* get_checksum(const std::string& dbc_name) {
void set_signal_type(Signal& s, ChecksumState* chk, const std::string& dbc_name, int line_num) {
if (chk) {
if (s.name == "CHECKSUM") {
DBC_ASSERT(s.size == chk->checksum_size, "CHECKSUM is not " << chk->checksum_size << " bits long");
DBC_ASSERT(chk->checksum_size == -1 || s.size == chk->checksum_size, "CHECKSUM is not " << chk->checksum_size << " bits long");
DBC_ASSERT(chk->checksum_start_bit == -1 || (s.start_bit % 8) == chk->checksum_start_bit, " CHECKSUM starts at wrong bit");
DBC_ASSERT(s.is_little_endian == chk->little_endian, "CHECKSUM has wrong endianness");
s.type = chk->checksum_type;
} else if (s.name == "COUNTER") {
DBC_ASSERT(chk->counter_size == -1 || s.size == chk->counter_size, "COUNTER is not " << chk->counter_size << " bits long");
DBC_ASSERT(chk->counter_start_bit == -1 || (s.start_bit % 8) == chk->counter_start_bit, "COUNTER starts at wrong bit");
DBC_ASSERT(chk->little_endian == s.is_little_endian, "COUNTER has wrong endianness");
s.type = chk->counter_type;
}
Expand Down

0 comments on commit 567601d

Please sign in to comment.