69 for (idx = 0; idx < level; idx++) printf(
" ");
70 printf(
"PORT %d STATUS\n",port);
72 for (idx = 0; idx < level; idx++) printf(
" ");
74 printf(
"wPortStatus = %04X ",x);
75 if (x & 1) printf(
"DevicePresent ");
76 if (x & 2) printf(
"Enabled ");
77 if (x & 4) printf(
"Suspend ");
78 if (x & 8) printf(
"OverCurrent ");
79 if (x & 16) printf(
"InReset ");
80 if (x & 256) printf(
"Powered ");
81 if (x & 512) printf(
"LowSpeed ");
83 for (idx = 0; idx < level; idx++) printf(
" ");
85 printf(
"wPortChange = %04X ",x);
86 if (x & 1) printf(
"ConnectChange ");
87 if (x & 2) printf(
"EnableChange ");
88 if (x & 4) printf(
"SuspendChange ");
89 if (x & 8) printf(
"OverCurrentChange ");
90 if (x & 16) printf(
"ResetChange ");
94static char *getstringmaybe(
usbdev_t *dev,
unsigned int string)
103 memset(buf,0,
sizeof(buf));
119 static char *eptattribs[4] = {
"Control",
"Isoc",
"Bulk",
"Interrupt"};
124 while (
ptr < endptr) {
131 printf(
"---------------------------------------------------\n");
132 printf(
"DEVICE DESCRIPTOR\n");
133 printf(
"bLength = %d\n",devdscr->
bLength);
135 printf(
"bcdUSB = %04X\n",
GETUSBFIELD(devdscr,bcdUSB));
140 if (endptr-
ptr <= 8)
break;
141 printf(
"idVendor = %04X (%d)\n",
144 printf(
"idProduct = %04X (%d)\n",
147 printf(
"bcdDevice = %04X\n",
GETUSBFIELD(devdscr,bcdDevice));
148 printf(
"iManufacturer = %d (%s)\n",
151 printf(
"iProduct = %d (%s)\n",
153 getstringmaybe(dev,devdscr->
iProduct));
154 printf(
"iSerialNumber = %d (%s)\n",
162 printf(
"---------------------------------------------------\n");
163 printf(
"CONFIG DESCRIPTOR\n");
165 printf(
"bLength = %d\n",cfgdscr->
bLength);
167 printf(
"wTotalLength = %d\n",
GETUSBFIELD(cfgdscr,wTotalLength));
170 printf(
"iConfiguration = %d (%s)\n",
178 printf(
"---------------------------------------------------\n");
179 printf(
"INTERFACE DESCRIPTOR\n");
183 printf(
"bLength = %d\n",ifdscr->
bLength);
191 printf(
"iInterface = %d (%s)\n",
197 printf(
"---------------------------------------------------\n");
198 printf(
"ENDPOINT DESCRIPTOR\n");
202 printf(
"bLength = %d\n",epdscr->
bLength);
204 printf(
"bEndpointAddr = %02X (%d,%s)\n",
209 printf(
"bmAttrbutes = %02X (%s)\n",
212 printf(
"wMaxPacketSize = %d\n",
GETUSBFIELD(epdscr,wMaxPacketSize));
213 printf(
"bInterval = %d\n",epdscr->
bInterval);
217 printf(
"---------------------------------------------------\n");
218 printf(
"HID DESCRIPTOR\n");
222 printf(
"bLength = %d\n",hiddscr->
bLength);
224 printf(
"bcdHID = %04X\n",
GETUSBFIELD(hiddscr,bcdHID));
228 printf(
"wClassDescrLen = %d\n",
GETUSBFIELD(hiddscr,wClassDescrLength));
232 printf(
"---------------------------------------------------\n");
233 printf(
"HUB DESCRIPTOR\n");
240 printf(
"wHubCharacters = %04X\n",
GETUSBFIELD(hubdscr,wHubCharacteristics));
248 printf(
"---------------------------------------------------\n");
249 printf(
"UNKNOWN DESCRIPTOR\n");
250 printf(
"bLength = %d\n",cfgdscr->
bLength);
252 printf(
"Data Bytes = ");
253 for (idx = 0; idx < cfgdscr->
bLength; idx++) {
254 printf(
"%02X ",
ptr[idx]);
273 memset(buffer,0,
sizeof(buffer));
280 printf(
"[a] usb_get_config_descriptor returns %d\n",res);
287 printf(
"[b] usb_get_config_descriptor returns %d\n",res);
301 printf(
" Vendor: %s (%04x)\n",getstringmaybe(dev,devdscr->
iManufacturer),
303 printf(
" Product: %s (%04x)\n",getstringmaybe(dev,devdscr->
iProduct),
316 printf(
"USB bus %d device %d: vendor %04X product %04X class %d [%s]\n",
321 (
IS_HUB(dev) ?
"HUB" :
"DEVICE"));
uint8_t bConfigurationValue
uint8_t bNumConfigurations
uint8_t bHubControlCurrent
uint8_t bDescriptorLength
uint8_t bRemoveAndPowerMask[64]
uint8_t bPowerOnToPowerGood
uint8_t bAlternateSetting
uint8_t bInterfaceSubClass
uint8_t bInterfaceProtocol
usb_device_descr_t ud_devdescr
#define GETUSBFIELD(s, f)
#define USB_HID_DESCRIPTOR_TYPE
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
#define USB_ENDPOINT_DESCRIPTOR_TYPE
#define USB_DEVICE_DESCRIPTOR_TYPE
#define USB_ENDPOINT_DIRECTION_IN
#define USB_HUB_DESCRIPTOR_TYPE
#define USB_INTERFACE_DESCRIPTOR_TYPE
int usb_get_config_descriptor(usbdev_t *dev, usb_config_descr_t *dscr, int idx, int maxlen)
int usb_get_string(usbdev_t *dev, int id, char *buf, int maxlen)
void usb_dbg_showdevice(usbdev_t *dev)
void usb_dbg_dumpdescriptors(usbdev_t *dev, uint8_t *ptr, int len)
void usb_dbg_dumpportstatus(int port, usb_port_status_t *portstatus, int level)
void usb_dbg_dumpdevice(usbdev_t *dev)
void usb_dbg_dumpcfgdescr(usbdev_t *dev, unsigned int index)