Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with viQueryf in VISA 2.6

We've recently installed VISA 2.6 on our systems and have found that our routines making use of viQueryf are no longer working. We've narrowed it down to two main problems:

1. When using "%#t", the size of the array is returned instead of the number of characters read, unless the size of the array is less than the number of characters read.

For example:
ViInt32 strSize = 256;
ViChar stringResult[256] = "\0";
stringResult[0] = 0;
ErrStatus = viQueryf(SessionID, "%s\n", "%#t",
"SYST:ERR?", &strSize,
stringResult);

This returns 256 as the strSize, even through only 14 characters are returned in the string. If I change strSize to 0, then after r
unning the function, it returns 14.

2. The function is not writing a null-terminating character to the return string. For example:

ViInt32 errorCode = 0;
ViChar errorMessage[256] = "abcdefghijklmnopqrstuvwxyz0124556789";
ErrStatus = viQueryf(SessionID, "SYST:ERR?\n", "%ld,%t", &errorCode, errorMessage);

After executing this, errorMessage contains "No error"\nlmnopqrstuvwxyz0124556789.

Flushing the buffer does not change the results, nor does setting the first character to null or calling sprintf(errorMessage, "\0"). The only way we've been able to work around this is to zero-fill the string previous to calling the function.

Are there any workarounds or fixes for these problems?

Scott
0 Kudos
Message 1 of 3
(3,763 Views)
Scott:

This is a known bug in NI-VISA 2.6.0. There is a patch (for Win32) available at the following URL. Just copy visa32.dll over the one in your Windows system directory.

ftp://ftp.ni.com/support/visa/drivers/win32/2.6/patch/

Dan Mondrik
Senior Software Engineer, NI-VISA
National Instruments
Message 2 of 3
(3,763 Views)
NI has known about this bug for a year. When will this fix be included in the version that is being distributed?
0 Kudos
Message 3 of 3
(3,763 Views)