lsusb.c ( File view )
- By 2010-08-29
- View(s):12
- Download(s):0
- Point(s): 1
/*
* libusb example program to list devices on the bus
* Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <sys/types.h>
#include <libusb/libusb.h>
static void print_devs(libusb_device **devs)
{
libusb_device *dev;
int i = 0;
while ((dev = devs[i++]) != NULL) {
struct libusb_device_descriptor desc;
int r = libusb_get_device_descriptor(dev, &desc);
if (r < 0) {
fprintf(stderr, "failed to get device descriptor");
return;
}
printf("%04x:%04x (bus %d, device %d)\n",
desc.idVendor, desc.idProduct,
libusb_get_bus_number(dev), libusb_get_device_address(dev));
}
}
int main(void)
{
libusb_device **devs;
int r;
ssize_t cnt;
r = libusb_init(NULL);
if (r < 0)
return r;
cnt = libusb_get_device_list(NULL, &devs);
if (cnt < 0)
return (int) cnt;
print_devs(devs);
libusb_free_device_list(devs, 1);
libusb_exit(NULL);
return 0;
}
...
Expand> <Close
Sponsored links
File list
Tips: You can preview the content of files by clicking file names^_^| Name | Size | Date |
|---|---|---|
| aclocal.m4 | 311.63 kB | 23-11-09 01:21 |
| AUTHORS | 400.00 B | 15-11-09 20:16 |
| ChangeLog | 53.40 kB | 23-11-09 01:21 |
| compile | 3.62 kB | 20-12-07 03:15 |
| config.guess | 44.40 kB | 20-06-08 12:30 |
| config.h.in | 2.25 kB | 23-11-09 01:21 |
| config.sub | 32.86 kB | 20-06-08 12:30 |
| configure | 402.91 kB | 23-11-09 01:21 |
| configure.ac | 3.96 kB | 23-11-09 01:18 |
| COPYING | 25.82 kB | 20-12-07 03:14 |
| depcomp | 17.16 kB | 20-12-07 03:15 |
| doxygen.cfg.in | 52.78 kB | 02-11-08 23:05 |
| Makefile.am | 182.00 B | 21-11-08 18:58 |
| Makefile.in | 9.79 kB | 23-11-09 01:21 |
| dpfp.c | 10.53 kB | 07-11-09 18:11 |
| dpfp_threaded.c | 11.37 kB | 25-06-08 12:00 |
| lsusb.c | 1.61 kB | 22-11-09 01:12 |
| Makefile.am | 356.00 B | 21-11-08 00:24 |
| Makefile.in | 17.82 kB | 23-11-09 01:21 |
| INSTALL | 9.20 kB | 20-12-07 03:14 |
| install-sh | 12.88 kB | 20-12-07 03:15 |
| core.c | 53.94 kB | 07-11-09 20:47 |
| descriptor.c | 18.97 kB | 11-06-09 04:39 |
| io.c | 86.80 kB | 22-11-09 01:02 |
| libusb.h | 40.60 kB | 23-11-09 01:17 |
| libusbi.h | 28.49 kB | 23-11-09 01:17 |
| Makefile.am | 512.00 B | 23-11-09 01:17 |
| Makefile.in | 25.37 kB | 23-11-09 01:21 |
| darwin_usb.c | 54.01 kB | 22-11-09 01:10 |
| darwin_usb.h | 4.27 kB | 22-11-09 01:06 |
| linux_usbfs.c | 57.96 kB | 23-11-09 01:17 |
| linux_usbfs.h | 4.03 kB | 07-11-09 20:47 |
| sync.c | 10.95 kB | 14-09-09 04:30 |
| libusb-1.0.pc.in | 245.00 B | 04-01-08 08:42 |
| ltmain.sh | 237.57 kB | 23-11-09 01:21 |
| Makefile.am | 621.00 B | 27-08-09 23:55 |
| Makefile.in | 25.03 kB | 23-11-09 01:21 |
| missing | 10.87 kB | 20-12-07 03:15 |
| NEWS | 1.09 kB | 23-11-09 01:20 |
| PORTING | 3.76 kB | 15-06-08 23:57 |
| README | 684.00 B | 18-09-09 16:30 |
| THANKS | 215.00 B | 11-08-08 06:10 |
| TODO | 290.00 B | 29-06-08 10:05 |
| <os> | 0.00 B | 22-12-09 19:27 |
| <doc> | 0.00 B | 22-12-09 19:27 |
| <examples> | 0.00 B | 22-12-09 19:27 |
| <libusb> | 0.00 B | 22-12-09 19:27 |
| <libusb-1.0.6> | 0.00 B | 22-12-09 19:27 |
Sponsored links





