Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

GpibException events

Solved!
Go to solution

I am using the board class for communication and  would like my application to be automatically notified of communication errors rather than manually polling the result after every comm procedure.

 

What is the best way to define a callback function to handle when a GpibException error code is thrown?

 

I see that it is not possible to have a Board.Notify monitoring the GpibStatusFlags.Error mask. The documentation also states that this exception is 'thrown' when an error occurs.

 

Thank you for the support

 

 

0 Kudos
Message 1 of 4
(4,015 Views)
Solution
Accepted by topic author Mayoub

Hey mayoub,

 

The recommended method to do what you desire is to use a try, catch, block architecture.  In your try, you would be performing all of the functions that are typical like your GPIN read and write functions.  In the catch portion,  you would allow a variable to be set whenever an error occurred using the GPIBexception class members.  Then in the block section (optional) you could perform the remaing of the functions if any.

 

Please take a look at the SimpleReadWrite example in our .NET examples for GPIB by going to the example directory (C:\Documents and Settings\All Users\Documents\National Instruments\NI-488.2\Examples\DotNET3.5\SimpleReadWrite\vb).  This example uses the try, catch, block architecture.  Also if you look in the MeasurementStudio Help and search for "GPIBexception members" and click on the first item, you'll find the available objects you can call.  For your application, you'll probably want to use the ErrorCode property.  For this, your catch function should be something like:

 

Catch ex As GpibException

ex.ErrorCode

 

Let me know if you need more information.

David Pratt
Group Manager for Application Engineering Specialists | Automated Test
NIC
0 Kudos
Message 2 of 4
(4,012 Views)

Dear DavidP,

 

Thank you for the reply.

 

So, am I correct to assume then that all the GPIB functions in the .NET classes will throw an exception internally if a read/write error occurs?

 

That means no 'events' are raised when any such exception take splace?

 

Thank you
0 Kudos
Message 3 of 4
(3,997 Views)

Hey Mayoub,

 

According to the provided documentation in the MeasurementStudio help, anytime an error occurs due to invalid parameters, configuration states, or other factors with the 488.2 driver, this exception is thrown and the members are assigned with the available data about the error (i.e. error code, error count, and error message).

 

Every function call made will speak with the driver and the driver will work on the hardware layer to perform the operation.  If the driver encounters an error, this exception should be thrown.

Message Edited by David P. on 05-26-2009 01:05 PM
David Pratt
Group Manager for Application Engineering Specialists | Automated Test
NIC
0 Kudos
Message 4 of 4
(3,993 Views)