Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.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 3.x 如何使用pyusb访问USB设备数据?_Python 3.x_Usb_Sensors_Pyusb - Fatal编程技术网

Python 3.x 如何使用pyusb访问USB设备数据?

Python 3.x 如何使用pyusb访问USB设备数据?,python-3.x,usb,sensors,pyusb,Python 3.x,Usb,Sensors,Pyusb,我正在尝试从USB传感器类型的设备传输数据。我尝试了以下代码: import usb.core device = usb.find(idVendor=0x1234, idProduct=0x4321) print(device.read(0x81, 7)) 我得到的结果是: array('B', [1, 96]) 我真的不确定如何使用它并获得有意义的传感器数据。谁能给我指一下正确的方向吗 以下是我运行print(device)时得到的输出信息: 没有通用的USB传感器协议。传感器很可能实现自

我正在尝试从USB传感器类型的设备传输数据。我尝试了以下代码:

import usb.core
device = usb.find(idVendor=0x1234, idProduct=0x4321)
print(device.read(0x81, 7))
我得到的结果是:

array('B', [1, 96])
我真的不确定如何使用它并获得有意义的传感器数据。谁能给我指一下正确的方向吗

以下是我运行
print(device)
时得到的输出信息:


没有通用的USB传感器协议。传感器很可能实现自定义协议。因此,您需要查找有关该协议的文档。根据问题中给出的信息,无法帮助您。谢谢您的评论。我已经添加了更多信息,但我不确定这有多有用。它没有多大帮助。它只是表明,除了强制控制端点外,传感器还有一个进出体积点。它还确认它没有实现任何USB类(如大容量存储或CDC)。好吧,那么你希望在某个地方有一个可供访问参考的制造协议?几乎没有任何设备有公共USB协议。因此,您通常必须亲自扮演侦探和反向工程的角色,通过查看设备通信如何与制造商的驱动程序协同工作,例如使用Wireshark。
DEVICE ID 1234:4321 on Bus 001 Address 013 =================
 bLength                :   0x12 (18 bytes)
 bDescriptorType        :    0x1 Device
 bcdUSB                 :  0x200 USB 2.0
 bDeviceClass           :    0x0 Specified at interface
 bDeviceSubClass        :    0x0
 bDeviceProtocol        :    0x0
 bMaxPacketSize0        :    0x8 (8 bytes)
 idVendor               : 0x0403
 idProduct              : 0xc2b0
 bcdDevice              : 0x1000 Device 16.0
 iManufacturer          :    0x1 XXXXXXXXXXXX
 iProduct               :    0x2 XXXX
 iSerialNumber          :    0x0 
 bNumConfigurations     :    0x1
  CONFIGURATION 1: 500 mA ==================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0x20 (32 bytes)
   bNumInterfaces       :    0x1
   bConfigurationValue  :    0x1
   iConfiguration       :    0x0 
   bmAttributes         :   0x80 Bus Powered
   bMaxPower            :   0xfa (500 mA)
    INTERFACE 0: Vendor Specific ===========================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :   0xff Vendor Specific
     bInterfaceSubClass :   0xff
     bInterfaceProtocol :   0xff
     iInterface         :    0x2 XXXX
      ENDPOINT 0x81: Bulk IN ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0
      ENDPOINT 0x2: Bulk OUT ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x2 OUT
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0