QCanBusDevice Class
The QCanBusDevice class is the interface class for CAN bus. More...
| Header: | #include <QCanBusDevice> |
| qmake: | QT += serialbus |
| Since: | Qt 5.8 |
| Inherits: | QObject |
This class was introduced in Qt 5.8.
Public Types
| struct | Filter |
| enum | CanBusDeviceState { UnconnectedState, ConnectingState, ConnectedState, ClosingState } |
| enum | CanBusError { NoError, ReadError, WriteError, ConnectionError, ConfigurationError, …, TimeoutError } |
| enum class | CanBusStatus { Unknown, Good, Warning, Error, BusOff } |
| enum | ConfigurationKey { RawFilterKey, ErrorFilterKey, LoopbackKey, ReceiveOwnKey, BitRateKey, …, UserKey } |
| enum | Direction { Input, Output, AllDirections } |
Detailed Description
QCanBusDevice communicates with a CAN plugin providing users with a convenient API. The CAN plugin must be specified during the object creation.
Member Type Documentation
enum QCanBusDevice::CanBusDeviceState
This enum describes all possible device states.
| Constant | Value | Description |
|---|---|---|
QCanBusDevice::UnconnectedState | 0 | The device is disconnected. |
QCanBusDevice::ConnectingState | 1 | The device is being connected. |
QCanBusDevice::ConnectedState | 2 | The device is connected to the CAN bus. |
QCanBusDevice::ClosingState | 3 | The device is being closed. |
enum QCanBusDevice::CanBusError
This enum describes all the possible error conditions.
| Constant | Value | Description |
|---|---|---|
QCanBusDevice::NoError | 0 | No errors have occurred. |
QCanBusDevice::ReadError | 1 | An error occurred during a read operation. |
QCanBusDevice::WriteError | 2 | An error occurred during a write operation. |
QCanBusDevice::ConnectionError | 3 | An error occurred when attempting to open the plugin. |
QCanBusDevice::ConfigurationError | 4 | An error occurred when attempting to set a configuration parameter. |
QCanBusDevice::UnknownError | 5 | An unknown error occurred. |
QCanBusDevice::OperationError | 6 | An operation was attempted while the device was in a state that did not permit it. This enum was introduced in Qt 5.14. |
QCanBusDevice::TimeoutError | 7 | An timeout occurred while waiting for frames written or received. This enum was introduced in Qt 5.14. |
enum class QCanBusDevice::CanBusStatus
This enum describes possible CAN bus status values.
| Constant | Value | Description |
|---|---|---|
QCanBusDevice::CanBusStatus::Unknown | 0 | The CAN bus status is unknown (e.g. not supported by the CAN plugin). |
QCanBusDevice::CanBusStatus::Good | 1 | The CAN controller is fully operational |
QCanBusDevice::CanBusStatus::Warning | 2 | The CAN controller is in warning status |
QCanBusDevice::CanBusStatus::Error | 3 | The CAN controller is in error status (no longer sending CAN frames) |
QCanBusDevice::CanBusStatus::BusOff | 4 | The CAN controller is in bus off status (disconnected from the CAN bus) |
This enum was introduced or modified in Qt 5.14.
enum QCanBusDevice::ConfigurationKey
This enum describes the possible configuration options for the CAN bus connection.
| Constant | Value | Description |
|---|---|---|
QCanBusDevice::RawFilterKey | 0 | This configuration determines the type of CAN bus frames that the current device accepts. The expected value is QList<QCanBusDevice::Filter>. Passing an empty list clears all previously set filters including default filters. For more details see QCanBusDevice::Filter. |
QCanBusDevice::ErrorFilterKey | 1 | This key defines the type of error that should be forwarded via the current connection. The associated value should be of type QCanBusFrame::FrameErrors. |
QCanBusDevice::LoopbackKey | 2 | This key defines whether the CAN bus device should operate in loopback mode. Loopback means, whenever a CAN frame is transmitted on the CAN bus, a local echo of this frame is sent to all applications connected to this CAN device. The expected value for this key is bool. |
QCanBusDevice::ReceiveOwnKey | 3 | This key defines whether this CAN device receives its own send frames. This can be used to check if the transmission was successful. The expected value for this key is bool. |
QCanBusDevice::BitRateKey | 4 | This key defines the CAN bitrate in bits per second. With CAN FD, the payload can be transmitted at a higher data bitrate, if QCanBusFrame::hasBitrateSwitch() is set. In this case, QCanBusDevice::BitRateKey is only used for the CAN ID arbitration phase. See also QCanBusDevice::DataBitRateKey |
QCanBusDevice::CanFdKey | 5 | This key defines whether sending and receiving of CAN FD frames should be enabled. The expected value for this key is bool. |
QCanBusDevice::DataBitRateKey | 6 | This key defines the CAN FD payload bitrate in bits per second. CAN FD allows to transmit the payload of frames with QCanBusFrame::hasBitrateSwitch() flag at a higher data bitrate, after the arbitration phase at the nominal bitrate is finished. This enum value was introduced in Qt 5.9. See also QCanBusDevice::BitRateKey |
QCanBusDevice::ProtocolKey | 7 | This key allows to specify another protocol. For now, this parameter can only be set and used in the SocketCAN plugin. This enum value was introduced in Qt 5.14. |
QCanBusDevice::UserKey | 30 | This key defines the range where custom keys start. Its most common purpose is to permit platform-specific configuration options. |
See also configurationParameter().
enum QCanBusDevice::Direction
This enum describes possible data transmission directions.
| Constant | Value | Description |
|---|---|---|
QCanBusDevice::Input | 1 | Input direction. |
QCanBusDevice::Output | 2 | Output direction. |
QCanBusDevice::AllDirections | Input | Output | Both directions, input and output. |
This enum was introduced or modified in Qt 5.12.