Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

What's the difference between a vi session and an io session in an ivi driver?

I'm writing a new IVI driver for an instrument, using LabWindows/CVI. There are two "sessions" generated and used in the driver. Both are of type ViSession.
The vi session is generated by xxx_IviInit(...) in the xxx_InitWithOptions routine and returned to the user.
The io session is generated by viOpen (...) in the xxx_IviInit routine, and stored in the IVI_ATTR_IO_SESSION attribute.
 
What is the difference between the two, and when should I use which? If I understand it correctly, vi refers to a specific instance of the driver itself (the user may, for instance, the same driver twice, for two different instruments of the same type). io refers to the VISA communications session and a specific comm port, and is only used when actually communicating with the instrument. Correct? Does the io session have any attributes associated with it? e.g.
xxx_SetAttributeViBoolean (io, ChannelNamePtr, attribute name,  VI_FALSE);
 
Paul
0 Kudos
Message 1 of 3
(4,284 Views)
Howdy pblase,

ViSession is a unique logical identifier to a session. VISA uses this as a reference to the Resource Manager session. I verified this in the NI-VISA help at Start»National Instruments»VISA»Documentation»NI-VISA Help.

What function uses the IVI_ATTR_IO_SESSION that you ask about? Once you know its specific IVI function call, you can likely find documentation for it in the IVI Help at Start»National Instruments»IVI Driver Help.

Let me know!
Warm regards,

pBerg
0 Kudos
Message 2 of 3
(4,242 Views)

Hi Paul

 

the vi session is used by all the top level and Get/Set/Check attribute functions.

 

The io session is used by all VISA IO operations such as viPrintf, viRead etc.  You can get the io session from the vi session as shonw in the "Example" function below

 

ViStatus Example(ViSession vi)      

{

 ViStatus error = VI_SUCCESS; 

 

 checkErr( Ivi_LockSession (vi, VI_NULL));  
 if (!Ivi_Simulating(vi))                /* call only when locked */
     {                                                             
     ViSession   io = Ivi_IOSession(vi); /* call only when locked */     
                                                                   
     checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE));

     checkErr(viPrintf(io,  cCommandString));   //cCommandString is the string you wish to send to the instrument

 

     }
Error:
 Ivi_UnlockSession (vi, VI_NULL);

 return error;  

}

0 Kudos
Message 3 of 3
(4,007 Views)