- Qt 6.8
- Qt Serial Bus
- Qt 6.8.3 Reference Documentation

# Qt Serial Bus

The Qt Serial Bus API provides classes and functions to access the various industrial serial buses and protocols, such as CAN, ModBus, and others.

## Getting Started

To use the module with CMake, use the `find_package()` command to locate the needed module components in the `Qt6` package:

     find_package(Qt6 COMPONENTS SerialBus REQUIRED)
     target_link_libraries(mytarget PRIVATE Qt6::SerialBus)

To use the module for building with qmake, add the module as a value of the `QT` variable in the project's .pro file:

     QT += serialbus

## Supported Buses and Protocols

- Qt CAN Bus
- Qt Modbus

## API Reference

These are links to the API reference materials.

- C++ Classes

## Logging Categories

The QtSerialBus module exports the following logging categories:

Logging Category | Description
--- | ---
qt.canbus | Enables standard logging inside the Qt CAN Bus classes
qt.canbus.plugins | Enables low level logging inside the Qt CAN Bus plugin classes. To set logging for a specific plugin, use "qt.canbus.plugins.pluginname". e.g. "qt.canbus.plugins.socketcan". "qt.canbus.plugins*" affects all plugins.
qt.modbus | Enables standard logging inside the Qt Modbus classes
qt.modbus.lowlevel | Enables low level logging including individual packet content inside the Qt Modbus classes

Logging categories can be used to enable additional warning and debug output for QtSerialBus. More detailed information about logging can be found in QLoggingCategory.

A quick way to enable all Qt Modbus logging is to add the following line to the main() function:

     QLoggingCategory::setFilterRules(QStringLiteral("qt.modbus* = true"));

## Examples

- CAN Bus Manager example
- Modbus Client example
- Modbus Server example
- Modbus Custom Command example

## Module Evolution

Changes to Qt SerialBus lists important changes in the module API and functionality that were done for the Qt 6 series of Qt.