1 #ifndef SERIALPORT_H 2 #define SERIALPORT_H 3 4 #include <QObject> 5 #include <QSerialPort> 6 #include "core_global.h" 7 8 class CORE_LIBRARY SerialPort : public QSerialPort 9 { 10 Q_OBJECT 11 public: 12 explicit SerialPort(QObject *parent = NULL); 13 14 bool config(const QString &name, 15 QSerialPort::BaudRate baudrate= QSerialPort::Baud115200, 16 QSerialPort::DataBits databits = QSerialPort::Data8, 17 QSerialPort::StopBits stopbit= QSerialPort::OneStop, 18 QSerialPort::Parity parity= NoParity, 19 QSerialPort::FlowControl control = QSerialPort::NoFlowControl); 20 21 bool config(const QString &name, 22 int baudrate, 23 int databits, 24 int stopbit, 25 int parity, 26 int control=-1); 27 28 bool config(const QVariant & settingValue); 29 30 void writeData(const QByteArray &arry); 31 32 QByteArray execCMD(const QByteArray &arry); 33 34 QByteArray readData(); 35 36 }; 37 38 #endif // SERIALPORT_H 39