LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the range for valid Unique Logical Ids from viOpen()?

Is there a valid range for the Unique Logical Identifier set in a viOpen() or are there illegal values I can test for (I.E. -1 or some other magic number or define)?
0 Kudos
Message 1 of 9
(4,590 Views)
Hello,

This is something that could be checked into, but your question begs another; are you having a problem with viOpen()? The ViStatus return value will indicate errors for you when the function returns, should they occur during execution. The return value either indicates completion or an error; here are some examples: (these have been take from the NI-VISA Help; see Start -> Programs -> National Instruments -> VISA -> NI-VISA Help)


Completion Codes include:

- VI_SUCCESS Session opened successfully.

- VI_SUCCESS_DEV_NPRESENT Session opened successfully, but the device at the specified address is not responding.

- VI_WARN_CONFIG_NLOADED The specified configuration either does not exist or could not be loaded; using VISA-specified defaults.


Error Codes include:

- VI_ERROR_INV_OBJECT The given session reference is invalid.

- VI_ERROR_NSUP_OPER The given sesn does not support this operation. This operation is supported only by a Resource Manager session.

- VI_ERROR_INV_RSRC_NAME Invalid resource reference specified. Parsing error.

- VI_ERROR_INV_ACC_MODE Invalid access mode.

- VI_ERROR_RSRC_NFOUND Insufficient location information or resource not present in the system.

- VI_ERROR_ALLOC Insufficient system resources to open a session.

- VI_ERROR_RSRC_BUSY The resource is valid, but VISA cannot currently access it.

- VI_ERROR_RSRC_LOCKED Specified type of lock cannot be obtained because the resource is already locked with a lock type incompatible with the lock requested.

- VI_ERROR_TMO A session to the resource could not be obtained within the specified openTimeout period.

- VI_ERROR_LIBRARY_NFOUND A code library required by VISA could not be located or loaded.

- VI_ERROR_INTF_NUM_NCONFIG The interface type is valid, but the specified interface number is not configured.

- VI_ERROR_MACHINE_NAVAIL The remote machine does not exist or is not accepting any connections. If the NI-VISA server is installed and running on the remote machine, it may have an incompatible version or may be listening on a different port.

- VI_ERROR_NPERMISSION Access to the remote machine is denied.


You can find more information in the NI-VISA Help document (Start -> Programs -> National Instruments -> VISA -> NI-VISA Help).


Definitely repost if you feel that more specific information about a session's unique logical identifier reference would be helpful to know!

Thank you,

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 9
(4,570 Views)
I'm not really having a problem with viOpen(). I read the NI-VISA documentation and see the different error codes that are returned.

Suppose I try to open a device that does not exist. I'll get an error returned, but I would need to keep that error value in order to know that the handle I intended to use for that device is not valid. I'd rather store the handle value and compare it to some range to know what makes it unique. For example, in Java, there is a concept called Not-A-Number. In C, a handle value of 0 might be good, I'd have to save another flag that said the value wasn't valid. So I was curious what makes the value Unique and if I can test it against a range or a particular value.
0 Kudos
Message 3 of 9
(4,559 Views)
Hello,

I understand your question. It may very well be, and I suppose almost certainly is, true that the value assigned as the session is contingent upon the success of the open operation; I don't happen to know the range associated with success or certain failures, however, indication of the success of the operation is really supposed to be observed in the true return value of the function, the viStatus. I don't think you are restricted from a development standpoint by using this value, in fact, it gives you information about why a failure occurs if indeed one does! I will look into this to see about valid ranges (if this information is available), however, I would recommend using the intended return value of viStatus as the mechanism for monitoring failure vs success of the open operation (or any other for that matter). Have you encountered a case where you cannot use the returned viStatus to achieve your desired functionality?

Definitely let me know if such a case exists, and I'll follow up with any information I find for you!

Best Regards,

Jassem
Best,
JLS
Sixclear
0 Kudos
Message 4 of 9
(4,548 Views)
Hi,

The case where I wanted to use the value of the handle is really artificial. I've wrapped the VISA calls so that I can simulate all my devices. Instead of having a handle value managed by your VISA library, I am making my own which conveniently is an index into a C array, 1 index per device/handle.

I suppose all values could be legal, I was just hoping that negative values were illegal, it would just simplify some of my error handling. It's not a big deal. I hoped it was an easy question that I overlooked in the literature, but it appears not.

Thanks again.
0 Kudos
Message 5 of 9
(4,547 Views)
Hello,

I have inquired about the range or set of valid and/or invalid values; I'll repost as soon as I have anything! But, it's good to know that this won't be a big pain if it turns out that there isn't a nice set or range of values indicating invalid.

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 6 of 9
(4,532 Views)
Hello again,

I was able to get information regarding the session reference. First, it appears not to be a good thing to use to determine the success of an open operation because the open operation is, in general, a multistep process. One step is to obtain a handle, however, obtaining a handle does not mean the open was successful! Thus, it would be very deceiving to monitor this alone! Further, the value returned for the session is an unsigned integer, so monitoring for negatives will not work. Finally, the manner in which the handle is acquired, and the values returned, depends on the operating system. Thus, in the event you were to port your code to other machines, even attempting to use an error handling scheme dependent upon this handle would be detrimental!

Ok, if you have any other questions feel free to repost!

Thanks for the great question!

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 7 of 9
(4,526 Views)
Thanks for researching this subject and providing a sufficient explanation for why it's not a good idea to rely on the handle value itself. I'm content with ending the thread. Thanks again.
0 Kudos
Message 8 of 9
(4,514 Views)
No problem,

If you have any other questions feel free to repost!

Best Regards,

Jassem
Best,
JLS
Sixclear
0 Kudos
Message 9 of 9
(4,490 Views)