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. how to create App for communicate with device through USB serial communication

how to create App for communicate with device through USB serial communication

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 5 Posters 4.2k 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.
  • V Offline
    V Offline
    vicksoccer
    wrote on 9 Oct 2019, 12:49 last edited by
    #3

    thanks for reply!!

    USB Communication Device Class (CDC) - Abstract Control Model (ACM) is possible with qserialport on linux machine?? If yes can anyone share example..

    J 1 Reply Last reply 9 Oct 2019, 12:53
    0
    • V vicksoccer
      9 Oct 2019, 12:49

      thanks for reply!!

      USB Communication Device Class (CDC) - Abstract Control Model (ACM) is possible with qserialport on linux machine?? If yes can anyone share example..

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 9 Oct 2019, 12:53 last edited by
      #4

      @vicksoccer The documentation page I linked above contains a link to serial port examples.
      Does this device behave like a serial port?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • K Offline
        K Offline
        kuzulis
        Qt Champions 2020
        wrote on 9 Oct 2019, 13:20 last edited by kuzulis 10 Sept 2019, 18:31
        #5

        USB Communication Device Class (CDC) - Abstract Control Model (ACM) is possible with qserialport on linux machine??

        Yes

        V 1 Reply Last reply 10 Oct 2019, 07:25
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 9 Oct 2019, 14:46 last edited by
          #6

          Hi
          Try the terminal example as it as dialog to setup comport and
          makes it easy to check out.
          Its available directly in Creator
          alt text

          1 Reply Last reply
          4
          • K kuzulis
            9 Oct 2019, 13:20

            USB Communication Device Class (CDC) - Abstract Control Model (ACM) is possible with qserialport on linux machine??

            Yes

            V Offline
            V Offline
            vicksoccer
            wrote on 10 Oct 2019, 07:25 last edited by vicksoccer 10 Oct 2019, 07:35
            #7

            @kuzulis Thanks for your support!!
            My device can be connected with USB B connector and RS232 both.
            In device datasheet mention information of baudrate,partiy,databits etc only under RS232 section and under USB section mention only -

            • USB version - USB 2.0 (480Mbps)
            • Device class - Communication device class (CDC)
            • Subclass -Abstract control mode (ACM)

            I need to connect with USB only So trying with qSerialport.
            detecting port by using QserialPortinfo done, it is tyACM0 but serialport open is getting failed.
            baudrate, parity, databits is not mentioned for usb connection so I am confused, failure is because of this. Tried with other possible combinations also still not helping it.
            Anything other need to do for communicate with cdc-acm device??

            K 1 Reply Last reply 10 Oct 2019, 07:46
            0
            • V vicksoccer
              10 Oct 2019, 07:25

              @kuzulis Thanks for your support!!
              My device can be connected with USB B connector and RS232 both.
              In device datasheet mention information of baudrate,partiy,databits etc only under RS232 section and under USB section mention only -

              • USB version - USB 2.0 (480Mbps)
              • Device class - Communication device class (CDC)
              • Subclass -Abstract control mode (ACM)

              I need to connect with USB only So trying with qSerialport.
              detecting port by using QserialPortinfo done, it is tyACM0 but serialport open is getting failed.
              baudrate, parity, databits is not mentioned for usb connection so I am confused, failure is because of this. Tried with other possible combinations also still not helping it.
              Anything other need to do for communicate with cdc-acm device??

              K Offline
              K Offline
              kuzulis
              Qt Champions 2020
              wrote on 10 Oct 2019, 07:46 last edited by
              #8

              @vicksoccer , are you sure that you have a right permissions to open the ttyACM device? You can search required info in google. What is an error code?

              V 1 Reply Last reply 10 Oct 2019, 09:45
              1
              • K kuzulis
                10 Oct 2019, 07:46

                @vicksoccer , are you sure that you have a right permissions to open the ttyACM device? You can search required info in google. What is an error code?

                V Offline
                V Offline
                vicksoccer
                wrote on 10 Oct 2019, 09:45 last edited by
                #9

                @kuzulis
                getting segmentation fault error in first line of qserialport code..

                usb->setPortName(port);
                usb->setBaudRate(QSerialPort::Baud9600);
                usb->setDataBits(QSerialPort::Data8);
                usb->setParity(QSerialPort::EvenParity);
                usb->setStopBits(QSerialPort::OneStop);
                usb->setFlowControl(QSerialPort::NoFlowControl);
                if (usb->open(QIODevice::ReadWrite)) {
                qDebug() << "Port open success!!";
                } else {
                qDebug() << "Port open failed!!";
                }
                nothing is happened with qserialport only port detection is succeed. I Dont know why, search on google also..

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vicksoccer
                  wrote on 10 Oct 2019, 11:31 last edited by
                  #10

                  Thanks all for your kind support!!!
                  Problem solved.. Its done with qserialport itself,
                  Now my device port is opened need to work on send commands..

                  M 1 Reply Last reply 10 Oct 2019, 11:55
                  0
                  • V vicksoccer
                    10 Oct 2019, 11:31

                    Thanks all for your kind support!!!
                    Problem solved.. Its done with qserialport itself,
                    Now my device port is opened need to work on send commands..

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 10 Oct 2019, 11:55 last edited by
                    #11

                    @vicksoccer

                    Hi
                    If possible, could you tell how you made the
                    segmentation fault error go away?
                    What was the issue and fix.

                    V 1 Reply Last reply 10 Oct 2019, 13:05
                    1
                    • M mrjj
                      10 Oct 2019, 11:55

                      @vicksoccer

                      Hi
                      If possible, could you tell how you made the
                      segmentation fault error go away?
                      What was the issue and fix.

                      V Offline
                      V Offline
                      vicksoccer
                      wrote on 10 Oct 2019, 13:05 last edited by vicksoccer 10 Oct 2019, 13:06
                      #12

                      @mrjj
                      I think fault is due to initialization of port is not proper.
                      this work for me for setting available device port and open it.

                      QSerialPort usb = new QSerialPort(port);
                      usb->setBaudRate(QSerialPort::Baud9600);
                      usb->setDataBits(QSerialPort::Data8);
                      usb->setParity(QSerialPort::EvenParity);
                      usb->setStopBits(QSerialPort::OneStop);
                      usb->setFlowControl(QSerialPort::NoFlowControl);
                      if (usb->open(QIODevice::ReadWrite)) {
                      qDebug() << "Port open success!!";
                      } else {
                      qDebug() << "Port open failed!! + usb->errorString()";
                      }

                      M 1 Reply Last reply 10 Oct 2019, 13:41
                      0
                      • V vicksoccer
                        10 Oct 2019, 13:05

                        @mrjj
                        I think fault is due to initialization of port is not proper.
                        this work for me for setting available device port and open it.

                        QSerialPort usb = new QSerialPort(port);
                        usb->setBaudRate(QSerialPort::Baud9600);
                        usb->setDataBits(QSerialPort::Data8);
                        usb->setParity(QSerialPort::EvenParity);
                        usb->setStopBits(QSerialPort::OneStop);
                        usb->setFlowControl(QSerialPort::NoFlowControl);
                        if (usb->open(QIODevice::ReadWrite)) {
                        qDebug() << "Port open success!!";
                        } else {
                        qDebug() << "Port open failed!! + usb->errorString()";
                        }

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 10 Oct 2019, 13:41 last edited by
                        #13

                        Hi
                        So you added the line
                        QSerialPort *usb = new QSerialPort(port);

                        and it then worked or something else ?

                        V 1 Reply Last reply 11 Oct 2019, 04:18
                        0
                        • M mrjj
                          10 Oct 2019, 13:41

                          Hi
                          So you added the line
                          QSerialPort *usb = new QSerialPort(port);

                          and it then worked or something else ?

                          V Offline
                          V Offline
                          vicksoccer
                          wrote on 11 Oct 2019, 04:18 last edited by
                          #14

                          @mrjj
                          Yes I have added this line only and its worked for me..

                          J 1 Reply Last reply 11 Oct 2019, 04:21
                          0
                          • V vicksoccer
                            11 Oct 2019, 04:18

                            @mrjj
                            Yes I have added this line only and its worked for me..

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 11 Oct 2019, 04:21 last edited by
                            #15

                            @vicksoccer Keep in mind that if you defined this "usb" variable somewhere else you're creating a new one with same name now.
                            If you already have one then do it like this:

                            usb = new QSerialPort(port);
                            

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            V 1 Reply Last reply 11 Oct 2019, 04:34
                            1
                            • J jsulm
                              11 Oct 2019, 04:21

                              @vicksoccer Keep in mind that if you defined this "usb" variable somewhere else you're creating a new one with same name now.
                              If you already have one then do it like this:

                              usb = new QSerialPort(port);
                              
                              V Offline
                              V Offline
                              vicksoccer
                              wrote on 11 Oct 2019, 04:34 last edited by
                              #16

                              @jsulm
                              Yes,Sure :)
                              Thanks

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                sammy_49ers
                                wrote on 19 Aug 2020, 18:08 last edited by
                                #17

                                I thought we are talking about HID devices ?

                                Whatever, if you need driver support for USB HID devices take look at www.hidxplat.com.

                                Thanks sammy

                                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