Closed GoogleCodeExporter closed 9 years ago
Here the project where you can test the problem...
For test you have to run 2 time: 1st time with the line SerialProblem.cpp:40
not commented and the second time try to comment it. At first run the line
"write()" will be write only when you change the focused window, at second time
the same line will be write every second.
In ubuntu the package who provide the file fcntl.h is libc6-dev and my version
is 2.11.1-0ubuntu7.2 maybe the problem is there.
The project was created with Eclipse Helios.
Original comment by robypomper
on 25 Aug 2010 at 9:11
Attachments:
[deleted comment]
[deleted comment]
Very strange.
I have downloaded your code compiled and tried.
My FTDI cable was plugged to my Friendlyarm board which had a linux console
output on it's port.
At the first try I hade noticed the high CPU usage, and sometimes the the timer
shooted again.
I have put to the output the number of bytes written:
qDebug() <<_port->write("$>9000RQCE#");
And I seen that the write was successful, so the code is stucking somewhere
else.
After that I have connected the readyReadSignal, and read the incoming data in
it the high CPU usage had left, and the timer interval get's back to normal.
As workaround you should use QextSerialPort::Polling mode in the opening if you
do not want to use the reading.
The problem's root is the following:
In event driven mode the QSocketNotifier emits activated(int) signal always
when a data is available on the port. Since in your example there is nothing
what should read the data it locks the main loop.
This kind of operation confronts with the QIODevice's readyRead signal's
description:
This signal is emitted once every time new data is available for reading from
the device. It will only be emitted again once new data is available, such as
when a new payload of network data has arrived on your network socket, or when
a new block of data has been appended to your device.
Original comment by martonmi...@gmail.com
on 30 Aug 2010 at 3:29
Well I have tried to patch the problem, but it seems to be impossible to do it
in this way.
The QSocketNotifier emits always signals if there is unreaded data on the port.
I have written a slot to check that the available bytes number is changed. Now
it works, but it eats all the CPU time.
Original comment by martonmi...@gmail.com
on 30 Aug 2010 at 3:46
Thanks
Original comment by dbzhang...@gmail.com
on 16 Mar 2012 at 8:17
Original issue reported on code.google.com by
robypomper
on 25 Aug 2010 at 8:41