ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB Controller and Asynchronous Programming

Hi,

I've been trying to write a large software that will allow me to
automate various GPIB programs all at once. I'm new with GPIB commands
so I need to ask this question: what happens if the program sends out 2
GPIB commands at the same time? or when the other command is not ready
to be sent? I'm trying to decide if I need to have a static "wait"
member that will block any write/query command on the GPIB bus until
the line is free. And if so, what commands do I use to figure out if
the line is busy or not? *OPC?

Thanks you.

0 Kudos
Message 1 of 2
(3,304 Views)

I believe you are trying to send GPIB commands at the same time from multiple threads or processes.  Normally GPIB and/or VISA driver does process its own mutual exclusion, keeping all the write/read function calls to be serialized.  Therefore multiple GPIB commands are never be cross-overlapped. 

Other case is that one thread (or process) sends a GPIB command and then reads the response, at the same other thread sends a different GPIB command then reads the response.  For example, the thread #1 is querying "*IDN?" and the thread #2 is querying "MEAS:VOLT?".  In this case, you should use Lock/Unlock functions to avoid the two query pairs from cross-overlapping.  If overlapping, sending "MEAS:VOLT?" command immediately after the "*IDN?" command without reading response will corrupt the IDN response to receive.

The Win32 functions for lock/unlock are Semaphoe, Critical-Section, or Mutex.  the VISA library also provides this kind mechanism for multiple VISA sessions that access the same I/O resource at the same time. 

0 Kudos
Message 2 of 2
(3,283 Views)