below includes a direct mapping of Libusb functions to usb
concepts.
This is the equivalent pattern for enumerating devices, choosing your device, and opening it
var found *usb.Device
devs, err := usb.List()
if err != nil {
panic(err)
}
for _, d := range devs {
if isMyDevice(d) {
found = d
break
}
}
if found == nil {
panic("device not found")
}
err = found.Open()
if err != nil {
panic(err)
}
defer found.Close()
The concept of needing a handle separately from a device object is not carried over to this library. The device is the object from which you may obtain descriptor data, and it is the device you use for I/O operations.
Similarly, the list obtained from usb.List()
does not need to be freed. And devices are not reference counted.
These are implemented in the gusb
subpackage
Libusb | usb equiv |
Done? |
---|---|---|
libusb_hotplug_register_callback() |
- | |
libusb_hotplug_deregister_callback() |
- |
TODO
TODO
Libusb | usb equiv |
Done? |
---|---|---|
libusb_control_transfer() |
- | |
libusb_bulk_transfer() |
- | |
libusb_interrupt_transfer() |
- |
These pieces are not being ported to usb