Пример #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")
}
Пример #2
0
func (i *Interface) Release() *UsbError {
	i.claimed--
	if i.claimed <= 0 {
		return returnUsbError(C.libusb_release_interface(i.handle.handle, i.num))
	}
	return nil
}
Пример #3
0
// Close releases the interface and closes the device. A device may not be
// opened again after calling this method. Returned errors may be safely
// ignored.
func (d *Device) Close() error {
	defer C.libusb_close(d.handle)

	if err := C.libusb_release_interface(d.handle, interfaceNum); err != C.LIBUSB_SUCCESS {
		return &libusbError{err}
	}
	return nil
}
Пример #4
0
// Close the device.
func (d *Device) Close() error {
	if d.handle == nil {
		return fmt.Errorf("usb: double close on device")
	}
	d.lock.Lock()
	defer d.lock.Unlock()
	for iface := range d.claimed {
		C.libusb_release_interface(d.handle, C.int(iface))
	}
	C.libusb_close(d.handle)
	d.handle = nil
	return nil
}
Пример #5
0
Файл: usb.go Проект: hanwen/usb
// Release an interface previously claimed with libusb_claim_interface().
func (h *DeviceHandle) ReleaseInterface(num byte) error {
	return toErr(C.libusb_release_interface(h.me(), C.int(num)))
}
Пример #6
0
func EndLibUsb() {
	Connected = false
	C.libusb_release_interface(keyboardHandle, 1)
	C.libusb_attach_kernel_driver(keyboardHandle, 1)
}