make it possible to specify the USB bus
document the usage for multiple cables
This commit is contained in:
parent
d377df04c9
commit
3a2a22bc86
8
README
8
README
@ -74,6 +74,14 @@ these steps:
|
|||||||
4. restart udev and re-plug the cable
|
4. restart udev and re-plug the cable
|
||||||
|
|
||||||
|
|
||||||
|
If you have multiple cables connected, you can specify the cable to use
|
||||||
|
in the XILINX_USB_DEV environment-variable as "bus:device".
|
||||||
|
These identifiers are available in the output of lsusb:
|
||||||
|
Bus 001 Device 004: ID 03fd:0008 Xilinx, Inc.
|
||||||
|
^^^ ^^^
|
||||||
|
To use this cable, set the XILINX_USB_DEV variable to "001:004".
|
||||||
|
|
||||||
|
|
||||||
Notes for the parallel cable
|
Notes for the parallel cable
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
43
usb-driver.c
43
usb-driver.c
@ -466,9 +466,8 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
|
|||||||
{
|
{
|
||||||
struct event *e = (struct event*)(wdheader->data);
|
struct event *e = (struct event*)(wdheader->data);
|
||||||
struct usb_bus *bus;
|
struct usb_bus *bus;
|
||||||
char* device_num;
|
char* devpos;
|
||||||
char* remainder;
|
int busnum = -1, devnum = -1;
|
||||||
int devnum = -1;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
DPRINTF("handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: %lu, ver: %lu, nummatch: %lu\n",
|
DPRINTF("handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: %lu, ver: %lu, nummatch: %lu\n",
|
||||||
@ -480,14 +479,35 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
|
|||||||
e->u.Usb.dwUniqueID, e->dwEventVer,
|
e->u.Usb.dwUniqueID, e->dwEventVer,
|
||||||
e->dwNumMatchTables);
|
e->dwNumMatchTables);
|
||||||
|
|
||||||
device_num=getenv("XILINX_USB_DEVNUM");
|
devpos = getenv("XILINX_USB_DEV");
|
||||||
if (device_num!=NULL) {
|
if (devpos != NULL) {
|
||||||
DPRINTF("XILINX_USB_BUS=%s\n",device_num);
|
int j;
|
||||||
devnum=strtol(device_num,&remainder,10);
|
char *devstr = NULL, *remainder;
|
||||||
if (device_num==remainder) /* no integer in env variable */
|
|
||||||
devnum=-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
DPRINTF("XILINX_USB_DEV=%s\n", devpos);
|
||||||
|
|
||||||
|
for (j = 0; j < strlen(devpos) && devpos[j] != 0; j++) {
|
||||||
|
if (devpos[j] == ':') {
|
||||||
|
devpos[j] = 0;
|
||||||
|
devstr = &(devpos[j+1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (devstr && strlen(devstr) > 0) {
|
||||||
|
busnum = strtol(devpos, &remainder, 10);
|
||||||
|
if (devpos == remainder) {
|
||||||
|
busnum = -1;
|
||||||
|
} else {
|
||||||
|
devnum = strtol(devstr, &remainder, 10);
|
||||||
|
if (devstr == remainder) {
|
||||||
|
devnum = -1;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,"Using XILINX platform cable USB at %03d:%03d\n",
|
||||||
|
busnum, devnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < e->dwNumMatchTables; i++) {
|
for (i = 0; i < e->dwNumMatchTables; i++) {
|
||||||
|
|
||||||
@ -503,6 +523,9 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
|
|||||||
for (bus = busses; bus; bus = bus->next) {
|
for (bus = busses; bus; bus = bus->next) {
|
||||||
struct usb_device *dev;
|
struct usb_device *dev;
|
||||||
|
|
||||||
|
if ((devnum != -1) && (strtol(bus->dirname, NULL, 10) != busnum))
|
||||||
|
continue;
|
||||||
|
|
||||||
for (dev = bus->devices; dev; dev = dev->next) {
|
for (dev = bus->devices; dev; dev = dev->next) {
|
||||||
struct usb_device_descriptor *desc = &(dev->descriptor);
|
struct usb_device_descriptor *desc = &(dev->descriptor);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user