HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/usb/backend/__pycache__/__init__.cpython-39.pyc
a

j��Y�>�@s:dZddlmZdZgd�Zdd�ZGdd�dej�ZdS)	a=usb.backend - Backend interface.

This module exports:

IBackend - backend interface.

Backends are Python objects which implement the IBackend interface.
The easiest way to do so is inherinting from IBackend.

PyUSB already provides backends for libusb versions 0.1 and 1.0,
and OpenUSB library. Backends modules included with PyUSB are required to
export the get_backend() function, which returns an instance of a backend
object. You can provide your own customized backend if you
want to. Below you find a skeleton of a backend implementation module:

import usb.backend

class MyBackend(usb.backend.IBackend):
    pass

def get_backend():
    return MyBackend()

You can use your customized backend by passing it as the backend parameter of the
usb.core.find() function. For example:

import custom_backend
import usb.core

myidVendor = 0xfffe
myidProduct = 0x0001

mybackend = custom_backend.get_backend()

dev = usb.core.find(backend = mybackend, idProduct=myidProduct,
                    idVendor=myidVendor)

For custom backends, you are not required to supply the get_backend() function,
since the application code will instantiate the backend.

If you do not provide a backend to the find() function, it will use one of the
defaults backend according to its internal rules. For details, consult the
find() function documentation.
�NzWander Lairson Costa)�IBackendZlibusb01Zlibusb10ZopenusbcCst|j��dS)N)�NotImplementedError�__name__)�func�r�8/usr/lib/python3.9/site-packages/usb/backend/__init__.py�_not_implementedPsrc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2S)3raBackend interface.

    IBackend is the basic interface for backend implementations. By default,
    the methods of the interface raise a NotImplementedError exception. A
    backend implementation should replace the methods to provide the funcionality
    necessary.

    As Python is a dynamic typed language, you are not obligated to inherit from
    IBackend: everything that behaves like an IBackend is an IBackend. But you
    are strongly recommended to do so, inheriting from IBackend provides consistent
    default behavior.
    cCst|j�dS)aThis function is required to return an iterable object which
        yields an implementation defined device identification for each
        USB device found in the system.

        The device identification object is used as argument to other methods
        of the interface.
        N)r�enumerate_devices)�selfrrrr	aszIBackend.enumerate_devicescCst|j�dS)akReturn the device descriptor of the given device.

        The object returned is required to have all the Device Descriptor
        fields accessible as member variables. They must be convertible (but
        not required to be equal) to the int type.

        dev is an object yielded by the iterator returned by the enumerate_devices()
        method.
        N)r�get_device_descriptor�r
�devrrrrks
zIBackend.get_device_descriptorcCst|j�dS)aEReturn a configuration descriptor of the given device.

        The object returned is required to have all the Configuration Descriptor
        fields acessible as member variables. They must be convertible (but
        not required to be equal) to the int type.

        The dev parameter is the device identification object.
        config is the logical index of the configuration (not the bConfigurationValue
        field).  By "logical index" we mean the relative order of the configurations
        returned by the peripheral as a result of GET_DESCRIPTOR request.
        N)r�get_configuration_descriptor)r
r
�configrrrrwsz%IBackend.get_configuration_descriptorcCst|j�dS)a�Return an interface descriptor of the given device.

        The object returned is required to have all the Interface Descriptor
        fields accessible as member variables. They must be convertible (but
        not required to be equal) to the int type.

        The dev parameter is the device identification object.
        The intf parameter is the interface logical index (not the bInterfaceNumber field)
        and alt is the alternate setting logical index (not the bAlternateSetting value).
        Not every interface has more than one alternate setting.  In this case, the alt
        parameter should be zero. config is the configuration logical index (not the
        bConfigurationValue field).
        N)r�get_interface_descriptor)r
r
�intf�altrrrrr�sz!IBackend.get_interface_descriptorcCst|j�dS)a�Return an endpoint descriptor of the given device.

        The object returned is required to have all the Endpoint Descriptor
        fields acessible as member variables. They must be convertible (but
        not required to be equal) to the int type.

        The ep parameter is the endpoint logical index (not the bEndpointAddress
        field) of the endpoint descriptor desired. dev, intf, alt and config are the same
        values already described in the get_interface_descriptor() method.
        N)r�get_endpoint_descriptor)r
r
�eprrrrrrr�sz IBackend.get_endpoint_descriptorcCst|j�dS)a�Open the device for data exchange.

        This method opens the device identified by the dev parameter for communication.
        This method must be called before calling any communication related method, such
        as transfer methods.

        It returns a handle identifying the communication instance. This handle must be
        passed to the communication methods.
        N)r�open_devicerrrrr�s
zIBackend.open_devicecCst|j�dS)z�Close the device handle.

        This method closes the device communication channel and releases any
        system resources related to it.
        N)r�close_device�r
�
dev_handlerrrr�szIBackend.close_devicecCst|j�dS)aNSet the active device configuration.

        This method should be called to set the active configuration
        of the device. The dev_handle parameter is the value returned
        by the open_device() method and the config_value parameter is the
        bConfigurationValue field of the related configuration descriptor.
        N)r�set_configuration)r
rZconfig_valuerrrr�szIBackend.set_configurationcCst|j�dS)ajGet the current active device configuration.

        This method returns the bConfigurationValue of the currently
        active configuration. Depending on the backend and the OS,
        either a cached value may be returned or a control request may
        be issued. The dev_handle parameter is the value returned by
        the open_device method.
        N)r�get_configurationrrrrr�s	zIBackend.get_configurationcCst|j�dS)a\Set the interface alternate setting.

        This method should only be called when the interface has more than
        one alternate setting. The dev_handle is the value returned by the
        open_device() method. intf and altsetting are respectivelly the
        bInterfaceNumber and bAlternateSetting fields of the related interface.
        N)r�set_interface_altsetting)r
rrZ
altsettingrrrr�sz!IBackend.set_interface_altsettingcCst|j�dS)a�Claim the given interface.

        Interface claiming is not related to USB spec itself, but it is
        generally an necessary call of the USB libraries. It requests exclusive
        access to the interface on the system. This method must be called
        before using one of the transfer methods.

        dev_handle is the value returned by the open_device() method and
        intf is the bInterfaceNumber field of the desired interface.
        N)r�claim_interface�r
rrrrrr�szIBackend.claim_interfacecCst|j�dS)z�Release the claimed interface.

        dev_handle and intf are the same parameters of the claim_interface
        method.
        N)r�release_interfacerrrrr�szIBackend.release_interfacecCst|j�dS)aPerform a bulk write.

        dev_handle is the value returned by the open_device() method.
        The ep parameter is the bEndpointAddress field whose endpoint
        the data will be sent to. intf is the bInterfaceNumber field
        of the interface containing the endpoint. The data parameter
        is the data to be sent. It must be an instance of the array.array
        class. The timeout parameter specifies a time limit to the operation
        in miliseconds.

        The method returns the number of bytes written.
        N)r�
bulk_write�r
rrr�data�timeoutrrrr�s
zIBackend.bulk_writecCst|j�dS)aEPerform a bulk read.

        dev_handle is the value returned by the open_device() method.
        The ep parameter is the bEndpointAddress field whose endpoint
        the data will be received from. intf is the bInterfaceNumber field
        of the interface containing the endpoint. The buff parameter
        is the buffer to receive the data read, the length of the buffer
        tells how many bytes should be read. The timeout parameter
        specifies a time limit to the operation in miliseconds.

        The method returns the number of bytes actually read.
        N)r�	bulk_read)r
rrrZbuffr"rrrr#�s
zIBackend.bulk_readcCst|j�dS)a#Perform an interrupt write.

        dev_handle is the value returned by the open_device() method.
        The ep parameter is the bEndpointAddress field whose endpoint
        the data will be sent to. intf is the bInterfaceNumber field
        of the interface containing the endpoint. The data parameter
        is the data to be sent. It must be an instance of the array.array
        class. The timeout parameter specifies a time limit to the operation
        in miliseconds.

        The method returns the number of bytes written.
        N)r�
intr_writer rrrr$s
zIBackend.intr_writecCst|j�dS)aKPerform an interrut read.

        dev_handle is the value returned by the open_device() method.
        The ep parameter is the bEndpointAddress field whose endpoint
        the data will be received from. intf is the bInterfaceNumber field
        of the interface containing the endpoint. The buff parameter
        is the buffer to receive the data read, the length of the buffer
        tells how many bytes should be read.  The timeout parameter
        specifies a time limit to the operation in miliseconds.

        The method returns the number of bytes actually read.
        N)r�	intr_read�r
rrr�sizer"rrrr%s
zIBackend.intr_readcCst|j�dS)a%Perform an isochronous write.

        dev_handle is the value returned by the open_device() method.
        The ep parameter is the bEndpointAddress field whose endpoint
        the data will be sent to. intf is the bInterfaceNumber field
        of the interface containing the endpoint. The data parameter
        is the data to be sent. It must be an instance of the array.array
        class. The timeout parameter specifies a time limit to the operation
        in miliseconds.

        The method returns the number of bytes written.
        N)r�	iso_writer rrrr(&s
zIBackend.iso_writecCst|j�dS)aIPerform an isochronous read.

        dev_handle is the value returned by the open_device() method.
        The ep parameter is the bEndpointAddress field whose endpoint
        the data will be received from. intf is the bInterfaceNumber field
        of the interface containing the endpoint. The buff parameter
        is buffer to receive the data read, the length of the buffer tells
        how many bytes should be read. The timeout parameter specifies
        a time limit to the operation in miliseconds.

        The method returns the number of bytes actually read.
        N)r�iso_readr&rrrr)5s
zIBackend.iso_readcCst|j�dS)a]Perform a control transfer on the endpoint 0.

        The direction of the transfer is inferred from the bmRequestType
        field of the setup packet.

        dev_handle is the value returned by the open_device() method.
        bmRequestType, bRequest, wValue and wIndex are the same fields
        of the setup packet. data is an array object, for OUT requests
        it contains the bytes to transmit in the data stage and for
        IN requests it is the buffer to hold the data read. The number
        of bytes requested to transmit or receive is equal to the length
        of the array times the data.itemsize field. The timeout parameter
        specifies a time limit to the operation in miliseconds.

        Return the number of bytes written (for OUT transfers) or the data
        read (for IN transfers), as an array.array object.
        N)r�
ctrl_transfer)r
rZ
bmRequestTypeZbRequestZwValueZwIndexr!r"rrrr*DszIBackend.ctrl_transfercCst|j�dS)z0Clear the halt/stall condition for the endpoint.N)r�
clear_halt)r
rrrrrr+_szIBackend.clear_haltcCst|j�dS)zReset the device.N)r�reset_devicerrrrr,cszIBackend.reset_devicecCst|j�dS)z�Determine if a kernel driver is active on an interface.

        If a kernel driver is active, you cannot claim the interface,
        and the backend will be unable to perform I/O.
        N)r�is_kernel_driver_activerrrrr-gsz IBackend.is_kernel_driver_activecCst|j�dS)z�Detach a kernel driver from an interface.

        If successful, you will then be able to claim the interface
        and perform I/O.
        N)r�detach_kernel_driverrrrrr.oszIBackend.detach_kernel_drivercCst|j�dS)zkRe-attach an interface's kernel driver, which was previously
        detached using detach_kernel_driver().N)r�attach_kernel_driverrrrrr/wszIBackend.attach_kernel_driverN)r�
__module__�__qualname__�__doc__r	rrrrrrrrrrrrr#r$r%r(r)r*r+r,r-r.r/rrrrrSs2





r)r2Zusb._objfinalizerZ
_objfinalizer�
__author__�__all__rZAutoFinalizedObjectrrrrr�<module>s
-