pyusb_bt_sockets.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:pybluetooth 作者: pebble 项目源码 文件源码
def recv(self, x=512, timeout_secs=10.0):
        # FIXME: Don't know how many bytes to expect here,
        # using 512 bytes -- will this fly if there's another event right
        # after it? Or is each event guaranteed to be put in a USB packet of
        # its own?
        try:
            data_array = self.pyusb_dev.read(
                USB_ENDPOINT_HCI_EVT, 512, int(timeout_secs * 1000.0))
        except usb.core.USBError as e:
            if e.errno == errno.ETIMEDOUT:
                return None
            else:
                raise e

        data = ''.join([chr(c) for c in data_array])  # Ugh.. array return val
        data = "\4" + data  # Prepend H4 'Event' packet indicator
        scapy_packet = HCI_Hdr(data)
        LOG.debug("recv %s" % scapy_packet.lastlayer().summary())
        LOG.debug("recv bytes: " + binascii.hexlify(data))
        return scapy_packet
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号