| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QCANCOMMONDEFINITIONS_H |
| 5 | #define QCANCOMMONDEFINITIONS_H |
| 6 | |
| 7 | #include <QtCore/qendian.h> |
| 8 | #include <QtCore/qsysinfo.h> |
| 9 | #include <QtCore/qtconfigmacros.h> |
| 10 | #include <QtCore/qtypes.h> |
| 11 | |
| 12 | #include <QtSerialBus/qtserialbusglobal.h> |
| 13 | |
| 14 | QT_BEGIN_NAMESPACE |
| 15 | |
| 16 | namespace QtCanBus { |
| 17 | |
| 18 | enum class DataSource : quint8 { |
| 19 | Payload = 0, |
| 20 | FrameId, |
| 21 | }; |
| 22 | |
| 23 | enum class DataFormat : quint8 { |
| 24 | SignedInteger = 0, |
| 25 | UnsignedInteger, |
| 26 | Float, |
| 27 | Double, |
| 28 | AsciiString, |
| 29 | }; |
| 30 | |
| 31 | enum class MultiplexState : quint8 { |
| 32 | None = 0x00, |
| 33 | MultiplexorSwitch = 0x01, |
| 34 | MultiplexedSignal = 0x02, |
| 35 | SwitchAndSignal = MultiplexorSwitch | MultiplexedSignal, |
| 36 | }; |
| 37 | |
| 38 | enum class UniqueId : quint32 {}; |
| 39 | |
| 40 | inline UniqueId qbswap(UniqueId src) noexcept |
| 41 | { |
| 42 | return UniqueId{qbswap_helper(source: qToUnderlying(e: src))}; |
| 43 | } |
| 44 | |
| 45 | } // namespace QtCanBus |
| 46 | |
| 47 | |
| 48 | #ifndef QT_NO_DEBUG_STREAM |
| 49 | |
| 50 | class QDebug; |
| 51 | |
| 52 | namespace QtCanBus { |
| 53 | Q_SERIALBUS_EXPORT QDebug operator<<(QDebug dbg, DataSource source); |
| 54 | Q_SERIALBUS_EXPORT QDebug operator<<(QDebug dbg, DataFormat format); |
| 55 | Q_SERIALBUS_EXPORT QDebug operator<<(QDebug dbg, MultiplexState state); |
| 56 | Q_SERIALBUS_EXPORT QDebug operator<<(QDebug dbg, UniqueId uid); |
| 57 | } // namespace QtCanBus |
| 58 | |
| 59 | #endif // QT_NO_DEBUG_STREAM |
| 60 | |
| 61 | QT_END_NAMESPACE |
| 62 | |
| 63 | #endif // QCANCOMMONDEFINITIONS_H |
| 64 | |