Discussion:
How VISA keep track of handles/sessions return from calling multiple vxi plug&play functions
(too old to reply)
Alex.F
2008-07-25 01:10:08 UTC
Permalink
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
Sran Zirojevi
2008-07-25 02:10:17 UTC
Permalink
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.
Dennis Knutson
2008-07-25 03:40:10 UTC
Permalink
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.
Alex.F
2008-07-25 18:10:10 UTC
Permalink
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
Sran Zirojevi
2008-07-25 18:40:13 UTC
Permalink
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,
Alex.F
2008-07-30 17:40:12 UTC
Permalink
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. :P

Thank you again for the help.

-A

Loading...