Qt serial port

Qt serial communication:
#ifdef _TTY_POSIX
#include “posix_qextserialport.h”
#define QextBaseType Posix_QextSerialPort
#else
#include “win_qextserialport. h”
#define “QextBaseTypeport.h”
#define QextBaseType Win_QexSerialPort
#endif
How QueryMode in the QextSerialBase class reads the serial port:
Polling: Set up timer reading Get the serial port information
EventDrrivent: Once there is data to send the readyRead() signal
Set the serial port to event-driven mode
mycom = new Win_QextSerialPort(“COM1”,QextSerialBase::EventDriven);
mycom->open (QIODevice::ReadWrite);
mycom->setBaudRate(BAUD9600);
mycom->setDataBits(DATA_8);
mycom->serParity(PAR_NONE);
mycom->setStopBits(STOP_1) ;
mycom->setFlowControl(FLOW_OFF); Data Flow Control
mycom->setTimeout(500);
connect(mycom,SIGNAL(readyRead()),this,SLOT(readMycom()));
void Widget::readMycom()
{
if(mycom->buteAvailable()>= 8)
{
QByteArray temp = mycom->readAll ();
ui->textBrowser->insertPlainText(Temp);
}
}
Use Polling mode:
mycom = new Win_QextSerialPort(“Com1”,QextSerialBase::Polling);
readTimer = new QTimer(this);
readTimer-> start(100);
mycom->setTimeout(10); Put data into serial buffer
connect(readTimer,SIGNAL(timeout()),this,SLOT(readMyCom()));
Linux:
mycom = new Posix_QextSerialPort(“/dev/ttyS0”,QextSerialBase::Polling)
www.yafeilinux.com documentation

qt serial communication:
#ifdef _TTY_POSIX
#include “posix_qextserialport.h”
#define QextBaseType Posix_QextSerialPort

#else
#include “win_qextserialport .h”
#define “QextBaseTypeport.h”
#define QextBaseType Win_QexSerialPort
#endif

The way in which QueryMode in the QextSerialBase class reads the serial port:
Polling: Create a timer Read the serial port information
EventDrrivent: Once there is data to send the readyRead() signal
Set the serial port to event-driven mode
mycom = new Win_QextSerialPort(“COM1”,QextSerialBase::EventDriven);
mycom-> open(QIODevice::ReadWrite);
mycom->setBaudRate(BAUD9600);
mycom->setDataBits(DATA_8);
mycom->serPar ity(PAR_NONE);
mycom->setStopBits(STOP_1);
mycom->setFlowControl(FLOW_OFF); data flow control
mycom->setTimeout(500);
connect(mycom,SIGNAL( readyRead()),this,SLOT(readMycom()));

void Widget::readMycom()
{
if(mycom->buteAvailable()>= 8 )
{
QByteArray temp = mycom->readAll();
ui->textBrowser->insertPlainText(Temp);

}

}

Use Polling mode:
mycom = new Win_QextSerialPort(“Com1”,QextSerialBase::Polling);
readTimer = new QTimer(this);
readTimer->start(100); < br>mycom->setTimeout(10); Put data into serial buffer
connect(readTimer,SIGNAL(timeout()),this,SLOT(readMyCom()));


Linux:

mycom = new Posix_QextSerialPort(“/dev/ttyS0”,QextSerialBase::Polling)

www.yafeilinux.com documentation

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1238 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.