Exemple #1
0
 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]
Exemple #2
0
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

            if is_emotiv:
                serial_number = device.serial_number
                path = device.path
        except:
            pass
    return path, serial_number
Exemple #3
0
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

            if is_emotiv:
                serial_number = device.serial_number
                path = device.path
        except:
            pass
    return path, serial_number
Exemple #4
0
 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]
Exemple #5
0
    def __init__(self):
        self.seq1 = 0x0001
        self.seq2 = 0x0068
        self.handle = None

        # Setup Device
        hidapi.hid_init()
        for dev in hidapi.hid_enumerate(vendor_id=0x03eb, product_id=0x2013):
            self.handle = hidapi.hid_open_path(dev.path)

        self.tx_type1(self.handle, '*IDN?')
        self.info = self.rx(self.handle)
Exemple #6
0
def SyncHassebDALIUSBDriverFactory():
    """Enumerates Hasseb DALI masters and instantiates `SyncHassebDALIUSBDriver`s
    for each one of them.
    """

    hasseb_dali_drivers = []

    hasseb_hid_devices = hidapi.hid_enumerate(HASSEB_USB_VENDOR,
                                              HASSEB_USB_PRODUCT)
    for hasseb_hid_device in hasseb_hid_devices:
        logging.getLogger("SyncHassebDALIUSBDriverFactory").debug(
            "device found, path is {}".format(hasseb_hid_device.path))
        hasseb_dali_drivers.append(
            SyncHassebDALIUSBDriver(hasseb_hid_device.path))

    return hasseb_dali_drivers
Exemple #7
0
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.")
Exemple #8
0
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."
def find_init_emotiv_non_windows():
    global g_serial_number
    global g_os_decryption
    global g_device
    global g_old_model

    device_path = ''
    devices = hidapi.hid_enumerate()
    for device in devices:
        is_emotiv = False
        try:
            if "Emotiv" in device.manufacturer_string:
                is_emotiv = True
            elif "Emotiv" in device.product_string:
                is_emotiv = True
            elif "EPOC" in device.product_string:
                is_emotiv = True
            elif "Brain Waves" in device.product_string:
                is_emotiv = True
            elif device.product_string == '00000000000':
                is_emotiv = True
            elif "EEG Signals" in device.product_string:
                is_emotiv = True

            if is_emotiv:
                g_serial_number = device.serial_number
                device_path = device.path
                break
        except:
            pass

    if g_serial_number == '':
        print("Could not find device.")
        shutdown_everything()
        return

    g_old_model = is_old_model(g_serial_number)
    g_os_decryption = os.path.exists('/dev/eeg/raw')
    if g_os_decryption:
        g_device = open("/dev/eeg/raw")
    else:
        try:
            g_device = hidapi.hid_open_path(device_path)
        except Exception, ex:
            print ex.message
            shutdown_everything()
Exemple #10
0
##########################################################################
# Copyright (C) 2014 Mark J. Blair, NF6X
#
# This file is part of pyhidapi.
#
#  pyhidapi is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  pyhidapi is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with pyhidapi.  If not, see <http://www.gnu.org/licenses/>.
##########################################################################
"""Enumerate all HID devices on the system."""

import hidapi

if __name__ == '__main__':
    hidapi.hid_init()

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

    for dev in hidapi.hid_enumerate():
        print '------------------------------------------------------------'
        print dev.description()
# This file is part of pyhidapi.
#
#  pyhidapi is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  pyhidapi is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with pyhidapi.  If not, see <http://www.gnu.org/licenses/>.
##########################################################################

"""Enumerate all HID devices on the system."""

import hidapi

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

    for dev in hidapi.hid_enumerate():
        print '------------------------------------------------------------'
        print dev.description()


Exemple #12
0
#!/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(0x0483, 0x5750)
if len(devices) == 0:
    print "No dev attached"
    exit(1)

device = hidapi.hid_open(0x0483, 0x5750)


import random
while True:
    result = hidapi.hid_read(device, 4)
    state = binascii.hexlify(result)
    print "#%d: %s"  % (len(result), state)

hidapi.hid_close(device)
#!/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"))
hidapi.hid_write(device, led_state)

def import_image(display_no, fname):
    import textwrap
Exemple #14
0
def tx_type2(handle, msg):
    msg = bytes('@', 'utf-8') + seq2.to_bytes(1, byteorder='big') + bytes('{}\n@@@@@@@@@@@@@'.format(msg), 'utf-8')
    hidapi.hid_write(handle, msg)

def rx(handle, numBytes=0x10):
    return hidapi.hid_read_timeout(handle, numBytes, 1000)

def getPpm(handle):
    tx_type2(handle, '*TR')
    return int.from_bytes(rx(handle)[2:4], byteorder='little')


# Setup Device
hidapi.hid_init()
for dev in hidapi.hid_enumerate(vendor_id=0x03eb, product_id=0x2013):
    handle = hidapi.hid_open_path(dev.path) 

print('reading info from device')
tx_type1(handle, '*IDN?')
info = rx(handle) + rx(handle) + rx(handle) + rx(handle) + rx(handle) + rx(handle) + rx(handle)
print('ret:"' + str(info) + '"')


# Setup Chart
data_x = []
data_y = []

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
Exemple #15
0
def dump_all_devices():
    for dev in hidapi.hid_enumerate():
        print dev.description()