code: def open(library, session, resource_name,
           access_mode=constants.AccessModes.no_lock, open_timeout=constants.VI_TMO_IMMEDIATE):
      
      try:
          open_timeout = int(open_timeout)
      except ValueError:
          raise ValueError('open_timeout (%r) must be an integer (or compatible type)' % open_timeout)
      out_session = ViSession()
  
      # [ViSession, ViRsrc, ViAccessMode, ViUInt32, ViPSession]
      # ViRsrc converts from (str, unicode, bytes) to bytes
      ret = library.viOpen(session, resource_name, access_mode, open_timeout, byref(out_session))
      return out_session.value, ret
docs: Opens a session to the specified resource.
  
      Corresponds to viOpen function of the VISA library.
  
      :param library: the visa library wrapped by ctypes.
      :param session: Resource Manager session (should always be a session returned from open_default_resource_manager()).
      :param resource_name: Unique symbolic name of a resource.
      :param access_mode: Specifies the mode by which the resource is to be accessed. (constants.AccessModes)
      :param open_timeout: Specifies the maximum time period (in milliseconds) that this operation waits
                           before returning an error.
      :return: Unique logical identifier reference to a session, return value of the library call.
      :rtype: session, :class:`pyvisa.constants.StatusCode`