LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

viQueryf formatting issue

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.

0 Kudos
Message 1 of 9
(6,146 Views)

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"

0 Kudos
Message 2 of 9
(6,141 Views)

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.

0 Kudos
Message 3 of 9
(6,137 Views)

And The Cmd is = "READ:SPUR1?". This works when sent from communicator.

0 Kudos
Message 4 of 9
(6,136 Views)

This shows also the same error:

 

    if ((viQueryf (visaHandle, "READ:SPUR1?\n", "%,#le", &retCnt, spurArray)) < 0)    return SA_ERROR_WRITE;

0 Kudos
Message 5 of 9
(6,134 Views)

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;

0 Kudos
Message 6 of 9
(6,130 Views)

hm, did you check that retCnt is not zero when you are calling viQueryf?

0 Kudos
Message 7 of 9
(6,128 Views)

Sorry, it was already =25 from the previous operation..!

0 Kudos
Message 8 of 9
(6,126 Views)

I re-initialize and now retCnt reads 0.

0 Kudos
Message 9 of 9
(6,124 Views)