How to use the hidapi.hid_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 ppasler / current-adas / project / code / src / posdbos / source / emotiv.py View on Github external
Setup for headset on a non-windows platform.
        Receives packets from headset and sends them to a Queue to be processed
        by the crypto greenlet.
        """
        _os_decryption = False
        if os.path.exists('/dev/eeg/raw'):
            # The decryption is handled by the Linux epoc daemon. We don't need to handle it.
            _os_decryption = True
            hidraw = open("/dev/eeg/raw")
        path, serial_number = hid_enumerate()
        if len(path) == 0:
            print("Could not find device.")
            print_hid_enumerate()
            sys.exit()
        self.serial_number = serial_number
        device = hidapi.hid_open_path(path)
        crypto = gevent.spawn(self.setup_crypto, self.serial_number)
        gevent.sleep(DEVICE_POLL_INTERVAL)
        console_updater = gevent.spawn(self.update_console)
        while self.running:
            try:
                if _os_decryption:
                    data = hidraw.read(32)
                    if data != "":
                        self.packets.put_nowait(EmotivPacket(data, self.sensors, self.old_model))
                else:
                    # Doesn't seem to matter how big we make the buffer 32 returned every time, 33 for other platforms
                    data = hidapi.hid_read(device, 34)
                    if len(data) == 32:
                        # Most of the time the 0 is truncated? That's ok we'll add it... Could probably not do this...
                        data.insert(0, 0)
                    if data != "":
github EmokitAlife / EmokitVisualizer / emokit / reader.py View on Github external
Setup for headset on a non-windows platform.
        Receives packets from headset and sends them to a Queue to be processed
        by the crypto thread.
        """
        if os.path.exists('/dev/eeg/raw'):
            self.hid = open("/dev/eeg/raw")
        if self.hid is not None:
            # The decryption is handled by the Linux epoc daemon. We don't need to handle it.
            self.platform += " raw_eeg"
        else:
            path, serial_number = hid_enumerate(hidapi, self.platform)
            if len(path) == 0:
                print_hid_enumerate(system_platform, hidapi)
                raise Exception("Device not found")
            self.serial_number = serial_number
            self.hid = hidapi.hid_open_path(path)
github openyou / emokit / python / emokit / reader.py View on Github external
Setup for headset on a non-windows platform.
        Receives packets from headset and sends them to a Queue to be processed
        by the crypto thread.
        """
        if os.path.exists('/dev/eeg/raw'):
            self.hid = open("/dev/eeg/raw")
        if self.hid is not None:
            # The decryption is handled by the Linux epoc daemon. We don't need to handle it.
            self.platform += " raw_eeg"
        else:
            path, serial_number = hid_enumerate(hidapi, self.platform)
            if len(path) == 0:
                print_hid_enumerate(system_platform, hidapi)
                raise Exception("Device not found")
            self.serial_number = serial_number
            self.hid = hidapi.hid_open_path(path)