CAN Error frame support for future extensibility

This commit is contained in:
Pavel Kirienko
2014-03-21 10:43:34 +04:00
parent 670d844f08
commit 6246f24297
4 changed files with 13 additions and 2 deletions
+6
View File
@@ -14,6 +14,7 @@ const uint32_t CanFrame::MaskStdID;
const uint32_t CanFrame::MaskExtID;
const uint32_t CanFrame::FlagEFF;
const uint32_t CanFrame::FlagRTR;
const uint32_t CanFrame::FlagERR;
std::string CanFrame::toString(StringRepresentation mode) const
@@ -42,6 +43,11 @@ std::string CanFrame::toString(StringRepresentation mode) const
{
wpos += snprintf(wpos, epos - wpos, " RTR");
}
else if (id & FlagERR)
{
// TODO: print error flags
wpos += snprintf(wpos, epos - wpos, " ERR");
}
else
{
for (int dlen = 0; dlen < dlc; dlen++) // hex bytes
+1 -1
View File
@@ -52,7 +52,7 @@ inline static uint32_t bitunpack(uint32_t val)
bool Frame::parse(const CanFrame& can_frame)
{
if ((can_frame.id & CanFrame::FlagRTR) || !(can_frame.id & CanFrame::FlagEFF))
if (can_frame.isErrorFrame() || can_frame.isRemoteTransmissionRequest() || !can_frame.isExtended())
return false;
if (can_frame.dlc > sizeof(CanFrame::data))