Skip to content

Commit

Permalink
Add CANMessage deep comparison operators
Browse files Browse the repository at this point in the history
  • Loading branch information
AGlass0fMilk committed May 16, 2021
1 parent 7279ae2 commit dfc1d3c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions drivers/include/drivers/interfaces/InterfaceCAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ class CANMessage : public CAN_Message {
id = _id;
memset(data, 0, 8);
}

bool CANMessage::operator ==(const CANMessage &b) const {
if(id != b.id)
return false;
if(len != b.len)
return false;
if(format != b.format)
return false;
if(type != b.type)
return false;
if(memcmp(data, b.data, len) != 0)
return false;

return true;
}

bool CANMessage::operator !=(const CANMessage &b) const {
return !(*this == b);
}
};

/** @}*/
Expand Down

0 comments on commit dfc1d3c

Please sign in to comment.