Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read function problem

VISA Read function  replys slowely if the string does not consists "end of line constant". How it can be improved?
0 Kudos
Message 1 of 4
(3,217 Views)
0 Kudos
Message 2 of 4
(3,207 Views)

What hardware interface are you using? GPIB, Serial, or any others?  GPIB has a special termination condition - EOI, which does not exist in Serial interface, therefore there is some difference between them.

VISA Read function (viRead, viScanf) can successfully and rapidly return only when:

(1) Explicit termination character (0x0A default) is encountered on viRead/viScanf call, or
(2) Number of bytes specified on viRead() call has been transfered.

In your case, it seems like the response string does not contain the CR(0x0D) or LF(0x0A) as a termination character, therefore the VISA Read call is timed out.  If any other character byte is constantly expected as string termination, you can avoid the timeout problem by changing VI_ATTR_TERMCHAR attribute using viSetAttribute() function.  Otherwise, you must use viRead function explicitly specifying number of bytes expected.

0 Kudos
Message 3 of 4
(3,204 Views)

Thank you.

Definiton of number of bytes expected solves the problem.

Thanks a lot.

 

0 Kudos
Message 4 of 4
(3,176 Views)