Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QSerial Port
Forum Updated to NodeBB v4.3 + New Features

QSerial Port

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
3 Posts 3 Posters 526 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.
  • M Offline
    M Offline
    Mar_60
    wrote on last edited by
    #1

    Hi everyone,

    I have issues in using QSerial port. Actually, I have reading/writting data in my QT project using arduino. I have initialized my serial port in this way:

    serialport = new QSerialPort(this);
    serialport->setPortName("COM3");
    serialport->setBaudRate(QSerialPort::Baud19200);
    serialport->setDataBits(QSerialPort::Data8);
    serialport->setFlowControl(QSerialPort::NoFlowControl);
    serialport->setParity(QSerialPort::NoParity);
    serialport->setStopBits(QSerialPort::OneStop);
    qDebug()<<"Serial Port Opened"<<serialport->open(QSerialPort::ReadWrite);
    

    After reading/writing data from arduino at desired time, I want to stop it.
    I am stopping the serial port by using the command:

    serial->close();
    

    When I run my code for the first time, serial port doesn't stop. So, I stop my serial port forcefully through arduino's Serial Monitor. And then when I run my app again, it works alright. It start working perfectly 2nd time and ownwards. What I need to do, in order to close serial port in the first attempt.

    Waiting for guidance

    TIA,

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

      Hi,

      What do you mean exactly by "stop 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
      • M Mar_60

        Hi everyone,

        I have issues in using QSerial port. Actually, I have reading/writting data in my QT project using arduino. I have initialized my serial port in this way:

        serialport = new QSerialPort(this);
        serialport->setPortName("COM3");
        serialport->setBaudRate(QSerialPort::Baud19200);
        serialport->setDataBits(QSerialPort::Data8);
        serialport->setFlowControl(QSerialPort::NoFlowControl);
        serialport->setParity(QSerialPort::NoParity);
        serialport->setStopBits(QSerialPort::OneStop);
        qDebug()<<"Serial Port Opened"<<serialport->open(QSerialPort::ReadWrite);
        

        After reading/writing data from arduino at desired time, I want to stop it.
        I am stopping the serial port by using the command:

        serial->close();
        

        When I run my code for the first time, serial port doesn't stop. So, I stop my serial port forcefully through arduino's Serial Monitor. And then when I run my app again, it works alright. It start working perfectly 2nd time and ownwards. What I need to do, in order to close serial port in the first attempt.

        Waiting for guidance

        TIA,

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Mar_60

        In your code, you open serialport, but you close serial.

        Might that be a problem?

        Otherwise provide more code. From the snippet, its not obvious.

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        3

        • Login

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