Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VB6 using Visa32.dll

I'm looking for an already developed class module that wraps Visa32.dll for VB6. I haven't found one, so I've started developing my own. I'm running into a challenge that hopefully someone can help me address. When I attempt to do a read from the GPIB bus using the driver, if I don't use a fixed length string, I get a 0 length string returned. If I use
 
viVScanf(vi, "%t", response)
 
where response is a string variable, it is blank. If I set response to be fixed length of 10, I'll return the first 10 characters in the buffer, but it will stop there. If I attempt to do another read, I get a "Query Interrupted" error on my instrument.
 
If I use:
 
viRead(vi, response, ReadLength, ReturnCount)
 
where response is fixed length of 10 and ReadLength=10, I can do subsequent reads and look for the ASCII 10 (line feed) character in the string until it is complete.
 
The problem with this approach is that I'll have to loop and consume extra time reading. I'd much rather be able to dynamically set the length of the string based on the need. For example, I'd like to have a function, GPIB_Read, where I pass the length I want to return and then I can set the string to be that length prior to calling the ViRead function (or viVScanf function).
 
Any tips on getting past this?
 
Thanks,
Tom
0 Kudos
Message 1 of 5
(5,351 Views)

Hi Tom,

Using the attribute VI_ATTR_ASRL_AVAIL_NUM might help you.  According to the NI-VISA Help, VI_ATTR_ASRL_AVAIL_NUM shows the number of bytes available in the low-level I/O receive buffer.  I hope this helps!

Regards,

Rima

Rima H.
Web Product Manager
0 Kudos
Message 2 of 5
(5,318 Views)
Thanks Rima,
 
I'll use that. I'll be able to reduce the number of loops by increasing the size I read in...And I won't have to default to the maximum string size when no size is passed.
 
Thanks,
Tom
0 Kudos
Message 3 of 5
(5,309 Views)
I was finally able to get back to this today and was looking for the attribute you mentioned. Unfortunately, it is specifically for a "serial INSTR". I'm working with a GPIB Instrument. Thanks for the try. I think I'll just have to read 10 bytes at a time until I hit the line feed character.

Thanks again.

Tom
0 Kudos
Message 4 of 5
(5,218 Views)

Hi Tom,

Unfortunately, there is no GPIB equivalent of that attribute, so you will have to read 10 bytes at a time.  Good luck!

Regards,

Rima

Rima H.
Web Product Manager
0 Kudos
Message 5 of 5
(5,201 Views)