Beispiel #1
0
func End(handle *C.struct_libusb_device_handle) {

	log.Print("Libusb goroutine exiting\n")

	C.libusb_release_interface(handle, 0)
	C.libusb_release_interface(handle, 1)
	C.libusb_attach_kernel_driver(handle, 0)
	C.libusb_attach_kernel_driver(handle, 1)
	C.libusb_exit(nil)

	log.Print("Libusb goroutine exited\n")
}
Beispiel #2
0
// attachKernelDriver re-attaches kernel drivers to any previously detached interfaces, if supported by the platform.
// If there are any errors, like Context.ListDevices, only the final one will be returned.
func (d *Device) attachKernelDriver() (err error) {
	for iface := range d.detached {
		switch attachErr := C.libusb_attach_kernel_driver(d.handle, C.int(iface)); attachErr {
		case C.LIBUSB_ERROR_NOT_SUPPORTED:
			// no need to do any futher checking, no platform support
			return
		case 0:
			continue
		default:
			err = fmt.Errorf("usb: attach kernel driver: %s", usbError(attachErr))
		}
	}

	return
}
Beispiel #3
0
Datei: usb.go Projekt: hanwen/usb
// Re-attach an interface's kernel driver, which was previously detached using libusb_detach_kernel_driver().
func (h *DeviceHandle) AttachKernelDriver(ifaceNum byte) error {
	return toErr(C.libusb_attach_kernel_driver(h.me(), C.int(ifaceNum)))
}
Beispiel #4
0
// AttachKernelDriver (re)attaches a previously detached kernel driver to interface iface
func (d *Device) AttachKernelDriver(iface uint8) error {
	if errno := C.libusb_attach_kernel_driver(d.handle, C.int(iface)); errno < 0 {
		return usbError(errno)
	}
	return nil
}
Beispiel #5
0
func (i *Interface) AttachKernelDriver() *UsbError {
	return returnUsbError(C.libusb_attach_kernel_driver(i.handle.handle, i.num))
}
Beispiel #6
0
func EndLibUsb() {
	Connected = false
	C.libusb_release_interface(keyboardHandle, 1)
	C.libusb_attach_kernel_driver(keyboardHandle, 1)
}