How to use the hidapi.open_path 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 / View on Github external
def _open(args):
	device = args.device
	if args.hidpp and not device:
		for d in _hid.enumerate(vendor_id=0x046d):
			if d.driver == 'logitech-djreceiver':
				device = d.path
		if not device:
			sys.exit("!! No HID++ receiver found.")
	if not device:
		sys.exit("!! Device path required.")

	print (".. Opening device", device)
	handle = _hid.open_path(device)
	if not handle:
		sys.exit("!! Failed to open %s, aborting." % device)

	print (".. Opened handle %r, vendor %r product %r serial %r." % (
	if args.hidpp:
		if _hid.get_manufacturer(handle) != b'Logitech':
			sys.exit("!! Only Logitech devices support the HID++ protocol.")
		print (".. HID++ validation enabled.")
		if (_hid.get_manufacturer(handle) == b'Logitech' and
			b'Receiver' in _hid.get_product(handle)):
			args.hidpp = True
github pwr-Solaar / Solaar / lib / logitech_receiver / View on Github external
def open_path(path):
	"""Checks if the given Linux device path points to the right UR device.

	:param path: the Linux device path.

	The UR physical device may expose multiple linux devices with the same
	interface, so we have to check for the right one. At this moment the only
	way to distinguish betheen them is to do a test ping on an invalid
	(attached) device number (i.e., 0), expecting a 'ping failed' reply.

	:returns: an open receiver handle if this is the right Linux device, or
	return _hid.open_path(path)