Qt Serial Port Communication Example
QT-Software
- Download the Repository.
- Extract the Files somewhere but let the file structure the same.
- Open QT-Creator and open the Project by Browsering to the extractet .pro file.
- I usually compile with MinGW so check if you have that or try other compilers.
- Compile the code.
- 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)
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...
//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!
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