Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

C# GPIB Interface Clear Error

I have a program in C# that instantiates a GPIB class that contains a Board object and Devices.  The first time through I am able to process the InterfaceClear method from the Board object, but if later on I want to initialize the objects by sending another InterfaceClear command.  I keep getting an error about the input handle is invalid or out of range.  This only happens the second time I call this method.  I don't see how I can invoke the Board object if it is not available on the thread.  Are Reset or ResetSystem more preferred methods?  I would like to initialize the board and devices after a period of idle time just to ensure there are no problems.  I can mask the problem by not sending an InterfaceClear command after the initial call, but I would prefer to be able to do that.  Any help is greatly appreciated.

 

Mike

0 Kudos
Message 1 of 5
(6,597 Views)

Hi msouza,

 

I recommend going through the examples provided for Text-based Code that come included with the drivers.

I Hope this is helpful

 
 
Luis S
Application Engineer
National Instruments
0 Kudos
Message 2 of 5
(6,579 Views)

Thanks for the feedback.  I've gone through all of the examples initially when I was developing the code.  This is a problem that is not happening consistently.  There are no examples on what I need assistance with.  I have setup my code almost identical to the ways they are setup in the examples but yet I still have an intermittent issue.  I have error trapped the issue and deal with it, but have not figured out why and how to properly handle the issue.

 

Mike

0 Kudos
Message 3 of 5
(6,568 Views)

msouza,

 

Thanks for posting, I wanted to clarify a few minor details. When you first use 'Interface Clear' are you then able to send subsequent commands to the board successfully? If not then the issue is most likely that the 'Interface Clear' command is clearing the reference to the board as well, and a more appropriate command to set your board to an initial state should be used. Or if you are simply trying to clear the GPIB communication buffer a specific command can be issued for that as well. If you are able to call the 'Interface Clear' command and then still communicate with the board successfully until the next 'Interface Clear' is sent then please let me know and I will do some further research. Also, is there an associated error number that you can provide?

Applications/Systems/Test
National Instruments | AWR Group
0 Kudos
Message 4 of 5
(6,552 Views)

Well, I have not had any further issues since the posting.  I have added in some exception handling to capture the scenario where the command to the Board object is invalid.  After an initial instantiation of the Board object, the only other times we use the Board object is to perform an Interface Clear and to set the timeout for the board for specific devices.  Other than that, we use Device objects to communicate to the devices.  Those work without any issues all the time. 

 

The Board object seems to be a little more intermittent.  When it happens though, it can happen a LOT.  I will write back if I get any better debugging information from the new exception handling. 

 

Mike

0 Kudos
Message 5 of 5
(6,543 Views)