Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Change values on Qt according to a serial port string
QtWS25 Last Chance

Change values on Qt according to a serial port string

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
bluetooth rfcomserial portlabelcirculargaugeread serial
4 Posts 2 Posters 2.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.
  • M Offline
    M Offline
    maxime.armand
    wrote on last edited by maxime.armand
    #1

    Hello everyone,

    I know that Qt has a great documentation, but it has been weeks that I'm reading everything on it and can't find a solution. I'll explain you my setup so you can figure it out.

    I have a microcontroller called "STM32 Nucleo" which is used to read several inputs and to deducts from these inputs, other electrical quantities.

    This STM32 is connected to a Bluetooth Module, which is used to send a string (and only this way, the other way (receiving data) is not wired. I've tested with HyperTerminal-like programs and it sends it really well.

    In the other hand, I have a Raspberry Pi which will have a Qt program running. This Qt program is used to receive the electrical quantities as a string and display them on a GUI.

    So here's my problem : I don't know how to read the data received on the serial port /dev/rfcomm0 of the raspberry with the Qt program, and then I need to parse the string and update the values of the GUI according to the data received.

    If I make a step-by-step list of my problem :

    • Read the /dev/rfcomm0 on my Qt program
    • Parse it to have my electrical quantities (I've already find it on the documentation)
    • Update some Labels and Values of CircularGauge QML Type

    So if anyone could give me a hint, i'll be glad and it will be a great step to finish my uni project.

    Thanks a lot,
    Max

    aha_1980A 1 Reply Last reply
    0
    • M maxime.armand

      Hello everyone,

      I know that Qt has a great documentation, but it has been weeks that I'm reading everything on it and can't find a solution. I'll explain you my setup so you can figure it out.

      I have a microcontroller called "STM32 Nucleo" which is used to read several inputs and to deducts from these inputs, other electrical quantities.

      This STM32 is connected to a Bluetooth Module, which is used to send a string (and only this way, the other way (receiving data) is not wired. I've tested with HyperTerminal-like programs and it sends it really well.

      In the other hand, I have a Raspberry Pi which will have a Qt program running. This Qt program is used to receive the electrical quantities as a string and display them on a GUI.

      So here's my problem : I don't know how to read the data received on the serial port /dev/rfcomm0 of the raspberry with the Qt program, and then I need to parse the string and update the values of the GUI according to the data received.

      If I make a step-by-step list of my problem :

      • Read the /dev/rfcomm0 on my Qt program
      • Parse it to have my electrical quantities (I've already find it on the documentation)
      • Update some Labels and Values of CircularGauge QML Type

      So if anyone could give me a hint, i'll be glad and it will be a great step to finish my uni project.

      Thanks a lot,
      Max

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @maxime.armand

      For part 1 have a look at the Serial Port Reader Example

      It's very simple and you will be able to re-use the class SerialPortReader in your project.

      I suggest that you first take the example as-is and see if you actually can receive data.

      Than integrate SerialPortReader in your project and check again.

      The last step is to change the QML elements from C++, but there are lots of examples also.

      Regards.

      Qt has to stay free or it will die.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        maxime.armand
        wrote on last edited by maxime.armand
        #3

        I've already read it, but I've difficulties to understand it.
        And doesn't it seem too much for what I'd like to do in my program ? Because I'll always connect to the same serial port, with the same BaudRate, etc...

        Although, in the example, I don't find where do I tell to the C++ to connect to /dev/rfcomm0 ? Did I miss something ?

        Thanks

        aha_1980A 1 Reply Last reply
        0
        • M maxime.armand

          I've already read it, but I've difficulties to understand it.
          And doesn't it seem too much for what I'd like to do in my program ? Because I'll always connect to the same serial port, with the same BaudRate, etc...

          Although, in the example, I don't find where do I tell to the C++ to connect to /dev/rfcomm0 ? Did I miss something ?

          Thanks

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by aha_1980
          #4

          @maxime.armand

          Have you actually tried it? It does exactly what you demand in step 1.

          And if you look in http://doc.qt.io/qt-5/qtserialport-creaderasync-main-cpp.html you will see that the serial port and the baud rate are given as command line parameters.

          Just (cross-)compile the program for the Raspberry, and run it. It should work like your HypterTerminal test.

          Qt has to stay free or it will die.

          1 Reply Last reply
          2

          • Login

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