NI Home > Community > NI Discussion Forums
Reply
Member
Posts: 31
0 Kudos

GPIB hang.

I have a C# app that writes data over the GPIB bus using .NET 4882.  When the device is off, I catch the appropriate error and the program continues.  When the device gets turned on from being in an off state, the program hangs on the Device.Write() command indefinitely despite the timeout value that the device was initialized with. 
 
When in the off state and I break on the Device.Write() command before it is executed, then turn on the device, wait about 5 seconds or so, then continue execution everything is fine.  Data gets written to the device.
 
Here's my code snippet:
In constructor I init my device:

_GPIBDevice =

new Device(0, (byte)_ChanCfg.GPIBAddress, 0, TimeoutValue.T10s);

Later in my write code:

try
{
_GPIBDevice.Write(senddata);
}
catch()
{.....}

Isn't there something one can do to catch this without a hang?
 
ScottO
Member
drewcrewof2
Posts: 1
0 Kudos

Re: GPIB hang.

Hey - since I am about to write some GPIB code as well, I would like ot see the results of this query... I don't want ot get "hung" too!
Member
MissyS
Posts: 186
0 Kudos

Re: GPIB hang.

Hi,
 
Your device may need several seconds to be ready to accept commands. During its initial power-up, it may be in an unknown state. You should wait to communicate with the device until it is ready to send and receive data.
 
The reason you are not able to catch the exception is because it's not returning from the driver call. What version of the driver are you using? Can you post a Spy capture of when you make this call? What instrument and GPIB card are you using? Do you see this behavior if you use MAX or an example such as found in the folder below?
C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\GPIB\SimpleReadWrite\CS
 
Regards,
Missy S.
Calibration Engineer
National Instruments