I use qextserial for serial programing,but when I run it and put into the port name,there are endless of "errror" on the screen.
Please take you a little time,help me!
the codes as the following:
sp = new QextSerialPort;
sp->setBaudRate( QextSerialPort::BAUD9600);
sp->setParity( QextSerialPort::PAR_NONE);
sp->setDataBits( QextSerialPort:: DATA_8);
sp->setStopBits( QextSerialPort::STOP_1);
qDebug("ConstructorDestructorTest");
qDebug("-------------------------");
qDebug("+++ Created");
{
qDebug("+++ Could not open");
cout<<"input port"<<endl;
char *POR;
cin>>POR;
sp->setName(PORTNAME1);
if( PORTNAME1 == sp->name() )
{
qDebug("+++ set port name");
if( sp->open() )
{
qDebug("+++ Opened");
sp->close();
qDebug("+++ Closed");
}
else {
qDebug("--- Could not open");
}
}
else {
qDebug("--- failed to set port name");
}
}
else {
qDebug("--- Opened");
sp->close();
qDebug("+++ Closed");
}
sp = new QextSerialPort;
sp->setBaudRate( QextSerialPort::BAUD9600);
sp->setParity( QextSerialPort::PAR_NONE);
sp->setDataBits( QextSerialPort:: DATA_8);
sp->setStopBits( QextSerialPort::STOP_1);
qDebug("ConstructorDestructorTest");
qDebug("-------------------------");
qDebug("+++ Created");
if( !(sp->open(QIODevice::ReadWrite)))
{
qDebug("+++ Could not open");
cout<<"input port"<<endl;
char *POR;
cin>>POR;
QString PORTNAME1 = QString(POR);
sp->setName(PORTNAME1);
if( PORTNAME1 == sp->name() )
{
qDebug("+++ set port name");
if( sp->open() )
{
qDebug("+++ Opened");
sp->close();
qDebug("+++ Closed");
}
else {
qDebug("--- Could not open");
}
}
else {
qDebug("--- failed to set port name");
}
}
else {
qDebug("--- Opened");
sp->close();
qDebug("+++ Closed");
}
To copy to clipboard, switch view to plain text mode
Bookmarks