Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. read and write in serial port
Forum Updated to NodeBB v4.3 + New Features

read and write in serial port

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmlserial port
13 Posts 4 Posters 25.3k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Do you have any other application also accessing that serial port ?

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

    N 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      Do you have any other application also accessing that serial port ?

      N Offline
      N Offline
      neda
      wrote on last edited by
      #3

      @SGaist

      Hi,
      I read data with Hercules_3-2-6 Application (rs232 terminal software), but before opening my program, I closed Hercules_3-2-6 Application

      1 Reply Last reply
      0
      • N Offline
        N Offline
        neda
        wrote on last edited by neda
        #4

        My program worked today, and I have not any error.
        But I do not any change to program.

        When I run program,
        program connects to port successfully, but I receive just one data (space).

        But when I close this program and open Hercules_3-2-6 Application (rs232 terminal software), that application read data,
        and after close Hercules_3-2-6 application and open my application again, this program works and reads data until restarting computer.

        I repeat this process many times.

        But my project does not receive data after restarting system until port opens one time by Hercules_3-2-6 Application.

        Meanwhile I have virtual USB COM port and my hardware connected to computer with USB.

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

          Are you using the same serial port setup in both your application and Hercules_3-2-6 ?

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

          N 1 Reply Last reply
          0
          • SGaistS SGaist

            Are you using the same serial port setup in both your application and Hercules_3-2-6 ?

            N Offline
            N Offline
            neda
            wrote on last edited by neda
            #6

            @SGaist

            yes, I using the same serial port setup in both my application and Hercules_3-2-6 .

            Specification of port: Name: COM3, Baud Rate: 9600, Data bits: 8, Parity: None, Stop bits: 1, Flow control: None

            Hercules_3-2-6

            My program:

            void MySerialPort::openSerialPort()
            {
                serial->setPortName("COM3");
            
            
                if (serial->open(QIODevice::ReadWrite)) {
                    serial->setParity(QSerialPort::NoParity);
                    serial->setBaudRate(QSerialPort::Baud9600);
                    serial->setDataBits(QSerialPort::Data8);
                    serial->setStopBits(QSerialPort::OneStop);
                    serial->setFlowControl(QSerialPort::NoFlowControl);
                    showStatusMessage("Connectedd");
            
                } else {
            
                    showStatusMessage(tr("Open error"));
                }
            }
            

            Meanwhile I have the same problem in qtserialport terminal example.
            When I run qtserialport terminal example, program connects to port successfully, but does not receive any data.
            But when I close this program and open Hercules_3-2-6 Application (rs232 terminal software), that application read data, and after close Hercules_3-2-6 application and open terminal example again, this program works and reads data until restarting computer.

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

              Does the device need DTR ?

              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
              1
              • N Offline
                N Offline
                neda
                wrote on last edited by neda
                #8

                No,
                I wrote a C# .net program. It worked very well likes to Hercules_3-2-6 Application and qt program worked after opening the program.
                I added this line for handle error port.

                void MySerialPort::handleError(QSerialPort::SerialPortError error)
                {
                    qDebug() << "Error: " << error;//I added this line
                
                    if (error == QSerialPort::ResourceError) {
                        showStatusMessage(serial->errorString());
                        closeSerialPort();
                    }
                }
                

                Result of run program:

                Error: 0
                "Connectedd"
                Error: 6
                "\x00"

                Just sometimes I have error 6.
                How do I fix break condition error?

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

                  @kuzulis might have an idea about that one

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

                  N 2 Replies Last reply
                  0
                  • SGaistS SGaist

                    @kuzulis might have an idea about that one

                    N Offline
                    N Offline
                    neda
                    wrote on last edited by
                    #10
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • SGaistS SGaist

                      @kuzulis might have an idea about that one

                      N Offline
                      N Offline
                      neda
                      wrote on last edited by neda
                      #11

                      @SGaist
                      Thank you very much my dear.
                      Your answer was a big help for me.

                      My problem was solved by set "setDataTerminalReady" function to false.
                      I did not have information about the signal DTR, by pointing you I read about that and find my problem.

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        TobyBar
                        wrote on last edited by
                        #12
                        This post is deleted!
                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          asterixxx
                          wrote on last edited by
                          #13

                          https://www.youtube.com/watch?v=7ny6Hrdc_2M&t=47s

                          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