How to use the hidapi.get_serial 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
break
		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." % (
					handle,
					_hid.get_manufacturer(handle),
					_hid.get_product(handle),
					_hid.get_serial(handle)))
	if args.hidpp:
		if _hid.get_manufacturer(handle) != b'Logitech':
			sys.exit("!! Only Logitech devices support the HID++ protocol.")
		print (".. HID++ validation enabled.")
	else:
		if (_hid.get_manufacturer(handle) == b'Logitech' and
			b'Receiver' in _hid.get_product(handle)):
			args.hidpp = True
			print (".. Logitech receiver detected, HID++ validation enabled.")

	return handle