Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with queries

I have a problem with device id.  When I use NI Communicator to send commands for what I want to do, including queries, everything works fine.  But when I send the same commands from my VB code, I have problems.  Commands work fine, and the instrument responds properly.  But queries return null strings in VB, while returning valid data from NI Communicator.  The only difference I have found, using NI Spy, is that the ibwrt and ibrd functions in NI Communicator have UD0 for the first parameter, while they have UD1 when I call the same functions from VB.  I am using the ildev function to retrieve the device id, and am using that id as the first parameter.  The GPIB address is right.  The only time I have problems is with queries.  What am I missing?
0 Kudos
Message 1 of 3
(3,124 Views)

I think this is a buffer issue for VB string.  Before reading a response string, you must allocate enough space for the receive buffer.  Your code has to be like:

Dim strRd As String

strRd = SPACE(256)

CALL ibrd( ud, strRd)

 

0 Kudos
Message 2 of 3
(3,119 Views)
Thank you for your reply.  I found the problem about two hours after I posted this question.  It was similar to what you described.  The key is, the buffer string must have been defined with some minimal length or it will have a length of 0.
0 Kudos
Message 3 of 3
(3,108 Views)