Skip to content

Commit

Permalink
CANParser: add msg name to debug prints (commaai#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored and mlocoteta committed Apr 29, 2023
1 parent 5852150 commit aa84b7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions can/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ unsigned int pedal_checksum(uint32_t address, const Signal &sig, const std::vect

class MessageState {
public:
std::string name;
uint32_t address;
unsigned int size;

Expand Down
6 changes: 4 additions & 2 deletions can/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ CANParser::CANParser(int abus, const std::string& dbc_name,
assert(false);
}

state.name = msg->name;
state.size = msg->size;
assert(state.size <= 64); // max signal size is 64 bytes

Expand Down Expand Up @@ -162,6 +163,7 @@ CANParser::CANParser(int abus, const std::string& dbc_name, bool ignore_checksum

for (const auto& msg : dbc->msgs) {
MessageState state = {
.name = msg.name,
.address = msg.address,
.size = msg.size,
.ignore_checksum = ignore_checksum,
Expand Down Expand Up @@ -287,9 +289,9 @@ void CANParser::UpdateValid(uint64_t sec) {
if (state.check_threshold > 0 && (missing || timed_out)) {
if (show_missing && !bus_timeout) {
if (missing) {
LOGE("0x%X NOT SEEN", state.address);
LOGE("0x%X '%s' NOT SEEN", state.address, state.name.c_str());
} else if (timed_out) {
LOGE("0x%X TIMED OUT", state.address);
LOGE("0x%X '%s' TIMED OUT", state.address, state.name.c_str());
}
}
_valid = false;
Expand Down

0 comments on commit aa84b7f

Please sign in to comment.