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. QSerialPort hangs on Windows works fine on ARM/LINUX
QtWS25 Last Chance

QSerialPort hangs on Windows works fine on ARM/LINUX

Scheduled Pinned Locked Moved Solved General and Desktop
qserialport crocross platform
9 Posts 3 Posters 3.7k Views
  • 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.
  • A Offline
    A Offline
    Auke-Dirk
    wrote on 2 Feb 2016, 09:56 last edited by
    #1

    Hi Qt Experts,

    I'm working on an opensource project writing a library for XIMU (IMU) devices. This library can be found on https://github.com/Auke-Dirk/x-IMU-CPP-API.

    I've been asked by some users to provide an IO inteface (SerialPort) making it more easy for programmers to interface with the XIMU. Since i wanted platform independence thought Qt would be a good option.

    On my ARM/Linux laptop all is fine and i recieve and parse the incomming data as expected. However on Window 7 i encounter problems with reading the SerialPort. I'm by far not an expert on Qt so hints/advice would be greatly appreciated.

    The problem: The SerialPort sometimes initially recieves data, after which it never enters the if (sp.waitForReadyRead(_timeout_msec)) guard. If i turn the device offand on i get one readyRead and that is it.

    Providing the code here would cause a mess and therefor i've added the necessary urls. The problems occurs in both gui and non-gui applications, i've added both a console and gui code.

    Qt 5.2 and 5.4 where used.

    The SerialPort: https://github.com/Auke-Dirk/x-IMU-CPP-API/blob/master/src/ximuapi/io/serial_port.cpp

    Widget: http://github.com/Auke-Dirk/x-IMU-CPP-API/blob/master/src/ximugui/widgets/serialview.cpp

    Commandline: http://github.com/Auke-Dirk/x-IMU-CPP-API/blob/master/apps/ximu_console.cpp

    regards Auke-Dirk

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 2 Feb 2016, 12:40 last edited by
      #2

      Hi and welcome to devnet,

      Not answer at first but why not make use of Qt's asynchronous capabilities for your serial port stuff ?

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

      A 1 Reply Last reply 2 Feb 2016, 14:02
      0
      • S SGaist
        2 Feb 2016, 12:40

        Hi and welcome to devnet,

        Not answer at first but why not make use of Qt's asynchronous capabilities for your serial port stuff ?

        A Offline
        A Offline
        Auke-Dirk
        wrote on 2 Feb 2016, 14:02 last edited by
        #3

        @SGaist said:

        Not answer at first but why not make use of Qt's asynchronous capabilities for your serial port stuff ?

        Hi SGaist,

        thanx for the reply!

        I've tried both approaches, yielding the same results.
        The reason i chose this approach is, i like the fact that QSerialPort has a small scope.

        void SerialPort::run(){
        _mutex.lock();
        QSerialPort sp;
        ..
        }

        for most of my hardware interfacing i follow that strategy, however since i'm Qt rookie i'm open for all ideas.

        regards Auke

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 2 Feb 2016, 21:30 last edited by
          #4

          Then what do you mean by hangs ? If you take your command line application, you didn't wrote any logic to quit the running QCoreApplication.

          On a side note, why go back and forth with std::string since you are using QString anyway ?

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

          A 1 Reply Last reply 3 Feb 2016, 09:42
          0
          • S SGaist
            2 Feb 2016, 21:30

            Then what do you mean by hangs ? If you take your command line application, you didn't wrote any logic to quit the running QCoreApplication.

            On a side note, why go back and forth with std::string since you are using QString anyway ?

            A Offline
            A Offline
            Auke-Dirk
            wrote on 3 Feb 2016, 09:42 last edited by
            #5

            Hi SGaist,

            thanx again for taking the time.

            Then what do you mean by hangs ?

            By hangs i mean that waitForReadyRead is never true, unless as i mentioned when i turn off/on the device after which i do recieve
            a few bytes.

            On a side note, why go back and forth with std::string since you are using QString anyway ?

            I don't want to expose Qt to much inside the SerialPort header (public functions) , someone might implement the serialort based boosts async_serial if Qt is not available.

            If you take your command line application, you didn't wrote any logic to quit the running QCoreApplication.

            Haven't gotten to that part yet, first like to get it running.

            I extended the research by sending a dump file through an emulated (com0com) comport, this way the data is correctly recieved. result and setup

            Are there any things/ideas i could test?

            kind regards Auke-Dirk

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Auke-Dirk
              wrote on 3 Feb 2016, 11:51 last edited by
              #6

              Little addition to the previous post.
              The programs seems to run fine under OS X Yosemite Qt 5.5.1
              sample

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 3 Feb 2016, 20:54 last edited by
                #7

                Are you using a special device for the serial port on Windows ?

                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
                • A Offline
                  A Offline
                  Auke-Dirk
                  wrote on 10 Feb 2016, 10:23 last edited by
                  #8

                  Hi Qt,

                  problem was quit easy and a bit annoying, different platform's require different Flow control. My first platform ARM all seemed fine, then on that Mac OS-X all was fine, windows however i needed to set setFlowControl(QSerialPort::HardwareControl);

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kuzulis
                    Qt Champions 2020
                    wrote on 10 Feb 2016, 12:09 last edited by
                    #9

                    different platform's require different Flow control.

                    it is not true

                    1 Reply Last reply
                    0

                    1/9

                    2 Feb 2016, 09:56

                    • Login

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