我也不知道这是啥东西

Contributor:筱、敏 Type:代码 Date time:2017-10-08 21:24:11 Favorite:16 Score:0
返回上页 Report
请选择举报理由:




Collection Modify the typo
serialThread.h:
#ifndef SERIALTHREAD_H
#define SERIALTHREAD_H
#include "posix_qextserialport.h"
#include <QThread>
class SerialThread:QThread
{
Q_OBJECT
public:
explicit SerialThread();
Posix_QextSerialPort *mycom;
private slots:
void run();
signals:
void serialFinished(QByteArray str);
};
#endif // SERIALTHREAD_H
serialthread.cpp:
#include "serialThread.h"
#include "form.h"
extern QString comname;
extern BaudRateType baud;
extern DataBitsType datatype;
extern ParityType par;
SerialThread::SerialThread()
{
PortSettings st;
mycom = new Posix_QextSerialPort("/dev/"+comname,st,QextSerialBase::Polling);
mycom->open(QIODevice::ReadWrite);
mycom->setDataBits(datatype);
mycom->setBaudRate(baud);
mycom->setParity(par);
mycom->setFlowControl(FLOW_OFF);
mycom->setStopBits(STOP_1);
mycom->setTimeout(70);
}
void SerialThread::run(){
while(1){
int len = mycom->bytesAvailable();
msleep(40);
if(len==mycom->bytesAvailable()){
QByteArray str = mycom->readAll();
emit serialFinished(str);
}
}
}
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
Hot degree:
Difficulty:
quality:
Description: the system according to the heat, the difficulty, the quality of automatic certification, the certification of the article will be involved in typing!

This paper typing ranking TOP20

登录后可见

用户更多文章推荐