PyUSB-Dev-Env on Mac with libusb
2016-06-02 本文已影响544人
Mintisan
usb logo
Dependencies
Procedure
- Find VendorID & ProductID on Mac
system_profiler SPUSBDataType
or u may prefer lsusb, if u come from Linux-like system:
brew update && brew tap jlhonora/lsusb && brew install lsusb
lsusb
brew install libusb-compat libusb
or you will encounter issue below when u use pyusb
Traceback (most recent call last):
File "<pyshell#83>", line 1, in <module>
usb.core.find()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/usb/core.py", line 1199, in find
raise ValueError('No backend available')
ValueError: No backend available
pip install pyusb
-
use pyusb to detect usb(STM32 STlink NUCLEO-F401RE)
NUCLEO-F401RE
# ipython or bpython
>>> import usb.core
## see idVendor & idProduct via `lsusb`
>>> stm32 = usb.core.find(idVendor=0x0483,idProduct=0x374b)
>>> print stm32
DEVICE ID 0483:374b on Bus 020 Address 013 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x200 USB 2.0
bDeviceClass : 0xef Miscellaneous
bDeviceSubClass : 0x2
bDeviceProtocol : 0x1
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x0483
idProduct : 0x374b
bcdDevice : 0x100 Device 1.0
iManufacturer : 0x1 STMicroelectronics
iProduct : 0x2 STM32 STLink
iSerialNumber : 0x3 066EFF494951785087033631
bNumConfigurations : 0x1
CONFIGURATION 1: 300 mA ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x80 (128 bytes)
bNumInterfaces : 0x4
bConfigurationValue : 0x1
iConfiguration : 0x0
bmAttributes : 0x80 Bus Powered
bMaxPower : 0x96 (300 mA)
INTERFACE 0: Vendor Specific ===========================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x3
bInterfaceClass : 0xff Vendor Specific
bInterfaceSubClass : 0xff
bInterfaceProtocol : 0xff
iInterface : 0x4 ST-Link Debug
ENDPOINT 0x81: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x40 (64 bytes)
bInterval : 0x0
ENDPOINT 0x1: Bulk OUT ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x1 OUT
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x40 (64 bytes)
bInterval : 0x0
ENDPOINT 0x82: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x82 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x30 (48 bytes)
bInterval : 0x0
INTERFACE 1: Mass Storage ==============================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x1
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x8 Mass Storage
bInterfaceSubClass : 0x6
bInterfaceProtocol : 0x50
iInterface : 0x5 ST-Link mass storage
ENDPOINT 0x83: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x83 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x40 (64 bytes)
bInterval : 0x0
ENDPOINT 0x3: Bulk OUT ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x3 OUT
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x40 (64 bytes)
bInterval : 0x0
INTERFACE 2: CDC Communication =========================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x2
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x2 CDC Communication
bInterfaceSubClass : 0x2
bInterfaceProtocol : 0x1
iInterface : 0x6 Error Accessing String
ENDPOINT 0x84: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x84 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x2 (2 bytes)
bInterval : 0xff
INTERFACE 3: CDC Data ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x3
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0xa CDC Data
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x7 Error Accessing String
ENDPOINT 0x5: Bulk OUT ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x5 OUT
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0xe (14 bytes)
bInterval : 0x0
ENDPOINT 0x85: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x85 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0xe (14 bytes)
bInterval : 0x0
>>>