[Qt-interest] QExtSerialPort Overhead
Donal
donaloconnor at gmail.com
Sat Feb 14 02:36:20 CET 2009
Hi again,
Forgive me for posting this in here, I will continue my qextserialport
issues else where but a final quick one just in case you have any ideas....
I created a separate thread for my serial I/O. In the run() method I created
all the necessary objects etc and created a connection to the serial port
successfully. I successfully wrote a command out. My problem however though
is the amount of time it takes to issue a read.
I created a QTime object to measure the elapsed time and the results are
crazy. About 500ms just to read from the buffer??
void run()
{
connection = new QextSerialPort("/dev/ttyUSB0");
connection->setBaudRate(BAUD38400);
connection->setDataBits(DATA_8);
connection->setParity(PAR_NONE);
connection->setStopBits(STOP_1);
connection->setFlowControl(FLOW_OFF);
int result = connection->open(QextSerialPort::ReadWrite);
if (result)
qDebug("Successfully Connected to Serial Port");
else
qDebug("Failure to Connect to Serial Port");
QTime t;
QString message("010C\x0D");
connection->write(message.toAscii(),message.length());
int bytes = 0;
QByteArray myBuffer;
bytes = connection->bytesAvailable();
while(bytes != 33)
{
bytes = connection->bytesAvailable();
if (bytes == 33)
{
t.start();
myBuffer = connection->read(bytes);
qDebug("Time elapsed : %d ms", t.elapsed());
} else
SleepThread::msleep(10);
}
connection->close();
}
OUTPUT:
Successfully Connected to Serial Port
Time elapsed : 499 ms
As matter of fact is is always 499ms. I am using XUbuntu in VMWare so I am
not sure if that is an issue or not.
I know that my code doesn't do much error checking etc.
How is it so slow to do a read from the buffer?
The problem I have is that I must send a command and read the full response
as quick as possible so I don't want to be doing sleeps before I attempt to
read, I want to poll as fast as possible and then read all data from buffer
at one go.
Cheers.
Donal
On Thu, Feb 12, 2009 at 5:08 PM, Donal <donaloconnor at gmail.com> wrote:
> Thanks very much for the response. Yep understand it is not part of the
> standard QT framework, so apologies for bringing it here.
>
> Thanks for the advice, I will take it onboard.
>
> Regards,
> Donal
>
> On Thu, Feb 12, 2009 at 4:58 PM, Pascal Patry <iscy at invalidip.com> wrote:
>
>> On February 12, 2009 11:31:09 am Donal wrote:
>> > Hi There,
>>
>> Hi,
>>
>> > I am wondering if I'll have timing issues further down the line and need
>> to
>> > know if QExtSerialPort is the way to go.
>>
>> QextSerialPort is not part of Qt. It is a separate project developed
>> developed by
>> different people. However its API is based on Qt.
>>
>> > I will be querying a serial device roughly 6 times a second, processing
>> lot
>> > of different commands. This will be running in a thread along
>> > with a QTimer in another for reading time outs etc.
>>
>> You should probably think about doing an IO only thread here instead of
>> relying on QTimer
>> for performance reasons...
>>
>> > I will be running this on a 200Mhz ARM processor on Embedded Linux. My
>> > question is, is QExtSerialPort quick enough to handle such requests
>> > while updating a GUI with maybe 6 values obtained each second.
>> >
>> > If not I may have to go more low level with C.
>>
>> Yes, QextSerialPort is more than enough for your needs. It will help you
>> staying far from
>> posix calls, while being cross platform. It is only a wrapper, so it won't
>> hurt the
>> performance your application.
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090214/518b8638/attachment.html
More information about the Qt-interest-old
mailing list