This command will cause a complete bus discovery to be initiated. If any devices attached or detached from the bus they will be processed during this command. This is the only way that new devices are found on the bus.
USB_DEVICEINFO Vt "struct usb_device_info"
This command can be used to retrieve some information about a device on the bus. The udi_addr field should be filled before the call and the other fields will be filled by information about the device on that address. Should no such device exist, an error is reported.
#define USB_MAX_DEVNAMES 4
#define USB_MAX_DEVNAMELEN 16
struct usb_device_info {
u_int8_t udi_bus;
u_int8_t udi_addr; /* device address */
usb_event_cookie_t udi_cookie;
char udi_product[USB_MAX_STRING_LEN];
char udi_vendor[USB_MAX_STRING_LEN];
char udi_release[8];
u_int16_t udi_productNo;
u_int16_t udi_vendorNo;
u_int16_t udi_releaseNo;
u_int8_t udi_class;
u_int8_t udi_subclass;
u_int8_t udi_protocol;
u_int8_t udi_config;
u_int8_t udi_speed;
#define USB_SPEED_LOW 1
#define USB_SPEED_FULL 2
#define USB_SPEED_HIGH 3
int udi_power;/* power consumption in mA, 0 if selfpowered */
int udi_nports;
char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
u_int8_t udi_ports[16];/* hub only: addresses of devices on ports */
#define USB_PORT_ENABLED 0xff
#define USB_PORT_SUSPENDED 0xfe
#define USB_PORT_POWERED 0xfd
#define USB_PORT_DISABLED 0xfc
};
udi_bus and udi_addr contain the topological information for the device. udi_devnames contains the device names of the connected drivers. For example, the third USB Zip drive connected will be umass2. The udi_product, udi_vendor and udi_release fields contain self-explanatory descriptions of the device. udi_productNo, udi_vendorNo, udi_releaseNo, udi_class, udi_subclass and udi_protocol contain the corresponding values from the device descriptors. The udi_config field shows the current configuration of the device.
udi_speed indicates whether the device is at low speed (USB_SPEED_LOW), full speed (USB_SPEED_FULL) or high speed (USB_SPEED_HIGH). The udi_power field shows the power consumption in milli-amps drawn at 5 volts, or zero if the device is self powered.
If the device is a hub, the udi_nports field is non-zero, and the udi_ports field contains the addresses of the connected devices. If no device is connected to a port, one of the USB_PORT_* values indicates its status.
USB_DEVICESTATS Vt "struct usb_device_stats"
This command retrieves statistics about the controller.
struct usb_device_stats {
u_long uds_requests[4];
};
The udi_requests field is indexed by the transfer kind, i.e. UE_*, and indicates how many transfers of each kind that has been completed by the controller.
USB_REQUEST Vt "struct usb_ctl_request"
This command can be used to execute arbitrary requests on the control pipe. This is DANGEROUS and should be used with great care since it can destroy the bus integrity.
The include file .In dev/usb/usb.h contains definitions for the types used by the various ioctl(2) calls. The naming convention of the fields for the various USB descriptors exactly follows the naming in the USB specification. Byte sized fields can be accessed directly, but word (16 bit) sized fields must be access by the UGETW field and USETW field value macros to handle byte order and alignment properly.
The include file .In dev/usb/usbhid.h similarly contains the definitions for Human Interface Devices (HID).