def usb_control_out(library, session, request_type_bitmap_field, request_id,
    request_value, index, data=''):
    """Performs a USB control pipe transfer to the device.

    Corresponds to viUsbControlOut function of the VISA library.

    :param library: the visa library wrapped by ctypes.
    :param session: Unique logical identifier to a session.
    :param request_type_bitmap_field: bmRequestType parameter of the setup stage of a USB control transfer.
    :param request_id: bRequest parameter of the setup stage of a USB control transfer.
    :param request_value: wValue parameter of the setup stage of a USB control transfer.
    :param index: wIndex parameter of the setup stage of a USB control transfer.
                  This is usually the index of the interface or endpoint.
    :param data: The data buffer that sends the data in the optional data stage of the control transfer.
    :return: return value of the library call.
    :rtype: :class:`pyvisa.constants.StatusCode`
    """
    length = len(data)
    return library.viUsbControlOut(session, request_type_bitmap_field,
        request_id, request_value, index, length, data)
