QCanBusDevice::Filter Struct
struct QCanBusDevice::FilterLa estructura QCanBusDevice::Filter define un filtro para las tramas de bus CAN. Más...
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 |
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
Una lista de instancias QCanBusDevice::Filter se pasa 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));
Miembro Tipo Documentación
enum Filter::FormatFilter
banderas Filter::FormatFilters
Este enum 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 de bus CAN debe utilizar el formato de trama base (identificador de 11 bits). |
QCanBusDevice::Filter::MatchExtendedFormat | 0x0002 | La trama de bus CAN debe utilizar el formato de trama ampliado (identificador de 29 bits). |
QCanBusDevice::Filter::MatchBaseAndExtendedFormat | 0x0003 | La trama de bus CAN puede tener un formato de trama base o ampliado. |
El tipo FormatFilters es un typedef para QFlags<FormatFilter>. Almacena una combinación OR de valores FormatFilter.
Documentación de variables de miembro
QCanBusDevice::Filter::FormatFilter Filter::format
Esta variable contiene el formato de trama de la trama de bus CAN correspondiente.
Por defecto, este campo está configurado en QCanBusDevice::Filter::MatchBaseAndExtendedFormat.
QCanBusFrame::FrameId Filter::frameId
Esta variable contiene el frameId utilizado para filtrar las tramas entrantes.
El frameId se utiliza junto con frameIdMask. La coincidencia tiene éxito si lo siguiente se evalúa como true:
(receivedFrameId & frameIdMask) == (frameId & frameIdMask)
Por defecto, este campo se establece 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 a la trama recibida.
Los dos identificadores de trama coinciden si se evalúa como true:
(receivedFrameId & frameIdMask) == (frameId & frameIdMask)
Por defecto, este campo tiene el valor 0x0.
Véase también frameId.
QCanBusFrame::FrameType Filter::type
Esta variable contiene el tipo de trama que se va a filtrar.
Cualquier tipo de trama de bus CAN puede coincidir ajustando esta variable a QCanBusFrame::InvalidFrame. El objeto de filtro no es válido si type es igual a QCanBusFrame::UnknownFrame.
Por defecto, este campo tiene el valor QCanBusFrame::InvalidFrame.
Véase también QCanBusFrame::FrameType.
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.