LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

viQueryf returning a NULL

I created an IVI Spectrum Analyzer driver using the Instrument Driver Development Wizard.  When it uses the viQueryf function, I get a NULL value returned. 
 
For example:
static ViStatus _VI_FUNC hp856xEAttrMarkerAmplitude_ReadCallback (ViSession vi,
                                                                            ViSession io,
                                                                            ViConstString channelName,
                                                                            ViAttr attributeId,
                                                                            ViReal64 *value)
{                
    ViStatus    error = VI_SUCCESS;
    ViChar      rdBuffer[BUFFER_SIZE];
    ViUInt32    retCnt;
   
    viCheckErr( viPrintf (io, "MKA?"));
    viCheckErr( viRead (io, rdBuffer, BUFFER_SIZE-1, &retCnt));  // This works!! Smiley Happy
    
    viCheckErr (viQueryf (io, "MKA?", "%lf", &value));  //  This doesn't  Smiley Sad
    
   
Error:
    return error;
}
 
If I use the NI-488.2 Communicator, the query function works fine.  I have LabWindows 7.1.1 and NI-Visa 3.3.1.  Does anyone have any ideas why the viQueryf function might not be working?
 
Thanks for your help!
0 Kudos
Message 1 of 3
(3,047 Views)
Hello,

Looks like you should be passing value into hp856xEAttrMarkerAmplitude_ReadCallback instead of &value.  Your read callback function takes a ViReal64* (value), but you pass the address of that (a ViReal64**) to viQueryf.  Instead of writing into value, it writes over value (not good, since it's writing 8 bytes to a 4-byte slot), making the number at value completely meaningless.

Hope this helps.

Mert A.
National Instruments


0 Kudos
Message 2 of 3
(3,041 Views)
Thanks Mert!!  I trusted the wizard too much, and didn't look at what was really happening.  It was a long day, yeah that's it...
 
Thanks again.
0 Kudos
Message 3 of 3
(3,034 Views)