Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT SerialPort Connect Problem
Qt 6.11 is out! See what's new in the release blog

QT SerialPort Connect Problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 430 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hyur
    wrote on last edited by hyur
    #1

    I am currently making middleware utilizing QtSerialPort.

    I want to connect this middleware with the Stm32 board to send and receive messages.

    The following is the serial port setup and open and readyread implementation.

        m_serialport.setPortName    (portName);
        m_serialport.setBaudRate    (QSerialPort::Baud115200); 
        m_serialport.setDataBits    (QSerialPort::Data8);
        m_serialport.setParity      (QSerialPort::NoParity);
        m_serialport.setStopBits    (QSerialPort::OneStop);
        m_serialport.setFlowControl (QSerialPort::NoFlowControl);
        m_serialport.open           (QIODevice::ReadWrite);
        if(!m_serialport.isOpen()){
            qDebug() << "Serial port open error";
            return false;
        }
        else {
            QObject::connect(&m_serialport, &QSerialPort::readyRead, [&]() {
                on_serialRX();
            });
        }
    

    My problem is that if I connect the middleware and STM immediately after uploading the source, the setup message does not come out.

    After uploading the source, open the Arduino IDE monitor and receive the setup message, then close the monitor and connect to the middleware, message transmission and reception are normal.

    Please tell me what i am doing wrong
    thank you

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What is that setup message ?
      Uploading which source to the Arduino ?
      How is the procedure different from the Arduino IDE and without it ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hyur
        wrote on last edited by hyur
        #3

        @SGaist
        Thanks for taking an interest in my problem.

        I solved this problem.
        QSerialPort::setDataTerminalReady() was set to false.
        After setting it to true, the setup message comes in.

        But, even if the setting value is changed to false after setting it to true once, the message is still received.

        If the message reception starts by raising the DTR to High, I think it is logically correct to lower the DTR to Low to stop the message reception, but the result was not.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved