I have a problem while reading data from microcontroller...my microcontroller sends char 'a' continiously(just to test)..and I want to receive the character in my ui application..(lineedit)...
QextSerialPort * port = new QextSerialPort("COM4", QextSerialPort::EventDriven);
port->setBaudRate(BAUD9600);
port->setFlowControl(FLOW_OFF);
port->setParity(PAR_NONE);
port->setDataBits(DATA_8);
port->setStopBits(STOP_1);
port->setTimeout(500);
port->setRts(true);
port->setDtr(true);
if(port->isReadable())
{
char buff[1024];
qint64 i=port->readLine(buff,1024);
buff[i]='\0';
if(i!=-1)
{
ui->lineEdit->setText(str);;
port->close();
}
}
else
qDebug("port not open");
QextSerialPort * port = new QextSerialPort("COM4", QextSerialPort::EventDriven);
port->setBaudRate(BAUD9600);
port->setFlowControl(FLOW_OFF);
port->setParity(PAR_NONE);
port->setDataBits(DATA_8);
port->setStopBits(STOP_1);
port->open(QIODevice::ReadWrite);
port->setTimeout(500);
port->setRts(true);
port->setDtr(true);
if(port->isReadable())
{
char buff[1024];
qint64 i=port->readLine(buff,1024);
buff[i]='\0';
QString str(buff);
if(i!=-1)
{
ui->lineEdit->setText(str);;
port->close();
}
}
else
qDebug("port not open");
To copy to clipboard, switch view to plain text mode
this does not help me ............please help me/...
Bookmarks