Hi list.
I am wondering if someone could shed some light on what I am trying to do.
I have been playing around trying to come up with something that kind of have
the verbosity of lsusb but use OpenBSD's #include <dev/usb/usb.h> and avoid all
of libusb stuff.
I hit a wall when I try to use USB_DEVICE_GET_FDESC :
Breakpoint 1, get_usb_device_fdesc (f=7, a=1, u=0x7f7ffffd40d0) at usbdevs.c:219
219 int e = ioctl(f, USB_DEVICE_GET_FDESC, u);
(gdb) s
218 u->udf_size=25;
(gdb)
219 int e = ioctl(f, USB_DEVICE_GET_FDESC, u);
(gdb)
__cerror () at /usr/src/lib/libc/arch/amd64/sys/cerror.S:48
48 movq PIC_GOT(_C_LABEL(errno)), %rcx
Current language: auto; currently asm
(gdb) bt
#0 __cerror () at /usr/src/lib/libc/arch/amd64/sys/cerror.S:48
#1 0x0000048cfe7022cc in usbdev (f=7, a=1, rec=Variable "rec" is not available.
) at usbdevs.c:285
#2 0x0000048cfe70235b in usbdump (f=7) at usbdevs.c:308
#3 0x0000048cfe70259b in main (argc=3, argv=0x7f7ffffd4258) at usbdevs.c:419
At the moment, I can get my small program to produce ouput like this:
Controller /dev/usb0:
Device Information:
addr 1:
idVendor Intel
VendorNo 0x8086
idProduct 0x0000
Product EHCI root hub
Release 1.00
ReleaseNo 0x0100
Config 1
Power 0 Self powered
Speed 3 (High Speed)
iSerialNumber none
Device Name[0] uhub2
nPorts 4
port 1 powered
port 2 powered
port 3 powered
port 4 powered
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 0x0200
bDeviceClass 9 (Hub)
bDeviceSubClass 0
bDeviceProtocol 1
bMaxPacketSize 64
idVendor 0x8086
bNumConfigurations 1
Configuration Descriptor
bLength 9
bDescriptorType 2
wTotalLength 25
bNumInterface 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x40 (Self Powered)
bMaxPower (mA) 0
So basically I have the following function that fails.
I set udf_size=25 as this is the value I get from wTotalLength shown above as
explained in the man.
int
get_usb_device_fdesc(int f, int a, struct usb_device_fdesc *u)
{
u->udf_addr = a;
u->udf_config_index = USB_CURRENT_CONFIG_INDEX;
u->udf_size=25;
int e = ioctl(f, USB_DEVICE_GET_FDESC, u);
return e;
}
Clearly I don't seem to use USB_DEVICE_GET_FDESC correctly.
Grepping /usr/src only reveals little on USB_DEVICE_GET_FDESC
/usr/src:
$>find . -name *.c|xargs grep USB_DEVICE_GET_FDESC
./sys/dev/usb/usb.c: case USB_DEVICE_GET_FDESC:
[email protected]:18:40:45
/usr/src:
$>find . -name *.c|xargs grep -n USB_DEVICE_GET_FDESC
./sys/dev/usb/usb.c:752: case USB_DEVICE_GET_FDESC:
Regards
Mario St-Gelais