Date:2011-07-05 23:53:32 (8 years 2 months ago)
Author:Werner Almesberger
Commit:391c37f58757c4a60c7a47752d4ecc55cf513a55
Message:tools/atrf-id/atrf-id.c: new option -D to read atusb debug log

Files: tools/atrf-id/atrf-id.c (5 diffs)

Change Details

tools/atrf-id/atrf-id.c
112112}
113113
114114
115static void do_dump_debug(struct atrf_dsc *dsc)
116{
117    usb_dev_handle *dev;
118    uint8_t buf[1024];
119    int res;
120    struct log {
121        uint16_t n;
122        uint8_t bmRequestType;
123        uint8_t bRequest;
124        uint16_t wValue;
125        uint16_t wIndex;
126        uint16_t wLength;
127    } *p;
128
129    dev = atrf_usb_handle(dsc);
130    if (!dev)
131        return;
132
133    res = usb_control_msg(dev, FROM_DEV, ATUSB_READ_LOG, 0, 0,
134        (void *) buf, sizeof(buf), 1000);
135    if (res < 0) {
136        fprintf(stderr, "ATUSB_READ_LOG: %s\n", usb_strerror());
137        return;
138    }
139
140    printf("Number\tbmRequestType\tbRequest\twValue\twIndex\twLength\n");
141    for (p = (void *) buf; (uint8_t *) (p+1) <= buf+res; p++) {
142        printf("%u\t", p->n);
143        printf("0x%02x\t\t", p->bmRequestType);
144        printf("0x%02x\t\t", p->bRequest);
145        printf("0x%04x\t", p->wValue);
146        printf("0x%04x\t", p->wIndex);
147        printf("0x%04x\n", p->wLength);
148
149    }
150}
151
152
115153#else /* HAVE_USB */
116154
117155
...... 
120158}
121159
122160
161static void do_dump_debug(struct atrf_dsc *dsc)
162{
163}
164
165
123166#endif /* !HAVE_USB */
124167
125168
...... 
161204    fprintf(stderr,
162205"usage: %s [-d driver[:arg]] [-s [-s]]\n\n"
163206" -d driver[:arg] use the specified driver (default: %s)\n"
207" -D dump atusb debug buffer\n"
164208" -s print only the local driver specification\n"
165209" -s -s print only the remote driver specification\n"
166210    , name, atrf_default_driver_name());
...... 
173217    const char *driver = NULL;
174218    struct atrf_dsc *dsc;
175219    int spec_only = 0;
220    int dump_debug = 0;
176221    int c;
177222
178    while ((c = getopt(argc, argv, "d:s")) != EOF)
223    while ((c = getopt(argc, argv, "d:Ds")) != EOF)
179224        switch (c) {
180225        case 'd':
181226            driver = optarg;
182227            break;
228        case 'D':
229            dump_debug = 1;
230            break;
183231        case 's':
184232            spec_only++;
185233            break;
...... 
205253    } else {
206254        show_info(dsc);
207255    }
256    if (dump_debug)
257        do_dump_debug(dsc);
208258
209259    atrf_close(dsc);
210260

Archive Download the corresponding diff file



interactive