Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. USB Communication Using Qt

USB Communication Using Qt

Scheduled Pinned Locked Moved 3rd Party Software
57 Posts 13 Posters 110.6k 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.
  • F Offline
    F Offline
    florent.revelut
    wrote on 28 Apr 2011, 05:20 last edited by
    #5

    Dear Candiman,

    you might want to have a look at "Waiting for Friday":http://www.waitingforfriday.com/index.php/Building_a_PIC18F_USB_device

    You'll find an example, containing hardware based on a Pic 18f4550 (cheap and free if you ask microchip for samples), firmware code (using a free as "free-beer" compiler), a base class to help you deal with the USB communication and a full visual application sample.

    From my point of view, should be fairly easy to hide your internal communication in usb in a few classes, then provide a nice shell object with signals and slots to deal with your hardware.
    This way, you split nicely the code and you can easily test your UI without bothering with hardware (and test your hardware without bothering with UI ;) ) Of course, the HW communication layer will most-probably be platform specific whereas your UI will be generic. You could even think of using plugins to extend the functionality of your UI with HW... I have had a similar project in mind for quite a while, just can't find time to start it....

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on 28 Apr 2011, 05:21 last edited by
      #6

      USB and other hardware peripheral communication means (excepting networking) are not part of the Qt modules, as far as I know. Best course of action would be to go for some cross platform library (e.g. libusb, which you already found) and use that in your Qt program.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Candiman
        wrote on 28 Apr 2011, 05:54 last edited by
        #7

        Thank you for the reply Florent.Revelut and Franzk.

        Would be great if you could finally do that project you had in mind and document it. Then you can sell it to the unintelectuals like me ;)

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on 28 Apr 2011, 07:46 last edited by
          #8

          Hi Candyman,
          there can be found some source code based on Qt for serial connections. You will across a couple of derivatives obviously orginating from the same starting point.
          "See for instance":http://qextserialport.sourceforge.net/
          It can be used with USB-serial (PC-device). What the differences for USB-USB are, I am blank. Would be great to know, how to do it.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on 28 Apr 2011, 08:14 last edited by
            #9

            Yes we use the usb-serial approach by way of an FT-245 convertor chip on the comms side of our devices. This just marshalls between usb and standard RS-232 comms which allows us to use qextserialport on /dev/ttyUSB0 or COM1 for e.g. Without such a chip, libusb is the way to go but Qt can still be used for other aspects of the application though.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on 28 Apr 2011, 08:52 last edited by
              #10

              @ZapB How would you address usb on windows systems? Your example is for linux.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on 28 Apr 2011, 09:06 last edited by
                #11

                On windows you refer to serial devices as \.\COM1, \.\COM2 etc. Which in C++ translates to

                @
                "\\.\COM1"
                @

                when you escape all those backslashes.

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on 28 Apr 2011, 09:35 last edited by
                  #12

                  Thanks ZapB
                  However, the serial com part is easy.
                  How does
                  @
                  "/dev/ttyUSB0"
                  @
                  translate on a windows system?
                  Is it
                  @"\\.\USB0"@ ?

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on 28 Apr 2011, 09:36 last edited by
                    #13

                    Could you not use QExtSerialPort to simply list the available ports, instead of guessing their names?

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      ZapB
                      wrote on 28 Apr 2011, 09:43 last edited by
                      #14

                      /dev/ttyUSB0 is simply the name that the kernel (or udev or whatever else you are using) assigns to serial over USB devices ie when using a usb-serial convertor. So when using this type of device under windows the corresponding device is COM1.

                      If you are not using a usb-serial convertor then you have to use the libusb functionality for communicating - that is you cannot simply use COM1 etc.

                      Nokia Certified Qt Specialist
                      Interested in hearing about Qt related work

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        koahnig
                        wrote on 28 Apr 2011, 09:53 last edited by
                        #15

                        [quote author="Andre" date="1303983404"]Could you not use QExtSerialPort to simply list the available ports, instead of guessing their names?[/quote]

                        Not that I am aware off. Probably, you have to do it brute force by checking all com ports.

                        [quote author="ZapB" date="1303983794"]If you are not using a usb-serial convertor then you have to use the libusb functionality for communicating - that is you cannot simply use COM1 etc.[/quote]

                        That gives me something to chew on...

                        Thanks for your valuable responses

                        Vote the answer(s) that helped you to solve your issue(s)

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on 28 Apr 2011, 10:06 last edited by
                          #16

                          [quote author="koahnig" date="1303984402"]
                          [quote author="Andre" date="1303983404"]Could you not use QExtSerialPort to simply list the available ports, instead of guessing their names?[/quote]

                          Not that I am aware off. Probably, you have to do it brute force by checking all com ports.

                          [/quote]

                          There is an enumerator in the source code: http://qextserialport.cvs.sourceforge.net/viewvc/qextserialport/qextserialport/

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            koahnig
                            wrote on 28 Apr 2011, 12:37 last edited by
                            #17

                            [quote author="Andre" date="1303985184"]
                            There is an enumerator in the source code: http://qextserialport.cvs.sourceforge.net/viewvc/qextserialport/qextserialport/
                            [/quote]

                            you mean the enum on NamingConvention ?
                            I did not come across this yet. But it is nowherelse referenced. So it could be dead source.

                            Vote the answer(s) that helped you to solve your issue(s)

                            1 Reply Last reply
                            0
                            • Z Offline
                              Z Offline
                              ZapB
                              wrote on 28 Apr 2011, 12:50 last edited by
                              #18

                              No, there is a device enumeration function in qextserialport that probes what serial devices you have available.

                              Nokia Certified Qt Specialist
                              Interested in hearing about Qt related work

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                andre
                                wrote on 28 Apr 2011, 13:04 last edited by
                                #19

                                I mean this class: http://qextserialport.cvs.sourceforge.net/viewvc/qextserialport/qextserialport/qextserialenumerator.h?revision=1.3&view=markup

                                Sure, old code, and not in the docs, but the code is there...

                                1 Reply Last reply
                                0
                                • Z Offline
                                  Z Offline
                                  ZapB
                                  wrote on 28 Apr 2011, 13:09 last edited by
                                  #20

                                  BTW the sourceforge project is no longer active. The new home is "here":http://code.google.com/p/qextserialport/

                                  Nokia Certified Qt Specialist
                                  Interested in hearing about Qt related work

                                  1 Reply Last reply
                                  0
                                  • K Offline
                                    K Offline
                                    koahnig
                                    wrote on 28 Apr 2011, 13:16 last edited by
                                    #21

                                    Got it!
                                    Thanks again. Will try to use it. Apperently, it was not part of the example I have come across.

                                    Vote the answer(s) that helped you to solve your issue(s)

                                    1 Reply Last reply
                                    0
                                    • C Offline
                                      C Offline
                                      Candiman
                                      wrote on 30 Apr 2011, 03:47 last edited by
                                      #22

                                      @Koahnig, if I don't come right with libusb I can fall back on serial to USB as you suggested. Tnx for the link to qextserport.
                                      @ZapB, tnx for the info serial to USB converter chip. If required I will modify my hardware and go the serial route.
                                      I will post here again on completion of the project with info on how to do it for others that might find it useful.

                                      1 Reply Last reply
                                      0
                                      • Z Offline
                                        Z Offline
                                        ZapB
                                        wrote on 30 Apr 2011, 06:53 last edited by
                                        #23

                                        OK. For info, the QStateMachine framework can be very handy for controlling hardware devices so it may be worth a look in you case. Good luck with your project.

                                        Nokia Certified Qt Specialist
                                        Interested in hearing about Qt related work

                                        1 Reply Last reply
                                        0
                                        • K Offline
                                          K Offline
                                          koahnig
                                          wrote on 30 Apr 2011, 16:04 last edited by
                                          #24

                                          @Candiman Thx for feedback. Good to know that it helped. Good luck with your project. Please make sure to post a link in this thread. I am interested to see the outcome.
                                          @ZapB Thx for updated link. Wasn't aware of this. There seem to be a couple of derivatives of the source floating around. Actually I started out with one, but some things required reversal. So it is good to know where the original source code is. Have fun.

                                          Vote the answer(s) that helped you to solve your issue(s)

                                          1 Reply Last reply
                                          0

                                          14/57

                                          28 Apr 2011, 09:43

                                          topic:navigator.unread, 43
                                          • Login

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