Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, file_name=None, mode="hid", hid=None, file=None, new_format=False, **kwargs):
self.mode = mode
self.file = file
self.file_name = file_name
self.hid = hid
self.new_format = new_format
self.platform = system_platform
self.serial_number = None
self.lock = Lock()
if self.platform != "Windows":
hidapi.hid_init()
self.setup_platform = {
'Windows': self.setup_windows,
'Darwin': self.setup_not_windows,
'Linux': self.setup_not_windows,
'Reader': self.setup_reader,
}
if self.mode == "csv":
if file_name is None:
raise ValueError("CSV file name must be specified when initializing an EmotivReader class using mode "
"'csv'.")
if sys.version_info >= (3, 0):
self.file = open(file_name, 'r')
else:
self.file = open(file_name, 'rb')
contents = self.file.read().split('\n')
#!/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):
Modified version of: https://github.com/openyou/emokit/blob/13512c5e078d0ff321709a31f19377fc9b7e18a1/python/emokit/emotiv.py
Use this script, as long as the current `master` of the emokit API is unstable.
'''
import os
import platform
import sys
system_platform = platform.system()
if system_platform == "Windows":
import pywinusb.hid as hid
else:
import hidapi #@UnresolvedImport
hidapi.hid_init()
import gevent
from Crypto.Cipher import AES
from Crypto import Random
from gevent.queue import Queue
from datetime import datetime
import csv
# How long to gevent-sleep if there is no data on the EEG.
# To be precise, this is not the frequency to poll on the input device
# (which happens with a blocking read), but how often the gevent thread
# polls the real threading queue that reads the data in a separate thread
# to not block gevent with the file read().
# This is the main latency control.
# Setting it to 1ms takes about 10% CPU on a Core i5 mobile.
# You can set this lower to reduce idle CPU usage; it has no effect
def open(self) -> None:
"""Opens the connection to the RoIP device."""
hidapi.hid_init()
self.hid_device = hidapi.hid_open(self.device[0], self.device[1])
self._logger.info('Opened hid_device="%s"', self.hid_device)
def __init__(self, file_name=None, mode="hid", hid=None, file=None, **kwargs):
self.mode = mode
self.file = file
self.file_name = file_name
self.hid = hid
self.platform = system_platform
self.serial_number = None
self.lock = Lock()
if self.platform != "Windows":
hidapi.hid_init()
self.setup_platform = {
'Windows': self.setup_windows,
'Darwin': self.setup_not_windows,
'Linux': self.setup_not_windows,
'Reader': self.setup_reader,
}
if self.mode == "csv":
if file_name is None:
raise ValueError("CSV file name must be specified when initializing an EmotivReader class using mode "
"'csv'.")
if sys.version_info >= (3, 0):
self.file = open(file_name, 'r')
else:
self.file = open(file_name, 'rb')
self.reader = csv.reader(self.file, quoting=csv.QUOTE_ALL)
from dali.frame import BackwardFrame
from dali.frame import BackwardFrameError
from dali.exceptions import BadDevice
from dali.exceptions import DeviceAlreadyBound
from dali.exceptions import DuplicateDevice
from dali.exceptions import NoFreeAddress
from dali.exceptions import NotConnected
from dali.exceptions import ProgramShortAddressFailure
import dali.gear.general as gear
import time
import hidapi
hidapi.hid_init()
HASSEB_USB_VENDOR = 0x04cc
HASSEB_USB_PRODUCT = 0x0802
HASSEB_READ_FIRMWARE_VERSION = 0x02
HASSEB_CONFIGURE_DEVICE = 0x05
HASSEB_DALI_FRAME = 0X07
HASSEB_DRIVER_NO_DATA_AVAILABLE = 0
HASSEB_DRIVER_NO_ANSWER = 1
HASSEB_DRIVER_OK = 2
HASSEB_DRIVER_INVALID_ANSWER = 3
HASSEB_DRIVER_TOO_EARLY = 4
HASSEB_DRIVER_SNIFFER_BYTE = 5
HASSEB_DRIVER_SNIFFER_BYTE_ERROR = 6