Esempio n. 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")
}
Esempio n. 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
}
Esempio n. 3
0
File: usb.go Progetto: 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)))
}
Esempio n. 4
0
File: device.go Progetto: ebfe/gousb
// 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
}
Esempio n. 5
0
File: usb.go Progetto: thequux/gousb
func (i *Interface) AttachKernelDriver() *UsbError {
	return returnUsbError(C.libusb_attach_kernel_driver(i.handle.handle, i.num))
}
Esempio n. 6
0
func EndLibUsb() {
	Connected = false
	C.libusb_release_interface(keyboardHandle, 1)
	C.libusb_attach_kernel_driver(keyboardHandle, 1)
}