05-10-2011 02:43 AM
Hello All,
I have trouble with VISA command
if ((viQueryf (visaHandle, Cmd, "%,# le", &retCnt, spurArray)) < 0) return SA_ERROR_WRITE;
I use it for reading a variable length array of spurious values from E4440A. When executed, I see the error:
NON-FATAL RUN-TIME ERROR: "sa.c", line 529, col 10, thread id 0x00000FEC, function id 2: Function viQueryf: (return value == -1073807297 [0xbfff003f]). A format specifier in the format string is invalid.
and the spurArray is all empty and retCnt comes = 25. Definition of spurArray is double of 128.
The actual data coming from instrument using NI 488.2 communicator is:
+6.00000000E+000,+1.00000000E+000,+1.00000000E+000,+9.87903500E+007,+1.71000000E-001,-7.40000000E+001,+0.00000000E+000,+2.00000000E+000,+1.00000000E+000,+2.00073200E+008,
-3.73750000E+001,-7.40000000E+001,+0.00000000E+000,+3.00000000E+000,+1.00000000E+000,
+3.01356100E+008,-5.78350000E+001,-7.40000000E+001,+0.00000000E+000,+4.00000000E+000,
+1.00000000E+000,+1.97776200E+009,-6.87270000E+001,-7.40000000E+001,+0.00000000E+000,
+5.00000000E+000,+1.00000000E+000,+1.75424100E+009,-6.97490000E+001,-7.40000000E+001,
+0.00000000E+000,+6.00000000E+000,+1.00000000E+000,+5.59802000E+008,-6.99430000E+001,
-7.40000000E+001,+0.00000000E+000
Does anyone have any suggestions?
Thanks,
Engin.
05-10-2011 03:00 AM
Obviously, one of your two format specifiers, the one in Cmd, or the one shown in your post, is wrong. Suggestions: check Cmd, and also I am not sure about the space in your format string "%,# le"
05-10-2011 03:19 AM
In my original code, there's no space. It is exacly the same as the example in Visa help:
This example shows how to take multiple readings from an instrument. The comma (,) indicates the parameter is an array and the number (#) sign specifies the actual number of readings returns from the instrument.
/* Read Multi-Point */
ViInt32 readingCnt
= 50;
ViReal64 readingArray[50];
viQueryf (io, "READ?\n", "%,#le",
&readingCnt, readingArray);
Thanks.
05-10-2011 03:20 AM
And The Cmd is = "READ:SPUR1?". This works when sent from communicator.
05-10-2011 03:27 AM
This shows also the same error:
if ((viQueryf (visaHandle, "READ:SPUR1?\n", "%,#le", &retCnt, spurArray)) < 0) return SA_ERROR_WRITE;
05-10-2011 03:31 AM
And this works, but returns only the 1st entry of the array:
if ((viQueryf (visaHandle, "READ:SPUR1?\n", "%le", spurArray)) < 0) return SA_ERROR_WRITE;
05-10-2011 03:45 AM
hm, did you check that retCnt is not zero when you are calling viQueryf?
05-10-2011 03:53 AM
Sorry, it was already =25 from the previous operation..!
05-10-2011 03:55 AM
I re-initialize and now retCnt reads 0.