mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 06:23:34 +08:00
Proper priority comparison for CAN frames of different types
This commit is contained in:
@@ -61,16 +61,13 @@ struct CanFrame
|
||||
enum StringRepresentation { StrTight, StrAligned };
|
||||
std::string toString(StringRepresentation mode = StrTight) const;
|
||||
|
||||
// TODO: priority comparison for EXT vs STD frames
|
||||
bool priorityHigherThan(const CanFrame& rhs) const
|
||||
{
|
||||
return (id & CanFrame::MaskExtID) < (rhs.id & CanFrame::MaskExtID);
|
||||
}
|
||||
|
||||
bool priorityLowerThan(const CanFrame& rhs) const
|
||||
{
|
||||
return (id & CanFrame::MaskExtID) > (rhs.id & CanFrame::MaskExtID);
|
||||
}
|
||||
/**
|
||||
* CAN frames arbitration rules, particularly STD vs EXT:
|
||||
* Marco Di Natale - "Understanding and using the Controller Area Network"
|
||||
* http://www6.in.tum.de/pub/Main/TeachingWs2013MSE/CANbus.pdf
|
||||
*/
|
||||
bool priorityHigherThan(const CanFrame& rhs) const;
|
||||
bool priorityLowerThan(const CanFrame& rhs) const { return rhs.priorityHigherThan(*this); }
|
||||
};
|
||||
UAVCAN_PACKED_END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user