How to use the hidapi.close function in hidapi

To help you get started, we’ve selected a few hidapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pwr-Solaar / Solaar / lib / hidapi / hidconsole.py View on Github external
rlist, wlist, xlist = _select([handle], [], [], 1)
				if data[1:2] == b'\xFF':
					# the receiver will reply very fast, in a few milliseconds
					time.sleep(0.010)
				else:
					# the devices might reply quite slow
					time.sleep(0.700)
	except EOFError:
		if interactive:
			print ("")
		else:
			time.sleep(1)

	finally:
		print (".. Closing handle %r" % handle)
		_hid.close(handle)
		if interactive:
			readline.write_history_file(args.history)
github pwr-Solaar / Solaar / lib / logitech_receiver / base.py View on Github external
def close(handle):
	"""Closes a HID device handle."""
	if handle:
		try:
			if isinstance(handle, int):
				_hid.close(handle)
			else:
				handle.close()
			# _log.info("closed receiver handle %r", handle)
			return True
		except:
			# _log.exception("closing receiver handle %r", handle)
			pass

	return False