-
Notifications
You must be signed in to change notification settings - Fork 2
USB Basics
Graham edited this page Mar 18, 2017
·
1 revision
The tutorial boilerplate seems to work...
DEVICE ID 054c:0034 on Bus 020 Address 012 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x110 USB 1.1
bDeviceClass : 0xff Vendor-specific
bDeviceSubClass : 0x0
bDeviceProtocol : 0x0
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x054c
idProduct : 0x0034
bcdDevice : 0x100 Device 1.0
iManufacturer : 0x1 xxxx
iProduct : 0x2 PCLK-MN10
iSerialNumber : 0x0
bNumConfigurations : 0x1
CONFIGURATION 1: 100 mA ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x20 (32 bytes)
bNumInterfaces : 0x1
bConfigurationValue : 0x1
iConfiguration : 0x2 PCLK-MN10
bmAttributes : 0x80 Bus Powered
bMaxPower : 0x32 (100 mA)
INTERFACE 0: Reserved ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x0 Reserved
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 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 : 0x40 (64 bytes)
bInterval : 0x0
We were going to attempt to figure out control commands but that was unneeded. The windows driver (and this library) send something (very close to):
# SETUP PACKET:
# 80 06 00 01 00 00 12 00
>>> dev.ctrl_transfer(0x80, 0x06, 0x0100, 0, 0x12)
array('B', [18, 1, 16, 1, 255, 0, 0, 64, 76, 5, 52, 0, 0, 1, 1, 2, 0, 1])
# SETUP PACKET:
# 80 06 00 02 00 00 09 02
>>> dev.ctrl_transfer(0x80, 0x06, 0x0002, 0, 0x0902)
array('B', [9, 2, 32, 0, 1, 1, 2, 128, 50, 9, 4, 0, 0, 2, 0, 0, 0, 0, 7, 5, 1, 2, 64, 0, 0, 7, 5, 130, 2, 64, 0, 0])
After many attempts, finally a write/read seemed to do something -- just the once...
>>> ep.write([0x00,0x60,0x00])
3
>>> rep.read(40)
array('B', [0, 96, 17, 0, 100])
>>> ep.write([0x00,0x60,0x00])
3
>>> rep.read(40)
array('B')
It transpired that the device had become confused somehow; a replug determined that this was indeed the poweron command. It seems that sending lots of garbage (or failing to read at appropriate times?) might cause something to get confused / out of sync somehow.