|
|
#include <unistd.h> | #include <unistd.h> |
#include <stdio.h> | #include <stdio.h> |
#include <stdarg.h> | #include <stdarg.h> |
|
#include <endian.h> |
| |
#include <linux/types.h> | #include <linux/types.h> |
#ifdef HAVE_LINUX_USBDEVICE_FS_H | #ifdef HAVE_LINUX_USBDEVICE_FS_H |
|
|
| |
static void dump_junk2(unsigned char *, unsigned int); | static void dump_junk2(unsigned char *, unsigned int); |
| |
|
static int to_me(int x) |
|
{ |
|
#ifndef __BIG_ENDIAN__ |
|
return x; |
|
#else |
|
return (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8); |
|
#endif |
|
} |
|
|
/* ---------------------------------------------------------------------- */ | /* ---------------------------------------------------------------------- */ |
| |
int lprintf(unsigned int vl, const char *format, ...) | int lprintf(unsigned int vl, const char *format, ...) |
|
|
" iSerial %5u %s\n" | " iSerial %5u %s\n" |
" bNumConfigurations %5u\n", | " bNumConfigurations %5u\n", |
buf[0], buf[1], buf[3], buf[2], buf[4], cls, buf[5], subcls, buf[6], proto, buf[7], | buf[0], buf[1], buf[3], buf[2], buf[4], cls, buf[5], subcls, buf[6], proto, buf[7], |
vid, vendor, pid, product, buf[13], buf[12], buf[14], mfg, buf[15], prod, buf[16], serial, buf[17]); |
to_me(vid), vendor, to_me(pid), product, buf[13], buf[12], buf[14], mfg, buf[15], prod, buf[16], serial, buf[17]); |
dump_junk(buf, " ", 18); | dump_junk(buf, " ", 18); |
} | } |
| |
|
|
pid = buf[10] | (buf[11] << 8); | pid = buf[10] | (buf[11] << 8); |
get_vendor_string(vendor, sizeof(vendor), vid); | get_vendor_string(vendor, sizeof(vendor), vid); |
get_product_string(product, sizeof(product), vid, pid); | get_product_string(product, sizeof(product), vid, pid); |
printf("Device: ID %04x:%04x %s %s\n", vid, pid, vendor, product); |
printf("Device: ID %04x:%04x %s %s\n", to_me(vid), to_me(pid), vendor, product); |
dumpdev(buf, fd, flags); | dumpdev(buf, fd, flags); |
status=0; | status=0; |
err: | err: |
|
|
get_product_string(product, sizeof(product), vid, pid); | get_product_string(product, sizeof(product), vid, pid); |
if (verblevel > 0) | if (verblevel > 0) |
printf("\n"); | printf("\n"); |
printf("Bus %s Device %s: ID %04x:%04x %s %s\n", de->d_name, de2->d_name, vid, pid, vendor, product); |
printf("Bus %s Device %s: ID %04x:%04x %s %s\n", de->d_name, de2->d_name, to_me(vid), to_me(pid), vendor, product); |
if (verblevel > 0) | if (verblevel > 0) |
dumpdev(buf, fd, flags); | dumpdev(buf, fd, flags); |
err: | err: |