Skip to contentSkip to conversation

failing to force-claim USB interface

DISCUSSION Martin F Krafft 2 participants 2 messages Jan 19, 2004 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

I am trying to make use of the usbfs USBDEVFS_DISCONNECT ioctl, and I am failing. Here is the code:

  struct usb_device *dev;
  [...]
  sprintf(path, "/proc/bus/usb/%s/%s", dev->bus->dirname, dev->filename);
  int fd = open(path);
  struct usbdevfs_ioctl command = { 0, USBDEVFS_DISCONNECT, 0 };
  ioctl (fd, USBDEVFS_IOCTL, &command) < 0

However, the ioctl always fails. I am not sure whether I am using the right values for the file descriptor passed to ioctl(), or what the interface number (first parameter of usbdevfs_ioctl) is.

Maybe someone could offer me some advice or tell me to RTFM (but please specify TM to FR).

Thanks,

Signature · 9 lines
Martin F. Krafft                Artificial Intelligence Laboratory
Ph.D. Student                   Department of Information Technology
Email: [email protected]          University of Zurich
Tel: +41.(0)1.63-54323          Andreasstrasse 15, Office 2.20
http://ailab.ch/people/krafft   CH-8050 Zurich, Switzerland
 
Invalid/expired PGP subkeys? Use subkeys.pgp.net as keyserver!
 
click the start menu and select 'shut down.'

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

also sprach Martin F Krafft <[email protected]> [2004.01.19.1646 +0100]:

Quoted 6 lines
  struct usb_device *dev;
  [...]
  sprintf(path, "/proc/bus/usb/%s/%s", dev->bus->dirname, dev->filename);
  int fd = open(path);
  struct usbdevfs_ioctl command = { 0, USBDEVFS_DISCONNECT, 0 };
  ioctl (fd, USBDEVFS_IOCTL, &command) < 0

I was using the wrong fd. The following works:

  struct usb_device *dev;
  [...]
  struct usb_device_handle udev = usb_open(dev);
  struct usbdevfs_ioctl command = { 0, USBDEVFS_DISCONNECT, 0 };
  ioctl(udev->fd, USBDEVFS_IOCTL, &command)

Now the only thing left to figure out is how the libusb library expects us to do this, because struct usb_device_handle; is not implemented in the exported interface.

I guess the solution is to implement the above functionality in libusb itself.

Signature · 11 lines
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
invalid/expired pgp subkeys? use subkeys.pgp.net as keyserver!
 
there are 3 types of guys -- the ones who hate nerds (all nerds, that
is; girls aren't let off the hook); the ones who are scared off by
girls who are slightly more intelligent than average; and the guys who
are also somewhat more intelligent than average, but are so shy that
they can't put 2 words together when they're within 20 feet of a girl.
                                     -- vikki roemer on debian-curiosa