| 1 | // Copyright (C) 2017 Ford Motor Company. | 
|---|---|
| 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 PASSTHRUCAN_PASSTHRUCANBACKEND_H | 
| 5 | #define PASSTHRUCAN_PASSTHRUCANBACKEND_H | 
| 6 | |
| 7 | #include <QtSerialBus/qcanbusdevice.h> | 
| 8 | #include <QtSerialBus/qcanbusframe.h> | 
| 9 | |
| 10 | #include <QList> | 
| 11 | #include <QString> | 
| 12 | #include <QThread> | 
| 13 | |
| 14 | QT_BEGIN_NAMESPACE | 
| 15 | |
| 16 | class PassThruCanIO; | 
| 17 | |
| 18 | class PassThruCanBackend : public QCanBusDevice | 
| 19 | { | 
| 20 | Q_OBJECT | 
| 21 | Q_DISABLE_COPY(PassThruCanBackend) | 
| 22 | public: | 
| 23 | explicit PassThruCanBackend(const QString &name, QObject *parent = nullptr); | 
| 24 | virtual ~PassThruCanBackend(); | 
| 25 | |
| 26 | void setConfigurationParameter(ConfigurationKey key, const QVariant &value) override; | 
| 27 | bool writeFrame(const QCanBusFrame &frame) override; | 
| 28 | QString interpretErrorFrame(const QCanBusFrame &errorFrame) override; | 
| 29 | |
| 30 | static QList<QCanBusDeviceInfo> interfaces(); | 
| 31 | QCanBusDeviceInfo deviceInfo() const override; | 
| 32 | |
| 33 | protected: | 
| 34 | bool open() override; | 
| 35 | void close() override; | 
| 36 | |
| 37 | private: | 
| 38 | void ackOpenFinished(bool success); | 
| 39 | void ackCloseFinished(); | 
| 40 | void applyConfig(QCanBusDevice::ConfigurationKey key, const QVariant &value); | 
| 41 | |
| 42 | QString m_deviceName; | 
| 43 | QThread m_ioThread; | 
| 44 | PassThruCanIO * m_canIO; | 
| 45 | }; | 
| 46 | |
| 47 | QT_END_NAMESPACE | 
| 48 | |
| 49 | Q_DECLARE_METATYPE(QCanBusDevice::CanBusError) | 
| 50 | Q_DECLARE_METATYPE(QList<QCanBusFrame>) | 
| 51 | |
| 52 | #endif // PASSTHRUCAN_PASSTHRUCANBACKEND_H | 
| 53 | 
