Switch Hardware and Software

cancel
Showing results for 
Search instead for 
Did you mean: 

How VISA keep track of handles/sessions return from calling multiple vxi plug&play functions

Hi there,

I'm trying to call multiple VXI plug&play driver functions within my CVI 8.5 program, but VISA DRM would return a single session after each call to an instrument.
It appears VISA closed the session/handle automatically whenever I invoke another driver function on a different insturment.

Here's an example:
1) ret = hp4156b_init("GPIB::17::INSTR",VI_TRUE,VI_TRUE, &vi);
    - VISA return handle from opening the above session
2) ret2 = hp81110a_init("GPIB::17::INSTR",VI_TRUE,VI_TRUE, &vi);
    - handle from 1) is close?

Not sure what's the best way to get around this since I'm using driver functions instead of VISA calls.

Appreciate any help.
Thanks,
-A
0 Kudos
Message 1 of 6
(7,154 Views)
Each time you open a session to an instrument driver, you will get unique session handle. Only explicit call to prefix_close(vi) will close the session handle.

If both instrument drivers are visa-based, then the sessions will be different. If the drivers are IVI-based, the sessions are IVI sessions, not VISA sessions. (But still different).

I hope this helps. Let me know if you see otherwise.


0 Kudos
Message 2 of 6
(7,153 Views)
Is that an snippet from your actual code or is that just something you typed here? For both of them, you are using the same resource (GPIB::17) and that of course, will not work.
0 Kudos
Message 3 of 6
(7,151 Views)
ops that was my typo, my code has different addresses for each instrument.

After I ran the above two inits for each instrument, NI spy is showing me an error 0xBFFF000E (given session or object reference is invalid) whenever I make function call to the first driver, so I was under the impression that the first handle was being closed even though it shows there are two seperate sessions.

Looks like I would have to keep track of session status (passing and checking error) on multipile instruments,  and doing this will take care of different function calls across various drivers.

Thanks and I'll look into what causes that 0xBFFF000E error in the first place.

I'll post again after I found out the origin of the error.

-A
0 Kudos
Message 4 of 6
(7,139 Views)
0xBFFF000E  happens when you make a VISA visa function call with a session that is invalid (has never been open or has been closed already).

First, make sure that you are not getting any errors from Initialize function, and that the vi is valid. Second, you can run  NI-SPY and spy on VISA calls to ensure that the viOpen call returns a valid session.

Let us know what you find.

best regards,
0 Kudos
Message 5 of 6
(7,132 Views)
Thanks for the info..

It turns out the error was due to not passing the vi session argument correctly in my code, rather than my assumption that the first session was being closed by the function calls to the 2nd driver.

spylog showed VI handle is 0x0 (since it wasn't passing from anywhere) rather than the one assigned by DRM previously.

I've fixed my code and VISA handles various instruments accordingly as long as I keep track of the various sessions in my code. 😛

Thank you again for the help.

-A
0 Kudos
Message 6 of 6
(7,085 Views)