In questa pagina

QCanBusDevice::Filter Struct

struct QCanBusDevice::Filter

La struttura ` QCanBusDevice::Filter ` definisce un filtro per i frame del bus CAN. Maggiori informazioni...

Tipi pubblici

enum FormatFilter { MatchBaseFormat, MatchExtendedFormat, MatchBaseAndExtendedFormat }
flags FormatFilters

Variabili pubbliche

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)

Descrizione dettagliata

Un elenco di istanze di ` QCanBusDevice::Filter ` viene passato a ` QCanBusDevice::setConfigurationParameter()` per abilitare il filtraggio. Se un frame CAN ricevuto corrisponde ad almeno uno dei filtri presenti nell'elenco, l'QCanBusDevice e lo accetterà.

L'esempio seguente illustra come utilizzare la struttura:

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));

Documentazione sui tipi dei membri

enum Filter::FormatFilter
flags Filter::FormatFilters

Questa enumerazione descrive il modello di formato utilizzato per filtrare i frame in entrata sul bus CAN.

CostanteValoreDescrizione
QCanBusDevice::Filter::MatchBaseFormat0x0001Il frame del bus CAN deve utilizzare il formato base (identificatore a 11 bit).
QCanBusDevice::Filter::MatchExtendedFormat0x0002Il frame del bus CAN deve utilizzare il formato frame esteso (identificatore a 29 bit).
QCanBusDevice::Filter::MatchBaseAndExtendedFormat0x0003Il frame del bus CAN può avere un formato base o esteso.

Il tipo FormatFilters è un typedef per QFlags<FormatFilter>. Memorizza una combinazione OR di valori FormatFilter.

Documentazione delle variabili membro

QCanBusDevice::Filter::FormatFilter Filter::format

Questa variabile contiene il formato del frame CAN corrispondente.

Per impostazione predefinita, questo campo è impostato su QCanBusDevice::Filter::MatchBaseAndExtendedFormat.

QCanBusFrame::FrameId Filter::frameId

Questa variabile contiene l'ID del frame utilizzato per filtrare i frame in entrata.

Il frameId viene utilizzato in combinazione con ` frameIdMask`. La corrispondenza ha esito positivo se la seguente espressione restituisce ` true`:

(receivedFrameId & frameIdMask) == (frameId & frameIdMask)

Per impostazione predefinita, questo campo è impostato su 0x0.

Vedi anche frameIdMask.

QCanBusFrame::FrameId Filter::frameIdMask

Questa variabile contiene la maschera di bit che viene applicata all'ID del frame del filtro e a quello del frame ricevuto.

I due ID di frame corrispondono se l'espressione seguente restituisce il valore true:

(receivedFrameId & frameIdMask) == (frameId & frameIdMask)

Per impostazione predefinita, questo campo è impostato su 0x0.

Vedi anche frameId.

QCanBusFrame::FrameType Filter::type

Questa variabile contiene il tipo di frame da filtrare.

È possibile abbinare qualsiasi tipo di frame del bus CAN impostando questa variabile su QCanBusFrame::InvalidFrame. L'oggetto filtro non è valido se il tipo è uguale a QCanBusFrame::UnknownFrame.

Per impostazione predefinita, questo campo è impostato su QCanBusFrame::InvalidFrame.

Vedi anche QCanBusFrame::FrameType.

Elementi correlati non membri

[constexpr noexcept] bool operator!=(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b)

Restituisce ` true` se il filtro ` a ` non è uguale al filtro ` b`; in caso contrario, restituisce ` false`.

[constexpr noexcept] bool operator==(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b)

Restituisce ` true`, se il filtro ` a ` è uguale al filtro ` b`; in caso contrario, restituisce ` 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.