Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting power off of remote ENET/100

Environment: Max OS X 10.4.10, simple working GPIB application written in C & Objective-C using Xcode, low data rates, communication only in response to user clicking on an on-screen button.

One problem left to solve. If the program is running when the power is turned off on the ENET/100 that it communicates with, the program will hang. This is inelegant. How do I detect that the ENET/100 is inaccessible? Other kinds of errors seem to handled successfully.
0 Kudos
Message 1 of 16
(5,310 Views)

bicycle,

Thank you for contacting National Instruments.

One option that I think you should try, was found in a previous discussion forum thread.

You could detect if an EDVR (Driver Error) error occured. EDVR is returned when GPIB hardware is not configured properly, or the interface name or device name passed to the ibfind function is incorrect. The error returned by the function is stored in ibcnt. You could use this error as a signal that the NI GPIB-ENET/100 is turned off. Any EDVR means some fatal error occur, so you can assume you need to reestablish communication. It does not matter if the NI GPIB-ENET/100 is off or the network is failing, in either case the EDVR will indicate an error.

You can then call a function that handles this situation by calling ibonl (device[index], 0); //This removes the entry from a table in memory maintained by the driver. to close the handle and then try to reestablish communication using the ibdev function.

For more information concerning the specific driver error, you can reference GPIB Error Codes and Common Solutions.

Please let me know if this was able to answer the question you had, if not please let me know.

Thank you very much.

 

 
Sarah S.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 16
(5,285 Views)
The suggestion seems a bit confused: "the error code returned by the function is store in ibcnt". Not according to my reading of the documentation.

The most non-invasive command I could find to probe the status of the remote interface is:
ibwait(BoardIndex,0);
which should return right away with an updated ibsta variable.

This also hangs as soon as the interface power is off. Looks to me like someone dropped the ball in allowing for this situation.
0 Kudos
Message 3 of 16
(5,254 Views)

bicycle,

Looking into the NI-488.2 Function Reference Manual for Windows, I was able to find the following information.

int ibcmda (int ud, void *cmdbuf, long count)

Possible Error that you are able to get: ENOL (2) No Listeners are on the GPIB.

ENOL usually occurs when a write operation is attempted with no Listeners addressed. For a device write, ENOL indicates that the GPIB address configured for that device in the software does not match the GPIB address of any device connected to the bus, that the GPIB cable is not connected to the device, or that the device is not powered on.

Please give this command a try and let me know if this is able to work without hanging.

Thank you very much.

 
Sarah S.
Applications Engineering
National Instruments
0 Kudos
Message 4 of 16
(5,231 Views)
I tried your suggestion. Didn't work. Details:

Added two buttons to the user interface. The first one issues a ibcmda, the second one cancels it.

While the program is running normally I can click on the first one (creates an asynchronous call), then the second one (cancels the call and resynchronizes the application with the driver), then continue normal usage of the program.

If the ENET is turned off, The program hangs after the async button is clicked. Thus I never get the option of checking ibsta or other error information.

- (IBAction)asyncButton:(id)sender {
char command[] = "\x3F";
ibcmda(BoardIndex, command,1);
}

- (IBAction)syncButton:(id)sender {
ibstop(BoardIndex);
}
0 Kudos
Message 5 of 16
(5,224 Views)
bicycle,

Are you able to ping the NI GPIB-ENET/100 device? If so, can this be used to determine if the device is on or off, before running the code.

Thanks
Sarah S.
Applications Engineering
National Instruments
0 Kudos
Message 6 of 16
(5,214 Views)
Yes, BUT
Do you have any sample code which will allow us to resolve gpib addresses to IP addresses? I need a hypothetical function IP(BoardIndex) which will give the IP address corresponding to the GPIB board of interest.

This mapping is arbitrary and can be user-configured. Thus I cannot hard-wire it into the code.
0 Kudos
Message 7 of 16
(5,208 Views)

bicycle,

I have found a developer zone tutorial: Developing Distributed GPIB Test Systems Using the NI GPIB-ENET and Existing Ethernet Networks, that includes example code.

Please look through this tutorial and let me know if these example are able to help you out. If it is not, I will continue to look into this issue.

Thank you very much.

 
Sarah S.
Applications Engineering
National Instruments
0 Kudos
Message 8 of 16
(5,194 Views)
Thanks. I do not see anything in the sample code that is relevant to solving my application problem.
0 Kudos
Message 9 of 16
(5,153 Views)
Have you tried use the function ibfind (GPIB0)?  If the GPIB-ENET/100 is GPIB0 an error should be returned.  If the error is EDVR, it will show that the GPIB-ENET/100 is powered down.


Message Edited by Sarah_S on 11-12-2007 01:23 PM
Sarah S.
Applications Engineering
National Instruments
0 Kudos
Message 10 of 16
(5,126 Views)