QCanBusDevice::Filter Struct
struct QCanBusDevice::FilterQCanBusDevice::Filter 構造体は、CANバスフレーム用のフィルタを定義します。詳細...
パブリック型
| enum | FormatFilter { MatchBaseFormat, MatchExtendedFormat, MatchBaseAndExtendedFormat } |
| flags | FormatFilters |
パブリック変数
| QCanBusDevice::Filter::FormatFilter | format |
| QCanBusFrame::FrameId | frameId |
| QCanBusFrame::FrameId | frameIdMask |
| QCanBusFrame::FrameType | type |
関連する非メンバ
| bool | operator!=(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b) |
| bool | operator==(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b) |
詳細な説明
フィルタリングを有効にするには、QCanBusDevice::Filter インスタンスのリストをQCanBusDevice::setConfigurationParameter()に渡します。受信したCANフレームがリスト内のフィルタの少なくとも1つに一致する場合、QCanBusDevice はそのフレームを受け入れます。
以下の例は、この構造体の使用方法を示しています:
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));メンバ型のドキュメント
enum Filter::FormatFilter
flags Filter::FormatFilters
この列挙型は、受信したCANバスフレームをフィルタリングするために使用されるフォーマットパターンを定義します。
| 定数 | 値 | 説明 |
|---|---|---|
QCanBusDevice::Filter::MatchBaseFormat | 0x0001 | CAN バスフレームは、基本フレーム形式(11 ビットの識別子)を使用する必要があります。 |
QCanBusDevice::Filter::MatchExtendedFormat | 0x0002 | CAN バスフレームは、拡張フレームフォーマット(29 ビットの識別子)を使用している必要があります。 |
QCanBusDevice::Filter::MatchBaseAndExtendedFormat | 0x0003 | CAN バスフレームは、基本フレーム形式または拡張フレーム形式のいずれかを使用できます。 |
FormatFilters 型は、QFlags<FormatFilter> の typedef です。これは、FormatFilter 値の OR 結合を格納します。
メンバ変数のドキュメント
QCanBusDevice::Filter::FormatFilter Filter::format
この変数には、一致したCANバスフレームのフレーム形式が格納されます。
デフォルトでは、このフィールドはQCanBusDevice::Filter::MatchBaseAndExtendedFormat に設定されています。
QCanBusFrame::FrameId Filter::frameId
この変数には、受信フレームのフィルタリングに使用されるフレームIDが格納されます。
frameIdはframeIdMask と組み合わせて使用されます。以下の式がtrue と評価された場合、マッチングは成功します:
(receivedFrameId & frameIdMask) == (frameId & frameIdMask)デフォルトでは、このフィールドは0x0 に設定されています。
「frameIdMask」も参照してください 。
QCanBusFrame::FrameId Filter::frameIdMask
この変数には、フィルタのフレームIDおよび受信フレームのフレームIDに適用されるビットマスクが格納されます。
以下の式がtrue と評価される場合、2つのフレームIDは一致しているとみなされます:
(receivedFrameId & frameIdMask) == (frameId & frameIdMask)デフォルトでは、このフィールドは `0x0` に設定されています。
「frameId」も参照してください 。
QCanBusFrame::FrameType Filter::type
この変数には、フィルタリング対象となるフレームのタイプが格納されます。
この変数をQCanBusFrame::InvalidFrame に設定することで、任意のCANバスフレームタイプに一致させることができます。typeがQCanBusFrame::UnknownFrame の場合、フィルタオブジェクトは無効となります。
デフォルトでは、このフィールドはQCanBusFrame::InvalidFrame に設定されています。
「QCanBusFrame::FrameType」も参照してください 。
関連する非メンバ
[constexpr noexcept] bool operator!=(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b)
フィルタ `a ` がフィルタ `b` と等しくない場合は `true` を返し、それ以外の場合は `false` を返します。
[constexpr noexcept] bool operator==(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b)
フィルタ `a ` がフィルタ `b` と等しい場合は `true` を返し、そうでない場合は `false` を返します。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.