Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从Nike+;Debian上带有PyUSB的Sportband_Python_Reverse Engineering_Pyusb - Fatal编程技术网

Python 从Nike+;Debian上带有PyUSB的Sportband

Python 从Nike+;Debian上带有PyUSB的Sportband,python,reverse-engineering,pyusb,Python,Reverse Engineering,Pyusb,我有一个旧的Nike+Sportband()。Nike已决定取消对该产品的支持。我想提取数据,然后解码。有人用C写了一段代码,可以工作()。我想在Python中实现它,所以我决定使用PyUSB 代码: import sys import usb.core import usb.util VENDOR_ID = 0x11ac PRODUCT_ID = 0x4269 device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)

我有一个旧的Nike+Sportband()。Nike已决定取消对该产品的支持。我想提取数据,然后解码。有人用C写了一段代码,可以工作()。我想在Python中实现它,所以我决定使用PyUSB

代码

import sys
import usb.core
import usb.util

VENDOR_ID = 0x11ac
PRODUCT_ID = 0x4269

device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)

print device

if device is None:
    sys.exit("Device not found.")

if device.is_kernel_driver_active(0):
    try:
        device.detach_kernel_driver(0)
        print('Kernel driver detatched.\n')
    except usb.core.USBError as e:
        sys.exit("Could not detatch kernel driver: %s" % str(e))

try:
    device.set_configuration()
    #device.reset()
    print('Configuration Ok')
except usb.core.USBError as e:
    sys.exit("Could not set configuration: %s" % str(e))


# read a data packet
data = device.read(0x81,8,10000)

print data
我总是会遇到这样的错误:

usb.core.USBError: [Errno 110] Operation timed out

有什么建议吗?

粗略地看一下C代码,它会先向设备发送一条控制消息,“询问”设备是否有特定类型的响应(
usb\u control\u msg
calls),但看起来您在这里并没有这样做。听起来是个有趣的项目。@jedwards是的,也许对我来说太难了。我还没有尝试用PyUSB发送消息,而且(如果我理解正确的话)我需要一个OUT端点,但我只找到了IN端点。但是谢谢你,我可以试着发一条信息,然后试着读它。