bounded read/write buffer issue

Skip to first unread message

Sebastian Parschauer

May 20, 2014, 6:36:11 AM5/20/14
to, Sebastian Parschauer
Hi QextSerialPort developers,

I'm using QextSerialPort and SCPI (standard commands for programmable
instruments) to control a Tektronix 4050 DMM with my Qt application
"DMM_get_values". As I only have limited access to such device, I've
developed a DMM emulation software called "DMM_send_values" based on the
same code basis. I use two Prolific PL2303 compatible USB-to-serial
adapters and a null modem cable. I've recently extended the tools to
handle a variable samples count. Multiple samples are sent
comma-separated. Then, I've noticed the issue.

When using 100 samples with 10 chars each, the next command is
incomplete (only the end of the command is transfered through the wire).
This reproduces always for sure. If using more or less samples, it works
as expected. This is independent from the baud rate.

Communication is like this:

Command sent and received:

Response sent and received:
"+0,\"No error\"\r\n"

Command sent and received:

Response sent and received:
"-0.000200,-0.000200,-0.000200," ... "-0.000200\r\n"

Command passed to the Qesp write() function:

Command received:
"EN?\n" or "S:EVEN?\n"

Any idea how to fix this issue?

I use 4097 bytes as a buffer (last char is used for '\0') and read up to
4096 bytes (the size of a memory page). I do polling with 5ms cycles
with DMM_get_values and 50ms cycles with DMM_send_values. In case a
command or response isn't terminated, I concatenate the strings of two
cycles. I also have separate QStrings for send and and receive. Can't
find any issue on my side.

I use QextSerialPort from Git commit 3be3fbf31ed (Jul 8 2013) and
develop mostly on Linux. My tools are GPLv3 licensed and public. So you
could have a look at my Qt 4.7 source code:

* QThread sending SCPI commands and receiving responses

* QThread receiving SCPI commands and sending responses

* wrapper/helper class for QextSerialPort


Sebastian Parschauer

May 20, 2014, 2:42:21 PM5/20/14
Hi again,

I've found the issue in my code. My tools handle timed out incomplete
commands the same way as timed out empty commands. This is why the first
part of the command disappears.

The fix is simple in this case: Give it another try and concatenate
command strings.

This is my patch:

Sometimes it just helps writing down the issue for somebody else. ;-)

Thank you very much for your great work on QextSerialPort!

It enables me to do Open Measurements. No NI VISA, no NI LabVIEW. :-)

Reply all
Reply to author
0 new messages