QSerialPort not working in startup stage with Atmel D20 on board USB to serial port
I work base on windows8.1 with QT5.4 environment and using QSerialPort example (terminal) to connect to my Atmel SAMD21 board USB-Serial port. When 1st time connect this board to my USB port, it doesn't have any response on this terminal workspace. But if I use other terminal tool (like teraterm), it will work properly everytime. Then after connect successful by that way, I switch back to execute my Qt terminal sample, it works as normal.
It is strange for me. Then I add serial=->clear() after serial->open() successfully, it will cause this application hang. My modification as below:
-------------------
void MainWindow::openSerialPort()
{
SettingsDialog::Settings p = settings->settings();
serial->setPortName(p.name);
serial->setBaudRate(p.baudRate);
serial->setDataBits(p.dataBits);
serial->setParity(p.parity);
serial->setStopBits(p.stopBits);
serial->setFlowControl(p.flowControl);
if (serial->open(QIODevice::ReadWrite)) {
console->setEnabled(true);
console->setLocalEchoEnabled(p.localEchoEnabled);
ui->actionConnect->setEnabled(false);
ui->actionDisconnect->setEnabled(true);
ui->actionConfigure->setEnabled(false);
ui->statusBar->showMessage(tr("Connected to %1 : %2, %3, %4, %5, %6")
.arg(p.name).arg(p.stringBaudRate).arg(p.stringDat aBits)
.arg(p.stringParity).arg(p.stringStopBits).arg(p.s tringFlowControl));
serial->clear(); // << The only line I add
} else {
QMessageBox::critical(this, tr("Error"), serial->errorString());
ui->statusBar->showMessage(tr("Open error"));
}
}
----------------------
Does anybody have same issue before as mine? Please help.
Re: QSerialPort not working in startup stage with Atmel D20 on board USB to serial po
You need to get the right baud rate, data bits, parity etc. to be able to talk. The serial port will open if the parameters are acceptable to your PC's serial hardware and no other software has a hold over the port. Opening the port does not guarantee anything about the other end of the comms link. Depending on the wiring of your serial link and the expectations of the remote device you may need to set the Data Terminal Ready (DTR) signal and/or hardware handshaking.