#ifndef QSERIALPORTUTIL_H
#define QSERIALPORTUTIL_H

#include <QObject>
#include <QSerialPort>

class QSerialPortUtil : public QObject
{
    Q_OBJECT
public:
    explicit QSerialPortUtil(QObject *parent = nullptr);

    void openSerialPort(QString portName, int baudRate);
    void sendData(QByteArray data);
    void readData();

    bool isOpen();

private:
    QSerialPort serial;

    bool open = false;

signals:
    void dataRecieved(QByteArray data); // 收到数据的信号
};

#endif // QSERIALPORTUTIL_H
