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