• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.endpoint_type函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中usb.util.endpoint_type函数的典型用法代码示例。如果您正苦于以下问题:Python endpoint_type函数的具体用法?Python endpoint_type怎么用?Python endpoint_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了endpoint_type函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: write

    def write(self, endpoint, data, timeout = None):
        r"""Write data to the endpoint.

        This method is used to send data to the device. The endpoint parameter
        corresponds to the bEndpointAddress member whose endpoint you want to
        communicate with.

        The data parameter should be a sequence like type convertible to
        the array type (see array module).

        The timeout is specified in miliseconds.

        The method returns the number of bytes written.
        """
        backend = self._ctx.backend

        fn_map = {
                    util.ENDPOINT_TYPE_BULK:backend.bulk_write,
                    util.ENDPOINT_TYPE_INTR:backend.intr_write,
                    util.ENDPOINT_TYPE_ISO:backend.iso_write
                }

        intf, ep = self._ctx.setup_request(self, endpoint)
        fn = fn_map[util.endpoint_type(ep.bmAttributes)]

        return fn(
                self._ctx.handle,
                ep.bEndpointAddress,
                intf.bInterfaceNumber,
                _interop.as_array(data),
                self.__get_timeout(timeout)
            )
开发者ID:mull3rcw,项目名称:python_mt_unitTest,代码行数:32,代码来源:core.py


示例2: read

    def read(self, endpoint, size, timeout = None):
        r"""Read data from the endpoint.

        This method is used to receive data from the device. The endpoint parameter
        corresponds to the bEndpointAddress member whose endpoint you want to
        communicate with. The size parameters tells how many bytes you want to read.

        The timeout is specified in miliseconds.

        The method returns an array object with the data read.
        """
        backend = self._ctx.backend

        fn_map = {
                    util.ENDPOINT_TYPE_BULK:backend.bulk_read,
                    util.ENDPOINT_TYPE_INTR:backend.intr_read,
                    util.ENDPOINT_TYPE_ISO:backend.iso_read
                }

        intf, ep = self._ctx.setup_request(self, endpoint)
        fn = fn_map[util.endpoint_type(ep.bmAttributes)]

        return fn(
                self._ctx.handle,
                ep.bEndpointAddress,
                intf.bInterfaceNumber,
                size,
                self.__get_timeout(timeout)
            )
开发者ID:manasdas17,项目名称:pyusb,代码行数:29,代码来源:core.py


示例3: __init__

    def __init__(self, dev):
        """
        __init__(dev) -> None
        Initialize the DEV of CCID.
        device: usb.core.Device object.
        """

        cfg = dev.get_active_configuration()
        intf = find_descriptor(cfg, bInterfaceClass=CCID_CLASS,
                               bInterfaceSubClass=CCID_SUBCLASS,
                               bInterfaceProtocol=CCID_PROTOCOL_0)
        if intf is None:
            raise ValueError("Not a CCID device")

        claim_interface(dev, intf)

        for ep in intf:
            if endpoint_type(ep.bmAttributes) == ENDPOINT_TYPE_BULK and \
               endpoint_direction(ep.bEndpointAddress) == ENDPOINT_OUT:
               self.__bulkout = ep.bEndpointAddress
            if endpoint_type(ep.bmAttributes) == ENDPOINT_TYPE_BULK and \
               endpoint_direction(ep.bEndpointAddress) == ENDPOINT_IN:
               self.__bulkin = ep.bEndpointAddress

        assert len(intf.extra_descriptors) == 54
        assert intf.extra_descriptors[1] == 33

        if (intf.extra_descriptors[42] & 0x02):
            # Short APDU level exchange
            self.__use_APDU = True
        elif (intf.extra_descriptors[42] & 0x04):
            # Short and extended APDU level exchange
            self.__use_APDU = True
        elif (intf.extra_descriptors[42] & 0x01):
            # TPDU level exchange
            self.__use_APDU = False
        else:
            raise ValueError("Unknown exchange level")

        # Check other bits???
        #       intf.extra_descriptors[40]
        #       intf.extra_descriptors[41]

        self.__dev = dev
        self.__timeout = 10000
        self.__seq = 0
开发者ID:jj1bdx,项目名称:gnuk,代码行数:46,代码来源:card_reader.py


示例4: get_endpoint_type

 def get_endpoint_type(self, device, address, intf):
     intf = self.get_interface(device, intf)
     key = (address, intf.bInterfaceNumber, intf.bAlternateSetting)
     try:
         return self._ep_type_map[key]
     except KeyError:
         e = util.find_descriptor(intf, bEndpointAddress=address)
         etype = util.endpoint_type(e.bmAttributes)
         self._ep_type_map[key] = etype
         return etype
开发者ID:jaseg,项目名称:pyusb,代码行数:10,代码来源:core.py


示例5: read

    def read(self, endpoint, size_or_buffer, timeout = None):
        r"""Read data from the endpoint.

        This method is used to receive data from the device. The endpoint
        parameter corresponds to the bEndpointAddress member whose endpoint
        you want to communicate with. The size_or_buffer parameter either
        tells how many bytes you want to read or supplies the buffer to
        receive the data (it *must* be an object of the type array).

        The timeout is specified in miliseconds.

        If the size_or_buffer parameter is the number of bytes to read, the
        method returns an array object with the data read. If the
        size_or_buffer parameter is an array object, it returns the number
        of bytes actually read.
        """
        backend = self._ctx.backend

        fn_map = {
                    util.ENDPOINT_TYPE_BULK:backend.bulk_read,
                    util.ENDPOINT_TYPE_INTR:backend.intr_read,
                    util.ENDPOINT_TYPE_ISO:backend.iso_read
                }

        intf, ep = self._ctx.setup_request(self, endpoint)
        fn = fn_map[util.endpoint_type(ep.bmAttributes)]

        if isinstance(size_or_buffer, array.array):
            buff = size_or_buffer
        else: # here we consider it is a integer
            buff = util.create_buffer(size_or_buffer)

        ret = fn(
                self._ctx.handle,
                ep.bEndpointAddress,
                intf.bInterfaceNumber,
                buff,
                self.__get_timeout(timeout),
                self._stopped)

        if isinstance(size_or_buffer, array.array):
            return ret
        elif ret != len(buff) * buff.itemsize:
            return buff[:ret]
        else:
            return buff
开发者ID:AeroEng43,项目名称:pyusb,代码行数:46,代码来源:core.py


示例6: __setup_device

 def __setup_device(self, dev):
     '''Get endpoints for a device. True on success.'''
     self.__inep = None
     self.__outep = None
     self.__intep = None
     self.__cfg = None
     self.__dev = None
     self.__intf = None
     # Attempt to find the USB in, out and interrupt endpoints for a PTP
     # interface.
     for cfg in dev:
         for intf in cfg:
             if intf.bInterfaceClass == PTP_USB_CLASS:
                 for ep in intf:
                     ep_type = endpoint_type(ep.bmAttributes)
                     ep_dir = endpoint_direction(ep.bEndpointAddress)
                     if ep_type == ENDPOINT_TYPE_BULK:
                         if ep_dir == ENDPOINT_IN:
                             self.__inep = ep
                         elif ep_dir == ENDPOINT_OUT:
                             self.__outep = ep
                     elif ((ep_type == ENDPOINT_TYPE_INTR) and
                             (ep_dir == ENDPOINT_IN)):
                         self.__intep = ep
             if not (self.__inep and self.__outep and self.__intep):
                 self.__inep = None
                 self.__outep = None
                 self.__intep = None
             else:
                 logger.debug('Found {}'.format(repr(self.__inep)))
                 logger.debug('Found {}'.format(repr(self.__outep)))
                 logger.debug('Found {}'.format(repr(self.__intep)))
                 self.__cfg = cfg
                 self.__dev = dev
                 self.__intf = intf
                 return True
     return False
开发者ID:Parrot-Developers,项目名称:sequoia-ptpy,代码行数:37,代码来源:usb.py


示例7: __init__

 def __init__(self, ep):
     self.address = ep.bEndpointAddress
     self.interval = ep.bInterval
     self.maxPacketSize = ep.wMaxPacketSize
     self.type = util.endpoint_type(ep.bmAttributes)
开发者ID:RoboticMayhem,项目名称:pyusb,代码行数:5,代码来源:legacy.py



注:本文中的usb.util.endpoint_type函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.find_descriptor函数代码示例发布时间:2022-05-27
下一篇:
Python _interop.as_array函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap