QCanBusDevice::Filter Struct
struct QCanBusDevice::FilterLa estructura ` QCanBusDevice::Filter ` define un filtro para tramas del bus CAN. Más información...
Tipos públicos
| enum | FormatFilter { MatchBaseFormat, MatchExtendedFormat, MatchBaseAndExtendedFormat } |
| flags | FormatFilters |
Variables públicas
| QCanBusDevice::Filter::FormatFilter | format |
| QCanBusFrame::FrameId | frameId |
| QCanBusFrame::FrameId | frameIdMask |
| QCanBusFrame::FrameType | type |
Elementos no miembros relacionados
| bool | operator!=(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b) |
| bool | operator==(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b) |
Descripción detallada
Se pasa una lista de instancias de ` QCanBusDevice::Filter ` a ` QCanBusDevice::setConfigurationParameter()` para habilitar el filtrado. Si una trama CAN recibida coincide con al menos uno de los filtros de la lista, ` QCanBusDevice ` la aceptará.
El siguiente ejemplo muestra cómo utilizar la estructura:
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));Documentación sobre los tipos de miembros
enum Filter::FormatFilter
flags Filter::FormatFilters
Esta enumeración describe el patrón de formato que se utiliza para filtrar las tramas entrantes del bus CAN.
| Constante | Valor | Descripción |
|---|---|---|
QCanBusDevice::Filter::MatchBaseFormat | 0x0001 | La trama del bus CAN debe utilizar el formato de trama básico (identificador de 11 bits). |
QCanBusDevice::Filter::MatchExtendedFormat | 0x0002 | La trama del bus CAN debe utilizar el formato de trama ampliado (identificador de 29 bits). |
QCanBusDevice::Filter::MatchBaseAndExtendedFormat | 0x0003 | La trama del bus CAN puede tener un formato básico o uno ampliado. |
El tipo FormatFilters es una definición de tipo (typedef) para QFlags<FormatFilter>. Almacena una combinación OR de valores de FormatFilter.
Documentación de las variables miembro
QCanBusDevice::Filter::FormatFilter Filter::format
Esta variable contiene el formato de la trama del bus CAN correspondiente.
Por defecto, este campo está configurado en « QCanBusDevice::Filter::MatchBaseAndExtendedFormat ».
QCanBusFrame::FrameId Filter::frameId
Esta variable contiene el identificador de trama que se utiliza para filtrar las tramas entrantes.
El «frameId» se utiliza junto con « frameIdMask ». La coincidencia se considera correcta si la siguiente expresión da como resultado « true »:
(receivedFrameId & frameIdMask) == (frameId & frameIdMask)Por defecto, este campo está establecido en 0x0.
Véase también « frameIdMask ».
QCanBusFrame::FrameId Filter::frameIdMask
Esta variable contiene la máscara de bits que se aplica al identificador de trama del filtro y al de la trama recibida.
Los dos identificadores de trama coinciden si la siguiente expresión da como resultado « true »:
(receivedFrameId & frameIdMask) == (frameId & frameIdMask)Por defecto, este campo está establecido en « 0x0 ».
Véase también « frameId ».
QCanBusFrame::FrameType Filter::type
Esta variable contiene el tipo de trama que se va a filtrar.
Se puede hacer coincidir cualquier tipo de trama del bus CAN estableciendo esta variable en « QCanBusFrame::InvalidFrame ». El objeto de filtro no es válido si el tipo es igual a « QCanBusFrame::UnknownFrame ».
Por defecto, este campo está establecido en « QCanBusFrame::InvalidFrame ».
Véase también « QCanBusFrame::FrameType ».
Elementos no miembros relacionados
[constexpr noexcept] bool operator!=(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b)
Devuelve ` true` si el filtro ` a ` no es igual al filtro ` b`; en caso contrario, devuelve ` false`.
[constexpr noexcept] bool operator==(const QCanBusDevice::Filter &a, const QCanBusDevice::Filter &b)
Devuelve « true » si el filtro « a » es igual al filtro « b »; en caso contrario, devuelve « 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.