Results 1 to 2 of 2

Thread: QSerialPort not working in startup stage with Atmel D20 on board USB to serial port

  1. #1
    Join Date
    May 2015
    Posts
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default 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:penSerialPort()
    {
    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.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,543
    Thanks
    13
    Thanked 1,577 Times in 1,506 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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.

Similar Threads

  1. How can i get data from com port use qserialport?
    By netvan42 in forum Qt Programming
    Replies: 0
    Last Post: 1st June 2014, 13:35
  2. QSerialPort :: read - Serial Comms noob.
    By llaregyb in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2014, 12:18
  3. Replies: 3
    Last Post: 2nd December 2012, 14:10
  4. Replies: 3
    Last Post: 22nd December 2011, 05:39
  5. Replies: 1
    Last Post: 16th June 2009, 09:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.