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
Forum Updated to NodeBB v4.3 + New Features

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.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.
  • V Offline
    V Offline
    vicksoccer
    wrote on 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..

    jsulmJ 1 Reply Last reply
    0
    • V vicksoccer

      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..

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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 last edited by kuzulis
        #5

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

        Yes

        V 1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on 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

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

            Yes

            V Offline
            V Offline
            vicksoccer
            wrote on last edited by vicksoccer
            #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
            0
            • V vicksoccer

              @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 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
              1
              • K kuzulis

                @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 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 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..

                  mrjjM 1 Reply Last reply
                  0
                  • V vicksoccer

                    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..

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 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
                    1
                    • mrjjM mrjj

                      @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 last edited by vicksoccer
                      #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()";
                      }

                      mrjjM 1 Reply Last reply
                      0
                      • V vicksoccer

                        @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()";
                        }

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 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
                        0
                        • mrjjM mrjj

                          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 last edited by
                          #14

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

                          jsulmJ 1 Reply Last reply
                          0
                          • V vicksoccer

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

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 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
                            1
                            • jsulmJ jsulm

                              @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 last edited by
                              #16

                              @jsulm
                              Yes,Sure :)
                              Thanks

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                sammy_49ers
                                wrote on 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