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. binary data communication through SerialPort
QtWS25 Last Chance

binary data communication through SerialPort

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 5 Posters 5.5k 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.
  • S Offline
    S Offline
    Sen Li
    wrote on last edited by Sen Li
    #1

    Hi,

    I am a newbie working on Qt to get data through Serial Port, trying to talk to CY5670, Cypree Dongle.

    It seems like, QSerialPort Class cannot talk to it with binary communication very well that, I cannot get any data.

    Is there a way that Qt may work like RealTerm/IIRC to communicate through binary data via serial port?

    Thank you!

    1 Reply Last reply
    1
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #2

      QSerialPort is what you need. Have you got the dongle protocol?

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        hi besides what @mrdebug ask, have you tested wtih
        http://doc.qt.io/qt-5/qtserialport-terminal-example.html
        Its available directly in Creator and good for testing.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sen Li
          wrote on last edited by
          #4

          Hi @mrdebug @mrjj ,

          That Terminal example is exactly what I have tried, and then I got the conclusion that QSerialPort Class cannot talk to it; I assume that is because of the failure of binary communication, however not sure about it.

          All I know is, serialRead() was never activated even though serialWrite() has been gone through again and again.

          Here is cited by Cypress Forum about CY5670 dongle communication:
          "Since the communication uses binary codes Putty is propably not the right tool. Maybe use RealTerm, IIRC it has a mode the send and receive binary data. And I think you need to send the correct data to the dongle to answer. Maybe there is some command sequence to get a version number?"

          It is sure that Putty could not talk to the dongle, while QSerialPort is similar to Putty.

          Could anyone help me find a solution to talk to the CY5670 dongle?

          Thank you!

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by koahnig
            #5

            Every comms in serial is basically binary. It will not know a difference.
            In most cases it is a baud rate respectively other settings issue. I guess that is also the issue with Putty.
            Do you have the correct baud rate, data and stop bits and otzher flags?

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

            S 1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              Im not sure what you mean by binary communication.
              But QSerialPort can handle all that a com port can send.

              When data comes in Terminal Example
              Its read into a byte array which can handle binary just fine.
              But the PutData calls
              insertPlainText(QString(data));

              And if its not printable as text, it might become nothing. (shows nothing)

              So first check is to see if readData() is called.

              If dongle has protocol, it might expect you to send something to it before it
              sends anything.

              void MainWindow::readData()
              {
              QByteArray data = serial->readAll();
              console->putData(data);
              qDebug() << "Its alive"; /// to test its called
              }

              1 Reply Last reply
              0
              • K koahnig

                Every comms in serial is basically binary. It will not know a difference.
                In most cases it is a baud rate respectively other settings issue. I guess that is also the issue with Putty.
                Do you have the correct baud rate, data and stop bits and otzher flags?

                S Offline
                S Offline
                Sen Li
                wrote on last edited by
                #7

                @koahnig said:

                Do you have the correct baud rate, data and stop bits and otzher flags?

                Yes, I am sure those are correct.

                The dongle is controlled by command packets. And any wrong command packets should active a error response, which I never received; the serialRead() was never called.

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  well I would try with
                  http://realterm.sourceforge.net/ then and see if it even works at all.

                  1 Reply Last reply
                  0
                  • mrdebugM Offline
                    mrdebugM Offline
                    mrdebug
                    wrote on last edited by mrdebug
                    #9

                    Have you tried the QThread approach instead of events?
                    Please, download this
                    http://kde-apps.org/content/show.php/QtComPort?content=142378
                    and have a look at the file qthcomport.cpp
                    I know everybody don't like the QThread approach instead of events but in a difficoult situation I think the QThread approach is better. You can manage timemouts an polling.
                    Have you got the dongle serial protocol?
                    Every serial device has a protocol. For example if you send at a modem at&v you will have the current modem configuration.
                    Often the serial devices have a command to know the firmware version. This is the first command to implement. Normally there are a byte to begin, end and control.
                    Have you found the serial protocol in the sdk?

                    Need programmers to hire?
                    www.labcsp.com
                    www.denisgottardello.it
                    GMT+1
                    Skype: mrdebug

                    1 Reply Last reply
                    1
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Hi,

                      Maybe a silly question but are you sure this dongle can be used like a serial port ? The description says BLE to USB bridge.

                      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
                      • mrdebugM Offline
                        mrdebugM Offline
                        mrdebug
                        wrote on last edited by
                        #11

                        I think the same thing. I normally use ble with bluez ( the Debian bluetooth stack) and not the usb dongle directly. Maybe his usb dongle has the bluetooth stack embedded.

                        Need programmers to hire?
                        www.labcsp.com
                        www.denisgottardello.it
                        GMT+1
                        Skype: mrdebug

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          Sen Li
                          wrote on last edited by
                          #12

                          Hi @mrjj @mrdebug ,

                          Thank you guys for helping me.

                          I finally got a response after sending a command packet to the dongle through a serial port.

                          So happy about it!

                          mrjjM 1 Reply Last reply
                          1
                          • S Sen Li

                            Hi @mrjj @mrdebug ,

                            Thank you guys for helping me.

                            I finally got a response after sending a command packet to the dongle through a serial port.

                            So happy about it!

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @Sen-Li
                            congratulation!

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              Nice, what was the problem ?

                              On a side note, you don't need to modify your thread title anymore, just use the "Topic Tool" button to mark the thread as solved :)

                              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
                              • S Offline
                                S Offline
                                Sen Li
                                wrote on last edited by
                                #15

                                That CY5670 BLE dongle discards any commands without a header, which means I need to add a header to my command packet to talk to the dongle, otherwise nothing will happen.

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  Thanks for sharing your findings :)

                                  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

                                  • Login

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