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. [QtSerialPort] Simple example crashes
Qt 6.11 is out! See what's new in the release blog

[QtSerialPort] Simple example crashes

Scheduled Pinned Locked Moved General and Desktop
25 Posts 6 Posters 22.4k 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.
  • K Offline
    K Offline
    kuzulis
    Qt Champions 2020
    wrote on last edited by
    #4

    For me, this problem doesn't repeat, I can't reproduce it. Probably, you incorrectly compiled library.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      quickybr
      wrote on last edited by
      #5

      I got the same error. I followed this tutorial:
      http://gracianotorrao.com/2013/05/07/how-to-build-the-qserialport-module-using-qt5-windows-7/

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kuzulis
        Qt Champions 2020
        wrote on last edited by
        #6

        Please try build and install through QtCreator.

        1 Reply Last reply
        0
        • mranger90M Offline
          mranger90M Offline
          mranger90
          wrote on last edited by
          #7

          I just built this with the latest-greatest 5.1 RC1 candidate on Ubuntu 12.04 64 bit. It ran with no problems.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kuzulis
            Qt Champions 2020
            wrote on last edited by
            #8

            @mranger90,

            because this "bug" only for Windows!

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              quickybr
              wrote on last edited by
              #9

              I got the problem!
              On my linux environment (arch Linux x86_64) it works perfectly (I compiled using qt creator).

              On my windows 7 I was having some troubles to make it works. I was getting the same dll issues that you're having and I solved, that's what I did:

              I reinstalled QT with all the addons (full-installation).
              Removed the Perl that I was using (strawberry Perl)
              Installed Active Perl (the last version)
              Compiled the qtserialport module following this tutorial:
              http://gracianotorrao.com/2013/05/07/how-to-build-the-qserialport-module-using-qt5-windows-7/

              The only exception was that I got the source by cloning the git repository.

              By now it compiles!
              Probably it will work to you too.
              Good luck ^^

              1 Reply Last reply
              0
              • M Offline
                M Offline
                M4chin3
                wrote on last edited by
                #10

                kuzulis:

                Hi,

                1. I'm trying to use USB-to-Comport devices with a FTDI IC (FT232R). Here's a picture of my device mger:

                "Device manager screen (imgshack)":http://imageshack.us/a/img29/4827/mzma.png

                1. I can reproduce the same error without the lines of code you mentioned. I forgot about this: The error occurs in the head of the foreach loop within the static method "availablePorts()" of class QSerialPortInfo.

                2. I can reproduce the same error with the release branch version of QtSerialPort.

                [quote author="kuzulis" date="1371481349"]Hi M4chin3.

                Here at a forum already there was the same problem, but I can't find a this thread. It is strange. Solutions of this problem, certainly still aren't present because the reason is unclear.

                1. Whether your OS has serial ports? Give please a screenshot from Device Manager (with numbers and names of ports).

                2. Can you reproduce a problem without this code?

                @// Example use QSerialPort
                QSerialPort serial;
                serial.setPort(info);
                if (serial.open(QIODevice::ReadWrite))
                serial.close();
                }@

                1. Can you reproduce a problem with Release branch?

                https://qt.gitorious.org/qt/qtserialport/commits/release[/quote]

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  M4chin3
                  wrote on last edited by
                  #11

                  quickybr:

                  I also got strawberry perl, so i tried your way with Active Perl on the WinXp machine.
                  -> The QtSerialPort lib was compiled fine (same like with strawberry perl). I also could use it in Qt Creator but it didn't find any of my serial ports. I will check about this in detail tomorrow.

                  Why WinXP machine and not the Win7 one iam actually working with?
                  -> i dont have admin on the win7 machine. I have to wait for the IT guys untill tomorrow.
                  :-/

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kuzulis
                    Qt Champions 2020
                    wrote on last edited by
                    #12

                    bq. Removed the Perl that I was using (strawberry Perl)
                    Installed Active Perl (the last version)

                    Hmm.. It is interesting, thx! May it is a cause of problem? Because I'm using Active perl and don't have a problem.

                    Can anyone try to check with this difference of Perl?

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      M4chin3
                      wrote on last edited by
                      #13

                      IT department has to check the licences before installtion, so it might take a while. But i'll try as soon as possible.

                      1 Reply Last reply
                      0
                      • Q Offline
                        Q Offline
                        quickybr
                        wrote on last edited by
                        #14

                        Yesterday I didn't have tried to communicate. But I tested now and I confirm, it's working properly

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          M4chin3
                          wrote on last edited by
                          #15

                          Hi everybody,

                          finally i got ActivePerl installed on the Win7 machine. Sadly it didn't change anything for me :-(. I compiled and installed QtSerialPort both ways: via console and via QtCreator and tested it.

                          The programm still crashes in the same behaviour as described before.

                          This is the crash track in detail:
                          main (QSerialPortInfo::availablePorts()) -> qserialportinfo_win.cpp;line 166 (QString s = devicePortName(deviceInfoSet, &deviceInfoData);) -> qserialportinfo_win.cpp;line 132 (QByteArray data(dataSize, 0);)

                          The construction of the QByteArray fails somehow and this creates the Qt5Core.dll error. The question is why?

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            M4chin3
                            wrote on last edited by
                            #16

                            Hi,

                            okay i' one step further:

                            WinXP 32bit:
                            Status:
                            Couldn't find any serial ports but did not crash like Win7 Pro 64bit. QtSerialPort compiled with Strawberry Perl or ActivePerl didn't matter.

                            Problem:
                            Administrator priviliges are needed otherwise "::SetupDiEnumDeviceInfo(deviceInfoSet, index++, &deviceInfoData)" returns true but the &deviceInfoData is emtpy respectivly the device name is empty (QString s = devicePortName(deviceInfoSet, &deviceInfoData))

                            I'll try to get administrator priviliges tomorrow to try this on Windows7. At least i know how the serial ports are searched on windows systems.

                            Will this be changed? Otherwise users of my programm will also need administrator priviliges right? Wouldn't be that good.

                            1 Reply Last reply
                            0
                            • K Offline
                              K Offline
                              kuzulis
                              Qt Champions 2020
                              wrote on last edited by
                              #17

                              @M4chin3,

                              bq. The question is why?

                              I don't know. For a solution I need to reproduce at itself crash - but I can't.

                              bq. Otherwise users of my programm will also need administrator priviliges right?

                              No. Privileges of the administrator aren't required. Most likely you have any other restrictions on your user account.

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                M4chin3
                                wrote on last edited by
                                #18

                                Hello everyone,

                                in the last weeks i had no time for further investigation about the error. Today i opened the example project again, ran it and it works! I Didn't change anything in the code and my priviliges on this machine are the same than i posted the last time.

                                I assume that in the time i didn't touch the project the IT department did a windows update via their updatemanagement that fixed my problem. I'll contact them for a list of updates they did in this time. I hope i get a list from them. Maybe i find a patch that could be related to my error.

                                I don't have any other explanation for this.

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  artem_pisarenko
                                  wrote on last edited by
                                  #19

                                  Similar issue.

                                  Using QtSerialPort built from current 'stable' branch (50ab4d) causes simple example (from wiki) to crash in first QSerialPort::open() with segmentation fault (application terminates with exit code 255). Using QtSerialPort built from current 'release' branch (84df6e) works ok.

                                  My setup is:
                                  Win7 Pro x64
                                  Qt 4.8.4

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    artem_pisarenko
                                    wrote on last edited by
                                    #20

                                    Bisecting between revisions I got following results:

                                    • da0c6b works ok
                                    • 43f7c6 seems works ok but adds messages to debug output: "virtual void QSerialPort::close(): device not open"
                                    • 50ab4d causes crash (as described in previous post)

                                    (Tests was performed by reusing full rebuild cycle: <module build dir> mingw32-make clean, <module build dir> mingw32-make uninstall, clean <module build dir>, clean <app project>, run qmake on <app project>, ...)

                                    1 Reply Last reply
                                    0
                                    • K Offline
                                      K Offline
                                      kuzulis
                                      Qt Champions 2020
                                      wrote on last edited by
                                      #21

                                      Hi.

                                      Yes, I confirm it. Thx.

                                      1 Reply Last reply
                                      0
                                      • K Offline
                                        K Offline
                                        kuzulis
                                        Qt Champions 2020
                                        wrote on last edited by
                                        #22

                                        Here a patch:

                                        https://codereview.qt-project.org/#change,67801

                                        please try it.

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          artem_pisarenko
                                          wrote on last edited by
                                          #23

                                          Yes, it fixed issue.
                                          (But there are still warnings since 43f7c6. Seems like QSerialPort destructor tries to do some finalizing work on already closed port.)

                                          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