Qt Serial Port Communication Example

Posted on by admin

QT-Software

  1. Example Of Serial Communication Protocol
  2. Qt Serial Port
  1. Download the Repository.
  2. Extract the Files somewhere but let the file structure the same.
  3. Open QT-Creator and open the Project by Browsering to the extractet .pro file.
  4. I usually compile with MinGW so check if you have that or try other compilers.
  5. Compile the code.
  6. The example uses only qDebug() outputs for displaying any data
    so let the console in QT-Creator open while the program is running.

Qt Serial Port support: summary refs log tree commit diff stats.

Device-Software

  • I used a Arduino to communicate to the GUI.
    The code for that is in the Device-code folder

Building

  • YES For more Information click here.
  • NO When you don't need a standalone version putt all needed .dll files to the .exe.
    In the Compiled folder, you can find all needed .dll files for the program. You can find these in your QT install folder.
    C:Qt5.10.1mingw53_32bin
    It depends on your installation and compiler.
    The folder platforms is allso needed.
    The .dll in there you can find
    E:Qt5.10.1mingw53_32pluginsplatforms

Questions?

  • Then contact my. (if you can)
Active3 months ago

I'm able to connect to my serial port, but I need to read data from it all the time.
It's working for about 39 minutes, but after it stops at line serial.flush().
When I stop Qt and start it again it also stops at serial.flush(). I need to restart my modem to let it work again...

I'm not sure I'm executing this properly...

Example

//EDIT

if deleting flush it's working, but code goes really fast. It don't wait for WaitFor...
After 2nd loop he doesn't has time to read data.

serial.isOpen() && serial.isWritable() always sends true in while loop.

Program stops at flush after 30 minutes!

lpapp
43.4k13 gold badges81 silver badges110 bronze badges
Communicationgr3ggr3g
1,7312 gold badges13 silver badges34 bronze badges

1 Answer

If serial.isOpen() && serial.isWritable() is true in while loop, but you can't access it could come from you preferences on your computer.

On OSX: System preferences -> network -> select serial -> advanced -> PPP:
able: Ask to stay connected every 10 minutes,
disable: disconnect at close of session,
disable: disconnect when changing of user

gr3gQt Serial Port Communication Examplegr3g

Example Of Serial Communication Protocol

1,7312 gold badges13 silver badges34 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Qt Serial Port

Not the answer you're looking for? Browse other questions tagged c++qtserial-portqtcoreqtserialport or ask your own question.