[Qt-interest] Qextserialport time out question
Phil
phillor at telstra.com
Sat Dec 26 08:14:37 CET 2009
Thank you for reading this.
This is a long standing problem that I have never been able to solve. If I
initialise the serial port as follows then it takes one second to read five
bytes. If I don't set the time out parameter or set it to anything less than
one second then the read fails.
However, if I step through the code with the debugger then the device is
read correctly so it's a timing issue somewhere.
Can anyone suggest a likely cure?
port = new QextSerialPort("/dev/ttyUSB0");
port->setBaudRate(BAUD4800);
port->setFlowControl(FLOW_OFF);
port->setParity(PAR_NONE);
port->setDataBits(DATA_8);
port->setStopBits(STOP_2);
port->setTimeout(1,0); //1 second
do
{
bytes = port->bytesAvailable();
error = port->lastError();
if(error == E_PORT_TIMEOUT)
return -1;
} while(bytes < 5);
port->read(buffer, 5);
Could the USB to serial converter be the cause of the timing problem? It
woks perfectly except in this application.
--
Regards,
Phil
More information about the Qt-interest-old
mailing list