Image 01
profile-image

wcai

Vincent Cai
QSerialDevice

Qt Components by kuzulis 143 comments

I create
UART = new AbstractSerial(this);// in "TSAApp" thread

and try to delete UART in "main" thread, and the system is crashed at
AbstractSerialEngine::~AbstractSerialEngine()
{
delete d_ptr;
}//crash here, and when I set a breakpoint here, I can see this breakpoint is hit by twice which is abnormal and lead to crash.

See attachement.
Sorry, I don't know how to upload attachement, please check you email. - Sep 16 2011
QSerialDevice

Qt Components by kuzulis 143 comments

Dear Denis,
I am using the QSerialDevice in my project and below is my setting:

UART = new AbstractSerial(this);
UART->setDeviceName("\\\\.\\" + DeviceName);
UART->setBaudRate(AbstractSerial::BaudRate921600);
UART->setDataBits(AbstractSerial::DataBits8);
UART->setFlowControl(AbstractSerial::FlowControlOff);
UART->setParity(AbstractSerial::ParityNone);
UART->setStopBits(AbstractSerial::StopBits1);
UART->flush();
if(UART->open(QIODevice::ReadOnly))
{
}
else
{
IsException = true;
}

And it works well with lower baudrate setting, such as BaudRate115200, but when I try BaudRate921600, there is always some data lost.
And I also found that, under below condition, the system will always pending in readData()
Condition: the external UART is always output data to PC, and I set a breakpoint after opening the UART device and wait for several senconds then continue running, then the system will pending in readData(). Please note that I am using your latest release source code in my project.
When system pending, I 'pause' the application, and found that it pending in below code:
while (readSoFar < bytesToRead) {
const char *ptr = d->readBuffer.readPointer();
int bytesToReadFromThisBlock = qMin(int(bytesToRead - readSoFar),
d->readBuffer.nextDataBlockSize());
memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock);
readSoFar += bytesToReadFromThisBlock;
d->readBuffer.free(bytesToReadFromThisBlock);
}
And I can watch that bytesToReadFromThisBlock is always 0 which lead to pending.

Please help :) - Sep 05 2011
QSerialDevice

Qt Components
by kuzulis

7.9
Sep 05 2011