1// Copyright (C) 2017 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 QMODBUSCLIENT_H
5#define QMODBUSCLIENT_H
6
7#include <QtCore/qobject.h>
8#include <QtSerialBus/qmodbusdataunit.h>
9#include <QtSerialBus/qmodbusdevice.h>
10#include <QtSerialBus/qmodbuspdu.h>
11#include <QtSerialBus/qmodbusreply.h>
12
13QT_BEGIN_NAMESPACE
14
15class QModbusClientPrivate;
16
17class Q_SERIALBUS_EXPORT QModbusClient : public QModbusDevice
18{
19 Q_OBJECT
20 Q_DECLARE_PRIVATE(QModbusClient)
21
22public:
23 explicit QModbusClient(QObject *parent = nullptr);
24 ~QModbusClient();
25
26 QModbusReply *sendReadRequest(const QModbusDataUnit &read, int serverAddress);
27 QModbusReply *sendWriteRequest(const QModbusDataUnit &write, int serverAddress);
28 QModbusReply *sendReadWriteRequest(const QModbusDataUnit &read, const QModbusDataUnit &write,
29 int serverAddress);
30 QModbusReply *sendRawRequest(const QModbusRequest &request, int serverAddress);
31
32 int timeout() const;
33 void setTimeout(int newTimeout);
34
35 int numberOfRetries() const;
36 void setNumberOfRetries(int number);
37
38Q_SIGNALS:
39 void timeoutChanged(int newTimeout);
40
41protected:
42 QModbusClient(QModbusClientPrivate &dd, QObject *parent = nullptr);
43
44 virtual bool processResponse(const QModbusResponse &response, QModbusDataUnit *data);
45 virtual bool processPrivateResponse(const QModbusResponse &response, QModbusDataUnit *data);
46};
47
48QT_END_NAMESPACE
49
50#endif // QMODBUSCLIENT_H
51

source code of qtserialbus/src/serialbus/qmodbusclient.h