staticchar *speed (enum usb_device_speed s)
{ switch (s) { case USB_SPEED_UNKNOWN: return"unknown"; case USB_SPEED_LOW: return"low"; case USB_SPEED_FULL: return"full"; case USB_SPEED_HIGH: return"high"; case USB_SPEED_WIRELESS: return"wireless"; case USB_SPEED_SUPER: return"super"; case USB_SPEED_SUPER_PLUS: return"super-plus"; default: return"??";
}
}
/* devices that start up using the EZ-USB default device and *whichwecanuseafterloadingsimplefirmware.hotplug *canfxloadit,andthenrunthistestdriver. * *wereturnfalsepositivesintwocases: *-thedevicehasa"real"driver(maybeusb-serial)that *renumerates.thedeviceshouldvanishquickly. *-thedevicedoesn'thavethetestfirmwareinstalled.
*/
/* generic EZ-USB FX controller */ if (dev.idVendor == 0x0547 && dev.idProduct == 0x2235) return0;
/* the FunctionFS gadget can have the source/sink interface *anywhere.Welookforaninterfacedescriptorthatmatch
* what we expect. We ignore configuratiens thou. */
errno = 0;
val = strtoul(str, &end, 0); if (errno || *end || val > UINT_MAX) return -1;
*num = val; return0;
}
int main (int argc, char **argv)
{
int c; struct testdev *entry; char *device; constchar *usb_dir = NULL; int all = 0, forever = 0, not = 0; int test = -1/* all */; struct usbtest_param param;
/* pick defaults that works with all speeds, without short packets. * *Bestper-framedatarates: *superspeed,bulk1024*16*8=131072 *interrupt1024*3*8=24576 *highspeed,bulk512*13*8=53248 *interrupt1024*3*8=24576 *fullspeed,bulk/intr64*19=1216 *interrupt64*1=64 *lowspeed,interrupt8*1=8
*/
param.iterations = 1000;
param.length = 1024;
param.vary = 1024;
param.sglen = 32;
/* for easy use when hotplugging */
device = getenv ("DEVICE");
while ((c = getopt (argc, argv, "D:aA:c:g:hlns:t:v:")) != EOF) switch (c) { case'D': /* device, if only one */
device = optarg; continue; case'A': /* use all devices with specified USB dir */
usb_dir = optarg; /* FALL THROUGH */ case'a': /* use all devices */
device = NULL;
all = 1; continue; case'c': /* count iterations */ if (parse_num(¶m.iterations, optarg)) goto usage; continue; case'g': /* scatter/gather entries */ if (parse_num(¶m.sglen, optarg)) goto usage; continue; case'l': /* loop forever */
forever = 1; continue; case'n': /* no test running! */ not = 1; continue; case's': /* size of packet */ if (parse_num(¶m.length, optarg)) goto usage; continue; case't': /* run just one test */
test = atoi (optarg); if (test < 0) goto usage; continue; case'v': /* vary packet size by ... */ if (parse_num(¶m.vary, optarg)) goto usage; continue; case'?': case'h': default:
usage:
fprintf (stderr, "usage: %s [options]\n" "Options:\n" "\t-D dev only test specific device\n" "\t-A usb-dir\n" "\t-a test all recognized devices\n" "\t-l loop forever(for stress test)\n" "\t-t testnum only run specified case\n" "\t-n no test running, show devices to be tested\n" "Case arguments:\n" "\t-c iterations default 1000\n" "\t-s transfer length default 1024\n" "\t-g sglen default 32\n" "\t-v vary default 1024\n",
argv[0]); return1;
} if (optind != argc) goto usage; if (!all && !device) {
fprintf (stderr, "must specify '-a' or '-D dev', " "or DEVICE=/dev/bus/usb/BBB/DDD in env\n"); goto usage;
}
/* Find usb device subdirectory */ if (!usb_dir) {
usb_dir = usb_dir_find(); if (!usb_dir) {
fputs ("USB device files are missing\n", stderr); return -1;
}
}
/* collect and list the test devices */ if (ftw (usb_dir, find_testdev, 3) != 0) {
fputs ("ftw failed; are USB device files missing?\n", stderr); return -1;
}
/* quit, run single test, or create test threads */ if (!testdevs && !device) {
fputs ("no test devices recognized\n", stderr); return -1;
} if (not) return0; if (testdevs && !testdevs->next && !device)
device = testdevs->name; for (entry = testdevs; entry; entry = entry->next) { int status;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.