Changeset 00d23a2 in mainline
- Timestamp:
- 2017-12-22T13:43:27Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e23b87b
- Parents:
- b10a434
- git-author:
- Petr Mánek <petr.manek@…> (2017-12-22 13:43:20)
- git-committer:
- Petr Mánek <petr.manek@…> (2017-12-22 13:43:27)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tmon/main.c
rb10a434 r00d23a2 38 38 #include "commands.h" 39 39 40 #define NAME "tmon" 40 #define NAME "tmon" 41 #define INDENT " " 41 42 42 typedef struct {43 typedef struct tmon_cmd { 43 44 const char *name; 44 45 const char *description; 45 46 int (*action)(int, char **); 46 } usb_diag_cmd_t;47 } tmon_cmd_t; 47 48 48 static usb_diag_cmd_t commands[] = {49 static tmon_cmd_t commands[] = { 49 50 { 50 51 .name = "list", … … 54 55 { 55 56 .name = "test-intr-in", 56 .description = "Read from interrupt in endpointsas fast as possible.",57 .description = "Read from interrupt endpoint as fast as possible.", 57 58 .action = tmon_burst_intr_in, 58 59 }, 59 60 { 60 61 .name = "test-intr-out", 61 .description = "Write to interrupt out endpointsas fast as possible.",62 .description = "Write to interrupt endpoint as fast as possible.", 62 63 .action = tmon_burst_intr_out, 63 64 }, 64 65 { 65 66 .name = "test-bulk-in", 66 .description = "Read from bulk in endpointsas fast as possible.",67 .description = "Read from bulk endpoint as fast as possible.", 67 68 .action = tmon_burst_bulk_in, 68 69 }, 69 70 { 70 71 .name = "test-bulk-out", 71 .description = "Write to bulk out endpointsas fast as possible.",72 .description = "Write to bulk endpoint as fast as possible.", 72 73 .action = tmon_burst_bulk_out, 73 74 }, 74 75 { 75 76 .name = "test-isoch-in", 76 .description = "Read from isochronous in endpointsas fast as possible.",77 .description = "Read from isochronous endpoint as fast as possible.", 77 78 .action = tmon_burst_isoch_in, 78 79 }, 79 80 { 80 81 .name = "test-isoch-out", 81 .description = "Write to isochronous e out endpointsas fast as possible.",82 .description = "Write to isochronous endpoint as fast as possible.", 82 83 .action = tmon_burst_isoch_out, 83 84 }, 85 { /* NULL-terminated */ } 86 }; 87 88 typedef struct tmon_opt { 89 const char *long_name; 90 char short_name; 91 const char *description; 92 } tmon_opt_t; 93 94 static tmon_opt_t options[] = { 84 95 { 85 .name = NULL 86 } 96 .long_name = "cycles", 97 .short_name = 'n', 98 .description = "Set the number of read/write cycles." 99 }, 100 { 101 .long_name = "size", 102 .short_name = 's', 103 .description = "Set the data size transferred in a single cycle." 104 }, 105 { /* NULL-terminated */ } 87 106 }; 88 107 89 108 static void print_usage(char *app_name) 90 109 { 91 printf(NAME ": benchmark USB diagnostic device\n\n"); 110 puts(NAME ": benchmark USB diagnostic device\n\n"); 111 printf("Usage: %s command [device] [options]\n\n", app_name); 92 112 93 printf("Usage: %s command [device] [options]\n", app_name);94 printf("Available commands:\n");95 113 for (int i = 0; commands[i].name; ++i) { 96 printf( "%s - %s\n", commands[i].name, commands[i].description);114 printf(INDENT "%s - %s\n", commands[i].name, commands[i].description); 97 115 } 98 116 99 // TODO: Print options. 117 puts("\n"); 118 for (int i = 0; options[i].long_name; ++i) { 119 printf(INDENT "-%c --%s\n" INDENT INDENT "%s\n", options[i].short_name, options[i].long_name, options[i].description); 120 } 100 121 101 p rintf("\nIf no device is specified, the first device is used provided that no other device is connected.\n\n");122 puts("\nIf no device is specified, the first device is used provided that it is the only one connected. Otherwise, the command fails.\n\n"); 102 123 } 103 124 … … 105 126 { 106 127 // Find a command to execute. 107 usb_diag_cmd_t *cmd = NULL;128 tmon_cmd_t *cmd = NULL; 108 129 for (int i = 0; argc > 1 && commands[i].name; ++i) { 109 130 if (str_cmp(argv[1], commands[i].name) == 0) {
Note:
See TracChangeset
for help on using the changeset viewer.