OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_c/] [jtag/] [jtag_libusb/] [list_usb_dev.c] - Blame information for rev 38

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 alirezamon
#include <stdio.h>
2
#include <stdlib.h>
3
#include <unistd.h>
4
#include <string.h>
5
#include <ctype.h>
6
#include <libusb-1.0/libusb.h>
7
 
8
 
9
int main(){
10
// discover devices
11
 
12
if (libusb_init(NULL) < 0)
13
                return -1;
14
 
15
 
16
 
17
 
18
 
19
 
20
 
21
 
22
 
23
 
24
libusb_context *ctx=NULL;
25
//uint16_t vendor_id,
26
//uint16_t product_id
27
 
28
        struct libusb_device **devs;
29
        //struct libusb_device *found = NULL;
30
        struct libusb_device *dev;
31
        //struct libusb_device_handle *handle = NULL;
32
        size_t i = 0;
33
        int r;
34
        if (libusb_get_device_list(ctx, &devs) < 0)
35
                return -1;
36
        while ((dev = devs[i++]) != NULL) {
37
                struct libusb_device_descriptor desc;
38
                r = libusb_get_device_descriptor(dev, &desc);
39
                if (r < 0)
40
                        goto out;
41
                printf("vid=%x,\t pid=%x\n",desc.idVendor,desc.idProduct);
42
                //if (desc.idVendor == vendor_id && desc.idProduct == product_id) {
43
                //      found = dev;
44
                //      break;
45
                //}
46
        }
47
        //if (found) {
48
        //      r = libusb_open(found, &handle);
49
        //      if (r < 0)
50
        //              handle = NULL;
51
        //}
52
out:
53
        libusb_free_device_list(devs, 1);
54
        //return handle;
55
 
56
return 0;
57
 
58
}
59
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.