CAN HW filters are added using map container

This commit is contained in:
ilia-sheremet
2015-06-26 14:35:53 +02:00
parent bad7123b7d
commit 573b268457
43 changed files with 953 additions and 782 deletions
+19 -16
View File
@@ -16,7 +16,6 @@ namespace uavcan
/**
* Raw CAN frame, as passed to/from the CAN driver.
*/
UAVCAN_PACKED_BEGIN
struct UAVCAN_EXPORT CanFrame
{
static const uint32_t MaskStdID = 0x000007FFU;
@@ -31,16 +30,16 @@ struct UAVCAN_EXPORT CanFrame
uint8_t data[MaxDataLen];
uint8_t dlc; ///< Data Length Code
CanFrame()
: id(0)
, dlc(0)
CanFrame() :
id(0),
dlc(0)
{
fill(data, data + MaxDataLen, uint8_t(0));
}
CanFrame(uint32_t can_id, const uint8_t* can_data, uint8_t data_len)
: id(can_id)
, dlc((data_len > MaxDataLen) ? MaxDataLen : data_len)
CanFrame(uint32_t can_id, const uint8_t* can_data, uint8_t data_len) :
id(can_id),
dlc((data_len > MaxDataLen) ? MaxDataLen : data_len)
{
UAVCAN_ASSERT(can_data != NULL);
UAVCAN_ASSERT(data_len == dlc);
@@ -63,7 +62,9 @@ struct UAVCAN_EXPORT CanFrame
StrTight, ///< Minimum string length (default)
StrAligned ///< Fixed formatting for any frame
};
std::string toString(StringRepresentation mode = StrTight) const;
#endif
/**
@@ -74,7 +75,6 @@ struct UAVCAN_EXPORT CanFrame
bool priorityHigherThan(const CanFrame& rhs) const;
bool priorityLowerThan(const CanFrame& rhs) const { return rhs.priorityHigherThan(*this); }
};
UAVCAN_PACKED_END
/**
* CAN hardware filter config struct.
@@ -86,15 +86,14 @@ struct UAVCAN_EXPORT CanFilterConfig
uint32_t id;
uint32_t mask;
//bool operator == (const CanFilterConfig&) const;
bool operator==(const CanFilterConfig& rhs) const
{
return rhs.id == id && rhs.mask == mask;
}
CanFilterConfig()
: id(0)
, mask(0)
CanFilterConfig() :
id(0),
mask(0)
{ }
};
@@ -107,9 +106,9 @@ struct UAVCAN_EXPORT CanSelectMasks
uint8_t read;
uint8_t write;
CanSelectMasks()
: read(0)
, write(0)
CanSelectMasks() :
read(0),
write(0)
{ }
};
@@ -178,7 +177,11 @@ public:
* Returns an interface by index, or null pointer if the index is out of range.
*/
virtual ICanIface* getIface(uint8_t iface_index) = 0;
virtual const ICanIface* getIface(uint8_t iface_index) const = 0;
virtual const ICanIface* getIface(uint8_t iface_index) const
{
return const_cast<ICanDriver*>(this)->getIface(iface_index);
}
/**
* Total number of available CAN interfaces.