How to use the hidapi.hid_enumerate 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 hansfbaier / open-maschine / proof-of-concept / talk-with-maschine.py View on Github external
#!/usr/bin/env python

import hidapi
import binascii
import time

hidapi.hid_init()
    
print 'Loaded hidapi library from: {:s}\n'.format(hidapi.hid_lib_path())

devices = hidapi.hid_enumerate(0x17cc, 0x1140)
if len(devices) == 0:
    print "No maschine attached"
    exit(1)

device = hidapi.hid_open(0x17cc, 0x1140)

quiet_state = "20000000100020003000400050006000700080009000a000b000c000d000e000f0000000100020003000400050006000700080009000a000b000c000d000e000f0"

to_bytearray = lambda display: [bytearray(line.replace(" ", "").decode("hex")) for line in display]
write_display = lambda display: [hidapi.hid_write(device, line) for line in to_bytearray(display)]

def clear_display(no):
    for i in range(0, 8):
        hidapi.hid_write(device, (bytearray((("e00000%02x00200008" % (8 * i) + ((265 - 8) * "00")).replace("e0", "e%d" %no)).decode("hex"))))

led_state = bytearray("820a0a0a 0a0a0a0a 0a0a0a0a 0a0a0a0a 0a0a0a0a 0a0a0a0a 0a3f3f3f 3f3f3f3f".replace(" ", "").decode("hex"))
github ppasler / current-adas / project / code / src / posdbos / source / emotiv.py View on Github external
def print_hid_enumerate():
    """
    Loops over all devices in the hidapi and attempts prints information.

    This is a fall back method that give the user information to give the developers when opening an issue.
    """
    devices = hidapi.hid_enumerate()
    print "-------------------------"
    for device in devices:
        print device.manufacturer_string
        print device.product_string
        print device.path
        print device.vendor_id
        print device.product_id
        print device.serial_number
        print "-------------------------"
    print "Please include this information if you open a new issue."
github markllama / powerusb / powerusb / powerusb.py View on Github external
    @staticmethod
    def strips():
        """
        Return the set of connected power strips
        """
        hid_devices = hidapi.hid_enumerate(
            PowerUSBStrip._vendor_id,
            PowerUSBStrip._product_id
            )
        return [PowerUSBStrip(d) for d in hid_devices]
github ppasler / current-adas / project / code / src / posdbos / source / emotiv.py View on Github external
def hid_enumerate():
    """
    Loops over all devices in the hidapi and attempts to locate the emotiv headset.

    Since hidapi ultimately uses the path there is no reason to get the vendor id or product id.

    Although, they may be useful in locating the device.

    :returns
        path - the path to the device
        serial_number - the serial number of the device
    """
    path = ""
    serial_number = ""
    devices = hidapi.hid_enumerate()
    for device in devices:
        is_emotiv = False
        try:
            if "Emotiv" in device.manufacturer_string:
                is_emotiv = True
            if "Emotiv" in device.product_string:
                is_emotiv = True
            if "EPOC" in device.product_string:
                is_emotiv = True
            if "Brain Waves" in device.product_string:
                is_emotiv = True
            if device.product_string == '00000000000':
                is_emotiv = True
            if "EEG Signals" in device.product_string:
                is_emotiv = True