bounded read/write buffer issue

13 views
Skip to first unread message

Sebastian Parschauer

unread,
May 20, 2014, 6:36:11 AM5/20/14
to qextser...@googlegroups.com, 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:
":TRIG:COUN 1;:SAMP:COUN 100;\n:SYST:ERR?\n"

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

Command sent and received:
"INIT;\nFETC?\n"

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

Command passed to the Qesp write() function:
":STAT:QUES:EVEN?\n"

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:

https://github.com/sriemer/dmmctr

src/dmmcontrol.cpp/.h:
* QThread sending SCPI commands and receiving responses

src/DMM_send_values/dmmcontrol.cpp/.h:
* QThread receiving SCPI commands and sending responses

src/serialportctr.cpp/.h
* wrapper/helper class for QextSerialPort

Cheers,
Sebastian

Sebastian Parschauer

unread,
May 20, 2014, 2:42:21 PM5/20/14
to qextser...@googlegroups.com
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:
https://github.com/sriemer/dmmctr/commit/871107e08875e21b270054d3e0e2a97bbc112824

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. :-)

Cheers,
Sebastian
Reply all
Reply to author
Forward
0 new messages