The QCanBusDevice::Filter struct defines a filter for CAN bus frames. 更多...
该结构在 Qt 5.8 引入。
enum | FormatFilter { MatchBaseFormat, MatchExtendedFormat, MatchBaseAndExtendedFormat } |
flags | FormatFilters |
QCanBusDevice::Filter::FormatFilter | format |
quint32 | frameId |
quint32 | frameIdMask |
QCanBusFrame::FrameType | type |
bool | operator!= (const QCanBusDevice::Filter & a , const QCanBusDevice::Filter & b ) |
bool | operator== (const QCanBusDevice::Filter & a , const QCanBusDevice::Filter & b ) |
A list of QCanBusDevice::Filter instances is passed to QCanBusDevice::setConfigurationParameter () to enable filtering. If a received CAN frame matches at least one of the filters in the list, the QCanBusDevice will accept it.
The example below demonstrates how to use the struct:
QCanBusDevice::Filter filter; QList<QCanBusDevice::Filter> filterList; // filter all CAN bus packages with id 0x444 (base) or 0xXXXXX444 (extended) filter.frameId = 0x444u; filter.frameIdMask = 0x7FFu; filter.format = QCanBusDevice::Filter::MatchBaseAndExtendedFormat; filter.type = QCanBusFrame::InvalidFrame; filterList.append(filter); // filter all DataFrames with extended CAN bus package format filter.frameId = 0x0; filter.frameIdMask = 0x0; filter.format = QCanBusDevice::Filter::MatchExtendedFormat; filter.type = QCanBusFrame::DataFrame; filterList.append(filter); // apply filter device->setConfigurationParameter(QCanBusDevice::RawFilterKey, QVariant::fromValue(filterList));
This enum describes the format pattern, which is used to filter incoming CAN bus frames.
常量 | 值 | 描述 |
---|---|---|
QCanBusDevice::Filter::MatchBaseFormat
|
0x0001
|
The CAN bus frame must use the base frame format (11 bit identifier). |
QCanBusDevice::Filter::MatchExtendedFormat
|
0x0002
|
The CAN bus frame must use the extended frame format (29 bit identifier). |
QCanBusDevice::Filter::MatchBaseAndExtendedFormat
|
0x0003
|
The CAN bus frame can have a base or an extended frame format. |
The FormatFilters type is a typedef for QFlags <FormatFilter>. It stores an OR combination of FormatFilter values.
This variable holds the frame format of the matching CAN bus frame.
By default this field is set to QCanBusDevice::Filter::MatchBaseAndExtendedFormat .
This variable holds the frame id used to filter the incoming frames.
The frameId is used in conjunction with
frameIdMask
. The matching is successful if the following evaluates to
true
:
(receivedFrameId & frameIdMask) == (frameId & frameIdMask)
By default this field is set to
0x0
.
另请参阅 frameIdMask .
This variable holds the bit mask that is applied to the frame id of the filter and the received frame.
The two frame ids are matching if the following evaluates to
true
:
(receivedFrameId & frameIdMask) == (frameId & frameIdMask)
By default this field is set to
0x0
.
另请参阅 frameId .
This variable holds the type of the frame to be filtered.
Any CAN bus frame type can be matched by setting this variable to QCanBusFrame::InvalidFrame . The filter object is invalid if type is equal to QCanBusFrame::UnknownFrame .
By default this field is set to QCanBusFrame::InvalidFrame .
另请参阅 QCanBusFrame::FrameType .
Returns true, if the filter a is not equal to the filter b ,否则返回 false。
Returns true, if the filter a is equal to the filter b ,否则返回 false。