qt在linux開啟串列埠寫資料
阿新 • • 發佈:2019-02-08
#include"mainwindow.h"
#include"ui_mainwindow.h"
#include"qdebug.h"
MainWindow::MainWindow(QWidget*parent)
:QMainWindow(parent),ui(newUi::MainWindow)
{
ui->setupUi(this);
PortSettingsmyComSetting={BAUD115200,DATA_8,PAR_NONE,STOP_1,FLOW_OFF,500};
myCom=newQextSerialPort("/dev/ttyS0",myComSetting);
boolre=myCom->open(QIODevice::ReadWrite);
qDebug()<<re;
writeMyCom();
}
voidMainWindow::writeMyCom()
{
QByteArraytemp=myCom->readAll();
qDebug()<<myCom->write("helloword\n");
ui->textBrowser->insertPlainText(temp);
}
MainWindow::~MainWindow()
{
deleteui;
}