QCanMessageDescription Class

The QCanMessageDescription class describes the rules to process a CAN message and represent it in an application-defined format. More...

Header: #include <QCanMessageDescription>
CMake: find_package(Qt6 REQUIRED COMPONENTS SerialBus)
target_link_libraries(mytarget PRIVATE Qt6::SerialBus)
qmake: QT += serialbus
Since: Qt 6.5

This class is under development and is subject to change.

Public Functions

QCanMessageDescription()
QCanMessageDescription(const QCanMessageDescription &other)
QCanMessageDescription(QCanMessageDescription &&other)
~QCanMessageDescription()
void addSignalDescription(const QCanSignalDescription &description)
void clearSignalDescriptions()
QString comment() const
bool isValid() const
QString name() const
void setComment(const QString &text)
void setName(const QString &name)
void setSignalDescriptions(const QList<QCanSignalDescription> &descriptions)
void setSize(quint8 size)
void setTransmitter(const QString &transmitter)
void setUniqueId(QtCanBus::UniqueId id)
QCanSignalDescription signalDescriptionForName(const QString &name) const
QList<QCanSignalDescription> signalDescriptions() const
quint8 size() const
QString transmitter() const
QtCanBus::UniqueId uniqueId() const
QCanMessageDescription &operator=(const QCanMessageDescription &other)
QCanMessageDescription &operator=(QCanMessageDescription &&other)

Detailed Description

A CAN message is basically a QCanBusFrame. The description of a CAN message includes the following:

  • Message ID.
  • Message name.
  • Message length in bytes.
  • Source of the message (transmitter).
  • Description of signals in the message.

The QCanMessageDescription class provides methods to control all those parameters.

Message ID

The message ID is a unique identifier, which is used to select the proper message description when decoding the incoming QCanBusFrame or encoding a QCanBusFrame based on the provided data.

See QCanUniqueIdDescription documentation for more details on the unique identifier description.

Signal Description

The signal description is represented by the QCanSignalDescription class. The QCanMessageDescription class only provides a list of signals that belong to the message.

See also QCanSignalDescription and QCanUniqueIdDescription.

Member Function Documentation

QCanMessageDescription::QCanMessageDescription()

Creates an empty message description.

QCanMessageDescription::QCanMessageDescription(const QCanMessageDescription &other)

Creates a message description with the values copied from other.

QCanMessageDescription::QCanMessageDescription(QCanMessageDescription &&other)

Creates a message description by moving from other.

Note: The moved-from QCanMessageDescription object can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.

QCanMessageDescription::~QCanMessageDescription()

Destroys this message description.

void QCanMessageDescription::addSignalDescription(const QCanSignalDescription &description)

Adds a new signal description description to this message description.

If the message description already has a signal description for a signal with the same name, it is overwritten.

See also signalDescriptions(), signalDescriptionForName(), setSignalDescriptions(), and clearSignalDescriptions().

void QCanMessageDescription::clearSignalDescriptions()

Clears all the signal descriptions of this message.

See also signalDescriptions(), signalDescriptionForName(), addSignalDescription(), and setSignalDescriptions().

QString QCanMessageDescription::comment() const

Returns the comment for the message.

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

See also setComment().

bool QCanMessageDescription::isValid() const

Returns true when the message description is valid and false otherwise.

A valid message description must have at least one signal description. All signal descriptions must be valid as well.

See also signalDescriptions() and QCanSignalDescription::isValid().

QString QCanMessageDescription::name() const

Returns the name of the CAN message.

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

See also setName().

void QCanMessageDescription::setComment(const QString &text)

Sets the comment for the message to text.

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

See also comment().

void QCanMessageDescription::setName(const QString &name)

Sets the name of the CAN message to name.

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

See also name().

void QCanMessageDescription::setSignalDescriptions(const QList<QCanSignalDescription> &descriptions)

Sets the descriptions of the signals belonging to this message description to descriptions.

Note: Message description must have signal descriptions with unique signal names, so if the descriptions list contains entries with duplicated names, only the last entry will be added.

See also signalDescriptions(), signalDescriptionForName(), addSignalDescription(), and clearSignalDescriptions().

void QCanMessageDescription::setSize(quint8 size)

Sets the size in bytes of the CAN message to size.

See also size().

void QCanMessageDescription::setTransmitter(const QString &transmitter)

Sets the transmitter node of the message to transmitter.

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

See also transmitter().

void QCanMessageDescription::setUniqueId(QtCanBus::UniqueId id)

Sets the unique identifier of the CAN message to id.

See the Message ID section for more information about the unique identifier.

See also uniqueId().

QCanSignalDescription QCanMessageDescription::signalDescriptionForName(const QString &name) const

Returns the signal description of a signal with the name name.

If the message description does not have such signal description, a default-constructed QCanSignalDescription object is returned.

See also signalDescriptions(), addSignalDescription(), setSignalDescriptions(), and clearSignalDescriptions().

QList<QCanSignalDescription> QCanMessageDescription::signalDescriptions() const

Returns the list of signal descriptions that belong to this message description.

See also signalDescriptionForName(), addSignalDescription(), setSignalDescriptions(), and clearSignalDescriptions().

quint8 QCanMessageDescription::size() const

Returns the size in bytes of the CAN message.

See also setSize().

QString QCanMessageDescription::transmitter() const

Returns the transmitter node of the message.

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

See also setTransmitter().

QtCanBus::UniqueId QCanMessageDescription::uniqueId() const

Returns the unique identifier of the CAN message.

See the Message ID section for more information about the unique identifier.

See also setUniqueId().

QCanMessageDescription &QCanMessageDescription::operator=(const QCanMessageDescription &other)

Assigns the values from other to this message description.

QCanMessageDescription &QCanMessageDescription::operator=(QCanMessageDescription &&other)

Move-assigns the values from other to this message description.

Note: The moved-from QCanMessageDescription object can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.

© 2024 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.