QtSerialPort and CPU usage
-
QByteArray may not be zero terminated - forget this.
Some ideas, try harder to figure out where actually the cpu time is consumed. We can only see the code you've applied but in my opinion you should look into the send signal and (more possible) the receive slot. Try to remove the lines from the above code until it stops hanging. Maybe it is hanging in some procedure you don't have the code for and you don't see the while loop where it is cycling. You may also look into the rest of your code, sometimes someone programs a recursive statement unintended especially when you filled up everything into a single class.
good look!
-
2Dolbyz,
Previously had a similar problem with the CPU load, using the USB / Serial converter chip Prolific. The problem was that in a false fire notifier QWinEventNotifier at data receiving. Presumably the reason is the driver, although it is difficult to say. Previously, I seems to be fixed this problem, though .. I try will check again.
-
My colleague found another usb-to-serial cable (USB-SERIAL CH340 wch.cn). It works perfectly.
When I debugged with the old cable it seemed to loop in qevendispatcher_win.cpp:770 for loop. With the old cable I got from two to eight readyRead-signals (message length about 16 bytes). With this "new" cable, just single signal with whole data.
Thanks for your help.
-
Please try to fix the code in the source code library QtSerialPort to test, as described "here":https://bugreports.qt-project.org/browse/QTPLAYGROUND-2 and take there is an example of an "attached":https://bugreports.qt-project.org/secure/attachment/28890/TestSerial.zip for testing.
-
I tried this fix. The problem still occurs. I used my own code for testing.
For second try I put debug print to that event-function. I guess it was called "few" times, because then qt creator jammed too :)
-
Bad bad bad. I do not have ideas how to fix it.
-
UPD: Please try repeat test with new test tool "CpuUsageTester":https://bugreports.qt-project.org/secure/attachment/28899/CpuUsageTester.zip
-
It works exactly same way with this test application.
-
Clear, thx
So, most likely a problem in the drivers.
-
2 Dolbyz,
Please check CPU load with a new concept from "here":https://codereview.qt-project.org/#change,32186
PS: If you have free time.
-
I'll try to test during this week.
-
With this version I could not reproduce the 100% CPU usage-bug.
At least previously it happened almost immediately. Now I tried for some time, but no issues.