How to use the hidapi.hid_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 openyou / emokit / python / emokit / reader.py View on Github external
else:
                time.sleep(0.00001)
            self.lock.acquire()
            if self._stop_signal:
                print("Reader stopping...")
                self.running = False
        if self.file is not None:
            self.file.close()
        if type(source) != int and type(source) != list:
            source.close()
        if self.hid is not None:
            if type(self.hid) != int:
                self.hid.close()
        if system_platform != "Windows":
            try:
                hidapi.hid_close(source)
            except Exception:
                pass
            try:
                hidapi.hid_exit()
            except Exception:
                pass
        print("Reader stopped...")
        self.stopped = True
        return
github ppasler / current-adas / project / code / src / posdbos / source / emotiv.py View on Github external
# Queue it!
                            if self.write and self.write_raw:
                                self.write_data(data)
                            tasks.put_nowait(''.join(map(chr, data[1:])))
                            self.packets_received += 1
                gevent.sleep(DEVICE_POLL_INTERVAL)
            except KeyboardInterrupt:
                self.running = False
            except Exception, ex:
                print("Setup emotiv.py(line=710): %s" % ex.message)
                self.running = False
            gevent.sleep(DEVICE_POLL_INTERVAL)
        if _os_decryption:
            hidraw.close()
        else:
            hidapi.hid_close(device)
        gevent.kill(crypto, KeyboardInterrupt)
        gevent.kill(console_updater, KeyboardInterrupt)
github hansfbaier / open-maschine / proof-of-concept / talk-with-maschine.py View on Github external
# 16 rgb buttons
        pad_state = bytearray(("80" + ''.join(format(random.randint(0,255), '02x') for _ in range(16 * 3))).decode("hex"))
        hidapi.hid_write(device, pad_state)

        # 8 group rgb_1 + 8 group rgb_2 + 8 transport buttons
        group_other_btn_state = bytearray(("81" + ''.join(format(random.randint(0,255), '02x') for _ in range(((8 + 8) * 3) + 8))).decode("hex"))
        hidapi.hid_write(device, group_other_btn_state)

        count = 0

    result = hidapi.hid_read(device, 256)
    state = binascii.hexlify(result)
    if state != quiet_state:
        print "#%d: %s"  % (len(result), state)

hidapi.hid_close(device)
github ampledata / roip / roip / classes.py View on Github external
def close(self) -> None:
        """Closes the connection to the RoIP device."""
        self.hid_device = hidapi.hid_close(self.hid_device)
github openyou / emokit / python / emokit / reader.py View on Github external
def __exit__(self, exc_type, exc_value, traceback):
        self.stop()
        if self.reader:
            self.reader.close()
        self.file.close()
        if 'eeg_raw' in self.platform and self.hid is not None:
            self.hid.close()
        elif 'Windows' not in self.platform and self.hid is not None:
            hidapi.hid_close(self.hid)