SerialPort Test
-
Just guessing: but maybe try reducing the speed of your serial port.
-
Hi,
Depending on your Qt version, there was a problem with the blocking implementation. The usual way of using QSerialPort is the asynchronous mode.
-
My Qt version is 5.2.0, I will try asynchronous mode today. Wish it could solve this problem.
-
Hi, I had another problem now. When I use the asynchronous method like this
@
connect(cSerialPort,SIGNAL(readyRead()),this,SLOT(ReadData()));
@
Firstly, nothing happened in my program, there is no data received. Next I add
a line like following
@
serialPort->waitForReadyRead(0);
@
My program can receive data. Is this usage appropriate?. -
Are you still using a loop anywhere in your code ?
-
Yes, I have a loop in "Read data" Slot function. They are like this
@
void worker::ReadData()
{
while(!serialPort->atEnd())
DataReceive += serialPort->read(serialPort->bytesAvailable());
}
@
The result still as same as synchronous mode. Byte and byte sometimes would delay a random time(0~15ms). -
Don't do it like that. Just call readAll and you'll get all what is currently available
-
Hi, I modified it and tested again. This problem still was existing.... By the way, I used another language(C#) to implement function like I wrote by Qt. I never found this problem occurred. Is it a potential bug in using QSerialPort?
-
Can you show your complete test code ?
-
Sure, but it's a little big. Do you have e-mail? I can mail the project to you.