#ifndef BTNSERIALTOOL_H
#define BTNSERIALTOOL_H
#include <QObject>
#include <QSerialPort>
#include <QPushButton>
#include <QLineEdit>
#include <QTextEdit>
#include <QByteArray>

class BtnSerialTool: public QObject
{
    Q_OBJECT
public:
    BtnSerialTool(QObject *parent = nullptr);
    void openSerialPort();
    void closeSerialPort();
    void readData();
    bool sendData(const QByteArray &data);
signals:
    void openCloseButtonTextChanged(const QString& text);
    void openError();
    void dataReceived(const QByteArray& data);
public slots:
    void handleSendDataReques(const QByteArray &data);
private:
    void setupSerialPort();
    QByteArray buffer; // 确保这里声明了 buffer 变量
    QSerialPort serialPort;
};

#endif // BTNSERIALTOOL_H
